Permalink
Browse files

Optimize unread counts.

Show/hide boxes, rather than destroying and re-rendering on every update.
Also tweak placement a bit.
  • Loading branch information...
akavlie committed Feb 4, 2012
1 parent 68098b5 commit 45fab12ba0409f0770ef1fafa4540c21b24394be
Showing with 18 additions and 20 deletions.
  1. +9 −6 assets/css/subway.css
  2. +7 −8 assets/js/views/channel_tab.js
  3. +2 −6 views/templates.jade
View
@@ -150,29 +150,32 @@ html { overflow: hidden; }
font-weight: bold;
}
-.channel > .unread, .channel > .unread_mentions {
- padding: 2px 6px 2px 6px;
+.channel .unread,
+.channel .unread-mentions {
+ padding: 2px 6px;
+ margin-top: -2px;
color: whiteSmoke;
font-weight: bold;
border-radius: 4px;
-webkit-border-radius: 4px;
float: right;
+ display: none;
}
-.unread{
+.channel .unread {
background: #980000;
}
-.unread_mentions{
+.channel .unread-mentions {
background: #0B2666;
margin-right: 0.3em;
}
-#logo{
+#logo {
text-align: center;
}
-#logo > img{
+#logo > img {
margin-top: 10%;
}
@@ -34,18 +34,17 @@ var ChannelTabView = Backbone.View.extend({
var unreadMentions = this.model.get('unreadMentions');
// TODO: do something more sensible here than remove/readd elements
- $(this.el).children('.unread, .unread_mentions').remove();
+ // this.$el.children('.unread, .unread_mentions').remove();
- if (unread > 0) {
- $(this.el).append(ich.unread({unread: unread}));
- }
- if (unreadMentions > 0) {
- $(this.el).append(ich.unread_mentions({unread_mentions: unreadMentions}));
- }
+ if (unread > 0) this.$('.unread').text(unread).show();
+ else this.$('.unread').hide();
+
+ if (unreadMentions > 0) this.$('.unread-mentions').text(unreadMentions).show();
+ else this.$('.unread-mentions').hide();
},
removeUnread: function() {
- $(this.el).children('.unread, .unread_mentions').remove();
+ this.$el.children('.unread, .unread-mentions').hide();
this.model.set({unread: 0, unreadMentions: 0});
},
View
@@ -66,13 +66,9 @@ script(id="channel", type="text/html")
span(class="channel-name") {{name}}
{{#notStatus}}
.close-button ×
- {{/notStatus}}
-
-script(id="unread", type="text/html")
span(class="unread", title="Unread Messages") {{unread}}
-
-script(id="unread_mentions", type="text/html")
- span(class="unread_mentions", title="Mentions in channel") {{unread_mentions}}
+ span(class="unread-mentions", title="Mentions in channel") {{unread_mentions}}
+ {{/notStatus}}
script(id="userlist_user", type="text/html")
div(class="userlist_user_activity")

0 comments on commit 45fab12

Please sign in to comment.