Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ $ ->
$tab.addClass('hidden').hide().addClass('hidden')
$addButton.show().removeClass('hidden')

switchToTab = ($tab, $tabs, $contents) ->
if $tab && $tab.length > 0
$tab.eq(0).click()
else
$tabs.removeClass("active")
$contents.hide()

$(".activeadmin-translations > ul").each ->
$dom = $(this)
# true when tabs are used in show action, false in form
Expand All @@ -40,8 +47,6 @@ $ ->
$contents.filter($tab.attr("href")).show()
e.preventDefault()

$tabs.eq(0).click()

# Add button and other behavior is not needed in show action
return if showAction

Expand Down Expand Up @@ -70,7 +75,7 @@ $ ->
$tab = $(this).parent()
toggleTab($tab, false)
if $tab.hasClass('active')
$tabs.not('.hidden').eq(0).click()
switchToTab $tabs.not('.hidden').eq(0), $tabs, $contents

updateLocaleButtonsStatus($dom)

Expand Down Expand Up @@ -133,7 +138,9 @@ $ ->

#Initially update the buttons' status
updateLocaleButtonsStatus($dom)
$tabs.filter('.default').click()
$nextActiveTab = $tabs.filter('.default')
$nextActiveTab = $tabs.filter(':not(.hidden)').eq(0) if !$nextActiveTab.length
switchToTab $nextActiveTab, $tabs, $contents

# this is to handle elements created with has_many
$("a").bind "click", ->
Expand Down