o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1381142257.433561: @value"a{I" class:EFI"ProcessedAsset;FI"logical_path;FI"4locomotive/views/shared/fields/has_many_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/fields/has_many_view.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-10-07T10:55:40+02:00;FI" length;FiiI" digest;F"%3fc2ca0d7b852ebba5072780d70d3fc3I" 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"%5c1e1a2c15c9e56bdf8c9ac9cb29020fI"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/fields/has_many_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/fields/has_many_view.js.coffee;TI" mtime;FI"2013-10-07T10:55:40+02:00;FI" digest;F"%b0fc487a1c3ad5fa856d841f06905a11I" _version;F"%ffd318ca8b794f42f5029101c2cf5d91