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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 /** | 112 /** |
113 * Margins type ticket item. | 113 * Margins type ticket item. |
114 * @type {!print_preview.ticket_items.MarginsType} | 114 * @type {!print_preview.ticket_items.MarginsType} |
115 * @private | 115 * @private |
116 */ | 116 */ |
117 this.marginsType_ = new print_preview.ticket_items.MarginsType( | 117 this.marginsType_ = new print_preview.ticket_items.MarginsType( |
118 this.appState_, this.documentInfo_, this.customMargins_); | 118 this.appState_, this.documentInfo_, this.customMargins_); |
119 | 119 |
120 /** | 120 /** |
| 121 * Media size ticket item. |
| 122 * @type {!print_preview.ticket_items.MediaSize} |
| 123 * @private |
| 124 */ |
| 125 this.mediaSize_ = new print_preview.ticket_items.MediaSize( |
| 126 this.appState_, this.destinationStore_); |
| 127 |
| 128 /** |
121 * Landscape ticket item. | 129 * Landscape ticket item. |
122 * @type {!print_preview.ticket_items.Landscape} | 130 * @type {!print_preview.ticket_items.Landscape} |
123 * @private | 131 * @private |
124 */ | 132 */ |
125 this.landscape_ = new print_preview.ticket_items.Landscape( | 133 this.landscape_ = new print_preview.ticket_items.Landscape( |
126 this.appState_, this.destinationStore_, this.documentInfo_, | 134 this.appState_, this.destinationStore_, this.documentInfo_, |
127 this.marginsType_, this.customMargins_); | 135 this.marginsType_, this.customMargins_); |
128 | 136 |
129 /** | 137 /** |
130 * Header-footer ticket item. | 138 * Header-footer ticket item. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 }, | 231 }, |
224 | 232 |
225 get fitToPage() { | 233 get fitToPage() { |
226 return this.fitToPage_; | 234 return this.fitToPage_; |
227 }, | 235 }, |
228 | 236 |
229 get headerFooter() { | 237 get headerFooter() { |
230 return this.headerFooter_; | 238 return this.headerFooter_; |
231 }, | 239 }, |
232 | 240 |
| 241 get mediaSize() { |
| 242 return this.mediaSize_; |
| 243 }, |
| 244 |
233 get landscape() { | 245 get landscape() { |
234 return this.landscape_; | 246 return this.landscape_; |
235 }, | 247 }, |
236 | 248 |
237 get marginsType() { | 249 get marginsType() { |
238 return this.marginsType_; | 250 return this.marginsType_; |
239 }, | 251 }, |
240 | 252 |
241 get pageRange() { | 253 get pageRange() { |
242 return this.pageRange_; | 254 return this.pageRange_; |
(...skipping 30 matching lines...) Expand all Loading... |
273 if (this.appState_.hasField( | 285 if (this.appState_.hasField( |
274 print_preview.AppState.Field.IS_COLOR_ENABLED)) { | 286 print_preview.AppState.Field.IS_COLOR_ENABLED)) { |
275 this.color_.updateValue(this.appState_.getField( | 287 this.color_.updateValue(this.appState_.getField( |
276 print_preview.AppState.Field.IS_COLOR_ENABLED)); | 288 print_preview.AppState.Field.IS_COLOR_ENABLED)); |
277 } | 289 } |
278 if (this.appState_.hasField( | 290 if (this.appState_.hasField( |
279 print_preview.AppState.Field.IS_DUPLEX_ENABLED)) { | 291 print_preview.AppState.Field.IS_DUPLEX_ENABLED)) { |
280 this.duplex_.updateValue(this.appState_.getField( | 292 this.duplex_.updateValue(this.appState_.getField( |
281 print_preview.AppState.Field.IS_DUPLEX_ENABLED)); | 293 print_preview.AppState.Field.IS_DUPLEX_ENABLED)); |
282 } | 294 } |
| 295 if (this.appState_.hasField(print_preview.AppState.Field.MEDIA_SIZE)) { |
| 296 this.mediaSize_.updateValue(this.appState_.getField( |
| 297 print_preview.AppState.Field.MEDIA_SIZE)); |
| 298 } |
283 if (this.appState_.hasField( | 299 if (this.appState_.hasField( |
284 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)) { | 300 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)) { |
285 this.landscape_.updateValue(this.appState_.getField( | 301 this.landscape_.updateValue(this.appState_.getField( |
286 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)); | 302 print_preview.AppState.Field.IS_LANDSCAPE_ENABLED)); |
287 } | 303 } |
288 // Initialize margins after landscape because landscape may reset margins. | 304 // Initialize margins after landscape because landscape may reset margins. |
289 if (this.appState_.hasField(print_preview.AppState.Field.MARGINS_TYPE)) { | 305 if (this.appState_.hasField(print_preview.AppState.Field.MARGINS_TYPE)) { |
290 this.marginsType_.updateValue( | 306 this.marginsType_.updateValue( |
291 this.appState_.getField(print_preview.AppState.Field.MARGINS_TYPE)); | 307 this.appState_.getField(print_preview.AppState.Field.MARGINS_TYPE)); |
292 } | 308 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 384 } |
369 } | 385 } |
370 } | 386 } |
371 if (this.copies.isCapabilityAvailable() && this.copies.isUserEdited()) { | 387 if (this.copies.isCapabilityAvailable() && this.copies.isUserEdited()) { |
372 cjt.print.copies = {copies: this.copies.getValueAsNumber()}; | 388 cjt.print.copies = {copies: this.copies.getValueAsNumber()}; |
373 } | 389 } |
374 if (this.duplex.isCapabilityAvailable() && this.duplex.isUserEdited()) { | 390 if (this.duplex.isCapabilityAvailable() && this.duplex.isUserEdited()) { |
375 cjt.print.duplex = | 391 cjt.print.duplex = |
376 {type: this.duplex.getValue() ? 'LONG_EDGE' : 'NO_DUPLEX'}; | 392 {type: this.duplex.getValue() ? 'LONG_EDGE' : 'NO_DUPLEX'}; |
377 } | 393 } |
| 394 if (this.mediaSize.isCapabilityAvailable()) { |
| 395 var value = this.mediaSize.getValue(); |
| 396 cjt.print.media_size = { |
| 397 width_microns: value.width_microns, |
| 398 height_microns: value.height_microns, |
| 399 is_continuous_feed: value.is_continuous_feed, |
| 400 vendor_id: value.vendor_id |
| 401 }; |
| 402 } |
378 if (this.landscape.isCapabilityAvailable() && | 403 if (this.landscape.isCapabilityAvailable() && |
379 this.landscape.isUserEdited()) { | 404 this.landscape.isUserEdited()) { |
380 cjt.print.page_orientation = | 405 cjt.print.page_orientation = |
381 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; | 406 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; |
382 } | 407 } |
383 return JSON.stringify(cjt); | 408 return JSON.stringify(cjt); |
384 }, | 409 }, |
385 | 410 |
386 /** | 411 /** |
387 * Adds event listeners for the print ticket store. | 412 * Adds event listeners for the print ticket store. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 onDocumentInfoChange_: function() { | 481 onDocumentInfoChange_: function() { |
457 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 482 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
458 }, | 483 }, |
459 }; | 484 }; |
460 | 485 |
461 // Export | 486 // Export |
462 return { | 487 return { |
463 PrintTicketStore: PrintTicketStore | 488 PrintTicketStore: PrintTicketStore |
464 }; | 489 }; |
465 }); | 490 }); |
OLD | NEW |