1
1
'use strict' ;
2
2
3
- var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
4
-
5
3
Object . defineProperty ( exports , "__esModule" , {
6
4
value : true
7
5
} ) ;
8
6
7
+ var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
8
+
9
9
var _react = require ( 'react' ) ;
10
10
11
11
var _react2 = _interopRequireDefault ( _react ) ;
12
12
13
+ var _propTypes = require ( 'prop-types' ) ;
14
+
13
15
function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
14
16
15
17
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
@@ -29,13 +31,13 @@ var seqGen = function seqGen() {
29
31
} ;
30
32
var seq = seqGen ( ) ;
31
33
32
- var Notification = ( function ( _React$Component ) {
34
+ var Notification = function ( _React$Component ) {
33
35
_inherits ( Notification , _React$Component ) ;
34
36
35
37
function Notification ( props ) {
36
38
_classCallCheck ( this , Notification ) ;
37
39
38
- var _this = _possibleConstructorReturn ( this , Object . getPrototypeOf ( Notification ) . call ( this , props ) ) ;
40
+ var _this = _possibleConstructorReturn ( this , ( Notification . __proto__ || Object . getPrototypeOf ( Notification ) ) . call ( this , props ) ) ;
39
41
40
42
var supported = false ;
41
43
var granted = false ;
@@ -44,8 +46,6 @@ var Notification = (function (_React$Component) {
44
46
if ( window . Notification . permission === PERMISSION_GRANTED ) {
45
47
granted = true ;
46
48
}
47
- } else {
48
- supported = false ;
49
49
}
50
50
51
51
_this . state = {
@@ -137,34 +137,32 @@ var Notification = (function (_React$Component) {
137
137
138
138
var doNotShowOnActiveWindow = this . props . disableActiveWindow && this . windowFocus ;
139
139
if ( ! this . props . ignore && this . props . title && this . state . supported && this . state . granted && ! doNotShowOnActiveWindow ) {
140
- ( function ( ) {
141
140
142
- var opt = _this3 . props . options ;
143
- if ( typeof opt . tag !== 'string' ) {
144
- opt . tag = 'web-notification-' + seq ( ) ;
145
- }
141
+ var opt = this . props . options ;
142
+ if ( typeof opt . tag !== 'string' ) {
143
+ opt . tag = 'web-notification-' + seq ( ) ;
144
+ }
146
145
147
- if ( ! _this3 . notifications [ opt . tag ] ) {
148
- var n = new window . Notification ( _this3 . props . title , opt ) ;
149
- n . onshow = function ( e ) {
150
- _this3 . props . onShow ( e , opt . tag ) ;
151
- setTimeout ( function ( ) {
152
- _this3 . close ( opt . tag ) ;
153
- } , _this3 . props . timeout ) ;
154
- } ;
155
- n . onclick = function ( e ) {
156
- _this3 . props . onClick ( e , opt . tag ) ;
157
- } ;
158
- n . onclose = function ( e ) {
159
- _this3 . props . onClose ( e , opt . tag ) ;
160
- } ;
161
- n . onerror = function ( e ) {
162
- _this3 . props . onError ( e , opt . tag ) ;
163
- } ;
164
-
165
- _this3 . notifications [ opt . tag ] = n ;
166
- }
167
- } ) ( ) ;
146
+ if ( ! this . notifications [ opt . tag ] ) {
147
+ var n = new window . Notification ( this . props . title , opt ) ;
148
+ n . onshow = function ( e ) {
149
+ _this3 . props . onShow ( e , opt . tag ) ;
150
+ setTimeout ( function ( ) {
151
+ _this3 . close ( n ) ;
152
+ } , _this3 . props . timeout ) ;
153
+ } ;
154
+ n . onclick = function ( e ) {
155
+ _this3 . props . onClick ( e , opt . tag ) ;
156
+ } ;
157
+ n . onclose = function ( e ) {
158
+ _this3 . props . onClose ( e , opt . tag ) ;
159
+ } ;
160
+ n . onerror = function ( e ) {
161
+ _this3 . props . onError ( e , opt . tag ) ;
162
+ } ;
163
+
164
+ this . notifications [ opt . tag ] = n ;
165
+ }
168
166
}
169
167
170
168
// return null cause
@@ -173,9 +171,9 @@ var Notification = (function (_React$Component) {
173
171
}
174
172
} , {
175
173
key : 'close' ,
176
- value : function close ( tag ) {
177
- if ( this . notifications [ tag ] && typeof this . notifications [ tag ] . close === 'function' ) {
178
- this . notifications [ tag ] . close ( ) ;
174
+ value : function close ( n ) {
175
+ if ( n && typeof n . close === 'function' ) {
176
+ n . close ( ) ;
179
177
}
180
178
}
181
179
@@ -189,22 +187,22 @@ var Notification = (function (_React$Component) {
189
187
} ] ) ;
190
188
191
189
return Notification ;
192
- } ) ( _react2 . default . Component ) ;
190
+ } ( _react2 . default . Component ) ;
193
191
194
192
Notification . propTypes = {
195
- ignore : _react2 . default . PropTypes . bool ,
196
- disableActiveWindow : _react2 . default . PropTypes . bool ,
197
- askAgain : _react2 . default . PropTypes . bool ,
198
- notSupported : _react2 . default . PropTypes . func ,
199
- onPermissionGranted : _react2 . default . PropTypes . func ,
200
- onPermissionDenied : _react2 . default . PropTypes . func ,
201
- onShow : _react2 . default . PropTypes . func ,
202
- onClick : _react2 . default . PropTypes . func ,
203
- onClose : _react2 . default . PropTypes . func ,
204
- onError : _react2 . default . PropTypes . func ,
205
- timeout : _react2 . default . PropTypes . number ,
206
- title : _react2 . default . PropTypes . string . isRequired ,
207
- options : _react2 . default . PropTypes . object
193
+ ignore : _propTypes . bool ,
194
+ disableActiveWindow : _propTypes . bool ,
195
+ askAgain : _propTypes . bool ,
196
+ notSupported : _propTypes . func ,
197
+ onPermissionGranted : _propTypes . func ,
198
+ onPermissionDenied : _propTypes . func ,
199
+ onShow : _propTypes . func ,
200
+ onClick : _propTypes . func ,
201
+ onClose : _propTypes . func ,
202
+ onError : _propTypes . func ,
203
+ timeout : _propTypes . number ,
204
+ title : _propTypes . string . isRequired ,
205
+ options : _propTypes . object
208
206
} ;
209
207
210
208
Notification . defaultProps = {
0 commit comments