o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1396340894.806109: @value"† {I" class:ETI"ProcessedAsset;FI"logical_path;TI")locomotive/views/shared/form_view.js;FI" pathname;TI" /Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-89566d497862/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;TI"2014-04-01T10:04:05+02:00;TI" length;TiRI" digest;TI"%513829292e23cb82ee3136c0de4e902a;FI" source;TI"R(function() { var _base, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; (_base = Locomotive.Views).Shared || (_base.Shared = {}); Locomotive.Views.Shared.FormView = (function(_super) { __extends(FormView, _super); function FormView() { return FormView.__super__.constructor.apply(this, arguments); } FormView.prototype.el = '#content'; FormView.prototype.namespace = null; FormView.prototype.render = function() { this.make_title_editable(); this._hide_last_separator(); this.make_inputs_foldable(); this.enable_save_with_keys_combination(); this.enable_form_notifications(); return this; }; FormView.prototype.save = function(event) {}; FormView.prototype.save_in_ajax = function(event, options) { var form, previous_attributes, xhr; event.stopPropagation() & event.preventDefault(); this.trigger_change_event_on_focused_inputs(); form = $(event.target).trigger('ajax:beforeSend'); this.clear_errors(); options || (options = { headers: {}, on_success: null, on_error: null }); previous_attributes = _.clone(this.model.attributes); xhr = this.model.save({}, { headers: options.headers, silent: true }); xhr.success((function(_this) { return function(model, response, _options) { form.trigger('ajax:complete'); _this.model.set(previous_attributes); model.attributes = previous_attributes; if (options.on_success) { return options.on_success(model, xhr); } }; })(this)); return xhr.error((function(_this) { return function(model, xhr) { var errors; form.trigger('ajax:complete'); errors = JSON.parse(model.responseText); _this.show_errors(errors); if (options.on_error) { return options.on_error(); } }; })(this)); }; FormView.prototype.make_title_editable = function() { var target, title; title = this.$('h2 a.editable'); if (title.size() > 0) { target = this.$("#" + (title.attr('rel'))); target.parent().hide(); return title.click((function(_this) { return function(event) { var newValue; event.stopPropagation() & event.preventDefault(); newValue = prompt(title.attr('title'), title.html()); if (newValue && newValue !== '') { title.html(newValue); return target.val(newValue).trigger('change'); } }; })(this)); } }; FormView.prototype.make_inputs_foldable = function() { var self; self = this; this.$('.formtastic fieldset.foldable.folded ol').hide(); return this.$('.formtastic fieldset.foldable legend').click(function() { var content, parent; parent = $(this).parent(); content = $(this).next(); if (parent.hasClass('folded')) { parent.removeClass('folded'); return content.slideDown(100, function() { return self.after_inputs_fold(parent); }); } else { return content.slideUp(100, function() { return parent.addClass('folded'); }); } }); }; FormView.prototype.trigger_change_event_on_focused_inputs = function() { var input; input = this.$('form input[type=text]:focus, form input[type=password]:focus, form textarea:focus'); if (input.size() > 0) { return input.trigger('change'); } }; FormView.prototype.enable_save_with_keys_combination = function() { return $.cmd('S', ((function(_this) { return function() { return _this.$('form input[type=submit]').trigger('click'); }; })(this)), [], { ignoreCase: true }); }; FormView.prototype.enable_form_notifications = function() { return this.$('form').formSubmitNotification(); }; FormView.prototype.after_inputs_fold = function() {}; FormView.prototype.clear_errors = function() { return this.$('.inline-errors').remove(); }; FormView.prototype.show_errors = function(errors) { var attribute, html, message, _results; _results = []; for (attribute in errors) { message = errors[attribute]; if (_.isString(message[0])) { html = $("

" + message[0] + "

"); _results.push(this.show_error(attribute, message[0], html)); } else { _results.push(this.show_error(attribute, message)); } } return _results; }; FormView.prototype.show_error = function(attribute, message, html) { var anchor, input, prefix; prefix = this.namespace != null ? "" + this.namespace + "_" : ''; input = this.$("#" + prefix + this.model.paramRoot + "_" + attribute); if (input.size() === 0) { input = this.$("#" + prefix + this.model.paramRoot + "_" + attribute + "_id"); } if (input.size() === 0) { input = this.$("#" + prefix + this.model.paramRoot + "_" + attribute + "_ids"); } if (!(input.size() > 0)) { return; } anchor = input.parent().find('.error-anchor'); if (anchor.size() === 0) { anchor = input; } return anchor.after(html); }; FormView.prototype._enable_checkbox = function(name, options) { var model_name; options || (options = {}); model_name = options.model_name || this.model.paramRoot; return this.$("li#" + model_name + "_" + name + "_input input[type=checkbox]").checkToggle({ on_callback: (function(_this) { return function() { _.each(options.features, function(exp) { return this.$("li#" + model_name + "_" + exp + "_input").hide(); }); if (options.on_callback != null) { options.on_callback(); } return _this._hide_last_separator(); }; })(this), off_callback: (function(_this) { return function() { _.each(options.features, function(exp) { return this.$("li#" + model_name + "_" + exp + "_input").show(); }); if (options.off_callback != null) { options.off_callback(); } return _this._hide_last_separator(); }; })(this) }); }; FormView.prototype._hide_last_separator = function() { return _.each(this.$('fieldset'), (function(_this) { return function(fieldset) { $(fieldset).find('li.last').removeClass('last'); return $(_.last($(fieldset).find('li.input:visible'))).addClass('last'); }; })(this)); }; return FormView; })(Backbone.View); }).call(this); ;TI"dependency_digest;TI"%6890ee7858f5cd4b3d72b669a917efb7;FI"required_paths;T[I" /Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-89566d497862/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;FI"dependency_paths;T[{I" path;TI" /Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-89566d497862/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;FI" mtime;TI"2014-04-01T10:04:05+02:00;TI" digest;TI"%530d8faa1e59d267e84e809bd2f80524;FI" _version;TI"%ffd318ca8b794f42f5029101c2cf5d91;F