diff options
| author | Josse Colpaert <jco@odoo.com> | 2014-05-30 10:37:26 +0200 |
|---|---|---|
| committer | Josse Colpaert <jco@odoo.com> | 2014-05-30 10:37:26 +0200 |
| commit | 45dc3db6cc6bc7f5c4774e8b61fc873df1e667c8 (patch) | |
| tree | c0d8a87fb33f6c6e97373e08244ed9c2cd0f743b /addons/web/static/src | |
| parent | 231278997e0ab3670726030b6bdbea6febb8c724 (diff) | |
| parent | ad58b17e6eb5ba7d3c92992695703ad0f5ba1353 (diff) | |
Merge branch 'master-wmssecurity3-jco' into master-wmsstaging-jco
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 2620e4ed40f..1ea14ee8c81 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -46,6 +46,8 @@ instance.web.Notification = instance.web.Widget.extend({ } }); +var opened_modal = []; + instance.web.action_notify = function(element, action) { element.do_notify(action.params.title, action.params.text, action.params.sticky); }; @@ -113,6 +115,8 @@ instance.web.Dialog = instance.web.Widget.extend({ this.init_dialog(); } this.$buttons.insertAfter(this.$dialog_box.find(".modal-body")); + //add to list of currently opened modal + opened_modal.push(this.$dialog_box); return this; }, _add_buttons: function(buttons) { @@ -152,7 +156,7 @@ instance.web.Dialog = instance.web.Widget.extend({ 'keyboard': true, }); if (options.size !== 'large'){ - var dialog_class_size = this.$dialog_box.find('.modal-lg').removeClass('modal-lg') + var dialog_class_size = this.$dialog_box.find('.modal-lg').removeClass('modal-lg'); if (options.size === 'small'){ dialog_class_size.addClass('modal-sm'); } @@ -165,7 +169,7 @@ instance.web.Dialog = instance.web.Widget.extend({ } $dialog_content.openerpClass(); - this.$dialog_box.on('hidden.bs.modal', this, function(){ + this.$dialog_box.on('hidden.bs.modal', this, function() { self.close(); }); this.$dialog_box.modal('show'); @@ -175,13 +179,15 @@ instance.web.Dialog = instance.web.Widget.extend({ return res; }, /** - Closes the popup, if destroy_on_close was passed to the constructor, it is also destroyed. + Closes (hide) the popup, if destroy_on_close was passed to the constructor, it will be destroyed instead. */ close: function(reason) { - if (this.dialog_inited) { + if (this.dialog_inited && !this.__tmp_dialog_hiding) { this.trigger("closing", reason); if (this.$el.is(":data(bs.modal)")) { // may have been destroyed by closing signal - this.$el.parents('.modal').modal('hide'); + this.__tmp_dialog_hiding = true; + this.$dialog_box.modal('hide'); + this.__tmp_dialog_hiding = undefined; } } }, @@ -212,9 +218,17 @@ instance.web.Dialog = instance.web.Widget.extend({ //we need this to put the instruction to remove modal from DOM at the end //of the queue, otherwise it might already have been removed before the modal-backdrop //is removed when pressing escape key - var $parent = this.$el.parents('.modal'); + var $element = this.$dialog_box; setTimeout(function () { - $parent.remove(); + //remove modal from list of opened modal since we just destroy it + var modal_list_index = $.inArray($element, opened_modal); + if (modal_list_index > -1){ + opened_modal.splice(modal_list_index,1)[0].remove(); + } + if (opened_modal.length > 0){ + //we still have other opened modal so we should focus it + opened_modal[opened_modal.length-1].focus(); + } },0); } this._super(); @@ -239,8 +253,7 @@ instance.web.CrashManager = instance.web.Class.extend({ this.show_warning({type: "Session Expired", data: { message: _t("Your OpenERP session expired. Please refresh the current web page.") }}); return; } - if (error.data.exception_type === "except_osv" || error.data.exception_type === "warning" - || error.data.exception_type === "access_error") { + if (error.data.exception_type === "except_osv" || error.data.exception_type === "warning" || error.data.exception_type === "access_error") { this.show_warning(error); } else { this.show_error(error); |
