Added rudimentary support for HTML5 notifications in webkit
authorKnut <knut@k-nut.eu>
Wed, 28 Aug 2013 10:04:21 +0000 (12:04 +0200)
committerKnut <knut@k-nut.eu>
Wed, 28 Aug 2013 10:04:21 +0000 (12:04 +0200)
client/assets/src/applets/settings.js
client/assets/src/index.html.tmpl
client/assets/src/translations/de.po
client/assets/src/translations/en-gb.po
client/assets/src/views/application.js
client/assets/src/views/panel.js

index 7b4580a2afd4ef0c25c60cb131aef12e4f12b5ab..5188edde03a74930a315d795e3be6742329e8d49 100644 (file)
@@ -3,7 +3,8 @@
         events: {\r
             'change [data-setting]': 'saveSettings',\r
             'click [data-setting="theme"]': 'selectTheme',\r
-            'click .register_protocol': 'registerProtocol'\r
+            'click .register_protocol': 'registerProtocol',\r
+           'click .enable_notifications': 'enableNoticiations'\r
         },\r
 \r
         initialize: function (options) {\r
                 default_client: _kiwi.global.i18n.translate('client_applets_settings_default_client').fetch(),\r
                 make_default: _kiwi.global.i18n.translate('client_applets_settings_default_client_enable').fetch(),\r
                 locale_restart_needed: _kiwi.global.i18n.translate('client_applets_settings_locale_restart_needed').fetch(),\r
-                default_note: _kiwi.global.i18n.translate('client_applets_settings_default_client_notice').fetch('<a href="chrome://settings/handlers">chrome://settings/handlers</a>')\r
+                default_note: _kiwi.global.i18n.translate('client_applets_settings_default_client_notice').fetch('<a href="chrome://settings/handlers">chrome://settings/handlers</a>'),\r
+               html5_notifications: _kiwi.global.i18n.translate('client_applets_settings_locale_html5_notifications').fetch(),\r
+               enable_notifications: _kiwi.global.i18n.translate('client_applets_settings_locale_enable_notifications').fetch()\r
             };\r
             this.$el = $(_.template($('#tmpl_applet_settings').html().trim(), text));\r
 \r
             if (!navigator.registerProtocolHandler) {\r
                 this.$el.find('.protocol_handler').remove();\r
             }\r
-\r
+/*\r
+           if (!window.webkitNotifications) {\r
+               this.$el.find('notification_enabler').remove();\r
+           }\r
+*/\r
             // Incase any settings change while we have this open, update them\r
             _kiwi.global.settings.on('change', this.loadSettings, this);\r
 \r
         registerProtocol: function (event) {\r
             navigator.registerProtocolHandler('irc', document.location.origin + _kiwi.app.get('base_path') + '/%s', 'Kiwi IRC');\r
             navigator.registerProtocolHandler('ircs', document.location.origin + _kiwi.app.get('base_path') + '/%s', 'Kiwi IRC');\r
-        }\r
+        },\r
+\r
+       enableNoticiations: function(event){\r
+           window.webkitNotifications.requestPermission();\r
+       }\r
+\r
     });\r
 \r
 \r
 \r
 \r
     _kiwi.model.Applet.register('kiwi_settings', Applet);\r
-})();
\ No newline at end of file
+})();\r
index 470814cb188e798eaaec57a2c86edf2864e4190b..2e149418a502db2e0f8d26e404998cf77d25c06a 100644 (file)
                     <small><%= default_note %></small>\r
                 </div>\r
             </section>\r
+\r
+           <section class="notification_enabler">\r
+                <h6><%= html5_notifications %></h6>\r
+                <div class="control-group">\r
+                    <button class="enable_notifications"><%= enable_notifications %></button>\r
+                </div>\r
+            </section>\r
+\r
         </div>\r
     </script>\r
 \r
index 77fe1d09217439c3d31ba7ed93bda3868f89cf3c..705cd10669c4c3877655e32e0eb691b8d5e29486 100755 (executable)
@@ -78,6 +78,14 @@ msgstr "Notiz: Nutzer von Chrome oder Chromium müssen ihre Einstellungen durch
 msgid "client_applets_settings_title"
 msgstr "Einstellungen"
 
+#:
+msgid "client_applets_settings_locale_html5_notifications"
+msgstr "HTML5 Benachrichtigungen"
+
+#:
+msgid "client_applets_settings_locale_enable_notifications"
+msgstr "Benachrichtigungen einschalten"
+
 #: client/assets/src/models/applet.js
 msgid "client_models_applet_unknown"
 msgstr "Unbekannte Anwendung"
index 22157543d74caadba3aac7d492d6cb81f6996ea1..828f67b36530367e94b7c147b31b456185b88d94 100755 (executable)
@@ -78,6 +78,15 @@ msgstr "Note: Chrome or Chromium browser users may need to check their settings
 msgid "client_applets_settings_title"
 msgstr "Settings"
 
+#:
+msgid "client_apllets_settings_html5_notifications"
+msgstr "HTML5 Notifications"
+
+#:
+msgid "client_apllets_settings_enable_notifications"
+msgstr "Enable notifications"
+
+
 #: client/assets/src/models/applet.js
 msgid "client_models_applet_unknown"
 msgstr "Unknown Applet"
index dcf9cfe02f71e6e59f5e2b250d896be385cb494a..e6a244c24e8f82c67b45b4da6c4fbd47878b688f 100644 (file)
@@ -285,5 +285,12 @@ _kiwi.view.Application = Backbone.View.extend({
             return;
         
         soundManager.play(sound_id);
+    },
+
+    showNotification: function(sender, message) {
+    console.log(sender, message);
+       if (window.webkitNotifications && webkitNotifications.checkPermission() === 0){
+           window.webkitNotifications.createNotification('/kiwi/assets/img/ico.png', sender, message).show();
+       }
     }
-});
\ No newline at end of file
+});
index 9d2fd338eca68017415f4f1d64ea9e6c579fe246..2d0674ac3fe9342f8e8f450e3a29139bc3d6a099 100644 (file)
@@ -136,6 +136,7 @@ _kiwi.view.Panel = Backbone.View.extend({
             _kiwi.app.view.alertWindow('* ' + _kiwi.global.i18n.translate('client_views_panel_activity').fetch());
             _kiwi.app.view.favicon.newHighlight();
             _kiwi.app.view.playSound('highlight');
+           _kiwi.app.view.showNotification(msg.nick, msg.msg);
             this.alert('highlight');
 
         } else {
@@ -312,4 +313,4 @@ _kiwi.view.Panel = Backbone.View.extend({
             this.$container[0].scrollTop = this.$container[0].scrollHeight;
         }
     }
-});
\ No newline at end of file
+});