/*--------------------------------------------------------- * OpenERP Web chrome *---------------------------------------------------------*/ openerp.web.chrome = function(instance) { 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); } }); 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"); /** * The very minimal function everything should call to create a dialog * in OpenERP Web Client. */ instance.web.dialog = function(element) { var result = element.dialog.apply(element, _.rest(_.toArray(arguments))); result.dialog("widget").openerpClass(); return result; }; /** 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: - 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