X-Git-Url: https://svn.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/a8f0edf22418e87346d8561e5e5904dc262acbdd..4d01bfd85c7c9c07ce1f3011e1a6cd5aa25fb5a1:/skins/ajax_scripts/folder_contents_script.js?ds=inline diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js index dc31b4c..00bdeb9 100644 --- a/skins/ajax_scripts/folder_contents_script.js +++ b/skins/ajax_scripts/folder_contents_script.js @@ -29,7 +29,8 @@ FolderDDropControler = function(listing) { this.listing.onmousedown = function(evt) {thisControler.drag(evt);}; this.listing.onmouseover = function(evt) {thisControler.moveRow(evt);}; this.listing.onmouseup = function(evt) {thisControler.drop(evt);}; - this.listing.onclick = function(evt) {thisControler.disableClickAfterDrop(evt);}; + addListener(this.listing, 'click', function(evt) {thisControler.disableClickAfterDrop(evt);}); + addListener(this.listing, 'click', function(evt) {thisControler.selectCBRange(evt);}); if (browser.isIE) { this.listing.ondragstart = function() { window.event.returnValue = false;}; @@ -134,6 +135,10 @@ FolderDDropControler.prototype.disableClickAfterDrop = function(evt) { this.reset(); }; +FolderDDropControler.prototype.selectCBRange = function(evt) { +}; + + FolderDDropControler.prototype.reset = function() { this.targetRow = null; this.lastOverPosition = null; @@ -244,6 +249,7 @@ loadListing = function(evt) { DDFolderUploader = function(dropbox, uploadUrl, listing) { DDFileUploaderBase.apply(this, [dropbox, uploadUrl]); this.listing = listing; + this.progressBarMaxSize = listing.clientWidth; var thead = listing; do { thead = thead.previousSibling; @@ -273,9 +279,19 @@ DDFolderUploader.prototype.createRow = function(file) { this.lastRowClassName = row.className; var td = document.createElement('td'); td.setAttribute('colspan', this.tableSpan); - td.innerHTML = file.name; + var relSpan = document.createElement('span'); + relSpan.style.position = 'relative'; + td.appendChild(relSpan); + var progressBar = document.createElement('span'); + progressBar.className = 'upload-progress'; + row.progressBar = progressBar; + relSpan.appendChild(progressBar); + var fileNameSpan = document.createElement('span'); + fileNameSpan.innerHTML = file.name; + td.appendChild(fileNameSpan); row.appendChild(td); this.listing.appendChild(row); + this.progressBarMaxSize = row.clientWidth; return row; }; @@ -290,16 +306,31 @@ DDFolderUploader.prototype.handleFiles = function(files) { }; DDFolderUploader.prototype.beforeUpload = function(item) { - // To be implemented by decendant. + this.uploadedItem = item; + this.progressBar = item.progressBar; }; DDFolderUploader.prototype.uploadCompleteHandlerCB = function(req) { - // To be implemented by descendant. + var item = this.uploadedItem; + var row = getCopyOfNode(req.responseXML.documentElement.firstChild); + row.className = item.className; + + if (req.status === 200) { + // update + console.log('todo'); + } + else if(req.status === 201) { + // creation + this.listing.replaceChild(row, item); + this.progressBarMaxSize = row.clientWidth; + } }; DDFolderUploader.prototype.progressHandlerCB = function(progress) { - // To be implemented by descendant. // 0 <= progress <= 1 + var size = this.progressBarMaxSize * progress; + size = Math.round(size); + this.progressBar.style.width = size + 'px'; }; }()); \ No newline at end of file