o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1397508827.905004: @value"w{I" class:ETI"ProcessedAsset;FI"logical_path;TI"9locomotive/views/content_types/custom_fields_view.js;FI" pathname;TI"­/Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-5337f0929131/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.coffee;FI"content_type;TI"application/javascript;TI" mtime;TI"2014-04-10T01:06:58+02:00;TI" length;Ti I" digest;TI"%61d311e1c6dcde1887c4342cb7f1f677;FI" source;TI" (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).ContentTypes || (_base.ContentTypes = {}); Locomotive.Views.ContentTypes.CustomFieldsView = (function(_super) { var _entry_views; __extends(CustomFieldsView, _super); function CustomFieldsView() { return CustomFieldsView.__super__.constructor.apply(this, arguments); } 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() { if (this.model.get('entries_custom_fields').length === 0) { return this.$('> .empty').show(); } else { return this.model.get('entries_custom_fields').each((function(_this) { return function(custom_field) { return _this._insert_entry(custom_field); }; })(this)); } }; 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;TI"%2916521b19875ad049f4f8ed4a3498a0;FI"required_paths;T[I"­/Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-5337f0929131/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.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-5337f0929131/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.coffee;FI" mtime;TI"2014-04-10T01:06:58+02:00;TI" digest;TI"%8741549bfb7834d98e65c555ac29f4ad;FI" _version;TI"%ffd318ca8b794f42f5029101c2cf5d91;F