mirror of
https://github.com/webslides/WebSlides.git
synced 2025-08-22 04:43:42 +02:00
kss - content organization
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
(function() {
|
||||
var KssStateGenerator;
|
||||
|
||||
KssStateGenerator = (function() {
|
||||
var pseudo_selectors;
|
||||
|
||||
pseudo_selectors = ['hover', 'enabled', 'disabled', 'active', 'visited', 'focus', 'target', 'checked', 'empty', 'first-of-type', 'last-of-type', 'first-child', 'last-child'];
|
||||
|
||||
function KssStateGenerator() {
|
||||
var idx, idxs, pseudos, replaceRule, rule, stylesheet, _i, _len, _len2, _ref, _ref2;
|
||||
pseudos = new RegExp("(\\:" + (pseudo_selectors.join('|\\:')) + ")", "g");
|
||||
try {
|
||||
_ref = document.styleSheets;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
stylesheet = _ref[_i];
|
||||
if (stylesheet.href && stylesheet.href.indexOf(document.domain) >= 0) {
|
||||
idxs = [];
|
||||
_ref2 = stylesheet.cssRules;
|
||||
for (idx = 0, _len2 = _ref2.length; idx < _len2; idx++) {
|
||||
rule = _ref2[idx];
|
||||
if ((rule.type === CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)) {
|
||||
replaceRule = function(matched, stuff) {
|
||||
return matched.replace(/\:/g, '.pseudo-class-');
|
||||
};
|
||||
this.insertRule(rule.cssText.replace(pseudos, replaceRule));
|
||||
}
|
||||
pseudos.lastIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (_error) {}
|
||||
}
|
||||
|
||||
KssStateGenerator.prototype.insertRule = function(rule) {
|
||||
var headEl, styleEl;
|
||||
headEl = document.getElementsByTagName('head')[0];
|
||||
styleEl = document.createElement('style');
|
||||
styleEl.type = 'text/css';
|
||||
if (styleEl.styleSheet) {
|
||||
styleEl.styleSheet.cssText = rule;
|
||||
} else {
|
||||
styleEl.appendChild(document.createTextNode(rule));
|
||||
}
|
||||
return headEl.appendChild(styleEl);
|
||||
};
|
||||
|
||||
return KssStateGenerator;
|
||||
|
||||
})();
|
||||
|
||||
new KssStateGenerator;
|
||||
|
||||
}).call(this);
|
Reference in New Issue
Block a user