Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // TODO(rltoscano): Maybe clear print ticket when destination changes. Or | 8 // TODO(rltoscano): Maybe clear print ticket when destination changes. Or |
| 9 // better yet, carry over any print ticket state that is possible. I.e. if | 9 // better yet, carry over any print ticket state that is possible. I.e. if |
| 10 // destination changes, the new destination might not support duplex anymore, | 10 // destination changes, the new destination might not support duplex anymore, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 */ | 298 */ |
| 299 init: function( | 299 init: function( |
| 300 thousandsDelimeter, decimalDelimeter, unitType, selectionOnly) { | 300 thousandsDelimeter, decimalDelimeter, unitType, selectionOnly) { |
| 301 this.measurementSystem_.setSystem(thousandsDelimeter, decimalDelimeter, | 301 this.measurementSystem_.setSystem(thousandsDelimeter, decimalDelimeter, |
| 302 unitType); | 302 unitType); |
| 303 this.selectionOnly_.updateValue(selectionOnly); | 303 this.selectionOnly_.updateValue(selectionOnly); |
| 304 | 304 |
| 305 // Initialize ticket with user's previous values. | 305 // Initialize ticket with user's previous values. |
| 306 if (this.appState_.hasField( | 306 if (this.appState_.hasField( |
| 307 print_preview.AppState.Field.IS_COLOR_ENABLED)) { | 307 print_preview.AppState.Field.IS_COLOR_ENABLED)) { |
| 308 this.color_.updateValue(this.appState_.getField( | 308 this.color_.updateValue( |
| 309 print_preview.AppState.Field.IS_COLOR_ENABLED)); | 309 /** @type {!Object} */(this.appState_.getField( |
| 310 print_preview.AppState.Field.IS_COLOR_ENABLED))); | |
| 310 } | 311 } |
| 311 if (this.appState_.hasField( | 312 if (this.appState_.hasField( |
| 312 print_preview.AppState.Field.IS_DUPLEX_ENABLED)) { | 313 print_preview.AppState.Field.IS_DUPLEX_ENABLED)) { |
| 313 this.duplex_.updateValue(this.appState_.getField( | 314 this.duplex_.updateValue( |
| 314 print_preview.AppState.Field.IS_DUPLEX_ENABLED)); | 315 /** @type {!Object} */(this.appState_.getField( |
| 316 print_preview.AppState.Field.IS_DUPLEX_ENABLED))); | |
| 315 } | 317 } |
| 316 if (this.appState_.hasField(print_preview.AppState.Field.MEDIA_SIZE)) { | 318 if (this.appState_.hasField(print_preview.AppState.Field.MEDIA_SIZE)) { |
| 317 this.mediaSize_.updateValue(this.appState_.getField( | 319 this.mediaSize_.updateValue( |
| 318 print_preview.AppState.Field.MEDIA_SIZE)); | 320 /** @type {!Object} */(this.appState_.getField( |
| 321 print_preview.AppState.Field.MEDIA_SIZE))); | |
| 319 } | 322 } |
| 320 if (this.appState_.hasField( | 323 if (this.appState_.hasField( |
| 321 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)) { | 324 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)) { |
| 322 this.landscape_.updateValue(this.appState_.getField( | 325 this.landscape_.updateValue( |
| 323 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)); | 326 /** @type {!Object} */(this.appState_.getField( |
| 327 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED))); | |
| 324 } | 328 } |
| 325 // Initialize margins after landscape because landscape may reset margins. | 329 // Initialize margins after landscape because landscape may reset margins. |
| 326 if (this.appState_.hasField(print_preview.AppState.Field.MARGINS_TYPE)) { | 330 if (this.appState_.hasField(print_preview.AppState.Field.MARGINS_TYPE)) { |
| 327 this.marginsType_.updateValue( | 331 this.marginsType_.updateValue( |
| 328 this.appState_.getField(print_preview.AppState.Field.MARGINS_TYPE)); | 332 /** @type {!Object} */(this.appState_.getField( |
| 333 print_preview.AppState.Field.MARGINS_TYPE))); | |
| 329 } | 334 } |
| 330 if (this.appState_.hasField( | 335 if (this.appState_.hasField( |
| 331 print_preview.AppState.Field.CUSTOM_MARGINS)) { | 336 print_preview.AppState.Field.CUSTOM_MARGINS)) { |
| 332 this.customMargins_.updateValue(this.appState_.getField( | 337 this.customMargins_.updateValue( |
| 333 print_preview.AppState.Field.CUSTOM_MARGINS)); | 338 /** @type {!Object} */(this.appState_.getField( |
| 339 print_preview.AppState.Field.CUSTOM_MARGINS))); | |
| 334 } | 340 } |
| 335 if (this.appState_.hasField( | 341 if (this.appState_.hasField( |
| 336 print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)) { | 342 print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)) { |
| 337 this.headerFooter_.updateValue(this.appState_.getField( | 343 this.headerFooter_.updateValue( |
| 338 print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)); | 344 /** @type {!Object} */(this.appState_.getField( |
| 345 print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED))); | |
| 339 } | 346 } |
| 340 if (this.appState_.hasField( | 347 if (this.appState_.hasField( |
| 341 print_preview.AppState.Field.IS_COLLATE_ENABLED)) { | 348 print_preview.AppState.Field.IS_COLLATE_ENABLED)) { |
| 342 this.collate_.updateValue(this.appState_.getField( | 349 this.collate_.updateValue( |
| 343 print_preview.AppState.Field.IS_COLLATE_ENABLED)); | 350 /** @type {!Object} */(this.appState_.getField( |
| 351 print_preview.AppState.Field.IS_COLLATE_ENABLED))); | |
| 344 } | 352 } |
| 345 if (this.appState_.hasField( | 353 if (this.appState_.hasField( |
| 346 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) { | 354 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) { |
| 347 this.cssBackground_.updateValue(this.appState_.getField( | 355 this.cssBackground_.updateValue( |
| 348 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)); | 356 /** @type {!Object} */(this.appState_.getField( |
| 357 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED))); | |
| 349 } | 358 } |
| 350 if (this.appState_.hasField( | 359 if (this.appState_.hasField( |
| 351 print_preview.AppState.Field.VENDOR_OPTIONS)) { | 360 print_preview.AppState.Field.VENDOR_OPTIONS)) { |
| 352 this.vendorItems_.updateValue(this.appState_.getField( | 361 this.vendorItems_.updateValue( |
| 353 print_preview.AppState.Field.VENDOR_OPTIONS)); | 362 /** @type {!Object.<string,string>} */(this.appState_.getField( |
|
Aleksey Shlyapnikov
2014/09/22 22:00:40
Space after comma.
Vitaly Pavlenko
2014/09/22 22:33:11
Done.
| |
| 363 print_preview.AppState.Field.VENDOR_OPTIONS))); | |
| 354 } | 364 } |
| 355 }, | 365 }, |
| 356 | 366 |
| 357 /** | 367 /** |
| 358 * @return {boolean} {@code true} if the stored print ticket is valid, | 368 * @return {boolean} {@code true} if the stored print ticket is valid, |
| 359 * {@code false} otherwise. | 369 * {@code false} otherwise. |
| 360 */ | 370 */ |
| 361 isTicketValid: function() { | 371 isTicketValid: function() { |
| 362 return this.isTicketValidForPreview() && | 372 return this.isTicketValidForPreview() && |
| 363 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && | 373 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 onDocumentInfoChange_: function() { | 528 onDocumentInfoChange_: function() { |
| 519 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 529 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
| 520 }, | 530 }, |
| 521 }; | 531 }; |
| 522 | 532 |
| 523 // Export | 533 // Export |
| 524 return { | 534 return { |
| 525 PrintTicketStore: PrintTicketStore | 535 PrintTicketStore: PrintTicketStore |
| 526 }; | 536 }; |
| 527 }); | 537 }); |
| OLD | NEW |