mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-04 16:47:15 +02:00
Safari: off/disabled version of toolbar icon
Toolbar icon now dims when on a whitelisted website
This commit is contained in:
parent
52ed1871b0
commit
1a55ecfbcd
@ -377,7 +377,7 @@
|
|||||||
i = wins.length,
|
i = wins.length,
|
||||||
j;
|
j;
|
||||||
|
|
||||||
while(i--) {
|
while(i --) {
|
||||||
j = wins[i].tabs.length;
|
j = wins[i].tabs.length;
|
||||||
|
|
||||||
while(j--) {
|
while(j--) {
|
||||||
@ -426,13 +426,13 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the badge, when tab is selected
|
// update the badge
|
||||||
vAPI.setIcon();
|
vAPI.setIcon(vAPI.tabs.getTabId(e.target));
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// reload the popup when that is opened
|
// reload the popup when it's opened
|
||||||
safari.application.addEventListener('popover', function(e) {
|
safari.application.addEventListener('popover', function(e) {
|
||||||
var w = e.target.contentWindow, body = w.document.body, child;
|
var w = e.target.contentWindow, body = w.document.body, child;
|
||||||
while(child = body.firstChild) {
|
while(child = body.firstChild) {
|
||||||
@ -442,42 +442,32 @@
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
function TabIcon() {}
|
||||||
|
TabIcon.prototype.badge = 0;
|
||||||
|
TabIcon.prototype.img = "";
|
||||||
|
|
||||||
vAPI.tabIcons = { /*tabId: {badge: 0, img: suffix}*/ };
|
vAPI.tabIcons = { /*tabId: {badge: 0, img: suffix}*/ };
|
||||||
vAPI.setIcon = function(tabId, iconStatus, badge) {
|
vAPI.setIcon = function(tabId, iconStatus, badge) {
|
||||||
var curTabId = vAPI.tabs.getTabId(
|
var icon = vAPI.tabIcons[tabId];
|
||||||
safari.application.activeBrowserWindow.activeTab
|
if(typeof icon === "undefined") {
|
||||||
);
|
icon = vAPI.tabIcons[tabId] = new TabIcon();
|
||||||
|
|
||||||
// from 'activate' event
|
|
||||||
if(tabId === undefined) {
|
|
||||||
tabId = curTabId;
|
|
||||||
} else {
|
|
||||||
if(badge && /\D/.test(badge)) {
|
|
||||||
badge = 999;
|
|
||||||
}
|
|
||||||
|
|
||||||
vAPI.tabIcons[tabId] = {
|
|
||||||
badge: badge || 0,
|
|
||||||
img: iconStatus === 'on' ? '' : '-off'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tabId !== curTabId) {
|
// If we've been passed a badge/iconStatus:
|
||||||
return;
|
if(typeof badge !== "undefined") {
|
||||||
|
icon.badge = badge;
|
||||||
|
icon.img = (iconStatus === "on" ? "" : "-off");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the selected tab has the same ID, then update the badge too,
|
var items = safari.extension.toolbarItems,
|
||||||
// or always update it when changing tabs ('activate' event)
|
i = items.length;
|
||||||
var items = safari.extension.toolbarItems;
|
|
||||||
var i = items.length;
|
|
||||||
|
|
||||||
while(i--) {
|
var curWindow = safari.application.activeBrowserWindow;
|
||||||
if(items[i].browserWindow === safari.application.activeBrowserWindow) {
|
while(i --) {
|
||||||
var icon = vAPI.tabIcons[tabId];
|
if(items[i].browserWindow === curWindow) {
|
||||||
items[i].badge = icon && icon.badge || 0;
|
items[i].badge = icon.badge;
|
||||||
// TODO: a disabled icon for Safari
|
items[i].image = vAPI.getURL("img/browsericons/icon16" +
|
||||||
// items[i].img = vAPI.getURL(icon.img);
|
icon.img + ".png");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/img/browsericons/icon16-off.png
Normal file
BIN
src/img/browsericons/icon16-off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 195 B |
BIN
src/img/browsericons/icon16-off@2x.png
Normal file
BIN
src/img/browsericons/icon16-off@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 344 B |
Loading…
Reference in New Issue
Block a user