From 240ab3296e7f452e60fa15fd0ca676b15e6b75ac Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Mon, 29 Oct 2007 18:31:27 +0000 Subject: [PATCH] Bug 401215 - "Background banding for the download manager" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r=sdwilsh aM9=beltzner] git-svn-id: svn://10.0.0.236/trunk@238313 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mozapps/downloads/content/downloads.js | 26 +++++++++++++++++-- .../pinstripe/mozapps/downloads/downloads.css | 4 +++ .../winstripe/mozapps/downloads/downloads.css | 4 +++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mozilla/toolkit/mozapps/downloads/content/downloads.js b/mozilla/toolkit/mozapps/downloads/content/downloads.js index afcf1fe918b..3c47e1b8647 100644 --- a/mozilla/toolkit/mozapps/downloads/content/downloads.js +++ b/mozilla/toolkit/mozapps/downloads/content/downloads.js @@ -161,9 +161,10 @@ function downloadCompleted(aDownload) // If we are displaying search results, we do not want to add it to the list // of completed downloads - if (!gSearching) + if (!gSearching) { gDownloadsView.insertBefore(dl, gDownloadsDoneArea.nextSibling); - else + evenOddCellAttribution(); + } else removeFromView(dl); // getTypeFromFile fails if it can't find a type for this file. @@ -848,6 +849,7 @@ function removeFromView(aDownload) let index = gDownloadsView.selectedIndex; gDownloadsView.removeChild(aDownload); gDownloadsView.selectedIndex = Math.min(index, gDownloadsView.itemCount - 1); + evenOddCellAttribution(); } function getReferrerOrSource(aDownload) @@ -878,6 +880,25 @@ function buildDefaultView() gDownloadsView.selectedItem = children[0]; } + /** + * Gives every second cell an odd attribute so they can receive alternating + * backgrounds from the stylesheets. + */ +function evenOddCellAttribution() +{ + let alternateCell = false; + let allDownloadsInView = gDownloadsView.getElementsByTagName("richlistitem"); + + for (let i = 0; i < allDownloadsInView.length; i++) { + if (alternateCell) + allDownloadsInView[i].setAttribute("alternate", "true"); + else + allDownloadsInView[i].removeAttribute("alternate"); + + alternateCell = !alternateCell; + } +} + /** * Builds the downloads list with a given statement and reference node. * @@ -923,6 +944,7 @@ function buildDownloadList(aStmt, aRef) if (dl) gDownloadsView.insertBefore(dl, aRef.nextSibling); } + evenOddCellAttribution(); } var gActiveDownloadsQuery = null; diff --git a/mozilla/toolkit/themes/pinstripe/mozapps/downloads/downloads.css b/mozilla/toolkit/themes/pinstripe/mozapps/downloads/downloads.css index b515f341ff8..f4d586a5b7f 100644 --- a/mozilla/toolkit/themes/pinstripe/mozapps/downloads/downloads.css +++ b/mozilla/toolkit/themes/pinstripe/mozapps/downloads/downloads.css @@ -10,6 +10,10 @@ richlistitem[type="download"] { min-height: 46px !important; } +richlistitem[type="download"][alternate="true"]:not([selected="true"]) { + background-color: #ecf2fe; +} + richlistitem[type="download"] .name { font-size: larger; } diff --git a/mozilla/toolkit/themes/winstripe/mozapps/downloads/downloads.css b/mozilla/toolkit/themes/winstripe/mozapps/downloads/downloads.css index e8f03bda22a..a569f32a534 100644 --- a/mozilla/toolkit/themes/winstripe/mozapps/downloads/downloads.css +++ b/mozilla/toolkit/themes/winstripe/mozapps/downloads/downloads.css @@ -16,6 +16,10 @@ richlistitem[type="download"] { min-height: 46px; } +richlistitem[type="download"][alternate="true"]:not([selected="true"]) { + background-color: ThreeDLightShadow; +} + richlistitem[type="download"] .name { font-size: larger; }