X-Git-Url: https://scm.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/3f727ea05aae7e2b69274046075b4d13feba2223..1604fa1edceb391a268f458fe09f6431bd818e61:/skins/ajax_scripts/folder_contents_script.js diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index 7edda7d..066bfc0 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -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,13 +29,15 @@ 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) { + if (browser.isIE10max) { this.listing.ondragstart = function() { window.event.returnValue = false;}; } }; @@ -68,7 +70,7 @@ FolderDDropControler.prototype.moveRow = function(evt){ var targetRow = this.targetRow; if (targetRow !== null) { this.noOver = false; - if (browser.isIE) {document.selection.clear();} + if (browser.isIE10max) {document.selection.clear();} var overRow = getTargetRow(evt); if (overRow.pos === targetRow.pos) {return;} @@ -232,7 +234,7 @@ DropTarget.prototype.drop = function(evt) { }; DropTarget.prototype.highlightTarget = function(evt){ - if (browser.isIE) {document.selection.clear();} + if (browser.isIE10max) {document.selection.clear();} var target = getTargetedObject(evt); if (this.folderDDControler.targetRow && target.nodeName === "A" && @@ -350,14 +352,25 @@ DDFolderUploader.prototype.beforeUpload = function(item) { DDFolderUploader.prototype.uploadCompleteHandlerCB = function(req) { var item = this.uploadedItem; var row = getCopyOfNode(req.responseXML.documentElement.firstChild); - row.className = item.className; if (req.status === 200) { // update - console.log('todo'); + this.listing.removeChild(item); + var itemUrl = row.getElementsByTagName('a')[0].href; + var links = this.listing.getElementsByTagName('a'); + var i, existingRow; + for (i=0 ; i < links.length ; i++) { + if (links[i].href === itemUrl) { + existingRow = links[i].parentNode.parentNode; + row.className = existingRow.className; + this.listing.replaceChild(row, existingRow); + break; + } + } } else if(req.status === 201) { // creation + row.className = item.className; this.listing.replaceChild(row, item); this.progressBarMaxSize = row.clientWidth; }