You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
863 B
JavaScript
24 lines
863 B
JavaScript
12 years ago
|
// Service for injecting CSS into the application
|
||
12 years ago
|
angular.module('panelApp').factory('appCss', function (chromeExtension) {
|
||
12 years ago
|
return {
|
||
|
addCssRule: function (args) {
|
||
|
chromeExtension.eval(function (window, args) {
|
||
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
||
|
styleSheet.insertRule(args.selector + '{' + args.style + '}', styleSheet.cssRules.length);
|
||
|
}, args);
|
||
|
},
|
||
|
|
||
|
removeCssRule: function (args) {
|
||
|
chromeExtension.eval(function (window, args) {
|
||
|
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
||
|
var i;
|
||
|
for (i = styleSheet.cssRules.length - 1; i >= 0; i -= 1) {
|
||
|
if (styleSheet.cssRules[i].cssText === args.selector + ' { ' + args.style + '; }') {
|
||
|
styleSheet.deleteRule(i);
|
||
|
}
|
||
|
}
|
||
|
}, args);
|
||
|
}
|
||
|
};
|
||
|
});
|