{:uriI"file:///Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/navigation/_language.js?type=application/javascript&pipeline=self&id=280a8f9b36fbe36a88592a521b8a2f79dffd3c0b3b0c63ac97c8d92739a6b939:ET:load_pathI"G/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts;T: filenameI"c/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/navigation/_language.js;T: nameI"fae/navigation/_language;T:logical_pathI"%fae/navigation/_language.self.js;T:content_typeI"application/javascript;T: sourceI" /* global Fae */ /** * Fae navigation language * @namespace navigation.language * @memberof navigation */ Fae.navigation.language = { el: {}, init: function(options, elm){ /** Stores shared jQuery objects in Fae.navigation.language.el */ this.el.$select = $('#js-language'); this.el.$lang_divs = $('div[data-language]'); if (this.el.$select.length) { this.setInitialState(); this.addNavEvents(); } }, /** * Reads the language of the active toggle on load and shows the corresponding fields */ setInitialState: function() { var lang = this.el.$select.find('option[selected]').val(); this._toggleLanguageFields(lang, 0); }, /** * On change of the select field, change the language displayed * @has_test {spec/features/language_nav_spec.rb} */ addNavEvents: function() { var _this = this; _this.el.$select.on('change', function(ev) { ev.preventDefault(); var $this = $(this); var lang = $this.val(); _this._toggleLanguageFields(lang, 200); // POSTs to Utilities#language_preference to save user's language preference lang = lang || 'all' var post_url = Fae.path + '/language_preference/' + lang; $.post(post_url); // Fade out extra error messages $('.hidden_errors').fadeOut(200, function() { $(this).remove(); }); }); }, /** * Hides all language fields and fades in ones according to language * @protected * @param {String} lang - Language of fields to fade in * @param {Number} speed - Speed of the fade transitions in ms * @has_test {spec/features/language_nav_spec.rb} */ _toggleLanguageFields: function(lang, speed) { var _this = this; _this.el.$lang_divs .fadeOut(speed) .promise() .done(function() { if (lang) { $('div[data-language='+lang+']').fadeIn(speed); } else { _this.el.$lang_divs.fadeIn(speed); } }); }, /** * Called on form validation; checks for hidden fields with errors and displays a message * @see {@link form.validator.formValidate} */ checkForHiddenErrors: function() { if (this.el.$select.length && $('div.field_with_errors:hidden').length && !FCH.exists('.hidden_errors')) { $(Fae.content_selector).prepend('
There are hidden errors. Click "All Languages" in the language nav to view all errors.
'); } } }; ;T: metadata{ :dependencieso:Set: @hash} I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"qfile-digest:///Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/navigation/_language.js;TTF: requiredo;;}F: stubbedo;;}F: linkso;;}F: charsetI" utf-8;F: digest"%:_Rpgq=8t.: lengthi :dependencies_digest"%~'<FEBhE:idI"E280a8f9b36fbe36a88592a521b8a2f79dffd3c0b3b0c63ac97c8d92739a6b939;F: mtimel+ܗX