Merge pull request #2001 from imachug/build-all
Build wrapper all.js to support web notifications
This commit is contained in:
commit
3f3e73455b
1 changed files with 17 additions and 39 deletions
|
@ -961,7 +961,7 @@ $.extend( $.easing,
|
||||||
this.address = null;
|
this.address = null;
|
||||||
this.opener_tested = false;
|
this.opener_tested = false;
|
||||||
this.announcer_line = null;
|
this.announcer_line = null;
|
||||||
this.push_notifications = {};
|
this.web_notifications = {};
|
||||||
this.allowed_event_constructors = [window.MouseEvent, window.KeyboardEvent, window.PointerEvent];
|
this.allowed_event_constructors = [window.MouseEvent, window.KeyboardEvent, window.PointerEvent];
|
||||||
window.onload = this.onPageLoad;
|
window.onload = this.onPageLoad;
|
||||||
window.onhashchange = (function(_this) {
|
window.onhashchange = (function(_this) {
|
||||||
|
@ -1164,10 +1164,10 @@ $.extend( $.easing,
|
||||||
return this.actionPermissionAdd(message);
|
return this.actionPermissionAdd(message);
|
||||||
} else if (cmd === "wrapperRequestFullscreen") {
|
} else if (cmd === "wrapperRequestFullscreen") {
|
||||||
return this.actionRequestFullscreen();
|
return this.actionRequestFullscreen();
|
||||||
} else if (cmd === "wrapperPushNotification") {
|
} else if (cmd === "wrapperWebNotification") {
|
||||||
return this.actionPushNotification(message);
|
return this.actionWebNotification(message);
|
||||||
} else if (cmd === "wrapperClosePushNotification") {
|
} else if (cmd === "wrapperCloseWebNotification") {
|
||||||
return this.actionClosePushNotification(message);
|
return this.actionCloseWebNotification(message);
|
||||||
} else {
|
} else {
|
||||||
if (message.id < 1000000) {
|
if (message.id < 1000000) {
|
||||||
if (message.cmd === "fileWrite" && !this.modified_panel_updater_timer && (typeof site_info !== "undefined" && site_info !== null ? (ref = site_info.settings) != null ? ref.own : void 0 : void 0)) {
|
if (message.cmd === "fileWrite" && !this.modified_panel_updater_timer && (typeof site_info !== "undefined" && site_info !== null ? (ref = site_info.settings) != null ? ref.own : void 0 : void 0)) {
|
||||||
|
@ -1236,26 +1236,15 @@ $.extend( $.easing,
|
||||||
return request_fullscreen.call(elem);
|
return request_fullscreen.call(elem);
|
||||||
};
|
};
|
||||||
|
|
||||||
Wrapper.prototype.actionPushNotification = function(message) {
|
Wrapper.prototype.actionWebNotification = function(message) {
|
||||||
return $.when(this.event_site_info).done((function(_this) {
|
return $.when(this.event_site_info).done((function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
var res;
|
var res;
|
||||||
if (indexOf.call(_this.site_info.settings.permissions, "PushNotifications") < 0) {
|
|
||||||
res = {
|
|
||||||
"error": "No PushNotifications permission"
|
|
||||||
};
|
|
||||||
_this.sendInner({
|
|
||||||
"cmd": "response",
|
|
||||||
"to": message.id,
|
|
||||||
"result": res
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Notification.permission === "granted") {
|
if (Notification.permission === "granted") {
|
||||||
return _this.displayPushNotification(message);
|
return _this.displayWebNotification(message);
|
||||||
} else if (Notification.permission === "denied") {
|
} else if (Notification.permission === "denied") {
|
||||||
res = {
|
res = {
|
||||||
"error": "Push notifications are disabled by the user"
|
"error": "Web notifications are disabled by the user"
|
||||||
};
|
};
|
||||||
return _this.sendInner({
|
return _this.sendInner({
|
||||||
"cmd": "response",
|
"cmd": "response",
|
||||||
|
@ -1265,7 +1254,7 @@ $.extend( $.easing,
|
||||||
} else {
|
} else {
|
||||||
return Notification.requestPermission().then(function(permission) {
|
return Notification.requestPermission().then(function(permission) {
|
||||||
if (permission === "granted") {
|
if (permission === "granted") {
|
||||||
return _this.displayPushNotification(message);
|
return _this.displayWebNotification(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1273,34 +1262,23 @@ $.extend( $.easing,
|
||||||
})(this));
|
})(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
Wrapper.prototype.actionClosePushNotification = function(message) {
|
Wrapper.prototype.actionCloseWebNotification = function(message) {
|
||||||
return $.when(this.event_site_info).done((function(_this) {
|
return $.when(this.event_site_info).done((function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
var id, res;
|
var id;
|
||||||
if (indexOf.call(_this.site_info.settings.permissions, "PushNotifications") < 0) {
|
|
||||||
res = {
|
|
||||||
"error": "No PushNotifications permission"
|
|
||||||
};
|
|
||||||
_this.sendInner({
|
|
||||||
"cmd": "response",
|
|
||||||
"to": message.id,
|
|
||||||
"result": res
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
id = message.params[0];
|
id = message.params[0];
|
||||||
return _this.push_notifications[id].close();
|
return _this.web_notifications[id].close();
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
Wrapper.prototype.displayPushNotification = function(message) {
|
Wrapper.prototype.displayWebNotification = function(message) {
|
||||||
var id, notification, options, title;
|
var id, notification, options, title;
|
||||||
title = message.params[0];
|
title = message.params[0];
|
||||||
id = message.params[1];
|
id = message.params[1];
|
||||||
options = message.params[2];
|
options = message.params[2];
|
||||||
notification = new Notification(title, options);
|
notification = new Notification(title, options);
|
||||||
this.push_notifications[id] = notification;
|
this.web_notifications[id] = notification;
|
||||||
notification.onshow = (function(_this) {
|
notification.onshow = (function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
return _this.sendInner({
|
return _this.sendInner({
|
||||||
|
@ -1316,7 +1294,7 @@ $.extend( $.easing,
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
return _this.sendInner({
|
return _this.sendInner({
|
||||||
"cmd": "pushNotificationClick",
|
"cmd": "webNotificationClick",
|
||||||
"params": {
|
"params": {
|
||||||
"id": id
|
"id": id
|
||||||
}
|
}
|
||||||
|
@ -1326,12 +1304,12 @@ $.extend( $.easing,
|
||||||
return notification.onclose = (function(_this) {
|
return notification.onclose = (function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
_this.sendInner({
|
_this.sendInner({
|
||||||
"cmd": "pushNotificationClose",
|
"cmd": "webNotificationClose",
|
||||||
"params": {
|
"params": {
|
||||||
"id": id
|
"id": id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return delete _this.push_notifications[id];
|
return delete _this.web_notifications[id];
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue