Merge pull request #398 from jmr0/master

fixing language selection disappearance when showing cached home view
This commit is contained in:
Nick Winter 2014-02-23 08:32:27 -08:00
commit 0a334b310f

View file

@ -15,13 +15,9 @@ filterKeyboardEvents = (allowedEvents, func) ->
module.exports = class RootView extends CocoView module.exports = class RootView extends CocoView
events: events:
"click #logout-button": "logoutAccount" "click #logout-button": "logoutAccount"
'change .language-dropdown': 'showDiplomatSuggestionModal' 'change .language-dropdown': 'onLanguageChanged'
'click .toggle-fullscreen': 'toggleFullscreen' 'click .toggle-fullscreen': 'toggleFullscreen'
afterRender: ->
super()
@buildLanguages()
logoutAccount: -> logoutAccount: ->
logoutUser($('#login-email').val()) logoutUser($('#login-email').val())
@ -41,11 +37,15 @@ module.exports = class RootView extends CocoView
hash = location.hash hash = location.hash
location.hash = '' location.hash = ''
location.hash = hash location.hash = hash
@buildLanguages()
# TODO: automate tabs to put in hashes and navigate to them here # TODO: automate tabs to put in hashes and navigate to them here
buildLanguages: -> buildLanguages: ->
$select = @$el.find(".language-dropdown").empty() $select = @$el.find(".language-dropdown").empty()
if $select.hasClass("fancified")
$select.parent().find('.options,.trigger').remove()
$select.unwrap().removeClass("fancified")
preferred = me.lang() preferred = me.lang()
codes = _.keys(locale) codes = _.keys(locale)
genericCodes = _.filter codes, (code) -> genericCodes = _.filter codes, (code) ->
@ -56,11 +56,12 @@ module.exports = class RootView extends CocoView
$("<option></option>").val(code).text(localeInfo.nativeDescription)) $("<option></option>").val(code).text(localeInfo.nativeDescription))
$select.val(preferred).fancySelect() $select.val(preferred).fancySelect()
showDiplomatSuggestionModal: -> onLanguageChanged: ->
newLang = $(".language-dropdown").val() newLang = $(".language-dropdown").val()
$.i18n.setLng(newLang, {}) $.i18n.setLng(newLang, {})
@saveLanguage(newLang) @saveLanguage(newLang)
@render() @render()
@buildLanguages()
unless newLang.split('-')[0] is "en" unless newLang.split('-')[0] is "en"
@openModalView(application.router.getView("modal/diplomat_suggestion", "_modal")) @openModalView(application.router.getView("modal/diplomat_suggestion", "_modal"))