Consistent use of view.$; Don't hide notification checkbox when Notification is on...
[KiwiIRC.git] / client / src / applets / settings.js
index 8e3820ced2d715f5ce64d39b2536f3cd904b1fd2..639e1a180248da2d19235f5ba22079b461d4d47c 100644 (file)
             this.$el = $(_.template($('#tmpl_applet_settings').html().trim(), text));\r
 \r
             if (!navigator.registerProtocolHandler) {\r
-                this.$el.find('.protocol_handler').remove();\r
+                this.$('.protocol_handler').remove();\r
             }\r
 \r
-            if (!window.webkitNotifications) {\r
-                this.$el.find('notification_enabler').remove();\r
+            if (!(window.Notification || window.webkitNotifications || window.mozNotification)) {\r
+                this.$('notification_enabler').remove();\r
             }\r
 \r
             // Incase any settings change while we have this open, update them\r
@@ -58,7 +58,7 @@
 \r
             $.each(_kiwi.global.settings.attributes, function(key, value) {\r
 \r
-                var $el = $('[data-setting="' + key + '"]', that.$el);\r
+                var $el = that.$('[data-setting="' + key + '"]');\r
 \r
                 // Only deal with settings we have a UI element for\r
                 if (!$el.length)\r
@@ -87,7 +87,7 @@
         saveSettings: function (event) {\r
             var value,\r
                 settings = _kiwi.global.settings,\r
-                $setting = $(event.currentTarget, this.$el);\r
+                $setting = this.$(event.currentTarget);\r
 \r
             switch (event.currentTarget.type) {\r
                 case 'checkbox':\r
         selectTheme: function(event) {\r
             event.preventDefault();\r
 \r
-            $('[data-setting="theme"].active', this.$el).removeClass('active');\r
+            this.$('[data-setting="theme"].active').removeClass('active');\r
             $(event.currentTarget).addClass('active').trigger('change');\r
         },\r
 \r
             navigator.registerProtocolHandler('ircs', document.location.origin + _kiwi.app.get('base_path') + '/%s', 'Kiwi IRC');\r
         },\r
 \r
-        enableNotifications: function(event){\r
+        enableNotifications: function(event) {\r
             event.preventDefault();\r
+            var Notify = window.Notification || window.webkitNotifications;\r
 \r
-            if ('webkitNotifications' in window) {\r
-                window.webkitNotifications.requestPermission();\r
-            } else if ('Notification' in window) {\r
-                Notification.requestPermission();\r
+            if (Notify) {\r
+                Notify.requestPermission();\r
             }\r
         }\r
 \r