I"X(function() { var $; $ = jQuery; $(document).on("turbolinks:load", function() { var debounceIntervalMs, shiftUrl; $(".test_click").click(function(e) { e.preventDefault(); alert("Whooo let the dogs out?"); console.log("The gang!"); }); $(".open_more").click(function(e) { e.preventDefault(); $(this).next('.details').toggle(); }); $(".onclick_open_backdrop").click(function(e) { e.preventDefault(); $(this).children('.snowflake_popover').popover('show'); $('.popover_backdrop').show(); }); $(document).on("click", ".close, .popover_backdrop", function(e) { e.preventDefault(); $('.snowflake_popover').popover('hide'); $('.popover_backdrop').hide(); }); $('[data-toggle="popover"]').popover({ html: true, trigger: 'manual', content: function() { return $(this).children('.popover_content').html(); } }); debounceIntervalMs = function() { return 240; }; shiftUrl = function(url, regex, shifts) { var change, text; change = function(str, p1, p2, offset, text) { return p1 + (parseInt(p2) + parseInt(shifts)); }; text = String(url); return text.replace(regex, change); }; $("a.debounce_this").click(function(e) { var delayedPageChange, newHref, regex; e.preventDefault(); if (window.forwardShiftAmount == null) { window.forwardShiftAmount = 0; } if (window.debounceTimeout != null) { clearTimeout(window.debounceTimeout); window.forwardShiftAmount = window.forwardShiftAmount + (e.currentTarget.dataset.directionForward === 'true' ? 1 : -1); console.log(window.forwardShiftAmount); } regex = new RegExp("(" + e.currentTarget.dataset.debounceParam + "=)(-?\\d+)", "g"); delayedPageChange = function() { return location.href = newHref; }; newHref = shiftUrl(e.currentTarget.href, regex, window.forwardShiftAmount); window.debounceTimeout = setTimeout(delayedPageChange, debounceIntervalMs()); }); }); }).call(this); :ET