Created
November 27, 2013 10:54
-
-
Save DrMartiner/7673870 to your computer and use it in GitHub Desktop.
Directive for idle timer
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
angular.module('app') | |
.directive 'idle', () -> | |
return { | |
restrict: 'E' | |
scope: | |
waitTime: '@ngIdleWaitTime' | |
afterRedirect: '&ngAfterRedirect' | |
link: (scope, element, attrs) -> | |
idleTimer = null | |
idleState = false | |
$(document).bind 'mousemove keydown scroll', () -> | |
clearTimeout idleTimer # отменяем прежний временной отрезок | |
idleState = false | |
idleTimer = setTimeout () -> | |
idleState = true | |
scope.afterRedirect() | |
, scope.waitTime | |
$('body').trigger 'mousemove' | |
} |
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
<idle ng-idle-wait-time="300000" ng-after-redirect="afterIdleRedirect()" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment