- 
      
 - 
        
Save Frontenda/d0d5a9c7073ab6f128ed385d781c28c1 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
yckart revised this gist
Nov 23, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,12 @@ /*! * jquery.addrule.js 0.0.2 - https://gist.github.com/yckart/5563717/ * Add css-rules to an existing stylesheet. * * @see http://stackoverflow.com/a/16507264/1250044 * * Copyright (c) 2013 Yannick Albert (http://yckart.com) * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php). * 2013/11/23 **/ (function ($) {  - 
        
yckart revised this gist
Nov 23, 2013 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,11 +16,11 @@ styles = (function (styles) { if (typeof styles === "string") return styles; var clone = ""; for (var prop in styles) { if (styles.hasOwnProperty(prop)) { var val = styles[prop]; prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase(); // convert to dash-case clone += prop + ":" + (prop === "content" ? '"' + val + '"' : val) + "; "; } } return clone; @@ -39,4 +39,4 @@ return this; }; }(this.jQuery || this.Zepto));  - 
        
Yannick Albert revised this gist
May 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ } return clone; }(styles)); sheet = sheet || document.styleSheets[document.styleSheets.length - 1]; if (sheet.insertRule) sheet.insertRule(selector + " {" + styles + "}", sheet.cssRules.length); else if (sheet.addRule) sheet.addRule(selector, styles);  - 
        
Yannick Albert revised this gist
May 15, 2013 . 1 changed file with 15 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,17 +13,18 @@ window.addRule = function (selector, styles, sheet) { styles = (function (styles) { if (typeof styles === "string") return styles; var clone = ""; for (var p in styles) { if (styles.hasOwnProperty(p)) { var val = styles[p]; p = p.replace(/([A-Z])/g, "-$1").toLowerCase(); // convert to dash-case clone += p + ":" + (p === "content" ? '"' + val + '"' : val) + "; "; } } return clone; }(styles)); sheet = sheet || document.styleSheets[0]; if (sheet.insertRule) sheet.insertRule(selector + " {" + styles + "}", sheet.cssRules.length); @@ -33,11 +34,9 @@ }; if ($) $.fn.addRule = function (styles, sheet) { addRule(this.selector, styles, sheet); return this; }; }(window.jQuery));  - 
        
Yannick Albert revised this gist
May 12, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ /*! * jquery.addrule.js 0.0.1 - https://gist.github.com/yckart/5563717/ * Add css-rules to an existing stylesheet. * * @see http://stackoverflow.com/a/16507264/1250044 *  - 
        
Yannick Albert revised this gist
May 12, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ * jquery.addrule.js 0.0.1 - https://gist.github.com/yckart/5563717/ * Adds css-rules to an existing stylesheet. * * @see http://stackoverflow.com/a/16507264/1250044 * * Copyright (c) 2013 Yannick Albert (http://yckart.com) * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php). * 2013/05/12  - 
        
Yannick Albert revised this gist
May 12, 2013 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,12 @@ /*! * jquery.addrule.js 0.0.1 - https://gist.github.com/yckart/5563717/ * Adds css-rules to an existing stylesheet. * * Copyright (c) 2013 Yannick Albert (http://yckart.com) * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php). * 2013/05/12 **/ (function ($) { window.addRule = function (selector, styles, sheet) {  - 
        
Yannick Albert revised this gist
May 12, 2013 . 1 changed file with 0 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +0,0 @@  - 
        
Yannick Albert revised this gist
May 12, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,9 @@ $("body:after").addRule({ content: "foo", color: "red" }); // or as string (note, you've to write the property in dash-case) $("body:after").addRule("font-size: 23px"); // or plain, without jquery addRule("body:after", "font-style: italic");  - 
        
Yannick Albert revised this gist
May 12, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -29,4 +29,4 @@ }; } }(this.jQuery));  - 
        
Yannick Albert created this gist
May 12, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ // add some styles as object notation $("body:after").addRule({ content: "foo", color: "red" }); // or as string (note, you've to write the property in dash-case) $("body:after").addRule("font-size: 23px"); // or plain, without jquery addRule("body:after", "font-style: italic"); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ (function ($) { window.addRule = function (selector, styles, sheet) { if (typeof styles !== "string") { var clone = ""; for (var style in styles) { var val = styles[style]; style = style.replace(/([A-Z])/g, "-$1").toLowerCase(); // convert to dash-case clone += style + ":" + (style === "content" ? '"' + val + '"' : val) + "; "; } styles = clone; } sheet = sheet || document.styleSheets[0]; if (sheet.insertRule) sheet.insertRule(selector + " {" + styles + "}", sheet.cssRules.length); else if (sheet.addRule) sheet.addRule(selector, styles); return this; }; if ($) { $.fn.addRule = function (styles, sheet) { addRule(this.selector, styles, sheet); return this; }; } }(window.jQuery));