Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: chrome/browser/resources/print_preview/print_preview_animations.js

Issue 8371017: Print Preview: Changing the structure of the html/css. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing unneeded css rules. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 rightColumn.classList.remove('no-padding');
92 wrapContentsInDiv(rightColumn, ['invisible']);
93
94 var toAnimate = el.querySelectorAll('.collapsible');
95 for (var i = 0; i < toAnimate.length; i++)
96 fadeInElement(toAnimate[i]);
97 el.classList.add('visible');
98 }
99
100 /**
101 * Fades out a printing option existing under |el|.
102 * @param {HTMLElement} el The element to hide.
103 */
104 function fadeOutOption(el) {
105 if (!el.classList.contains('visible'))
106 return;
107
108 wrapContentsInDiv(el.querySelector('h1'), ['visible']);
109 var rightColumn = el.querySelector('.right-column');
110 rightColumn.classList.add('no-padding');
111 wrapContentsInDiv(rightColumn, ['visible']);
112
113 var toAnimate = el.querySelectorAll('.collapsible');
114 for (var i = 0; i < toAnimate.length; i++)
115 fadeOutElement(toAnimate[i]);
116 el.classList.remove('visible');
117 }
118
119 /**
120 * Wraps the contents of |el| in a div element and attaches css classes
121 * |classes| in the new div, only if has not been already done. It is neccesary
122 * for animating the height of table cells.
123 * @param {HTMLElement} el The element to be processed.
124 * @param {array} classes The css classes to add.
125 */
126 function wrapContentsInDiv(el, classes) {
127 var div = el.querySelector('div');
128 if (!div || !div.classList.contains('collapsible')) {
129 el.innerHTML = '<div>' + el.innerHTML + '</div>';
130 div = el.querySelector('div');
131 div.classList.add('collapsible');
132 }
133
134 div.classList.classList = '';
135 for (var i = 0; i < classes.length; i++)
136 div.classList.add(classes[i]);
137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698