En fait, on a déjà l’index de position des éléments – sauf qu’il était créé en dehors...
authorBenoît Pin <benoit.pin@gmail.com>
Sun, 8 Dec 2013 14:05:16 +0000 (15:05 +0100)
committerBenoît Pin <benoit.pin@gmail.com>
Sun, 8 Dec 2013 14:05:16 +0000 (15:05 +0100)
skins/ajax_scripts/folder_contents_script.js
skins/photo_theme/folder_contents_macros.pt

index 0351cde..89cca56 100644 (file)
@@ -18,15 +18,15 @@ function getTargetRow(evt){
        return target;
 }
 
        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.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);};
        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){
 };
 
 FolderDDropControler.prototype.drag =  function(evt){
index 7d25a02..c2c3780 100644 (file)
                        var listing = document.getElementById("FolderListingBody");
 
                        if (ddEnabled) {
                        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) {
                                var topNavBatchBar              = document.getElementById("topNavBatchBar");
                                var bottomNavBatchBar   = document.getElementById("bottomNavBatchBar");
                                if (topNavBatchBar && bottomNavBatchBar) {