spec/dummy/tmp/cache/assets/D42/A50/sprockets%2F6eeb95c9b82772676251bc26c51a3aec in locomotivecms-search-0.2.8 vs spec/dummy/tmp/cache/assets/D42/A50/sprockets%2F6eeb95c9b82772676251bc26c51a3aec in locomotivecms-search-0.3.0
- old
+ new
@@ -1,9 +1,9 @@
-o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1384093247.229198:@value"{I"
+o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1396022041.625993:@value"{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"8locomotive/views/shared/fields/many_to_many_view.js; FI"
pathname; TI"~/Users/didier/Documents/LocomotiveCMS/engine/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee; FI"content_type; TI"application/javascript; TI"
-mtime; TI"2013-07-06T11:40:04+02:00; TI"length; TiI"digest; TI"%22df1b1b6042756fd55324fd3c6fb27a; FI"source; TI"(function() {
- var _base, _base1, _ref,
+mtime; TI"2013-11-22T20:40:15+01:00; TI"length; TiI"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 = {});
@@ -11,21 +11,20 @@
Locomotive.Views.Shared.Fields.ManyToManyView = (function(_super) {
__extends(ManyToManyView, _super);
function ManyToManyView() {
- _ref = ManyToManyView.__super__.constructor.apply(this, arguments);
- return _ref;
+ 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 select': '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"];
@@ -35,32 +34,32 @@
return ich["" + this.options.name + "_entry"];
};
ManyToManyView.prototype.initialize = function() {
_.bindAll(this, 'refresh_position_entries');
- this.collection = this.model.get(this.options.name);
- return this.all_entries = this.options.all_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.refresh_select_field();
+ this.enable_select2();
return this;
};
ManyToManyView.prototype.ui_enabled = function() {
return this.template() != null;
};
ManyToManyView.prototype.insert_entries = function() {
- var _this = this;
if (this.collection.length > 0) {
- return this.collection.each(function(entry) {
- return _this.insert_entry(entry);
- });
+ return this.collection.each((function(_this) {
+ return function(entry) {
+ return _this.insert_entry(entry);
+ };
+ })(this));
} else {
return this.$('.empty').show();
}
};
@@ -85,29 +84,30 @@
update: this.refresh_position_entries
});
};
ManyToManyView.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", index);
- });
+ 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 entry, entry_id;
+ var data, entry;
event.stopPropagation() & event.preventDefault();
- entry_id = this.$('.new-entry select').val();
- entry = this.get_entry_from_id(entry_id);
- if (entry == null) {
+ 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.refresh_select_field();
+ return this.$('.new-entry .selected-entry').select2('val', '');
};
ManyToManyView.prototype.remove_entry = function(event) {
var entry;
event.stopPropagation() & event.preventDefault();
@@ -116,69 +116,30 @@
this.collection.remove(entry);
$(event.target).closest('li').remove();
if (this.$('> ul > li').size() === 0) {
this.$('.empty').show();
}
- return this.refresh_position_entries() & this.refresh_select_field();
+ return this.refresh_position_entries();
}
};
- ManyToManyView.prototype.refresh_select_field = function() {
- var _this = this;
- this.$('.new-entry select optgroup, .new-entry select option').remove();
- return _.each(this.all_entries, function(entry_or_group) {
- var group_html, option;
- if (_.isArray(entry_or_group.entries)) {
- group_html = $('<optgroup/>').attr('label', entry_or_group.name);
- _.each(entry_or_group.entries, function(entry) {
- var option;
- if (_this.collection.get(entry._id) == null) {
- option = new Option(entry._label, entry._id, false);
- return group_html.append(option);
- }
- });
- return _this.$('.new-entry select').append(group_html);
- } else {
- if (_this.collection.get(entry_or_group._id) == null) {
- option = new Option(entry_or_group._label, entry_or_group._id, false);
- return _this.$('.new-entry select').append(option);
- }
- }
- });
+ 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);
};
- ManyToManyView.prototype.get_entry_from_id = function(id) {
- var entry,
- _this = this;
- entry = null;
- _.each(this.all_entries, function(entry_or_group) {
- if (_.isArray(entry_or_group.entries)) {
- return entry || (entry = _.detect(entry_or_group.entries, function(_entry) {
- return _entry._id === id;
- }));
- } else {
- if (entry_or_group._id === id) {
- return entry = entry_or_group;
- }
- }
- });
- if (entry != null) {
- return new Locomotive.Models.ContentEntry(entry);
- } else {
- return null;
- }
- };
-
return ManyToManyView;
- })(Backbone.View);
+ })(Locomotive.Views.Shared.Fields.RelationshipView);
}).call(this);
-; TI"dependency_digest; TI"%44764c3fcbdfc4b32862d9d925df78d2; FI"required_paths; T[I"~/Users/didier/Documents/LocomotiveCMS/engine/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee; FI"dependency_paths; T[{I" path; TI"~/Users/didier/Documents/LocomotiveCMS/engine/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee; FI"
-mtime; TI"2013-07-06T11:40:04+02:00; TI"digest; TI"%46decb93dc7e08b0755e076af2553870; FI"
_version; TI"%ffd318ca8b794f42f5029101c2cf5d91; F
+; TI"dependency_digest; TI"%d46110c346419fd887c17e9427ad4ade; FI"required_paths; T[I"~/Users/didier/Documents/LocomotiveCMS/engine/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee; FI"dependency_paths; T[{I" path; TI"~/Users/didier/Documents/LocomotiveCMS/engine/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee; FI"
+mtime; TI"2013-11-22T20:40:15+01:00; TI"digest; TI"%335e919568e0e231ceb2a6547824f964; FI"
_version; TI"%ffd318ca8b794f42f5029101c2cf5d91; F
\ No newline at end of file