moved CSS features to their own service, cleaned up services
parent
c0aee3c066
commit
a0f8358de2
@ -0,0 +1,23 @@
|
||||
// Service for injecting CSS into the application
|
||||
panelApp.factory('appCss', function (chromeExtension) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
});
|
Reference in New Issue