diff options
Diffstat (limited to 'addons/web/static/src/js/widgets/notification.js')
| -rw-r--r-- | addons/web/static/src/js/widgets/notification.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/addons/web/static/src/js/widgets/notification.js b/addons/web/static/src/js/widgets/notification.js new file mode 100644 index 00000000000..d99ef75b324 --- /dev/null +++ b/addons/web/static/src/js/widgets/notification.js @@ -0,0 +1,44 @@ +odoo.define('web.Notification', ['web.Widget'], function (require) { +"use strict"; + +var Widget = require('web.Widget'); + +var Notification = Widget.extend({ + template: 'Notification', + init: function() { + this._super.apply(this, arguments); + }, + start: function() { + this._super.apply(this, arguments); + this.$el.notify({ + speed: 500, + expires: 2500 + }); + }, + notify: function(title, text, sticky) { + sticky = !!sticky; + var opts = {}; + if (sticky) { + opts.expires = false; + } + return this.$el.notify('create', { + title: title, + text: text + }, opts); + }, + warn: function(title, text, sticky) { + sticky = !!sticky; + var opts = {}; + if (sticky) { + opts.expires = false; + } + return this.$el.notify('create', 'oe_notification_alert', { + title: title, + text: text + }, opts); + } +}); + +return Notification; + +}); |
