o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1384182741.6861172: @value"ú{I" class:ETI"ProcessedAsset;FI"logical_path;TI"4locomotive/views/shared/fields/has_many_view.js;FI" pathname;TI"¤/Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/locomotive_cms-2.3.1/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;TI"2013-11-11T00:40:29+01:00;TI" length;Ti¯I" digest;TI"%82d1d00185e52c6441acfa17725cfb68;FI" source;TI"¯(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()()).attr('id', "" + this.model.paramRoot + "_" + this.options.name); 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).closest('a').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;TI"%30dcc05d241309370918e92d51ed875c;FI"required_paths;T[I"¤/Users/didier/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/locomotive_cms-2.3.1/app/assets/javascripts/locomotive/views/shared/fields/has_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/gems/locomotive_cms-2.3.1/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee;FI" mtime;TI"2013-11-11T00:40:29+01:00;TI" digest;TI"%a73e3e9cc2a844a686df9597594e7dc6;FI" _version;TI"%ffd318ca8b794f42f5029101c2cf5d91;F