Extracting the right_bar into its own view with toggling logic
authorDarren <darren@darrenwhitlen.com>
Mon, 21 Apr 2014 14:47:52 +0000 (15:47 +0100)
committerDarren <darren@darrenwhitlen.com>
Mon, 21 Apr 2014 14:47:52 +0000 (15:47 +0100)
client/build.js
client/src/models/application.js
client/src/views/application.js
client/src/views/apptoolbar.js
client/src/views/panel.js
client/src/views/rightbar.js [new file with mode: 0644]
server/settingsgenerator.js

index 7b41a1c99392bed77106b6acb0aabac97617ada6..261d1e1fe269cff51fba029ac9e1388472515450 100644 (file)
@@ -79,6 +79,7 @@ var source_files = [
     __dirname + '/src/views/userbox.js',\r
     __dirname + '/src/views/channeltools.js',\r
     __dirname + '/src/views/channelinfo.js',\r
+    __dirname + 'src/views/rightbar.js',\r
 \r
     __dirname + '/src/applets/settings.js',\r
     __dirname + '/src/applets/chanlist.js',\r
index 443b38fb2b10535cfd67a0aeeb228bf263dc68d4..60b5207a72624fea7cf3177dab37c95961c807cd 100644 (file)
@@ -88,6 +88,7 @@
              */\r
             this.controlbox = new _kiwi.view.ControlBox({el: $('#kiwi .controlbox')[0]});\r
             this.bindControllboxCommands(this.controlbox);\r
+            this.rightbar = new _kiwi.view.RightBar({el: this.view.$('.right_bar')[0]});\r
 \r
             this.topicbar = new _kiwi.view.TopicBar({el: this.view.$el.find('.topic')[0]});\r
 \r
index 5d6a045d09597652aeffcf7723321503bbf483eb..b4522bc9df653c6b431d06f4e9ac535897620f19 100644 (file)
@@ -176,7 +176,7 @@ _kiwi.view.Application = Backbone.View.extend({
         }
 
         // Set the panels width depending on the memberlist visibility
-        if (el_right_bar.css('display') != 'none') {
+        if (!el_right_bar.hasClass('disabled')) {
             // Panels to the side of the memberlist
             el_panels.css('right', el_right_bar.outerWidth(true));
             // The resize handle sits overlapping the panels and memberlist
index e69b069fcb4cf22126fd51738cc93db8e52fa442..82b496527c1695d3c9b2e5564f3e338e3cfcb4a3 100644 (file)
@@ -25,7 +25,7 @@ _kiwi.view.AppToolbar = Backbone.View.extend({
     clickHideRightBar: function (event) {
         event.preventDefault();
 
-        _kiwi.app.view.$('.right_bar').toggleClass('disabled');
+        _kiwi.app.rightbar.toggle();
         _kiwi.app.view.doLayout();
     }
 });
index c22d6f07e155e4620669031c0dce93a56fedd33c..4b641a04bc79d8eaa18728a44599c588bdc541c1 100644 (file)
@@ -41,11 +41,10 @@ _kiwi.view.Panel = Backbone.View.extend({
         // Show this panels memberlist
         var members = this.model.get("members");
         if (members) {
-            $('#kiwi .right_bar').removeClass('disabled');
+            _kiwi.app.rightbar.show();
             members.view.show();
         } else {
-            // Memberlist not found for this panel, hide any active ones
-            $('#kiwi .right_bar').addClass('disabled').children().removeClass('active');
+            _kiwi.app.rightbar.hide();
         }
 
         // Remove any alerts and activity counters for this panel
diff --git a/client/src/views/rightbar.js b/client/src/views/rightbar.js
new file mode 100644 (file)
index 0000000..67c5c2f
--- /dev/null
@@ -0,0 +1,32 @@
+_kiwi.view.RightBar = Backbone.View.extend({
+    initialize: function() {
+        this.keep_hidden = false;
+        this.hidden = false;
+    },
+
+
+    hide: function() {
+        this.hidden = true;
+        this.$el.addClass('disabled');
+    },
+
+
+    show: function() {
+        this.hidden = false;
+
+        if (!this.keep_hidden)
+            this.$el.removeClass('disabled');
+    },
+
+
+    // Toggle if the rightbar should be shown or not
+    toggle: function() {
+        this.keep_hidden = !this.keep_hidden;
+
+        if (this.keep_hidden || this.hidden) {
+            this.$el.addClass('disabled');
+        } else {
+            this.$el.removeClass('disabled');
+        }
+    }
+});
\ No newline at end of file
index ffb108708a67fbdcf1c47a2d9dc793d3bcc8316a..0a3463f9ce96f389cf439381690d19e89feec7ac 100644 (file)
@@ -244,7 +244,8 @@ function addScripts(vars, debug) {
             'src/views/topicbar.js',
             'src/views/userbox.js',
             'src/views/channeltools.js',
-            'src/views/channelinfo.js'
+            'src/views/channelinfo.js',
+            'src/views/rightbar.js'
         ],
         [
             'src/applets/settings.js',