o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1381401969.026604: @value"{I" class:EFI"ProcessedAsset;FI"logical_path;FI"9locomotive/views/content_types/custom_fields_view.js;TI" pathname;FI"‘/Users/papipo/.rvm/gems/ruby-1.9.3-p448/gems/locomotive_cms-2.2.3/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-10-10T12:39:17+02:00;FI" length;FiI" digest;F"%7dedfc99cebf88d9d37259e29187eb93I" 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).ContentTypes || (_base.ContentTypes = {}); Locomotive.Views.ContentTypes.CustomFieldsView = (function(_super) { var _entry_views; __extends(CustomFieldsView, _super); function CustomFieldsView() { _ref = CustomFieldsView.__super__.constructor.apply(this, arguments); return _ref; } CustomFieldsView.prototype.tagName = 'div'; CustomFieldsView.prototype.className = 'list'; _entry_views = []; CustomFieldsView.prototype.events = { 'click .new-entry a.add': 'add_entry', 'keypress .new-entry input[type=text]': 'add_on_entry_from_enter' }; CustomFieldsView.prototype.initialize = function() { return _.bindAll(this, 'refresh_position_entries'); }; CustomFieldsView.prototype.render = function() { $(this.el).html(ich.custom_fields_list(this.model.toJSON())); this.render_entries(); this.make_list_sortable(); return this; }; CustomFieldsView.prototype.make_list_sortable = function() { return this.sortable_list = this.$('> ul').sortable({ handle: '.handle', items: 'li.custom-field', axis: 'y', update: this.refresh_position_entries }); }; CustomFieldsView.prototype.refresh_position_entries = function() { return _.each(this._entry_views, function(view) { return view.model.set({ position: $(view.el).index() }); }); }; CustomFieldsView.prototype.find_entry_view = function(key) { return _.find(this._entry_views, function(view) { if (key.length > 3) { return view.model.id === key; } else { return view.model.get('position') === parseInt(key); } }); }; CustomFieldsView.prototype.add_entry = function(event) { var custom_field, labelInput, params, typeInput; event.stopPropagation() & event.preventDefault(); labelInput = this.$('> .new-entry input[name=label]'); typeInput = this.$('> .new-entry select'); if (labelInput.val() !== '') { custom_field = new Locomotive.Models.CustomField({ label: labelInput.val(), type: typeInput.val() }); params = { string: labelInput.val(), underscore: '1' }; $.getJSON(window.permalink_service_url, params, function(data, textStatus, jqXHR) { return custom_field.set('name', data['value']); }); this.model.get('entries_custom_fields').add(custom_field); this._insert_entry(custom_field); this.$('> .empty').hide(); this.sortable_list.sortable('refresh'); return labelInput.val(''); } }; CustomFieldsView.prototype.add_on_entry_from_enter = function(event) { if (event.keyCode !== 13) { return; } return this.add_entry(event); }; CustomFieldsView.prototype.remove_entry = function(custom_field, view) { if (custom_field.isNew()) { this.model.get('entries_custom_fields').remove(custom_field); } else { custom_field.set({ _destroy: true }); } this._entry_views = _.reject(this._entry_views, function(_view) { return _view === view; }); this.refresh_position_entries(); if (this._entry_views.length === 0) { return this.$('> .empty').show(); } }; CustomFieldsView.prototype.render_entries = function() { var _this = this; if (this.model.get('entries_custom_fields').length === 0) { return this.$('> .empty').show(); } else { return this.model.get('entries_custom_fields').each(function(custom_field) { return _this._insert_entry(custom_field); }); } }; CustomFieldsView.prototype._insert_entry = function(custom_field) { var view; view = new Locomotive.Views.ContentTypes.CustomFieldEntryView({ model: custom_field, parent_view: this }); (this._entry_views || (this._entry_views = [])).push(view); this.$('> ul').append(view.render().el); return this.refresh_position_entries(); }; return CustomFieldsView; })(Backbone.View); }).call(this); ;TI"dependency_digest;F"%c35ecbb1d4702dd498857d87f9003111I"required_paths;F[I"‘/Users/papipo/.rvm/gems/ruby-1.9.3-p448/gems/locomotive_cms-2.2.3/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.coffee;TI"dependency_paths;F[{I" path;FI"‘/Users/papipo/.rvm/gems/ruby-1.9.3-p448/gems/locomotive_cms-2.2.3/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.coffee;TI" mtime;FI"2013-10-10T12:39:17+02:00;FI" digest;F"%8741549bfb7834d98e65c555ac29f4adI" _version;F"%ffd318ca8b794f42f5029101c2cf5d91