OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 8 /** |
9 * Creates a Margins object that holds four margin values. The units in which | 9 * Creates a Margins object that holds four margin values. The units in which |
10 * the values are expressed can be any numeric value. | 10 * the values are expressed can be any numeric value. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 var margins = {}; | 165 var margins = {}; |
166 margins.marginLeft = this.customMargins_.left; | 166 margins.marginLeft = this.customMargins_.left; |
167 margins.marginTop = this.customMargins_.top; | 167 margins.marginTop = this.customMargins_.top; |
168 margins.marginRight = this.customMargins_.right; | 168 margins.marginRight = this.customMargins_.right; |
169 margins.marginBottom = this.customMargins_.bottom; | 169 margins.marginBottom = this.customMargins_.bottom; |
170 return margins; | 170 return margins; |
171 }, | 171 }, |
172 | 172 |
173 /** | 173 /** |
174 * @return {number} The value of the selected margin option. | 174 * @return {number} The value of the selected margin option. |
175 * @private | |
176 */ | 175 */ |
177 get selectedMarginsValue_() { | 176 get selectedMarginsValue() { |
178 return this.marginList_.options[this.marginList_.selectedIndex].value; | 177 var val = this.marginList_.options[this.marginList_.selectedIndex].value; |
| 178 return parseInt(val, 10); |
179 }, | 179 }, |
180 | 180 |
181 /** | 181 /** |
182 * @return {boolean} True if default margins are selected. | 182 * @return {boolean} True if default margins are selected. |
183 */ | 183 */ |
184 isDefaultMarginsSelected: function() { | 184 isDefaultMarginsSelected: function() { |
185 return this.selectedMarginsValue_ == MarginSettings.MARGINS_VALUE_DEFAULT; | 185 return this.selectedMarginsValue == MarginSettings.MARGINS_VALUE_DEFAULT; |
186 }, | 186 }, |
187 | 187 |
188 /** | 188 /** |
189 * @return {boolean} True if no margins are selected. | 189 * @return {boolean} True if no margins are selected. |
190 */ | 190 */ |
191 isNoMarginsSelected: function() { | 191 isNoMarginsSelected: function() { |
192 return this.selectedMarginsValue_ == | 192 return this.selectedMarginsValue == |
193 MarginSettings.MARGINS_VALUE_NO_MARGINS; | 193 MarginSettings.MARGINS_VALUE_NO_MARGINS; |
194 }, | 194 }, |
195 | 195 |
196 /** | 196 /** |
197 * @return {boolean} True if custom margins are selected. | 197 * @return {boolean} True if custom margins are selected. |
198 */ | 198 */ |
199 isCustomMarginsSelected: function() { | 199 isCustomMarginsSelected: function() { |
200 return this.selectedMarginsValue_ == MarginSettings.MARGINS_VALUE_CUSTOM; | 200 return this.selectedMarginsValue == MarginSettings.MARGINS_VALUE_CUSTOM; |
201 }, | 201 }, |
202 | 202 |
203 /** | 203 /** |
204 * If the custom margin values have changed then request a new preview based | 204 * If the custom margin values have changed then request a new preview based |
205 * on the newly set margins. | 205 * on the newly set margins. |
206 * @private | 206 * @private |
207 */ | 207 */ |
208 requestPreviewIfNeeded_: function() { | 208 requestPreviewIfNeeded_: function() { |
209 if (!this.areMarginSettingsValid()) | 209 if (!this.areMarginSettingsValid()) |
210 return; | 210 return; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 * @private | 353 * @private |
354 */ | 354 */ |
355 onMarginsChanged_: function() { | 355 onMarginsChanged_: function() { |
356 if (this.isDefaultMarginsSelected()) | 356 if (this.isDefaultMarginsSelected()) |
357 this.onDefaultMarginsSelected_(); | 357 this.onDefaultMarginsSelected_(); |
358 else if (this.isNoMarginsSelected()) | 358 else if (this.isNoMarginsSelected()) |
359 this.onNoMarginsSelected_(); | 359 this.onNoMarginsSelected_(); |
360 else if (this.isCustomMarginsSelected()) | 360 else if (this.isCustomMarginsSelected()) |
361 this.onCustomMarginsSelected_(); | 361 this.onCustomMarginsSelected_(); |
362 | 362 |
363 this.lastSelectedOption_ = this.selectedMarginsValue_; | 363 this.lastSelectedOption_ = this.selectedMarginsValue; |
364 }, | 364 }, |
365 | 365 |
366 /** | 366 /** |
367 * Executes when the default margins option is selected. | 367 * Executes when the default margins option is selected. |
368 * @private | 368 * @private |
369 */ | 369 */ |
370 onDefaultMarginsSelected_: function() { | 370 onDefaultMarginsSelected_: function() { |
371 this.removeCustomMarginEventListeners_(); | 371 this.removeCustomMarginEventListeners_(); |
372 this.forceDisplayingMarginLines_ = true; | 372 this.forceDisplayingMarginLines_ = true; |
373 setDefaultValuesAndRegeneratePreview(false); | 373 setDefaultValuesAndRegeneratePreview(false); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 if (!previewModifiable) | 466 if (!previewModifiable) |
467 fadeOutElement(this.marginsOption_); | 467 fadeOutElement(this.marginsOption_); |
468 } | 468 } |
469 }; | 469 }; |
470 | 470 |
471 return { | 471 return { |
472 MarginSettings: MarginSettings, | 472 MarginSettings: MarginSettings, |
473 PageLayout: PageLayout, | 473 PageLayout: PageLayout, |
474 }; | 474 }; |
475 }); | 475 }); |
OLD | NEW |