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

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

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * Component that renders the copies settings UI. 9 * Component that renders the copies settings UI.
10 * @param {!print_preview.ticket_items.Copies} copiesTicketItem Used to read 10 * @param {!print_preview.ticket_items.Copies} copiesTicketItem Used to read
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 if (isEnabled) { 81 if (isEnabled) {
82 this.updateState_(); 82 this.updateState_();
83 } 83 }
84 }, 84 },
85 85
86 /** @override */ 86 /** @override */
87 enterDocument: function() { 87 enterDocument: function() {
88 this.inputField_ = this.getChildElement('input.user-value'); 88 this.inputField_ = this.getChildElement('input.user-value');
89 print_preview.SettingsSection.prototype.enterDocument.call(this); 89 print_preview.SettingsSection.prototype.enterDocument.call(this);
90 this.tracker.add( 90 this.tracker.add(
91 this.inputField_, 91 this.inputField_, 'keydown', this.onTextfieldKeyDown_.bind(this));
92 'keydown',
93 this.onTextfieldKeyDown_.bind(this));
94 this.tracker.add( 92 this.tracker.add(
95 this.inputField_, 93 this.inputField_, 'input', this.onTextfieldInput_.bind(this));
96 'input',
97 this.onTextfieldInput_.bind(this));
98 this.tracker.add( 94 this.tracker.add(
99 this.inputField_, 95 this.inputField_, 'blur', this.onTextfieldBlur_.bind(this));
100 'blur',
101 this.onTextfieldBlur_.bind(this));
102 this.tracker.add( 96 this.tracker.add(
103 this.getChildElement('input.collate'), 97 this.getChildElement('input.collate'), 'click',
104 'click',
105 this.onCollateCheckboxClick_.bind(this)); 98 this.onCollateCheckboxClick_.bind(this));
106 this.tracker.add( 99 this.tracker.add(
107 this.copiesTicketItem_, 100 this.copiesTicketItem_,
108 print_preview.ticket_items.TicketItem.EventType.CHANGE, 101 print_preview.ticket_items.TicketItem.EventType.CHANGE,
109 this.updateState_.bind(this)); 102 this.updateState_.bind(this));
110 this.tracker.add( 103 this.tracker.add(
111 this.collateTicketItem_, 104 this.collateTicketItem_,
112 print_preview.ticket_items.TicketItem.EventType.CHANGE, 105 print_preview.ticket_items.TicketItem.EventType.CHANGE,
113 this.updateState_.bind(this)); 106 this.updateState_.bind(this));
114 }, 107 },
(...skipping 12 matching lines...) Expand all
127 this.inputField_.classList.remove('invalid'); 120 this.inputField_.classList.remove('invalid');
128 fadeOutElement(this.getChildElement('.hint')); 121 fadeOutElement(this.getChildElement('.hint'));
129 var currentValue = this.copiesTicketItem_.getValueAsNumber(); 122 var currentValue = this.copiesTicketItem_.getValueAsNumber();
130 currentValueGreaterThan1 = currentValue > 1; 123 currentValueGreaterThan1 = currentValue > 1;
131 } else { 124 } else {
132 this.inputField_.classList.add('invalid'); 125 this.inputField_.classList.add('invalid');
133 fadeInElement(this.getChildElement('.hint')); 126 fadeInElement(this.getChildElement('.hint'));
134 } 127 }
135 128
136 if (!(this.getChildElement('.collate-container').hidden = 129 if (!(this.getChildElement('.collate-container').hidden =
137 !this.collateTicketItem_.isCapabilityAvailable() || 130 !this.collateTicketItem_.isCapabilityAvailable() ||
138 !currentValueGreaterThan1)) { 131 !currentValueGreaterThan1)) {
139 this.getChildElement('input.collate').checked = 132 this.getChildElement('input.collate').checked =
140 this.collateTicketItem_.getValue(); 133 this.collateTicketItem_.getValue();
141 } 134 }
142 } 135 }
143 this.updateUiStateInternal(); 136 this.updateUiStateInternal();
144 }, 137 },
145 138
146 /** 139 /**
147 * Called after a timeout after user input into the textfield. 140 * Called after a timeout after user input into the textfield.
148 * @private 141 * @private
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 * Called when the focus leaves the textfield. If the textfield is empty, 180 * Called when the focus leaves the textfield. If the textfield is empty,
188 * its value is set to 1. 181 * its value is set to 1.
189 * @private 182 * @private
190 */ 183 */
191 onTextfieldBlur_: function() { 184 onTextfieldBlur_: function() {
192 if (this.inputField_.value == '') { 185 if (this.inputField_.value == '') {
193 if (this.copiesTicketItem_.getValue() == '1') { 186 if (this.copiesTicketItem_.getValue() == '1') {
194 // No need to update the ticket, but change the display to match. 187 // No need to update the ticket, but change the display to match.
195 this.inputField_.value = '1'; 188 this.inputField_.value = '1';
196 } else { 189 } else {
197 setTimeout((function() { 190 setTimeout(
198 this.copiesTicketItem_.updateValue('1'); 191 (function() {
199 }).bind(this), 0); 192 this.copiesTicketItem_.updateValue('1');
193 }).bind(this),
194 0);
200 } 195 }
201 } 196 }
202 }, 197 },
203 198
204 /** 199 /**
205 * Called when the collate checkbox is clicked. Updates the print ticket. 200 * Called when the collate checkbox is clicked. Updates the print ticket.
206 * @private 201 * @private
207 */ 202 */
208 onCollateCheckboxClick_: function() { 203 onCollateCheckboxClick_: function() {
209 this.collateTicketItem_.updateValue( 204 this.collateTicketItem_.updateValue(
210 this.getChildElement('input.collate').checked); 205 this.getChildElement('input.collate').checked);
211 } 206 }
212 }; 207 };
213 208
214 // Export 209 // Export
215 return { 210 return {CopiesSettings: CopiesSettings};
216 CopiesSettings: CopiesSettings
217 };
218 }); 211 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698