/*--------------------------------------------------------- * OpenERP Web chrome *---------------------------------------------------------*/ (function() { var instance = openerp; openerp.web.chrome = {}; var QWeb = instance.web.qweb, _t = instance.web._t; instance.web.Notification = instance.web.Widget.extend({ template: 'Notification', init: function() { this._super.apply(this, arguments); instance.web.notification = this; }, 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); } }); var opened_modal = []; instance.web.action_notify = function(element, action) { element.do_notify(action.params.title, action.params.text, action.params.sticky); }; instance.web.client_actions.add("action_notify", "instance.web.action_notify"); instance.web.action_warn = function(element, action) { element.do_warn(action.params.title, action.params.text, action.params.sticky); }; instance.web.client_actions.add("action_warn", "instance.web.action_warn"); /** A useful class to handle dialogs. Attributes: - $buttons: A jQuery element targeting a dom part where buttons can be added. It always exists during the lifecycle of the dialog. */ instance.web.Dialog = instance.web.Widget.extend({ dialog_title: "", /** Constructor. @param {Widget} parent @param {dictionary} options A dictionary that will be forwarded to jQueryUI Dialog. Additionaly, that dictionary can contain the following keys: - size: one of the following: 'large', 'medium', 'small' - dialogClass: class to add to the body of dialog - buttons: Deprecated. The buttons key is not propagated to jQueryUI Dialog. It must be a dictionary (key = button label, value = click handler) or a list of dictionaries (each element in the dictionary is send to the corresponding method of a jQuery element targeting the