o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1364984308.3564239:@value"\{I" class:EFI"ProcessedAsset; FI"logical_path; FI")locomotive/views/shared/form_view.js; TI" pathname; FI"p/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee; TI"content_type; FI"application/javascript; FI" mtime; FI"2013-04-03T11:01:13+02:00; FI"length; FiÞI"digest; F"%212a7d68016081a8c2032f962d2e540dI"source; FI"Þ(function() { var _base, _ref, __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() { _ref = FormView.__super__.constructor.apply(this, arguments); return _ref; } 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, _this = this; event.stopPropagation() & event.preventDefault(); 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(model, response, _options) { form.trigger('ajax:complete'); model.attributes = previous_attributes; if (options.on_success) { return options.on_success(model, xhr); } }); return xhr.error(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(); } }); }; FormView.prototype.make_title_editable = function() { var target, title, _this = this; title = this.$('h2 a.editable'); if (title.size() > 0) { target = this.$("#" + (title.attr('rel'))); target.parent().hide(); return title.click(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'); } }); } }; 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.enable_save_with_keys_combination = function() { var _this = this; return $.cmd('S', (function() { var input; input = _this.$('form input[type=text]:focus, form input[type=password]:focus'); if (input.size() > 0) { input.trigger('change'); } return _this.$('form input[type=submit]').trigger('click'); }), [], { 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] + "