Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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.ticket_items', function() { | 5 cr.define('print_preview.ticket_items', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Ticket item whose value is a {@code boolean} that represents whether to | 9 * Ticket item whose value is a {@code boolean} that represents whether to |
| 10 * print selection only. | 10 * simplify the page before printing. |
| 11 * @param {!print_preview.DocumentInfo} documentInfo Information about the | 11 * @param {!print_preview.DocumentInfo} documentInfo Information about the |
| 12 * document to print. | 12 * document to print. |
| 13 * @param {!print_preview.SelectionOnly} selectionOnly Ticket definig whether | |
| 14 * only selected content should be printed. | |
| 13 * @constructor | 15 * @constructor |
| 14 * @extends {print_preview.ticket_items.TicketItem} | 16 * @extends {print_preview.ticket_items.TicketItem} |
| 15 */ | 17 */ |
| 16 function SelectionOnly(documentInfo) { | 18 function PrintFriendly(documentInfo, selectionOnly) { |
| 17 print_preview.ticket_items.TicketItem.call( | 19 print_preview.ticket_items.TicketItem.call( |
| 18 this, | 20 this, |
| 19 null /*appState*/, | 21 null /*appState*/, |
| 20 null /*field*/, | 22 null /*field*/, |
| 21 null /*destinationStore*/, | 23 null /*destinationStore*/, |
| 22 documentInfo); | 24 documentInfo); |
| 25 | |
| 26 this.isAvailable_ = false; | |
| 27 | |
| 28 this.selectionOnly_ = selectionOnly; | |
| 23 }; | 29 }; |
| 24 | 30 |
| 25 SelectionOnly.prototype = { | 31 PrintFriendly.prototype = { |
| 26 __proto__: print_preview.ticket_items.TicketItem.prototype, | 32 __proto__: print_preview.ticket_items.TicketItem.prototype, |
| 27 | 33 |
| 28 /** @override */ | 34 /** @override */ |
| 29 wouldValueBeValid: function(value) { | 35 wouldValueBeValid: function(value) { |
| 30 return true; | 36 return true; |
| 31 }, | 37 }, |
| 32 | 38 |
| 33 /** @override */ | 39 /** @override */ |
| 34 isCapabilityAvailable: function() { | 40 isCapabilityAvailable: function() { |
| 35 return this.getDocumentInfoInternal().isModifiable && | 41 return this.isAvailable_ && !this.selectionOnly_.isCapabilityAvailable(); |
|
Aleksey Shlyapnikov
2015/07/07 01:26:17
Wouldn't the behavior be pretty random for the uns
| |
| 36 this.getDocumentInfoInternal().hasSelection; | |
| 37 }, | 42 }, |
| 38 | 43 |
| 39 /** @override */ | 44 /** @override */ |
| 40 getDefaultValueInternal: function() { | 45 getDefaultValueInternal: function() { |
| 41 return false; | 46 return false; |
| 42 }, | 47 }, |
| 43 | 48 |
| 44 /** @override */ | 49 /** @override */ |
| 45 getCapabilityNotAvailableValueInternal: function() { | 50 getCapabilityNotAvailableValueInternal: function() { |
| 46 return false; | 51 return false; |
| 52 }, | |
| 53 | |
| 54 setIsCapabilityAvailable: function(isAvailable) { | |
| 55 this.isAvailable_ = isAvailable; | |
| 56 this.dispatchChangeEventInternal(); | |
|
Aleksey Shlyapnikov
2015/07/07 01:26:17
Dispatch this event only when the value was actual
| |
| 47 } | 57 } |
| 48 }; | 58 }; |
| 49 | 59 |
| 50 // Export | 60 // Export |
| 51 return { | 61 return { |
| 52 SelectionOnly: SelectionOnly | 62 PrintFriendly: PrintFriendly |
| 53 }; | 63 }; |
| 54 }); | 64 }); |
| OLD | NEW |