},\r
\r
initialize: function (options) {\r
- var settings = _kiwi.global.settings;\r
-\r
this.$el = $($('#tmpl_applet_settings').html());\r
\r
- this.$el.find('.theme').val(settings.get('theme'));\r
+ // Incase any settings change while we have this open, update them\r
+ _kiwi.global.settings.on('change', this.loadSettings, this);\r
+\r
+ // Now actually show the current settings\r
+ this.loadSettings();\r
+\r
+\r
},\r
\r
- saveSettings: function () {\r
+\r
+ loadSettings: function () {\r
var settings = _kiwi.global.settings;\r
\r
- settings.set('theme', $('.theme', this.$el).val());\r
+ // TODO: Tidy this up\r
+ var theme = settings.get('theme') || 'relaxed';\r
+ this.$el.find('.setting-theme option').filter(function() {\r
+ return $(this).val() === theme;\r
+ }).attr('selected', true);\r
+\r
+ var list_style = settings.get('channel_list_style') || 'tabs';\r
+ this.$el.find('.setting-channel_list_style option').filter(function() {\r
+ return $(this).val() === list_style;\r
+ }).attr('selected', true);\r
+\r
+ this.$el.find('.setting-scrollback').val(settings.get('scrollback') || '250');\r
+\r
+ if (typeof settings.get('show_joins_parts') === 'undefined' || settings.get('show_joins_parts')) {\r
+ this.$el.find('.setting-show_joins_parts').attr('checked', true);\r
+ } else {\r
+ this.$el.find('.setting-show_joins_parts').attr('checked', false);\r
+ }\r
+\r
+ if (typeof settings.get('show_timestamps') === 'undefined' || !settings.get('show_timestamps')) {\r
+ this.$el.find('.setting-show_timestamps').attr('checked', false);\r
+ } else {\r
+ this.$el.find('.setting-show_timestamps').attr('checked', true);\r
+ }\r
+ },\r
+\r
+\r
+ saveSettings: function () {\r
+ var settings = _kiwi.global.settings,\r
+ feedback;\r
+\r
+ // Stop settings being updated while we're saving one by one\r
+ _kiwi.global.settings.off('change', this.loadSettings, this);\r
+\r
+ settings.set('theme', $('.setting-theme', this.$el).val());\r
+ settings.set('channel_list_style', $('.setting-channel_list_style', this.$el).val());\r
+ settings.set('scrollback', $('.setting-scrollback', this.$el).val());\r
+ settings.set('show_joins_parts', $('.setting-show_joins_parts', this.$el).is(':checked'));\r
+ settings.set('show_timestamps', $('.setting-show_timestamps', this.$el).is(':checked'));\r
\r
settings.save();\r
+\r
+ feedback = $('.feedback', this.$el);\r
+ feedback.fadeIn('slow', function () {\r
+ feedback.fadeOut('slow');\r
+ })\r
+\r
+ // Continue listening for setting changes\r
+ _kiwi.global.settings.on('change', this.loadSettings, this);\r
}\r
});\r
\r
\r
\r
- _kiwi.applets.Settings = Backbone.Model.extend({\r
+ var Applet = Backbone.Model.extend({\r
initialize: function () {\r
this.set('title', 'Settings');\r
this.view = new View();\r
}\r
});\r
+\r
+\r
+ _kiwi.model.Applet.register('kiwi_settings', Applet);\r
})();
\ No newline at end of file