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