| 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, |
| 11 // so we should clear the ticket's isDuplexEnabled state. | 11 // so we should clear the ticket's isDuplexEnabled state. |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Storage of the print ticket and document statistics. Dispatches events when | 14 * Storage of the print ticket and document statistics. Dispatches events when |
| 15 * the contents of the print ticket or document statistics change. Also | 15 * the contents of the print ticket or document statistics change. Also |
| 16 * handles validation of the print ticket against destination capabilities and | 16 * handles validation of the print ticket against destination capabilities and |
| 17 * against the document. | 17 * against the document. |
| 18 * @param {!print_preview.DestinationStore} destinationStore Used to | 18 * @param {!print_preview.DestinationStore} destinationStore Used to |
| 19 * understand which printer is selected. | 19 * understand which printer is selected. |
| 20 * @param {!print_preview.AppState} appState Print preview application state. |
| 20 * @constructor | 21 * @constructor |
| 21 * @extends {cr.EventTarget} | 22 * @extends {cr.EventTarget} |
| 22 */ | 23 */ |
| 23 function PrintTicketStore(destinationStore) { | 24 function PrintTicketStore(destinationStore, appState) { |
| 24 cr.EventTarget.call(this); | 25 cr.EventTarget.call(this); |
| 25 | 26 |
| 26 /** | 27 /** |
| 27 * Destination store used to understand which printer is selected. | 28 * Destination store used to understand which printer is selected. |
| 28 * @type {!print_preview.DestinationStore} | 29 * @type {!print_preview.DestinationStore} |
| 29 * @private | 30 * @private |
| 30 */ | 31 */ |
| 31 this.destinationStore_ = destinationStore; | 32 this.destinationStore_ = destinationStore; |
| 32 | 33 |
| 34 /** |
| 35 * App state used to persist and load ticket values. |
| 36 * @type {!print_preview.AppState} |
| 37 * @private |
| 38 */ |
| 39 this.appState_ = appState; |
| 40 |
| 33 // Create the document info with some initial settings. Actual | 41 // Create the document info with some initial settings. Actual |
| 34 // page-related information won't be set until preview generation occurs, | 42 // page-related information won't be set until preview generation occurs, |
| 35 // so we'll use some defaults until then. This way, the print ticket store | 43 // so we'll use some defaults until then. This way, the print ticket store |
| 36 // will be valid even if no preview can be generated. | 44 // will be valid even if no preview can be generated. |
| 37 var initialPageSize = new print_preview.Size(612, 792); // 8.5"x11" | 45 var initialPageSize = new print_preview.Size(612, 792); // 8.5"x11" |
| 38 | 46 |
| 39 /** | 47 /** |
| 40 * Information about the document to print. | 48 * Information about the document to print. |
| 41 * @type {!print_preview.DocumentInfo} | 49 * @type {!print_preview.DocumentInfo} |
| 42 * @private | 50 * @private |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 */ | 252 */ |
| 245 getDocumentMargins: function() { | 253 getDocumentMargins: function() { |
| 246 return this.documentInfo_.margins; | 254 return this.documentInfo_.margins; |
| 247 }, | 255 }, |
| 248 | 256 |
| 249 /** | 257 /** |
| 250 * Initializes the print ticket store. Dispatches an INITIALIZE event. | 258 * Initializes the print ticket store. Dispatches an INITIALIZE event. |
| 251 * @param {boolean} isDocumentModifiable Whether the document to print is | 259 * @param {boolean} isDocumentModifiable Whether the document to print is |
| 252 * modifiable (i.e. can be re-flowed by Chromium). | 260 * modifiable (i.e. can be re-flowed by Chromium). |
| 253 * @param {string} documentTitle Title of the document to print. | 261 * @param {string} documentTitle Title of the document to print. |
| 254 * @param {?boolean} isDuplexEnabled Previous duplex setting. | |
| 255 * @param {?boolean} isHeaderFooterEnabled Previous header-footer setting. | |
| 256 * @param {print_preview.ticket_items.MarginsType.Value} marginsType | |
| 257 * Previous margins type. | |
| 258 * @param {print_preview.Margins} customMargins Previous custom margins. | |
| 259 * @param {string} thousandsDelimeter Delimeter of the thousands place. | 262 * @param {string} thousandsDelimeter Delimeter of the thousands place. |
| 260 * @param {string} decimalDelimeter Delimeter of the decimal point. | 263 * @param {string} decimalDelimeter Delimeter of the decimal point. |
| 261 * @param {!print_preview.MeasurementSystem.UnitType} unitType Type of unit | 264 * @param {!print_preview.MeasurementSystem.UnitType} unitType Type of unit |
| 262 * of the local measurement system. | 265 * of the local measurement system. |
| 263 */ | 266 */ |
| 264 initialize: function( | 267 init: function( |
| 265 isDocumentModifiable, | 268 isDocumentModifiable, |
| 266 documentTitle, | 269 documentTitle, |
| 267 isDuplexEnabled, | |
| 268 isHeaderFooterEnabled, | |
| 269 marginsType, | |
| 270 customMargins, | |
| 271 thousandsDelimeter, | 270 thousandsDelimeter, |
| 272 decimalDelimeter, | 271 decimalDelimeter, |
| 273 unitType) { | 272 unitType) { |
| 274 | 273 |
| 275 this.documentInfo_.isModifiable = isDocumentModifiable; | 274 this.documentInfo_.isModifiable = isDocumentModifiable; |
| 276 this.documentInfo_.title = documentTitle; | 275 this.documentInfo_.title = documentTitle; |
| 277 this.measurementSystem_.setSystem( | 276 this.measurementSystem_.setSystem( |
| 278 thousandsDelimeter, decimalDelimeter, unitType); | 277 thousandsDelimeter, decimalDelimeter, unitType); |
| 279 | 278 |
| 280 // Initialize ticket with user's previous values. | 279 // Initialize ticket with user's previous values. |
| 281 this.duplex_.updateValue(isDuplexEnabled); | 280 this.marginsType_.updateValue(this.appState_.marginsType); |
| 282 this.headerFooter_.updateValue(isHeaderFooterEnabled); | 281 this.customMargins_.updateValue(this.appState_.customMargins); |
| 283 if (marginsType != null) { | 282 this.color_.updateValue(this.appState_.isColorEnabled); |
| 284 this.marginsType_.updateValue(marginsType); | 283 this.duplex_.updateValue(this.appState_.isDuplexEnabled); |
| 285 } | 284 this.headerFooter_.updateValue(this.appState_.isHeaderFooterEnabled); |
| 286 if (customMargins != null) { | 285 this.landscape_.updateValue(this.appState_.isLandscapeEnabled); |
| 287 this.customMargins_.updateValue(customMargins); | 286 this.collate_.updateValue(this.appState_.isCollateEnabled); |
| 288 } | |
| 289 }, | 287 }, |
| 290 | 288 |
| 291 /** @return {boolean} Whether the ticket store has the copies capability. */ | 289 /** @return {boolean} Whether the ticket store has the copies capability. */ |
| 292 hasCopiesCapability: function() { | 290 hasCopiesCapability: function() { |
| 293 return this.copies_.isCapabilityAvailable(); | 291 return this.copies_.isCapabilityAvailable(); |
| 294 }, | 292 }, |
| 295 | 293 |
| 296 /** | 294 /** |
| 297 * @return {boolean} Whether the string representation of the copies value | 295 * @return {boolean} Whether the string representation of the copies value |
| 298 * currently in the ticket store is valid. | 296 * currently in the ticket store is valid. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 }, | 339 }, |
| 342 | 340 |
| 343 /** | 341 /** |
| 344 * Updates whether collate is enabled. Dispatches a TICKET_CHANGE event if | 342 * Updates whether collate is enabled. Dispatches a TICKET_CHANGE event if |
| 345 * collate has changed. | 343 * collate has changed. |
| 346 * @param {boolean} isCollateEnabled Whether collate is enabled. | 344 * @param {boolean} isCollateEnabled Whether collate is enabled. |
| 347 */ | 345 */ |
| 348 updateCollate: function(isCollateEnabled) { | 346 updateCollate: function(isCollateEnabled) { |
| 349 if (this.collate_.getValue() != isCollateEnabled) { | 347 if (this.collate_.getValue() != isCollateEnabled) { |
| 350 this.collate_.updateValue(isCollateEnabled); | 348 this.collate_.updateValue(isCollateEnabled); |
| 349 this.appState_.persistIsCollateEnabled(isCollateEnabled); |
| 351 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 350 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 352 } | 351 } |
| 353 }, | 352 }, |
| 354 | 353 |
| 355 /** | 354 /** |
| 356 * @return {boolean} Whether the ticket store has color printing capability. | 355 * @return {boolean} Whether the ticket store has color printing capability. |
| 357 */ | 356 */ |
| 358 hasColorCapability: function() { | 357 hasColorCapability: function() { |
| 359 return this.color_.isCapabilityAvailable(); | 358 return this.color_.isCapabilityAvailable(); |
| 360 }, | 359 }, |
| 361 | 360 |
| 362 /** @return {boolean} Whether color printing is enabled. */ | 361 /** @return {boolean} Whether color printing is enabled. */ |
| 363 isColorEnabled: function() { | 362 isColorEnabled: function() { |
| 364 return this.color_.getValue(); | 363 return this.color_.getValue(); |
| 365 }, | 364 }, |
| 366 | 365 |
| 367 /** | 366 /** |
| 368 * Updates whether color printing is enabled. Dispatches a TICKET_CHANGE if | 367 * Updates whether color printing is enabled. Dispatches a TICKET_CHANGE if |
| 369 * color has changed. | 368 * color has changed. |
| 370 * @param {boolean} isColorEnabled Whether the color printing is enabled. | 369 * @param {boolean} isColorEnabled Whether the color printing is enabled. |
| 371 */ | 370 */ |
| 372 updateColor: function(isColorEnabled) { | 371 updateColor: function(isColorEnabled) { |
| 373 if (this.color_.getValue() != isColorEnabled) { | 372 if (this.color_.getValue() != isColorEnabled) { |
| 374 this.color_.updateValue(isColorEnabled); | 373 this.color_.updateValue(isColorEnabled); |
| 374 this.appState_.persistIsColorEnabled(isColorEnabled); |
| 375 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 375 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 376 } | 376 } |
| 377 }, | 377 }, |
| 378 | 378 |
| 379 /** @return {boolean} Whether the header-footer capability is available. */ | 379 /** @return {boolean} Whether the header-footer capability is available. */ |
| 380 hasHeaderFooterCapability: function() { | 380 hasHeaderFooterCapability: function() { |
| 381 return this.headerFooter_.isCapabilityAvailable(); | 381 return this.headerFooter_.isCapabilityAvailable(); |
| 382 }, | 382 }, |
| 383 | 383 |
| 384 /** @return {boolean} Whether the header-footer setting is enabled. */ | 384 /** @return {boolean} Whether the header-footer setting is enabled. */ |
| 385 isHeaderFooterEnabled: function() { | 385 isHeaderFooterEnabled: function() { |
| 386 return this.headerFooter_.getValue(); | 386 return this.headerFooter_.getValue(); |
| 387 }, | 387 }, |
| 388 | 388 |
| 389 /** | 389 /** |
| 390 * Updates the whether the header-footer setting is enabled. Dispatches a | 390 * Updates the whether the header-footer setting is enabled. Dispatches a |
| 391 * TICKET_CHANGE event if the setting changed. | 391 * TICKET_CHANGE event if the setting changed. |
| 392 * @param {boolean} isHeaderFooterEnabled Whether the header-footer setting | 392 * @param {boolean} isHeaderFooterEnabled Whether the header-footer setting |
| 393 * is enabled. | 393 * is enabled. |
| 394 */ | 394 */ |
| 395 updateHeaderFooter: function(isHeaderFooterEnabled) { | 395 updateHeaderFooter: function(isHeaderFooterEnabled) { |
| 396 if (this.headerFooter_.getValue() != isHeaderFooterEnabled) { | 396 if (this.headerFooter_.getValue() != isHeaderFooterEnabled) { |
| 397 this.headerFooter_.updateValue(isHeaderFooterEnabled); | 397 this.headerFooter_.updateValue(isHeaderFooterEnabled); |
| 398 this.appState_.persistIsHeaderFooterEnabled(isHeaderFooterEnabled); |
| 398 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 399 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 399 } | 400 } |
| 400 }, | 401 }, |
| 401 | 402 |
| 402 /** | 403 /** |
| 403 * @return {boolean} Whether the page orientation capability is available. | 404 * @return {boolean} Whether the page orientation capability is available. |
| 404 */ | 405 */ |
| 405 hasOrientationCapability: function() { | 406 hasOrientationCapability: function() { |
| 406 return this.landscape_.isCapabilityAvailable(); | 407 return this.landscape_.isCapabilityAvailable(); |
| 407 }, | 408 }, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 419 * @param {boolean} isLandscapeEnabled Whether the document should be | 420 * @param {boolean} isLandscapeEnabled Whether the document should be |
| 420 * printed in landscape. | 421 * printed in landscape. |
| 421 */ | 422 */ |
| 422 updateOrientation: function(isLandscapeEnabled) { | 423 updateOrientation: function(isLandscapeEnabled) { |
| 423 if (this.landscape_.getValue() != isLandscapeEnabled) { | 424 if (this.landscape_.getValue() != isLandscapeEnabled) { |
| 424 this.landscape_.updateValue(isLandscapeEnabled); | 425 this.landscape_.updateValue(isLandscapeEnabled); |
| 425 // Reset the user set margins. | 426 // Reset the user set margins. |
| 426 this.marginsType_.updateValue( | 427 this.marginsType_.updateValue( |
| 427 print_preview.ticket_items.MarginsType.Value.DEFAULT); | 428 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
| 428 this.customMargins_.updateValue(null); | 429 this.customMargins_.updateValue(null); |
| 430 this.appState_.persistMarginsType( |
| 431 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
| 432 this.appState_.persistCustomMargins(null); |
| 433 this.appState_.persistIsLandscapeEnabled(isLandscapeEnabled); |
| 429 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 434 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 430 } | 435 } |
| 431 }, | 436 }, |
| 432 | 437 |
| 433 /** @return {boolean} Whether the duplexing capability is available. */ | 438 /** @return {boolean} Whether the duplexing capability is available. */ |
| 434 hasDuplexCapability: function() { | 439 hasDuplexCapability: function() { |
| 435 return this.duplex_.isCapabilityAvailable(); | 440 return this.duplex_.isCapabilityAvailable(); |
| 436 }, | 441 }, |
| 437 | 442 |
| 438 /** @return {boolean} Whether the document should be printed in duplex. */ | 443 /** @return {boolean} Whether the document should be printed in duplex. */ |
| 439 isDuplexEnabled: function() { | 444 isDuplexEnabled: function() { |
| 440 return this.duplex_.getValue(); | 445 return this.duplex_.getValue(); |
| 441 }, | 446 }, |
| 442 | 447 |
| 443 /** | 448 /** |
| 444 * Updates the duplexing setting. Dispatches a TICKET_CHANGE event if the | 449 * Updates the duplexing setting. Dispatches a TICKET_CHANGE event if the |
| 445 * value changes. | 450 * value changes. |
| 446 * @param {boolean} isDuplexEnabled Whether the document should be printed | 451 * @param {boolean} isDuplexEnabled Whether the document should be printed |
| 447 * in duplex. | 452 * in duplex. |
| 448 */ | 453 */ |
| 449 updateDuplex: function(isDuplexEnabled) { | 454 updateDuplex: function(isDuplexEnabled) { |
| 450 if (this.duplex_.getValue() != isDuplexEnabled) { | 455 if (this.duplex_.getValue() != isDuplexEnabled) { |
| 451 this.duplex_.updateValue(isDuplexEnabled); | 456 this.duplex_.updateValue(isDuplexEnabled); |
| 457 this.appState_.persistIsDuplexEnabled(isDuplexEnabled); |
| 452 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 458 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 453 } | 459 } |
| 454 }, | 460 }, |
| 455 | 461 |
| 456 /** @return {boolean} Whether the margins capability is available. */ | 462 /** @return {boolean} Whether the margins capability is available. */ |
| 457 hasMarginsCapability: function() { | 463 hasMarginsCapability: function() { |
| 458 return this.marginsType_.isCapabilityAvailable(); | 464 return this.marginsType_.isCapabilityAvailable(); |
| 459 }, | 465 }, |
| 460 | 466 |
| 461 /** | 467 /** |
| 462 * @return {!print_preview.ticket_items.MarginsType.Value} Type of | 468 * @return {!print_preview.ticket_items.MarginsType.Value} Type of |
| 463 * predefined margins. | 469 * predefined margins. |
| 464 */ | 470 */ |
| 465 getMarginsType: function() { | 471 getMarginsType: function() { |
| 466 return this.marginsType_.getValue(); | 472 return this.marginsType_.getValue(); |
| 467 }, | 473 }, |
| 468 | 474 |
| 469 /** | 475 /** |
| 470 * Updates the type of predefined margins. Dispatches a TICKET_CHANGE event | 476 * Updates the type of predefined margins. Dispatches a TICKET_CHANGE event |
| 471 * if the margins type changes. | 477 * if the margins type changes. |
| 472 * @param {print_preview.ticket_items.MarginsType.Value} marginsType Type of | 478 * @param {print_preview.ticket_items.MarginsType.Value} marginsType Type of |
| 473 * predefined margins. | 479 * predefined margins. |
| 474 */ | 480 */ |
| 475 updateMarginsType: function(marginsType) { | 481 updateMarginsType: function(marginsType) { |
| 476 if (this.marginsType_.getValue() != marginsType) { | 482 if (this.marginsType_.getValue() != marginsType) { |
| 477 this.marginsType_.updateValue(marginsType); | 483 this.marginsType_.updateValue(marginsType); |
| 484 this.appState_.persistMarginsType(marginsType); |
| 478 if (marginsType == | 485 if (marginsType == |
| 479 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 486 print_preview.ticket_items.MarginsType.Value.CUSTOM) { |
| 480 // If CUSTOM, set the value of the custom margins so that it won't be | 487 // If CUSTOM, set the value of the custom margins so that it won't be |
| 481 // overridden by the default value. | 488 // overridden by the default value. |
| 482 this.customMargins_.updateValue(this.customMargins_.getValue()); | 489 this.customMargins_.updateValue(this.customMargins_.getValue()); |
| 490 this.appState_.persistCustomMargins(this.customMargins_.getValue()); |
| 483 } | 491 } |
| 484 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 492 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 485 } | 493 } |
| 486 }, | 494 }, |
| 487 | 495 |
| 488 /** @return {boolean} Whether all of the custom margins are valid. */ | 496 /** @return {boolean} Whether all of the custom margins are valid. */ |
| 489 isCustomMarginsValid: function() { | 497 isCustomMarginsValid: function() { |
| 490 return this.customMargins_.isValid(); | 498 return this.customMargins_.isValid(); |
| 491 }, | 499 }, |
| 492 | 500 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 510 /** | 518 /** |
| 511 * Updates the custom margins of the document. Dispatches a TICKET_CHANGE | 519 * Updates the custom margins of the document. Dispatches a TICKET_CHANGE |
| 512 * event if the margins have changed. | 520 * event if the margins have changed. |
| 513 * @param {!print_preview.Margins} margins New document page margins in | 521 * @param {!print_preview.Margins} margins New document page margins in |
| 514 * points. | 522 * points. |
| 515 */ | 523 */ |
| 516 updateCustomMargins: function(margins) { | 524 updateCustomMargins: function(margins) { |
| 517 if (!this.isCustomMarginsValid() || | 525 if (!this.isCustomMarginsValid() || |
| 518 !margins.equals(this.getCustomMargins())) { | 526 !margins.equals(this.getCustomMargins())) { |
| 519 this.customMargins_.updateValue(margins); | 527 this.customMargins_.updateValue(margins); |
| 528 this.appState_.persistCustomMargins(margins); |
| 520 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 529 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 521 } | 530 } |
| 522 }, | 531 }, |
| 523 | 532 |
| 524 /** | 533 /** |
| 525 * Updates a single custom margin's value in points. | 534 * Updates a single custom margin's value in points. |
| 526 * @param {!print_preview.ticket_items.CustomMargins.Orientation} | 535 * @param {!print_preview.ticket_items.CustomMargins.Orientation} |
| 527 * orientation Specifies the margin to update. | 536 * orientation Specifies the margin to update. |
| 528 * @param {number} value Updated margin in points. | 537 * @param {number} value Updated margin in points. |
| 529 */ | 538 */ |
| 530 updateCustomMargin: function(orientation, value) { | 539 updateCustomMargin: function(orientation, value) { |
| 531 if (this.customMargins_.getValue().get(orientation) != value) { | 540 if (this.customMargins_.getValue().get(orientation) != value) { |
| 532 this.customMargins_.updateMargin(orientation, value); | 541 this.customMargins_.updateMargin(orientation, value); |
| 542 this.appState_.persistCustomMargins(this.customMargins_.getValue()); |
| 533 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 543 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 534 } | 544 } |
| 535 }, | 545 }, |
| 536 | 546 |
| 537 /** @return {boolean} Whether the page range capability is available. */ | 547 /** @return {boolean} Whether the page range capability is available. */ |
| 538 hasPageRangeCapability: function() { | 548 hasPageRangeCapability: function() { |
| 539 return this.pageRange_.isCapabilityAvailable(); | 549 return this.pageRange_.isCapabilityAvailable(); |
| 540 }, | 550 }, |
| 541 | 551 |
| 542 /** | 552 /** |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 * @private | 638 * @private |
| 629 */ | 639 */ |
| 630 onSelectedDestinationCapabilitiesReady_: function() { | 640 onSelectedDestinationCapabilitiesReady_: function() { |
| 631 var caps = this.destinationStore_.selectedDestination.capabilities; | 641 var caps = this.destinationStore_.selectedDestination.capabilities; |
| 632 var isFirstUpdate = this.capabilitiesHolder_.get() == null; | 642 var isFirstUpdate = this.capabilitiesHolder_.get() == null; |
| 633 this.capabilitiesHolder_.set(caps); | 643 this.capabilitiesHolder_.set(caps); |
| 634 if (isFirstUpdate) { | 644 if (isFirstUpdate) { |
| 635 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); | 645 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); |
| 636 } else { | 646 } else { |
| 637 // Reset user selection for certain ticket items. | 647 // Reset user selection for certain ticket items. |
| 638 this.duplex_.updateValue(null); | |
| 639 this.customMargins_.updateValue(null); | 648 this.customMargins_.updateValue(null); |
| 649 this.appState_.persistCustomMargins(null); |
| 640 | 650 |
| 641 if (this.marginsType_.getValue() == | 651 if (this.marginsType_.getValue() == |
| 642 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 652 print_preview.ticket_items.MarginsType.Value.CUSTOM) { |
| 643 this.marginsType_.updateValue( | 653 this.marginsType_.updateValue( |
| 644 print_preview.ticket_items.MarginsType.Value.DEFAULT); | 654 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
| 655 this.appState_.persistMarginsType( |
| 656 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
| 645 } | 657 } |
| 646 cr.dispatchSimpleEvent( | 658 cr.dispatchSimpleEvent( |
| 647 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); | 659 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); |
| 648 } | 660 } |
| 649 } | 661 } |
| 650 }; | 662 }; |
| 651 | 663 |
| 652 // Export | 664 // Export |
| 653 return { | 665 return { |
| 654 PrintTicketStore: PrintTicketStore | 666 PrintTicketStore: PrintTicketStore |
| 655 }; | 667 }; |
| 656 }); | 668 }); |
| OLD | NEW |