Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 3e1bcc0

Browse files
committed
Merge branch 'release/1.2.1'
2 parents ac5f51d + 6d440e8 commit 3e1bcc0

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

angular-idle.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*** Directives and services for responding to idle users in AngularJS
22
* @author Mike Grabski <me@mikegrabski.com>
3-
* @version v1.2.0
3+
* @version v1.2.1
44
* @link https://github.com/HackedByChinese/ng-idle.git
55
* @license MIT
66
*/
@@ -151,9 +151,10 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
151151

152152
function toggleState() {
153153
state.idling = !state.idling;
154-
var name = state.idling ? 'Start' : 'End';
154+
var name = state.idling ? 'IdleStart' : 'IdleEnd';
155155

156156
if (state.idling) {
157+
$rootScope.$broadcast(name);
157158
stopKeepalive();
158159
if (options.timeout) {
159160
state.countdown = options.timeout;
@@ -162,10 +163,9 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
162163
}
163164
} else {
164165
startKeepalive();
166+
$rootScope.$broadcast(name);
165167
}
166168

167-
$rootScope.$broadcast('Idle' + name);
168-
169169
$interval.cancel(state.idle);
170170
}
171171

angular-idle.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

angular-idle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-idle",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"homepage": "https://github.com/HackedByChinese/ng-idle",
55
"description": "Responding to idle users in AngularJS",
66
"main": "angular-idle.js",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-idle",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Directives and services for responding to idle users in AngularJS",
55
"keywords": [
66
"angularjs",
@@ -12,7 +12,7 @@
1212
"user",
1313
"session"
1414
],
15-
"main": "angular-idle.js",
15+
"main": "index.js",
1616
"scripts": {
1717
"test": "grunt test"
1818
},

src/idle/idle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
7171

7272
function toggleState() {
7373
state.idling = !state.idling;
74-
var name = state.idling ? 'Start' : 'End';
74+
var name = state.idling ? 'IdleStart' : 'IdleEnd';
7575

7676
if (state.idling) {
77+
$rootScope.$broadcast(name);
7778
stopKeepalive();
7879
if (options.timeout) {
7980
state.countdown = options.timeout;
@@ -82,10 +83,9 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
8283
}
8384
} else {
8485
startKeepalive();
86+
$rootScope.$broadcast(name);
8587
}
8688

87-
$rootScope.$broadcast('Idle' + name);
88-
8989
$interval.cancel(state.idle);
9090
}
9191

src/idle/idle.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,18 @@ describe('ngIdle', function() {
257257
expect(Keepalive.stop).toHaveBeenCalled();
258258
});
259259

260+
it('should broadcast IdleStart then IdleWarn', function() {
261+
spyOn($rootScope, '$broadcast');
262+
263+
Idle.watch();
264+
265+
$interval.flush(DEFAULTIDLEDURATION);
266+
$rootScope.$digest();
267+
268+
expect($rootScope.$broadcast).toHaveBeenCalledWith('IdleStart');
269+
expect($rootScope.$broadcast.mostRecentCall.args[0]).toBe('IdleWarn');
270+
});
271+
260272
it('should broadcast IdleEnd, start keepalive and ping', function() {
261273
spyOn($rootScope, '$broadcast');
262274

0 commit comments

Comments
 (0)