comparison js/mpiwg.js @ 198:7515f7e51b0f

styles for flyout divs (for websites).
author casties
date Mon, 24 Jun 2013 18:05:04 +0200
parents b0ed3974efbd
children 5ffb9e7167b6
comparison
equal deleted inserted replaced
197:b0ed3974efbd 198:7515f7e51b0f
181 }).css('cursor', 'pointer'); 181 }).css('cursor', 'pointer');
182 }); 182 });
183 183
184 /* 184 /*
185 * flyout divs 185 * flyout divs
186 *
187 * currently only for div.flyout in col in row.triple.
188 *
189 * div.flyout contains img.flyout_open and img.flyout_close.
190 *
191 * div.flyout gets additional class .flying when open.
192 *
193 * div.folded will be shown when open.
194 *
186 */ 195 */
187 $('.flyout').each(function () { 196 $('.flyout').each(function () {
197 // flyout target size
198 var tw = 300;
199 var th = 400;
188 var $flyout = $(this); 200 var $flyout = $(this);
189 var parent = $flyout.parent(); 201 var $buttons = $flyout.find('.flyout_open, .flyout_close');
190 var ph = parent.height();
191 var pw = parent.width();
192 // size up to parent in folded state 202 // size up to parent in folded state
193 var dh = ph - $flyout.outerHeight(); 203 var dh = $flyout.parent().height() - $flyout.outerHeight();
194 if (dh > 0) { 204 if (dh > 0) {
195 $flyout.height($flyout.height()+dh); 205 $flyout.height($flyout.height()+dh);
196 } 206 }
207 // save original size
208 var ow = $flyout.width();
209 var oh = $flyout.height();
210 // handle click on open button
197 $flyout.find('.flyout_open').on('click', function () { 211 $flyout.find('.flyout_open').on('click', function () {
198 console.debug('flyout click on ', this);
199 $flyout.addClass('flying'); 212 $flyout.addClass('flying');
200 $flyout.css('position','absolute'); 213 $flyout.css('position','absolute');
201 $flyout.width(2*pw); 214 $flyout.animate({'width': tw, 'height': th}, 'fast');
202 $flyout.height(2*ph); 215 // change open to close button
203 }).css('cursor', 'pointer'); 216 $buttons.toggle();
204 217 }).css('cursor', 'pointer');
218 // handle click on close button
219 $flyout.find('.flyout_close').on('click', function () {
220 $flyout.animate({'width': ow, 'height': oh}, {
221 'duration': 'fast',
222 'complete': function () {
223 $flyout.removeClass('flying');
224 $flyout.css('position','relative');
225 // change close to open button
226 $buttons.toggle();
227 }
228 });
229 }).css('cursor', 'pointer');
205 }); 230 });
206 231
207 }); 232 });