Skip to content

Commit 7a27ded

Browse files
committed
Trigger deviceChange event on window. Closes #5.
1 parent 1e9cf41 commit 7a27ded

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

categorizr.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
, isBrowser = context != null && context == context.window
1111
, isNode = !isBrowser
1212
, is$ = isBrowser && context.$
13+
, eventEmitter = (function () {
14+
var e
15+
if (is$) e = context.$('').trigger
16+
return e
17+
}())
1318
, docElement = isNode ? null : document.documentElement
1419

1520
, deviceTypes = 'Tv Desktop Tablet Mobile'.split(' ')
@@ -95,6 +100,9 @@
95100
function _update () {
96101
_setDeviceBooleans()
97102
_setClassName()
103+
104+
// trigger deviceChange event
105+
if (eventEmitter) context.$(context).trigger('deviceChange', [{ type: device }])
98106
}
99107

100108
// init

categorizr.min.js

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

src/categorizr.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
, isBrowser = context != null && context == context.window
99
, isNode = !isBrowser
1010
, is$ = isBrowser && context.$
11+
, eventEmitter = (function () {
12+
var e
13+
if (is$) e = context.$('').trigger
14+
return e
15+
}())
1116
, docElement = isNode ? null : document.documentElement
1217

1318
, deviceTypes = 'Tv Desktop Tablet Mobile'.split(' ')
@@ -93,6 +98,9 @@
9398
function _update () {
9499
_setDeviceBooleans()
95100
_setClassName()
101+
102+
// trigger deviceChange event
103+
if (eventEmitter) context.$(context).trigger('deviceChange', [{ type: device }])
96104
}
97105

98106
// init

test/buster.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var config = module.exports
33

44

55
// Functional tests
6+
/*
67
78
config['browser.functional'] = {
89
rootPath: '../'
@@ -29,12 +30,10 @@ config['node.user-agents'] = {
2930
, tests: [ 'test/node.user-agents.js' ]
3031
}
3132
32-
/*
3333
*/
3434

3535

3636
// External Library Integration
37-
/*
3837

3938
config['integration.ender'] = {
4039
rootPath: '../'
@@ -43,6 +42,7 @@ config['integration.ender'] = {
4342
, tests: [ 'test/integration.ender.js' ]
4443
}
4544

45+
/*
4646
config['integration.jquery'] = {
4747
rootPath: '../'
4848
, environment: 'browser'

0 commit comments

Comments
 (0)