Skip to content

Commit

Permalink
create tabs work now
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzettler committed Apr 5, 2012
1 parent 2ee81a5 commit 876fad7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
19 changes: 7 additions & 12 deletions app/assets/javascripts/backbone/helpers/channels.js.coffee
Expand Up @@ -4,11 +4,11 @@ class Kandan.Helpers.Channels
autoScrollThreshold: 0.90
maxActivities: 5

@replaceCreateButton: ()->
$tabNav = $(".create_channel").parent().parent()
$createButton = $(".create_channel").parent().html()
$tabNav.find(".create_channel").parent().remove()
$tabNav.append("<li>"+$createButton+"</li>")
# @replaceCreateButton: ()->
# $tabNav = $(".create_channel").parent().parent()
# $createButton = $(".create_channel").parent().html()
# $tabNav.find(".create_channel").parent().remove()
# $tabNav.append("<li>"+$createButton+"</li>")

@pastAutoScrollThreshold: (channelId)->
currentPosition = @currentScrollPosition channelId
Expand Down Expand Up @@ -63,10 +63,6 @@ class Kandan.Helpers.Channels


@getChannelIdByTabIndex: (tabIndex)->
console.log("getChannelIdByTabIndex", tabIndex)
console.log($("#channels .ui-tabs-panel"))
console.log($("#channels .ui-tabs-panel").eq(tabIndex))
console.log($("#channels .ui-tabs-panel").eq(tabIndex).data('channel_id'))
$("#channels .ui-tabs-panel")
.eq(tabIndex)
.data('channel_id')
Expand Down Expand Up @@ -98,10 +94,9 @@ class Kandan.Helpers.Channels
channelArea = "#channels-#{channel.get('id')}"
totalTabs = $("#kandan").tabs("length")

console.log('createChannelArea',channelArea, totalTabs);

$createTab = $(".create_channel").parents('li').detach()
$("#kandan").tabs('add', channelArea, "#{channel.get("name")}", totalTabs)
Kandan.Helpers.Channels.replaceCreateButton()
$createTab.appendTo('ul.ui-tabs-nav')
view = new Kandan.Views.ChannelPane({channel: channel})
view.render $(channelArea)
$(channelArea).data('channel_id', channel.get('id'))
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee
Expand Up @@ -42,6 +42,9 @@ window.Kandan =
$(document).data('active_channel_id',
Kandan.Helpers.Channels.getChannelIdByTabIndex(ui.index))
Kandan.Data.Channels.runCallbacks('change')
add: (event, ui) ->
$('.header .ui-tabs-panel:last').detach().appendTo('#channels')
$('#kandan').tabs('option', 'disabled', [])
})

$("#kandan").tabs 'option', 'tabTemplate', '''
Expand Down

0 comments on commit 876fad7

Please sign in to comment.