| 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 // Counter used to give webkit animations unique names. | 5 // Counter used to give webkit animations unique names. |
| 6 var animationCounter = 0; | 6 var animationCounter = 0; |
| 7 | 7 |
| 8 var animationEventTracker_ = new EventTracker(); | 8 var animationEventTracker_ = new EventTracker(); |
| 9 | 9 |
| 10 function addAnimation(code) { | 10 function addAnimation(code) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 /** | 36 /** |
| 37 * Fades in an element. Used for both printing options and error messages | 37 * Fades in an element. Used for both printing options and error messages |
| 38 * appearing underneath the textfields. | 38 * appearing underneath the textfields. |
| 39 * @param {HTMLElement} el The element to be faded in. | 39 * @param {HTMLElement} el The element to be faded in. |
| 40 */ | 40 */ |
| 41 function fadeInElement(el) { | 41 function fadeInElement(el) { |
| 42 if (el.classList.contains('visible')) | 42 if (el.classList.contains('visible')) |
| 43 return; | 43 return; |
| 44 el.classList.remove('closing'); | 44 el.classList.remove('closing'); |
| 45 el.hidden = false; | 45 el.hidden = false; |
| 46 el.setAttribute('aria-hidden', 'false'); |
| 46 el.style.height = 'auto'; | 47 el.style.height = 'auto'; |
| 47 var height = el.offsetHeight; | 48 var height = el.offsetHeight; |
| 48 el.style.height = height + 'px'; | 49 el.style.height = height + 'px'; |
| 49 var animName = addAnimation(getFadeInAnimationCode(height)); | 50 var animName = addAnimation(getFadeInAnimationCode(height)); |
| 50 animationEventTracker_.add( | 51 animationEventTracker_.add( |
| 51 el, 'webkitAnimationEnd', onFadeInAnimationEnd.bind(el), false); | 52 el, 'webkitAnimationEnd', onFadeInAnimationEnd.bind(el), false); |
| 52 el.style.webkitAnimationName = animName; | 53 el.style.webkitAnimationName = animName; |
| 53 el.classList.add('visible'); | 54 el.classList.add('visible'); |
| 54 } | 55 } |
| 55 | 56 |
| 56 /** | 57 /** |
| 57 * Fades out an element. Used for both printing options and error messages | 58 * Fades out an element. Used for both printing options and error messages |
| 58 * appearing underneath the textfields. | 59 * appearing underneath the textfields. |
| 59 * @param {HTMLElement} el The element to be faded out. | 60 * @param {HTMLElement} el The element to be faded out. |
| 60 */ | 61 */ |
| 61 function fadeOutElement(el) { | 62 function fadeOutElement(el) { |
| 62 if (!el.classList.contains('visible')) | 63 if (!el.classList.contains('visible')) |
| 63 return; | 64 return; |
| 64 fadeInAnimationCleanup(el); | 65 fadeInAnimationCleanup(el); |
| 65 el.style.height = 'auto'; | 66 el.style.height = 'auto'; |
| 66 var height = el.offsetHeight; | 67 var height = el.offsetHeight; |
| 67 el.style.height = height + 'px'; | 68 el.style.height = height + 'px'; |
| 68 el.offsetHeight; // Should force an update of the computed style. | 69 el.offsetHeight; // Should force an update of the computed style. |
| 69 animationEventTracker_.add( | 70 animationEventTracker_.add( |
| 70 el, 'webkitTransitionEnd', onFadeOutTransitionEnd.bind(el), false); | 71 el, 'webkitTransitionEnd', onFadeOutTransitionEnd.bind(el), false); |
| 71 el.classList.add('closing'); | 72 el.classList.add('closing'); |
| 72 el.classList.remove('visible'); | 73 el.classList.remove('visible'); |
| 74 el.setAttribute('aria-hidden', 'true'); |
| 73 } | 75 } |
| 74 | 76 |
| 75 /** | 77 /** |
| 76 * Executes when a fade out animation ends. | 78 * Executes when a fade out animation ends. |
| 77 * @param {WebkitTransitionEvent} event The event that triggered this listener. | 79 * @param {WebkitTransitionEvent} event The event that triggered this listener. |
| 78 * @this {HTMLElement} The element where the transition occurred. | 80 * @this {HTMLElement} The element where the transition occurred. |
| 79 */ | 81 */ |
| 80 function onFadeOutTransitionEnd(event) { | 82 function onFadeOutTransitionEnd(event) { |
| 81 if (event.propertyName != 'height') | 83 if (event.propertyName != 'height') |
| 82 return; | 84 return; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 while (el.childNodes.length > 0) | 171 while (el.childNodes.length > 0) |
| 170 div.appendChild(el.firstChild); | 172 div.appendChild(el.firstChild); |
| 171 el.appendChild(div); | 173 el.appendChild(div); |
| 172 } | 174 } |
| 173 | 175 |
| 174 div.className = ''; | 176 div.className = ''; |
| 175 div.classList.add('collapsible'); | 177 div.classList.add('collapsible'); |
| 176 for (var i = 0; i < classes.length; i++) | 178 for (var i = 0; i < classes.length; i++) |
| 177 div.classList.add(classes[i]); | 179 div.classList.add(classes[i]); |
| 178 } | 180 } |
| OLD | NEW |