o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1396088397.7672389: @value"{I" class:ETI"ProcessedAsset;FI"logical_path;TI"8locomotive/views/shared/fields/many_to_many_view.js;FI" pathname;TI"¯/Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-c0bddd719ddf/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;TI"2014-03-29T11:18:01+01:00;TI" length;Ti¤I" digest;TI"%2d7e2b77a66b7630c8133a2e122dbc5f;FI" source;TI"¤(function() { var _base, _base1, __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 = {}); (_base1 = Locomotive.Views.Shared).Fields || (_base1.Fields = {}); Locomotive.Views.Shared.Fields.ManyToManyView = (function(_super) { __extends(ManyToManyView, _super); function ManyToManyView() { return ManyToManyView.__super__.constructor.apply(this, arguments); } ManyToManyView.prototype.tagName = 'div'; ManyToManyView.prototype.className = 'list'; ManyToManyView.prototype.events = { 'click .new-entry a.add': 'add_entry', 'keypress .new-entry input.selected-entry': 'add_entry', 'click ul span.actions a.remove': 'remove_entry' }; ManyToManyView.prototype.template = function() { return ich["" + this.options.name + "_list"]; }; ManyToManyView.prototype.entry_template = function() { return ich["" + this.options.name + "_entry"]; }; ManyToManyView.prototype.initialize = function() { _.bindAll(this, 'refresh_position_entries'); return this.collection = this.model.get(this.options.name); }; ManyToManyView.prototype.render = function() { $(this.el).html(this.template()()).attr('id', "" + this.model.paramRoot + "_" + this.options.name + "_ids"); this.insert_entries(); this.make_entries_sortable(); this.enable_select2(); return this; }; ManyToManyView.prototype.ui_enabled = function() { return this.template() != null; }; ManyToManyView.prototype.insert_entries = function() { if (this.collection.length > 0) { return this.collection.each((function(_this) { return function(entry) { return _this.insert_entry(entry); }; })(this)); } else { return this.$('.empty').show(); } }; ManyToManyView.prototype.insert_entry = function(entry) { var entry_html; if (this.collection.get(entry.get('_id')) == null) { this.collection.add(entry); } this.$('.empty').hide(); entry_html = $(this.entry_template()({ label: entry.get('_label') })); entry_html.data('data-entry-id', entry.id); return this.$('> ul').append(entry_html); }; ManyToManyView.prototype.make_entries_sortable = function() { return this.sortable_list = this.$('> ul').sortable({ handle: '.handle', items: 'li', axis: 'y', update: this.refresh_position_entries }); }; ManyToManyView.prototype.refresh_position_entries = function() { return this.$('> ul > li').each((function(_this) { return function(index, entry_html) { var entry, id; id = $(entry_html).data('data-entry-id'); entry = _this.collection.get(id); return entry.set_attribute("__position", index); }; })(this)); }; ManyToManyView.prototype.add_entry = function(event) { var data, entry; event.stopPropagation() & event.preventDefault(); data = this.$('.new-entry .selected-entry').select2('data'); if ((data == null) || _.isArray(data)) { return; } entry = new Locomotive.Models.ContentEntry(data); this.insert_entry(entry); return this.$('.new-entry .selected-entry').select2('val', ''); }; ManyToManyView.prototype.remove_entry = function(event) { var entry; event.stopPropagation() & event.preventDefault(); if (confirm($(event.target).closest('a').data('confirm'))) { entry = this.get_entry_from_element($(event.target)); this.collection.remove(entry); $(event.target).closest('li').remove(); if (this.$('> ul > li').size() === 0) { this.$('.empty').show(); } return this.refresh_position_entries(); } }; ManyToManyView.prototype.enable_select2 = function() { var $input, options; $input = this.$('.new-entry .selected-entry'); options = $input.data(); return ManyToManyView.__super__.enable_select2.call(this, $input, options); }; ManyToManyView.prototype.get_entry_from_element = function(element) { var entry_html, id; entry_html = $(element).closest('li'); id = $(entry_html).data('data-entry-id'); return this.collection.get(id); }; return ManyToManyView; })(Locomotive.Views.Shared.Fields.RelationshipView); }).call(this); ;TI"dependency_digest;TI"%d46110c346419fd887c17e9427ad4ade;FI"required_paths;T[I"¯/Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/engine-c0bddd719ddf/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_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-c0bddd719ddf/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee;FI" mtime;TI"2014-03-29T11:18:01+01:00;TI" digest;TI"%335e919568e0e231ceb2a6547824f964;FI" _version;TI"%ffd318ca8b794f42f5029101c2cf5d91;F