From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/grid/_grid/selection.js | 215 ++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 includes/js/dojox/grid/_grid/selection.js (limited to 'includes/js/dojox/grid/_grid/selection.js') diff --git a/includes/js/dojox/grid/_grid/selection.js b/includes/js/dojox/grid/_grid/selection.js new file mode 100644 index 0000000..75229c0 --- /dev/null +++ b/includes/js/dojox/grid/_grid/selection.js @@ -0,0 +1,215 @@ +if(!dojo._hasResource['dojox.grid._grid.selection']){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource['dojox.grid._grid.selection'] = true; +dojo.provide('dojox.grid._grid.selection'); + +dojo.declare("dojox.grid.selection", + null, + { + // summary: + // Manages row selection for grid. Owned by grid and used internally + // for selection. Override to implement custom selection. + + constructor: function(inGrid){ + this.grid = inGrid; + this.selected = []; + }, + + multiSelect: true, + selected: null, + updating: 0, + selectedIndex: -1, + + onCanSelect: function(inIndex){ + return this.grid.onCanSelect(inIndex); + }, + + onCanDeselect: function(inIndex){ + return this.grid.onCanDeselect(inIndex); + }, + + onSelected: function(inIndex){ + return this.grid.onSelected(inIndex); + }, + + onDeselected: function(inIndex){ + return this.grid.onDeselected(inIndex); + }, + + //onSetSelected: function(inIndex, inSelect) { }; + onChanging: function(){ + }, + + onChanged: function(){ + return this.grid.onSelectionChanged(); + }, + + isSelected: function(inIndex){ + return this.selected[inIndex]; + }, + + getFirstSelected: function(){ + for(var i=0, l=this.selected.length; i= inIndex){ + this.selectedIndex++; + } + }, + + remove: function(inIndex){ + this.selected.splice(inIndex, 1); + if(this.selectedIndex >= inIndex){ + this.selectedIndex--; + } + }, + + unselectAll: function(inExcept){ + for(var i in this.selected){ + if((i!=inExcept)&&(this.selected[i]===true)){ + this.deselect(i); + } + } + }, + + shiftSelect: function(inFrom, inTo){ + var s = (inFrom >= 0 ? inFrom : inTo), e = inTo; + if(s > e){ + e = s; + s = inTo; + } + for(var i=s; i<=e; i++){ + this.addToSelection(i); + } + }, + + clickSelect: function(inIndex, inCtrlKey, inShiftKey){ + this.beginUpdate(); + if(!this.multiSelect){ + this.select(inIndex); + }else{ + var lastSelected = this.selectedIndex; + if(!inCtrlKey){ + this.unselectAll(inIndex); + } + if(inShiftKey){ + this.shiftSelect(lastSelected, inIndex); + }else if(inCtrlKey){ + this.toggleSelect(inIndex); + }else{ + this.addToSelection(inIndex) + } + } + this.endUpdate(); + }, + + clickSelectEvent: function(e){ + this.clickSelect(e.rowIndex, e.ctrlKey, e.shiftKey); + }, + + clear: function(){ + this.beginUpdate(); + this.unselectAll(); + this.endUpdate(); + } + +}); + +} -- cgit v1.2.3