| 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 * Class that represents a UI component. | 9 * Class that represents a UI component. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 this.element_ = cr.doc.createElement('div'); | 66 this.element_ = cr.doc.createElement('div'); |
| 67 }, | 67 }, |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Called when the component's element is known to be in the document. | 70 * Called when the component's element is known to be in the document. |
| 71 * Anything using document.getElementById etc. should be done at this stage. | 71 * Anything using document.getElementById etc. should be done at this stage. |
| 72 * Sub-classes should extend this method and attach listeners. | 72 * Sub-classes should extend this method and attach listeners. |
| 73 */ | 73 */ |
| 74 enterDocument: function() { | 74 enterDocument: function() { |
| 75 this.isInDocument_ = true; | 75 this.isInDocument_ = true; |
| 76 for (var child, i = 0; child = this.children_[i]; i++) { | 76 this.children_.forEach(function(child) { |
| 77 if (!child.isInDocument && child.getElement()) { | 77 if (!child.isInDocument && child.getElement()) { |
| 78 child.enterDocument(); | 78 child.enterDocument(); |
| 79 } | 79 } |
| 80 } | 80 }); |
| 81 }, | 81 }, |
| 82 | 82 |
| 83 /** Removes all event listeners. */ | 83 /** Removes all event listeners. */ |
| 84 exitDocument: function() { | 84 exitDocument: function() { |
| 85 for (var child, i = 0; child = this.children_[i]; i++) { | 85 this.children_.forEach(function(child) { |
| 86 if (child.isInDocument) { | 86 if (child.isInDocument) { |
| 87 child.exitDocument(); | 87 child.exitDocument(); |
| 88 } | 88 } |
| 89 } | 89 }); |
| 90 this.tracker_.removeAll(); | 90 this.tracker_.removeAll(); |
| 91 this.isInDocument_ = false; | 91 this.isInDocument_ = false; |
| 92 }, | 92 }, |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Renders this UI component and appends the element to the given parent | 95 * Renders this UI component and appends the element to the given parent |
| 96 * element. | 96 * element. |
| 97 * @param {!Element} parentElement Element to render the component's | 97 * @param {!Element} parentElement Element to render the component's |
| 98 * element into. | 98 * element into. |
| 99 */ | 99 */ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 setIsVisible(el, true); | 183 setIsVisible(el, true); |
| 184 } | 184 } |
| 185 return el; | 185 return el; |
| 186 } | 186 } |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 return { | 189 return { |
| 190 Component: Component | 190 Component: Component |
| 191 }; | 191 }; |
| 192 }); | 192 }); |
| OLD | NEW |