summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@openerp.com>2011-10-13 17:03:17 +0200
committerChristophe Simonis <chs@openerp.com>2011-10-13 17:03:17 +0200
commitde5c2f58e81fefb2f5d23124f5b44ee00ec16da1 (patch)
tree1f9efbc90ceffd0a1537325772af76d5555dae5a /addons/web/static/src
parent00b269d1c0a3507a01a296587e96bcb9e8e6da86 (diff)
[IMP] Notification Widget is now a singleton
bzr revid: chs@openerp.com-20111013150317-kzy2h7bz407kiugz
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js37
-rw-r--r--addons/web/static/src/js/core.js12
2 files changed, 15 insertions, 34 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 2b35fae540f..1629dc1de55 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -8,6 +8,11 @@ openerp.web.Notification = openerp.web.Widget.extend(/** @lends openerp.web.Not
template: 'Notification',
identifier_prefix: 'notification-',
+ init: function() {
+ this._super.apply(this, arguments);
+ openerp.notification = this;
+ },
+
start: function() {
this._super.apply(this, arguments);
this.$element.notify({
@@ -29,35 +34,21 @@ openerp.web.Notification = openerp.web.Widget.extend(/** @lends openerp.web.Not
expires: false,
});
},
-
- do_notify: function() { this.notify.apply(this, arguments); },
- do_warn: function() {this.warn.apply(this, arguments); },
});
-openerp.web.NotifiableWidget = openerp.web.Widget.extend({
-
- init: function(/*arguments*/) {
- this._super.apply(this, arguments);
- this.notification = new openerp.web.Notification(this);
+openerp.web.Widget.include({
+ do_notify: function() {
+ var n = openerp.notification;
+ n.notify.apply(n, arguments);
},
-
- start: function() {
- this._super.apply(this, arguments);
- this.notification.prependTo(this.$element);
- },
-
- stop: function() {
- this.notification.stop();
- return this._super.apply(this, arguments);
+ do_warn: function() {
+ var n = openerp.notification;
+ n.warn.apply(n, arguments);
},
-
- do_notify: function() { this.notification.notify.apply(this.notification, arguments); },
- do_warn: function() { this.notification.warn.apply(this.notification, arguments); },
});
-
openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# */{
dialog_title: "",
identifier_prefix: 'dialog',
@@ -945,7 +936,7 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{
}
});
-openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.web.WebClient */{
+openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClient */{
/**
* @constructs openerp.web.WebClient
* @extends openerp.web.Widget
@@ -963,6 +954,7 @@ openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.w
}
this.$element.html(QWeb.render("Interface", params));
+ this.notification = new openerp.web.Notification();
this.session = new openerp.web.Session();
this.loading = new openerp.web.Loading(this,"oe_loading");
this.crashmanager = new openerp.web.CrashManager(this);
@@ -988,6 +980,7 @@ openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.w
},
start: function() {
this._super.apply(this, arguments);
+ this.notification.prependTo(this.$element);
this.header.appendTo($("#oe_header"));
this.session.start();
this.login.appendTo($('#oe_login'));
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index bed5f199157..755413c1aea 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -949,18 +949,6 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg
}
return false;
},
- do_notify: function() {
- if (this.widget_parent) {
- return this.widget_parent.do_notify.apply(this,arguments);
- }
- return false;
- },
- do_warn: function() {
- if (this.widget_parent) {
- return this.widget_parent.do_warn.apply(this,arguments);
- }
- return false;
- },
rpc: function(url, data, success, error) {
var def = $.Deferred().then(success, error);
var self = this;