From 99dd8eeff06c2b61bc907325335db33988f58aa1 Mon Sep 17 00:00:00 2001 From: kmdjs Date: Sat, 30 Apr 2016 05:34:37 +0800 Subject: [PATCH 1/7] now, you can close tow-way binding when using super large data list --- dist/nuclear.js | 16 ++++++++++------ dist/nuclear.min.js | 2 +- src/nuclear.js | 16 ++++++++++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dist/nuclear.js b/dist/nuclear.js index ef64ca26d..8725002a1 100644 --- a/dist/nuclear.js +++ b/dist/nuclear.js @@ -18,18 +18,22 @@ var Nuclear={}; -Nuclear.create = function (obj) { - Nuclear._mixObj(obj); +Nuclear.create = function (obj, setting) { + Nuclear._mixObj(obj,setting); var currentEvn = this === Nuclear ? Nuclear.Class : this; - var component = currentEvn.extend(obj); + var component = currentEvn.extend(obj,setting); component.create = Nuclear.create; return component; }; -Nuclear._mixObj = function (obj) { +Nuclear._mixObj = function (obj,setting) { obj.ctor = function (option, selector) { this._ncInstanceId=Nuclear.getInstanceId(); - //加window防止构建到webpack中,Nuclear是局部而非全局 + this._nuclearTwoWay = true; + if(setting.twoWay === false) { + this._nuclearTwoWay = false; + } + //加window防止构建到webpack中,Nuclear是局部而非全局 window.Nuclear.instances[this._ncInstanceId] = this; this._nuclearParentEmpty = !selector; this.HTML = ""; @@ -60,7 +64,7 @@ Nuclear._mixObj = function (obj) { this._nuclearTimer = null; this._preNuclearTime = new Date(); - if (this.option) { + if (this.option && this._nuclearTwoWay) { Nuclear.observe(this.option, function (prop, value, oldValue, path) { if (!this.onOptionChange||(this.onOptionChange && this.onOptionChange(prop, value, oldValue, path)!==false)) { clearTimeout(this._nuclearTimer); diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js index 89cc4f535..51ed605ba 100644 --- a/dist/nuclear.min.js +++ b/dist/nuclear.min.js @@ -3,4 +3,4 @@ * Github: https://github.com/AlloyTeam/Nuclear * MIT Licensed. */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():"function"==typeof define&&define.cmd&&define(function(e,n,r){r.exports=t()}),e.Nuclear=t()}(window,function(){var e={};return e.create=function(t){e._mixObj(t);var n=this===e?e.Class:this,r=n.extend(t);return r.create=e.create,r},e._mixObj=function(t){t.ctor=function(t,n){if(this._ncInstanceId=e.getInstanceId(),window.Nuclear.instances[this._ncInstanceId]=this,this._nuclearParentEmpty=!n,this.HTML="",this.option=t,this._nuclearParentEmpty)this.parent=document.createElement("div");else if(this.parent="string"==typeof n?document.querySelector(n):n,document.body!==this.parent)for(;this.parent.firstChild;)this.parent.removeChild(this.parent.firstChild);this.install&&this.install(),this._nuclearRef=[];for(var r in this)this.hasOwnProperty(r)&&this[r]&&this[r]._nuclearLocalRefresh&&(this[r]._nuclearParent=this,this._nuclearRef.push(this[r]));this._nuclearTimer=null,this._preNuclearTime=new Date,this.option&&e.observe(this.option,function(e,t,n,r){(!this.onOptionChange||this.onOptionChange&&this.onOptionChange(e,t,n,r)!==!1)&&(clearTimeout(this._nuclearTimer),new Date-this._preNuclearTime>40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,A=new l(t);!A.eos();){if(I=A.pos,C=A.scanUntil(u))for(var k=0,S=C.length;S>k;++k)$=C.charAt(k),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!A.scan(u))break;if(x=!0,T=A.scan(w)||"name",A.scan(g),"="===T?(C=A.scanUntil(m),A.scan(m),A.scanUntil(h)):"{"===T?(C=A.scanUntil(p),A.scan(_),A.scanUntil(h),T="&"):C=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(E=[T,C,I,A.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,A=new l(t);!A.eos();){if(I=A.pos,C=A.scanUntil(u))for(var k=0,S=C.length;S>k;++k)$=C.charAt(k),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!A.scan(u))break;if(x=!0,T=A.scan(w)||"name",A.scan(g),"="===T?(C=A.scanUntil(m),A.scan(m),A.scanUntil(h)):"{"===T?(C=A.scanUntil(p),A.scan(_),A.scanUntil(h),T="&"):C=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(E=[T,C,I,A.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i Date: Sat, 30 Apr 2016 05:35:12 +0800 Subject: [PATCH 2/7] now, you can close tow-way binding when using super large data list --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b3b3fb6f..a1f9905d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alloynuclear", - "version": "0.1.3", + "version": "0.1.4", "description": "made UI super easy.", "main": "nuclear.js", "scripts": { From 2d4ab0c2a104b7b50287d2128fd8f9dd92207b88 Mon Sep 17 00:00:00 2001 From: kmdjs Date: Sat, 30 Apr 2016 05:41:13 +0800 Subject: [PATCH 3/7] now, you can close tow-way binding when using super large data list --- dist/nuclear.js | 2 +- dist/nuclear.min.js | 2 +- package.json | 2 +- src/nuclear.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/nuclear.js b/dist/nuclear.js index 8725002a1..bb8521e78 100644 --- a/dist/nuclear.js +++ b/dist/nuclear.js @@ -30,7 +30,7 @@ Nuclear._mixObj = function (obj,setting) { obj.ctor = function (option, selector) { this._ncInstanceId=Nuclear.getInstanceId(); this._nuclearTwoWay = true; - if(setting.twoWay === false) { + if(setting&&setting.twoWay === false) { this._nuclearTwoWay = false; } //加window防止构建到webpack中,Nuclear是局部而非全局 diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js index 51ed605ba..13ced08e3 100644 --- a/dist/nuclear.min.js +++ b/dist/nuclear.min.js @@ -3,4 +3,4 @@ * Github: https://github.com/AlloyTeam/Nuclear * MIT Licensed. */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():"function"==typeof define&&define.cmd&&define(function(e,n,r){r.exports=t()}),e.Nuclear=t()}(window,function(){var e={};return e.create=function(t,n){e._mixObj(t,n);var r=this===e?e.Class:this,o=r.extend(t,n);return o.create=e.create,o},e._mixObj=function(t,n){t.ctor=function(t,r){if(this._ncInstanceId=e.getInstanceId(),this._nuclearTwoWay=!0,n.twoWay===!1&&(this._nuclearTwoWay=!1),window.Nuclear.instances[this._ncInstanceId]=this,this._nuclearParentEmpty=!r,this.HTML="",this.option=t,this._nuclearParentEmpty)this.parent=document.createElement("div");else if(this.parent="string"==typeof r?document.querySelector(r):r,document.body!==this.parent)for(;this.parent.firstChild;)this.parent.removeChild(this.parent.firstChild);this.install&&this.install(),this._nuclearRef=[];for(var o in this)this.hasOwnProperty(o)&&this[o]&&this[o]._nuclearLocalRefresh&&(this[o]._nuclearParent=this,this._nuclearRef.push(this[o]));this._nuclearTimer=null,this._preNuclearTime=new Date,this.option&&this._nuclearTwoWay&&e.observe(this.option,function(e,t,n,r){(!this.onOptionChange||this.onOptionChange&&this.onOptionChange(e,t,n,r)!==!1)&&(clearTimeout(this._nuclearTimer),new Date-this._preNuclearTime>40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,A=new l(t);!A.eos();){if(I=A.pos,C=A.scanUntil(u))for(var k=0,S=C.length;S>k;++k)$=C.charAt(k),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!A.scan(u))break;if(x=!0,T=A.scan(w)||"name",A.scan(g),"="===T?(C=A.scanUntil(m),A.scan(m),A.scanUntil(h)):"{"===T?(C=A.scanUntil(p),A.scan(_),A.scanUntil(h),T="&"):C=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(E=[T,C,I,A.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,A=new l(t);!A.eos();){if(I=A.pos,C=A.scanUntil(u))for(var k=0,S=C.length;S>k;++k)$=C.charAt(k),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!A.scan(u))break;if(x=!0,T=A.scan(w)||"name",A.scan(g),"="===T?(C=A.scanUntil(m),A.scan(m),A.scanUntil(h)):"{"===T?(C=A.scanUntil(p),A.scan(_),A.scanUntil(h),T="&"):C=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(E=[T,C,I,A.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i Date: Sat, 30 Apr 2016 05:47:40 +0800 Subject: [PATCH 4/7] now, you can close tow-way binding when using super large data list --- dist/nuclear.js | 9 +++++---- dist/nuclear.min.js | 2 +- src/nuclear.js | 9 +++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dist/nuclear.js b/dist/nuclear.js index bb8521e78..1564e0e1c 100644 --- a/dist/nuclear.js +++ b/dist/nuclear.js @@ -19,18 +19,19 @@ var Nuclear={}; Nuclear.create = function (obj, setting) { - Nuclear._mixObj(obj,setting); + obj._nuclearSetting = setting; + Nuclear._mixObj(obj); var currentEvn = this === Nuclear ? Nuclear.Class : this; - var component = currentEvn.extend(obj,setting); + var component = currentEvn.extend(obj); component.create = Nuclear.create; return component; }; -Nuclear._mixObj = function (obj,setting) { +Nuclear._mixObj = function (obj) { obj.ctor = function (option, selector) { this._ncInstanceId=Nuclear.getInstanceId(); this._nuclearTwoWay = true; - if(setting&&setting.twoWay === false) { + if(this._nuclearSetting&&this._nuclearSetting.twoWay === false) { this._nuclearTwoWay = false; } //加window防止构建到webpack中,Nuclear是局部而非全局 diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js index 13ced08e3..cd570a838 100644 --- a/dist/nuclear.min.js +++ b/dist/nuclear.min.js @@ -3,4 +3,4 @@ * Github: https://github.com/AlloyTeam/Nuclear * MIT Licensed. */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():"function"==typeof define&&define.cmd&&define(function(e,n,r){r.exports=t()}),e.Nuclear=t()}(window,function(){var e={};return e.create=function(t,n){e._mixObj(t,n);var r=this===e?e.Class:this,o=r.extend(t,n);return o.create=e.create,o},e._mixObj=function(t,n){t.ctor=function(t,r){if(this._ncInstanceId=e.getInstanceId(),this._nuclearTwoWay=!0,n&&n.twoWay===!1&&(this._nuclearTwoWay=!1),window.Nuclear.instances[this._ncInstanceId]=this,this._nuclearParentEmpty=!r,this.HTML="",this.option=t,this._nuclearParentEmpty)this.parent=document.createElement("div");else if(this.parent="string"==typeof r?document.querySelector(r):r,document.body!==this.parent)for(;this.parent.firstChild;)this.parent.removeChild(this.parent.firstChild);this.install&&this.install(),this._nuclearRef=[];for(var o in this)this.hasOwnProperty(o)&&this[o]&&this[o]._nuclearLocalRefresh&&(this[o]._nuclearParent=this,this._nuclearRef.push(this[o]));this._nuclearTimer=null,this._preNuclearTime=new Date,this.option&&this._nuclearTwoWay&&e.observe(this.option,function(e,t,n,r){(!this.onOptionChange||this.onOptionChange&&this.onOptionChange(e,t,n,r)!==!1)&&(clearTimeout(this._nuclearTimer),new Date-this._preNuclearTime>40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,A=new l(t);!A.eos();){if(I=A.pos,C=A.scanUntil(u))for(var k=0,S=C.length;S>k;++k)$=C.charAt(k),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!A.scan(u))break;if(x=!0,T=A.scan(w)||"name",A.scan(g),"="===T?(C=A.scanUntil(m),A.scan(m),A.scanUntil(h)):"{"===T?(C=A.scanUntil(p),A.scan(_),A.scanUntil(h),T="&"):C=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(E=[T,C,I,A.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,S=new l(t);!S.eos();){if(I=S.pos,C=S.scanUntil(u))for(var A=0,k=C.length;k>A;++A)$=C.charAt(A),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!S.scan(u))break;if(x=!0,T=S.scan(w)||"name",S.scan(g),"="===T?(C=S.scanUntil(m),S.scan(m),S.scanUntil(h)):"{"===T?(C=S.scanUntil(p),S.scan(_),S.scanUntil(h),T="&"):C=S.scanUntil(h),!S.scan(h))throw new Error("Unclosed tag at "+S.pos);if(E=[T,C,I,S.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+S.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i Date: Sat, 30 Apr 2016 06:12:09 +0800 Subject: [PATCH 5/7] wording --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d5be61e56..98028be0e 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,14 @@ Some HTML + Scoped CSS + JS === Reusable Component ![preview](http://alloyteam.github.io/Nuclear/img/guide.png) -We have several examples on [the website](http://alloyteam.github.io/Nuclear/en.html). +Several examples on [the website](http://alloyteam.github.io/Nuclear/en.html). +Performance-testing on [the website](http://alloyteam.github.io/Nuclear/pt/). # Install -the file is here: [nuclear.js](https://raw.githubusercontent.com/AlloyTeam/Nuclear/master/dist/nuclear.js) or [nuclear.min.js](https://raw.githubusercontent.com/AlloyTeam/Nuclear/master/dist/nuclear.min.js) - -You can also install it via npm: +You can install it via npm: ```html npm install alloynuclear From 02a8b2c14d264fedca2c244b22a472096f1a09b9 Mon Sep 17 00:00:00 2001 From: kmdjs Date: Sat, 30 Apr 2016 06:17:11 +0800 Subject: [PATCH 6/7] wording --- dist/nuclear.js | 1 + dist/nuclear.min.js | 2 +- package.json | 2 +- src/scoper.js | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/nuclear.js b/dist/nuclear.js index 1564e0e1c..26019e14e 100644 --- a/dist/nuclear.js +++ b/dist/nuclear.js @@ -1212,6 +1212,7 @@ Nuclear.Class.extend = function (prop) { if ("scoped" in document.createElement("style")) { + Nuclear.refreshStyle= function(){}; return; } diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js index cd570a838..c74e9b0c5 100644 --- a/dist/nuclear.min.js +++ b/dist/nuclear.min.js @@ -3,4 +3,4 @@ * Github: https://github.com/AlloyTeam/Nuclear * MIT Licensed. */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():"function"==typeof define&&define.cmd&&define(function(e,n,r){r.exports=t()}),e.Nuclear=t()}(window,function(){var e={};return e.create=function(t,n){t._nuclearSetting=n,e._mixObj(t);var r=this===e?e.Class:this,o=r.extend(t);return o.create=e.create,o},e._mixObj=function(t){t.ctor=function(t,n){if(this._ncInstanceId=e.getInstanceId(),this._nuclearTwoWay=!0,this._nuclearSetting&&this._nuclearSetting.twoWay===!1&&(this._nuclearTwoWay=!1),window.Nuclear.instances[this._ncInstanceId]=this,this._nuclearParentEmpty=!n,this.HTML="",this.option=t,this._nuclearParentEmpty)this.parent=document.createElement("div");else if(this.parent="string"==typeof n?document.querySelector(n):n,document.body!==this.parent)for(;this.parent.firstChild;)this.parent.removeChild(this.parent.firstChild);this.install&&this.install(),this._nuclearRef=[];for(var r in this)this.hasOwnProperty(r)&&this[r]&&this[r]._nuclearLocalRefresh&&(this[r]._nuclearParent=this,this._nuclearRef.push(this[r]));this._nuclearTimer=null,this._preNuclearTime=new Date,this.option&&this._nuclearTwoWay&&e.observe(this.option,function(e,t,n,r){(!this.onOptionChange||this.onOptionChange&&this.onOptionChange(e,t,n,r)!==!1)&&(clearTimeout(this._nuclearTimer),new Date-this._preNuclearTime>40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,E,R,S=new l(t);!S.eos();){if(I=S.pos,C=S.scanUntil(u))for(var A=0,k=C.length;k>A;++A)$=C.charAt(A),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!S.scan(u))break;if(x=!0,T=S.scan(w)||"name",S.scan(g),"="===T?(C=S.scanUntil(m),S.scan(m),S.scanUntil(h)):"{"===T?(C=S.scanUntil(p),S.scan(_),S.scanUntil(h),T="&"):C=S.scanUntil(h),!S.scan(h))throw new Error("Unclosed tag at "+S.pos);if(E=[T,C,I,S.pos],v.push(E),"#"===T||"^"===T)f.push(E);else if("/"===T){if(R=f.pop(),!R)throw new Error('Unopened section "'+C+'" at '+I);if(R[1]!==C)throw new Error('Unclosed section "'+R[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(R=f.pop())throw new Error('Unclosed section "'+R[1]+'" at '+S.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,S,E,R=new l(t);!R.eos();){if(I=R.pos,C=R.scanUntil(u))for(var A=0,k=C.length;k>A;++A)$=C.charAt(A),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!R.scan(u))break;if(x=!0,T=R.scan(w)||"name",R.scan(g),"="===T?(C=R.scanUntil(m),R.scan(m),R.scanUntil(h)):"{"===T?(C=R.scanUntil(p),R.scan(_),R.scanUntil(h),T="&"):C=R.scanUntil(h),!R.scan(h))throw new Error("Unclosed tag at "+R.pos);if(S=[T,C,I,R.pos],v.push(S),"#"===T||"^"===T)f.push(S);else if("/"===T){if(E=f.pop(),!E)throw new Error('Unopened section "'+C+'" at '+I);if(E[1]!==C)throw new Error('Unclosed section "'+E[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(E=f.pop())throw new Error('Unclosed section "'+E[1]+'" at '+R.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i Date: Sun, 1 May 2016 21:17:00 +0800 Subject: [PATCH 7/7] change Nuclear.Tpl.render to Nuclear.render --- dist/nuclear.js | 7 ++++--- dist/nuclear.min.js | 2 +- example/arttemplate.html | 2 +- package.json | 2 +- src/nuclear.js | 6 +++--- src/tpl.js | 1 + 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dist/nuclear.js b/dist/nuclear.js index 26019e14e..488475346 100644 --- a/dist/nuclear.js +++ b/dist/nuclear.js @@ -135,14 +135,14 @@ Nuclear._mixObj = function (obj) { this.node = null; this.HTML = ""; } else { - var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); + var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); item.parent.replaceChild(newNode, this.node); this.node = newNode; } } else { //第一次渲染 if (!Nuclear.isUndefined(item.tpl)) { - item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); + item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); this.node = item.parent.lastChild; } } @@ -224,7 +224,7 @@ Nuclear._mixObj = function (obj) { var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length; item.tpl = this._nuclearTplGenerator(); if (rpLen > 0) { - var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]'); + var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]'); window["_nuclearIndex"] = null; for (var j = 0; j < rpLen; j++) { var part = item.refreshPart[j]; @@ -337,6 +337,7 @@ Nuclear.instances = {}; ;(function defineMustache (global, factory) { Nuclear.Tpl = {}; factory(Nuclear.Tpl); // script, wsh, asp + Nuclear.render=Nuclear.Tpl.render; }(this, function mustacheFactory (mustache) { var objectToString = Object.prototype.toString; diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js index c74e9b0c5..cc3a56b48 100644 --- a/dist/nuclear.min.js +++ b/dist/nuclear.min.js @@ -3,4 +3,4 @@ * Github: https://github.com/AlloyTeam/Nuclear * MIT Licensed. */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():"function"==typeof define&&define.cmd&&define(function(e,n,r){r.exports=t()}),e.Nuclear=t()}(window,function(){var e={};return e.create=function(t,n){t._nuclearSetting=n,e._mixObj(t);var r=this===e?e.Class:this,o=r.extend(t);return o.create=e.create,o},e._mixObj=function(t){t.ctor=function(t,n){if(this._ncInstanceId=e.getInstanceId(),this._nuclearTwoWay=!0,this._nuclearSetting&&this._nuclearSetting.twoWay===!1&&(this._nuclearTwoWay=!1),window.Nuclear.instances[this._ncInstanceId]=this,this._nuclearParentEmpty=!n,this.HTML="",this.option=t,this._nuclearParentEmpty)this.parent=document.createElement("div");else if(this.parent="string"==typeof n?document.querySelector(n):n,document.body!==this.parent)for(;this.parent.firstChild;)this.parent.removeChild(this.parent.firstChild);this.install&&this.install(),this._nuclearRef=[];for(var r in this)this.hasOwnProperty(r)&&this[r]&&this[r]._nuclearLocalRefresh&&(this[r]._nuclearParent=this,this._nuclearRef.push(this[r]));this._nuclearTimer=null,this._preNuclearTime=new Date,this.option&&this._nuclearTwoWay&&e.observe(this.option,function(e,t,n,r){(!this.onOptionChange||this.onOptionChange&&this.onOptionChange(e,t,n,r)!==!1)&&(clearTimeout(this._nuclearTimer),new Date-this._preNuclearTime>40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.Tpl.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,S,E,R=new l(t);!R.eos();){if(I=R.pos,C=R.scanUntil(u))for(var A=0,k=C.length;k>A;++A)$=C.charAt(A),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!R.scan(u))break;if(x=!0,T=R.scan(w)||"name",R.scan(g),"="===T?(C=R.scanUntil(m),R.scan(m),R.scanUntil(h)):"{"===T?(C=R.scanUntil(p),R.scan(_),R.scanUntil(h),T="&"):C=R.scanUntil(h),!R.scan(h))throw new Error("Unclosed tag at "+R.pos);if(S=[T,C,I,R.pos],v.push(S),"#"===T||"^"===T)f.push(S);else if("/"===T){if(E=f.pop(),!E)throw new Error('Unopened section "'+C+'" at '+I);if(E[1]!==C)throw new Error('Unclosed section "'+E[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(E=f.pop())throw new Error('Unclosed section "'+E[1]+'" at '+R.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i40?(this._nuclearLocalRefresh(),this._preNuclearTime=new Date):this._nuclearTimer=setTimeout(function(){this._nuclearLocalRefresh()}.bind(this),40))}.bind(this)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this.option._nuclearIndex=function(){return++window._nuclearIndex||(window._nuclearIndex=0)},this.option._resetNuclearIndex=function(){window._nuclearIndex=-1},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},t.refresh=function(){this._nuclearLocalRefresh()},t.render&&(t._nuclearTplGenerator=t.render),t.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},t._nuclearRender=function(t){if(this.node)if(e.isUndefined(t.tpl))t.parent.removeChild(this.node),this.node=null,this.HTML="";else{var n=e.str2Dom(this._nuclearWrap(e.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data)));t.parent.replaceChild(n,this.node),this.node=n}else e.isUndefined(t.tpl)||(t.parent.insertAdjacentHTML("beforeEnd",this._nuclearWrap(e.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))),this.node=t.parent.lastChild);window._nuclearIndex=null,this.node&&(this._nuclearId=e.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this._mixNode(),t.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh())},t._mixNode=function(){var e=this.node.querySelectorAll("*[nc-id]"),t=e.length;if(t>0)for(var n=0;t>n;n++){var r=e[n];this[r.getAttribute("nc-id")]=r}var o=this.node.querySelectorAll("*[nc-class]"),i=o.length;if(i>0)for(var s=0;i>s;s++){var a=o[s],c=a.getAttribute("nc-class");this[c]||(this[c]=[]),this[c].push(a)}},t._nuclearFix=function(){this._nuclearParent||this._nuclearFixOne(this)},t._nuclearFixOne=function(e){var t=e._nuclearRef.length;if(t>0)for(var n=0;t>n;n++){var r=e._nuclearRef[n];r.node=e.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r.node&&(r._mixNode(),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,this._nuclearFixOne(r),r.onRefresh&&r.onRefresh(),r.installed&&r.installed())}},t._nuclearWrap=function(e){var t="";return this.style&&(t=""),"
"+e+t+"
"},t._nuclearLocalRefresh=function(){var t=this._nuclearRenderInfo,n=t.refreshPart.length;if(t.tpl=this._nuclearTplGenerator(),n>0){var r=e.str2Dom(this._nuclearWrap(e.render(e._fixEvent(e._fixTplIndex(t.tpl),this._ncInstanceId),t.data))).querySelectorAll("*[nc-refresh]");window._nuclearIndex=null;for(var o=0;n>o;o++){var i=t.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}t.refreshPart=r,this._mixNode(),this.HTML=this.node.outerHTML,this._nuclearFix(),this.onRefresh&&this.onRefresh()}else this._nuclearRender(t);e.refreshStyle()}},e._fixEvent=function(e,t){return e.replace(/<[\s\S]*?>/g,function(e){return e.replace(/(onabort|onblur|oncancel|oncanplay|oncanplaythrough|onchange|onclick|onclose|oncontextmenu|oncuechange|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|ondurationchange|onemptied|onended|onerror|onfocus|oninput|oninvalid|onkeydown|onkeypress|onkeyup|onload|onloadeddata|onloadedmetadata|onloadstart|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseout|onmouseover|onmouseup|onmousewheel|onpause|onplay|onplaying|onprogress|onratechange|onreset|onresize|onscroll|onseeked|onseeking|onselect|onshow|onstalled|onsubmit|onsuspend|ontimeupdate|ontoggle|onvolumechange|onwaiting|onautocomplete|onautocompleteerror|onbeforecopy|onbeforecut|onbeforepaste|oncopy|oncut|onpaste|onsearch|onselectstart|onwheel|onwebkitfullscreenchange|onwebkitfullscreenerror)=('|")/g,function(e,n,r,o,i){return"Nuclear.instances["===i.substr(e.length+o,18)?e:e+="Nuclear.instances["+t+"]."})})},e._fixTplIndex=function(e){return e.replace(/{{#[\s\S]*?{{@index}}/g,function(e){return"{{_resetNuclearIndex}}"+e.replace("{{@index}}","{{_nuclearIndex}}")})},e.str2Dom=function(e){var t={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],body:[0,"",""],_default:[1,"
","
"]};t.optgroup=t.option,t.tbody=t.tfoot=t.colgroup=t.caption=t.thead,t.th=t.td;var n=/<\s*\w.*?>/g.exec(e),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=document.createElement("body");r.innerHTML=e.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=e;for(var a=0;a"'\/]/g,function(e){return y[e]})}function s(t,r){function i(){if(x&&!P)for(;y.length;)delete v[y.pop()];else y=[];x=!1,P=!1}function s(e){if("string"==typeof e&&(e=e.split(b,2)),!d(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(n(e[0])+"\\s*"),h=new RegExp("\\s*"+n(e[1])),p=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var u,h,p,f=[],v=[],y=[],x=!1,P=!1;s(r||e.tags);for(var I,T,C,$,S,E,R=new l(t);!R.eos();){if(I=R.pos,C=R.scanUntil(u))for(var A=0,k=C.length;k>A;++A)$=C.charAt(A),o($)?y.push(v.length):P=!0,v.push(["text",$,I,I+1]),I+=1,"\n"===$&&i();if(!R.scan(u))break;if(x=!0,T=R.scan(w)||"name",R.scan(g),"="===T?(C=R.scanUntil(m),R.scan(m),R.scanUntil(h)):"{"===T?(C=R.scanUntil(p),R.scan(_),R.scanUntil(h),T="&"):C=R.scanUntil(h),!R.scan(h))throw new Error("Unclosed tag at "+R.pos);if(S=[T,C,I,R.pos],v.push(S),"#"===T||"^"===T)f.push(S);else if("/"===T){if(E=f.pop(),!E)throw new Error('Unopened section "'+C+'" at '+I);if(E[1]!==C)throw new Error('Unclosed section "'+E[1]+'" at '+I)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(C)}if(E=f.pop())throw new Error('Unclosed section "'+E[1]+'" at '+R.pos);return c(a(v))}function a(e){for(var t,n,r=[],o=0,i=e.length;i>o;++o)t=e[o],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],o=r,i=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":o.push(t),i.push(t),o=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(t)}return r}function l(e){this.string=e,this.tail=e,this.pos=0}function u(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function h(){this.cache={}}var p=Object.prototype.toString,d=Array.isArray||function(e){return"[object Array]"===p.call(e)},f=RegExp.prototype.test,v=/\S/,y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},g=/\s*/,b=/\s+/,m=/\s*=/,_=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},u.prototype.push=function(e){return new u(e,this)},u.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var o,i,s=this,a=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),i=0;null!=n&&ic;++c)s=void 0,o=e[c],i=o[0],"#"===i?s=this.renderSection(o,t,n,r):"^"===i?s=this.renderInverted(o,t,n,r):">"===i?s=this.renderPartial(o,t,n,r):"&"===i?s=this.unescapedValue(o,t):"name"===i?s=this.escapedValue(o,t):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(e,n,r,o){function i(e){return s.render(e,n,r)}var s=this,a="",c=n.lookup(e[1]);if(c){if(d(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(e[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(e[4],n.push(c),r,o);else if(t(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(e[3],e[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(e[4],n,r,o);return a}},h.prototype.renderInverted=function(e,t,n,r){var o=t.lookup(e[1]);return!o||d(o)&&0===o.length?this.renderTokens(e[4],t,n,r):void 0},h.prototype.renderPartial=function(e,n,r){if(r){var o=t(r)?r(e[1]):r[e[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},h.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.0.0",e.tags=["{{","}}"];var x=new h;e.clearCache=function(){return x.clearCache()},e.parse=function(e,t){return x.parse(e,t)},e.render=function(e,t,n){return x.render(e,t,n)},e.to_html=function(n,r,o,i){var s=e.render(n,r,o);return t(i)?void i(s):s},e.escape=i,e.Scanner=l,e.Context=u,e.Writer=h}),function(){var t=function(e,n,r){var o=function(e,n,r){e.$observer||(e.$observer=this);var o=e.$observer,i=[];t.isArray(e)&&(0===e.length&&(e.$observeProps={},e.$observeProps.$observerPath="#"),o.mock(e));for(var s in e)e.hasOwnProperty(s)&&(r?t.isArray(n)&&t.isInArray(n,s)?(i.push(s),o.watch(e,s)):t.isString(n)&&s==n&&(i.push(s),o.watch(e,s)):(i.push(s),o.watch(e,s)));o.target=e,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(e,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=t._getRootName(e,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||t.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,e,n,r,i)}0!==e.indexOf("Array-")&&"object"==typeof n&&this.watch(o,e,o.$observeProps.$observerPath)},mock:function(e){var n=this;t.methods.forEach(function(r){e[r]=function(){var e=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(t.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!t.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,e,this,this.$observeProps.$observerPath)}return o}})},watch:function(e,n,r){if("$observeProps"!==n&&"$observer"!==n&&!t.isFunction(e[n])){e.$observeProps||(e.$observeProps={}),void 0!==r?e.$observeProps.$observerPath=r:e.$observeProps.$observerPath="#";var o=this,i=e.$observeProps[n]=e[n];if(Object.defineProperty(e,n,{get:function(){return this.$observeProps[n]},set:function(t){var r=this.$observeProps[n];this.$observeProps[n]=t,o.onPropertyChanged(n,t,r,this,e.$observeProps.$observerPath)}}),"object"==typeof i){t.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),void 0!==r?i.$observeProps.$observerPath=r:i.$observeProps.$observerPath="#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,e.$observeProps.$observerPath+"-"+n)}}}},new o(e,n,r)};t.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],t.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isInArray=function(e,t){for(var n=e.length;--n>-1;)if(t===e[n])return!0;return!1},t.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)},t.twoWay=function(e,n,r,o){"object"==typeof e[n]&&"object"==typeof r[o]?(t(e,n,function(e,t){r[o]=this[n]}),t(r,o,function(t,r){e[n]=this[o]})):(t(e,n,function(e,t){r[o]=t}),t(r,o,function(t,r){e[n]=r}))},t._getRootName=function(e,t){return"#"===t?e:t.split("-")[1]},t.add=function(e,t,n){e[t]=n;var r=e.$observer;r.watch(e,t)},Array.prototype.size=function(e){this.length=e},e.observe=t}(),e.Class=function(){},e.Class.extend=function(t){function n(){this.ctor.apply(this,arguments)}var r=Object.create(this.prototype);for(var o in t)r[o]=t[o];return n.prototype=r,n.prototype._super=Object.create(this.prototype),n.prototype.constructor=n,n.extend=e.Class.extend,n},function(){function t(){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e),e.sheet.insertRule("body { visibility: hidden; }",0)}function n(e,t){var n=new RegExp("([^\r\n,{}]+)(,(?=[^}]*{)|s*{)","g");return e=e.replace(n,function(e,n,r){return n.match(/^\s*(@media|@keyframes|to|from|@font-face)/)?n+r:(n.match(/:scope/)&&(n=n.replace(/([^\s]*):scope/,function(e,t){return""===t?"> *":"> "+t})),n=n.replace(/^(\s*)/,"$1"+t+" "),n+r)})}function r(){var e=document.body.querySelectorAll("style[scoped]");if(0===e.length)return void(document.getElementsByTagName("body")[0].style.visibility="visible");var t=document.head||document.getElementsByTagName("head")[0];o&&t.removeChild(o),o=document.createElement("style");for(var r="",i=0;i diff --git a/package.json b/package.json index 7a858d0dc..7184d2a0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alloynuclear", - "version": "0.1.6", + "version": "0.1.7", "description": "made UI super easy.", "main": "nuclear.js", "scripts": { diff --git a/src/nuclear.js b/src/nuclear.js index 22365f3fa..e5d5df723 100644 --- a/src/nuclear.js +++ b/src/nuclear.js @@ -117,14 +117,14 @@ Nuclear._mixObj = function (obj) { this.node = null; this.HTML = ""; } else { - var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); + var newNode = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); item.parent.replaceChild(newNode, this.node); this.node = newNode; } } else { //第一次渲染 if (!Nuclear.isUndefined(item.tpl)) { - item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); + item.parent.insertAdjacentHTML("beforeEnd", this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))); this.node = item.parent.lastChild; } } @@ -206,7 +206,7 @@ Nuclear._mixObj = function (obj) { var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length; item.tpl = this._nuclearTplGenerator(); if (rpLen > 0) { - var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.Tpl.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]'); + var parts = Nuclear.str2Dom(this._nuclearWrap(Nuclear.render(Nuclear._fixEvent(Nuclear._fixTplIndex(item.tpl), this._ncInstanceId), item.data))).querySelectorAll('*[nc-refresh]'); window["_nuclearIndex"] = null; for (var j = 0; j < rpLen; j++) { var part = item.refreshPart[j]; diff --git a/src/tpl.js b/src/tpl.js index 4e9575087..c161f095b 100644 --- a/src/tpl.js +++ b/src/tpl.js @@ -8,6 +8,7 @@ ;(function defineMustache (global, factory) { Nuclear.Tpl = {}; factory(Nuclear.Tpl); // script, wsh, asp + Nuclear.render=Nuclear.Tpl.render; }(this, function mustacheFactory (mustache) { var objectToString = Object.prototype.toString;