5e3715fbe14fc37ab8ffe111c45282f10f565320 max Thu Jul 15 06:05:05 2021 -0700 changes after code review, refs #27846 diff --git src/hg/js/utils.js src/hg/js/utils.js index 47ddf0c..c29a20f 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -3,30 +3,31 @@ // "use strict"; // Don't complain about line break before '||' etc: /* jshint -W014 */ var debug = false; // Google Analytics helper functions to send events, see src/hg/lib/googleAnalytics.c function gaOnButtonClick(ev) { /* user clicked a button: send event to GA, then execute the old handler */ var button = ev.currentTarget; var buttonName = button.name; ga('send', 'event', 'buttonClick', buttonName); + if (button.oldOnClick) // most buttons did not have an onclick function at all (the default click is a listener) button.oldOnClick(ev); } function gaTrackButtons() { /* replace the click handler on all buttons with one the sends a GA event first, then handles the click */ if (!window.ga || ga.loaded) // When using an Adblocker, the ga object does not exist return; var buttons = document.querySelectorAll('input[type=submit],input[type=button]'); for (var i = 0; i < buttons.length; i++) { var b = buttons[i]; b.oldOnClick = b.onclick; b.onclick = gaOnButtonClick; // addEventHandler would not work here, the default click stops propagation. } } // end Google Analytics helper functions