Merge pull request #739 from kddlb/windows-toasts
Enhancements for a hypothetical Windows app
This commit is contained in:
commit
311205029f
1 changed files with 23 additions and 0 deletions
|
@ -45,7 +45,28 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
tag: 'gb-highlight-vib'
|
tag: 'gb-highlight-vib'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else if (typeof Windows !== 'undefined' && typeof Windows.UI !== 'undefined' && typeof Windows.UI.Notifications !== 'undefined') {
|
||||||
|
|
||||||
|
var winNotifications = Windows.UI.Notifications;
|
||||||
|
var toastNotifier = winNotifications.ToastNotificationManager.createToastNotifier();
|
||||||
|
var template = winNotifications.ToastTemplateType.toastText02;
|
||||||
|
var toastXml = winNotifications.ToastNotificationManager.getTemplateContent(template);
|
||||||
|
var toastTextElements = toastXml.getElementsByTagName("text");
|
||||||
|
|
||||||
|
toastTextElements[0].appendChild(toastXml.createTextNode(title));
|
||||||
|
toastTextElements[1].appendChild(toastXml.createTextNode(body));
|
||||||
|
|
||||||
|
var toast = new winNotifications.ToastNotification(toastXml);
|
||||||
|
|
||||||
|
toast.onactivated = function() {
|
||||||
|
models.setActiveBuffer(buffer.id);
|
||||||
|
window.focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
toastNotifier.show(toast);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var notification = new Notification(title, {
|
var notification = new Notification(title, {
|
||||||
body: body,
|
body: body,
|
||||||
icon: 'assets/img/favicon.png'
|
icon: 'assets/img/favicon.png'
|
||||||
|
@ -74,7 +95,9 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
notification.onclose = function() {
|
notification.onclose = function() {
|
||||||
delete notifications[this.id];
|
delete notifications[this.id];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue