-
-
Save gdyrrahitis/6dd958772ee559fe0b2e55d36d39a60f to your computer and use it in GitHub Desktop.
This file contains 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
/** @hidden */ | |
function clickHook(el: IAugmentedJQuery, $state: StateService, $timeout: ITimeoutService, type: TypeInfo, getDef: () => Def) { | |
return function (e: JQueryMouseEventObject) { | |
var button = e.which || e.button, target = getDef(); | |
if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) { | |
// HACK: This is to allow ng-clicks to be processed before the transition is initiated: | |
var transition = $timeout(function () { | |
$state.go(target.uiState, target.uiStateParams, target.uiStateOpts); | |
}); | |
e.preventDefault(); | |
// if the state has no URL, ignore one preventDefault from the <a> directive. | |
var ignorePreventDefaultCount = type.isAnchor && !target.href ? 1 : 0; | |
e.preventDefault = function () { | |
if (ignorePreventDefaultCount-- <= 0) $timeout.cancel(transition); | |
}; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment