diff options
author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 21:21:12 +0000 |
---|---|---|
committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 21:21:12 +0000 |
commit | d41355e6f0576dc372a6047ffc8e6f0fdea0129d (patch) | |
tree | 559d0200951e69c1b904edeafd45f5edb53844c5 /chrome/browser/resources | |
parent | b4abd1f1c5973ba9877f6617549d72c1fde74595 (diff) | |
download | chromium_src-d41355e6f0576dc372a6047ffc8e6f0fdea0129d.zip chromium_src-d41355e6f0576dc372a6047ffc8e6f0fdea0129d.tar.gz chromium_src-d41355e6f0576dc372a6047ffc8e6f0fdea0129d.tar.bz2 |
Cloned from 62030
Add a "Clear All" link to the downloads page.
Fixes jankiness of the blue bar in the download page as it loads.
Improve rendering time of the downloads page by chunking the number of
download items to do before scheduling the timeout.
BUG=9033
Review URL: http://codereview.chromium.org/62115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r-- | chrome/browser/resources/downloads.html | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/chrome/browser/resources/downloads.html b/chrome/browser/resources/downloads.html index 6d85f3b..6f1a545 100644 --- a/chrome/browser/resources/downloads.html +++ b/chrome/browser/resources/downloads.html @@ -32,10 +32,18 @@ html[dir='rtl'] .form { margin-top:12px; border-top:1px solid #9cc2ef; background-color:#ebeff9; - font-weight:bold; padding:3px; margin-bottom:6px; } +#downloads-summary-text { + font-weight:bold; +} +#downloads-summary > a { + float:right; +} +html[dir='rtl'] #downloads-summary > a { + float:left; +} #downloads-display { max-width:740px; } @@ -111,7 +119,7 @@ html[dir='rtl'] .name { } .download .url { color:#080; - width:500px; + max-width:500px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; @@ -239,7 +247,7 @@ function createButton(onclick, value) { function Downloads() { this.downloads_ = {}; this.node_ = $('downloads-display'); - this.summary_ = $('downloads-summary'); + this.summary_ = $('downloads-summary-text'); this.searchText_ = ""; // Keep track of the dates of the newest and oldest downloads so that we @@ -648,8 +656,7 @@ var downloads, localStrings, resultsTimeout; function load() { localStrings = new LocalStrings($('l10n')); - Download.Progress.dir = - !!(document.getElementsByTagName('html')[0].dir == 'rtl'); + Download.Progress.dir = document.documentElement.dir == 'rtl'; downloads = new Downloads(); $('term').focus(); setSearch(""); @@ -661,6 +668,13 @@ function setSearch(searchText) { chrome.send("getDownloads", [searchText.toString()]); } +function clearAll() { + downloads.clear(); + downloads.setSearchText(''); + chrome.send('clearAll', []); + return false; +} + /////////////////////////////////////////////////////////////////////////////// // Chrome callbacks: /** @@ -673,6 +687,7 @@ function downloadsList(results) { window.console.log('results'); downloads.clear(); downloadUpdated(results); + downloads.updateSummary(); } /** @@ -683,17 +698,18 @@ function downloadUpdated(results) { if (!downloads) return; - if (results.length) { - downloads.updated(results[0]); - - if (results.length > 1) { + var start = Date.now(); + for (var i = 0; i < results.length; i++) { + downloads.updated(results[i]); + // Do as much as we can in 50ms. + if (Date.now() - start > 50) { clearTimeout(resultsTimeout); - resultsTimeout = setTimeout(downloadUpdated, 5, results.slice(1)); - } else { - downloads.updateSummary(); + resultsTimeout = setTimeout(downloadUpdated, 5, results.slice(i + 1)); + break; } } } + </script> </head> <body onload="load();" jsvalues=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> @@ -709,7 +725,10 @@ function downloadUpdated(results) { </form> </div> <div class="main"> - <div id="downloads-summary"></div> + <div id="downloads-summary"> + <span id="downloads-summary-text" jscontent="downloads">Downloads</span> + <a id="clear-all" href="" onclick="clearAll();" jscontent="clear_all">Clear All</a> + </div> <div id="downloads-display"></div> </div> <div class="footer"> |