test/dummy/tmp/cache/assets/E00/880/sprockets%2Fecb876bb310c1a3e6fd534ece45c9ed9 in cytoplasm-0.3.8 vs test/dummy/tmp/cache/assets/E00/880/sprockets%2Fecb876bb310c1a3e6fd534ece45c9ed9 in cytoplasm-0.3.9

- old
+ new

@@ -1,8 +1,8 @@ -o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1360781385.841859: @value"´${I" +o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1360871912.272655: @value"©!{I" class:EFI"BundledAsset;FI"logical_path;FI"cytoplasm/cytoSlider.js;FI" pathname;FI"g/Applications/XAMPP/xamppfiles/htdocs/cytoplasm/app/assets/javascripts/cytoplasm/cytoSlider.js.erb;FI"content_type;FI"application/javascript;FI" -mtime;FI"2013-02-13T13:49:44-05:00;FI" length;FiÅ"I" digest;F"%6c50ec17c14a01b61198a5d140b1e116I" source;FI"Å"// CytoSlider v0.5 +mtime;FI"2013-02-14T14:40:46-05:00;FI" length;FiºI" digest;F"%74a92b5041382395ff0c8392804a2792I" source;FI"º// CytoSlider v0.5 // By MacKinley Smith (function($){ var defaults = { dimensions:1, widget:{ @@ -15,11 +15,11 @@ readout:{ css:{}, unit:false } }, - slider:{ + sliders:{ css:{}, elements:[], options:{ min:0, max:100, @@ -37,11 +37,12 @@ } }, events:{ create:function(cy){}, change:function(cy,event){}, - destroy:function(cy){} + destroy:function(cy){}, + resize:function(cy,event){} } }; var methods = { init:function(options,reinit){ if (reinit==null) reinit = false; @@ -56,31 +57,31 @@ settings = $.extend(true,{},defaults,options); if ($this.data('settings')!=null) settings = $.extend(true,{},settings,$this.data('settings')); if ($this.data('dimensions')!=null) settings.dimensions = $this.data('dimensions'); if ($this.data('label')!=null) settings.widget.label.html = $this.data('label'); if ($this.data('unit')!=null) settings.widget.label.readout.unit = $this.data('unit'); - if ($this.data('min')!=null) settings.widget.slider.options.min = $this.data('min'); - if ($this.data('max')!=null) settings.widget.slider.options.max = $this.data('max'); - if ($this.data('step')!=null) settings.widget.slider.options.step = $this.data('step'); - if ($this.val()!=null && $this.val()!="") settings.widget.slider.options.value = parseInt($this.val()); + if ($this.data('min')!=null) settings.widget.sliders.options.min = $this.data('min'); + if ($this.data('max')!=null) settings.widget.sliders.options.max = $this.data('max'); + if ($this.data('step')!=null) settings.widget.sliders.options.step = $this.data('step'); + if ($this.val()!=null && $this.val()!="") settings.widget.sliders.options.value = parseInt($this.val()); } else settings = options; // Generate widget settings.widget.wrapper.element = $this.wrap("<div></div>").parent().addClass('cytoSlider-wrapper').css(settings.widget.wrapper.css); settings.widget.label.element = $('<label />').attr("for",$this.attr("name")).addClass('cytoSlider-label').css(settings.widget.label.css).html(settings.widget.label.html+": ").prependTo(settings.widget.wrapper.element); settings.widget.label.readout.element = $('<span />').addClass("cytoSlider-label-readout").css(settings.widget.label.readout.css).appendTo(settings.widget.label.element); - // Set up sliders - $this.data('cytoSlider',settings); - methods.setDimensions.apply($this,[settings.dimensions]); - // Bindings $this.bind("change.cytoSlider",function(e){ settings.widget.label.readout.element.html($(this).val()); settings.events.change.apply($this,[settings,e]); }); + // Generate sliders + $this.data('cytoSlider',settings); + methods.setDimensions.apply($this,[settings.dimensions]); + // Save settings data to input $this.data('cytoSlider',settings); methods.resize.apply($this); settings.events.create.apply($this,[settings]); }); @@ -114,84 +115,59 @@ return this.each(function(){ var $this = $(this); var settings = $this.data('cytoSlider'); if (!$this.hasClass("cytoSlider") || settings==null) return console.warn("You must instanciate $.cytoSlider before you call the resize method!"); - settings.widget.wrapper.element.width(0); + var w = settings.widget.wrapper.element.width(0); setTimeout(function(){ - settings.widget.wrapper.element.width("auto"); + w.width("auto"); },1); }); }, - addDimension:function(){ - return this.each(function(){ - var $this = $(this); - var settings = $this.data('cytoSlider'); - if (!$this.hasClass("cytoSlider") || settings==null) return console.warn("You must instanciate $.cytoSlider before you call the addDimension method!"); - - var slider = $('<div />').addClass('cytoSlider-slider') - .css(settings.widget.slider.css) - .appendTo(settings.widget.wrapper.element) - .slider(settings.widget.slider.options).slider("value",settings.widget.slider.options.value); - settings.widget.slider.elements.push(slider); - - $this.data('cytoSlider',settings); - }); - }, - removeDimension:function(){ - return this.each(function(){ - var $this = $(this); - var settings = $this.data('cytoSlider'); - if (!$this.hasClass("cytoSlider") || settings==null) return console.warn("You must instanciate $.cytoSlider before you call the addDimension method!"); - - var slider = settings.widget.slider.elements.pop(); - slider.remove(); - - $this.data('cytoSlider',settings); - }); - }, setDimensions:function(n){ return this.each(function(){ var $this = $(this); var settings = $this.data('cytoSlider'); if (!$this.hasClass("cytoSlider") || settings==null) return console.warn("You must instanciate $.cytoSlider before you call the setDimensions method!"); // Reset sliders - $.each(settings.widget.slider.elements,function(i,s){s.remove()}); - settings.widget.slider.elements = []; + if (settings.widget.sliders.elements.length) settings.widget.sliders.elements.each(function(){$(this).remove()}); - settings.dimensions = n; + // Create sliders + for (var i=0;i<n;i++) { + var slider = $('<div />').addClass('cytoSlider-slider') + .css(settings.widget.sliders.css) + .appendTo(settings.widget.wrapper.element) + .slider(); + } + var sliders = settings.widget.wrapper.element.find('.cytoSlider-slider'); // Set up options - $.each(["slide","change"],function(i,v){ - var orig = settings.widget.slider.options[v]; - settings.widget.slider.options[v] = function(e,ui){ + $.each(["slide","change"],function(i,event){ + var orig = settings.widget.sliders.options[event]; + settings.widget.sliders.options[event] = function(e,ui){ var values = []; - for (var i=0;i<settings.dimensions;i++) values.push(settings.widget.slider.elements[i].slider("value")+settings.widget.label.readout.unit); - $this.val(values.join(" ")); - orig.apply(this,arguments); - $this.trigger("change.cytoSlider"); + $(this).parent().find('.cytoSlider-slider').each(function(){values.push($(this).slider("value")+settings.widget.label.readout.unit);}); + $this.val(values.join(" ")).trigger("change.cytoSlider"); + orig.apply($this,[e,ui]); }; }); - // Create sliders - for (var i=0;i<settings.dimensions;i++) { - var slider = $('<div />').addClass('cytoSlider-slider') - .css(settings.widget.slider.css) - .appendTo(settings.widget.wrapper.element) - .slider().slider("value",settings.widget.slider.options.value); - settings.widget.slider.elements.push(slider); + // Margin fix + if (n>1) { + sliders.each(function(){$(this).css("margin-top",10);}); + $(sliders).first().css("margin-top",0); } - if (settings.dimensions>1) { - $.each(settings.widget.slider.elements,function(i,s){s.css("margin-top",10);}); - settings.widget.slider.elements[0].css("margin-top",0); - } // Set options - $.each(settings.widget.slider.elements,function(i,s){s.slider("option",settings.widget.slider.options);}); + sliders.each(function(){ + $(this).slider("option",settings.widget.sliders.options); + }); // Store settings + settings.dimensions = n; + settings.widget.sliders.elements = sliders; $this.data('cytoSlider',settings); }); }, value:function(set){ if (set==null || set==undefined) set = false; @@ -201,11 +177,20 @@ var settings = $this.data('cytoSlider'); if (settings==null) return console.warn("You must instantiate $.cytoSlider before you call the value method!"); if (set===false) value = $this.val(); else { - settings.widget.slider.element.slider("value",set); + if (set.indexOf(" ")>-1) { + set = set.split(" "); + methods.setDimensions.apply($this,[set.length]); + $.each(set,function(i,v){ + settings.widget.sliders.elements[i].slider("value",parseFloat(v)); + }); + } else { + methods.setDimensions.apply($this,[1]); + settings.widget.sliders.elements[0].slider("value",parseFloat(set)); + } $this.trigger('change.cytoSlider'); } }); return (value!=null) ? value : this; }, @@ -240,6 +225,6 @@ $(window).resize(function(){$('.cytoSlider').cytoSlider('resize');}); $.Cytoplasm("ready",function(){ $('.cytoSlider').cytoSlider(); }); })(jQuery); -;FI"required_assets_digest;F"%28a9240599f54bad40525c1687b85f1cI" _version;F"%6776f581a4329e299531e1d52aa59832 +;FI"required_assets_digest;F"%7f9175cd01b1dbfa7649cd78ad92fdddI" _version;F"%6776f581a4329e299531e1d52aa59832 \ No newline at end of file