Last active
March 11, 2022 00:30
-
-
Save dorian-e3/1a15d0161de3a127633f8eb145136bbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add an indicator to clicked element that we're processing currently. | |
*/ | |
window.indicateInProgressClickHandler = function(handlerId,$element){ | |
let inProgressClickHandlers = ''; | |
if(typeof $element.data('in-progress-click-handlers') !== 'undefined') { | |
inProgressClickHandlers = $element.data('in-progress-click-handlers') + '|'; | |
} | |
$element.data('in-progress-click-handlers', inProgressClickHandlers + handlerId); | |
}; | |
/** | |
* Remove indicator on clicked element that we were processing. | |
*/ | |
window.indicateClickHandlerCompletion = function(handlerId,$element) { | |
let inProgressClickHandlers = $element.data('in-progress-click-handlers'); | |
inProgressClickHandlers = inProgressClickHandlers.replace('|'+handlerId,'').replace(handlerId, ''); | |
$element.data('in-progress-click-handlers', inProgressClickHandlers); | |
}; | |
/* | |
// Add an indication that we have a click handler in progress. | |
// This is to help avoid race conditions. | |
window.indicateInProgressClickHandler('informz',jQuery(this)); | |
*/ | |
/* | |
// Indicate that we've finished our click handler business | |
window.indicateClickHandlerCompletion('informz',jQuery(event.originalEvent.target)); | |
*/ | |
/* | |
// If there are no still-in-progress click handlers | |
if( | |
typeof jQuery(event.originalEvent.target).data('in-progress-click-handlers') === 'undefined' | |
|| jQuery(event.originalEvent.target).data('in-progress-click-handlers') === '' | |
) { | |
window.location = jQuery(event.originalEvent.target).attr('href'); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment