L’objet FolderDDropControler doit être instancié à chaque fois (même quand le critère...
authorBenoît Pin <benoit.pin@gmail.com>
Sun, 8 Dec 2013 20:59:09 +0000 (21:59 +0100)
committerBenoît Pin <benoit.pin@gmail.com>
Sun, 8 Dec 2013 20:59:09 +0000 (21:59 +0100)
skins/ajax_scripts/folder_contents_script.js
skins/photo_theme/folder_contents_macros.pt

index 7edda7d..45ec76a 100644 (file)
@@ -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;
@@ -29,10 +29,12 @@ FolderDDropControler = function(listing, 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) {
index 042dfbc..a9d046a 100644 (file)
     </div>
     <script type="text/javascript">
                (function(){
-                       // variables for drag-and-drop ordered support
-                       var ddEnabled = false
-                       try {
-                               var firstItemPos = parseInt(document.getElementById("FirstItemPos").innerHTML);
-                               ddEnabled = true;
-                       }
-                       catch (e) {}
-
-                       var topNavBatchBar              = document.getElementById("topNavBatchBar");
-                       var bottomNavBatchBar   = document.getElementById("bottomNavBatchBar");
+                       // ordering / selecting
+                       var firsItemPosElement = document.getElementById('FirstItemPos');
                        var listing = document.getElementById("FolderListingBody");
-
-                       if (ddEnabled) {
-                               var fDDcontroler = new FolderDDropControler(listing, firstItemPos);
-                               var topNavBatchBar              = document.getElementById("topNavBatchBar");
-                               var bottomNavBatchBar   = document.getElementById("bottomNavBatchBar");
+                       var orderable = firsItemPosElement ? true : false;
+                       var firstItemPos = orderable ? parseInt(firsItemPosElement.innerHTML, 10) : 1;
+                       var fDDcontroler = new FolderDDropControler(listing, orderable, firstItemPos);
+                       var topNavBatchBar, bottomNavBatchBar;
+                       if (orderable) {
+                               topNavBatchBar = document.getElementById("topNavBatchBar");
+                               bottomNavBatchBar = document.getElementById("bottomNavBatchBar");
                                if (topNavBatchBar && bottomNavBatchBar) {
                                        new DropTarget(topNavBatchBar, fDDcontroler);
                                        new DropTarget(bottomNavBatchBar, fDDcontroler);
                                }
                        }
-
-
                        addListener(document.getElementById("FolderListingHeader"), "click", loadListing);
                        if (topNavBatchBar && bottomNavBatchBar) {
                                addListener(topNavBatchBar, "click", loadListing);
                                addListener(bottomNavBatchBar, "click", loadListing);
                        }
-                       
+                       // upload by drag and drop
                        var uploadUrl = absolute_url() + '/put_upload';
-      new DDFolderUploader(document.getElementById('ForematterCell'), uploadUrl, listing);
+                       new DDFolderUploader(document.getElementById('ForematterCell'), uploadUrl, listing);
 
                }());
     </script>