From 522ae82bd3a30e30ed50c444fd93164479a8e051 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Benoi=CC=82t=20Pin?= <benoit.pin@gmail.com>
Date: Wed, 4 Dec 2013 23:32:56 +0100
Subject: [PATCH] =?utf8?q?Ajout=20barre=20de=20progression=20de=20l?=
 =?utf8?q?=E2=80=99upload=20du=20fichier=20courant.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 skins/ajax_scripts/folder_contents_script.js | 26 +++++++++++++++-----
 skins/custom_generic/zpt_stylesheet.css.dtml | 13 +++++++++-
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/skins/ajax_scripts/folder_contents_script.js b/skins/ajax_scripts/folder_contents_script.js
index 7204a4e..d427939 100644
--- a/skins/ajax_scripts/folder_contents_script.js
+++ b/skins/ajax_scripts/folder_contents_script.js
@@ -244,6 +244,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 +274,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,28 +301,31 @@ DDFolderUploader.prototype.handleFiles = function(files) {
 };
 
 DDFolderUploader.prototype.beforeUpload = function(item) {
-  this.uploadedItem = item;
-	// To be implemented by decendant.
+  	this.uploadedItem = item;
+	this.progressBar = item.progressBar;
 };
 
 DDFolderUploader.prototype.uploadCompleteHandlerCB = function(req) {
 	var item = this.uploadedItem;
 	var row = getCopyOfNode(req.responseXML.documentElement.firstChild);
-  row.className = item.className;
+  	row.className = item.className;
 
 	if (req.status === 200) {
 		// update
-    console.log('todo');
+    	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
diff --git a/skins/custom_generic/zpt_stylesheet.css.dtml b/skins/custom_generic/zpt_stylesheet.css.dtml
index 8acbdab..77011e0 100644
--- a/skins/custom_generic/zpt_stylesheet.css.dtml
+++ b/skins/custom_generic/zpt_stylesheet.css.dtml
@@ -390,7 +390,18 @@ textarea {
 }
 .listing .even {
   background-color: &dtml-evenRowBackgroundColor;;
-} 
+}
+
+.listing span.upload-progress {
+  display: block;
+  position:absolute;
+  background:#ef8e32;
+  height:4px;
+  border-radius:2px;
+  width:0;
+  top:3px;
+}
+
 
 /* Batched navigation */
 
-- 
2.20.1