| Index: options.js |
| =================================================================== |
| --- a/options.js |
| +++ b/options.js |
| @@ -62,6 +62,22 @@ |
| }; |
| }; |
| + Collection.prototype._isControlDisabled = function(item, i) |
| + { |
| + return item.disableable == false && |
| + this.details[i].onClick == toggleDisableSubscription; |
| + }; |
| + |
| + Collection.prototype._getItemTitle = function(item, i) |
| + { |
| + var title = null; |
| + if (this.details[i].useOriginalTitle) |
| + title = item.originalTitle; |
| + if (!title) |
| + title = item.title || item.url || item.text; |
| + return title; |
| + }; |
| + |
| Collection.prototype.addItems = function() |
| { |
| var length = Array.prototype.push.apply(this.items, arguments); |
| @@ -70,10 +86,15 @@ |
| this.items.sort(function(a, b) |
| { |
| - var aValue = (a.title || a.text || a.url).toLowerCase(); |
| - var bValue = (b.title || b.text || b.url).toLowerCase(); |
| - return aValue.localeCompare(bValue); |
| - }); |
| + var aDisabled = this._isControlDisabled(a, 0); |
|
Sebastian Noack
2016/04/01 18:26:43
This makes sure that items with disabled checkboxe
|
| + var bDisabled = this._isControlDisabled(b, 0); |
| + if (aDisabled != bDisabled) |
| + return aDisabled - bDisabled; |
| + |
| + var aTitle = this._getItemTitle(a, 0).toLowerCase(); |
|
Sebastian Noack
2016/04/01 18:26:43
This was missed on the previous review, where we s
|
| + var bTitle = this._getItemTitle(b, 0).toLowerCase(); |
| + return aTitle.localeCompare(bTitle); |
| + }.bind(this)); |
| for (var j = 0; j < this.details.length; j++) |
| { |
| @@ -168,17 +189,17 @@ |
| if (!element) |
| continue; |
| - var title = null; |
| - if (this.details[i].useOriginalTitle) |
| - title = item.originalTitle; |
| - if (!title) |
| - title = item.title || item.url || item.text; |
| + var title = this._getItemTitle(item, i); |
| element.querySelector(".display").textContent = title; |
| if (title) |
| element.setAttribute("data-search", title.toLowerCase()); |
| var control = element.querySelector(".control[role='checkbox']"); |
| if (control) |
| + { |
| control.setAttribute("aria-checked", item.disabled == false); |
| + if (this._isControlDisabled(item, i)) |
| + control.setAttribute("disabled", true); |
| + } |
| var downloadStatus = item.downloadStatus; |
| var dateElement = element.querySelector(".date"); |
| @@ -453,7 +474,10 @@ |
| collection = collections.allLangs; |
| } |
| else if (subscriptionUrl == acceptableAdsUrl) |
| + { |
| collection = collections.acceptableAds; |
| + subscription.disableable = false; |
| + } |
| else |
| collection = collections.custom; |
| @@ -897,14 +921,7 @@ |
| function getAcceptableAdsURL(callback) |
| { |
| - getPref("subscriptions_exceptionsurl", function(value) |
| - { |
| - getAcceptableAdsURL = function(callback) |
| - { |
| - callback(value); |
| - }; |
| - getAcceptableAdsURL(callback); |
| - }); |
| + getPref("subscriptions_exceptionsurl", callback); |
| } |
| function addEnableSubscription(url, title, homepage) |