roojs-all.js
authorAlan Knowles <alan@akbkhome.com>
Fri, 18 Mar 2011 03:50:37 +0000 (11:50 +0800)
committerAlan Knowles <alan@akbkhome.com>
Fri, 18 Mar 2011 03:50:37 +0000 (11:50 +0800)
roojs-all.js

index f380634..65c8383 100644 (file)
@@ -874,7 +874,7 @@ cm.setLocked(B,D,true);cm.moveColumn(B,C);this.grid.fireEvent("columnmove",B,C);
 Roo.grid.GridView=function(A){Roo.grid.GridView.superclass.constructor.call(this);this.el=null;Roo.apply(this,A);};Roo.extend(Roo.grid.GridView,Roo.grid.AbstractGridView,{rowClass:"x-grid-row",cellClass:"x-grid-col",tdClass:"x-grid-td",hdClass:"x-grid-hd",splitClass:"x-grid-split",sortClasses:["sort-asc","sort-desc"],enableMoveAnim:false,hlColor:"C3DAF9",dh:Roo.DomHelper,fly:Roo.Element.fly,css:Roo.util.CSS,borderWidth:1,splitOffset:3,scrollIncrement:22,cellRE:/(?:.*?)x-grid-(?:hd|cell|csplit)-(?:[\d]+)-([\d]+)(?:.*?)/,findRE:/\s?(?:x-grid-hd|x-grid-col|x-grid-csplit)\s/,bind:function(ds,cm){if(this.ds){this.ds.un("load",this.onLoad,this);this.ds.un("datachanged",this.onDataChange,this);this.ds.un("add",this.onAdd,this);this.ds.un("remove",this.onRemove,this);this.ds.un("update",this.onUpdate,this);this.ds.un("clear",this.onClear,this);}if(ds){ds.on("load",this.onLoad,this);ds.on("datachanged",this.onDataChange,this);ds.on("add",this.onAdd,this);ds.on("remove",this.onRemove,this);ds.on("update",this.onUpdate,this);ds.on("clear",this.onClear,this);}
 this.ds=ds;if(this.cm){this.cm.un("widthchange",this.onColWidthChange,this);this.cm.un("headerchange",this.onHeaderChange,this);this.cm.un("hiddenchange",this.onHiddenChange,this);this.cm.un("columnmoved",this.onColumnMove,this);this.cm.un("columnlockchange",this.onColumnLock,this);}if(cm){this.generateRules(cm);cm.on("widthchange",this.onColWidthChange,this);cm.on("headerchange",this.onHeaderChange,this);cm.on("hiddenchange",this.onHiddenChange,this);cm.on("columnmoved",this.onColumnMove,this);cm.on("columnlockchange",this.onColumnLock,this);}
 this.cm=cm;},init:function(A){Roo.grid.GridView.superclass.init.call(this,A);this.bind(A.dataSource,A.colModel);A.on("headerclick",this.handleHeaderClick,this);if(A.trackMouseOver){A.on("mouseover",this.onRowOver,this);A.on("mouseout",this.onRowOut,this);}
-A.cancelTextSelection=function(){};this.gridId=A.id;var B=this.templates||{};if(!B.master){B.master=new Roo.Template('<div class="x-grid" hidefocus="true">','<div class="x-grid-topbar"></div>','<div class="x-grid-scroller"><div></div></div>','<div class="x-grid-locked">','<div class="x-grid-header">{lockedHeader}</div>','<div class="x-grid-body">{lockedBody}</div>',"</div>",'<div class="x-grid-viewport">','<div class="x-grid-header">{header}</div>','<div class="x-grid-body">{body}</div>',"</div>",'<div class="x-grid-bottombar"></div>','<a href="#" class="x-grid-focus" tabIndex="-1"></a>','<div class="x-grid-resize-proxy">&#160;</div>',"</div>");B.master.disableformats=true;}if(!B.header){B.header=new Roo.Template('<table border="0" cellspacing="0" cellpadding="0">','<tbody><tr class="x-grid-hd-row">{cells}</tr></tbody>',"</table>{splits}");B.header.disableformats=true;}
+A.cancelTextSelection=function(){};this.gridId=A.id;var B=this.templates||{};if(!B.master){B.master=new Roo.Template('<div class="x-grid" hidefocus="true">','<a href="#" class="x-grid-focus" tabIndex="-1"></a>','<div class="x-grid-topbar"></div>','<div class="x-grid-scroller"><div></div></div>','<div class="x-grid-locked">','<div class="x-grid-header">{lockedHeader}</div>','<div class="x-grid-body">{lockedBody}</div>',"</div>",'<div class="x-grid-viewport">','<div class="x-grid-header">{header}</div>','<div class="x-grid-body">{body}</div>',"</div>",'<div class="x-grid-bottombar"></div>','<div class="x-grid-resize-proxy">&#160;</div>',"</div>");B.master.disableformats=true;}if(!B.header){B.header=new Roo.Template('<table border="0" cellspacing="0" cellpadding="0">','<tbody><tr class="x-grid-hd-row">{cells}</tr></tbody>',"</table>{splits}");B.header.disableformats=true;}
 B.header.compile();if(!B.hcell){B.hcell=new Roo.Template('<td class="x-grid-hd x-grid-td-{id} {cellId}"><div title="{title}" class="x-grid-hd-inner x-grid-hd-{id}">','<div class="x-grid-hd-text" unselectable="on">{value}<img class="x-grid-sort-icon" src="',Roo.BLANK_IMAGE_URL,'" /></div>',"</div></td>");B.hcell.disableFormats=true;}
 B.hcell.compile();if(!B.hsplit){B.hsplit=new Roo.Template('<div class="x-grid-split {splitId} x-grid-split-{id}" style="{style}" unselectable="on">&#160;</div>');B.hsplit.disableFormats=true;}
 B.hsplit.compile();if(!B.body){B.body=new Roo.Template('<table border="0" cellspacing="0" cellpadding="0">',"<tbody>{rows}</tbody>","</table>");B.body.disableFormats=true;}
@@ -884,7 +884,7 @@ B.cell.compile();this.templates=B;},onColWidthChange:function(){this.updateColum
 this.insertRows(ds,B,B,true);this.onRemove(ds,A,B+1,true);this.syncRowHeights(B,B);this.layout();this.fireEvent("rowupdated",this,B,A);},onAdd:function(ds,A,B){this.insertRows(ds,B,B+(A.length-1));},onRemove:function(ds,A,B,C){if(C!==true){this.fireEvent("beforerowremoved",this,B,A);}var bt=this.getBodyTable(),lt=this.getLockedTable();if(bt.rows[B]){bt.firstChild.removeChild(bt.rows[B]);}if(lt.rows[B]){lt.firstChild.removeChild(lt.rows[B]);}if(C!==true){this.stripeRows(B);this.syncRowHeights(B,B);this.layout();this.fireEvent("rowremoved",this,B,A);}},onLoad:function(){this.scrollToTop();},scrollToTop:function(){if(this.scroller){this.scroller.dom.scrollTop=0;this.syncScroll();}},getHeaderPanel:function(A){if(A){this.headerPanel.show();}return this.headerPanel;},getFooterPanel:function(A){if(A){this.footerPanel.show();}return this.footerPanel;},initElements:function(){var E=Roo.Element;var el=this.grid.getGridEl().dom.firstChild;var cs=el.childNodes;this.el=new E(el);this.headerPanel=new E(el.firstChild);this.headerPanel.enableDisplayMode("block");this.scroller=new E(cs[1]);this.scrollSizer=new E(this.scroller.dom.firstChild);this.lockedWrap=new E(cs[2]);this.lockedHd=new E(this.lockedWrap.dom.firstChild);this.lockedBody=new E(this.lockedWrap.dom.childNodes[1]);this.mainWrap=new E(cs[3]);this.mainHd=new E(this.mainWrap.dom.firstChild);this.mainBody=new E(this.mainWrap.dom.childNodes[1]);this.footerPanel=new E(cs[4]);this.footerPanel.enableDisplayMode("block");this.focusEl=new E(cs[5]);this.focusEl.swallowEvent("click",true);this.resizeProxy=new E(cs[6]);this.headerSelector=String.format('#{0} td.x-grid-hd, #{1} td.x-grid-hd',this.lockedHd.id,this.mainHd.id);this.splitterSelector=String.format('#{0} div.x-grid-split, #{1} div.x-grid-split',this.idToCssName(this.lockedHd.id),this.idToCssName(this.mainHd.id));},idToCssName:function(s){return s.replace(/[^a-z0-9]+/ig,'-');},getHeaderCell:function(A){return Roo.DomQuery.select(this.headerSelector)[A];},getHeaderCellMeasure:function(A){return this.getHeaderCell(A).firstChild;},getHeaderCellText:function(A){return this.getHeaderCell(A).firstChild.firstChild;},getLockedTable:function(){return this.lockedBody.dom.firstChild;},getBodyTable:function(){return this.mainBody.dom.firstChild;},getLockedRow:function(A){return this.getLockedTable().rows[A];},getRow:function(A){return this.getBodyTable().rows[A];},getRowComposite:function(A){if(!this.rowEl){this.rowEl=new Roo.CompositeElementLite();}var B=[],C,D;if(C=this.getLockedRow(A)){B.push(C);}if(D=this.getRow(A)){B.push(D);}
 this.rowEl.elements=B;return this.rowEl;},getCell:function(A,B){var C=this.cm.getLockedCount();var D;if(B<C){D=this.lockedBody.dom.firstChild;}else {D=this.mainBody.dom.firstChild;B-=C;}return D.rows[A].childNodes[B];},getCellText:function(A,B){return this.getCell(A,B).firstChild.firstChild;},getCellBox:function(A){var b=this.fly(A).getBox();if(Roo.isOpera){b.y=A.offsetTop+this.mainBody.getY();}return b;},getCellIndex:function(A){var id=String(A.className).match(this.cellRE);if(id){return parseInt(id[1],10);}return 0;},findHeaderIndex:function(n){var r=Roo.fly(n).findParent("td."+this.hdClass,6);return r?this.getCellIndex(r):false;},findHeaderCell:function(n){var r=Roo.fly(n).findParent("td."+this.hdClass,6);return r?r:false;},findRowIndex:function(n){if(!n){return false;}var r=Roo.fly(n).findParent("tr."+this.rowClass,6);return r?r.rowIndex:false;},findCellIndex:function(A){var B=this.el.dom;while(A&&A!=B){if(this.findRE.test(A.className)){return this.getCellIndex(A);}
 A=A.parentNode;}return false;},getColumnId:function(A){return this.cm.getColumnId(A);},getSplitters:function(){if(this.splitterSelector){return Roo.DomQuery.select(this.splitterSelector);}else {return null;}},getSplitter:function(A){return this.getSplitters()[A];},onRowOver:function(e,t){var A;if((A=this.findRowIndex(t))!==false){this.getRowComposite(A).addClass("x-grid-row-over");}},onRowOut:function(e,t){var A;if((A=this.findRowIndex(t))!==false&&A!==this.findRowIndex(e.getRelatedTarget())){this.getRowComposite(A).removeClass("x-grid-row-over");}},renderHeaders:function(){var cm=this.cm;var ct=this.templates.hcell,ht=this.templates.header,st=this.templates.hsplit;var cb=[],lb=[],sb=[],A=[],p={};for(var i=0,B=cm.getColumnCount();i<B;i++){p.cellId="x-grid-hd-0-"+i;p.splitId="x-grid-csplit-0-"+i;p.id=cm.getColumnId(i);p.title=cm.getColumnTooltip(i)||"";p.value=cm.getColumnHeader(i)||"";p.style=(this.grid.enableColumnResize===false||!cm.isResizable(i)||cm.isFixed(i))?'cursor:default':'';if(!cm.isLocked(i)){cb[cb.length]=ct.apply(p);sb[sb.length]=st.apply(p);}else {lb[lb.length]=ct.apply(p);A[A.length]=st.apply(p);}}return [ht.apply({cells:lb.join(""),splits:A.join("")}),ht.apply({cells:cb.join(""),splits:sb.join("")})];},updateHeaders:function(){var A=this.renderHeaders();this.lockedHd.update(A[0]);this.mainHd.update(A[1]);},focusRow:function(A){var x=this.scroller.dom.scrollLeft;this.focusCell(A,0,false);this.scroller.dom.scrollLeft=x;},focusCell:function(A,B,C){var el=this.ensureVisible(A,B,C);this.focusEl.alignTo(el,"tl-tl");if(Roo.isGecko){this.focusEl.focus();}else {this.focusEl.focus.defer(1,this.focusEl);}},ensureVisible:function(A,B,C){if(typeof A!="number"){A=A.rowIndex;}if(A<0&&A>=this.ds.getCount()){return null;}
-B=(B!==undefined?B:0);var cm=this.grid.colModel;while(cm.isHidden(B)){B++;}var el=this.getCell(A,B);if(!el){return null;}var c=this.scroller.dom;var D=parseInt(el.offsetTop,10);var E=parseInt(el.offsetLeft,10);var F=D+el.offsetHeight;var G=E+el.offsetWidth;var ch=c.clientHeight-this.mainHd.dom.offsetHeight;var H=parseInt(c.scrollTop,10);var I=parseInt(c.scrollLeft,10);var J=H+ch;var K=I+c.clientWidth;if(D<H){c.scrollTop=D;}else if(F>J){c.scrollTop=F-ch;}if(C!==false){if(E<I){c.scrollLeft=E;}else if(G>K){c.scrollLeft=G-c.clientWidth;}}return null;return el;},updateColumns:function(){this.grid.stopEditing();var cm=this.grid.colModel,A=this.getColumnIds();var B=0;for(var i=0,C=cm.getColumnCount();i<C;i++){var w=cm.getColumnWidth(i);this.css.updateRule(this.colSelector+this.idToCssName(A[i]),"width",(w-this.borderWidth)+"px");this.css.updateRule(this.hdSelector+this.idToCssName(A[i]),"width",(w-this.borderWidth)+"px");}
+B=(B!==undefined?B:0);var cm=this.grid.colModel;while(cm.isHidden(B)){B++;}var el=this.getCell(A,B);if(!el){return null;}var c=this.scroller.dom;var D=parseInt(el.offsetTop,10);var E=parseInt(el.offsetLeft,10);var F=D+el.offsetHeight;var G=E+el.offsetWidth;var ch=c.clientHeight-this.mainHd.dom.offsetHeight;var H=parseInt(c.scrollTop,10);var I=parseInt(c.scrollLeft,10);var J=H+ch;var K=I+c.clientWidth;if(D<H){c.scrollTop=D;}else if(F>J){c.scrollTop=F-ch;}if(C!==false){if(E<I){c.scrollLeft=E;}else if(G>K){c.scrollLeft=G-c.clientWidth;}}return el;},updateColumns:function(){this.grid.stopEditing();var cm=this.grid.colModel,A=this.getColumnIds();var B=0;for(var i=0,C=cm.getColumnCount();i<C;i++){var w=cm.getColumnWidth(i);this.css.updateRule(this.colSelector+this.idToCssName(A[i]),"width",(w-this.borderWidth)+"px");this.css.updateRule(this.hdSelector+this.idToCssName(A[i]),"width",(w-this.borderWidth)+"px");}
 this.updateSplitters();},generateRules:function(cm){var A=[],B=this.idToCssName(this.grid.id)+'-cssrules';Roo.util.CSS.removeStyleSheet(B);for(var i=0,C=cm.getColumnCount();i<C;i++){var D=cm.getColumnId(i);var E='';if(cm.config[i].align){E='text-align:'+cm.config[i].align+';';}var F='';if(cm.isHidden(i)){F='display:none;';}var G="width:"+(cm.getColumnWidth(i)-this.borderWidth)+"px;";A.push(this.colSelector,D," {\n",cm.config[i].css,E,G,"\n}\n",this.hdSelector,D," {\n",E,G,"}\n",this.tdSelector,D," {\n",F,"\n}\n",this.splitSelector,D," {\n",F,"\n}\n");}return Roo.util.CSS.createStyleSheet(A.join(""),B);},updateSplitters:function(){var cm=this.cm,s=this.getSplitters();if(s){var A=0,B=true;for(var i=0,C=cm.getColumnCount();i<C;i++){if(cm.isHidden(i))continue;var w=cm.getColumnWidth(i);if(!cm.isLocked(i)&&B){A=0;B=false;}
 A+=w;s[i].style.left=(A-this.splitOffset)+"px";}}},handleHiddenChange:function(A,B,C){if(C){this.hideColumn(B);}else {this.unhideColumn(B);}},hideColumn:function(A){var B=this.getColumnId(A);this.css.updateRule(this.tdSelector+this.idToCssName(B),"display","none");this.css.updateRule(this.splitSelector+this.idToCssName(B),"display","none");if(Roo.isSafari){this.updateHeaders();}
 this.updateSplitters();this.layout();},unhideColumn:function(A){var B=this.getColumnId(A);this.css.updateRule(this.tdSelector+this.idToCssName(B),"display","");this.css.updateRule(this.splitSelector+this.idToCssName(B),"display","");if(Roo.isSafari){this.updateHeaders();}