(function() { var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, extend = 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; }, hasProp = {}.hasOwnProperty; Backbone.Poised || (Backbone.Poised = {}); Backbone.Poised.List = (function(superClass) { extend(List, superClass); function List() { this.render = bind(this.render, this); this.appendGroup = bind(this.appendGroup, this); this.appendAddButton = bind(this.appendAddButton, this); this.appendItem = bind(this.appendItem, this); this.appendSearchfield = bind(this.appendSearchfield, this); return List.__super__.constructor.apply(this, arguments); } List.prototype.tagName = 'ul'; List.prototype.className = 'poised'; List.prototype.addButtonTemplate = _.template("
  • <%= label %>
  • "); List.prototype.extractGroupOptions = function(options) { if (options == null) { options = {}; } return this.options.group = _.chain(options).pick('by', 'collapsible', 'collapsed', 'sorting').defaults({ collapsible: false, collapsed: [] }).value(); }; List.prototype.initialize = function(options) { this.options = _.chain(options).pick('filterAttributes', 'itemClass', 'itemLabel', 'itemTemplate', 'addible', 'addLabel', 'singleSelect').defaults({ filterAttributes: false, itemClass: Backbone.Poised.List.Item, addible: false, singleSelect: false }).value(); this.extractGroupOptions(options.group); return this.collection.on('add remove reset', this.render); }; List.prototype.appendSearchfield = function() { this.subviews.searchfield = new Backbone.Poised.List.Searchfield({ parentView: this, locale: this.locale, localePrefix: this.localePrefix }); return this.$el.append(this.subviews.searchfield.render().el); }; List.prototype.appendItem = function(model, $el) { var itemView; if ($el == null) { $el = this.$el; } this.subviews["item" + model.cid] = itemView = new this.options.itemClass({ model: model, parentView: this, itemLabel: this.options.itemLabel, itemTemplate: this.options.itemTemplate, filterAttributes: this.options.filterAttributes, singleSelect: this.options.singleSelect, locale: this.locale, localePrefix: this.localePrefix }); return $el.append(itemView.render().el); }; List.prototype.appendAddButton = function() { this.subviews.addButton = new Backbone.Poised.List.AddButton({ label: this.options.addLabel || 'Add item', parentView: this, locale: this.locale, localePrefix: this.localePrefix }); return this.$el.append(this.subviews.addButton.render().el); }; List.prototype.appendGroup = function(group, models) { var $grp, groupView, i, len, model, results; group = group.toCamel(); this.subviews[group] = groupView = new Backbone.Poised.List.Anchor({ name: group, parentView: this, collapsible: $.ematch(group, this.options.group.collapsible), collapsed: $.ematch(group, this.options.group.collapsed), locale: this.locale, localePrefix: this.localePrefix }); this.$el.append(groupView.render().el); $grp = $('