Sha256: 7655eae1729b644fa941a2707cc8dd319deba4b26782c3cd4becb3bbdde106a7
Contents?: true
Size: 1.52 KB
Versions: 14
Compression:
Stored size: 1.52 KB
Contents
/** This is a collection of javascript functions and whatnot under the spree namespace that do stuff we find helpful. Hopefully, this will evolve into a propper class. **/ var spree; if (!spree) spree = {}; jQuery.noConflict() ; jQuery(document).ajaxStart(function(){ jQuery("#progress").slideDown(); }); jQuery(document).ajaxStop(function(){ jQuery("#progress").slideUp(); }); jQuery.fn.visible = function(cond) { this[cond ? 'show' : 'hide' ]() }; // Apply to individual radio button that makes another element visible when checked jQuery.fn.radioControlsVisibilityOfElement = function(dependentElementSelector){ if(!this.get(0)){ return } showValue = this.get(0).value; radioGroup = $("input[name='" + this.get(0).name + "']"); radioGroup.each(function(){ jQuery(this).click(function(){ jQuery(dependentElementSelector).visible(this.checked && this.value == showValue) }); if(this.checked){ this.click() } }); } var request = function(options) { jQuery.ajax(jQuery.extend({ dataType: 'script', url: options.url, type: 'get' }, options)); return false; }; // remote links handler jQuery('a[data-remote=true]').live('click', function() { if(method = jQuery(this).attr("data-method")){ return request({ url: this.href, type: 'POST', data: {'_method': method} }); } else { return request({ url: this.href }); } }); // remote forms handler jQuery('form[data-remote=true]').live('submit', function() { return request({ url : this.action, type : this.method, data : jQuery(this).serialize() }); });
Version data entries
14 entries across 9 versions & 1 rubygems