Chromium Code Reviews| 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 'strict'; | 6 'strict'; |
| 7 | 7 |
| 8 function MarginsUI() { | 8 function MarginsUI() { |
| 9 var marginsUI = document.createElement('div'); | 9 var marginsUI = document.createElement('div'); |
| 10 marginsUI.__proto__ = MarginsUI.prototype; | 10 marginsUI.__proto__ = MarginsUI.prototype; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 draw: function() { | 100 draw: function() { |
| 101 this.applyClippingMask_(); | 101 this.applyClippingMask_(); |
| 102 this.pairsAsList.forEach(function(pair) { pair.draw(); }); | 102 this.pairsAsList.forEach(function(pair) { pair.draw(); }); |
| 103 }, | 103 }, |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Shows the margins UI. | 106 * Shows the margins UI. |
| 107 */ | 107 */ |
| 108 show: function() { | 108 show: function() { |
| 109 this.hidden = false; | 109 this.hidden = false; |
| 110 this.classList.remove('invisible'); | |
| 110 }, | 111 }, |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * Hides the margins UI. | 114 * Hides the margins UI and removes from the DOM if requested. |
| 115 * @param {boolean} removeFromDOM True if |this| should also be removed from | |
|
Lei Zhang
2011/10/26 00:51:48
Technically it's still in the DOM, just hidden.
dpapad
2011/10/26 01:24:24
Yes, display: none; prevents it from being rendere
| |
| 116 * the DOM (in order to not interfere with the tab order). | |
| 114 */ | 117 */ |
| 115 hide: function() { | 118 hide: function(removeFromDOM) { |
| 116 this.hidden = true; | 119 removeFromDOM ? this.hidden = true : this.classList.add('invisible'); |
| 117 }, | 120 }, |
| 118 | 121 |
| 119 /** | 122 /** |
| 120 * Applies a clipping mask on |this| so that it does not paint on top of the | 123 * Applies a clipping mask on |this| so that it does not paint on top of the |
| 121 * scrollbars (if any). | 124 * scrollbars (if any). |
| 122 */ | 125 */ |
| 123 applyClippingMask_: function() { | 126 applyClippingMask_: function() { |
| 124 var bottom = previewArea.height; | 127 var bottom = previewArea.height; |
| 125 var right = previewArea.width; | 128 var right = previewArea.width; |
| 126 this.style.clip = "rect(0, " + right + "px, " + bottom + "px, 0)"; | 129 this.style.clip = "rect(0, " + right + "px, " + bottom + "px, 0)"; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 this.lastClickedMarginsUIPair.getDragDisplacementFrom(point); | 195 this.lastClickedMarginsUIPair.getDragDisplacementFrom(point); |
| 193 dragEvent.destinationPoint = point; | 196 dragEvent.destinationPoint = point; |
| 194 this.dispatchEvent(dragEvent); | 197 this.dispatchEvent(dragEvent); |
| 195 }, | 198 }, |
| 196 }; | 199 }; |
| 197 | 200 |
| 198 return { | 201 return { |
| 199 MarginsUI: MarginsUI | 202 MarginsUI: MarginsUI |
| 200 }; | 203 }; |
| 201 }); | 204 }); |
| OLD | NEW |