datatable-min.js revision 970d3605073835415b62245302838340763d086f
YUI.add("datatable-base",function(c){var w=c.Lang,g=w.isValue,F=c.Lang.substitute,d=c.Node,t=d.create,p=c.ClassNameManager.getClassName,q="datatable",r="column",H="focus",K="keydown",h="mouseenter",o="mouseleave",k="mouseup",z="mousedown",C="click",v="dblclick",e=p(q,"columns"),B=p(q,"data"),b=p(q,"msg"),l=p(q,"liner"),E=p(q,"first"),i=p(q,"last"),u=p(q,"even"),A=p(q,"odd"),D="<table></table>",x="<col></col>",I='<thead class="'+e+'"></thead>',f='<tbody class="'+B+'"></tbody>',J='<th id="{id}" rowspan="{rowspan}" colspan="{colspan}" class="{classnames}" abbr="{abbr}"><div class="'+l+'">{value}</div></th>',G='<tr id="{id}"></tr>',a='<td headers="{headers}" class="{classnames}"><div class="'+l+'">{value}</div></td>',j="{value}",n='<tbody class="'+b+'"></tbody>';function m(L){m.superclass.constructor.apply(this,arguments);}c.mix(m,{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:{}}});c.extend(m,c.Widget,{_defaultId:function(){return c.guid();},_defaultKey:function(L){return L||c.guid();},_defaultField:function(L){return L||this.get("key");},_defaultLabel:function(L){return L||this.get("key");},_afterAbbrChange:function(L){this._uiSetAbbr(L.newVal);},keyIndex:null,headers:null,colSpan:1,rowSpan:1,parent:null,thNode:null,initializer:function(L){},destructor:function(){},_getClassnames:function(){return c.ClassNameManager.getClassName(r,this.get("id"));},syncUI:function(){this._uiSetAbbr(this.get("abbr"));},_uiSetAbbr:function(L){this.thNode.set("abbr",L);}});c.Column=m;function y(L){y.superclass.constructor.apply(this,arguments);}c.mix(y,{NAME:"columnset",ATTRS:{definitions:{setter:"_setDefinitions"}}});c.extend(y,c.Base,{_setDefinitions:function(L){return c.clone(L);},tree:null,idHash:null,keyHash:null,keys:null,initializer:function(){var L=[],Q={},R={},P=[],O=this.get("definitions"),M=this;function N(Z,Y,X){var U=0,T=Y.length,W,V,S;Z++;if(!L[Z]){L[Z]=[];}for(;U<T;++U){W=Y[U];W=w.isString(W)?{key:W}:W;V=new c.Column(W);W.yuiColumnId=V.get("id");Q[V.get("id")]=V;R[V.get("key")]=V;if(X){V.parent=X;}if(w.isArray(W.children)){S=W.children;V._set("children",S);M._setColSpans(V,W);M._cascadePropertiesToChildren(V,S);if(!L[Z+1]){L[Z+1]=[];}N(Z,S,V);}else{V.keyIndex=P.length;P.push(V);}L[Z].push(V);}Z--;}N(-1,O);this.tree=L;this.idHash=Q;this.keyHash=R;this.keys=P;this._setRowSpans();this._setHeaders();},destructor:function(){},_cascadePropertiesToChildren:function(O,M){var N=0,L=M.length,P;for(;N<L;++N){P=M[N];if(O.get("className")&&(P.className===undefined)){P.className=O.get("className");}if(O.get("editor")&&(P.editor===undefined)){P.editor=O.get("editor");}if(O.get("formatter")&&(P.formatter===undefined)){P.formatter=O.get("formatter");}if(O.get("resizeable")&&(P.resizeable===undefined)){P.resizeable=O.get("resizeable");}if(O.get("sortable")&&(P.sortable===undefined)){P.sortable=O.get("sortable");}if(O.get("hidden")){P.hidden=true;}if(O.get("width")&&(P.width===undefined)){P.width=O.get("width");}if(O.get("minWidth")&&(P.minWidth===undefined)){P.minWidth=O.get("minWidth");}if(O.get("maxAutoWidth")&&(P.maxAutoWidth===undefined)){P.maxAutoWidth=O.get("maxAutoWidth");}}},_setColSpans:function(N,M){var O=0;function L(R){var S=R.children,Q=0,P=S.length;for(;Q<P;++Q){if(w.isArray(S[Q].children)){L(S[Q]);}else{O++;}}}L(M);N.colSpan=O;},_setRowSpans:function(){function L(N){var O=1,Q,P,M,S;function R(X,W){W=W||1;var V=0,T=X.length,U;for(;V<T;++V){U=X[V];if(w.isArray(U.children)){W++;R(U.children,W);W--;}else{if(U.get&&w.isArray(U.get("children"))){W++;R(U.get("children"),W);W--;}else{if(W>O){O=W;}}}}}for(M=0;M<N.length;M++){Q=N[M];R(Q);for(S=0;S<Q.length;S++){P=Q[S];if(!w.isArray(P.get("children"))){P.rowSpan=O;}}O=1;}}L(this.tree);},_setHeaders:function(){var Q,O,N=this.keys,M=0,L=N.length;function P(S,R){S.push(R.get("id"));if(R.parent){P(S,R.parent);}}for(;M<L;++M){Q=[];O=N[M];P(Q,O);O.headers=Q.reverse().join(" ");}},getColumn:function(){}});c.Columnset=y;function s(L){s.superclass.constructor.apply(this,arguments);}c.mix(s,{NAME:"dataTable",ATTRS:{columnset:{setter:"_setColumnset"},recordset:{value:new c.Recordset({records:[]}),setter:"_setRecordset"},summary:{},caption:{},thValueTemplate:{value:j},tdValueTemplate:{value:j},trTemplate:{value:G}},HTML_PARSER:{}});c.extend(s,c.Widget,{thTemplate:J,tdTemplate:a,_theadNode:null,_tbodyNode:null,_msgNode:null,_setColumnset:function(L){return w.isArray(L)?new c.Columnset({definitions:L}):L;},_afterColumnsetChange:function(L){if(this.get("rendered")){this._uiSetColumnset(L.newVal);}},_setRecordset:function(L){if(w.isArray(L)){L=new c.Recordset({records:L});}L.addTarget(this);return L;},_afterRecordsetChange:function(L){if(this.get("rendered")){this._uiSetRecordset(L.newVal);}},_afterSummaryChange:function(L){if(this.get("rendered")){this._uiSetSummary(L.newVal);}},_afterCaptionChange:function(L){if(this.get("rendered")){this._uiSetCaption(L.newVal);}},initializer:function(L){this.after("columnsetChange",this._afterColumnsetChange);this.after("recordsetChange",this._afterRecordsetChange);this.after("summaryChange",this._afterSummaryChange);this.after("captionChange",this._afterCaptionChange);},destructor:function(){this.get("recordset").removeTarget(this);},renderUI:function(){return(this._addTableNode(this.get("contentBox"))&&this._addColgroupNode(this._tableNode)&&this._addTheadNode(this._tableNode)&&this._addTbodyNode(this._tableNode)&&this._addMessageNode(this._tableNode)&&this._addCaptionNode(this._tableNode));},_addTableNode:function(L){if(!this._tableNode){this._tableNode=L.appendChild(t(D));}return this._tableNode;},_addColgroupNode:function(N){var L=this.get("columnset").keys.length,M=0,O=["<colgroup>"];for(;M<L;++M){O.push(x);}O.push("</colgroup>");this._colgroupNode=N.insertBefore(t(O.join("")),N.get("firstChild"));
return this._colgroupNode;},_addTheadNode:function(L){if(L){this._theadNode=L.insertBefore(t(I),this._colgroupNode.next());return this._theadNode;}},_addTbodyNode:function(L){this._tbodyNode=L.appendChild(t(f));return this._tbodyNode;},_addMessageNode:function(L){this._msgNode=L.insertBefore(t(n),this._tbodyNode);return this._msgNode;},_addCaptionNode:function(L){this._captionNode=L.createCaption();return this._captionNode;},bindUI:function(){var M="thead."+e+">tr>th",N="tbody."+B+">tr>td",L="tbody."+b+">tr>td";},delegate:function(L){if(L==="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(L){L=g(L)?L:"";this._tableNode.set("summary",L);},_uiSetCaption:function(L){L=g(L)?L:"";this._captionNode.setContent(L);},_uiSetColumnset:function(P){var M=P.tree,R=this._theadNode,N=0,L=M.length,O=R.get("parentNode"),Q=R.next();R.remove();R.get("children").remove(true);for(;N<L;++N){this._addTheadTrNode({thead:R,columns:M[N]},(N===0),(N===L-1));}O.insert(R,Q);},_addTheadTrNode:function(N,L,M){N.tr=this._createTheadTrNode(N,L,M);this._attachTheadTrNode(N);},_createTheadTrNode:function(S,M,R){var Q=t(F(this.get("trTemplate"),S)),O=0,N=S.columns,L=N.length,P;if(M){Q.addClass(E);}if(R){Q.addClass(i);}for(;O<L;++O){P=N[O];this._addTheadThNode({value:P.get("label"),column:P,tr:Q});}return Q;},_attachTheadTrNode:function(L){L.thead.appendChild(L.tr);},_addTheadThNode:function(L){L.th=this._createTheadThNode(L);this._attachTheadThNode(L);L.column.thNode=L.th;},_createTheadThNode:function(M){var L=M.column;M.id=L.get("id");M.colspan=L.colSpan;M.rowspan=L.rowSpan;M.abbr=L.get("abbr");M.classnames=L.get("classnames");M.value=F(this.get("thValueTemplate"),M);return t(F(this.thTemplate,M));},_attachTheadThNode:function(L){L.tr.appendChild(L.th);},_uiSetRecordset:function(M){var O=0,L=M.getLength(),S=this._tbodyNode,P=S.get("parentNode"),Q=S.next(),R={},N;S.remove();S=null;N=this._addTbodyNode(this._tableNode);N.remove();this._tbodyNode=N;R.tbody=N;for(;O<L;++O){R.record=M.getRecord(O);R.rowindex=O;this._addTbodyTrNode(R);}P.insert(this._tbodyNode,Q);},_addTbodyTrNode:function(N){var M=N.tbody,L=N.record;N.tr=M.one("#"+L.get("id"))||this._createTbodyTrNode(N);this._attachTbodyTrNode(N);},_createTbodyTrNode:function(P){var O=t(F(this.get("trTemplate"),{id:P.record.get("id")})),M=0,N=this.get("columnset").keys,L=N.length;P.tr=O;for(;M<L;++M){P.column=N[M];this._addTbodyTdNode(P);}return O;},_attachTbodyTrNode:function(P){var M=P.tbody,O=P.tr,L=P.rowindex,N=M.get("children").item(L)||null,Q=(L%2===0);if(Q){O.replaceClass(A,u);}else{O.replaceClass(u,A);}M.insertBefore(O,N);},_addTbodyTdNode:function(L){L.td=this._createTbodyTdNode(L);this._attachTbodyTdNode(L);},_createTbodyTdNode:function(M){var L=M.column;M.headers=L.headers;M.classnames=L.get("classnames");M.value=this.formatDataCell(M);return t(F(this.tdTemplate,M));},_attachTbodyTdNode:function(L){L.tr.appendChild(L.td);},formatDataCell:function(O){var L=O.record,N=O.column,M=N.get("formatter");O.data=L.get("data");O.value=L.getValue(N.get("field"));return w.isString(M)?F(M,O):w.isFunction(M)?M.call(this,O):F(this.get("tdValueTemplate"),O);}});c.namespace("DataTable").Base=s;},"@VERSION@",{requires:["recordset-base","widget","substitute","event-mouseenter"]});YUI.add("datatable-datasource",function(b){function a(){a.superclass.constructor.apply(this,arguments);}b.mix(a,{NS:"datasource",NAME:"dataTableDataSource",ATTRS:{datasource:{setter:"_setDataSource"},initialRequest:{setter:"_setInitialRequest"}}});b.extend(a,b.Plugin.Base,{_setDataSource:function(c){return c||new b.DataSource.Local(c);},_setInitialRequest:function(c){},initializer:function(c){if(!b.Lang.isUndefined(c.initialRequest)){this.load({request:c.initialRequest});}},load:function(c){c=c||{};c.request=c.request||this.get("initialRequest");c.callback=c.callback||{success:b.bind(this.onDataReturnInitializeTable,this),failure:b.bind(this.onDataReturnInitializeTable,this),argument:this.get("host").get("state")};var d=(c.datasource||this.get("datasource"));if(d){d.sendRequest(c);}},onDataReturnInitializeTable:function(c){this.get("host").set("recordset",new b.Recordset({records:c.response.results}));}});b.namespace("Plugin").DataTableDataSource=a;},"@VERSION@",{requires:["datatable-base","plugin","datasource-local"]});YUI.add("datatable-sort",function(g){var f=g.ClassNameManager.getClassName,h="datatable",b="column",d="asc",c="desc",a='<a class="{link_class}" title="{link_title}" href="{link_href}">{value}</a>';function e(){e.superclass.constructor.apply(this,arguments);}g.mix(e,{NS:"sort",NAME:"dataTableSort",ATTRS:{trigger:{value:{event:"click",selector:"th"},writeOnce:"initOnly"},lastSortedBy:{setter:"_setLastSortedBy",lazyAdd:false},template:{value:a}}});g.extend(e,g.Plugin.Base,{initializer:function(j){var k=this.get("host"),i=this.get("trigger");k.get("recordset").plug(g.Plugin.RecordsetSort,{dt:k});k.get("recordset").sort.addTarget(k);this.doBefore("_createTheadThNode",this._beforeCreateTheadThNode);this.doBefore("_attachTheadThNode",this._beforeAttachTheadThNode);this.doBefore("_attachTbodyTdNode",this._beforeAttachTbodyTdNode);k.delegate(i.event,g.bind(this._onEventSortColumn,this),i.selector);k.after("recordsetSort:sort",function(){this._uiSetRecordset(this.get("recordset"));});this.on("lastSortedByChange",function(l){this._uiSetLastSortedBy(l.prevVal,l.newVal,k);});if(k.get("rendered")){k._uiSetColumnset(k.get("columnset"));this._uiSetLastSortedBy(null,this.get("lastSortedBy"),k);}},_setLastSortedBy:function(i){if(g.Lang.isString(i)){return{key:i,dir:"asc",notdir:"desc"};}else{if(i&&i.key){if(i.dir==="desc"){return{key:i.key,dir:"desc",notdir:"asc"};}else{return{key:i.key,dir:"asc",notdir:"desc"};
}}else{return null;}}},_uiSetLastSortedBy:function(m,j,i){var u=m&&m.key,n=m&&m.dir,t=j&&j.key,k=j&&j.dir,q=i.get("columnset"),s=q.keyHash[u],o=q.keyHash[t],r=i._tbodyNode,l,p;if(s){s.thNode.removeClass(f(h,n));l=r.all("."+f(b,s.get("id")));l.removeClass(f(h,n));}if(o){o.thNode.addClass(f(h,k));p=r.all("."+f(b,o.get("id")));p.addClass(f(h,k));}},_beforeCreateTheadThNode:function(i){if(i.column.get("sortable")){i.value=g.substitute(this.get("template"),{link_class:i.link_class||"",link_title:"title",link_href:"#",value:i.value});}},_beforeAttachTheadThNode:function(m){var l=this.get("lastSortedBy"),k=l&&l.key,i=l&&l.dir,j=l&&l.notdir;if(m.column.get("sortable")){m.th.addClass(f(h,"sortable"));}if(k&&(k===m.column.get("key"))){m.th.replaceClass(f(h,j),f(h,i));}},_beforeAttachTbodyTdNode:function(m){var l=this.get("lastSortedBy"),k=l&&l.key,i=l&&l.dir,j=l&&l.notdir;if(m.column.get("sortable")){m.td.addClass(f(h,"sortable"));}if(k&&(k===m.column.get("key"))){m.td.replaceClass(f(h,j),f(h,i));}},_onEventSortColumn:function(n){n.halt();var l=this.get("host"),k=l.get("columnset").idHash[n.currentTarget.get("id")],j=k.get("key"),m=k.get("field"),o=this.get("lastSortedBy"),i=(o&&o.key===j&&o.dir===d)?c:d,p=k.get("sortFn");if(k.get("sortable")){l.get("recordset").sort.sort(m,i===c,p);this.set("lastSortedBy",{key:j,dir:i});}}});g.namespace("Plugin").DataTableSort=e;},"@VERSION@",{requires:["datatable-base","plugin","recordset-sort"],lang:["en"]});YUI.add("datatable-scroll",function(b){var k=b.Node,j=b.Lang,m=b.UA,f=b.ClassNameManager.getClassName,l="datatable",a=f(l,"hd"),e=f(l,"bd"),d=f(l,"data"),i=f(l,"scrollable"),h='<div class="'+a+'"></div>',c='<div class="'+e+'"></div>',g="<table></table>";function n(){n.superclass.constructor.apply(this,arguments);}b.mix(n,{NS:"scroll",NAME:"dataTableScroll",ATTRS:{width:{value:undefined,writeOnce:"initOnly"},height:{value:undefined,writeOnce:"initOnly"},_scroll:{valueFn:function(){var o=this.get("width"),p=this.get("height");if(o&&p){return"xy";}else{if(o){return"x";}else{if(p){return"y";}else{return null;}}}}},COLOR_COLUMNFILLER:{value:"#f2f2f2",validator:j.isString,setter:function(o){if(this._headerContainerNode){this._headerContainerNode.setStyle("backgroundColor",o);}}}}});b.extend(n,b.Plugin.Base,{_parentTableNode:null,_parentTheadNode:null,_parentTbodyNode:null,_parentMsgNode:null,_parentContainer:null,_bodyContainerNode:null,_headerContainerNode:null,initializer:function(o){var p=this.get("host");this._parentContainer=p.get("contentBox");this._parentContainer.addClass(i);this._setUpNodes();},_setUpNodes:function(){this.afterHostMethod("_addTableNode",this._setUpParentTableNode);this.afterHostMethod("_addTheadNode",this._setUpParentTheadNode);this.afterHostMethod("_addTbodyNode",this._setUpParentTbodyNode);this.afterHostMethod("_addMessageNode",this._setUpParentMessageNode);this.afterHostMethod("renderUI",this.renderUI);this.afterHostMethod("syncUI",this.syncUI);if(this.get("_scroll")!=="x"){this.afterHostMethod("_attachTheadThNode",this._attachTheadThNode);this.afterHostMethod("_attachTbodyTdNode",this._attachTbodyTdNode);}},_setUpParentTableNode:function(){this._parentTableNode=this.get("host")._tableNode;},_setUpParentTheadNode:function(){this._parentTheadNode=this.get("host")._theadNode;},_setUpParentTbodyNode:function(){this._parentTbodyNode=this.get("host")._tbodyNode;},_setUpParentMessageNode:function(){this._parentMsgNode=this.get("host")._msgNode;},renderUI:function(){this._createBodyContainer();this._createHeaderContainer();this._setContentBoxDimensions();},syncUI:function(){this._removeCaptionNode();this._syncWidths();this._syncScroll();},_removeCaptionNode:function(){this.get("host")._captionNode.remove();},_syncWidths:function(){var p=k.all("#"+this._parentContainer.get("id")+" ."+a+" table thead th"),q=k.one("#"+this._parentContainer.get("id")+" ."+e+" table ."+d).get("firstChild").get("children"),r,u,w,t,v,s,o=m.ie;for(r=0,u=p.size();r<u;r++){v=p.item(r).get("firstChild");s=q.item(r).get("firstChild");if(!o){w=v.get("clientWidth");t=q.item(r).get("clientWidth");}else{w=v.get("offsetWidth");t=q.item(r).get("offsetWidth");}if(w>t){s.setStyle("width",(w-20+"px"));}else{if(t>w){v.setStyle("width",(t-20+"px"));s.setStyle("width",(t-20+"px"));}}}},_attachTheadThNode:function(q){var p=q.column.get("width")||"auto";if(p!=="auto"){q.th.get("firstChild").setStyles({width:p,overflow:"hidden"});}return q;},_attachTbodyTdNode:function(q){var p=q.column.get("width")||"auto";if(p!=="auto"){q.td.get("firstChild").setStyles({width:p,overflow:"hidden"});}return q;},_createBodyContainer:function(){var p=k.create(c),o=b.bind("_onScroll",this);this._bodyContainerNode=p;this._setStylesForTbody();p.appendChild(this._parentTableNode);this._parentContainer.appendChild(p);p.on("scroll",o);},_createHeaderContainer:function(){var p=k.create(h),o=k.create(g);this._headerContainerNode=p;this._setStylesForThead();o.appendChild(this._parentTheadNode);p.appendChild(o);this._parentContainer.prepend(p);},_setStylesForTbody:function(){var p=this.get("_scroll"),o=this.get("width")||"",r=this.get("height")||"",q=this._bodyContainerNode,s={width:"",height:r};if(p==="x"){s.overflowY="hidden";s.width=o;}else{if(p==="y"){s.overflowX="hidden";}else{if(p==="xy"){s.width=o;}else{s.overflowX="hidden";s.overflowY="hidden";s.width=o;}}}q.setStyles(s);return q;},_setStylesForThead:function(){var o=this.get("width")||"",p=this._headerContainerNode;p.setStyles({"width":o,"overflow":"hidden"});},_setContentBoxDimensions:function(){if(this.get("_scroll")==="y"||(!this.get("width"))){this._parentContainer.setStyle("width","auto");}},_onScroll:function(){this._headerContainerNode.set("scrollLeft",this._bodyContainerNode.get("scrollLeft"));},_syncScroll:function(){this._syncScrollX();this._syncScrollY();this._syncScrollOverhang();if(m.opera){this._headerContainerNode.set("scrollLeft",this._bodyContainerNode.get("scrollLeft"));if(!this.get("width")){document.body.style+="";}}},_syncScrollY:function(){var o=this._parentTbodyNode,q=this._bodyContainerNode,p;
if(!this.get("width")){p=(q.get("scrollHeight")>q.get("clientHeight"))?(o.get("parentNode").get("clientWidth")+19)+"px":(o.get("parentNode").get("clientWidth")+2)+"px";this._parentContainer.setStyle("width",p);}},_syncScrollX:function(){var o=this._parentTbodyNode,q=this._bodyContainerNode,p;this._headerContainerNode.set("scrollLeft",this._bodyContainerNode.get("scrollLeft"));if(!this.get("height")&&(m.ie)){p=(q.get("scrollWidth")>q.get("offsetWidth"))?(o.get("parentNode").get("offsetHeight")+18)+"px":o.get("parentNode").get("offsetHeight")+"px";q.setStyle("height",p);}if(o.get("rows").length===0){this._parentMsgNode.get("parentNode").setStyle("width",this._parentTheadNode.get("parentNode").get("offsetWidth")+"px");}else{this._parentMsgNode.get("parentNode").setStyle("width","");}},_syncScrollOverhang:function(){var o=this._bodyContainerNode,p=1;if((o.get("scrollHeight")>o.get("clientHeight"))||(o.get("scrollWidth")>o.get("clientWidth"))){p=18;}this._setOverhangValue(p);if(m.ie!==0&&this.get("_scroll")==="y"&&this._bodyContainerNode.get("scrollHeight")>this._bodyContainerNode.get("offsetHeight")){this._headerContainerNode.setStyle("width",this._parentContainer.get("width"));}},_setOverhangValue:function(p){var r=this.get("host"),t=r.get("columnset").get("definitions"),o=t.length,s=p+"px solid "+this.get("COLOR_COLUMNFILLER"),q=k.all("#"+this._parentContainer.get("id")+" ."+a+" table thead th");q.item(o-1).setStyle("borderRight",s);}});b.namespace("Plugin").DataTableScroll=n;},"@VERSION@",{requires:["datatable-base","plugin","stylesheet"]});YUI.add("datatable",function(a){},"@VERSION@",{use:["datatable-base","datatable-datasource","datatable-sort","datatable-scroll"]});