Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Akash Manohar J <akash@akash.im>
- Loading branch information
Showing
6 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/assets/javascripts/backbone/views/channel_tabs.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Kandan.Views.ChannelTabs extends Backbone.View | ||
template: JST['chatarea'] | ||
tagName: 'ul' | ||
|
||
events: | ||
"click .close_channel" : "deleteChannel" | ||
"click .create_channel": "createChannel" | ||
|
||
|
||
render: ()-> | ||
$(@el).html @template({channels: @options.channels}) | ||
@ | ||
|
||
createChannel: (event)-> | ||
channelName = prompt("What's the channel name?", "New channel") | ||
channelName = channelName.replace(/^\s+|\s+$/g, '') | ||
if channelName | ||
channel = new Kandan.Models.Channel({name: channelName}) | ||
channel.save({}, { | ||
success: (model)-> | ||
Kandan.Helpers.Channels.createChannelArea(model) | ||
}) | ||
console.log "create channel: #{channelName}" | ||
|
||
deleteChannel: (event)-> | ||
console.log "deleteChannel" | ||
channelIndex = $(event.target).parent().prevAll().length | ||
console.log "request for deletion", channelIndex | ||
Kandan.Helpers.Channels.deleteChannelByTabIndex(channelIndex) if channelIndex != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,11 @@ | ||
class Kandan.Views.ChatArea extends Backbone.View | ||
|
||
template: JST['chatarea'] | ||
# className: 'channels' | ||
render: ()-> | ||
tabView = new Kandan.Views.ChannelTabs({channels: @options.channels}) | ||
$('.header .logo').after(tabView.render().el) | ||
|
||
events: | ||
"click .close_channel" : "deleteChannel" | ||
"click .create_channel": "createChannel" | ||
|
||
render: -> | ||
$('.header .logo').after(@template({channels: @options.channels})) | ||
for channel in @options.channels.models | ||
view = new Kandan.Views.ChannelPane({channel: channel}) | ||
$(@el).append(view.render().el) | ||
$(@el).attr('id', 'channels') | ||
@ | ||
|
||
createChannel: (event)-> | ||
channelName = prompt("What's the channel name?", "New channel") | ||
channelName = channelName.replace(/^\s+|\s+$/g, '') | ||
if channelName | ||
channel = new Kandan.Models.Channel({name: channelName}) | ||
channel.save({}, { | ||
success: (model)-> | ||
Kandan.Helpers.Channels.createChannelArea(model) | ||
}) | ||
console.log "create channel: #{channelName}" | ||
|
||
deleteChannel: (event)-> | ||
channelIndex = $(event.target).parent().prevAll().length | ||
console.log "request for deletion", channelIndex | ||
Kandan.Helpers.Channels.deleteChannelByTabIndex(channelIndex) if channelIndex != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
<ul> | ||
<% for channel in @channels.models: %> | ||
<li> | ||
<span class="tab_right"></span> | ||
<span class="tab_left"></span> | ||
<span class="tab_content"> | ||
<a href="#<%= "channels-#{channel.get('id')}" %>"><%= channel.get('name') %></a> | ||
<a href="#" class="close_channel" title="close channel">x</a> | ||
</span> | ||
</li> | ||
<% end %> | ||
<% for channel in @channels.models: %> | ||
<li> | ||
<a href="#" class="create_channel">+</a> | ||
</li> | ||
</ul> | ||
|
||
<span class="tab_right"></span> | ||
<span class="tab_left"></span> | ||
<span class="tab_content"> | ||
<a href="#<%= "channels-#{channel.get('id')}" %>"><%= channel.get('name') %></a> | ||
<a href="#" class="close_channel" title="close channel">x</a> | ||
</span> | ||
</li> | ||
<% end %> | ||
<%- JST['create_channel']() %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="ui-state-default ui-corner-top"> | ||
<span class="create_channel">+</span> | ||
</li> |