Skip to content

Instantly share code, notes, and snippets.

@DrMartiner
Created November 27, 2013 10:54
Show Gist options
  • Save DrMartiner/7673870 to your computer and use it in GitHub Desktop.
Save DrMartiner/7673870 to your computer and use it in GitHub Desktop.
Directive for idle timer
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'
}
<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