Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show and hide tags in a single pane.
- Loading branch information
Showing
5 changed files
with
105 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
isc.defineClass("CSSRules").addProperties({ | ||
legalStyles: ["color", "backgroundColor", "display"], | ||
|
||
init : function() { | ||
this.Super("init", arguments); | ||
|
||
// cssRules is a cache of the actual rules in the actual stylesheet | ||
this.cssRules = {}; | ||
|
||
var head = document.documentElement.firstChild; | ||
var title = "Dynamic-Styles"; | ||
isc.Element.insertAdjacentHTML(head, "afterBegin", "<style type='text/css' title='" + title + "' />", true); | ||
|
||
for (var i = 0; i < document.styleSheets.length; i++) { | ||
if (document.styleSheets[i].title == title) { | ||
this.stylesheet = document.styleSheets[i]; | ||
break; | ||
} | ||
} | ||
|
||
return this; | ||
}, | ||
|
||
setRule : function(selector, styles) { | ||
var cssRule = this.cssRules[selector]; | ||
|
||
if (!cssRule) { | ||
this.stylesheet.insertRule(selector + " {}", 0); | ||
cssRule = this.cssRules[selector] = this.stylesheet.cssRules[0]; | ||
} | ||
|
||
this.legalStyles.map(function(style) { | ||
if (styles[style]) cssRule.style[style] = styles[style]; | ||
}); | ||
|
||
return selector; | ||
}, | ||
|
||
getRule: function(selector) { | ||
var result = {}; | ||
var rule = this.cssRules[selector]; | ||
if (rule) { | ||
this.legalStyles.map(function(style) { | ||
if (rule.style[style]) result[style] = rule.style[style]; | ||
}); | ||
} | ||
return result; | ||
}, | ||
|
||
clearRules: function() { | ||
|
||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters