Index: trunk/core/admin_templates/js/grid.js =================================================================== diff -u -N -r6656 -r7391 --- trunk/core/admin_templates/js/grid.js (.../grid.js) (revision 6656) +++ trunk/core/admin_templates/js/grid.js (.../grid.js) (revision 7391) @@ -62,6 +62,14 @@ else this.class_off = class_off; this.HTMLelement = an_element; + + if (document.getElementById('left_'+an_element.id)) { + this.LeftElement = document.getElementById('left_'+an_element.id); + } + else { + this.LeftElement = false; + } + this.CheckBox = cb; this.value = this.ItemId; @@ -77,6 +85,15 @@ this.HTMLelement.ondblclick = function(ev) { this.GridItem.DblClick(ev); } + if ( this.LeftElement ) { + this.LeftElement.GridItem = this; + this.LeftElement.onclick = function(ev) { + this.GridItem.Click(ev); + }; + this.LeftElement.ondblclick = function(ev) { + this.GridItem.DblClick(ev); + } + } if ( isset(this.CheckBox) ) { this.CheckBox.GridItem = this; this.CheckBox.onclick = function(ev) { @@ -96,6 +113,14 @@ this.HTMLelement.ondblclick = function(ev) { return false; } + if ( this.LeftElement ) { + this.LeftElement.onclick = function(ev) { + return false; + }; + this.LeftElement.ondblclick = function(ev) { + return false; + } + } if ( isset(this.CheckBox) ) { this.CheckBox.onclick = function(ev) { return false; @@ -108,6 +133,9 @@ if (this.selected) return; this.selected = true; this.HTMLelement.className = this.class_on; + if ( this.LeftElement ) { + this.LeftElement.className = this.class_on; + } if ( isset(this.CheckBox) ) { this.CheckBox.checked = true; } @@ -126,25 +154,21 @@ if ( !this.selected && !force) return; this.selected = false; this.HTMLelement.className = this.class_off; + if ( this.LeftElement ) { + this.LeftElement.className = this.class_off; + } if ( isset(this.CheckBox) ) { this.CheckBox.checked = false; } this.Grid.SelectedCount--; if (typeof (this.Grid.OnUnSelect) == 'function' ) { this.Grid.OnUnSelect(this.ItemId); } + this.Grid.LastSelectedId = null; } GridItem.prototype.ClearBrowserSelection = function() { - if (window.getSelection) { - // removeAllRanges will be supported by Opera from v 9+, do nothing by now - var selection = window.getSelection(); - if (selection.removeAllRanges) { // Mozilla & Opera 9+ - window.getSelection().removeAllRanges(); - } - } else if (document.selection && !is.opera) { // IE - document.selection.empty(); - } + ClearBrowserSelection(); } GridItem.prototype.Click = function (ev) @@ -153,6 +177,7 @@ this.Grid.ClearAlternativeGridsSelection('GridItem.Click'); var e = !is.ie ? ev : window.event; + if (e.shiftKey && !this.Grid.RadioMode) { this.Grid.SelectRangeUpTo(this.sequence); } @@ -163,7 +188,14 @@ else { if (!(this.Grid.RadioMode && this.Grid.LastSelectedId == this.ItemId && this.selected)) { // don't clear selection if item same as current is selected - this.Grid.ClearSelection(null,'GridItem.Click'); + if (!this.Grid.StickySelection) { + this.Grid.ClearSelection(null,'GridItem.Click'); + } + else { + if (this.Grid.LastSelectedId == this.ItemId) { + return; + } + } this.Toggle(); } } @@ -219,6 +251,10 @@ this.AlternativeGrids = new Array(); this.DependantButtons = new Array(); this.RadioMode = false; + + // K3-style sticky selection, selection an item does not unselect currently selected + // even w/o Ctrl key pressed + this.StickySelection = false; } Grid.prototype.AddItem = function( an_item ) { @@ -249,6 +285,33 @@ this.Items[i].Init(); } this.ClearSelection( true,'Grid.InitItems' ); + + var a_Grid = this; + addEvent(document, 'keyup', function(ev) { + var e = !is.ie ? ev : window.event; + switch (e.keyCode) { + case 65: + if (!e.ctrlKey) break; + a_Grid.SelectAll(); + ClearBrowserSelection() +// window.setTimeout(ClearBrowserSelection, 500); + break; + case 27: + a_Grid.ClearSelection(); + break; + case 33: + case 37: + //alert('<-') // go to prev page here + break; + case 34: + case 39: + // alert('->') // go to next page here + break; + case 88: + ClearBrowserSelection(); + break; + } + }); } Grid.prototype.DisableClicking = function() {