Text theme fixes
[KiwiIRC.git] / client / src / views / application.js
index 2f0af27d78a74b114bc9f1bb73ca88aa2ae585b9..5d6a045d09597652aeffcf7723321503bbf483eb 100644 (file)
@@ -9,7 +9,7 @@ _kiwi.view.Application = Backbone.View.extend({
 
         this.elements = {
             panels:        this.$el.find('.panels'),
-            memberlists:   this.$el.find('.memberlists'),
+            right_bar:     this.$el.find('.right_bar'),
             toolbar:       this.$el.find('.toolbar'),
             controlbox:    this.$el.find('.controlbox'),
             resize_handle: this.$el.find('.memberlists_resize_handle')
@@ -65,15 +65,23 @@ _kiwi.view.Application = Backbone.View.extend({
         }
 
         // If we have no theme specified, get it from the settings
-        if (!theme_name) theme_name = _kiwi.global.settings.get('theme');
+        if (!theme_name) theme_name = _kiwi.global.settings.get('theme') || 'relaxed';
+
+        theme_name = theme_name.toLowerCase();
 
         // Clear any current theme
-        this.$el.removeClass(function (i, css) {
-            return (css.match(/\btheme_\S+/g) || []).join(' ');
+        $('[data-theme]:not([disabled])').each(function (idx, link) {
+            var $link = $(link);
+            $link.attr('rel', 'alternate ' + $link.attr('rel')).attr('disabled', true)[0].disabled = true;
         });
 
         // Apply the new theme
-        this.$el.addClass('theme_' + (theme_name || 'relaxed'));
+        var link = $('[data-theme][title=' + theme_name + ']');
+        if (link.length > 0) {
+            link.attr('rel', 'stylesheet').attr('disabled', false)[0].disabled = false;
+        }
+
+        this.doLayout();
     },
 
 
@@ -126,7 +134,7 @@ _kiwi.view.Application = Backbone.View.extend({
     doLayout: function () {
         var el_kiwi = this.$el;
         var el_panels = this.elements.panels;
-        var el_memberlists = this.elements.memberlists;
+        var el_right_bar = this.elements.right_bar;
         var el_toolbar = this.elements.toolbar;
         var el_controlbox = this.elements.controlbox;
         var el_resize_handle = this.elements.resize_handle;
@@ -152,7 +160,7 @@ _kiwi.view.Application = Backbone.View.extend({
 
         // Apply the CSS sizes
         el_panels.css(css_heights);
-        el_memberlists.css(css_heights);
+        el_right_bar.css(css_heights);
         el_resize_handle.css(css_heights);
 
         // If we have channel tabs on the side, adjust the height
@@ -168,11 +176,11 @@ _kiwi.view.Application = Backbone.View.extend({
         }
 
         // Set the panels width depending on the memberlist visibility
-        if (el_memberlists.css('display') != 'none') {
+        if (el_right_bar.css('display') != 'none') {
             // Panels to the side of the memberlist
-            el_panels.css('right', el_memberlists.outerWidth(true));
+            el_panels.css('right', el_right_bar.outerWidth(true));
             // The resize handle sits overlapping the panels and memberlist
-            el_resize_handle.css('left', el_memberlists.position().left - (el_resize_handle.outerWidth(true) / 2));
+            el_resize_handle.css('left', el_right_bar.position().left - (el_resize_handle.outerWidth(true) / 2));
         } else {
             // Memberlist is hidden so panels to the right edge
             el_panels.css('right', 0);
@@ -192,7 +200,7 @@ _kiwi.view.Application = Backbone.View.extend({
                 var tmr;
                 var has_focus = true;
                 var state = 0;
-                var default_title = 'Kiwi IRC';
+                var default_title = _kiwi.app.server_settings.client.window_title || 'Kiwi IRC';
                 var title = 'Kiwi IRC';
 
                 this.setTitle = function (new_title) {