o: ActiveSupport::Cache::Entry :@compressedF:@created_atf1327292622.6592989 1ô:@value"ô{"content_type"application/javascript" class"ProcessedAsset"dependency_digest"%8a8fab00855396855342ca20a9c416e5" mtime"2012-01-23T15:23:26+11:00" _version"%45a9b34d2c65935f21d8f90f1e1b2836"dependency_paths[{" mtime"2012-01-23T15:23:26+11:00"digest"%e6ead66c83fcba442077044eab9c67d9" path"f/Users/tom/Development/Percolate/edifice-forms/app/assets/javascripts/edifice-forms/rails_form.js"digest"%60976f00a5785cbfdceaf3ad3a0c4f43"required_paths["f/Users/tom/Development/Percolate/edifice-forms/app/assets/javascripts/edifice-forms/rails_form.js" pathname"f/Users/tom/Development/Percolate/edifice-forms/app/assets/javascripts/edifice-forms/rails_form.js"logical_path" edifice-forms/rails_form.js"lengthi"source"/** * A small jQuery plugin to add 'rails-aware' form functionality. * * Basically, this understands the 'standard' rails way of structuring forms * and makes some functions available to manipulate that. */ (function($) { $.fn.rails_form = function(method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else { $.error('Method ' + method + ' does not exist on rails_form'); } }; // in these 'this' is the $form var methods = { fields: function() { return this.find('input:not([type=hidden]):not([type=submit]), textarea, select'); }, field: function(name_or_field) { if (name_or_field instanceof $) { return name_or_field; } else { return this.rails_form('fields').filter('[name*=' + $.escape(name_or_field) + ']'); } }, error_fields: function() { var $form = this; return this.rails_form('fields').filter(function() { return $form.rails_form('has_error', $(this)); }); }, submits: function() { return this.find('input[type=submit], button[type=submit]'); }, label_for: function(name_or_field) { var $field = this.rails_form('field', name_or_field); return this.find('label[for=' + $field.attr('id') + ']'); }, error_on: function(name_or_field) { return this.rails_form('label_for', name_or_field).parents('.field_with_errors').next('.formError'); }, has_error: function(name_or_field) { var $field = this.rails_form('field', name_or_field); return $field.parent('.field_with_errors').length > 0; }, clear_errors: function() { var $form = this; this.rails_form('fields').each(function() { $form.rails_form('clear_error', $(this)); }); // clear base errors too this.find('.errors').html(''); }, clear_error: function(name_or_field) { var $field = this.rails_form('field', name_or_field); var id = $field.attr('id'); if (this.rails_form('has_error', $field)) { $field.unwrap() } this.find('.field_with_errors label[for=' + id + ']') .unwrap() .next('.formError').remove(); // remove from a .errors ul this.find('.errors [data-for=' + id + ']').remove(); return this; }, // display standard errors as returned by JSON set_errors: function(errors) { this.rails_form('clear_errors'); for (var name in errors) { for (var i in errors[name]) { this.rails_form('add_error', name, errors[name][i]); } } return this; }, add_error: function(name_or_field, error) { var $field = this.rails_form('field', name_or_field); $field.filter('.field_with_errors > *').unwrap(); $field.wrap('