/* --- name : Sheet authors : Thomas Aylott copyright : © 2010 Thomas Aylott license : MIT provides : Sheet requires : SheetParser.CSS ... */ ;(function(exports){ /**/ var UNDEF = {undefined:1} /**/ var SheetParser = UNDEF[typeof require] ? exports.SheetParser : require('./SheetParser.CSS').SheetParser exports.Sheet = Sheet /**/ /**/;if (!(!UNDEF[typeof SheetParser] && SheetParser.CSS)) throw new Error('Missing required function: "SheetParser.CSS"');/**/ /**/ Sheet.version = '1.0.2 dev' function Sheet(cssText){ if (this instanceof Sheet) this.initialize(cssText) else return Sheet.from(cssText) } Sheet.from = function(cssText){ return new Sheet(cssText) } Sheet.prototype = { parser: SheetParser.CSS, initialize: function(cssText){ this.cssText = cssText || '' this.style = this.rules = this.cssRules = this.parser.parse(this.cssText) var self = this }, update: function(){ var cssText = '', i = -1, rule, rules = this.style || this.rules || this.cssRules while ((rule = rules[++i])){ if (typeof rule == 'object'){ // cssRule if (this.update) rule.cssText = this.update.call(rule) cssText += rule.cssText = rule.selectorText + '{' + rule.cssText + '}' } else { // style key/value cssText += rule + ':' cssText += rules[rule] + ';' } } if (rules.selectorText) return rules.cssText = rules.selectorText + '{' + cssText + '}' return rules.cssText = cssText } } Sheet.prototype.toString = Sheet.prototype.update }(typeof exports != 'undefined' ? exports : this));