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

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

Powered by Google App Engine
This is Rietveld 408576698