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 // 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 function addAnimation(code) { | 8 function addAnimation(code) { |
9 var name = 'anim' + animationCounter; | 9 var name = 'anim' + animationCounter; |
10 animationCounter++; | 10 animationCounter++; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 /** | 71 /** |
72 * Removes the <style> element corrsponding to |animationName| from the DOM. | 72 * Removes the <style> element corrsponding to |animationName| from the DOM. |
73 * @param {string} animationName The name of the animation to be removed. | 73 * @param {string} animationName The name of the animation to be removed. |
74 */ | 74 */ |
75 function fadeInOutCleanup(animationName) { | 75 function fadeInOutCleanup(animationName) { |
76 animEl = document.getElementById(animationName); | 76 animEl = document.getElementById(animationName); |
77 if (animEl) | 77 if (animEl) |
78 animEl.parentNode.removeChild(animEl); | 78 animEl.parentNode.removeChild(animEl); |
79 } | 79 } |
80 | 80 |
| 81 /** |
| 82 * Fades in a printing option existing under |el|. |
| 83 * @param {HTMLElement} el The element to hide. |
| 84 */ |
| 85 function fadeInOption(el) { |
| 86 if (el.classList.contains('visible')) |
| 87 return; |
| 88 |
| 89 wrapContentsInDiv(el.querySelector('h1'), ['invisible']); |
| 90 var rightColumn = el.querySelector('.right-column'); |
| 91 wrapContentsInDiv(rightColumn, ['invisible']); |
| 92 |
| 93 var toAnimate = el.querySelectorAll('.collapsible'); |
| 94 for (var i = 0; i < toAnimate.length; i++) |
| 95 fadeInElement(toAnimate[i]); |
| 96 el.classList.add('visible'); |
| 97 } |
| 98 |
| 99 /** |
| 100 * Fades out a printing option existing under |el|. |
| 101 * @param {HTMLElement} el The element to hide. |
| 102 */ |
| 103 function fadeOutOption(el) { |
| 104 if (!el.classList.contains('visible')) |
| 105 return; |
| 106 |
| 107 wrapContentsInDiv(el.querySelector('h1'), ['visible']); |
| 108 var rightColumn = el.querySelector('.right-column'); |
| 109 wrapContentsInDiv(rightColumn, ['visible']); |
| 110 |
| 111 var toAnimate = el.querySelectorAll('.collapsible'); |
| 112 for (var i = 0; i < toAnimate.length; i++) |
| 113 fadeOutElement(toAnimate[i]); |
| 114 el.classList.remove('visible'); |
| 115 } |
| 116 |
| 117 /** |
| 118 * Wraps the contents of |el| in a div element and attaches css classes |
| 119 * |classes| in the new div, only if has not been already done. It is neccesary |
| 120 * for animating the height of table cells. |
| 121 * @param {HTMLElement} el The element to be processed. |
| 122 * @param {array} classes The css classes to add. |
| 123 */ |
| 124 function wrapContentsInDiv(el, classes) { |
| 125 var div = el.querySelector('div'); |
| 126 if (!div || !div.classList.contains('collapsible')) { |
| 127 div = document.createElement('div'); |
| 128 while (el.childNodes.length > 0) |
| 129 div.appendChild(el.firstChild); |
| 130 el.appendChild(div); |
| 131 } |
| 132 |
| 133 div.className = ''; |
| 134 div.classList.add('collapsible'); |
| 135 for (var i = 0; i < classes.length; i++) |
| 136 div.classList.add(classes[i]); |
| 137 } |
OLD | NEW |