datatable-scroll-min.js revision 76ca635d61eb3f9fb7c9d788a44fa8b1690aa138
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"]});