| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Copies ticket item. | 81 * Copies ticket item. |
| 82 * @type {!print_preview.ticket_items.Copies} | 82 * @type {!print_preview.ticket_items.Copies} |
| 83 * @private | 83 * @private |
| 84 */ | 84 */ |
| 85 this.copies_ = | 85 this.copies_ = |
| 86 new print_preview.ticket_items.Copies(this.destinationStore_); | 86 new print_preview.ticket_items.Copies(this.destinationStore_); |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * DPI ticket item. |
| 90 * @type {!print_preview.ticket_items.Dpi} |
| 91 * @private |
| 92 */ |
| 93 this.dpi_ = new print_preview.ticket_items.Dpi( |
| 94 this.appState_, this.destinationStore_); |
| 95 |
| 96 /** |
| 89 * Duplex ticket item. | 97 * Duplex ticket item. |
| 90 * @type {!print_preview.ticket_items.Duplex} | 98 * @type {!print_preview.ticket_items.Duplex} |
| 91 * @private | 99 * @private |
| 92 */ | 100 */ |
| 93 this.duplex_ = new print_preview.ticket_items.Duplex( | 101 this.duplex_ = new print_preview.ticket_items.Duplex( |
| 94 this.appState_, this.destinationStore_); | 102 this.appState_, this.destinationStore_); |
| 95 | 103 |
| 96 /** | 104 /** |
| 97 * Page range ticket item. | 105 * Page range ticket item. |
| 98 * @type {!print_preview.ticket_items.PageRange} | 106 * @type {!print_preview.ticket_items.PageRange} |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 }, | 244 }, |
| 237 | 245 |
| 238 get cssBackground() { | 246 get cssBackground() { |
| 239 return this.cssBackground_; | 247 return this.cssBackground_; |
| 240 }, | 248 }, |
| 241 | 249 |
| 242 get customMargins() { | 250 get customMargins() { |
| 243 return this.customMargins_; | 251 return this.customMargins_; |
| 244 }, | 252 }, |
| 245 | 253 |
| 254 get dpi() { |
| 255 return this.dpi_; |
| 256 }, |
| 257 |
| 246 get duplex() { | 258 get duplex() { |
| 247 return this.duplex_; | 259 return this.duplex_; |
| 248 }, | 260 }, |
| 249 | 261 |
| 250 get fitToPage() { | 262 get fitToPage() { |
| 251 return this.fitToPage_; | 263 return this.fitToPage_; |
| 252 }, | 264 }, |
| 253 | 265 |
| 254 get headerFooter() { | 266 get headerFooter() { |
| 255 return this.headerFooter_; | 267 return this.headerFooter_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 unitType); | 314 unitType); |
| 303 this.selectionOnly_.updateValue(selectionOnly); | 315 this.selectionOnly_.updateValue(selectionOnly); |
| 304 | 316 |
| 305 // Initialize ticket with user's previous values. | 317 // Initialize ticket with user's previous values. |
| 306 if (this.appState_.hasField( | 318 if (this.appState_.hasField( |
| 307 print_preview.AppState.Field.IS_COLOR_ENABLED)) { | 319 print_preview.AppState.Field.IS_COLOR_ENABLED)) { |
| 308 this.color_.updateValue( | 320 this.color_.updateValue( |
| 309 /** @type {!Object} */(this.appState_.getField( | 321 /** @type {!Object} */(this.appState_.getField( |
| 310 print_preview.AppState.Field.IS_COLOR_ENABLED))); | 322 print_preview.AppState.Field.IS_COLOR_ENABLED))); |
| 311 } | 323 } |
| 324 if (this.appState_.hasField(print_preview.AppState.Field.DPI)) { |
| 325 this.dpi_.updateValue( |
| 326 /** @type {!Object} */(this.appState_.getField( |
| 327 print_preview.AppState.Field.DPI))); |
| 328 } |
| 312 if (this.appState_.hasField( | 329 if (this.appState_.hasField( |
| 313 print_preview.AppState.Field.IS_DUPLEX_ENABLED)) { | 330 print_preview.AppState.Field.IS_DUPLEX_ENABLED)) { |
| 314 this.duplex_.updateValue( | 331 this.duplex_.updateValue( |
| 315 /** @type {!Object} */(this.appState_.getField( | 332 /** @type {!Object} */(this.appState_.getField( |
| 316 print_preview.AppState.Field.IS_DUPLEX_ENABLED))); | 333 print_preview.AppState.Field.IS_DUPLEX_ENABLED))); |
| 317 } | 334 } |
| 318 if (this.appState_.hasField(print_preview.AppState.Field.MEDIA_SIZE)) { | 335 if (this.appState_.hasField(print_preview.AppState.Field.MEDIA_SIZE)) { |
| 319 this.mediaSize_.updateValue( | 336 this.mediaSize_.updateValue( |
| 320 /** @type {!Object} */(this.appState_.getField( | 337 /** @type {!Object} */(this.appState_.getField( |
| 321 print_preview.AppState.Field.MEDIA_SIZE))); | 338 print_preview.AppState.Field.MEDIA_SIZE))); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (!this.landscape.isCapabilityAvailable()) { | 450 if (!this.landscape.isCapabilityAvailable()) { |
| 434 // In this case "orientation" option is hidden from user, so user can't | 451 // In this case "orientation" option is hidden from user, so user can't |
| 435 // adjust it for page content, see Landscape.isCapabilityAvailable(). | 452 // adjust it for page content, see Landscape.isCapabilityAvailable(). |
| 436 // We can improve results if we set AUTO here. | 453 // We can improve results if we set AUTO here. |
| 437 if (this.landscape.hasOption('AUTO')) | 454 if (this.landscape.hasOption('AUTO')) |
| 438 cjt.print.page_orientation = { type: 'AUTO' }; | 455 cjt.print.page_orientation = { type: 'AUTO' }; |
| 439 } else if (this.landscape.isUserEdited()) { | 456 } else if (this.landscape.isUserEdited()) { |
| 440 cjt.print.page_orientation = | 457 cjt.print.page_orientation = |
| 441 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; | 458 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; |
| 442 } | 459 } |
| 460 if (this.dpi.isCapabilityAvailable()) { |
| 461 var value = this.dpi.getValue(); |
| 462 cjt.print.dpi = { |
| 463 horizontal_dpi: value.horizontal_dpi, |
| 464 vertical_dpi: value.vertical_dpi, |
| 465 vendor_id: value.vendor_id |
| 466 }; |
| 467 } |
| 443 if (this.vendorItems.isCapabilityAvailable() && | 468 if (this.vendorItems.isCapabilityAvailable() && |
| 444 this.vendorItems.isUserEdited()) { | 469 this.vendorItems.isUserEdited()) { |
| 445 var items = this.vendorItems.ticketItems; | 470 var items = this.vendorItems.ticketItems; |
| 446 cjt.print.vendor_ticket_item = []; | 471 cjt.print.vendor_ticket_item = []; |
| 447 for (var itemId in items) { | 472 for (var itemId in items) { |
| 448 if (items.hasOwnProperty(itemId)) { | 473 if (items.hasOwnProperty(itemId)) { |
| 449 cjt.print.vendor_ticket_item.push( | 474 cjt.print.vendor_ticket_item.push( |
| 450 {id: itemId, value: items[itemId]}); | 475 {id: itemId, value: items[itemId]}); |
| 451 } | 476 } |
| 452 } | 477 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 onDocumentInfoChange_: function() { | 554 onDocumentInfoChange_: function() { |
| 530 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 555 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
| 531 }, | 556 }, |
| 532 }; | 557 }; |
| 533 | 558 |
| 534 // Export | 559 // Export |
| 535 return { | 560 return { |
| 536 PrintTicketStore: PrintTicketStore | 561 PrintTicketStore: PrintTicketStore |
| 537 }; | 562 }; |
| 538 }); | 563 }); |
| OLD | NEW |