| OLD | NEW |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 }, | 48 }, |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Makes sure the content of the select element matches the capabilities of | 51 * Makes sure the content of the select element matches the capabilities of |
| 52 * the destination. | 52 * the destination. |
| 53 * @private | 53 * @private |
| 54 */ | 54 */ |
| 55 updateSelect_: function() { | 55 updateSelect_: function() { |
| 56 var select = this.select_; | 56 var select = this.select_; |
| 57 if (!this.ticketItem_.isCapabilityAvailable()) { | 57 if (!this.ticketItem_.isCapabilityAvailable()) { |
| 58 select.innerHtml = ''; | 58 select.innerHTML = ''; |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 // Should the select content be updated? | 61 // Should the select content be updated? |
| 62 var sameContent = | 62 var sameContent = |
| 63 this.ticketItem_.capability.option.length == select.length && | 63 this.ticketItem_.capability.option.length == select.length && |
| 64 this.ticketItem_.capability.option.every(function(option, index) { | 64 this.ticketItem_.capability.option.every(function(option, index) { |
| 65 return select.options[index].value == JSON.stringify(option); | 65 return select.options[index].value == JSON.stringify(option); |
| 66 }); | 66 }); |
| 67 var indexToSelect = select.selectedIndex; | 67 var indexToSelect = select.selectedIndex; |
| 68 if (!sameContent) { | 68 if (!sameContent) { |
| 69 select.innerHtml = ''; | 69 select.innerHTML = ''; |
| 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 }); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 fadeOutOption(this.getElement()); | 112 fadeOutOption(this.getElement()); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 // Export | 117 // Export |
| 118 return { | 118 return { |
| 119 MediaSizeSettings: MediaSizeSettings | 119 MediaSizeSettings: MediaSizeSettings |
| 120 }; | 120 }; |
| 121 }); | 121 }); |
| OLD | NEW |