Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Lotsa styling & code for parting channels.

Clicking new X button seems to work fine now.
  • Loading branch information...
commit 90ecc97c8228c10a1fdbb0abb70f2c0a0126e40f 1 parent 6b22164
Aaron Kavlie akavlie authored
11 assets/css/subway.css
View
@@ -64,15 +64,22 @@
}
#channels > .channel .close-button {
- color: white;
+ color: #333;
font: bold 20px Arial;
- text-shadow: 0 1px 0 black;
+ text-shadow: 0 1px 0 whiteSmoke;
line-height: 19px;
float: right;
opacity: 0.3;
+ width: 24px;
+ text-align: center;
cursor: pointer;
}
+#channels > .channel.active .close-button {
+ color: white;
+ text-shadow: 0 1px 0 black;
+}
+
#channels > .channel .close-button:hover {
opacity: 0.8;
}
8 assets/js/views/channel_list.js
View
@@ -2,17 +2,15 @@ var ChannelListView = Backbone.View.extend({
el: '#channels',
initialize: function() {
- console.log('channel list init');
irc.chatWindows.bind('add', this.addChannel, this);
this.channelTabs = []
},
- addChannel: function(chat) {
- console.log('channel added to list');
- var view = new ChannelTabView({model: chat});
+ addChannel: function(chatWindow) {
+ var view = new ChannelTabView({model: chatWindow});
this.channelTabs.push(view);
$(this.el).append(view.render().el);
- irc.chatWindows.setActive(chat);
+ irc.chatWindows.setActive(chatWindow);
view.setActive();
}
});
31 assets/js/views/channel_tab.js
View
@@ -2,16 +2,23 @@ var ChannelTabView = Backbone.View.extend({
className: 'channel',
events: {
- 'click': 'setActive'
+ 'click': 'setActive',
+ 'click .close-button': 'close'
},
initialize: function() {
this.model.stream.bind('add', this.updateUnreadCounts, this);
- this.model.bind('destroy', this.close, this);
+ this.model.bind('destroy', this.switchAndRemove, this);
},
render: function() {
- var tmpl = ich.channel({name: this.model.get('name')});
+ var self = this;
+ var tmpl = ich.channel({
+ name: this.model.get('name'),
+ notStatus: function() {
+ return self.model.get('type') !== 'status';
+ }
+ });
$(this.el).html(tmpl);
return this;
},
@@ -42,17 +49,27 @@ var ChannelTabView = Backbone.View.extend({
this.model.set({unread: 0, unreadMentions: 0});
},
- close: function() {
+ close: function(e) {
+ e.stopPropagation();
+ if (this.model.get('type') === 'channel')
+ irc.socket.emit('part', this.model.get('name'));
+ else
+ this.model.destroy();
+ },
+
+ switchAndRemove: function() {
+ var $nextTab;
// Focus on next frame if this one has the focus
if ($(this.el).hasClass('active')) {
// Go to previous frame unless it's status
- if ($(this.el).prev().text().trim() !== 'status') {
- $(this.el).prev().click();
+ if ($(this.el).prev().text().trim() !== 'status' || !$(this.el).next().length) {
+ $nextTab = $(this.el).prev();
} else {
- $(this.el).next().click();
+ $nextTab = $(this.el).next();
}
}
this.remove();
+ $nextTab.click();
}
});
2  views/templates.jade
View
@@ -63,7 +63,9 @@ script(id="chat", type="text/html")
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}}
Please sign in to comment.
Something went wrong with that request. Please try again.