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

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

Issue 580203002: Set orientation to 'AUTO' if we hide orientation option from user. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/resources/print_preview/data/print_ticket_store.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.ticket_items', function() { 5 cr.define('print_preview.ticket_items', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Landscape ticket item whose value is a {@code boolean} that indicates 9 * Landscape ticket item whose value is a {@code boolean} that indicates
10 * whether the document should be printed in landscape orientation. 10 * whether the document should be printed in landscape orientation.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 var defaultOptions = cap.option.filter(function(option) { 84 var defaultOptions = cap.option.filter(function(option) {
85 return option.is_default; 85 return option.is_default;
86 }); 86 });
87 return defaultOptions.length == 0 ? false : 87 return defaultOptions.length == 0 ? false :
88 defaultOptions[0].type == 'LANDSCAPE'; 88 defaultOptions[0].type == 'LANDSCAPE';
89 }, 89 },
90 90
91 /** @override */ 91 /** @override */
92 getCapabilityNotAvailableValueInternal: function() { 92 getCapabilityNotAvailableValueInternal: function() {
93 var doc = this.getDocumentInfoInternal(); 93 var doc = this.getDocumentInfoInternal();
94 return doc.hasCssMediaStyles ? 94 // TODO(vitalybuka): For landscape PDF dimmensions should be
Aleksey Shlyapnikov 2014/09/18 19:03:01 dimensions
Vitaly Buka (NO REVIEWS) 2014/09/18 19:08:46 Done.
95 // width > height. Find why it's not true.
96 return (!doc.isModifiable || doc.hasCssMediaStyles) ?
Aleksey Shlyapnikov 2014/09/18 19:03:01 Let's not add this check.
Vitaly Buka (NO REVIEWS) 2014/09/18 19:08:46 Done.
95 (doc.pageSize.width > doc.pageSize.height) : 97 (doc.pageSize.width > doc.pageSize.height) :
96 false; 98 false;
97 }, 99 },
98 100
99 /** @override */ 101 /** @override */
100 updateValueInternal: function(value) { 102 updateValueInternal: function(value) {
101 var updateMargins = !this.isValueEqual(value); 103 var updateMargins = !this.isValueEqual(value);
102 print_preview.ticket_items.TicketItem.prototype.updateValueInternal.call( 104 print_preview.ticket_items.TicketItem.prototype.updateValueInternal.call(
103 this, value); 105 this, value);
104 if (updateMargins) { 106 if (updateMargins) {
105 // Reset the user set margins when page orientation changes. 107 // Reset the user set margins when page orientation changes.
106 this.marginsType_.updateValue( 108 this.marginsType_.updateValue(
107 print_preview.ticket_items.MarginsType.Value.DEFAULT); 109 print_preview.ticket_items.MarginsType.Value.DEFAULT);
108 this.customMargins_.updateValue(null); 110 this.customMargins_.updateValue(null);
109 } 111 }
110 }, 112 },
111 113
112 /** 114 /**
115 * @return {boolean} Whether capability contains the |value|.
116 * @param {string} value Option to check.
117 */
118 hasOption: function(value) {
119 var cap = this.getPageOrientationCapability_();
120 if (!cap) {
121 return false;
122 }
Aleksey Shlyapnikov 2014/09/18 19:03:01 Remove brackets.
Vitaly Buka (NO REVIEWS) 2014/09/18 19:08:46 Done.
123 var result = false;
124 cap.option.forEach(function(option) {
Aleksey Shlyapnikov 2014/09/18 19:03:01 return capability.option.some(...
Vitaly Buka (NO REVIEWS) 2014/09/18 19:08:46 Done.
125 result = result || option.type == value;
126 });
127 return result;
128 },
129
130 /**
113 * @return {Object} Page orientation capability of the selected destination. 131 * @return {Object} Page orientation capability of the selected destination.
114 * @private 132 * @private
115 */ 133 */
116 getPageOrientationCapability_: function() { 134 getPageOrientationCapability_: function() {
117 var dest = this.getSelectedDestInternal(); 135 var dest = this.getSelectedDestInternal();
118 return (dest && 136 return (dest &&
119 dest.capabilities && 137 dest.capabilities &&
120 dest.capabilities.printer && 138 dest.capabilities.printer &&
121 dest.capabilities.printer.page_orientation) || 139 dest.capabilities.printer.page_orientation) ||
122 null; 140 null;
123 } 141 }
124 }; 142 };
125 143
126 // Export 144 // Export
127 return { 145 return {
128 Landscape: Landscape 146 Landscape: Landscape
129 }; 147 };
130 }); 148 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/data/print_ticket_store.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698