| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * PreviewPanel UI class. | 8 * PreviewPanel UI class. |
| 9 * @param {HTMLElement} element DOM Element of preview panel. | 9 * @param {HTMLElement} element DOM Element of preview panel. |
| 10 * @param {PreviewPanel.VisibilityType} visibilityType Initial value of the | 10 * @param {PreviewPanel.VisibilityType} visibilityType Initial value of the |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 PreviewPanel.Event = Object.freeze({ | 85 PreviewPanel.Event = Object.freeze({ |
| 86 // Event to be triggered at the end of visibility change. | 86 // Event to be triggered at the end of visibility change. |
| 87 VISIBILITY_CHANGE: 'visibilityChange' | 87 VISIBILITY_CHANGE: 'visibilityChange' |
| 88 }); | 88 }); |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Visibility type of the preview panel. | 91 * Visibility type of the preview panel. |
| 92 */ | 92 */ |
| 93 PreviewPanel.VisibilityType = Object.freeze({ | 93 PreviewPanel.VisibilityType = Object.freeze({ |
| 94 // Preview panel always shows. | 94 // Preview panel always shows. |
| 95 ALWAYS_VISIBLE: 'alwaysVisible', | 95 ALWAYS: 'always', |
| 96 // Preview panel shows when the entries property are set. | 96 // Preview panel shows when the entries property are set. |
| 97 AUTO: 'auto', | 97 AUTO: 'auto', |
| 98 // Preview panel does not show. | 98 // Preview panel does not show. |
| 99 ALWAYS_HIDDEN: 'alwaysHidden' | 99 HIDDEN: 'hidden' |
| 100 }); | 100 }); |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * @private | 103 * @private |
| 104 */ | 104 */ |
| 105 PreviewPanel.Visibility_ = Object.freeze({ | 105 PreviewPanel.Visibility_ = Object.freeze({ |
| 106 VISIBLE: 'visible', | 106 VISIBLE: 'visible', |
| 107 HIDING: 'hiding', | 107 HIDING: 'hiding', |
| 108 HIDDEN: 'hidden' | 108 HIDDEN: 'hidden' |
| 109 }); | 109 }); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 /** | 162 /** |
| 163 * Update the visibility of the preview panel. | 163 * Update the visibility of the preview panel. |
| 164 * @private | 164 * @private |
| 165 */ | 165 */ |
| 166 PreviewPanel.prototype.updateVisibility_ = function() { | 166 PreviewPanel.prototype.updateVisibility_ = function() { |
| 167 // Get the new visibility value. | 167 // Get the new visibility value. |
| 168 var visibility = this.element_.getAttribute('visibility'); | 168 var visibility = this.element_.getAttribute('visibility'); |
| 169 var newVisible = null; | 169 var newVisible = null; |
| 170 switch (this.visibilityType_) { | 170 switch (this.visibilityType_) { |
| 171 case PreviewPanel.VisibilityType.ALWAYS_VISIBLE: | 171 case PreviewPanel.VisibilityType.ALWAYS: |
| 172 newVisible = true; | 172 newVisible = true; |
| 173 break; | 173 break; |
| 174 case PreviewPanel.VisibilityType.AUTO: | 174 case PreviewPanel.VisibilityType.AUTO: |
| 175 newVisible = this.entries_.length != 0 || | 175 newVisible = this.entries_.length != 0 || |
| 176 !PathUtil.isRootPath(this.currentPath_); | 176 !PathUtil.isRootPath(this.currentPath_); |
| 177 break; | 177 break; |
| 178 case PreviewPanel.VisibilityType.ALWAYS_HIDDEN: | 178 case PreviewPanel.VisibilityType.HIDDEN: |
| 179 newVisible = false; | 179 newVisible = false; |
| 180 break; | 180 break; |
| 181 default: | 181 default: |
| 182 console.error('Invalid visibilityType.'); | 182 console.error('Invalid visibilityType.'); |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 | 185 |
| 186 // If the visibility has been already the new value, just return. | 186 // If the visibility has been already the new value, just return. |
| 187 if ((visibility == PreviewPanel.Visibility_.VISIBLE && newVisible) || | 187 if ((visibility == PreviewPanel.Visibility_.VISIBLE && newVisible) || |
| 188 (visibility == PreviewPanel.Visibility_.HIDDEN && !newVisible)) | 188 (visibility == PreviewPanel.Visibility_.HIDDEN && !newVisible)) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 204 */ | 204 */ |
| 205 PreviewPanel.prototype.onTransitionEnd_ = function(event) { | 205 PreviewPanel.prototype.onTransitionEnd_ = function(event) { |
| 206 if (event.target != this.element_ || event.propertyName != 'opacity') | 206 if (event.target != this.element_ || event.propertyName != 'opacity') |
| 207 return; | 207 return; |
| 208 var visibility = this.element_.getAttribute('visibility'); | 208 var visibility = this.element_.getAttribute('visibility'); |
| 209 if (visibility != PreviewPanel.Visibility_.HIDING) | 209 if (visibility != PreviewPanel.Visibility_.HIDING) |
| 210 return; | 210 return; |
| 211 this.element_.setAttribute('visibility', PreviewPanel.Visibility_.HIDDEN); | 211 this.element_.setAttribute('visibility', PreviewPanel.Visibility_.HIDDEN); |
| 212 cr.dispatchSimpleEvent(this, PreviewPanel.Event.VISIBILITY_CHANGE); | 212 cr.dispatchSimpleEvent(this, PreviewPanel.Event.VISIBILITY_CHANGE); |
| 213 }; | 213 }; |
| OLD | NEW |