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

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

Issue 325313003: Add vendor id and custom display name to media selection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address cl comments. Created 6 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
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // TODO: Better heuristics for the display name and options grouping. 70 // TODO: Better heuristics for the display name and options grouping.
71 this.ticketItem_.capability.option.forEach(function(option, index) { 71 this.ticketItem_.capability.option.forEach(function(option, index) {
72 var selectOption = document.createElement('option'); 72 var selectOption = document.createElement('option');
73 selectOption.text = option.custom_display_name || option.name; 73 selectOption.text = option.custom_display_name || option.name;
74 selectOption.value = JSON.stringify(option); 74 selectOption.value = JSON.stringify(option);
75 select.add(selectOption); 75 select.add(selectOption);
76 if (option.is_default) { 76 if (option.is_default) {
77 indexToSelect = index; 77 indexToSelect = index;
78 } 78 }
79 }); 79 });
80 } else { 80 }
81 var valueToSelect = JSON.stringify(this.ticketItem_.getValue()); 81 // Try to select current ticket item.
82 for (var i = 0, option; option = select.options[i]; i++) { 82 var valueToSelect = JSON.stringify(this.ticketItem_.getValue());
83 if (option.value == valueToSelect) { 83 for (var i = 0, option; option = select.options[i]; i++) {
84 indexToSelect = i; 84 if (option.value == valueToSelect) {
85 break; 85 indexToSelect = i;
86 } 86 break;
87 } 87 }
88 } 88 }
89 select.selectedIndex = indexToSelect; 89 select.selectedIndex = indexToSelect;
90 this.onSelectChange_();
90 }, 91 },
91 92
92 /** 93 /**
93 * Called when the select element is changed. Updates the print ticket. 94 * Called when the select element is changed. Updates the print ticket.
94 * @private 95 * @private
95 */ 96 */
96 onSelectChange_: function() { 97 onSelectChange_: function() {
97 var select = this.select_; 98 var select = this.select_;
98 var mediaSize = JSON.parse(select.options[select.selectedIndex].value); 99 var mediaSize = JSON.parse(select.options[select.selectedIndex].value);
99 this.ticketItem_.updateValue(mediaSize); 100 this.ticketItem_.updateValue(mediaSize);
(...skipping 12 matching lines...) Expand all
112 fadeOutOption(this.getElement()); 113 fadeOutOption(this.getElement());
113 } 114 }
114 } 115 }
115 }; 116 };
116 117
117 // Export 118 // Export
118 return { 119 return {
119 MediaSizeSettings: MediaSizeSettings 120 MediaSizeSettings: MediaSizeSettings
120 }; 121 };
121 }); 122 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/native_layer.js ('k') | chrome/browser/ui/webui/print_preview/print_preview_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698