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

Side by Side Diff: chrome/browser/resources/print_preview/data/ticket_items/scaling.js

Issue 2713033003: Print Preview: Show error message if text is typed in Copies section (Closed)
Patch Set: Remove unnecessary diff Created 3 years, 10 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 * Scaling ticket item whose value is a {@code string} that indicates what the 9 * Scaling ticket item whose value is a {@code string} that indicates what the
10 * scaling (in percent) of the document should be. The ticket item is backed 10 * scaling (in percent) of the document should be. The ticket item is backed
(...skipping 27 matching lines...) Expand all
38 * @private {number} 38 * @private {number}
39 * @const 39 * @const
40 */ 40 */
41 Scaling.MIN_VAL = 10; 41 Scaling.MIN_VAL = 10;
42 42
43 Scaling.prototype = { 43 Scaling.prototype = {
44 __proto__: print_preview.ticket_items.TicketItem.prototype, 44 __proto__: print_preview.ticket_items.TicketItem.prototype,
45 45
46 /** @override */ 46 /** @override */
47 wouldValueBeValid: function(value) { 47 wouldValueBeValid: function(value) {
48 if (/[^\d]+/.test(value)) { 48 return true;
dpapad 2017/02/27 21:56:02 Is this resulting in the same behavior as before?
rbpotter 2017/02/28 00:12:59 It should be. This function was only called in isV
49 return false; 49 },
50 }
51 var scaling = parseInt(value, 10);
52 return scaling >= Scaling.MIN_VAL && scaling <= Scaling.MAX_VAL;
53 },
54 50
55 /** @override */ 51 /** @override */
56 isValueEqual: function(value) { 52 isValueEqual: function(value) {
57 return this.getValueAsNumber() == value; 53 return this.getValueAsNumber() == value;
58 }, 54 },
59 55
60 /**
61 * @param {number} The desired scaling percentage.
62 * @return {number} Nearest valid scaling percentage
63 */
64 getNearestValidValue: function(value) {
65 return Math.min(Math.max(value, Scaling.MIN_VAL), Scaling.MAX_VAL);
66 },
67
68 /** @override */ 56 /** @override */
69 isCapabilityAvailable: function() { 57 isCapabilityAvailable: function() {
70 // This is not a function of the printer, but should be disabled if we are 58 // This is not a function of the printer, but should be disabled if we are
71 // saving a PDF to a PDF. 59 // saving a PDF to a PDF.
72 var knownSizeToSaveAsPdf = 60 var knownSizeToSaveAsPdf =
73 (!this.getDocumentInfoInternal().isModifiable || 61 (!this.getDocumentInfoInternal().isModifiable ||
74 this.getDocumentInfoInternal().hasCssMediaStyles) && 62 this.getDocumentInfoInternal().hasCssMediaStyles) &&
75 this.getSelectedDestInternal() && 63 this.getSelectedDestInternal() &&
76 this.getSelectedDestInternal().id == 64 this.getSelectedDestInternal().id ==
77 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; 65 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
(...skipping 14 matching lines...) Expand all
92 getCapabilityNotAvailableValueInternal: function() { 80 getCapabilityNotAvailableValueInternal: function() {
93 return '100'; 81 return '100';
94 }, 82 },
95 }; 83 };
96 84
97 // Export 85 // Export
98 return { 86 return {
99 Scaling: Scaling 87 Scaling: Scaling
100 }; 88 };
101 }); 89 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698