From: Darren Date: Thu, 29 May 2014 20:52:40 +0000 (+0100) Subject: Merging the user counts element into member list view X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4ad632579a96e97a8ecef8e8c572e16534b2144a;p=KiwiIRC.git Merging the user counts element into member list view --- diff --git a/client/assets/css/style.css b/client/assets/css/style.css index 0364b19..402f9da 100644 --- a/client/assets/css/style.css +++ b/client/assets/css/style.css @@ -149,8 +149,8 @@ html, body { height:100%; } } /* The active channels nicklist */ -#kiwi .memberlists ul { display:none; } -#kiwi .memberlists ul.active { display:block; } +#kiwi .memberlists > div { display:none; } +#kiwi .memberlists > div.active { display:block; } #kiwi .memberlists ul li { overflow-y:auto; overflow-x:hidden; cursor:pointer; } #kiwi .memberlists ul li a.nick { } diff --git a/client/assets/themes/basic/style.css b/client/assets/themes/basic/style.css index 1147b5a..82f4aa7 100644 --- a/client/assets/themes/basic/style.css +++ b/client/assets/themes/basic/style.css @@ -87,18 +87,6 @@ transition: color 0.3s; color: #88C56A; } -#kiwi .membercount { - font-size: 0.9em; - margin-bottom: 10px; - padding: 0 0 5%; - text-align: center; -} -#kiwi .membercount span { - display: none; -} -#kiwi .membercount span.active { - display: block; -} #kiwi .messages { } #kiwi .messages.active { } @@ -181,6 +169,13 @@ background-color: #DADADA; border-left: 1px dashed #8A8A8A; } + +#kiwi .memberlists .meta { + font-size: 0.9em; + margin-bottom: 10px; + text-align: center; +} + #kiwi .memberlists ul { list-style: none; margin-left:2px; } #kiwi .memberlists ul.active { } #kiwi .memberlists ul li { padding:0 2px; } diff --git a/client/assets/themes/cli/style.css b/client/assets/themes/cli/style.css index cf0d810..712d40f 100644 --- a/client/assets/themes/cli/style.css +++ b/client/assets/themes/cli/style.css @@ -96,6 +96,15 @@ #kiwi .right_bar { background:#252525; } + +#kiwi .memberlists .meta { + border-bottom: 1px solid #8A8A8A; + font-size: 0.9em; + margin-bottom: 10px; + padding: 0 0 5%; + text-align: center; +} + #kiwi .memberlists ul li { padding: 0.2em 1em; } #kiwi .memberlists ul li a.nick { color:#6d6d6d; } #kiwi .memberlists ul li:hover { @@ -126,19 +135,6 @@ transition: color 0.3s; color: #88C56A; } -#kiwi .membercount { - border-bottom: 1px solid #8A8A8A; - font-size: 0.9em; - margin-bottom: 10px; - padding: 0 0 5%; - text-align: center; -} -#kiwi .membercount span { - display: none; -} -#kiwi .membercount span.active { - display: block; -} #kiwi .messages .msg > div { color:#6d6d6d; font-family: Inconsolata, Consolas, 'courier new', monospace; } #kiwi .messages .msg { border: none; padding: 2px 5px; } diff --git a/client/assets/themes/relaxed/style.css b/client/assets/themes/relaxed/style.css index 44a09d0..3918487 100644 --- a/client/assets/themes/relaxed/style.css +++ b/client/assets/themes/relaxed/style.css @@ -112,19 +112,6 @@ transition: color 0.3s; color: #88C56A; } -#kiwi .membercount { - border-bottom: 1px solid #8A8A8A; - font-size: 0.9em; - margin-bottom: 10px; - padding: 0 0 5%; - text-align: center; -} -#kiwi .membercount span { - display: none; -} -#kiwi .membercount span.active { - display: block; -} #kiwi .messages { color: #333333; } #kiwi .messages.active { } @@ -208,6 +195,15 @@ border-left: 1px solid #8A8A8A; } #kiwi.narrow .right_bar { display:none; } + +#kiwi .memberlists .meta { + border-bottom: 1px solid #8A8A8A; + font-size: 0.9em; + margin-bottom: 10px; + padding: 0 0 5%; + text-align: center; +} + #kiwi .memberlists ul { list-style: none; } #kiwi .memberlists ul.active { } #kiwi .memberlists ul li { padding: 0.2em 1em; } diff --git a/client/src/views/memberlist.js b/client/src/views/memberlist.js index a8028ed..22721b0 100644 --- a/client/src/views/memberlist.js +++ b/client/src/views/memberlist.js @@ -1,5 +1,5 @@ _kiwi.view.MemberList = Backbone.View.extend({ - tagName: "ul", + tagName: "div", events: { "click .nick": "nickClick", "click .channel_info": "channelInfoClick" @@ -7,27 +7,36 @@ _kiwi.view.MemberList = Backbone.View.extend({ initialize: function (options) { this.model.bind('all', this.render, this); - $(this.el).appendTo('#kiwi .memberlists'); + this.$el.appendTo('#kiwi .memberlists'); + + // Holds meta data. User counts, etc + this.$meta = $('
').appendTo(this.$el); + + // The list for holding the nicks + this.$list = $('').appendTo(this.$el); }, render: function () { - var $this = this.$el; - $this.empty(); - + var that = this; + + this.$list.empty(); this.model.forEach(function (member) { member.view.$el.data('member', member); - $this.append(member.view.$el); + that.$list.append(member.view.$el); }); - - // User count - if(this.model.channel.cid === _kiwi.app.panels().active.cid) { - var members_count = this.model.length + ' ' + translateText('client_applets_chanlist_users'); - $('#kiwi .membercount > span.' + this.model.channel.cid).text(members_count); - $('#kiwi .membercount > span.' + this.model.channel.cid).addClass('active'); + // User count + if(this.model.channel.isActive()) { + this.renderMeta(); } return this; }, + + renderMeta: function() { + var members_count = this.model.length + ' ' + translateText('client_applets_chanlist_users'); + this.$meta.text(members_count); + }, + nickClick: function (event) { var $target = $(event.currentTarget).parent('li'), member = $target.data('member'), @@ -85,17 +94,6 @@ _kiwi.view.MemberList = Backbone.View.extend({ $('#kiwi .memberlists').children().removeClass('active'); $(this.el).addClass('active'); - // User count - var members_count = this.model.length + ' ' + translateText('client_applets_chanlist_users'); - var members_count_code = ''; - - $('#kiwi .membercount').children().removeClass('active'); - // If the span for this panel doesn't exist, create it - if($('#kiwi .membercount > span.' + this.model.channel.cid).length == 0){ - $(members_count_code).appendTo('#kiwi .membercount'); - } - - $('#kiwi .membercount > span.' + this.model.channel.cid).text(members_count); - $('#kiwi .membercount > span.' + this.model.channel.cid).addClass('active'); + this.renderMeta(); } }); \ No newline at end of file