/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html version: 3.3.0 build: 3167 */ YUI.add('datatable-base',function(Y){var YLang=Y.Lang,YisValue=YLang.isValue,Ysubstitute=Y.Lang.substitute,YNode=Y.Node,Ycreate=YNode.create,YgetClassName=Y.ClassNameManager.getClassName,DATATABLE="datatable",COLUMN="column",FOCUS="focus",KEYDOWN="keydown",MOUSEENTER="mouseenter",MOUSELEAVE="mouseleave",MOUSEUP="mouseup",MOUSEDOWN="mousedown",CLICK="click",DBLCLICK="dblclick",CLASS_COLUMNS=YgetClassName(DATATABLE,"columns"),CLASS_DATA=YgetClassName(DATATABLE,"data"),CLASS_MSG=YgetClassName(DATATABLE,"msg"),CLASS_LINER=YgetClassName(DATATABLE,"liner"),CLASS_FIRST=YgetClassName(DATATABLE,"first"),CLASS_LAST=YgetClassName(DATATABLE,"last"),CLASS_EVEN=YgetClassName(DATATABLE,"even"),CLASS_ODD=YgetClassName(DATATABLE,"odd"),TEMPLATE_TABLE='
',TEMPLATE_COL='',TEMPLATE_THEAD='',TEMPLATE_TBODY='',TEMPLATE_TH='
{value}
',TEMPLATE_TR='',TEMPLATE_TD='
{value}
',TEMPLATE_VALUE='{value}',TEMPLATE_MSG='';function Column(config){Column.superclass.constructor.apply(this,arguments);} Y.mix(Column,{NAME:"column",ATTRS:{id:{valueFn:"_defaultId",readOnly:true},key:{valueFn:"_defaultKey"},field:{valueFn:"_defaultField"},label:{valueFn:"_defaultLabel"},children:{value:null},abbr:{value:""},classnames:{readOnly:true,getter:"_getClassnames"},formatter:{},sortable:{value:false},editor:{},width:{},resizeable:{},minimized:{},minWidth:{},maxAutoWidth:{}}});Y.extend(Column,Y.Widget,{_defaultId:function(){return Y.guid();},_defaultKey:function(key){return key||Y.guid();},_defaultField:function(field){return field||this.get("key");},_defaultLabel:function(label){return label||this.get("key");},_afterAbbrChange:function(e){this._uiSetAbbr(e.newVal);},keyIndex:null,headers:null,colSpan:1,rowSpan:1,parent:null,thNode:null,initializer:function(config){},destructor:function(){},_getClassnames:function(){return Y.ClassNameManager.getClassName(COLUMN,this.get("id"));},syncUI:function(){this._uiSetAbbr(this.get("abbr"));},_uiSetAbbr:function(val){this.thNode.set("abbr",val);}});Y.Column=Column;function Columnset(config){Columnset.superclass.constructor.apply(this,arguments);} Y.mix(Columnset,{NAME:"columnset",ATTRS:{definitions:{setter:"_setDefinitions"}}});Y.extend(Columnset,Y.Base,{_setDefinitions:function(definitions){return Y.clone(definitions);},tree:null,idHash:null,keyHash:null,keys:null,initializer:function(){var tree=[],idHash={},keyHash={},keys=[],definitions=this.get("definitions"),self=this;function parseColumns(depth,currentDefinitions,parent){var i=0,len=currentDefinitions.length,currentDefinition,column,currentChildren;depth++;if(!tree[depth]){tree[depth]=[];} for(;imaxRowDepth){maxRowDepth=tmpRowDepth;}}}} for(m=0;m"];for(;i");this._colgroupNode=tableNode.insertBefore(Ycreate(allCols.join("")),tableNode.get("firstChild"));return this._colgroupNode;},_addTheadNode:function(tableNode){if(tableNode){this._theadNode=tableNode.insertBefore(Ycreate(TEMPLATE_THEAD),this._colgroupNode.next());return this._theadNode;}},_addTbodyNode:function(tableNode){this._tbodyNode=tableNode.appendChild(Ycreate(TEMPLATE_TBODY));return this._tbodyNode;},_addMessageNode:function(tableNode){this._msgNode=tableNode.insertBefore(Ycreate(TEMPLATE_MSG),this._tbodyNode);return this._msgNode;},_addCaptionNode:function(tableNode){this._captionNode=tableNode.createCaption();return this._captionNode;},bindUI:function(){var theadFilter="thead."+CLASS_COLUMNS+">tr>th",tbodyFilter="tbody."+CLASS_DATA+">tr>td",msgFilter="tbody."+CLASS_MSG+">tr>td";},delegate:function(type){if(type==="dblclick"){this.get("boundingBox").delegate.apply(this.get("boundingBox"),arguments);} else{this.get("contentBox").delegate.apply(this.get("contentBox"),arguments);}},syncUI:function(){this._uiSetColumnset(this.get("columnset"));this._uiSetRecordset(this.get("recordset"));this._uiSetSummary(this.get("summary"));this._uiSetCaption(this.get("caption"));},_uiSetSummary:function(val){val=YisValue(val)?val:"";this._tableNode.set("summary",val);},_uiSetCaption:function(val){val=YisValue(val)?val:"";this._captionNode.setContent(val);},_uiSetColumnset:function(cs){var tree=cs.tree,thead=this._theadNode,i=0,len=tree.length,parent=thead.get("parentNode"),nextSibling=thead.next();thead.remove();thead.get("children").remove(true);for(;i