o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1364984314.81356: @value"{I" class:EFI"ProcessedAsset;FI"logical_path;FI"4locomotive/views/shared/fields/has_many_view.js;TI" pathname;FI"{/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-04-03T11:01:13+02:00;FI" length;FiiI" digest;F"%455c5872895c6e81ab249d1febc0babbI" source;FI"i(function() { var _base, _base1, _ref, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __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.HasManyView = (function(_super) { __extends(HasManyView, _super); function HasManyView() { this.get_entry_from_element = __bind(this.get_entry_from_element, this); _ref = HasManyView.__super__.constructor.apply(this, arguments); return _ref; } HasManyView.prototype.tagName = 'div'; HasManyView.prototype.className = 'list'; HasManyView.prototype.events = { 'click p.actions a.add': 'open_new_entry_view', 'click ul span.actions a.edit': 'edit_entry', 'click ul span.actions a.remove': 'remove_entry' }; HasManyView.prototype.template = function() { return ich["" + this.options.name + "_list"]; }; HasManyView.prototype.entry_template = function() { return ich["" + this.options.name + "_entry"]; }; HasManyView.prototype.initialize = function() { _.bindAll(this, 'refresh_position_entries'); this.collection = this.model.get(this.options.name); return this.build_target_entry_view(); }; HasManyView.prototype.render = function() { $(this.el).html(this.template()()); this.insert_entries(); this.make_entries_sortable(); return this; }; HasManyView.prototype.ui_enabled = function() { return this.template() != null; }; HasManyView.prototype.insert_entries = function() { var _this = this; if (this.collection.length > 0) { return this.collection.each(function(entry) { return _this.insert_entry(entry); }); } else { return this.$('.empty').show(); } }; HasManyView.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); }; HasManyView.prototype.make_entries_sortable = function() { return this.sortable_list = this.$('> ul').sortable({ handle: '.handle', items: 'li', axis: 'y', update: this.refresh_position_entries }); }; HasManyView.prototype.refresh_position_entries = function() { var _this = this; return this.$('> ul > li').each(function(index, entry_html) { var entry, id; id = $(entry_html).data('data-entry-id'); entry = _this.collection.get(id); return entry.set_attribute("position_in_" + _this.options.inverse_of, index); }); }; HasManyView.prototype.build_target_entry_view = function() { this.target_entry_view = new Locomotive.Views.ContentEntries.PopupFormView({ el: $("#" + this.options.name + "-template-entry"), parent_view: this, model: this.options.new_entry.clone(), namespace: this.options.name }); return this.target_entry_view.render(); }; HasManyView.prototype.edit_entry = function(event) { var entry; event.stopPropagation() & event.preventDefault(); entry = this.get_entry_from_element($(event.target)); this.target_entry_view.reset(entry); return this.target_entry_view.open(); }; HasManyView.prototype.update_entry = function(entry) { var entry_html, new_entry_html; entry_html = $(_.detect(this.$('> ul > li'), function(_entry_html) { return $(_entry_html).data('data-entry-id') === entry.id; })); this.collection.get(entry.id).set(entry.attributes); new_entry_html = $(this.entry_template()({ label: entry.get('_label') })); new_entry_html.data('data-entry-id', entry.id); return entry_html.replaceWith(new_entry_html); }; HasManyView.prototype.insert_or_update_entry = function(entry) { if (this.collection.get(entry.id) != null) { return this.update_entry(entry); } else { return this.insert_entry(entry); } }; HasManyView.prototype.remove_entry = function(event) { var entry; event.stopPropagation() & event.preventDefault(); if (confirm($(event.target).data('confirm'))) { entry = this.get_entry_from_element($(event.target)); entry.set({ _destroy: true }); $(event.target).closest('li').remove(); if (this.$('> ul > li').size() === 0) { this.$('.empty').show(); } return this.refresh_position_entries(); } }; HasManyView.prototype.open_new_entry_view = function(event) { event.stopPropagation() & event.preventDefault(); this.target_entry_view.reset(this.options.new_entry.clone()); return this.target_entry_view.open(); }; HasManyView.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 HasManyView; })(Backbone.View); }).call(this); ;TI"dependency_digest;F"%f0b04e012f86db8c29b7c94edf188704I"required_paths;F[I"{/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee;TI"dependency_paths;F[{I" path;FI"{/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee;TI" mtime;FI"2013-04-03T11:01:13+02:00;FI" digest;F"%28824689b184254e375aa9d23c8c58cdI" _version;F"%6776f581a4329e299531e1d52aa59832