Skip to content

Commit 0c1cc0c

Browse files
committed
build
1 parent 84a74d9 commit 0c1cc0c

File tree

1 file changed

+47
-49
lines changed

1 file changed

+47
-49
lines changed

lib/components/Notification.js

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
'use strict';
22

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-
53
Object.defineProperty(exports, "__esModule", {
64
value: true
75
});
86

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+
99
var _react = require('react');
1010

1111
var _react2 = _interopRequireDefault(_react);
1212

13+
var _propTypes = require('prop-types');
14+
1315
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1416

1517
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() {
2931
};
3032
var seq = seqGen();
3133

32-
var Notification = (function (_React$Component) {
34+
var Notification = function (_React$Component) {
3335
_inherits(Notification, _React$Component);
3436

3537
function Notification(props) {
3638
_classCallCheck(this, Notification);
3739

38-
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Notification).call(this, props));
40+
var _this = _possibleConstructorReturn(this, (Notification.__proto__ || Object.getPrototypeOf(Notification)).call(this, props));
3941

4042
var supported = false;
4143
var granted = false;
@@ -44,8 +46,6 @@ var Notification = (function (_React$Component) {
4446
if (window.Notification.permission === PERMISSION_GRANTED) {
4547
granted = true;
4648
}
47-
} else {
48-
supported = false;
4949
}
5050

5151
_this.state = {
@@ -137,34 +137,32 @@ var Notification = (function (_React$Component) {
137137

138138
var doNotShowOnActiveWindow = this.props.disableActiveWindow && this.windowFocus;
139139
if (!this.props.ignore && this.props.title && this.state.supported && this.state.granted && !doNotShowOnActiveWindow) {
140-
(function () {
141140

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+
}
146145

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+
}
168166
}
169167

170168
// return null cause
@@ -173,9 +171,9 @@ var Notification = (function (_React$Component) {
173171
}
174172
}, {
175173
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();
179177
}
180178
}
181179

@@ -189,22 +187,22 @@ var Notification = (function (_React$Component) {
189187
}]);
190188

191189
return Notification;
192-
})(_react2.default.Component);
190+
}(_react2.default.Component);
193191

194192
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
208206
};
209207

210208
Notification.defaultProps = {

0 commit comments

Comments
 (0)