[IMP] alias backbone to ensure searchview doesn't care about POS stomping an old-as-shit backbone on top of the more recent one bundled with core

bzr revid: xmo@openerp.com-20120427154614-otxpbsc9lio9azko
This commit is contained in:
Xavier Morel 2012-04-27 17:46:14 +02:00
parent 15cf79717f
commit 24e104fcbe
1 changed files with 10 additions and 9 deletions

View File

@ -9,18 +9,19 @@ _.mixin({
/** @namespace */ /** @namespace */
var my = instance.web.search = {}; var my = instance.web.search = {};
my.FacetValue = Backbone.Model.extend({ var B = Backbone;
my.FacetValue = B.Model.extend({
}); });
my.FacetValues = Backbone.Collection.extend({ my.FacetValues = B.Collection.extend({
model: my.FacetValue model: my.FacetValue
}); });
my.Facet = Backbone.Model.extend({ my.Facet = B.Model.extend({
initialize: function (attrs) { initialize: function (attrs) {
var values = attrs.values; var values = attrs.values;
delete attrs.values; delete attrs.values;
Backbone.Model.prototype.initialize.apply(this, arguments); B.Model.prototype.initialize.apply(this, arguments);
this.values = new my.FacetValues(values || []); this.values = new my.FacetValues(values || []);
this.values.on('add remove change reset', function () { this.values.on('add remove change reset', function () {
@ -29,13 +30,13 @@ my.Facet = Backbone.Model.extend({
}, },
get: function (key) { get: function (key) {
if (key !== 'values') { if (key !== 'values') {
return Backbone.Model.prototype.get.call(this, key); return B.Model.prototype.get.call(this, key);
} }
return this.values.toJSON(); return this.values.toJSON();
}, },
set: function (key, value) { set: function (key, value) {
if (key !== 'values') { if (key !== 'values') {
return Backbone.Model.prototype.set.call(this, key, value); return B.Model.prototype.set.call(this, key, value);
} }
this.values.reset(value); this.values.reset(value);
}, },
@ -52,10 +53,10 @@ my.Facet = Backbone.Model.extend({
return out; return out;
} }
}); });
my.SearchQuery = Backbone.Collection.extend({ my.SearchQuery = B.Collection.extend({
model: my.Facet, model: my.Facet,
initialize: function () { initialize: function () {
Backbone.Collection.prototype.initialize.apply( B.Collection.prototype.initialize.apply(
this, arguments); this, arguments);
this.on('change', function (facet) { this.on('change', function (facet) {
if(!facet.values.isEmpty()) { return; } if(!facet.values.isEmpty()) { return; }
@ -79,7 +80,7 @@ my.SearchQuery = Backbone.Collection.extend({
previous.values.add(model.get('values')); previous.values.add(model.get('values'));
return; return;
} }
Backbone.Collection.prototype.add.call(this, model, options); B.Collection.prototype.add.call(this, model, options);
}, this); }, this);
return this; return this;
}, },