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 /** | 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM; | 233 lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM; |
234 this.marginList_.selectedIndex = | 234 this.marginList_.selectedIndex = |
235 this.getMarginOptionIndexByValue_(lastUsedMarginsType); | 235 this.getMarginOptionIndexByValue_(lastUsedMarginsType); |
236 if (lastUsedMarginsSettings.hasOwnProperty('marginTop') && | 236 if (lastUsedMarginsSettings.hasOwnProperty('marginTop') && |
237 lastUsedMarginsSettings.hasOwnProperty('marginBottom') && | 237 lastUsedMarginsSettings.hasOwnProperty('marginBottom') && |
238 lastUsedMarginsSettings.hasOwnProperty('marginRight') && | 238 lastUsedMarginsSettings.hasOwnProperty('marginRight') && |
239 lastUsedMarginsSettings.hasOwnProperty('marginLeft')) { | 239 lastUsedMarginsSettings.hasOwnProperty('marginLeft')) { |
240 this.customMargins_ = new Margins(-1, -1, -1 , -1); | 240 this.customMargins_ = new Margins(-1, -1, -1 , -1); |
241 this.customMargins = lastUsedMarginsSettings; | 241 this.customMargins = lastUsedMarginsSettings; |
242 } | 242 } |
243 this.dispatchMarginsChangedEvent_(); | |
244 }, | |
245 | |
246 dispatchMarginsChangedEvent_: function() { | |
247 var customEvent = cr.Event(customEvents.MARGINS_SELECTION_CHANGED); | |
248 customEvent.selectedMargins = this.selectedMarginsValue; | |
249 document.dispatchEvent(customEvent); | |
250 }, | 243 }, |
251 | 244 |
252 /** | 245 /** |
253 * @return {number} The total width of the plugin in points. | 246 * @return {number} The total width of the plugin in points. |
254 */ | 247 */ |
255 get totalWidthInPoints() { | 248 get totalWidthInPoints() { |
256 var pageInformation = previewArea.pageLocationNormalized; | 249 var pageInformation = previewArea.pageLocationNormalized; |
257 return this.pageWidth_ / pageInformation.width; | 250 return this.pageWidth_ / pageInformation.width; |
258 }, | 251 }, |
259 | 252 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 this.forceDisplayingMarginLines_ = true; | 553 this.forceDisplayingMarginLines_ = true; |
561 this.marginsUI.show(); | 554 this.marginsUI.show(); |
562 }, | 555 }, |
563 | 556 |
564 /** | 557 /** |
565 * Executes when user selects a different margin option, ie, | 558 * Executes when user selects a different margin option, ie, |
566 * |this.marginList_.selectedIndex| is changed. | 559 * |this.marginList_.selectedIndex| is changed. |
567 * @private | 560 * @private |
568 */ | 561 */ |
569 onMarginsChanged_: function() { | 562 onMarginsChanged_: function() { |
570 this.dispatchMarginsChangedEvent_(); | |
571 | |
572 if (this.isDefaultMarginsSelected() || this.isMinimumMarginsSelected() || | 563 if (this.isDefaultMarginsSelected() || this.isMinimumMarginsSelected() || |
573 this.isNoMarginsSelected()) | 564 this.isNoMarginsSelected()) |
574 this.onDefaultMinimumNoMarginsSelected_(); | 565 this.onDefaultMinimumNoMarginsSelected_(); |
575 else if (this.isCustomMarginsSelected()) | 566 else if (this.isCustomMarginsSelected()) |
576 this.onCustomMarginsSelected_(); | 567 this.onCustomMarginsSelected_(); |
577 }, | 568 }, |
578 | 569 |
579 /** | 570 /** |
580 * Executes when the default or minimum or no margins option is selected. | 571 * Executes when the default or minimum or no margins option is selected. |
581 * @private | 572 * @private |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; | 696 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; |
706 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; | 697 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; |
707 } | 698 } |
708 }; | 699 }; |
709 | 700 |
710 return { | 701 return { |
711 MarginSettings: MarginSettings, | 702 MarginSettings: MarginSettings, |
712 PageLayout: PageLayout | 703 PageLayout: PageLayout |
713 }; | 704 }; |
714 }); | 705 }); |
OLD | NEW |