From: Benoît Pin Date: Sun, 8 Dec 2013 19:44:11 +0000 (+0100) Subject: Implémentation de la sélection par range des cases à cocher. X-Git-Url: https://scm.cri.ensmp.fr/git/Plinn.git/commitdiff_plain/3f727ea05aae7e2b69274046075b4d13feba2223?ds=inline Implémentation de la sélection par range des cases à cocher. --- diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index 800a746..7edda7d 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -27,6 +27,7 @@ FolderDDropControler = function(listing, firstItemPos) { this.listing = listing; this.firstItemPos = firstItemPos; this._updatePositions(); + this.lastCBChecked = undefined; var thisControler = this; this.listing.onmousedown = function(evt) {thisControler.drag(evt);}; this.listing.onmouseover = function(evt) {thisControler.moveRow(evt);}; @@ -120,7 +121,7 @@ FolderDDropControler.prototype.drop = function(evt){ String(this.lastOverPosition - 1 + trim); // reinitialize positions - this._updatePositions() + this._updatePositions(); // send request var req = new XMLHttpRequest(); @@ -142,8 +143,37 @@ FolderDDropControler.prototype.disableClickAfterDrop = function(evt) { }; FolderDDropControler.prototype.selectCBRange = function(evt) { + var target = getTargetedObject(evt); + if (target.tagName === 'INPUT' && target.type === 'checkbox') { + evt = getEventObject(evt); + var shift = evt.shiftKey; + if (shift && this.lastCBChecked) { + var from = this.getCBIndex(this.lastCBChecked); + var to = this.getCBIndex(target); + var rows = this.listing.getElementsByTagName('TR'); + var start = Math.min(from, to); + var stop = Math.max(from, to); + var i; + for (i=start ; i