| OLD | NEW |
| 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Creates a PageSettings object. This object encapsulates all settings and | 9 * Creates a PageSettings object. This object encapsulates all settings and |
| 10 * logic related to page selection. | 10 * logic related to page selection. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 }, | 252 }, |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * Executes whenever a blur event occurs on |this.selectedPagesTextfield| | 255 * Executes whenever a blur event occurs on |this.selectedPagesTextfield| |
| 256 * or when the timer expires. It takes care of | 256 * or when the timer expires. It takes care of |
| 257 * 1) showing/hiding warnings/suggestions | 257 * 1) showing/hiding warnings/suggestions |
| 258 * 2) updating print button/summary | 258 * 2) updating print button/summary |
| 259 */ | 259 */ |
| 260 onSelectedPagesTextfieldChanged: function() { | 260 onSelectedPagesTextfieldChanged: function() { |
| 261 this.validateSelectedPages_(); | 261 this.validateSelectedPages_(); |
| 262 cr.dispatchSimpleEvent(document, 'updateSummary'); | 262 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
| 263 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 263 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); |
| 264 }, | 264 }, |
| 265 | 265 |
| 266 /** | 266 /** |
| 267 * When the user stops typing in |this.selectedPagesTextfield| or clicks on | 267 * When the user stops typing in |this.selectedPagesTextfield| or clicks on |
| 268 * |allPagesRadioButton|, a new print preview is requested, only if | 268 * |allPagesRadioButton|, a new print preview is requested, only if |
| 269 * 1) The input is compeletely valid (it can be parsed in its entirety). | 269 * 1) The input is compeletely valid (it can be parsed in its entirety). |
| 270 * 2) The newly selected pages differ from |this.previouslySelectedPages_|. | 270 * 2) The newly selected pages differ from |this.previouslySelectedPages_|. |
| 271 * @private | 271 * @private |
| 272 */ | 272 */ |
| 273 onSelectedPagesMayHaveChanged_: function() { | 273 onSelectedPagesMayHaveChanged_: function() { |
| 274 if (this.selectedPagesRadioButton_.checked) | 274 if (this.selectedPagesRadioButton_.checked) |
| 275 this.onSelectedPagesTextfieldChanged(); | 275 this.onSelectedPagesTextfieldChanged(); |
| 276 | 276 |
| 277 // Toggling between "all pages"/"some pages" radio buttons while having an | 277 // Toggling between "all pages"/"some pages" radio buttons while having an |
| 278 // invalid entry in the page selection textfield still requires updating | 278 // invalid entry in the page selection textfield still requires updating |
| 279 // the print summary and print button. | 279 // the print summary and print button. |
| 280 if (!this.isPageSelectionValid() || !this.hasPageSelectionChanged_()) { | 280 if (!this.isPageSelectionValid() || !this.hasPageSelectionChanged_()) { |
| 281 cr.dispatchSimpleEvent(document, 'updateSummary'); | 281 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
| 282 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 282 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); |
| 283 return; | 283 return; |
| 284 } | 284 } |
| 285 requestPrintPreview(); | 285 requestPrintPreview(); |
| 286 }, | 286 }, |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * Whenever |this.selectedPagesTextfield| gains focus we add a timer to | 289 * Whenever |this.selectedPagesTextfield| gains focus we add a timer to |
| 290 * detect when the user stops typing in order to update the print preview. | 290 * detect when the user stops typing in order to update the print preview. |
| 291 * @private | 291 * @private |
| 292 */ | 292 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 this.addTimerToSelectedPagesTextfield_.bind(this); | 357 this.addTimerToSelectedPagesTextfield_.bind(this); |
| 358 this.selectedPagesTextfield.onblur = | 358 this.selectedPagesTextfield.onblur = |
| 359 this.onSelectedPagesTextfieldBlur_.bind(this); | 359 this.onSelectedPagesTextfieldBlur_.bind(this); |
| 360 } | 360 } |
| 361 }; | 361 }; |
| 362 | 362 |
| 363 return { | 363 return { |
| 364 PageSettings: PageSettings, | 364 PageSettings: PageSettings, |
| 365 }; | 365 }; |
| 366 }); | 366 }); |
| OLD | NEW |