YUI.add("datatable-table",function(e,t){var n=e.Array,r=e.Lang,i=r.sub,s=r.isArray,o=r.isFunction;e.namespace("DataTable").TableView=e.Base.create("table",e.View,[],{CAPTION_TEMPLATE:'<caption class="{className}"/>',TABLE_TEMPLATE:'<table cellspacing="0" class="{className}"/>',getCell:function(){return this.body&&this.body.getCell&&this.body.getCell.apply(this.body,arguments)},getClassName:function(){var t=this.host,r=t&&t.constructor.NAME||this.constructor.NAME;return t&&t.getClassName?t.getClassName.apply(t,arguments):e.ClassNameManager.getClassName.apply(e.ClassNameManager,[r].concat(n(arguments,0,!0)))},getRecord:function(){return this.body&&this.body.getRecord&&this.body.getRecord.apply(this.body,arguments)},getRow:function(){return this.body&&this.body.getRow&&this.body.getRow.apply(this.body,arguments)},_afterSummaryChange:function(e){this._uiSetSummary(e.newVal)},_afterCaptionChange:function(e){this._uiSetCaption(e.newVal)},_afterWidthChange:function(e){this._uiSetWidth(e.newVal)},_bindUI:function(){var t;this._eventHandles||(t=e.bind("_relayAttrChange",this),this._eventHandles=this.after({columnsChange:t,modelListChange:t,summaryChange:e.bind("_afterSummaryChange",this),captionChange:e.bind("_afterCaptionChange",this),widthChange:e.bind("_afterWidthChange",this)}))},_createTable:function(){return e.Node.create(i(this.TABLE_TEMPLATE,{className:this.getClassName("table")})).empty()},_defRenderBodyFn:function(e){e.view.render()},_defRenderFooterFn:function(e){e.view.render()},_defRenderHeaderFn:function(e){e.view.render()},_defRenderTableFn:function(t){var n=this.get("container"),r=this.getAttrs();this.tableNode||(this.tableNode=this._createTable()),r.host=this.get("host")||this,r.table=this,r.container=this.tableNode,this._uiSetCaption(this.get("caption")),this._uiSetSummary(this.get("summary")),this._uiSetWidth(this.get("width"));if(this.head||t.headerView)this.head||(this.head=new t.headerView(e.merge(r,t.headerConfig))),this.fire("renderHeader",{view:this.head});if(this.foot||t.footerView)this.foot||(this.foot=new t.footerView(e.merge(r,t.footerConfig))),this.fire("renderFooter",{view:this.foot});r.columns=this.displayColumns;if(this.body||t.bodyView)this.body||(this.body=new t.bodyView(e.merge(r,t.bodyConfig))),this.fire("renderBody",{view:this.body});n.contains(this.tableNode)||n.append(this.tableNode),this._bindUI()},destructor:function(){this.head&&this.head.destroy&&this.head.destroy(),delete this.head,this.foot&&this.foot.destroy&&this.foot.destroy(),delete this.foot,this.body&&this.body.destroy&&this.body.destroy(),delete this.body,this._eventHandles&&(this._eventHandles.detach(),delete this._eventHandles),this.tableNode&&this.tableNode.remove().destroy(!0)},_extractDisplayColumns:function(){function n(e){var r,i,o;for(r=0,i=e.length;r<i;++r)o=e[r],s(o.children)?n(o.children):t.push(o)}var e=this.get("columns"),t=[];e&&n(e),this.displayColumns=t},_initEvents:function(){this.publish({renderTable:{defaultFn:e.bind("_defRenderTableFn",this)},renderHeader:{defaultFn:e.bind("_defRenderHeaderFn",this)},renderBody:{defaultFn:e.bind("_defRenderBodyFn",this)},renderFooter:{defaultFn:e.bind("_defRenderFooterFn",this)}})},initializer:function(e){this.host=e.host,this._initEvents(),this._extractDisplayColumns(),this.after("columnsChange",this._extractDisplayColumns,this)},_relayAttrChange:function(e){var t=e.attrName,n=e.newVal;this.head&&this.head.set(t,n),this.foot&&this.foot.set(t,n),this.body&&(t==="columns"&&(n=this.displayColumns),this.body.set(t,n))},render:function(){return this.get("container")&&this.fire("renderTable",{headerView:this.get("headerView"),headerConfig:this.get("headerConfig"),bodyView:this.get("bodyView"),bodyConfig:this.get("bodyConfig"),footerView:this.get("footerView"),footerConfig:this.get("footerConfig")}),this},_uiSetCaption:function(t){var n=this.tableNode,r=this.captionNode;t?(r||(this.captionNode=r=e.Node.create(i(this.CAPTION_TEMPLATE,{className:this.getClassName("caption")})),n.prepend(this.captionNode)),r.setHTML(t)):r&&(r.remove(!0),delete this.captionNode)},_uiSetSummary:function(e){e?this.tableNode.setAttribute("summary",e):this.tableNode.removeAttribute("summary")},_uiSetWidth:function(e){var t=this.tableNode;t.setStyle("width",e?this.get("container").get("offsetWidth")-(parseInt(t.getComputedStyle("borderLeftWidth"),10)||0)-(parseInt(t.getComputedStyle("borderLeftWidth"),10)||0)+"px":""),t.setStyle("width",e)},_validateView:function(e){return o(e)&&e.prototype.render}},{ATTRS:{columns:{validator:s},width:{value:"",validator:r.isString},headerView:{value:e.DataTable.HeaderView,validator:"_validateView"},footerView:{validator:"_validateView"},bodyView:{value:e.DataTable.BodyView,validator:"_validateView"}}})},"@VERSION@",{requires:["datatable-core","datatable-head","datatable-body","view","classnamemanager"]});
