From 34df232d4fec274f5a91fa21dae9506f6d0ab5b4 Mon Sep 17 00:00:00 2001 From: jmr0 Date: Fri, 21 Feb 2014 07:42:52 -0500 Subject: [PATCH 1/3] fixing language selection disappearance when showing cached home view --- app/views/kinds/RootView.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/kinds/RootView.coffee b/app/views/kinds/RootView.coffee index daefb695e..6fb9e431c 100644 --- a/app/views/kinds/RootView.coffee +++ b/app/views/kinds/RootView.coffee @@ -18,10 +18,6 @@ module.exports = class RootView extends CocoView 'change .language-dropdown': 'showDiplomatSuggestionModal' 'click .toggle-fullscreen': 'toggleFullscreen' - afterRender: -> - super() - @buildLanguages() - logoutAccount: -> logoutUser($('#login-email').val()) @@ -41,11 +37,15 @@ module.exports = class RootView extends CocoView hash = location.hash location.hash = '' location.hash = hash + @buildLanguages() # TODO: automate tabs to put in hashes and navigate to them here buildLanguages: -> $select = @$el.find(".language-dropdown").empty() + if $select.hasClass("fancified") + $select.parent().find('.options,.trigger').remove() + $select.unwrap().removeClass("fancified") preferred = me.lang() codes = _.keys(locale) genericCodes = _.filter codes, (code) -> From 1562b02fd144cee3d1e5bc5c831f1f1d6d172ac2 Mon Sep 17 00:00:00 2001 From: jmr0 Date: Fri, 21 Feb 2014 08:40:55 -0500 Subject: [PATCH 2/3] still need this for rendering after a language switch --- app/views/kinds/RootView.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/kinds/RootView.coffee b/app/views/kinds/RootView.coffee index 6fb9e431c..9367c7562 100644 --- a/app/views/kinds/RootView.coffee +++ b/app/views/kinds/RootView.coffee @@ -18,6 +18,10 @@ module.exports = class RootView extends CocoView 'change .language-dropdown': 'showDiplomatSuggestionModal' 'click .toggle-fullscreen': 'toggleFullscreen' + afterRender: -> + super() + @buildLanguages() + logoutAccount: -> logoutUser($('#login-email').val()) From f00d9b2acc7d19c8cbbc952a53352594f523b2cb Mon Sep 17 00:00:00 2001 From: jmr0 Date: Sat, 22 Feb 2014 21:06:37 -0500 Subject: [PATCH 3/3] changing showDiplomatSuggestionModal function name and moving language build call to it from afterRender --- app/views/kinds/RootView.coffee | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/kinds/RootView.coffee b/app/views/kinds/RootView.coffee index 9367c7562..d29023af1 100644 --- a/app/views/kinds/RootView.coffee +++ b/app/views/kinds/RootView.coffee @@ -15,13 +15,9 @@ filterKeyboardEvents = (allowedEvents, func) -> module.exports = class RootView extends CocoView events: "click #logout-button": "logoutAccount" - 'change .language-dropdown': 'showDiplomatSuggestionModal' + 'change .language-dropdown': 'onLanguageChanged' 'click .toggle-fullscreen': 'toggleFullscreen' - afterRender: -> - super() - @buildLanguages() - logoutAccount: -> logoutUser($('#login-email').val()) @@ -60,11 +56,12 @@ module.exports = class RootView extends CocoView $("").val(code).text(localeInfo.nativeDescription)) $select.val(preferred).fancySelect() - showDiplomatSuggestionModal: -> + onLanguageChanged: -> newLang = $(".language-dropdown").val() $.i18n.setLng(newLang, {}) @saveLanguage(newLang) @render() + @buildLanguages() unless newLang.split('-')[0] is "en" @openModalView(application.router.getView("modal/diplomat_suggestion", "_modal"))