From a39c19625ee4aac9b6090b75d65264feee25fe09 Mon Sep 17 00:00:00 2001 From: Cory Chaplin Date: Tue, 20 May 2014 13:23:02 +0200 Subject: [PATCH] Channels user counter --- client/assets/themes/basic/style.css | 12 ++++++++++++ client/assets/themes/cli/style.css | 13 +++++++++++++ client/assets/themes/relaxed/style.css | 13 +++++++++++++ client/src/index.html.tmpl | 1 + client/src/views/memberlist.js | 23 +++++++++++++++++++++++ 5 files changed, 62 insertions(+) diff --git a/client/assets/themes/basic/style.css b/client/assets/themes/basic/style.css index dd5565b..1147b5a 100644 --- a/client/assets/themes/basic/style.css +++ b/client/assets/themes/basic/style.css @@ -87,6 +87,18 @@ 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 { } diff --git a/client/assets/themes/cli/style.css b/client/assets/themes/cli/style.css index e86ea47..cf0d810 100644 --- a/client/assets/themes/cli/style.css +++ b/client/assets/themes/cli/style.css @@ -126,6 +126,19 @@ 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 56d7b8d..44a09d0 100644 --- a/client/assets/themes/relaxed/style.css +++ b/client/assets/themes/relaxed/style.css @@ -112,6 +112,19 @@ 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 { } diff --git a/client/src/index.html.tmpl b/client/src/index.html.tmpl index 66eb835..a6bb62b 100644 --- a/client/src/index.html.tmpl +++ b/client/src/index.html.tmpl @@ -51,6 +51,7 @@ +
diff --git a/client/src/views/memberlist.js b/client/src/views/memberlist.js index 085148a..a8028ed 100644 --- a/client/src/views/memberlist.js +++ b/client/src/views/memberlist.js @@ -12,10 +12,20 @@ _kiwi.view.MemberList = Backbone.View.extend({ render: function () { var $this = this.$el; $this.empty(); + this.model.forEach(function (member) { member.view.$el.data('member', member); $this.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'); + } + return this; }, nickClick: function (event) { @@ -74,5 +84,18 @@ _kiwi.view.MemberList = Backbone.View.extend({ show: function () { $('#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'); } }); \ No newline at end of file -- 2.25.1