[IMP] Added callbacks to null object generator.

bzr revid: nicolas.vanhoren@openerp.com-20110524163420-tju2e4a06htfzbzt
This commit is contained in:
niv-openerp
2011-05-24 18:34:20 +02:00
parent 15e208d9ee
commit ba308938c4
2 changed files with 27 additions and 23 deletions
+26 -23
View File
@@ -152,29 +152,6 @@ openerp.base.Registry = Class.extend( /** @lends openerp.base.Registry# */ {
}
});
/**
* Generates an inherited class that replaces all the methods by null methods (methods
* that does nothing and always return undefined).
*
* @param {Class} claz
* @param {dict} add Additional functions to override.
* @return {Class}
*/
openerp.base.generate_null_object_class = function(claz, add) {
var newer = {};
var copy_proto = function(prototype) {
for (var name in prototype) {
if(typeof prototype[name] == "function") {
newer[name] = function() {};
}
}
if (prototype.prototype)
copy_proto(prototype.prototype);
}
copy_proto(claz.prototype);
return claz.extend(_.extend({}, newer, add || {}));
}
openerp.base.BasicController = Class.extend( /** @lends openerp.base.BasicController# */{
/**
* rpc operations, event binding and callback calling should be done in
@@ -254,6 +231,32 @@ openerp.base.BasicController = Class.extend( /** @lends openerp.base.BasicContro
}
});
/**
* Generates an inherited class that replaces all the methods by null methods (methods
* that does nothing and always return undefined).
*
* @param {Class} claz
* @param {dict} add Additional functions to override.
* @return {Class}
*/
openerp.base.generate_null_object_class = function(claz, add) {
var newer = {};
var copy_proto = function(prototype) {
for (var name in prototype) {
if(typeof prototype[name] == "function") {
newer[name] = function() {};
}
}
if (prototype.prototype)
copy_proto(prototype.prototype);
}
copy_proto(claz.prototype);
var init = openerp.base.BasicController.prototype.init;
newer.init = init;
var tmpclass = claz.extend(newer);
return tmpclass.extend(add || {});
}
openerp.base.Notification = openerp.base.BasicController.extend({
init: function(element_id) {
this._super(element_id);
+1
View File
@@ -201,6 +201,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
openerp.base.NullViewManager = openerp.base.generate_null_object_class(openerp.base.ViewManager, {
init: function() {
this._super();
this.action = {flags: {}};
this.sidebar = new openerp.base.NullSidebar();
}