1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-14 08:15:03 +12:00

Firefox: fix styling for toolbar button

This commit is contained in:
Deathamns 2014-12-16 16:10:50 +01:00 committed by gorhill
parent e2105c395e
commit 7348d11871

View file

@ -595,31 +595,9 @@ vAPI.toolbarButton.init = function() {
}
});
var doc = Services.wm.getMostRecentWindow('navigator:browser').document;
var button = doc.getElementById(this.widgetId);
button.style.listStyleImage = 'url(' + vAPI.getURL('img/icon16.svg') + ')';
if (!this.styleURI) {
var css = encodeURIComponent([
'#' + this.widgetId + '[badge]:not([badge=""])::after {',
'position: absolute; color: #fff; background: #666;',
'content: attr(badge); font-size: 9px; font-weight: bold;',
'padding: 1px 2px; margin-left: -16px; margin-top: 3px }'
].join(''));
this.styleURI = Services.io.newURI('data:text/css,' + css, null, null);
}
var sss = Cc['@mozilla.org/content/style-sheet-service;1']
.getService(Ci.nsIStyleSheetService);
sss.loadAndRegisterSheet(this.styleURI, sss.USER_SHEET);
vAPI.unload.push(function() {
sss.unregisterSheet(this.styleURI, sss.USER_SHEET);
CustomizableUI.createWidget(this.widgetId);
}.bind(this));
CustomizableUI.destroyWidget(vAPI.toolbarButton.widgetId);
});
};
/******************************************************************************/
@ -635,7 +613,7 @@ vAPI.toolbarButton.add = function(doc) {
iframe.setAttribute('type', 'content');
panel.style.cssText = iframe.style.cssText
= 'width: 180px; height: 310px; transition: width .1s, height .1s';
= 'width: 180px; height: 310px; transition: width .1s, height .1s; overflow: hidden';
doc.getElementById('PanelUI-multiView')
.appendChild(panel)
@ -677,6 +655,32 @@ vAPI.toolbarButton.add = function(doc) {
};
iframe.addEventListener('load', onPopupReady, true);
if (!this.styleURI) {
this.styleURI = 'data:text/css,' + encodeURIComponent([
'#' + this.widgetId + ' {',
'list-style-image: url(',
vAPI.getURL('img/browsericons/icon16-off.svg'),
');',
'}',
'#' + this.widgetId + '[badge]:not([badge=""])::after {',
'position: absolute;',
'margin-left: -16px;',
'margin-top: 3px;',
'padding: 1px 2px;',
'font-size: 9px;',
'font-weight: bold;',
'color: #fff;',
'background: #666;',
'content: attr(badge);',
'}'
].join(''));
this.styleURI = Services.io.newURI(this.styleURI, null, null);
}
doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils).loadSheet(this.styleURI, 1);
};
/******************************************************************************/