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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 */ | 140 */ |
141 this.marginsType_ = new print_preview.ticket_items.MarginsType( | 141 this.marginsType_ = new print_preview.ticket_items.MarginsType( |
142 this.appState_, this.documentInfo_, this.customMargins_); | 142 this.appState_, this.documentInfo_, this.customMargins_); |
143 | 143 |
144 /** | 144 /** |
145 * Media size ticket item. | 145 * Media size ticket item. |
146 * @type {!print_preview.ticket_items.MediaSize} | 146 * @type {!print_preview.ticket_items.MediaSize} |
147 * @private | 147 * @private |
148 */ | 148 */ |
149 this.mediaSize_ = new print_preview.ticket_items.MediaSize( | 149 this.mediaSize_ = new print_preview.ticket_items.MediaSize( |
150 this.appState_, | 150 this.appState_, this.destinationStore_, this.documentInfo_, |
151 this.destinationStore_, | 151 this.marginsType_, this.customMargins_); |
152 this.documentInfo_, | |
153 this.marginsType_, | |
154 this.customMargins_); | |
155 | 152 |
156 /** | 153 /** |
157 * Landscape ticket item. | 154 * Landscape ticket item. |
158 * @type {!print_preview.ticket_items.Landscape} | 155 * @type {!print_preview.ticket_items.Landscape} |
159 * @private | 156 * @private |
160 */ | 157 */ |
161 this.landscape_ = new print_preview.ticket_items.Landscape( | 158 this.landscape_ = new print_preview.ticket_items.Landscape( |
162 this.appState_, | 159 this.appState_, this.destinationStore_, this.documentInfo_, |
163 this.destinationStore_, | 160 this.marginsType_, this.customMargins_); |
164 this.documentInfo_, | |
165 this.marginsType_, | |
166 this.customMargins_); | |
167 | 161 |
168 /** | 162 /** |
169 * Header-footer ticket item. | 163 * Header-footer ticket item. |
170 * @type {!print_preview.ticket_items.HeaderFooter} | 164 * @type {!print_preview.ticket_items.HeaderFooter} |
171 * @private | 165 * @private |
172 */ | 166 */ |
173 this.headerFooter_ = new print_preview.ticket_items.HeaderFooter( | 167 this.headerFooter_ = new print_preview.ticket_items.HeaderFooter( |
174 this.appState_, | 168 this.appState_, this.documentInfo_, this.marginsType_, |
175 this.documentInfo_, | 169 this.customMargins_, this.mediaSize_, this.landscape_); |
176 this.marginsType_, | |
177 this.customMargins_, | |
178 this.mediaSize_, | |
179 this.landscape_); | |
180 | 170 |
181 /** | 171 /** |
182 * Fit-to-page ticket item. | 172 * Fit-to-page ticket item. |
183 * @type {!print_preview.ticket_items.FitToPage} | 173 * @type {!print_preview.ticket_items.FitToPage} |
184 * @private | 174 * @private |
185 */ | 175 */ |
186 this.fitToPage_ = new print_preview.ticket_items.FitToPage( | 176 this.fitToPage_ = new print_preview.ticket_items.FitToPage( |
187 this.appState_, this.documentInfo_, this.destinationStore_); | 177 this.appState_, this.documentInfo_, this.destinationStore_); |
188 | 178 |
189 /** | 179 /** |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 * Initializes the print ticket store. Dispatches an INITIALIZE event. | 319 * Initializes the print ticket store. Dispatches an INITIALIZE event. |
330 * @param {string} thousandsDelimeter Delimeter of the thousands place. | 320 * @param {string} thousandsDelimeter Delimeter of the thousands place. |
331 * @param {string} decimalDelimeter Delimeter of the decimal point. | 321 * @param {string} decimalDelimeter Delimeter of the decimal point. |
332 * @param {!print_preview.MeasurementSystemUnitType} unitType Type of unit | 322 * @param {!print_preview.MeasurementSystemUnitType} unitType Type of unit |
333 * of the local measurement system. | 323 * of the local measurement system. |
334 * @param {boolean} selectionOnly Whether only selected content should be | 324 * @param {boolean} selectionOnly Whether only selected content should be |
335 * printed. | 325 * printed. |
336 */ | 326 */ |
337 init: function( | 327 init: function( |
338 thousandsDelimeter, decimalDelimeter, unitType, selectionOnly) { | 328 thousandsDelimeter, decimalDelimeter, unitType, selectionOnly) { |
339 this.measurementSystem_.setSystem(thousandsDelimeter, decimalDelimeter, | 329 this.measurementSystem_.setSystem( |
340 unitType); | 330 thousandsDelimeter, decimalDelimeter, unitType); |
341 this.selectionOnly_.updateValue(selectionOnly); | 331 this.selectionOnly_.updateValue(selectionOnly); |
342 | 332 |
343 // Initialize ticket with user's previous values. | 333 // Initialize ticket with user's previous values. |
344 if (this.appState_.hasField( | 334 if (this.appState_.hasField( |
345 print_preview.AppStateField.IS_COLOR_ENABLED)) { | 335 print_preview.AppStateField.IS_COLOR_ENABLED)) { |
346 this.color_.updateValue( | 336 this.color_.updateValue( |
347 /** @type {!Object} */(this.appState_.getField( | 337 /** @type {!Object} */ (this.appState_.getField( |
348 print_preview.AppStateField.IS_COLOR_ENABLED))); | 338 print_preview.AppStateField.IS_COLOR_ENABLED))); |
349 } | 339 } |
350 if (this.appState_.hasField(print_preview.AppStateField.DPI)) { | 340 if (this.appState_.hasField(print_preview.AppStateField.DPI)) { |
351 this.dpi_.updateValue( | 341 this.dpi_.updateValue( |
352 /** @type {!Object} */(this.appState_.getField( | 342 /** @type {!Object} */ ( |
353 print_preview.AppStateField.DPI))); | 343 this.appState_.getField(print_preview.AppStateField.DPI))); |
354 } | 344 } |
355 if (this.appState_.hasField( | 345 if (this.appState_.hasField( |
356 print_preview.AppStateField.IS_DUPLEX_ENABLED)) { | 346 print_preview.AppStateField.IS_DUPLEX_ENABLED)) { |
357 this.duplex_.updateValue( | 347 this.duplex_.updateValue( |
358 /** @type {!Object} */(this.appState_.getField( | 348 /** @type {!Object} */ (this.appState_.getField( |
359 print_preview.AppStateField.IS_DUPLEX_ENABLED))); | 349 print_preview.AppStateField.IS_DUPLEX_ENABLED))); |
360 } | 350 } |
361 if (this.appState_.hasField(print_preview.AppStateField.MEDIA_SIZE)) { | 351 if (this.appState_.hasField(print_preview.AppStateField.MEDIA_SIZE)) { |
362 this.mediaSize_.updateValue( | 352 this.mediaSize_.updateValue( |
363 /** @type {!Object} */(this.appState_.getField( | 353 /** @type {!Object} */ (this.appState_.getField( |
364 print_preview.AppStateField.MEDIA_SIZE))); | 354 print_preview.AppStateField.MEDIA_SIZE))); |
365 } | 355 } |
366 if (this.appState_.hasField( | 356 if (this.appState_.hasField( |
367 print_preview.AppStateField.IS_LANDSCAPE_ENABLED)) { | 357 print_preview.AppStateField.IS_LANDSCAPE_ENABLED)) { |
368 this.landscape_.updateValue( | 358 this.landscape_.updateValue( |
369 /** @type {!Object} */(this.appState_.getField( | 359 /** @type {!Object} */ (this.appState_.getField( |
370 print_preview.AppStateField.IS_LANDSCAPE_ENABLED))); | 360 print_preview.AppStateField.IS_LANDSCAPE_ENABLED))); |
371 } | 361 } |
372 // Initialize margins after landscape because landscape may reset margins. | 362 // Initialize margins after landscape because landscape may reset margins. |
373 if (this.appState_.hasField(print_preview.AppStateField.MARGINS_TYPE)) { | 363 if (this.appState_.hasField(print_preview.AppStateField.MARGINS_TYPE)) { |
374 this.marginsType_.updateValue( | 364 this.marginsType_.updateValue( |
375 /** @type {!Object} */(this.appState_.getField( | 365 /** @type {!Object} */ (this.appState_.getField( |
376 print_preview.AppStateField.MARGINS_TYPE))); | 366 print_preview.AppStateField.MARGINS_TYPE))); |
| 367 } |
| 368 if (this.appState_.hasField(print_preview.AppStateField.CUSTOM_MARGINS)) { |
| 369 this.customMargins_.updateValue( |
| 370 /** @type {!Object} */ (this.appState_.getField( |
| 371 print_preview.AppStateField.CUSTOM_MARGINS))); |
377 } | 372 } |
378 if (this.appState_.hasField( | 373 if (this.appState_.hasField( |
379 print_preview.AppStateField.CUSTOM_MARGINS)) { | 374 print_preview.AppStateField.IS_HEADER_FOOTER_ENABLED)) { |
380 this.customMargins_.updateValue( | 375 this.headerFooter_.updateValue( |
381 /** @type {!Object} */(this.appState_.getField( | 376 /** @type {!Object} */ (this.appState_.getField( |
382 print_preview.AppStateField.CUSTOM_MARGINS))); | 377 print_preview.AppStateField.IS_HEADER_FOOTER_ENABLED))); |
383 } | 378 } |
384 if (this.appState_.hasField( | 379 if (this.appState_.hasField( |
385 print_preview.AppStateField.IS_HEADER_FOOTER_ENABLED)) { | 380 print_preview.AppStateField.IS_COLLATE_ENABLED)) { |
386 this.headerFooter_.updateValue( | 381 this.collate_.updateValue( |
387 /** @type {!Object} */(this.appState_.getField( | 382 /** @type {!Object} */ (this.appState_.getField( |
388 print_preview.AppStateField.IS_HEADER_FOOTER_ENABLED))); | 383 print_preview.AppStateField.IS_COLLATE_ENABLED))); |
389 } | 384 } |
390 if (this.appState_.hasField( | 385 if (this.appState_.hasField( |
391 print_preview.AppStateField.IS_COLLATE_ENABLED)) { | 386 print_preview.AppStateField.IS_FIT_TO_PAGE_ENABLED)) { |
392 this.collate_.updateValue( | 387 this.fitToPage_.updateValue( |
393 /** @type {!Object} */(this.appState_.getField( | 388 /** @type {!Object} */ (this.appState_.getField( |
394 print_preview.AppStateField.IS_COLLATE_ENABLED))); | 389 print_preview.AppStateField.IS_FIT_TO_PAGE_ENABLED))); |
| 390 } |
| 391 if (this.appState_.hasField(print_preview.AppStateField.SCALING)) { |
| 392 this.scaling_.updateValue( |
| 393 /** @type {!Object} */ ( |
| 394 this.appState_.getField(print_preview.AppStateField.SCALING))); |
395 } | 395 } |
396 if (this.appState_.hasField( | 396 if (this.appState_.hasField( |
397 print_preview.AppStateField.IS_FIT_TO_PAGE_ENABLED)) { | 397 print_preview.AppStateField.IS_CSS_BACKGROUND_ENABLED)) { |
398 this.fitToPage_.updateValue( | 398 this.cssBackground_.updateValue( |
399 /** @type {!Object} */(this.appState_.getField( | 399 /** @type {!Object} */ (this.appState_.getField( |
400 print_preview.AppStateField.IS_FIT_TO_PAGE_ENABLED))); | 400 print_preview.AppStateField.IS_CSS_BACKGROUND_ENABLED))); |
401 } | 401 } |
402 if (this.appState_.hasField( | 402 if (this.appState_.hasField(print_preview.AppStateField.VENDOR_OPTIONS)) { |
403 print_preview.AppStateField.SCALING)) { | |
404 this.scaling_.updateValue( | |
405 /** @type {!Object} */(this.appState_.getField( | |
406 print_preview.AppStateField.SCALING))); | |
407 } | |
408 if (this.appState_.hasField( | |
409 print_preview.AppStateField.IS_CSS_BACKGROUND_ENABLED)) { | |
410 this.cssBackground_.updateValue( | |
411 /** @type {!Object} */(this.appState_.getField( | |
412 print_preview.AppStateField.IS_CSS_BACKGROUND_ENABLED))); | |
413 } | |
414 if (this.appState_.hasField( | |
415 print_preview.AppStateField.VENDOR_OPTIONS)) { | |
416 this.vendorItems_.updateValue( | 403 this.vendorItems_.updateValue( |
417 /** @type {!Object<string>} */(this.appState_.getField( | 404 /** @type {!Object<string>} */ (this.appState_.getField( |
418 print_preview.AppStateField.VENDOR_OPTIONS))); | 405 print_preview.AppStateField.VENDOR_OPTIONS))); |
419 } | 406 } |
420 }, | 407 }, |
421 | 408 |
422 /** | 409 /** |
423 * @return {boolean} {@code true} if the stored print ticket is valid, | 410 * @return {boolean} {@code true} if the stored print ticket is valid, |
424 * {@code false} otherwise. | 411 * {@code false} otherwise. |
425 */ | 412 */ |
426 isTicketValid: function() { | 413 isTicketValid: function() { |
427 return this.isTicketValidForPreview() && | 414 return this.isTicketValidForPreview() && |
428 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && | 415 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && |
429 (!this.pageRange_.isCapabilityAvailable() || | 416 (!this.pageRange_.isCapabilityAvailable() || |
430 this.pageRange_.isValid()); | 417 this.pageRange_.isValid()); |
431 }, | 418 }, |
432 | 419 |
433 /** @return {boolean} Whether the ticket is valid for preview generation. */ | 420 /** @return {boolean} Whether the ticket is valid for preview generation. */ |
434 isTicketValidForPreview: function() { | 421 isTicketValidForPreview: function() { |
435 return (!this.marginsType_.isCapabilityAvailable() || | 422 return ( |
436 !this.marginsType_.isValueEqual( | 423 !this.marginsType_.isCapabilityAvailable() || |
437 print_preview.ticket_items.MarginsTypeValue.CUSTOM) || | 424 !this.marginsType_.isValueEqual( |
438 this.customMargins_.isValid()); | 425 print_preview.ticket_items.MarginsTypeValue.CUSTOM) || |
| 426 this.customMargins_.isValid()); |
439 }, | 427 }, |
440 | 428 |
441 /** | 429 /** |
442 * Creates an object that represents a Google Cloud Print print ticket. | 430 * Creates an object that represents a Google Cloud Print print ticket. |
443 * @param {!print_preview.Destination} destination Destination to print to. | 431 * @param {!print_preview.Destination} destination Destination to print to. |
444 * @return {string} Google Cloud Print print ticket. | 432 * @return {string} Google Cloud Print print ticket. |
445 */ | 433 */ |
446 createPrintTicket: function(destination) { | 434 createPrintTicket: function(destination) { |
447 assert(!destination.isLocal || | 435 assert( |
448 destination.isPrivet || destination.isExtension, | 436 !destination.isLocal || destination.isPrivet || |
449 'Trying to create a Google Cloud Print print ticket for a local ' + | 437 destination.isExtension, |
450 ' non-privet and non-extension destination'); | 438 'Trying to create a Google Cloud Print print ticket for a local ' + |
| 439 ' non-privet and non-extension destination'); |
451 | 440 |
452 assert(destination.capabilities, | 441 assert( |
453 'Trying to create a Google Cloud Print print ticket for a ' + | 442 destination.capabilities, |
454 'destination with no print capabilities'); | 443 'Trying to create a Google Cloud Print print ticket for a ' + |
455 var cjt = { | 444 'destination with no print capabilities'); |
456 version: '1.0', | 445 var cjt = {version: '1.0', print: {}}; |
457 print: {} | |
458 }; | |
459 if (this.collate.isCapabilityAvailable() && this.collate.isUserEdited()) { | 446 if (this.collate.isCapabilityAvailable() && this.collate.isUserEdited()) { |
460 cjt.print.collate = {collate: this.collate.getValue()}; | 447 cjt.print.collate = {collate: this.collate.getValue()}; |
461 } | 448 } |
462 if (this.color.isCapabilityAvailable() && this.color.isUserEdited()) { | 449 if (this.color.isCapabilityAvailable() && this.color.isUserEdited()) { |
463 var selectedOption = this.color.getSelectedOption(); | 450 var selectedOption = this.color.getSelectedOption(); |
464 if (!selectedOption) { | 451 if (!selectedOption) { |
465 console.error('Could not find correct color option'); | 452 console.error('Could not find correct color option'); |
466 } else { | 453 } else { |
467 cjt.print.color = {type: selectedOption.type}; | 454 cjt.print.color = {type: selectedOption.type}; |
468 if (selectedOption.hasOwnProperty('vendor_id')) { | 455 if (selectedOption.hasOwnProperty('vendor_id')) { |
469 cjt.print.color.vendor_id = selectedOption.vendor_id; | 456 cjt.print.color.vendor_id = selectedOption.vendor_id; |
470 } | 457 } |
471 } | 458 } |
472 } | 459 } |
473 if (this.copies.isCapabilityAvailable() && this.copies.isUserEdited()) { | 460 if (this.copies.isCapabilityAvailable() && this.copies.isUserEdited()) { |
474 cjt.print.copies = {copies: this.copies.getValueAsNumber()}; | 461 cjt.print.copies = {copies: this.copies.getValueAsNumber()}; |
475 } | 462 } |
476 if (this.duplex.isCapabilityAvailable() && this.duplex.isUserEdited()) { | 463 if (this.duplex.isCapabilityAvailable() && this.duplex.isUserEdited()) { |
477 cjt.print.duplex = | 464 cjt.print.duplex = { |
478 {type: this.duplex.getValue() ? 'LONG_EDGE' : 'NO_DUPLEX'}; | 465 type: this.duplex.getValue() ? 'LONG_EDGE' : 'NO_DUPLEX' |
| 466 }; |
479 } | 467 } |
480 if (this.mediaSize.isCapabilityAvailable()) { | 468 if (this.mediaSize.isCapabilityAvailable()) { |
481 var value = this.mediaSize.getValue(); | 469 var value = this.mediaSize.getValue(); |
482 cjt.print.media_size = { | 470 cjt.print.media_size = { |
483 width_microns: value.width_microns, | 471 width_microns: value.width_microns, |
484 height_microns: value.height_microns, | 472 height_microns: value.height_microns, |
485 is_continuous_feed: value.is_continuous_feed, | 473 is_continuous_feed: value.is_continuous_feed, |
486 vendor_id: value.vendor_id | 474 vendor_id: value.vendor_id |
487 }; | 475 }; |
488 } | 476 } |
489 if (!this.landscape.isCapabilityAvailable()) { | 477 if (!this.landscape.isCapabilityAvailable()) { |
490 // In this case "orientation" option is hidden from user, so user can't | 478 // In this case "orientation" option is hidden from user, so user can't |
491 // adjust it for page content, see Landscape.isCapabilityAvailable(). | 479 // adjust it for page content, see Landscape.isCapabilityAvailable(). |
492 // We can improve results if we set AUTO here. | 480 // We can improve results if we set AUTO here. |
493 if (this.landscape.hasOption('AUTO')) | 481 if (this.landscape.hasOption('AUTO')) |
494 cjt.print.page_orientation = {type: 'AUTO'}; | 482 cjt.print.page_orientation = {type: 'AUTO'}; |
495 } else if (this.landscape.isUserEdited()) { | 483 } else if (this.landscape.isUserEdited()) { |
496 cjt.print.page_orientation = | 484 cjt.print.page_orientation = { |
497 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; | 485 type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT' |
| 486 }; |
498 } | 487 } |
499 if (this.dpi.isCapabilityAvailable()) { | 488 if (this.dpi.isCapabilityAvailable()) { |
500 var value = this.dpi.getValue(); | 489 var value = this.dpi.getValue(); |
501 cjt.print.dpi = { | 490 cjt.print.dpi = { |
502 horizontal_dpi: value.horizontal_dpi, | 491 horizontal_dpi: value.horizontal_dpi, |
503 vertical_dpi: value.vertical_dpi, | 492 vertical_dpi: value.vertical_dpi, |
504 vendor_id: value.vendor_id | 493 vendor_id: value.vendor_id |
505 }; | 494 }; |
506 } | 495 } |
507 if (this.vendorItems.isCapabilityAvailable() && | 496 if (this.vendorItems.isCapabilityAvailable() && |
(...skipping 15 matching lines...) Expand all Loading... |
523 * @private | 512 * @private |
524 */ | 513 */ |
525 addEventListeners_: function() { | 514 addEventListeners_: function() { |
526 this.tracker_.add( | 515 this.tracker_.add( |
527 this.destinationStore_, | 516 this.destinationStore_, |
528 print_preview.DestinationStore.EventType.DESTINATION_SELECT, | 517 print_preview.DestinationStore.EventType.DESTINATION_SELECT, |
529 this.onDestinationSelect_.bind(this)); | 518 this.onDestinationSelect_.bind(this)); |
530 | 519 |
531 this.tracker_.add( | 520 this.tracker_.add( |
532 this.destinationStore_, | 521 this.destinationStore_, |
533 print_preview.DestinationStore.EventType. | 522 print_preview.DestinationStore.EventType |
534 SELECTED_DESTINATION_CAPABILITIES_READY, | 523 .SELECTED_DESTINATION_CAPABILITIES_READY, |
535 this.onSelectedDestinationCapabilitiesReady_.bind(this)); | 524 this.onSelectedDestinationCapabilitiesReady_.bind(this)); |
536 | 525 |
537 this.tracker_.add( | 526 this.tracker_.add( |
538 this.destinationStore_, | 527 this.destinationStore_, |
539 print_preview.DestinationStore.EventType. | 528 print_preview.DestinationStore.EventType |
540 CACHED_SELECTED_DESTINATION_INFO_READY, | 529 .CACHED_SELECTED_DESTINATION_INFO_READY, |
541 this.onSelectedDestinationCapabilitiesReady_.bind(this)); | 530 this.onSelectedDestinationCapabilitiesReady_.bind(this)); |
542 | 531 |
543 // TODO(rltoscano): Print ticket store shouldn't be re-dispatching these | 532 // TODO(rltoscano): Print ticket store shouldn't be re-dispatching these |
544 // events, the consumers of the print ticket store events should listen | 533 // events, the consumers of the print ticket store events should listen |
545 // for the events from document info instead. Will move this when | 534 // for the events from document info instead. Will move this when |
546 // consumers are all migrated. | 535 // consumers are all migrated. |
547 this.tracker_.add( | 536 this.tracker_.add( |
548 this.documentInfo_, | 537 this.documentInfo_, print_preview.DocumentInfo.EventType.CHANGE, |
549 print_preview.DocumentInfo.EventType.CHANGE, | |
550 this.onDocumentInfoChange_.bind(this)); | 538 this.onDocumentInfoChange_.bind(this)); |
551 }, | 539 }, |
552 | 540 |
553 /** | 541 /** |
554 * Called when the destination selected. | 542 * Called when the destination selected. |
555 * @private | 543 * @private |
556 */ | 544 */ |
557 onDestinationSelect_: function() { | 545 onDestinationSelect_: function() { |
558 // Reset user selection for certain ticket items. | 546 // Reset user selection for certain ticket items. |
559 if (this.capabilitiesHolder_.get() != null) { | 547 if (this.capabilitiesHolder_.get() != null) { |
560 this.customMargins_.updateValue(null); | 548 this.customMargins_.updateValue(null); |
561 if (this.marginsType_.getValue() == | 549 if (this.marginsType_.getValue() == |
562 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { | 550 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
563 this.marginsType_.updateValue( | 551 this.marginsType_.updateValue( |
564 print_preview.ticket_items.MarginsTypeValue.DEFAULT); | 552 print_preview.ticket_items.MarginsTypeValue.DEFAULT); |
565 } | 553 } |
566 this.vendorItems_.updateValue({}); | 554 this.vendorItems_.updateValue({}); |
567 } | 555 } |
568 }, | 556 }, |
569 | 557 |
570 /** | 558 /** |
571 * Called when the capabilities of the selected destination are ready. | 559 * Called when the capabilities of the selected destination are ready. |
572 * @private | 560 * @private |
573 */ | 561 */ |
574 onSelectedDestinationCapabilitiesReady_: function() { | 562 onSelectedDestinationCapabilitiesReady_: function() { |
575 var caps = assert( | 563 var caps = |
576 this.destinationStore_.selectedDestination.capabilities); | 564 assert(this.destinationStore_.selectedDestination.capabilities); |
577 var isFirstUpdate = this.capabilitiesHolder_.get() == null; | 565 var isFirstUpdate = this.capabilitiesHolder_.get() == null; |
578 this.capabilitiesHolder_.set(caps); | 566 this.capabilitiesHolder_.set(caps); |
579 if (isFirstUpdate) { | 567 if (isFirstUpdate) { |
580 this.isInitialized_ = true; | 568 this.isInitialized_ = true; |
581 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); | 569 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); |
582 } else { | 570 } else { |
583 cr.dispatchSimpleEvent( | 571 cr.dispatchSimpleEvent( |
584 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); | 572 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); |
585 } | 573 } |
586 }, | 574 }, |
587 | 575 |
588 /** | 576 /** |
589 * Called when document data model has changed. Dispatches a print ticket | 577 * Called when document data model has changed. Dispatches a print ticket |
590 * store event. | 578 * store event. |
591 * @private | 579 * @private |
592 */ | 580 */ |
593 onDocumentInfoChange_: function() { | 581 onDocumentInfoChange_: function() { |
594 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 582 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
595 }, | 583 }, |
596 }; | 584 }; |
597 | 585 |
598 // Export | 586 // Export |
599 return { | 587 return {PrintTicketStore: PrintTicketStore}; |
600 PrintTicketStore: PrintTicketStore | |
601 }; | |
602 }); | 588 }); |
OLD | NEW |