| Index: chrome/browser/resources/print_preview/data/print_ticket_store.js
|
| diff --git a/chrome/browser/resources/print_preview/data/print_ticket_store.js b/chrome/browser/resources/print_preview/data/print_ticket_store.js
|
| index 007419c8d6a4aba1c070433aa0144a5e4f1af99f..90cc79b295dda7edb2e66d68e14812788ef38c43 100644
|
| --- a/chrome/browser/resources/print_preview/data/print_ticket_store.js
|
| +++ b/chrome/browser/resources/print_preview/data/print_ticket_store.js
|
| @@ -147,11 +147,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| this.mediaSize_ = new print_preview.ticket_items.MediaSize(
|
| - this.appState_,
|
| - this.destinationStore_,
|
| - this.documentInfo_,
|
| - this.marginsType_,
|
| - this.customMargins_);
|
| + this.appState_, this.destinationStore_, this.documentInfo_,
|
| + this.marginsType_, this.customMargins_);
|
|
|
| /**
|
| * Landscape ticket item.
|
| @@ -159,11 +156,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| this.landscape_ = new print_preview.ticket_items.Landscape(
|
| - this.appState_,
|
| - this.destinationStore_,
|
| - this.documentInfo_,
|
| - this.marginsType_,
|
| - this.customMargins_);
|
| + this.appState_, this.destinationStore_, this.documentInfo_,
|
| + this.marginsType_, this.customMargins_);
|
|
|
| /**
|
| * Header-footer ticket item.
|
| @@ -171,9 +165,7 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| this.headerFooter_ = new print_preview.ticket_items.HeaderFooter(
|
| - this.appState_,
|
| - this.documentInfo_,
|
| - this.marginsType_,
|
| + this.appState_, this.documentInfo_, this.marginsType_,
|
| this.customMargins_);
|
|
|
| /**
|
| @@ -334,87 +326,86 @@ cr.define('print_preview', function() {
|
| */
|
| init: function(
|
| thousandsDelimeter, decimalDelimeter, unitType, selectionOnly) {
|
| - this.measurementSystem_.setSystem(thousandsDelimeter, decimalDelimeter,
|
| - unitType);
|
| + this.measurementSystem_.setSystem(
|
| + thousandsDelimeter, decimalDelimeter, unitType);
|
| this.selectionOnly_.updateValue(selectionOnly);
|
|
|
| // Initialize ticket with user's previous values.
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_COLOR_ENABLED)) {
|
| + print_preview.AppState.Field.IS_COLOR_ENABLED)) {
|
| this.color_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_COLOR_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_COLOR_ENABLED)));
|
| }
|
| if (this.appState_.hasField(print_preview.AppState.Field.DPI)) {
|
| this.dpi_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.DPI)));
|
| + /** @type {!Object} */ (
|
| + this.appState_.getField(print_preview.AppState.Field.DPI)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_DUPLEX_ENABLED)) {
|
| + print_preview.AppState.Field.IS_DUPLEX_ENABLED)) {
|
| this.duplex_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_DUPLEX_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_DUPLEX_ENABLED)));
|
| }
|
| if (this.appState_.hasField(print_preview.AppState.Field.MEDIA_SIZE)) {
|
| this.mediaSize_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.MEDIA_SIZE)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.MEDIA_SIZE)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)) {
|
| + print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)) {
|
| this.landscape_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)));
|
| }
|
| // Initialize margins after landscape because landscape may reset margins.
|
| if (this.appState_.hasField(print_preview.AppState.Field.MARGINS_TYPE)) {
|
| this.marginsType_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.MARGINS_TYPE)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.MARGINS_TYPE)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.CUSTOM_MARGINS)) {
|
| + print_preview.AppState.Field.CUSTOM_MARGINS)) {
|
| this.customMargins_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.CUSTOM_MARGINS)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.CUSTOM_MARGINS)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)) {
|
| + print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)) {
|
| this.headerFooter_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_COLLATE_ENABLED)) {
|
| + print_preview.AppState.Field.IS_COLLATE_ENABLED)) {
|
| this.collate_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_COLLATE_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_COLLATE_ENABLED)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_FIT_TO_PAGE_ENABLED)) {
|
| + print_preview.AppState.Field.IS_FIT_TO_PAGE_ENABLED)) {
|
| this.fitToPage_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_FIT_TO_PAGE_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_FIT_TO_PAGE_ENABLED)));
|
| }
|
| - if (this.appState_.hasField(
|
| - print_preview.AppState.Field.SCALING)) {
|
| + if (this.appState_.hasField(print_preview.AppState.Field.SCALING)) {
|
| this.scaling_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.SCALING)));
|
| + /** @type {!Object} */ (
|
| + this.appState_.getField(print_preview.AppState.Field.SCALING)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) {
|
| + print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) {
|
| this.cssBackground_.updateValue(
|
| - /** @type {!Object} */(this.appState_.getField(
|
| - print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)));
|
| + /** @type {!Object} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)));
|
| }
|
| if (this.appState_.hasField(
|
| - print_preview.AppState.Field.VENDOR_OPTIONS)) {
|
| + print_preview.AppState.Field.VENDOR_OPTIONS)) {
|
| this.vendorItems_.updateValue(
|
| - /** @type {!Object<string>} */(this.appState_.getField(
|
| - print_preview.AppState.Field.VENDOR_OPTIONS)));
|
| - }
|
| + /** @type {!Object<string>} */ (this.appState_.getField(
|
| + print_preview.AppState.Field.VENDOR_OPTIONS)));
|
| + }
|
| },
|
|
|
| /**
|
| @@ -425,15 +416,16 @@ cr.define('print_preview', function() {
|
| return this.isTicketValidForPreview() &&
|
| (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) &&
|
| (!this.pageRange_.isCapabilityAvailable() ||
|
| - this.pageRange_.isValid());
|
| + this.pageRange_.isValid());
|
| },
|
|
|
| /** @return {boolean} Whether the ticket is valid for preview generation. */
|
| isTicketValidForPreview: function() {
|
| - return (!this.marginsType_.isCapabilityAvailable() ||
|
| - !this.marginsType_.isValueEqual(
|
| - print_preview.ticket_items.MarginsType.Value.CUSTOM) ||
|
| - this.customMargins_.isValid());
|
| + return (
|
| + !this.marginsType_.isCapabilityAvailable() ||
|
| + !this.marginsType_.isValueEqual(
|
| + print_preview.ticket_items.MarginsType.Value.CUSTOM) ||
|
| + this.customMargins_.isValid());
|
| },
|
|
|
| /**
|
| @@ -442,18 +434,17 @@ cr.define('print_preview', function() {
|
| * @return {!Object} Google Cloud Print print ticket.
|
| */
|
| createPrintTicket: function(destination) {
|
| - assert(!destination.isLocal ||
|
| - destination.isPrivet || destination.isExtension,
|
| - 'Trying to create a Google Cloud Print print ticket for a local ' +
|
| - ' non-privet and non-extension destination');
|
| -
|
| - assert(destination.capabilities,
|
| - 'Trying to create a Google Cloud Print print ticket for a ' +
|
| - 'destination with no print capabilities');
|
| - var cjt = {
|
| - version: '1.0',
|
| - print: {}
|
| - };
|
| + assert(
|
| + !destination.isLocal || destination.isPrivet ||
|
| + destination.isExtension,
|
| + 'Trying to create a Google Cloud Print print ticket for a local ' +
|
| + ' non-privet and non-extension destination');
|
| +
|
| + assert(
|
| + destination.capabilities,
|
| + 'Trying to create a Google Cloud Print print ticket for a ' +
|
| + 'destination with no print capabilities');
|
| + var cjt = {version: '1.0', print: {}};
|
| if (this.collate.isCapabilityAvailable() && this.collate.isUserEdited()) {
|
| cjt.print.collate = {collate: this.collate.getValue()};
|
| }
|
| @@ -472,8 +463,9 @@ cr.define('print_preview', function() {
|
| cjt.print.copies = {copies: this.copies.getValueAsNumber()};
|
| }
|
| if (this.duplex.isCapabilityAvailable() && this.duplex.isUserEdited()) {
|
| - cjt.print.duplex =
|
| - {type: this.duplex.getValue() ? 'LONG_EDGE' : 'NO_DUPLEX'};
|
| + cjt.print.duplex = {
|
| + type: this.duplex.getValue() ? 'LONG_EDGE' : 'NO_DUPLEX'
|
| + };
|
| }
|
| if (this.mediaSize.isCapabilityAvailable()) {
|
| var value = this.mediaSize.getValue();
|
| @@ -489,10 +481,11 @@ cr.define('print_preview', function() {
|
| // adjust it for page content, see Landscape.isCapabilityAvailable().
|
| // We can improve results if we set AUTO here.
|
| if (this.landscape.hasOption('AUTO'))
|
| - cjt.print.page_orientation = { type: 'AUTO' };
|
| + cjt.print.page_orientation = {type: 'AUTO'};
|
| } else if (this.landscape.isUserEdited()) {
|
| - cjt.print.page_orientation =
|
| - {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'};
|
| + cjt.print.page_orientation = {
|
| + type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'
|
| + };
|
| }
|
| if (this.dpi.isCapabilityAvailable()) {
|
| var value = this.dpi.getValue();
|
| @@ -527,15 +520,13 @@ cr.define('print_preview', function() {
|
| this.onDestinationSelect_.bind(this));
|
|
|
| this.tracker_.add(
|
| - this.destinationStore_,
|
| - print_preview.DestinationStore.EventType.
|
| - SELECTED_DESTINATION_CAPABILITIES_READY,
|
| + this.destinationStore_, print_preview.DestinationStore.EventType
|
| + .SELECTED_DESTINATION_CAPABILITIES_READY,
|
| this.onSelectedDestinationCapabilitiesReady_.bind(this));
|
|
|
| this.tracker_.add(
|
| - this.destinationStore_,
|
| - print_preview.DestinationStore.EventType.
|
| - CACHED_SELECTED_DESTINATION_INFO_READY,
|
| + this.destinationStore_, print_preview.DestinationStore.EventType
|
| + .CACHED_SELECTED_DESTINATION_INFO_READY,
|
| this.onSelectedDestinationCapabilitiesReady_.bind(this));
|
|
|
| // TODO(rltoscano): Print ticket store shouldn't be re-dispatching these
|
| @@ -543,8 +534,7 @@ cr.define('print_preview', function() {
|
| // for the events from document info instead. Will move this when
|
| // consumers are all migrated.
|
| this.tracker_.add(
|
| - this.documentInfo_,
|
| - print_preview.DocumentInfo.EventType.CHANGE,
|
| + this.documentInfo_, print_preview.DocumentInfo.EventType.CHANGE,
|
| this.onDocumentInfoChange_.bind(this));
|
| },
|
|
|
| @@ -570,8 +560,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onSelectedDestinationCapabilitiesReady_: function() {
|
| - var caps = assert(
|
| - this.destinationStore_.selectedDestination.capabilities);
|
| + var caps =
|
| + assert(this.destinationStore_.selectedDestination.capabilities);
|
| var isFirstUpdate = this.capabilitiesHolder_.get() == null;
|
| this.capabilitiesHolder_.set(caps);
|
| if (isFirstUpdate) {
|
| @@ -594,7 +584,5 @@ cr.define('print_preview', function() {
|
| };
|
|
|
| // Export
|
| - return {
|
| - PrintTicketStore: PrintTicketStore
|
| - };
|
| + return {PrintTicketStore: PrintTicketStore};
|
| });
|
|
|