text: KISSY.add("brix/core/chunk",function(e,t,r,n,i,a){function l(e,t){for(var r=0;e.length>r;r++)for(var n=0;t.length>n;n++)if(e[r]==t[n])return!0;return!1}var s=t.all,o=e.noop,u=n.prototype.__getHook,d=n.extend({constructor:function d(){d.superclass.constructor.apply(this,arguments),(this.get("autoRender")||this.get("tmpler").inDom)&&this.render()},initializer:function(){this._bx_buildTmpler(),this._bx_buildDataset()},_bx_buildTmpler:function(){var e=this,t=e.get("tmpl");if(!e.get("isBuidTmpler")){e.set("isBuidTmpler",!0);var r=new a(t,e.get("level"));e.set("tmpler",r),r.inDom&&e.set("el",t)}},_bx_buildDataset:function(){var t=this;if(!t.get("isBuidDataset")){t.set("isBuidDataset",!0);var r=e.clone(t.get("data")||{}),n=new i({data:r}),a=t.get("renderer");a&&n.setRenderer(a,t),t.set("dataset",n),n.on("*Change",function(r){var i=!1,a=e.map(r.subAttrName,function(e){return/^data\./g.test(e)?(i=!0,e.replace(/^data\./,"")):"zuomo.xb@taobao.com"});i&&t._bx_renderTmpl(a,n.get("data"))})}},destructor:function(){var e=this,t=e.get("tmpler"),r=e.get("dataset");t&&e.set("tmpler",null),r&&(e.set("dataset",null),r.detach())},bindUI:o,initialize:o,syncUI:o,addSubTmpl:function(e,t,r){return this.get("tmpler").addSubTmpl(e,t,r)},getStoreTmpl:function(e){return this.get("tmpler").getStoreTmpl(e)},setChunkData:function(t,r,n){var i=this,a=i.get("dataset");if(a){if(e.isObject(t)){t=e.clone(t);var l={};for(var s in t)l["data."+s]=t[s];t=l,n=r}else t="data."+t,r=e.clone(r);var o="html";n&&n.renderType&&(o=n.renderType,delete n.renderType),i.set("renderType",o),a.set.apply(a,arguments)}},render:function(){var e=this;return e.get("rendered")||(e.fire("beforeRenderUI"),e._bx_render(),e.fire("afterRenderUI"),e.setInternal("rendered",!0),e.fire("beforeBindUI"),d.superclass.bindInternal.call(e),e.bindUI(),e.initialize(),e.fire("afterBindUI"),e.fire("beforeSyncUI"),d.superclass.syncInternal.call(e),e.syncUI(),e.fire("afterSyncUI")),e},_bx_render:function(){var n=this,i=n.get("tmpler");if(i.tmpl&&!i.inDom){var a,l=n.get("container"),o=n.get("el"),u=e.trim(i.render(n.get("dataset").get("data")));if(o&&0!==o.length)if(8>=r.ie){for(a=new t("<div />"),l.append(a),a.html(u);a[0].childNodes.length>0;)l[0].appendChild(a[0].childNodes[0]);a.remove(),a=null}else l.append(u);else{var d="brix_"+e.guid();if(8>=r.ie){a=new t("<div />"),l.append(a),a.html(u);var c=a[0].childNodes;if(c.length>1)a.attr("id",d);else{for(d=c[0].id||d,c[0].id=d;c.length>0;)l[0].appendChild(c[0]);a.remove(),a=null}}else a=new t(u),a.length>1?a=s('<div id="'+d+'"></div>').append(a):(d=a.attr("id")||d,a.attr("id",d)),l.append(a);n.set("el","#"+d)}}},_bx_renderTmpl:function(t,r){var n=this,i=n.get("tmpler");if(i&&n.get("rendered")){var a=n.get("el"),s=i.subTmpls;e.each(s,function(i){var s=e.map(i.datakey.split(","),function(t){return e.trim(t)});if(l(s,t)){var o=a.all("[bx-tmpl="+i.name+"]");a.attr("bx-tmpl")==i.name&&(o=a.add(o)),o.each(function(t){if(t.attr("bx-datakey")==i.datakey){var a={};e.each(s,function(e){for(var t=r,n=e.split("."),i=n.length,l=0;l!==i;)t=t[n[l]],l++;a[n[i-1]]=t,t=null}),e.each(r,function(t,r){e.isFunction(t)&&(a[r]=t)});var l=n.get("renderType")||"html";n.fire("beforeRefreshTmpl",{node:t,renderType:l}),t[l](e.trim(i.tmpler.render(a))),n.fire("afterRefreshTmpl",{node:t}),a=null}}),o=null}})}}},{__hooks__:{initialize:u("__initialize"),bindUI:u("__bindUI"),syncUI:u("__syncUI")},ATTRS:{el:{getter:function(t){return e.isString(t)&&(t=s(t)),t}},destroyAction:{value:"remove"},container:{value:"body",getter:function(t){return e.isString(t)&&(t=s(t)),t}},tmpl:{value:!1},tmpler:{value:!1},rendered:{value:!1},autoRender:{value:!0},data:{value:!1},dataset:{value:!1},renderer:{value:!1},level:{value:3}}});return d},{requires:["node","ua","base","./dataset","./tmpler"]});