o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1381142253.509973: @value"¿{I" class:EFI"ProcessedAsset;FI"logical_path;FI")locomotive/views/shared/form_view.js;TI" pathname;FI"„/Users/papipo/.rvm/gems/ruby-1.9.3-p448/gems/locomotive_cms-2.1.0/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-10-07T10:55:40+02:00;FI" length;FióI" digest;F"%647ebb76896198d32c659a7fc787e3feI" 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, form textarea: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] + "

"); _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)) { 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, _this = this; options || (options = {}); model_name = options.model_name || this.model.paramRoot; return this.$("li#" + model_name + "_" + name + "_input input[type=checkbox]").checkToggle({ on_callback: 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(); }, off_callback: 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(); } }); }; FormView.prototype._hide_last_separator = function() { var _this = this; return _.each(this.$('fieldset'), function(fieldset) { $(fieldset).find('li.last').removeClass('last'); return $(_.last($(fieldset).find('li.input:visible'))).addClass('last'); }); }; return FormView; })(Backbone.View); }).call(this); ;TI"dependency_digest;F"%a452dce2e26c059c0868abd2b82a91c2I"required_paths;F[I"„/Users/papipo/.rvm/gems/ruby-1.9.3-p448/gems/locomotive_cms-2.1.0/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;TI"dependency_paths;F[{I" path;FI"„/Users/papipo/.rvm/gems/ruby-1.9.3-p448/gems/locomotive_cms-2.1.0/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;TI" mtime;FI"2013-10-07T10:55:40+02:00;FI" digest;F"%e4f8acd406d0d29f928f278bc23eee51I" _version;F"%ffd318ca8b794f42f5029101c2cf5d91