Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/resources/options/language_options.js

Issue 7146009: Options: Hide the language UI elements when the list is empty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(kochi): Generalize the notification as a component and put it 5 // TODO(kochi): Generalize the notification as a component and put it
6 // in js/cr/ui/notification.js . 6 // in js/cr/ui/notification.js .
7 7
8 cr.define('options', function() { 8 cr.define('options', function() {
9 const OptionsPage = options.OptionsPage; 9 const OptionsPage = options.OptionsPage;
10 const LanguageList = options.LanguageList; 10 const LanguageList = options.LanguageList;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 updateSelectedLanguageName_: function(languageCode) { 298 updateSelectedLanguageName_: function(languageCode) {
299 var languageDisplayName = LanguageList.getDisplayNameFromLanguageCode( 299 var languageDisplayName = LanguageList.getDisplayNameFromLanguageCode(
300 languageCode); 300 languageCode);
301 var languageNativeDisplayName = 301 var languageNativeDisplayName =
302 LanguageList.getNativeDisplayNameFromLanguageCode(languageCode); 302 LanguageList.getNativeDisplayNameFromLanguageCode(languageCode);
303 // If the native name is different, add it. 303 // If the native name is different, add it.
304 if (languageDisplayName != languageNativeDisplayName) { 304 if (languageDisplayName != languageNativeDisplayName) {
305 languageDisplayName += ' - ' + languageNativeDisplayName; 305 languageDisplayName += ' - ' + languageNativeDisplayName;
306 } 306 }
307 // Update the currently selected language name. 307 // Update the currently selected language name.
308 $('language-options-language-name').textContent = languageDisplayName; 308 var languageName = $('language-options-language-name');
309 if (languageDisplayName) {
310 languageName.hidden = false;
311 languageName.textContent = languageDisplayName;
312 } else {
313 languageName.hidden = true;
314 }
309 }, 315 },
310 316
311 /** 317 /**
312 * Updates the UI language button. 318 * Updates the UI language button.
313 * @param {string} languageCode Language code (ex. "fr"). 319 * @param {string} languageCode Language code (ex. "fr").
314 * @private 320 * @private
315 */ 321 */
316 updateUiLanguageButton_: function(languageCode) { 322 updateUiLanguageButton_: function(languageCode) {
317 var uiLanguageButton = $('language-options-ui-language-button'); 323 var uiLanguageButton = $('language-options-ui-language-button');
318 // Check if the language code matches the current UI language. 324 // Check if the language code matches the current UI language.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 uiLanguageButton.style.display = 'block'; 363 uiLanguageButton.style.display = 'block';
358 $('language-options-ui-notification-bar').style.display = 'none'; 364 $('language-options-ui-notification-bar').style.display = 'none';
359 }, 365 },
360 366
361 /** 367 /**
362 * Updates the spell check language button. 368 * Updates the spell check language button.
363 * @param {string} languageCode Language code (ex. "fr"). 369 * @param {string} languageCode Language code (ex. "fr").
364 * @private 370 * @private
365 */ 371 */
366 updateSpellCheckLanguageButton_: function(languageCode) { 372 updateSpellCheckLanguageButton_: function(languageCode) {
373 var display = 'block';
367 var spellCheckLanguageButton = $( 374 var spellCheckLanguageButton = $(
368 'language-options-spell-check-language-button'); 375 'language-options-spell-check-language-button');
369 // Check if the language code matches the current spell check language. 376 // Check if the language code matches the current spell check language.
370 if (languageCode == this.spellCheckDictionary_) { 377 if (languageCode == this.spellCheckDictionary_) {
371 // If it matches, the button just says that the spell check language is 378 // If it matches, the button just says that the spell check language is
372 // currently in use. 379 // currently in use.
373 spellCheckLanguageButton.textContent = 380 spellCheckLanguageButton.textContent =
374 localStrings.getString('is_used_for_spell_checking'); 381 localStrings.getString('is_used_for_spell_checking');
375 // Make it look like a text label. 382 // Make it look like a text label.
376 spellCheckLanguageButton.className = 'text-button'; 383 spellCheckLanguageButton.className = 'text-button';
377 // Remove the event listner. 384 // Remove the event listner.
378 spellCheckLanguageButton.onclick = undefined; 385 spellCheckLanguageButton.onclick = undefined;
379 } else if (languageCode in templateData.spellCheckLanguageCodeSet) { 386 } else if (languageCode in templateData.spellCheckLanguageCodeSet) {
380 // If the language is supported as spell check language, users can 387 // If the language is supported as spell check language, users can
381 // click on the button to change the spell check language. 388 // click on the button to change the spell check language.
382 spellCheckLanguageButton.textContent = 389 spellCheckLanguageButton.textContent =
383 localStrings.getString('use_this_for_spell_checking'); 390 localStrings.getString('use_this_for_spell_checking');
384 spellCheckLanguageButton.className = ''; 391 spellCheckLanguageButton.className = '';
385 spellCheckLanguageButton.languageCode = languageCode; 392 spellCheckLanguageButton.languageCode = languageCode;
386 // Add an event listner to the click event. 393 // Add an event listner to the click event.
387 spellCheckLanguageButton.addEventListener('click', 394 spellCheckLanguageButton.addEventListener('click',
388 this.handleSpellCheckLanguageButtonClick_.bind(this)); 395 this.handleSpellCheckLanguageButtonClick_.bind(this));
396 } else if (!languageCode) {
397 display = 'none';
389 } else { 398 } else {
390 // If the language is not supported as spell check language, the 399 // If the language is not supported as spell check language, the
391 // button just says that this language cannot be used for spell 400 // button just says that this language cannot be used for spell
392 // checking. 401 // checking.
393 spellCheckLanguageButton.textContent = 402 spellCheckLanguageButton.textContent =
394 localStrings.getString('cannot_be_used_for_spell_checking'); 403 localStrings.getString('cannot_be_used_for_spell_checking');
395 spellCheckLanguageButton.className = 'text-button'; 404 spellCheckLanguageButton.className = 'text-button';
396 spellCheckLanguageButton.onclick = undefined; 405 spellCheckLanguageButton.onclick = undefined;
397 } 406 }
398 spellCheckLanguageButton.style.display = 'block'; 407 spellCheckLanguageButton.style.display = display;
399 $('language-options-ui-notification-bar').style.display = 'none'; 408 $('language-options-ui-notification-bar').style.display = 'none';
400 }, 409 },
401 410
402 /** 411 /**
403 * Updates the input method list. 412 * Updates the input method list.
404 * @param {string} languageCode Language code (ex. "fr"). 413 * @param {string} languageCode Language code (ex. "fr").
405 * @private 414 * @private
406 */ 415 */
407 updateInputMethodList_: function(languageCode) { 416 updateInputMethodList_: function(languageCode) {
408 // Give one of the checkboxes or buttons focus, if it's specified in the 417 // Give one of the checkboxes or buttons focus, if it's specified in the
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 LanguageOptions.uiLanguageSaved = function() { 775 LanguageOptions.uiLanguageSaved = function() {
767 $('language-options-ui-language-button').style.display = 'none'; 776 $('language-options-ui-language-button').style.display = 'none';
768 $('language-options-ui-notification-bar').style.display = 'block'; 777 $('language-options-ui-notification-bar').style.display = 'block';
769 }; 778 };
770 779
771 // Export 780 // Export
772 return { 781 return {
773 LanguageOptions: LanguageOptions 782 LanguageOptions: LanguageOptions
774 }; 783 };
775 }); 784 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698