Abandon de l’affichage de la position (c’est moche). Il faudra trouver un moyen de...
[Plinn.git] / skins / ajax_scripts / folder_contents_script.js
index 0351cde..800a746 100644 (file)
@@ -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,17 +39,16 @@ 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, row;
+       for (i=0 ; i < rows.length ; i++ ) {
+               row = rows[i];
+               row.pos = i + this.firstItemPos;
+               if (i % 2 === 0) {
+                       row.className = "even"; }
+               else {
+                       row.className = "odd"; }
        }
 };
 
@@ -121,16 +120,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();