make use of :nth-child in the download list, remove stripeifyList()
r=sdwilsh
This commit is contained in:
Dão Gottwald 2008-06-11 10:11:14 -04:00
Родитель 466f823e85
Коммит a7c9c4101a
3 изменённых файлов: 5 добавлений и 33 удалений

Просмотреть файл

@ -156,10 +156,8 @@ function downloadCompleted(aDownload)
while (next && next.inProgress)
next = next.nextSibling;
// Move the item and color everything after where it moved from
let fixup = dl.nextSibling;
// Move the item
gDownloadsView.insertBefore(dl, next);
stripeifyList(fixup);
} else {
removeFromView(dl);
}
@ -1082,9 +1080,6 @@ function removeFromView(aDownload)
gDownloadsView.removeChild(aDownload);
gDownloadsView.selectedIndex = Math.min(index, gDownloadsView.itemCount - 1);
// Color everything after from the newly selected item
stripeifyList(gDownloadsView.selectedItem);
// We might have removed the last item, so update the clear list button
updateClearListButton();
}
@ -1200,9 +1195,8 @@ function stepListBuilder(aNumItems) {
// Make the item and add it to the end if it's active or matches the search
let item = createDownloadItem(attrs);
if (item && (isActive || downloadMatchesSearch(item))) {
// Add item to the end and color just that one item
// Add item to the end
gDownloadsView.appendChild(item);
stripeifyList(item);
// Because of the joys of XBL, we can't update the buttons until the
// download object is in the document.
@ -1253,9 +1247,8 @@ function prependList(aDownload)
// Make the item and add it to the beginning
let item = createDownloadItem(attrs);
if (item) {
// Add item to the beginning and color the whole list
// Add item to the beginning
gDownloadsView.insertBefore(item, gDownloadsView.firstChild);
stripeifyList(item);
// Because of the joys of XBL, we can't update the buttons until the
// download object is in the document.
@ -1291,27 +1284,6 @@ function downloadMatchesSearch(aItem)
return true;
}
/**
* Stripeify the download list by setting or clearing the "alternate" attribute
* on items starting from a particular item and continuing to the end.
*
* @param aItem
* Download rishlist item to start stripeifying
*/
function stripeifyList(aItem)
{
let alt = "alternate";
// Set the item to be opposite of the other
let flipFrom = function(aOther) aOther && aOther.hasAttribute(alt) ?
aItem.removeAttribute(alt) : aItem.setAttribute(alt, "true");
// Keep coloring items as the opposite of its previous until no more
while (aItem) {
flipFrom(aItem.previousSibling);
aItem = aItem.nextSibling;
}
}
// we should be using real URLs all the time, but until
// bug 239948 is fully fixed, this will do...
//

Просмотреть файл

@ -20,7 +20,7 @@ richlistitem[type="download"][selected="true"] {
background-image: url(chrome://mozapps/skin/extensions/itemEnabledFader.png);
}
richlistitem[type="download"][alternate="true"]:not([selected="true"]) {
richlistitem[type="download"]:not([selected="true"]):nth-child(odd) {
background-color: -moz-oddtreerow;
}

Просмотреть файл

@ -12,7 +12,7 @@ richlistitem[type="download"] {
min-height: 40px !important;
}
richlistitem[type="download"][alternate="true"]:not([selected="true"]) {
richlistitem[type="download"]:not([selected="true"]):nth-child(odd) {
background-color: -moz-oddtreerow;
}