[imp] switched to nivjs
bzr revid: nicolas.vanhoren@openerp.com-20120223161041-mymbna11fsp3bo9m
This commit is contained in:
parent
2b73fb4a6a
commit
fa510462f4
|
@ -36,6 +36,7 @@
|
||||||
"static/lib/underscore/underscore.string.js",
|
"static/lib/underscore/underscore.string.js",
|
||||||
"static/lib/labjs/LAB.src.js",
|
"static/lib/labjs/LAB.src.js",
|
||||||
"static/lib/py.parse/lib/py.js",
|
"static/lib/py.parse/lib/py.js",
|
||||||
|
"static/lib/nivjs/src/niv.js",
|
||||||
"static/src/js/boot.js",
|
"static/src/js/boot.js",
|
||||||
"static/src/js/core.js",
|
"static/src/js/core.js",
|
||||||
"static/src/js/dates.js",
|
"static/src/js/dates.js",
|
||||||
|
|
|
@ -24,105 +24,109 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
niv = (function() {
|
niv = (function() {
|
||||||
var niv = {};
|
var lib = {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple JavaScript Inheritance By John Resig http://ejohn.org/ MIT
|
* Simple JavaScript Inheritance By John Resig http://ejohn.org/ MIT
|
||||||
* Licensed.
|
* Licensed.
|
||||||
*/
|
*/
|
||||||
// Inspired by base2 and Prototype
|
// Inspired by base2 and Prototype
|
||||||
(function(){
|
(function() {
|
||||||
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
var initializing = false, fnTest = /xyz/.test(function() {
|
||||||
// The base Class implementation (does nothing)
|
xyz;
|
||||||
this.Class = function(){};
|
}) ? /\b_super\b/ : /.*/;
|
||||||
|
// The base Class implementation (does nothing)
|
||||||
// Create a new Class that inherits from this class
|
this.Class = function() {
|
||||||
this.Class.extend = function(prop) {
|
};
|
||||||
var _super = this.prototype;
|
|
||||||
|
|
||||||
// Instantiate a base class (but only create the instance,
|
|
||||||
// don't run the init constructor)
|
|
||||||
initializing = true;
|
|
||||||
var prototype = new this();
|
|
||||||
initializing = false;
|
|
||||||
|
|
||||||
// Copy the properties over onto the new prototype
|
|
||||||
for (var name in prop) {
|
|
||||||
// Check if we're overwriting an existing function
|
|
||||||
prototype[name] = typeof prop[name] == "function" &&
|
|
||||||
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
|
||||||
(function(name, fn){
|
|
||||||
return function() {
|
|
||||||
var tmp = this._super;
|
|
||||||
|
|
||||||
// Add a new ._super() method that is the same method
|
|
||||||
// but on the super-class
|
|
||||||
this._super = _super[name];
|
|
||||||
|
|
||||||
// The method only need to be bound temporarily, so we
|
|
||||||
// remove it when we're done executing
|
|
||||||
var ret = fn.apply(this, arguments);
|
|
||||||
this._super = tmp;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
})(name, prop[name]) :
|
|
||||||
prop[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
// The dummy class constructor
|
|
||||||
function Class() {
|
|
||||||
// All construction is actually done in the init method
|
|
||||||
if ( !initializing && this.init )
|
|
||||||
this.init.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate our constructed prototype object
|
|
||||||
Class.prototype = prototype;
|
|
||||||
|
|
||||||
// Enforce the constructor to be what we expect
|
|
||||||
Class.prototype.constructor = Class;
|
|
||||||
|
|
||||||
// And make this class extendable
|
// Create a new Class that inherits from this class
|
||||||
Class.extend = arguments.callee;
|
this.Class.extend = function(prop) {
|
||||||
|
var _super = this.prototype;
|
||||||
return Class;
|
|
||||||
};
|
|
||||||
}).call(niv);
|
|
||||||
|
|
||||||
niv.ParentedMixin = {
|
|
||||||
__parented_mixin: true,
|
|
||||||
setParent: function(parent) {
|
|
||||||
if(this.getParent()) {
|
|
||||||
if (this.getParent().__parented_mixin) {
|
|
||||||
this.getParent().__parented_children = _.without(this.getParent().getChildren(), this);
|
|
||||||
}
|
|
||||||
this.__parented_parent = undefined;
|
|
||||||
}
|
|
||||||
this.__parented_parent = parent;
|
|
||||||
if(parent && parent.__parented_mixin) {
|
|
||||||
if (!parent.getChildren())
|
|
||||||
parent.__parented_children = [];
|
|
||||||
parent.getChildren().push(this);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getParent: function() {
|
|
||||||
return this.__parented_parent;
|
|
||||||
},
|
|
||||||
getChildren: function() {
|
|
||||||
return this.__parented_children ? _.clone(this.__parented_children) : [];
|
|
||||||
},
|
|
||||||
isDestroyed: function() {
|
|
||||||
return this.__parented_stopped;
|
|
||||||
},
|
|
||||||
destroy: function() {
|
|
||||||
_.each(this.getChildren(), function(el) {
|
|
||||||
el.destroy();
|
|
||||||
});
|
|
||||||
this.setParent(undefined);
|
|
||||||
this.__parented_stopped = true;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return niv;
|
// Instantiate a base class (but only create the instance,
|
||||||
|
// don't run the init constructor)
|
||||||
|
initializing = true;
|
||||||
|
var prototype = new this();
|
||||||
|
initializing = false;
|
||||||
|
|
||||||
|
// Copy the properties over onto the new prototype
|
||||||
|
for ( var name in prop) {
|
||||||
|
// Check if we're overwriting an existing function
|
||||||
|
prototype[name] = typeof prop[name] == "function"
|
||||||
|
&& typeof _super[name] == "function"
|
||||||
|
&& fnTest.test(prop[name]) ? (function(name, fn) {
|
||||||
|
return function() {
|
||||||
|
var tmp = this._super;
|
||||||
|
|
||||||
|
// Add a new ._super() method that is the same method
|
||||||
|
// but on the super-class
|
||||||
|
this._super = _super[name];
|
||||||
|
|
||||||
|
// The method only need to be bound temporarily, so we
|
||||||
|
// remove it when we're done executing
|
||||||
|
var ret = fn.apply(this, arguments);
|
||||||
|
this._super = tmp;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
})(name, prop[name]) : prop[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
// The dummy class constructor
|
||||||
|
function Class() {
|
||||||
|
// All construction is actually done in the init method
|
||||||
|
if (!initializing && this.init)
|
||||||
|
this.init.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate our constructed prototype object
|
||||||
|
Class.prototype = prototype;
|
||||||
|
|
||||||
|
// Enforce the constructor to be what we expect
|
||||||
|
Class.prototype.constructor = Class;
|
||||||
|
|
||||||
|
// And make this class extendable
|
||||||
|
Class.extend = arguments.callee;
|
||||||
|
|
||||||
|
return Class;
|
||||||
|
};
|
||||||
|
}).call(lib);
|
||||||
|
|
||||||
|
lib.ParentedMixin = {
|
||||||
|
__parented_mixin : true,
|
||||||
|
setParent : function(parent) {
|
||||||
|
if (this.getParent()) {
|
||||||
|
if (this.getParent().__parented_mixin) {
|
||||||
|
this.getParent().__parented_children = _.without(this
|
||||||
|
.getParent().getChildren(), this);
|
||||||
|
}
|
||||||
|
this.__parented_parent = undefined;
|
||||||
|
}
|
||||||
|
this.__parented_parent = parent;
|
||||||
|
if (parent && parent.__parented_mixin) {
|
||||||
|
if (!parent.__parented_children)
|
||||||
|
parent.__parented_children = [];
|
||||||
|
parent.__parented_children.push(this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getParent : function() {
|
||||||
|
return this.__parented_parent;
|
||||||
|
},
|
||||||
|
getChildren : function() {
|
||||||
|
return this.__parented_children ? _.clone(this.__parented_children)
|
||||||
|
: [];
|
||||||
|
},
|
||||||
|
isDestroyed : function() {
|
||||||
|
return this.__parented_destroyed;
|
||||||
|
},
|
||||||
|
destroy : function() {
|
||||||
|
_.each(this.getChildren(), function(el) {
|
||||||
|
el.destroy();
|
||||||
|
});
|
||||||
|
this.setParent(undefined);
|
||||||
|
this.__parented_destroyed = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return lib;
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -925,40 +925,6 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
openerp.web.ParentedMixin = {
|
|
||||||
__parented_mixin: true,
|
|
||||||
setParent: function(parent) {
|
|
||||||
if(this.getParent()) {
|
|
||||||
if (this.getParent().__parented_mixin) {
|
|
||||||
this.getParent().__parented_children = _.without(this.getParent().getChildren(), this);
|
|
||||||
}
|
|
||||||
this.__parented_parent = undefined;
|
|
||||||
}
|
|
||||||
this.__parented_parent = parent;
|
|
||||||
if(parent && parent.__parented_mixin) {
|
|
||||||
if (!parent.__parented_children)
|
|
||||||
parent.__parented_children = [];
|
|
||||||
parent.__parented_children.push(this);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getParent: function() {
|
|
||||||
return this.__parented_parent;
|
|
||||||
},
|
|
||||||
getChildren: function() {
|
|
||||||
return this.__parented_children ? _.clone(this.__parented_children) : [];
|
|
||||||
},
|
|
||||||
isDestroyed: function() {
|
|
||||||
return this.__parented_destroyed;
|
|
||||||
},
|
|
||||||
destroy: function() {
|
|
||||||
_.each(this.getChildren(), function(el) {
|
|
||||||
el.destroy();
|
|
||||||
});
|
|
||||||
this.setParent(undefined);
|
|
||||||
this.__parented_destroyed = true;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all visual components. Provides a lot of functionalities helpful
|
* Base class for all visual components. Provides a lot of functionalities helpful
|
||||||
* for the management of a part of the DOM.
|
* for the management of a part of the DOM.
|
||||||
|
@ -1007,7 +973,7 @@ openerp.web.ParentedMixin = {
|
||||||
*
|
*
|
||||||
* That will kill the widget in a clean way and erase its content from the dom.
|
* That will kill the widget in a clean way and erase its content from the dom.
|
||||||
*/
|
*/
|
||||||
openerp.web.Widget = openerp.web.CallbackEnabled.extend(openerp.web.ParentedMixin).extend(/** @lends openerp.web.Widget# */{
|
openerp.web.Widget = openerp.web.CallbackEnabled.extend(niv.ParentedMixin).extend(/** @lends openerp.web.Widget# */{
|
||||||
/**
|
/**
|
||||||
* The name of the QWeb template that will be used for rendering. Must be
|
* The name of the QWeb template that will be used for rendering. Must be
|
||||||
* redefined in subclasses or the default render() method can not be used.
|
* redefined in subclasses or the default render() method can not be used.
|
||||||
|
|
Loading…
Reference in New Issue