diff options
author | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 21:53:58 +0000 |
---|---|---|
committer | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 21:53:58 +0000 |
commit | ebb90aa0b972184a818b49d250b2ba7cc9c36d53 (patch) | |
tree | 5de550b8c2ba8109161306edbe829be6ef2648ff /chrome/browser/resources/filebrowse.html | |
parent | 885ff1dfd127346d8fd1bfa239c7375773aabe48 (diff) | |
download | chromium_src-ebb90aa0b972184a818b49d250b2ba7cc9c36d53.zip chromium_src-ebb90aa0b972184a818b49d250b2ba7cc9c36d53.tar.gz chromium_src-ebb90aa0b972184a818b49d250b2ba7cc9c36d53.tar.bz2 |
Submmiting for achuith, plus some additional changes to the filebrowser for download cases
review cl:
http://codereview.chromium.org/3575016/show
Review URL: http://codereview.chromium.org/3530013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/filebrowse.html')
-rw-r--r-- | chrome/browser/resources/filebrowse.html | 72 |
1 files changed, 52 insertions, 20 deletions
diff --git a/chrome/browser/resources/filebrowse.html b/chrome/browser/resources/filebrowse.html index 3b1a9f1..510f068 100644 --- a/chrome/browser/resources/filebrowse.html +++ b/chrome/browser/resources/filebrowse.html @@ -254,7 +254,7 @@ li.filebrowserow { .downloadstatus { width: 100%; font-size: .6em; - height: 10px; + height: 20px; } .downloadpause { @@ -624,7 +624,8 @@ function $(o) { */ function partial(fn, var_args) { var args = Array.prototype.slice.call(arguments, 1); - return function() { + return function(e) { + if (e.stopPropagation) e.stopPropagation(); // Prepend the bound arguments to the current arguments. var newArgs = Array.prototype.slice.call(arguments); newArgs.unshift.apply(newArgs, args); @@ -1140,6 +1141,14 @@ function downloadsList(results) { function allowDownload(id, path) { var element = $(path); element.removeAttribute('dangerous'); + var pauseDiv = $('downloaditem' + id); + if (pauseDiv) { + if (pauseDiv.firstChild) { + pauseDiv.removeChild(pauseDiv.firstChild); + } + pauseDiv.onclick = partial(pauseToggleDownload, id); + pauseDiv.textContent = kPauseDownload; + } chrome.send('allowDownload', ['' + id]); } @@ -1160,7 +1169,7 @@ function newDownload(results) { var extracted = getPathAndFilenameForPath(results[x].file_path); var dirId = $('list/dir/' + extracted[1]); if (dirId) { - element = createNewItem(extracted[2], results[x].file_path, false); + element = createNewItem(results[x].file_name, results[x].file_path, false); downloadList.push(element); if (dirId.firstChild) { dirId.insertBefore(element, dirId.firstChild); @@ -1173,7 +1182,7 @@ function newDownload(results) { } } -function removeDownload(element) { +function removeDownload(element, dirId) { var status = undefined; var pause = undefined; for (var x = 0; x < element.children.length; x++) { @@ -1199,10 +1208,18 @@ function removeDownload(element) { } } downloadList = elementList; + if (dirId) { + dirId.removeChild(element); + } } function downloadUpdated(results) { var removeDownloads = []; + removeDownloads.pushUnique = function (element) { + if (this.indexOf(element) === -1) { + this.push(element); + } + }; for (var y = 0; y < downloadList.length; y++) { var found = false; for (var x = 0; x < results.length; x++) { @@ -1213,19 +1230,18 @@ function downloadUpdated(results) { } } if (!found) { - removeDownloads.push(downloadList[y]); + removeDownloads.pushUnique(downloadList[y]); } } - for (var x = 0; x < removeDownloads.length; x++) { - removeDownload(removeDownloads[x]); - } + for (var x = 0; x < results.length; x++) { var element = $(results[x].file_path); + // extracted and dirId should be computed outside this loop. + var extracted = getPathAndFilenameForPath(results[x].file_path); + var dirId = $('list/dir/' + extracted[1]); if (!element && results[x].state != 'CANCELLED') { - extracted = getPathAndFilenameForPath(results[x].file_path); - var dirId = $('list/dir/' + extracted[1]); - if (dirId) { - element = createNewItem(extracted[2], results[x].file_path, false); + if (dirId) { + element = createNewItem(results[x].file_name, results[x].file_path, false); if (dirId.firstChild) { dirId.insertBefore(element, dirId.firstChild); } else { @@ -1236,8 +1252,8 @@ function downloadUpdated(results) { } if (element) { if (results[x].state == 'CANCELLED') { - element.parentNode.removeChild(element); - continue; + element.parentNode.removeChild(element); + continue; } if (results[x].percent < 100 || results[x].state == 'DANGEROUS') { var progressDiv = null; @@ -1250,6 +1266,7 @@ function downloadUpdated(results) { if (progressDiv == null) { downloadList.push(element); element.className = 'filebrowserow downloading'; + fixTitleForItem(element, results[x]); var progressDiv = document.createElement('div'); progressDiv.className = 'downloadstatus'; element.appendChild(progressDiv); @@ -1279,24 +1296,33 @@ function downloadUpdated(results) { pauseDiv.appendChild(yes); pauseDiv.appendChild(no); progressDiv.textContent = ''; - } else if (results[x].state == "PAUSED") { - pauseDiv.textContent = kResumeDownload; - } else if (results[x].state == "IN_PROGRESS") { - pauseDiv.textContent = kPauseDownload; } pauseDiv.id = 'downloaditem' + results[x].id; element.appendChild(pauseDiv); } + var pauseDiv = $('downloaditem' + results[x].id); + if (pauseDiv && + results[x].state == "PAUSED" && + pauseDiv.textContent != kResumeDownload) { + pauseDiv.textContent = kResumeDownload; + } else if (pauseDiv && + results[x].state == "IN_PROGRESS" && + pauseDiv.textContent != kPauseDownload) { + pauseDiv.textContent = kPauseDownload; + } if (results[x].percent < 100 && results[x].state != 'DANGEROUS') { progressDiv.textContent = results[x].progress_status_text; } - } else { - removeDownload(element); + } else if (downloadList.indexOf(element) !== -1) { + removeDownloads.pushUnique(element); } } } + for (x = 0; x < removeDownloads.length; x++) { + removeDownload(removeDownloads[x], dirId); + } } function dialogNewFolderClick() { @@ -1677,6 +1703,12 @@ function createNewItem(title, path, isDirectory) { return element; } +function fixTitleForItem(element, result) { + element.title = result.file_name; + // This is a bit fragile. + element.getElementsByTagName('span')[0].textContent = result.file_name; +} + function clearChildren(element) { element.innerHTML = ''; } |