X-Git-Url: https://svn.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/8c427cd00d1605e275df038865ffa85623171c13..e932032bdbb367869cd8c7346a98f6b7660c41dd:/skins/ajax_scripts/folder_contents_script.js diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index 89cca56..6480f9d 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -18,7 +18,7 @@ function getTargetRow(evt){ return target; } -FolderDDropControler = function(listing, firstItemPos) { +FolderDDropControler = function(listing, orderable, firstItemPos) { this.folderUrl = document.getElementById("FolderUrl").innerHTML; this.targetRow = null; this.lastOverPosition = null; @@ -27,24 +27,32 @@ 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);}; - this.listing.onmouseup = function(evt) {thisControler.drop(evt);}; - addListener(this.listing, 'click', function(evt) {thisControler.disableClickAfterDrop(evt);}); + if (orderable) { + this.listing.onmousedown = function(evt) {thisControler.drag(evt);}; + this.listing.onmouseover = function(evt) {thisControler.moveRow(evt);}; + this.listing.onmouseup = function(evt) {thisControler.drop(evt);}; + addListener(this.listing, 'click', function(evt) {thisControler.disableClickAfterDrop(evt);}); + } addListener(this.listing, 'click', function(evt) {thisControler.selectCBRange(evt);}); - if (browser.isIE) { + if (browser.isIE10max) { this.listing.ondragstart = function() { window.event.returnValue = false;}; } }; FolderDDropControler.prototype._updatePositions = function() { var rows = this.listing.getElementsByTagName("TR"); - var i; + var i, row; for (i=0 ; i < rows.length ; i++ ) { - rows[i].pos = i + this.firstItemPos; } - + row = rows[i]; + row.pos = i + this.firstItemPos; + if (i % 2 === 0) { + row.className = "even"; } + else { + row.className = "odd"; } + } }; FolderDDropControler.prototype.drag = function(evt){ @@ -62,7 +70,7 @@ FolderDDropControler.prototype.moveRow = function(evt){ var targetRow = this.targetRow; if (targetRow !== null) { this.noOver = false; - if (browser.isIE) {document.selection.clear();} + if (browser.isIE10max) {document.selection.clear();} var overRow = getTargetRow(evt); if (overRow.pos === targetRow.pos) {return;} @@ -115,16 +123,7 @@ FolderDDropControler.prototype.drop = function(evt){ String(this.lastOverPosition - 1 + trim); // reinitialize positions - var rows = this.listing.getElementsByTagName("TR"), row; - var i; - for (i = 0 ; i < rows.length ; i++) { - row = rows[i]; - row.pos = i+1; - if (i % 2 === 0){ - row.className = "even";} - else{ - row.className = "odd";} - } + this._updatePositions(); // send request var req = new XMLHttpRequest(); @@ -146,8 +145,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