diff --git a/bower.json b/bower.json index 7f772b7eb..dd9b0a00b 100644 --- a/bower.json +++ b/bower.json @@ -87,7 +87,7 @@ "build/js/intlTelInput.js" ], "backbone.typeahead": [ - "backbone.typeahead.min.js" + "backbone.typeahead.js" ] }, "concat": { diff --git a/components/backbone.typeahead/backbone.typeahead.js b/components/backbone.typeahead/backbone.typeahead.js new file mode 100644 index 000000000..3c99b9730 --- /dev/null +++ b/components/backbone.typeahead/backbone.typeahead.js @@ -0,0 +1,285 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var __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; }, + __slice = [].slice; + + Backbone.TypeaheadCollection = (function(_super) { + __extends(TypeaheadCollection, _super); + + function TypeaheadCollection() { + return TypeaheadCollection.__super__.constructor.apply(this, arguments); + } + + TypeaheadCollection.prototype._tokenize = function(s) { + s = $.trim(s); + if (s.length === 0) { + return null; + } + return s.toLowerCase().split(/[\s\-_]+/); + }; + + + /* + Recursive method for walking an object as defined by an + array. Returns the value of the last key in the array + sequence. + @private + @method _deepObjectMap + @param {Object} Object to walk + @param {Array} Keys to walk the object with + @return {Value} Last value from the object by array walk + + @example + _deepObjectMap + key: + key2: + key3: "val" + , ['key', 'key2', 'key3'] + * Returns "val" + */ + + TypeaheadCollection.prototype._deepObjectMap = function(obj, attrs) { + if (!(attrs.length > 0 && _.isObject(obj))) { + return obj; + } + if (attrs.length === 1) { + return obj[attrs[0]]; + } + return this._deepObjectMap(obj[attrs[0]], attrs.slice(1, attrs.length)); + }; + + + /* + Split each typeaheadAttribute into an array of nested methods + and return an array map the returned values from deepObjectMap. + @private + @method _getAttributeValues + @param {Backbone.Model} Model to fetch and map values from + @return {Array} Values from model retrieved by _deepObjectMap + */ + + TypeaheadCollection.prototype._getAttributeValues = function(model) { + return _.map(this.typeaheadAttributes, (function(_this) { + return function(att) { + var attArray; + attArray = att.split('.'); + return _this._deepObjectMap(model.get(attArray[0]), attArray.slice(1)); + }; + })(this)); + }; + + TypeaheadCollection.prototype._extractValues = function(model) { + if (this.typeaheadAttributes != null) { + return this._getAttributeValues(model); + } else { + return _.values(model.attributes); + } + }; + + TypeaheadCollection.prototype._tokenizeModel = function(model) { + return _.uniq(this._tokenize(_.flatten(this._extractValues(model)).join(' '))); + }; + + TypeaheadCollection.prototype._addToIndex = function(models) { + var adjacency, character, id, model, t, tokens, _i, _len, _results; + if (!_.isArray(models)) { + models = [models]; + } + _results = []; + for (_i = 0, _len = models.length; _i < _len; _i++) { + model = models[_i]; + tokens = this._tokenizeModel(model); + id = model.id != null ? model.id : model.cid; + this._tokens[id] = tokens; + _results.push((function() { + var _base, _j, _len1, _results1; + _results1 = []; + for (_j = 0, _len1 = tokens.length; _j < _len1; _j++) { + t = tokens[_j]; + character = t.charAt(0); + adjacency = (_base = this._adjacency)[character] || (_base[character] = [id]); + if (!~_.indexOf(adjacency, id)) { + _results1.push(adjacency.push(id)); + } else { + _results1.push(void 0); + } + } + return _results1; + }).call(this)); + } + return _results; + }; + + TypeaheadCollection.prototype._removeFromIndex = function(models) { + var id, ids, k, v, _i, _len, _ref, _results; + if (!_.isArray(models)) { + models = [models]; + } + ids = _.map(models, function(m) { + if (m.id != null) { + return m.id; + } else { + return m.cid; + } + }); + for (_i = 0, _len = ids.length; _i < _len; _i++) { + id = ids[_i]; + delete this._tokens[id]; + } + _ref = this._adjacency; + _results = []; + for (k in _ref) { + v = _ref[k]; + _results.push(this._adjacency[k] = _.without.apply(_, [v].concat(__slice.call(ids)))); + } + return _results; + }; + + TypeaheadCollection.prototype._rebuildIndex = function() { + this._adjacency = {}; + this._tokens = {}; + return this._addToIndex(this.models); + }; + + TypeaheadCollection.prototype.typeaheadIndexer = function(facets) { + if (!((facets != null) && _.keys(facets).length > 0)) { + return null; + } + return _.map(this.where(facets), function(m) { + if (m.id != null) { + return m.id; + } else { + return m.cid; + } + }); + }; + + TypeaheadCollection.prototype.typeahead = function(query, facets) { + var checkIfShortestList, facetList, firstChars, id, isCandidate, isMatch, item, lists, queryTokens, shortestList, suggestions, _i, _len; + if (this._adjacency == null) { + throw new Error('Index is not built'); + } + queryTokens = this._tokenize(query); + lists = []; + shortestList = null; + firstChars = _(queryTokens).chain().map(function(t) { + return t.charAt(0); + }).uniq().value(); + checkIfShortestList = (function(_this) { + return function(list) { + if (list.length < ((shortestList != null ? shortestList.length : void 0) || _this.length)) { + return shortestList = list; + } + }; + })(this); + _.all(firstChars, (function(_this) { + return function(firstChar) { + var list; + list = _this._adjacency[firstChar]; + if (list == null) { + return false; + } + lists.push(list); + checkIfShortestList(list); + return true; + }; + })(this)); + if (lists.length < firstChars.length) { + return []; + } + facetList = this.typeaheadIndexer(facets); + if (facetList != null) { + lists.push(facetList); + checkIfShortestList(facetList); + } + if (shortestList == null) { + return this.models; + } + if (shortestList.length === 0) { + return []; + } + suggestions = []; + for (_i = 0, _len = shortestList.length; _i < _len; _i++) { + id = shortestList[_i]; + isCandidate = _.every(lists, function(list) { + return ~_.indexOf(list, id); + }); + isMatch = isCandidate && _.every(queryTokens, (function(_this) { + return function(qt) { + return _.some(_this._tokens[id], function(t) { + return t.indexOf(qt) === 0; + }); + }; + })(this)); + if (isMatch) { + item = this.get(id); + if (this.typeaheadPreserveOrder) { + suggestions[this.indexOf(item)] = item; + } else { + suggestions.push(item); + } + } + } + if (this.typeaheadPreserveOrder) { + return _.compact(suggestions); + } else { + return suggestions; + } + }; + + TypeaheadCollection.prototype._reset = function() { + this._tokens = {}; + this._adjacency = {}; + return TypeaheadCollection.__super__._reset.apply(this, arguments); + }; + + TypeaheadCollection.prototype.set = function() { + var models; + models = TypeaheadCollection.__super__.set.apply(this, arguments); + if (!_.isArray(models)) { + models = [models]; + } + this._rebuildIndex(models); + return models; + }; + + TypeaheadCollection.prototype.remove = function() { + var models; + models = TypeaheadCollection.__super__.remove.apply(this, arguments); + if (!_.isArray(models)) { + models = [models]; + } + this._removeFromIndex(models); + return models; + }; + + TypeaheadCollection.prototype._onModelEvent = function(event, model, collection, options) { + var add; + add = false; + if (event === ("change:" + model.idAttribute)) { + add = true; + this._removeFromIndex({ + id: model.previous(model.idAttribute) + }); + } else if (event.indexOf('change:') === 0) { + if ((this.typeaheadAttributes == null) || _.indexOf(_.map(this.typeaheadAttributes, function(att) { + return 'change:' + att; + }), event) >= 0) { + add = true; + this._removeFromIndex(model); + } + } + if (add) { + this._addToIndex(model); + } + return TypeaheadCollection.__super__._onModelEvent.apply(this, arguments); + }; + + return TypeaheadCollection; + + })(Backbone.Collection); + +}).call(this); + +//# sourceMappingURL=backbone.typeahead.js.map diff --git a/components/backbone.typeahead/backbone.typeahead.min.js b/components/backbone.typeahead/backbone.typeahead.min.js deleted file mode 100644 index ca19eb98c..000000000 --- a/components/backbone.typeahead/backbone.typeahead.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(){var t={}.hasOwnProperty,e=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e},n=[].slice;Backbone.TypeaheadCollection=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return e(r,t),r.prototype._tokenize=function(t){return t=$.trim(t),0===t.length?null:t.toLowerCase().split(/[\s\-_]+/)},r.prototype._deepObjectMap=function(t,e){return e.length>0&&_.isObject(t)?1===e.length?t[e[0]]:this._deepObjectMap(t[e[0]],e.slice(1,e.length)):t},r.prototype._getAttributeValues=function(t){return _.map(this.typeaheadAttributes,function(e){return function(n){var r;return r=n.split("."),e._deepObjectMap(t.get(r[0]),r.slice(1))}}(this))},r.prototype._extractValues=function(t){return null!=this.typeaheadAttributes?this._getAttributeValues(t):_.values(t.attributes)},r.prototype._tokenizeModel=function(t){return _.uniq(this._tokenize(_.flatten(this._extractValues(t)).join(" ")))},r.prototype._addToIndex=function(t){var e,n,r,i,o,u,s,a,h;for(_.isArray(t)||(t=[t]),h=[],s=0,a=t.length;a>s;s++)i=t[s],u=this._tokenizeModel(i),r=null!=i.id?i.id:i.cid,this._tokens[r]=u,h.push(function(){var t,i,s,a;for(a=[],i=0,s=u.length;s>i;i++)o=u[i],n=o.charAt(0),e=(t=this._adjacency)[n]||(t[n]=[r]),a.push(~_.indexOf(e,r)?void 0:e.push(r));return a}.call(this));return h},r.prototype._removeFromIndex=function(t){var e,r,i,o,u,s,a,h;for(_.isArray(t)||(t=[t]),r=_.map(t,function(t){return null!=t.id?t.id:t.cid}),u=0,s=r.length;s>u;u++)e=r[u],delete this._tokens[e];a=this._adjacency,h=[];for(i in a)o=a[i],h.push(this._adjacency[i]=_.without.apply(_,[o].concat(n.call(r))));return h},r.prototype._rebuildIndex=function(){return this._adjacency={},this._tokens={},this._addToIndex(this.models)},r.prototype.typeaheadIndexer=function(t){return null!=t&&_.keys(t).length>0?_.map(this.where(t),function(t){return null!=t.id?t.id:t.cid}):null},r.prototype.typeahead=function(t,e){var n,r,i,o,u,s,a,h,p,l,c,d,f;if(null==this._adjacency)throw new Error("Index is not built");if(p=this._tokenize(t),h=[],l=null,i=_(p).chain().map(function(t){return t.charAt(0)}).uniq().value(),n=function(t){return function(e){return e.length<((null!=l?l.length:void 0)||t.length)?l=e:void 0}}(this),_.all(i,function(t){return function(e){var r;return r=t._adjacency[e],null==r?!1:(h.push(r),n(r),!0)}}(this)),h.lengthd;d++)o=l[d],u=_.every(h,function(t){return~_.indexOf(t,o)}),s=u&&_.every(p,function(t){return function(e){return _.some(t._tokens[o],function(t){return 0===t.indexOf(e)})}}(this)),s&&(a=this.get(o),this.typeaheadPreserveOrder?c[this.indexOf(a)]=a:c.push(a));return this.typeaheadPreserveOrder?_.compact(c):c},r.prototype._reset=function(){return this._tokens={},this._adjacency={},r.__super__._reset.apply(this,arguments)},r.prototype.set=function(){var t;return t=r.__super__.set.apply(this,arguments),_.isArray(t)||(t=[t]),this._rebuildIndex(t),t},r.prototype.remove=function(){var t;return t=r.__super__.remove.apply(this,arguments),_.isArray(t)||(t=[t]),this._removeFromIndex(t),t},r.prototype._onModelEvent=function(t,e){var n;return n=!1,t==="change:"+e.idAttribute?(n=!0,this._removeFromIndex({id:e.previous(e.idAttribute)})):0===t.indexOf("change:")&&(null==this.typeaheadAttributes||_.indexOf(_.map(this.typeaheadAttributes,function(t){return"change:"+t}),t)>=0)&&(n=!0,this._removeFromIndex(e)),n&&this._addToIndex(e),r.__super__._onModelEvent.apply(this,arguments)},r}(Backbone.Collection)}).call(this); \ No newline at end of file diff --git a/js/components.js b/js/components.js index 3a50e876d..9232a79da 100644 --- a/js/components.js +++ b/js/components.js @@ -27216,4 +27216,288 @@ JSON.stringify(result); }; } }); -(function(){var t={}.hasOwnProperty,e=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e},n=[].slice;Backbone.TypeaheadCollection=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return e(r,t),r.prototype._tokenize=function(t){return t=$.trim(t),0===t.length?null:t.toLowerCase().split(/[\s\-_]+/)},r.prototype._deepObjectMap=function(t,e){return e.length>0&&_.isObject(t)?1===e.length?t[e[0]]:this._deepObjectMap(t[e[0]],e.slice(1,e.length)):t},r.prototype._getAttributeValues=function(t){return _.map(this.typeaheadAttributes,function(e){return function(n){var r;return r=n.split("."),e._deepObjectMap(t.get(r[0]),r.slice(1))}}(this))},r.prototype._extractValues=function(t){return null!=this.typeaheadAttributes?this._getAttributeValues(t):_.values(t.attributes)},r.prototype._tokenizeModel=function(t){return _.uniq(this._tokenize(_.flatten(this._extractValues(t)).join(" ")))},r.prototype._addToIndex=function(t){var e,n,r,i,o,u,s,a,h;for(_.isArray(t)||(t=[t]),h=[],s=0,a=t.length;a>s;s++)i=t[s],u=this._tokenizeModel(i),r=null!=i.id?i.id:i.cid,this._tokens[r]=u,h.push(function(){var t,i,s,a;for(a=[],i=0,s=u.length;s>i;i++)o=u[i],n=o.charAt(0),e=(t=this._adjacency)[n]||(t[n]=[r]),a.push(~_.indexOf(e,r)?void 0:e.push(r));return a}.call(this));return h},r.prototype._removeFromIndex=function(t){var e,r,i,o,u,s,a,h;for(_.isArray(t)||(t=[t]),r=_.map(t,function(t){return null!=t.id?t.id:t.cid}),u=0,s=r.length;s>u;u++)e=r[u],delete this._tokens[e];a=this._adjacency,h=[];for(i in a)o=a[i],h.push(this._adjacency[i]=_.without.apply(_,[o].concat(n.call(r))));return h},r.prototype._rebuildIndex=function(){return this._adjacency={},this._tokens={},this._addToIndex(this.models)},r.prototype.typeaheadIndexer=function(t){return null!=t&&_.keys(t).length>0?_.map(this.where(t),function(t){return null!=t.id?t.id:t.cid}):null},r.prototype.typeahead=function(t,e){var n,r,i,o,u,s,a,h,p,l,c,d,f;if(null==this._adjacency)throw new Error("Index is not built");if(p=this._tokenize(t),h=[],l=null,i=_(p).chain().map(function(t){return t.charAt(0)}).uniq().value(),n=function(t){return function(e){return e.length<((null!=l?l.length:void 0)||t.length)?l=e:void 0}}(this),_.all(i,function(t){return function(e){var r;return r=t._adjacency[e],null==r?!1:(h.push(r),n(r),!0)}}(this)),h.lengthd;d++)o=l[d],u=_.every(h,function(t){return~_.indexOf(t,o)}),s=u&&_.every(p,function(t){return function(e){return _.some(t._tokens[o],function(t){return 0===t.indexOf(e)})}}(this)),s&&(a=this.get(o),this.typeaheadPreserveOrder?c[this.indexOf(a)]=a:c.push(a));return this.typeaheadPreserveOrder?_.compact(c):c},r.prototype._reset=function(){return this._tokens={},this._adjacency={},r.__super__._reset.apply(this,arguments)},r.prototype.set=function(){var t;return t=r.__super__.set.apply(this,arguments),_.isArray(t)||(t=[t]),this._rebuildIndex(t),t},r.prototype.remove=function(){var t;return t=r.__super__.remove.apply(this,arguments),_.isArray(t)||(t=[t]),this._removeFromIndex(t),t},r.prototype._onModelEvent=function(t,e){var n;return n=!1,t==="change:"+e.idAttribute?(n=!0,this._removeFromIndex({id:e.previous(e.idAttribute)})):0===t.indexOf("change:")&&(null==this.typeaheadAttributes||_.indexOf(_.map(this.typeaheadAttributes,function(t){return"change:"+t}),t)>=0)&&(n=!0,this._removeFromIndex(e)),n&&this._addToIndex(e),r.__super__._onModelEvent.apply(this,arguments)},r}(Backbone.Collection)}).call(this); \ No newline at end of file +// Generated by CoffeeScript 1.8.0 +(function() { + var __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; }, + __slice = [].slice; + + Backbone.TypeaheadCollection = (function(_super) { + __extends(TypeaheadCollection, _super); + + function TypeaheadCollection() { + return TypeaheadCollection.__super__.constructor.apply(this, arguments); + } + + TypeaheadCollection.prototype._tokenize = function(s) { + s = $.trim(s); + if (s.length === 0) { + return null; + } + return s.toLowerCase().split(/[\s\-_]+/); + }; + + + /* + Recursive method for walking an object as defined by an + array. Returns the value of the last key in the array + sequence. + @private + @method _deepObjectMap + @param {Object} Object to walk + @param {Array} Keys to walk the object with + @return {Value} Last value from the object by array walk + + @example + _deepObjectMap + key: + key2: + key3: "val" + , ['key', 'key2', 'key3'] + * Returns "val" + */ + + TypeaheadCollection.prototype._deepObjectMap = function(obj, attrs) { + if (!(attrs.length > 0 && _.isObject(obj))) { + return obj; + } + if (attrs.length === 1) { + return obj[attrs[0]]; + } + return this._deepObjectMap(obj[attrs[0]], attrs.slice(1, attrs.length)); + }; + + + /* + Split each typeaheadAttribute into an array of nested methods + and return an array map the returned values from deepObjectMap. + @private + @method _getAttributeValues + @param {Backbone.Model} Model to fetch and map values from + @return {Array} Values from model retrieved by _deepObjectMap + */ + + TypeaheadCollection.prototype._getAttributeValues = function(model) { + return _.map(this.typeaheadAttributes, (function(_this) { + return function(att) { + var attArray; + attArray = att.split('.'); + return _this._deepObjectMap(model.get(attArray[0]), attArray.slice(1)); + }; + })(this)); + }; + + TypeaheadCollection.prototype._extractValues = function(model) { + if (this.typeaheadAttributes != null) { + return this._getAttributeValues(model); + } else { + return _.values(model.attributes); + } + }; + + TypeaheadCollection.prototype._tokenizeModel = function(model) { + return _.uniq(this._tokenize(_.flatten(this._extractValues(model)).join(' '))); + }; + + TypeaheadCollection.prototype._addToIndex = function(models) { + var adjacency, character, id, model, t, tokens, _i, _len, _results; + if (!_.isArray(models)) { + models = [models]; + } + _results = []; + for (_i = 0, _len = models.length; _i < _len; _i++) { + model = models[_i]; + tokens = this._tokenizeModel(model); + id = model.id != null ? model.id : model.cid; + this._tokens[id] = tokens; + _results.push((function() { + var _base, _j, _len1, _results1; + _results1 = []; + for (_j = 0, _len1 = tokens.length; _j < _len1; _j++) { + t = tokens[_j]; + character = t.charAt(0); + adjacency = (_base = this._adjacency)[character] || (_base[character] = [id]); + if (!~_.indexOf(adjacency, id)) { + _results1.push(adjacency.push(id)); + } else { + _results1.push(void 0); + } + } + return _results1; + }).call(this)); + } + return _results; + }; + + TypeaheadCollection.prototype._removeFromIndex = function(models) { + var id, ids, k, v, _i, _len, _ref, _results; + if (!_.isArray(models)) { + models = [models]; + } + ids = _.map(models, function(m) { + if (m.id != null) { + return m.id; + } else { + return m.cid; + } + }); + for (_i = 0, _len = ids.length; _i < _len; _i++) { + id = ids[_i]; + delete this._tokens[id]; + } + _ref = this._adjacency; + _results = []; + for (k in _ref) { + v = _ref[k]; + _results.push(this._adjacency[k] = _.without.apply(_, [v].concat(__slice.call(ids)))); + } + return _results; + }; + + TypeaheadCollection.prototype._rebuildIndex = function() { + this._adjacency = {}; + this._tokens = {}; + return this._addToIndex(this.models); + }; + + TypeaheadCollection.prototype.typeaheadIndexer = function(facets) { + if (!((facets != null) && _.keys(facets).length > 0)) { + return null; + } + return _.map(this.where(facets), function(m) { + if (m.id != null) { + return m.id; + } else { + return m.cid; + } + }); + }; + + TypeaheadCollection.prototype.typeahead = function(query, facets) { + var checkIfShortestList, facetList, firstChars, id, isCandidate, isMatch, item, lists, queryTokens, shortestList, suggestions, _i, _len; + if (this._adjacency == null) { + throw new Error('Index is not built'); + } + queryTokens = this._tokenize(query); + lists = []; + shortestList = null; + firstChars = _(queryTokens).chain().map(function(t) { + return t.charAt(0); + }).uniq().value(); + checkIfShortestList = (function(_this) { + return function(list) { + if (list.length < ((shortestList != null ? shortestList.length : void 0) || _this.length)) { + return shortestList = list; + } + }; + })(this); + _.all(firstChars, (function(_this) { + return function(firstChar) { + var list; + list = _this._adjacency[firstChar]; + if (list == null) { + return false; + } + lists.push(list); + checkIfShortestList(list); + return true; + }; + })(this)); + if (lists.length < firstChars.length) { + return []; + } + facetList = this.typeaheadIndexer(facets); + if (facetList != null) { + lists.push(facetList); + checkIfShortestList(facetList); + } + if (shortestList == null) { + return this.models; + } + if (shortestList.length === 0) { + return []; + } + suggestions = []; + for (_i = 0, _len = shortestList.length; _i < _len; _i++) { + id = shortestList[_i]; + isCandidate = _.every(lists, function(list) { + return ~_.indexOf(list, id); + }); + isMatch = isCandidate && _.every(queryTokens, (function(_this) { + return function(qt) { + return _.some(_this._tokens[id], function(t) { + return t.indexOf(qt) === 0; + }); + }; + })(this)); + if (isMatch) { + item = this.get(id); + if (this.typeaheadPreserveOrder) { + suggestions[this.indexOf(item)] = item; + } else { + suggestions.push(item); + } + } + } + if (this.typeaheadPreserveOrder) { + return _.compact(suggestions); + } else { + return suggestions; + } + }; + + TypeaheadCollection.prototype._reset = function() { + this._tokens = {}; + this._adjacency = {}; + return TypeaheadCollection.__super__._reset.apply(this, arguments); + }; + + TypeaheadCollection.prototype.set = function() { + var models; + models = TypeaheadCollection.__super__.set.apply(this, arguments); + if (!_.isArray(models)) { + models = [models]; + } + this._rebuildIndex(models); + return models; + }; + + TypeaheadCollection.prototype.remove = function() { + var models; + models = TypeaheadCollection.__super__.remove.apply(this, arguments); + if (!_.isArray(models)) { + models = [models]; + } + this._removeFromIndex(models); + return models; + }; + + TypeaheadCollection.prototype._onModelEvent = function(event, model, collection, options) { + var add; + add = false; + if (event === ("change:" + model.idAttribute)) { + add = true; + this._removeFromIndex({ + id: model.previous(model.idAttribute) + }); + } else if (event.indexOf('change:') === 0) { + if ((this.typeaheadAttributes == null) || _.indexOf(_.map(this.typeaheadAttributes, function(att) { + return 'change:' + att; + }), event) >= 0) { + add = true; + this._removeFromIndex(model); + } + } + if (add) { + this._addToIndex(model); + } + return TypeaheadCollection.__super__._onModelEvent.apply(this, arguments); + }; + + return TypeaheadCollection; + + })(Backbone.Collection); + +}).call(this); + +//# sourceMappingURL=backbone.typeahead.js.map