Skip to content

Skip display of loading animation when CMD, CTRL, or SHIFT is pressed (CO-2488) #41

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions app/templates/element/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,16 @@

// Add loading animation when a form is submitted, when any item with a "spin" class is clicked,
// or on any button or anchor tag lacking the .nospin class.
$("input[type='submit'], button:not(.nospin), a:not(.nospin), .spin").click(function() {
$("input[type='submit'], button:not(.nospin), a:not(.nospin), .spin").click(function(e) {

displaySpinner();
// Start a spinner only if CTRL, CMD, or SHIFT is not pressed (which loads a new tab or window).
if(!(e.ctrlKey || e.metaKey || e.shiftKey)) {
displaySpinner();

// Test for invalid fields (HTML5) and turn off spinner explicitly if found
if(document.querySelectorAll(":invalid").length) {
stopSpinner();
// Test for invalid fields (HTML5) and turn off spinner explicitly if found
if (document.querySelectorAll(":invalid").length) {
stopSpinner();
}
}

});
Expand Down