Merge "Prevent infinite 'Loading' spinner when using mouse"

This commit is contained in:
Jenkins 2015-06-29 17:25:29 +00:00 committed by Gerrit Code Review
commit 4933517709
1 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,9 @@
horizon.addInitFunction(function() {
var allPanelGroupBodies = $('.nav_accordion > dd > div > ul');
// In case the event was generated by clicking any mouse button,
// the normalized codes are matched according to http://api.jquery.com/event.which/
var MOUSE_LBUTTON_CODE_NORMALIZED = 1;
var MOUSE_WHEEL_CODE_NORMALIZED = 2;
// mark the active panel group
var activePanel = $('.nav_accordion > dd > div > ul > li > a.active');
@ -76,8 +80,14 @@ horizon.addInitFunction(function() {
});
// panel selection
$('.nav_accordion > dd > div > ul > li > a').click(function() {
horizon.modals.modal_spinner(gettext("Loading"));
$('.nav_accordion > dd > div > ul > li > a').click(function(ev) {
// NOTE(tsufiev): prevent infinite 'Loading' spinner when opening link
// in the other browser tab with mouse wheel or mouse lbutton + modifier
if ( ev.which !== MOUSE_WHEEL_CODE_NORMALIZED &&
!( ev.which === MOUSE_LBUTTON_CODE_NORMALIZED &&
( ev.shiftKey || ev.ctrlKey ) ) ) {
horizon.modals.modal_spinner(gettext("Loading"));
}
});
});