100% width nick list on small screens
[KiwiIRC.git] / client / src / views / rightbar.js
CommitLineData
626c1246 1_kiwi.view.RightBar = Backbone.View.extend({
06d56c90
D
2 events: {
3 'click .right-bar-toggle': 'onClickToggle',
4 'click .right-bar-toggle-inner': 'onClickToggle'
5 },
6
626c1246
D
7 initialize: function() {
8 this.keep_hidden = false;
06d56c90
D
9 this.hidden = this.$el.hasClass('disabled');
10
11 this.updateIcon();
626c1246
D
12 },
13
14
15 hide: function() {
16 this.hidden = true;
17 this.$el.addClass('disabled');
06d56c90
D
18
19 this.updateIcon();
626c1246
D
20 },
21
22
23 show: function() {
24 this.hidden = false;
25
26 if (!this.keep_hidden)
27 this.$el.removeClass('disabled');
06d56c90
D
28
29 this.updateIcon();
626c1246
D
30 },
31
32
33 // Toggle if the rightbar should be shown or not
95d37c14
D
34 toggle: function(keep_hidden) {
35 // Hacky, but we need to ignore the toggle() call from doLayout() as we are overriding it
36 if (this.ignore_layout)
37 return true;
38
39 if (typeof keep_hidden === 'undefined') {
40 this.keep_hidden = !this.keep_hidden;
41 } else {
42 this.keep_hidden = keep_hidden;
43 }
626c1246
D
44
45 if (this.keep_hidden || this.hidden) {
46 this.$el.addClass('disabled');
47 } else {
48 this.$el.removeClass('disabled');
49 }
06d56c90
D
50
51 this.updateIcon();
52 },
53
54
55 updateIcon: function() {
56 var $toggle = this.$('.right-bar-toggle'),
57 $icon = $toggle.find('i');
58
59 if (!this.hidden && this.keep_hidden) {
60 $toggle.show();
61 } else {
62 $toggle.hide();
63 }
64
65 if (this.keep_hidden) {
66 $icon.removeClass('icon-double-angle-right').addClass('icon-user');
67 } else {
68 $icon.removeClass('icon-user').addClass('icon-double-angle-right');
69 }
70 },
71
72
73 onClickToggle: function(event) {
74 this.toggle();
95d37c14
D
75
76 // Hacky, but we need to ignore the toggle() call from doLayout() as we are overriding it
77 this.ignore_layout = true;
06d56c90 78 _kiwi.app.view.doLayout();
95d37c14
D
79
80 // No longer ignoring the toggle() call from doLayout()
81 delete this.ignore_layout;
626c1246
D
82 }
83});