| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * Modal dialog base component. | 9 * Modal dialog base component. |
| 10 * @param {!print_preview.MetricsContext} metricsContext Metrics | 10 * @param {!print_preview.MetricsContext} metricsContext Metrics |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 this.getElement().addEventListener('keydown', function f(e) { | 41 this.getElement().addEventListener('keydown', function f(e) { |
| 42 // Escape pressed -> cancel the dialog. | 42 // Escape pressed -> cancel the dialog. |
| 43 if (!hasKeyModifiers(e)) { | 43 if (!hasKeyModifiers(e)) { |
| 44 if (e.keyCode == 27) { | 44 if (e.keyCode == 27) { |
| 45 e.stopPropagation(); | 45 e.stopPropagation(); |
| 46 e.preventDefault(); | 46 e.preventDefault(); |
| 47 this.cancel(); | 47 this.cancel(); |
| 48 } else if (e.keyCode == 13) { | 48 } else if (e.keyCode == 13) { |
| 49 var activeElementTag = document.activeElement ? | 49 var activeElementTag = document.activeElement ? |
| 50 document.activeElement.tagName.toUpperCase() : ''; | 50 document.activeElement.tagName.toUpperCase() : |
| 51 ''; |
| 51 if (activeElementTag != 'BUTTON' && activeElementTag != 'SELECT') { | 52 if (activeElementTag != 'BUTTON' && activeElementTag != 'SELECT') { |
| 52 if (this.onEnterPressedInternal()) { | 53 if (this.onEnterPressedInternal()) { |
| 53 e.stopPropagation(); | 54 e.stopPropagation(); |
| 54 e.preventDefault(); | 55 e.preventDefault(); |
| 55 } | 56 } |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 }.bind(this)); | 60 }.bind(this)); |
| 60 | 61 |
| 61 this.tracker.add( | 62 this.tracker.add( |
| 62 this.getChildElement('.page > .close-button'), | 63 this.getChildElement('.page > .close-button'), 'click', |
| 63 'click', | |
| 64 this.cancel.bind(this)); | 64 this.cancel.bind(this)); |
| 65 | 65 |
| 66 this.tracker.add( | 66 this.tracker.add( |
| 67 this.getElement(), 'click', this.onOverlayClick_.bind(this)); | 67 this.getElement(), 'click', this.onOverlayClick_.bind(this)); |
| 68 this.tracker.add( | 68 this.tracker.add( |
| 69 this.getChildElement('.page'), | 69 this.getChildElement('.page'), 'webkitAnimationEnd', |
| 70 'webkitAnimationEnd', | |
| 71 this.onAnimationEnd_.bind(this)); | 70 this.onAnimationEnd_.bind(this)); |
| 72 }, | 71 }, |
| 73 | 72 |
| 74 /** @return {boolean} Whether the component is visible. */ | 73 /** @return {boolean} Whether the component is visible. */ |
| 75 getIsVisible: function() { | 74 getIsVisible: function() { |
| 76 return !this.getElement().classList.contains('transparent'); | 75 return !this.getElement().classList.contains('transparent'); |
| 77 }, | 76 }, |
| 78 | 77 |
| 79 /** @param {boolean} isVisible Whether the component is visible. */ | 78 /** @param {boolean} isVisible Whether the component is visible. */ |
| 80 setIsVisible: function(isVisible) { | 79 setIsVisible: function(isVisible) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 * @param {Event} e Contains the target done animating. | 128 * @param {Event} e Contains the target done animating. |
| 130 * @private | 129 * @private |
| 131 */ | 130 */ |
| 132 onAnimationEnd_: function(e) { | 131 onAnimationEnd_: function(e) { |
| 133 if (e.target && e.animationName == 'pulse') | 132 if (e.target && e.animationName == 'pulse') |
| 134 e.target.classList.remove('pulse'); | 133 e.target.classList.remove('pulse'); |
| 135 } | 134 } |
| 136 }; | 135 }; |
| 137 | 136 |
| 138 // Export | 137 // Export |
| 139 return { | 138 return {Overlay: Overlay}; |
| 140 Overlay: Overlay | |
| 141 }; | |
| 142 }); | 139 }); |
| OLD | NEW |