Début d’implémentation de l’upload par glisser / déposer dans les dossiers Plinn.
authorBenoît Pin <benoit.pin@gmail.com>
Tue, 3 Dec 2013 22:30:31 +0000 (23:30 +0100)
committerBenoît Pin <benoit.pin@gmail.com>
Tue, 3 Dec 2013 22:30:31 +0000 (23:30 +0100)
skins/ajax_scripts/folder_contents_script.js
skins/photo_theme/folder_contents_macros.pt

index ece076d..dc31b4c 100644 (file)
@@ -7,6 +7,7 @@
 var FolderDDropControler;
 var DropTarget;
 var loadListing;
+var DDFolderUploader;
 
 (function(){
 
@@ -240,4 +241,65 @@ loadListing = function(evt) {
        return false;
 }
 
+DDFolderUploader = function(dropbox, uploadUrl, listing) {
+       DDFileUploaderBase.apply(this, [dropbox, uploadUrl]);
+       this.listing = listing;
+       var thead = listing;
+       do {
+               thead = thead.previousSibling;
+       } while (thead.tagName !== 'THEAD')
+
+       var cells = thead.getElementsByTagName('th');
+       var cell;
+       this.tableSpan = 0;
+       for (var i = 0 ; i < cells.length ; i++) {
+               cell = cells[i];
+               this.tableSpan += cell.getAttribute('colspan') ? Number(cell.getAttribute('colspan')) : 1;
+       }
+       var lastRow = listing.lastChild;
+       while(lastRow && lastRow.tagName !== 'TR') {
+               lastRow = lastRow.previousSibling;
+       }
+       this.lastRowClassName = lastRow ? lastRow.className : 'even';
+};
+
+copyPrototype(DDFolderUploader, DDFileUploaderBase);
+
+
+DDFolderUploader.prototype.createRow = function(file) {
+       var row = document.createElement('tr');
+       row.file = file;
+       row.className = this.lastRowClassName === 'even' ? 'odd' : 'even';
+       this.lastRowClassName = row.className;
+       var td = document.createElement('td');
+       td.setAttribute('colspan', this.tableSpan);
+       td.innerHTML = file.name;
+       row.appendChild(td);
+       this.listing.appendChild(row);
+       return row;
+};
+
+// Methods about upload
+DDFolderUploader.prototype.handleFiles = function(files) {
+       var file, i, row;
+       for (i = 0; i < files.length; i++) {
+               file = files[i];
+               row = this.createRow(file);
+               this.uploadQueuePush(row);
+       }
+};
+
+DDFolderUploader.prototype.beforeUpload = function(item) {
+       // To be implemented by decendant.
+};
+
+DDFolderUploader.prototype.uploadCompleteHandlerCB = function(req) {
+       // To be implemented by descendant.
+};
+
+DDFolderUploader.prototype.progressHandlerCB = function(progress) {
+       // To be implemented by descendant.
+       // 0 <= progress <= 1
+};
+
 }());
\ No newline at end of file
index 00d2ee9..bd8e7f5 100644 (file)
@@ -77,7 +77,7 @@
       <span metal:use-macro="here/batch_macros/macros/navigation">batch navigation</span>
     </div>
                <script type="text/javascript">
-               //<!--
+               (function(){
                        // variables for drag-and-drop ordered support
                        var ddEnabled = false
                        try {
                                addListener(topNavBatchBar, "click", loadListing);
                                addListener(bottomNavBatchBar, "click", loadListing);
                        }
+                       
+                       var uploadUrl = absolute_url() + '/put_upload';
+      // new DDFolderUploader(document.getElementById('ForematterCell'), uploadUrl, listing);
 
-               //-->
+               }());
                </script>
   </body>