From 8609d28433a50283670258d0cb7f06d9178c864c Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Sun, 18 Nov 2012 18:38:33 +0800 Subject: [PATCH] roojs-ui.js roojs-ui-debug.js roojs-all.js roojs-debug.js --- roojs-all.js | 17 +++++++------ roojs-debug.js | 65 ++++++++++++++++++++++++++++++++++++++++------- roojs-ui-debug.js | 58 +++++++++++++++++++++++++++++++++++++----- roojs-ui.js | 13 +++++----- 4 files changed, 124 insertions(+), 29 deletions(-) diff --git a/roojs-all.js b/roojs-all.js index 62c854d35f..a45f849ee9 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -224,11 +224,11 @@ this.update(this.defaultUrl,null,A,true);},startAutoRefresh:function(A,B,C,D,E){ this.autoRefreshProcId=setInterval(this.update.createDelegate(this,[B||this.defaultUrl,C,D,true]),A*1000);},stopAutoRefresh:function(){if(this.autoRefreshProcId){clearInterval(this.autoRefreshProcId);delete this.autoRefreshProcId;}},isAutoRefreshing:function(){return this.autoRefreshProcId?true:false;},showLoading:function(){if(this.showLoadIndicator){this.el.update(this.indicatorText);}},prepareUrl:function(A){if(this.disableCaching){var B="_dc="+(new Date().getTime());if(A.indexOf("?")!==-1){A+="&"+B;}else {A+="?"+B;}}return A;},processSuccess:function(A){this.transaction=null;if(A.argument.form&&A.argument.reset){try{A.argument.form.reset();}catch(e){}}if(this.loadScripts){this.renderer.render(this.el,A,this,this.updateComplete.createDelegate(this,[A]));}else {this.renderer.render(this.el,A,this);this.updateComplete(A);}},updateComplete:function(A){this.fireEvent("update",this.el,A);if(typeof A.argument.callback=="function"){A.argument.callback(this.el,true,A);}},processFailure:function(A){this.transaction=null;this.fireEvent("failure",this.el,A);if(typeof A.argument.callback=="function"){A.argument.callback(this.el,false,A);}},setRenderer:function(A){this.renderer=A;},getRenderer:function(){return this.renderer;},setDefaultUrl:function(A){this.defaultUrl=A;},abort:function(){if(this.transaction){Roo.Ajax.abort(this.transaction);}},isUpdating:function(){if(this.transaction){return Roo.Ajax.isLoading(this.transaction);}return false;}});Roo.UpdateManager.defaults={timeout:30,loadScripts:false,sslBlankUrl:(Roo.SSL_SECURE_URL||"javascript:false"),disableCaching:false,showLoadIndicator:true,indicatorText:'
Loading...
'};Roo.UpdateManager.updateElement=function(el,A,B,C){var um=Roo.get(el,true).getUpdateManager();Roo.apply(um,C);um.update(A,B,C?C.callback:null);};Roo.UpdateManager.update=Roo.UpdateManager.updateElement;Roo.UpdateManager.BasicRenderer=function(){};Roo.UpdateManager.BasicRenderer.prototype={render:function(el,A,B,C){el.update(A.responseText,B.loadScripts,C);}}; //Roo/DomTemplate.js Roo.DomTemplate=function(){Roo.DomTemplate.superclass.constructor.apply(this,arguments);if(this.html){this.compile();}};Roo.extend(Roo.DomTemplate,Roo.Template,{id:0,inPre:false,tpls:false,re:/(\{|\%7B)([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\}|\%7D)/g,iterChild:function(A,B){var C=this.inPre;if(A.tagName=='PRE'){this.inPre=true;}for(var i=0;i=d){clearInterval(id);id=null;fn.apply(A,B||[]);}};this.delay=function(D,E,F,G){if(id&&D!=d){this.cancel();} d=D;t=new Date().getTime();fn=E||fn;A=F||A;B=G||B;if(!id){id=setInterval(C,d);}};this.cancel=function(){if(id){clearInterval(id);id=null;}};}; @@ -1076,15 +1076,15 @@ px+=this.proxyOffsets[0];this.proxyTop.setLeftTop(px,py);this.proxyTop.show();if this.proxyBottom.setLeftTop(px,py+this.proxyTop.dom.offsetHeight+this.bottomOffset);this.proxyBottom.show();return pt;},onNodeEnter:function(n,dd,e,A){if(A.header!=n){this.positionIndicator(A.header,n,e);}},onNodeOver:function(n,dd,e,A){var B=false;if(A.header!=n){B=this.positionIndicator(A.header,n,e);}if(!B){this.proxyTop.hide();this.proxyBottom.hide();}return B?this.dropAllowed:this.dropNotAllowed;},onNodeOut:function(n,dd,e,A){this.proxyTop.hide();this.proxyBottom.hide();},onNodeDrop:function(n,dd,e,A){var h=A.header;if(h!=n){var cm=this.grid.colModel;var x=Roo.lib.Event.getPageX(e);var r=Roo.lib.Dom.getRegion(n.firstChild);var pt=(r.right-x)<=((r.right-r.left)/2)?"after":"before";var B=this.view.getCellIndex(h);var C=this.view.getCellIndex(n);var D=cm.isLocked(C);if(pt=="after"){C++;}if(B','','
','
','
','
{lockedHeader}
','
{lockedBody}
',"
",'
','
{header}
','
{body}
',"
",'
','
 
',"");B.master.disableformats=true;}if(!B.header){B.header=new Roo.Template('','{cells}',"
{splits}");B.header.disableformats=true;} -B.header.compile();if(!B.hcell){B.hcell=new Roo.Template('
','
{value}
',"
");B.hcell.disableFormats=true;} -B.hcell.compile();if(!B.hsplit){B.hsplit=new Roo.Template('
 
');B.hsplit.disableFormats=true;} +B.header.compile();if(!B.hcell){B.hcell=new Roo.Template('
','
{value}
',"
");B.hcell.disableFormats=true;} +B.hcell.compile();if(!B.hsplit){B.hsplit=new Roo.Template('
 
');B.hsplit.disableFormats=true;} B.hsplit.compile();if(!B.body){B.body=new Roo.Template('',"{rows}","
");B.body.disableFormats=true;} B.body.compile();if(!B.row){B.row=new Roo.Template('{cells}');B.row.disableFormats=true;} -B.row.compile();if(!B.cell){B.cell=new Roo.Template('','
{value}
',"");B.cell.disableFormats=true;} +B.row.compile();if(!B.cell){B.cell=new Roo.Template('','
{value}
',"");B.cell.disableFormats=true;} B.cell.compile();this.templates=B;},onColWidthChange:function(){this.updateColumns.apply(this,arguments);},onHeaderChange:function(){this.updateHeaders.apply(this,arguments);},onHiddenChange:function(){this.handleHiddenChange.apply(this,arguments);},onColumnMove:function(){this.handleColumnMove.apply(this,arguments);},onColumnLock:function(){this.handleLockChange.apply(this,arguments);},onDataChange:function(){this.refresh();this.updateHeaderSortState();},onClear:function(){this.refresh();},onUpdate:function(ds,A){this.refreshRow(A);},refreshRow:function(A){var ds=this.ds,B;if(typeof A=='number'){B=A;A=ds.getAt(B);}else {B=ds.indexOf(A);} 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.focusEl=new E(el.firstChild);this.focusEl.swallowEvent("click",true);this.headerPanel=new E(cs[1]);this.headerPanel.enableDisplayMode("block");this.scroller=new E(cs[2]);this.scrollSizer=new E(this.scroller.dom.firstChild);this.lockedWrap=new E(cs[3]);this.lockedHd=new E(this.lockedWrap.dom.firstChild);this.lockedBody=new E(this.lockedWrap.dom.childNodes[1]);this.mainWrap=new E(cs[4]);this.mainHd=new E(this.mainWrap.dom.firstChild);this.mainBody=new E(this.mainWrap.dom.childNodes[1]);this.footerPanel=new E(cs[5]);this.footerPanel.enableDisplayMode("block");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
', - '
{value}
', + '
{value}
', "
" ); tpls.hcell.disableFormats = true; @@ -50193,7 +50197,8 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { tpls.hcell.compile(); if(!tpls.hsplit){ - tpls.hsplit = new Roo.Template('
 
'); + tpls.hsplit = new Roo.Template('
 
'); tpls.hsplit.disableFormats = true; } tpls.hsplit.compile(); @@ -50217,7 +50222,8 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { if(!tpls.cell){ tpls.cell = new Roo.Template( '', - '
{value}
', + '
{value}
', "" ); tpls.cell.disableFormats = true; @@ -51520,6 +51526,7 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { this.dd = new Roo.grid.GridDragZone(this.grid, { ddGroup : this.grid.ddGroup || 'GridDD' }); + } /* @@ -51818,15 +51825,45 @@ Roo.extend(Roo.grid.GridDragZone, Roo.dd.DragZone, { getDragData : function(e){ var t = Roo.lib.Event.getTarget(e); var rowIndex = this.view.findRowIndex(t); + var sm = this.grid.selModel; + + //Roo.log(rowIndex); + + if (sm.getSelectedCell) { + // cell selection.. + if (!sm.getSelectedCell()) { + return false; + } + if (rowIndex != sm.getSelectedCell()[0]) { + return false; + } + + } + if(rowIndex !== false){ - var sm = this.grid.selModel; + + // if editorgrid.. + + + //Roo.log([ sm.getSelectedCell() ? sm.getSelectedCell()[0] : 'NO' , rowIndex ]); + //if(!sm.isSelected(rowIndex) || e.hasModifier()){ - // sm.mouseDown(e, t); + // //} if (e.hasModifier()){ sm.handleMouseDown(e, t); // non modifier buttons are handled by row select. } - return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()}; + + Roo.log("getDragData"); + + return { + grid: this.grid, + ddel: this.ddel, + rowIndex: rowIndex, + selections:sm.getSelections ? sm.getSelections() : ( + sm.getSelectedCell() ? [ grid.ds.getAt(sm.getSelectedCell()[0]) ] : [] + ) + }; } return false; }, @@ -53391,7 +53428,17 @@ Roo.extend(Roo.grid.EditorGrid, Roo.grid.Grid, { this.activeEditor.completeEdit(); } this.activeEditor = null; + }, + + /** + * Called to get grid's drag proxy text, by default returns this.ddText. + * @return {String} + */ + getDragDropText : function(){ + var count = this.selModel.getSelectedCell() ? 1 : 0; + return String.format(this.ddText, count, count == 1 ? '' : 's'); } + });/* * Based on: * Ext JS Library 1.1.1 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 3a13bfb30d..ff98a3e654 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -35072,6 +35072,9 @@ Roo.grid.GridView = function(config){ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { + unselectable : 'unselectable="on"', + unselectableCls : 'x-unselectable', + rowClass : "x-grid-row", @@ -35193,7 +35196,7 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { if(!tpls.hcell){ tpls.hcell = new Roo.Template( '
', - '
{value}
', + '
{value}
', "
" ); tpls.hcell.disableFormats = true; @@ -35201,7 +35204,8 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { tpls.hcell.compile(); if(!tpls.hsplit){ - tpls.hsplit = new Roo.Template('
 
'); + tpls.hsplit = new Roo.Template('
 
'); tpls.hsplit.disableFormats = true; } tpls.hsplit.compile(); @@ -35225,7 +35229,8 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { if(!tpls.cell){ tpls.cell = new Roo.Template( '', - '
{value}
', + '
{value}
', "" ); tpls.cell.disableFormats = true; @@ -36528,6 +36533,7 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { this.dd = new Roo.grid.GridDragZone(this.grid, { ddGroup : this.grid.ddGroup || 'GridDD' }); + } /* @@ -36826,15 +36832,45 @@ Roo.extend(Roo.grid.GridDragZone, Roo.dd.DragZone, { getDragData : function(e){ var t = Roo.lib.Event.getTarget(e); var rowIndex = this.view.findRowIndex(t); + var sm = this.grid.selModel; + + //Roo.log(rowIndex); + + if (sm.getSelectedCell) { + // cell selection.. + if (!sm.getSelectedCell()) { + return false; + } + if (rowIndex != sm.getSelectedCell()[0]) { + return false; + } + + } + if(rowIndex !== false){ - var sm = this.grid.selModel; + + // if editorgrid.. + + + //Roo.log([ sm.getSelectedCell() ? sm.getSelectedCell()[0] : 'NO' , rowIndex ]); + //if(!sm.isSelected(rowIndex) || e.hasModifier()){ - // sm.mouseDown(e, t); + // //} if (e.hasModifier()){ sm.handleMouseDown(e, t); // non modifier buttons are handled by row select. } - return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()}; + + Roo.log("getDragData"); + + return { + grid: this.grid, + ddel: this.ddel, + rowIndex: rowIndex, + selections:sm.getSelections ? sm.getSelections() : ( + sm.getSelectedCell() ? [ grid.ds.getAt(sm.getSelectedCell()[0]) ] : [] + ) + }; } return false; }, @@ -38399,7 +38435,17 @@ Roo.extend(Roo.grid.EditorGrid, Roo.grid.Grid, { this.activeEditor.completeEdit(); } this.activeEditor = null; + }, + + /** + * Called to get grid's drag proxy text, by default returns this.ddText. + * @return {String} + */ + getDragDropText : function(){ + var count = this.selModel.getSelectedCell() ? 1 : 0; + return String.format(this.ddText, count, count == 1 ? '' : 's'); } + });/* * Based on: * Ext JS Library 1.1.1 diff --git a/roojs-ui.js b/roojs-ui.js index 6729739752..47dc65bdb5 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -776,15 +776,15 @@ px+=this.proxyOffsets[0];this.proxyTop.setLeftTop(px,py);this.proxyTop.show();if this.proxyBottom.setLeftTop(px,py+this.proxyTop.dom.offsetHeight+this.bottomOffset);this.proxyBottom.show();return pt;},onNodeEnter:function(n,dd,e,A){if(A.header!=n){this.positionIndicator(A.header,n,e);}},onNodeOver:function(n,dd,e,A){var B=false;if(A.header!=n){B=this.positionIndicator(A.header,n,e);}if(!B){this.proxyTop.hide();this.proxyBottom.hide();}return B?this.dropAllowed:this.dropNotAllowed;},onNodeOut:function(n,dd,e,A){this.proxyTop.hide();this.proxyBottom.hide();},onNodeDrop:function(n,dd,e,A){var h=A.header;if(h!=n){var cm=this.grid.colModel;var x=Roo.lib.Event.getPageX(e);var r=Roo.lib.Dom.getRegion(n.firstChild);var pt=(r.right-x)<=((r.right-r.left)/2)?"after":"before";var B=this.view.getCellIndex(h);var C=this.view.getCellIndex(n);var D=cm.isLocked(C);if(pt=="after"){C++;}if(B','','
','
','
','
{lockedHeader}
','
{lockedBody}
',"
",'
','
{header}
','
{body}
',"
",'
','
 
',"");B.master.disableformats=true;}if(!B.header){B.header=new Roo.Template('','{cells}',"
{splits}");B.header.disableformats=true;} -B.header.compile();if(!B.hcell){B.hcell=new Roo.Template('
','
{value}
',"
");B.hcell.disableFormats=true;} -B.hcell.compile();if(!B.hsplit){B.hsplit=new Roo.Template('
 
');B.hsplit.disableFormats=true;} +B.header.compile();if(!B.hcell){B.hcell=new Roo.Template('
','
{value}
',"
");B.hcell.disableFormats=true;} +B.hcell.compile();if(!B.hsplit){B.hsplit=new Roo.Template('
 
');B.hsplit.disableFormats=true;} B.hsplit.compile();if(!B.body){B.body=new Roo.Template('',"{rows}","
");B.body.disableFormats=true;} B.body.compile();if(!B.row){B.row=new Roo.Template('{cells}');B.row.disableFormats=true;} -B.row.compile();if(!B.cell){B.cell=new Roo.Template('','
{value}
',"");B.cell.disableFormats=true;} +B.row.compile();if(!B.cell){B.cell=new Roo.Template('','
{value}
',"");B.cell.disableFormats=true;} B.cell.compile();this.templates=B;},onColWidthChange:function(){this.updateColumns.apply(this,arguments);},onHeaderChange:function(){this.updateHeaders.apply(this,arguments);},onHiddenChange:function(){this.handleHiddenChange.apply(this,arguments);},onColumnMove:function(){this.handleColumnMove.apply(this,arguments);},onColumnLock:function(){this.handleLockChange.apply(this,arguments);},onDataChange:function(){this.refresh();this.updateHeaderSortState();},onClear:function(){this.refresh();},onUpdate:function(ds,A){this.refreshRow(A);},refreshRow:function(A){var ds=this.ds,B;if(typeof A=='number'){B=A;A=ds.getAt(B);}else {B=ds.indexOf(A);} 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.focusEl=new E(el.firstChild);this.focusEl.swallowEvent("click",true);this.headerPanel=new E(cs[1]);this.headerPanel.enableDisplayMode("block");this.scroller=new E(cs[2]);this.scrollSizer=new E(this.scroller.dom.firstChild);this.lockedWrap=new E(cs[3]);this.lockedHd=new E(this.lockedWrap.dom.firstChild);this.lockedBody=new E(this.lockedWrap.dom.childNodes[1]);this.mainWrap=new E(cs[4]);this.mainHd=new E(this.mainWrap.dom.firstChild);this.mainBody=new E(this.mainWrap.dom.childNodes[1]);this.footerPanel=new E(cs[5]);this.footerPanel.enableDisplayMode("block");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