[eGroupWare-svn] r56008 - /trunk/egroupware/api/js/jsapi/egw_notification.js

[email protected] Wed, 04 May 2016 13:04:56 -0000
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: hnategh
Date: Wed May  4 15:04:55 2016
New Revision: 56008

URL: http://svn.stylite.de/viewvc/egroupware?rev=56008&view=rev
Log:
Check Notification API is supported by browser before using it

Modified:
    trunk/egroupware/api/js/jsapi/egw_notification.js

Modified: trunk/egroupware/api/js/jsapi/egw_notification.js
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/js/jsapi/egw_notification.js?rev=56008&r1=56007&r2=56008&view=diff
==============================================================================
--- trunk/egroupware/api/js/jsapi/egw_notification.js (original)
+++ trunk/egroupware/api/js/jsapi/egw_notification.js Wed May  4 15:04:55 2016
@@ -19,14 +19,20 @@
  * @augments Class
  * @param {string} _app application name object is instanciated for
  * @param {object} _wnd window object is instanciated for
+ *
+ * @return {object} defined functions of module
  */
 egw.extend('notification', egw.MODULE_WND_LOCAL, function(_app, _wnd)
 {
 	"use strict";
 
 	// Notification permission, the default value is 'default' which is equivalent to 'denied'
-	var permission = Notification.permission || 'default';
-
+	var permission = 'default';
+	
+	if (typeof Notification != 'undefined')
+	{
+		permission = Notification.permission;
+	}
 
 	return {
 
@@ -45,10 +51,12 @@
 		 *			onclose: // Callback function dispateches on notification close
 		 *			onerror: // Callback function dispatches on error, default is a egw.debug log
 		 *		}
-		 *	@return {boolean} true if the permission is granted otherwise false
+		 *	@return {boolean} false if Notification is not supported by browser
 		 */
 		notification: function (_title, _options)
 		{
+			// Check if the notification is supported by  browser
+			if (typeof Notification == 'undefined') return false;
 
 			var self = this;
 			// Check and ask for permission


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z