UNPKG

ng2-idle

Version:

A module for responding to idle users in Angular2 applications.

2 lines 12.4 kB
System.registerDynamic("ng2-idle/module",["@angular/core","ng2-idle/idle","ng2-idle/idleexpiry","ng2-idle/simpleexpiry"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=this&&this.__decorate||function(a,b,c,d){var e,f=arguments.length,g=f<3?b:null===d?d=Object.getOwnPropertyDescriptor(b,c):d;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)g=Reflect.decorate(a,b,c,d);else for(var h=a.length-1;h>=0;h--)(e=a[h])&&(g=(f<3?e(g):f>3?e(b,c,g):e(b,c))||g);return f>3&&g&&Object.defineProperty(b,c,g),g},g=this&&this.__metadata||function(a,b){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(a,b)},h=a("@angular/core"),i=a("ng2-idle/idle"),j=a("ng2-idle/idleexpiry"),k=a("ng2-idle/simpleexpiry"),l=function(){function a(){}return a.forRoot=function(){return{ngModule:a,providers:[k.SimpleExpiry,{provide:j.IdleExpiry,useExisting:k.SimpleExpiry},i.Idle]}},a=f([h.NgModule(),g("design:paramtypes",[])],a)}();return b.Ng2IdleModule=l,d.define=e,c.exports}),System.registerDynamic("ng2-idle/simpleexpiry",["ng2-idle/idleexpiry"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},g=a("ng2-idle/idleexpiry"),h=function(a){function b(){a.call(this),this.lastValue=null}return f(b,a),b.prototype.last=function(a){return void 0!==a&&(this.lastValue=a),this.lastValue},b}(g.IdleExpiry);return b.SimpleExpiry=h,d.define=e,c.exports}),System.registerDynamic("ng2-idle/windowinterruptsource",["ng2-idle/eventtargetinterruptsource"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},g=a("ng2-idle/eventtargetinterruptsource"),h=function(a){function b(b,c){void 0===c&&(c=500),a.call(this,window,b,c)}return f(b,a),b}(g.EventTargetInterruptSource);return b.WindowInterruptSource=h,d.define=e,c.exports}),System.registerDynamic("ng2-idle/keepalivesvc",[],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=function(){function a(){}return a}();return b.KeepaliveSvc=f,d.define=e,c.exports}),System.registerDynamic("ng2-idle/interrupt",[],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=function(){function a(a){this.source=a}return a.prototype.subscribe=function(a){this.sub=this.source.onInterrupt.subscribe(a)},a.prototype.unsubscribe=function(){this.sub.unsubscribe(),this.sub=null},a.prototype.resume=function(){this.source.attach()},a.prototype.pause=function(){this.source.detach()},a}();return b.Interrupt=f,d.define=e,c.exports}),System.registerDynamic("ng2-idle/idleexpiry",[],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=function(){function a(){this.idValue=new Date}return a.prototype.id=function(a){if(void 0!==a){if(!a)throw new Error("A value must be specified for the ID.");this.idValue=a}return this.idValue},a.prototype.now=function(){return new Date},a.prototype.isExpired=function(){var a=this.last();return null!=a&&a<=this.now()},a}();return b.IdleExpiry=f,d.define=e,c.exports}),System.registerDynamic("ng2-idle/idle",["@angular/core","ng2-idle/idleexpiry","ng2-idle/interrupt","ng2-idle/keepalivesvc"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=this&&this.__decorate||function(a,b,c,d){var e,f=arguments.length,g=f<3?b:null===d?d=Object.getOwnPropertyDescriptor(b,c):d;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)g=Reflect.decorate(a,b,c,d);else for(var h=a.length-1;h>=0;h--)(e=a[h])&&(g=(f<3?e(g):f>3?e(b,c,g):e(b,c))||g);return f>3&&g&&Object.defineProperty(b,c,g),g},g=this&&this.__metadata||function(a,b){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(a,b)},h=this&&this.__param||function(a,b){return function(c,d){b(c,d,a)}},i=a("@angular/core"),j=a("ng2-idle/idleexpiry"),k=a("ng2-idle/interrupt"),l=a("ng2-idle/keepalivesvc");!function(a){a[a.disabled=0]="disabled",a[a.idle=1]="idle",a[a.notIdle=2]="notIdle"}(b.AutoResume||(b.AutoResume={}));var m=b.AutoResume,n=function(){function a(a,b){this.expiry=a,this.idle=1200,this.timeoutVal=30,this.autoResume=m.idle,this.interrupts=new Array,this.running=!1,this.idling=!1,this.keepaliveEnabled=!1,this.onIdleStart=new i.EventEmitter,this.onIdleEnd=new i.EventEmitter,this.onTimeoutWarning=new i.EventEmitter,this.onTimeout=new i.EventEmitter,this.onInterrupt=new i.EventEmitter,b&&(this.keepaliveSvc=b,this.keepaliveEnabled=!0)}return a.prototype.getKeepaliveEnabled=function(){return this.keepaliveEnabled},a.prototype.setKeepaliveEnabled=function(a){if(!this.keepaliveSvc)throw new Error("Cannot enable keepalive integration because no KeepaliveSvc has been provided.");return this.keepaliveEnabled=a},a.prototype.getTimeout=function(){return this.timeoutVal},a.prototype.setTimeout=function(a){if(a===!1)this.timeoutVal=0;else{if(!("number"==typeof a&&a>=0))throw new Error("'seconds' can only be 'false' or a positive number.");this.timeoutVal=a}return this.timeoutVal},a.prototype.getIdle=function(){return this.idle},a.prototype.setIdle=function(a){if(a<=0)throw new Error("'seconds' must be greater zero");return this.idle=a},a.prototype.getAutoResume=function(){return this.autoResume},a.prototype.setAutoResume=function(a){return this.autoResume=a},a.prototype.setInterrupts=function(a){this.clearInterrupts();for(var b=this,c=0,d=a;c<d.length;c++){var e=d[c],f=new k.Interrupt(e);f.subscribe(function(a){b.interrupt(a.force,a.innerArgs)}),this.interrupts.push(f)}return this.interrupts},a.prototype.getInterrupts=function(){return this.interrupts},a.prototype.clearInterrupts=function(){for(var a=0,b=this.interrupts;a<b.length;a++){var c=b[a];c.pause(),c.unsubscribe()}this.interrupts.length=0},a.prototype.isRunning=function(){return this.running},a.prototype.isIdling=function(){return this.idling},a.prototype.watch=function(a){var b=this;this.safeClearInterval("idleHandle"),this.safeClearInterval("timeoutHandle");var c=this.timeoutVal?this.timeoutVal:0;if(!a){var d=new Date(this.expiry.now().getTime()+1e3*(this.idle+c));this.expiry.last(d)}this.idling&&this.toggleState(),this.running||(this.startKeepalive(),this.toggleInterrupts(!0)),this.running=!0,this.idleHandle=setInterval(function(){b.toggleState()},1e3*this.idle)},a.prototype.stop=function(){this.stopKeepalive(),this.toggleInterrupts(!1),this.safeClearInterval("idleHandle"),this.safeClearInterval("timeoutHandle"),this.idling=!1,this.running=!1,this.expiry.last(null)},a.prototype.timeout=function(){this.stopKeepalive(),this.toggleInterrupts(!1),this.safeClearInterval("idleHandle"),this.safeClearInterval("timeoutHandle"),this.idling=!0,this.running=!1,this.countdown=0,this.onTimeout.emit(null)},a.prototype.interrupt=function(a,b){if(this.running){if(this.timeoutVal&&this.expiry.isExpired())return void this.timeout();this.onInterrupt.emit(b),(a===!0||this.autoResume===m.idle||this.autoResume===m.notIdle&&!this.idling)&&this.watch(a)}},a.prototype.toggleState=function(){var a=this;this.idling=!this.idling,this.idling?(this.onIdleStart.emit(null),this.stopKeepalive(),this.timeoutVal>0&&(this.countdown=this.timeoutVal,this.doCountdown(),this.timeoutHandle=setInterval(function(){a.doCountdown()},1e3))):(this.toggleInterrupts(!0),this.onIdleEnd.emit(null),this.startKeepalive()),this.safeClearInterval("idleHandle")},a.prototype.toggleInterrupts=function(a){for(var b=0,c=this.interrupts;b<c.length;b++){var d=c[b];a?d.resume():d.pause()}},a.prototype.doCountdown=function(){if(this.idling){if(this.countdown<=0)return void this.timeout();this.onTimeoutWarning.emit(this.countdown),this.countdown--}},a.prototype.safeClearInterval=function(a){this[a]&&(clearInterval(this[a]),this[a]=null)},a.prototype.startKeepalive=function(){this.keepaliveSvc&&this.keepaliveEnabled&&(this.running&&this.keepaliveSvc.ping(),this.keepaliveSvc.start())},a.prototype.stopKeepalive=function(){this.keepaliveSvc&&this.keepaliveEnabled&&this.keepaliveSvc.stop()},a.prototype.ngOnDestroy=function(){this.stop(),this.clearInterrupts()},a=f([i.Injectable(),h(1,i.Optional()),g("design:paramtypes",[j.IdleExpiry,l.KeepaliveSvc])],a)}();return b.Idle=n,d.define=e,c.exports}),System.registerDynamic("ng2-idle/interruptsource",["@angular/core"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=a("@angular/core"),g=function(){function a(a,b){this.attachFn=a,this.detachFn=b,this.isAttached=!1,this.onInterrupt=new f.EventEmitter}return a.prototype.attach=function(){!this.isAttached&&this.attachFn&&this.attachFn(this),this.isAttached=!0},a.prototype.detach=function(){this.isAttached&&this.detachFn&&this.detachFn(this),this.isAttached=!1},a}();return b.InterruptSource=g,d.define=e,c.exports}),System.registerDynamic("ng2-idle/interruptargs",[],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=function(){function a(a,b,c){void 0===c&&(c=!1),this.source=a,this.innerArgs=b,this.force=c}return a}();return b.InterruptArgs=f,d.define=e,c.exports}),System.registerDynamic("ng2-idle/eventtargetinterruptsource",["rxjs/Rx","ng2-idle/interruptargs","ng2-idle/interruptsource"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},g=a("rxjs/Rx"),h=a("ng2-idle/interruptargs"),i=a("ng2-idle/interruptsource"),j=function(a){function b(b,c,d){var e=this;void 0===d&&(d=500),a.call(this,null,null),this.target=b,this.events=c,this.throttleDelay=d,this.eventSrc=new Array,this.eventSubscription=new Array;var f=this;c.split(" ").forEach(function(a){var c=g.Observable.fromEvent(b,a);f.throttleDelay>0&&(c=c.throttleTime(f.throttleDelay)),f.eventSrc.push(c)});var i=function(a){if(!f.filterEvent(a)){var b=new h.InterruptArgs(this,a);f.onInterrupt.emit(b)}};this.attachFn=function(){e.eventSrc.forEach(function(a){f.eventSubscription.push(a.subscribe(i))})},this.detachFn=function(){e.eventSubscription.forEach(function(a){a.unsubscribe()}),e.eventSubscription.length=0}}return f(b,a),b.prototype.filterEvent=function(a){return!1},b}(i.InterruptSource);return b.EventTargetInterruptSource=j,d.define=e,c.exports}),System.registerDynamic("ng2-idle/documentinterruptsource",["ng2-idle/eventtargetinterruptsource"],!0,function(a,b,c){"use strict";var d=this,e=d.define;d.define=void 0;var f=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},g=a("ng2-idle/eventtargetinterruptsource"),h=function(a){function b(b,c){void 0===c&&(c=500),a.call(this,document.documentElement,b,c)}return f(b,a),b.prototype.filterEvent=function(a){return!("mousemove"!==a.type||!(a.originalEvent&&0===a.originalEvent.movementX&&0===a.originalEvent.movementY||void 0!==a.movementX&&!a.movementX)&&a.movementY)},b}(g.EventTargetInterruptSource);return b.DocumentInterruptSource=h,d.define=e,c.exports}),System.registerDynamic("ng2-idle/index",["ng2-idle/documentinterruptsource","ng2-idle/idle","ng2-idle/interruptargs","ng2-idle/interruptsource","ng2-idle/eventtargetinterruptsource","ng2-idle/windowinterruptsource","ng2-idle/keepalivesvc","ng2-idle/idleexpiry","ng2-idle/simpleexpiry","ng2-idle/module"],!0,function(a,b,c){"use strict";function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}var e=this,f=e.define;e.define=void 0;var g=a("ng2-idle/documentinterruptsource");d(a("ng2-idle/idle")),d(a("ng2-idle/interruptargs")),d(a("ng2-idle/interruptsource")),d(a("ng2-idle/eventtargetinterruptsource")),d(a("ng2-idle/documentinterruptsource")),d(a("ng2-idle/windowinterruptsource")),d(a("ng2-idle/keepalivesvc")),d(a("ng2-idle/idleexpiry")),d(a("ng2-idle/simpleexpiry")),b.DEFAULT_INTERRUPTSOURCES=[new g.DocumentInterruptSource("mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove scroll")];var h=a("ng2-idle/module");return b.Ng2IdleModule=h.Ng2IdleModule,e.define=f,c.exports}); //# sourceMappingURL=ng2-idle.min.js.map