/* * cssUpdate - v1.0.0 */ ;(function ( $, window, document, undefined ) { var pluginName = "cssUpdate", defaults = { properties: ["color"], propertyValue: "pink", classes: "Null" }; // Plugin constructor function cssLiveUpdater ( element, options ) { this.element = element; this.settings = $.extend( {}, defaults, options ); this._defaults = defaults; this._name = pluginName; this._cssproperties = CSSOM.parse($(this.element).html()); this.init(); } cssLiveUpdater.prototype = { init: function () { this.changeProperties(); }, update_plugin: function ( options ) { //this.element = element; this.settings = $.extend( {}, defaults, options ); //this._defaults = defaults; //this._name = pluginName; //this._cssproperties = CSSOM.parse($(this.element).html()); this.changeProperties(); }, changeProperties: function () { var self = this, css = this._cssproperties.cssRules; if ( typeof css[0] !== "undefined" && css[0].hasOwnProperty('media') ) { // in this case we run a media query object $.each(css, function( key, media_query ){ // simple object with css properties // change them with new ones $.each(media_query.cssRules, function(i, property){ var property_name = property.style[0]; css[key].cssRules[i].style[property_name] = self.updateCssRule(property_name, self.settings, css[key].cssRules[i].selectorText); }); }); } else { // simple object with css properties // change them with new ones $.each(css, function(i, property){ if ( property.hasOwnProperty( 'style' ) ) { var property_name = property.style[0]; css[i].style[property_name] = self.updateCssRule(property_name, self.settings, css[i].selectorText); } }); } $(window).trigger('resize'); //Insert the new properties into