Skip to content

Commit

Permalink
Fixes Channels API: the way it sets active channel id
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Mar 19, 2012
1 parent d5bed59 commit 7144978
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/assets/javascripts/backbone/helpers/channels.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ class Kandan.Helpers.Channels
@channel_pagination_el: (channel_id)->
$("#channels-#{channel_id} .pagination")

@get_channel_id_from_tab_index: (tab_index)->
$("#channels .ui-tabs-panel")
.eq(tab_index)
.data('channel_id')

@selected_tab: ()->
$('#channels').tabs('option', 'selected')
$('#channels').tabs('option', 'selected')

@get_active_channel_id: ()->
$("#channels .ui-tabs-panel")
.eq(@selected_tab())
.data('channel_id')
if $(document).data('active_channel_id') == undefined
return $("#channels .ui-tabs-panel")
.eq(@selected_tab())
.data('channel_id')
else
return $(document).data('active_channel_id')


@new_activity_view: (activity_attributes)->
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ window.Kandan =
chatbox = new Kandan.Views.Chatbox()
$(".container").append(chatbox.render().el)
$('#channels').tabs({select: (event, ui)->
$(document).data('active_channel_id',
Kandan.Helpers.Channels.get_channel_id_from_tab_index(ui.index))
console.log "channel changed to index", ui.index
Kandan.Data.Channels.run_callbacks('change')
})
Expand Down

0 comments on commit 7144978

Please sign in to comment.