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

Side by Side Diff: chrome/browser/resources/print_preview/settings/media_size_settings.js

Issue 588713002: Compile print_preview, part 3: reduce down to 185 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_2
Patch Set: revert movement of enums: now handle in compiler pass Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Encapsulates all settings and logic related to the media size selection UI. 9 * Encapsulates all settings and logic related to the media size selection UI.
10 * @param {!print_preview.ticket_items.MediaSize} ticketItem Used to read and 10 * @param {!print_preview.ticket_items.MediaSize} ticketItem Used to read and
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return select.options[index].value == JSON.stringify(option); 74 return select.options[index].value == JSON.stringify(option);
75 }); 75 });
76 var indexToSelect = select.selectedIndex; 76 var indexToSelect = select.selectedIndex;
77 if (!sameContent) { 77 if (!sameContent) {
78 select.innerHTML = ''; 78 select.innerHTML = '';
79 // TODO: Better heuristics for the display name and options grouping. 79 // TODO: Better heuristics for the display name and options grouping.
80 this.ticketItem_.capability.option.forEach(function(option, index) { 80 this.ticketItem_.capability.option.forEach(function(option, index) {
81 var selectOption = document.createElement('option'); 81 var selectOption = document.createElement('option');
82 var displayName = option.custom_display_name; 82 var displayName = option.custom_display_name;
83 if (!displayName && option.custom_display_name_localized) { 83 if (!displayName && option.custom_display_name_localized) {
84 var getLocaleToCompare = function(locale, languageOnly) { 84 var getLocaleToCompare =
85 var code = languageOnly ? locale.split('-')[0] : locale; 85 /** @type {function(string, boolean=): string} */
Dan Beam 2014/09/29 18:42:00 what is the point of this cast?
Vitaly Pavlenko 2014/10/01 00:33:37 Otherwise at line 93 we get the following error:
86 (function(locale, opt_languageOnly) {
87 var code = opt_languageOnly ? locale.split('-')[0] : locale;
86 return code.toLowerCase(); 88 return code.toLowerCase();
87 }; 89 });
88 var getItemForLocale = function(items, locale, languageOnly) { 90 var getItemForLocale = function(items, locale, languageOnly) {
89 locale = getLocaleToCompare(locale, languageOnly); 91 locale = getLocaleToCompare(locale, languageOnly);
90 for (var i = 0; i < items.length; i++) { 92 for (var i = 0; i < items.length; i++) {
91 if (getLocaleToCompare(items[i].locale) == locale) 93 if (getLocaleToCompare(items[i].locale) == locale)
92 return items[i].value; 94 return items[i].value;
93 } 95 }
94 return ''; 96 return '';
95 }; 97 };
96 var items = option.custom_display_name_localized; 98 var items = option.custom_display_name_localized;
97 displayName = 99 displayName =
98 getItemForLocale(items, navigator.language, false) || 100 getItemForLocale(items, navigator.language, false) ||
99 getItemForLocale(items, navigator.language, true); 101 getItemForLocale(items, navigator.language, true);
100 } 102 }
101 selectOption.text = displayName || option.name; 103 selectOption.text = displayName || option.name;
102 selectOption.value = JSON.stringify(option); 104 selectOption.value = JSON.stringify(option);
103 select.add(selectOption); 105 select.appendChild(selectOption);
104 if (option.is_default) { 106 if (option.is_default) {
105 indexToSelect = index; 107 indexToSelect = index;
106 } 108 }
107 }); 109 });
108 } 110 }
109 // Try to select current ticket item. 111 // Try to select current ticket item.
110 var valueToSelect = JSON.stringify(this.ticketItem_.getValue()); 112 var valueToSelect = JSON.stringify(this.ticketItem_.getValue());
111 for (var i = 0, option; option = select.options[i]; i++) { 113 for (var i = 0, option; option = select.options[i]; i++) {
112 if (option.value == valueToSelect) { 114 if (option.value == valueToSelect) {
113 indexToSelect = i; 115 indexToSelect = i;
(...skipping 23 matching lines...) Expand all
137 this.updateSelect_(); 139 this.updateSelect_();
138 this.updateUiStateInternal(); 140 this.updateUiStateInternal();
139 } 141 }
140 }; 142 };
141 143
142 // Export 144 // Export
143 return { 145 return {
144 MediaSizeSettings: MediaSizeSettings 146 MediaSizeSettings: MediaSizeSettings
145 }; 147 };
146 }); 148 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698