}
});
+var opened_modal = [];
+
instance.web.action_notify = function(element, action) {
element.do_notify(action.params.title, action.params.text, action.params.sticky);
};
this.init_dialog();
}
this.$buttons.insertAfter(this.$dialog_box.find(".modal-body"));
+ $('.tooltip').remove(); //remove open tooltip if any to prevent them staying when modal is opened
+ //add to list of currently opened modal
+ opened_modal.push(this.$dialog_box);
return this;
},
_add_buttons: function(buttons) {
'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');
}
}
$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');
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) {
- this.trigger("closing", reason);
+ if (this.dialog_inited && !this.__tmp_dialog_hiding) {
+ $('.tooltip').remove(); //remove open tooltip if any to prevent them staying when modal has disappeared
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;
}
+ this.trigger("closing", reason);
}
},
_closing: function() {
//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();
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);
size: 'medium',
title: error.title,
buttons: [
- {text: _t("Ok"), click: function() { this.$el.parents('.modal').modal('hide'); }}
+ {text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }}
]
}, $('<div>').html(error.error)).open();
},
var $button = self.$el.find('.oe_form_button');
$button.appendTo(this.getParent().$buttons);
$button.eq(2).click(function(){
- self.getParent().close();
+ self.$el.parents('.modal').modal('hide');
});
$button.eq(0).click(function(){
self.rpc("/web/session/change_password",{
size: 'medium',
title: error.title,
buttons: [
- {text: _t("Ok"), click: function() { this.$el.parents('.modal').modal('hide'); }}
+ {text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }}
]
}, $('<div>').html(error.error)).open();
},
$clicked_menu.parent().addClass('active');
}
}
+ // add a tooltip to cropped menu items
this.$secondary_menus.find('.oe_secondary_submenu li a span').each(function() {
- $(this).tooltip(this.scrollWidth > this.clientWidth? {title: $(this).text().trim()} :'destroy');
+ $(this).tooltip(this.scrollWidth > this.clientWidth ? {title: $(this).text().trim(), placement: 'auto right'} :'destroy');
});
},
/**
this.update_promise = this.update_promise.then(fct, fct);
},
on_menu_help: function() {
- window.open('http://help.openerp.com', '_blank');
+ window.open('http://help.odoo.com', '_blank');
},
on_menu_logout: function() {
this.trigger('user_logout');
state: JSON.stringify(state),
scope: 'userinfo',
};
- instance.web.redirect('https://accounts.openerp.com/oauth2/auth?'+$.param(params));
+ instance.web.redirect('https://accounts.odoo.com/oauth2/auth?'+$.param(params));
+ }).fail(function(result, ev){
+ ev.preventDefault();
+ instance.web.redirect('https://accounts.odoo.com/web');
});
}
},
}, 0);
});
instance.web.bus.on('click', this, function(ev) {
- $.fn.tooltip('destroy');
+ $('.tooltip').remove();
if (!$(ev.target).is('input[type=file]')) {
self.$el.find('.oe_dropdown_menu.oe_opened, .oe_dropdown_toggle.oe_opened').removeClass('oe_opened');
}