From: Benoît Pin Date: Sun, 8 Dec 2013 14:05:16 +0000 (+0100) Subject: En fait, on a déjà l’index de position des éléments – sauf qu’il était créé en dehors... X-Git-Url: https://scm.cri.mines-paristech.fr/git/Plinn.git/commitdiff_plain/8c427cd00d1605e275df038865ffa85623171c13 En fait, on a déjà l’index de position des éléments – sauf qu’il était créé en dehors du constructeur. On l’y met, c’est plus propre. --- diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index 0351cde..89cca56 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -18,15 +18,15 @@ function getTargetRow(evt){ return target; } -FolderDDropControler = function(listing) { +FolderDDropControler = function(listing, firstItemPos) { this.folderUrl = document.getElementById("FolderUrl").innerHTML; this.targetRow = null; this.lastOverPosition = null; this.prevDirUp = null; this.noOver = true; this.listing = listing; - this.checkboxes = undefined; - this._updateCBIndex(); + this.firstItemPos = firstItemPos; + this._updatePositions(); var thisControler = this; this.listing.onmousedown = function(evt) {thisControler.drag(evt);}; this.listing.onmouseover = function(evt) {thisControler.moveRow(evt);}; @@ -39,18 +39,12 @@ FolderDDropControler = function(listing) { } }; -FolderDDropControler.prototype._updateCBIndex = function() { - var cbs = this.listing.getElementsByTagName('INPUT'); - var index = 0; - var cb, i; - this.checkboxes = []; - for (i=0 ; i < cbs.length ; i++) { - cb = cbs[i]; - if (cb.type === 'checkbox') { - cb.position = index++; - this.checkboxes[cb.position] = cb; - } - } +FolderDDropControler.prototype._updatePositions = function() { + var rows = this.listing.getElementsByTagName("TR"); + var i; + for (i=0 ; i < rows.length ; i++ ) { + rows[i].pos = i + this.firstItemPos; } + }; FolderDDropControler.prototype.drag = function(evt){ diff --git a/skins/photo_theme/folder_contents_macros.pt b/skins/photo_theme/folder_contents_macros.pt index 7d25a02..c2c3780 100644 --- a/skins/photo_theme/folder_contents_macros.pt +++ b/skins/photo_theme/folder_contents_macros.pt @@ -91,11 +91,7 @@ var listing = document.getElementById("FolderListingBody"); if (ddEnabled) { - var rows = listing.getElementsByTagName("TR") - for ( var i = 0 ; i < rows.length ; i++ ) - rows[i].pos = i + firstItemPos; - - var fDDcontroler = new FolderDDropControler(listing); + var fDDcontroler = new FolderDDropControler(listing, firstItemPos); var topNavBatchBar = document.getElementById("topNavBatchBar"); var bottomNavBatchBar = document.getElementById("bottomNavBatchBar"); if (topNavBatchBar && bottomNavBatchBar) {