r67040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67039‎ | r67040 | r67041 >
Date:03:20, 29 May 2010
Author:neilk
Status:deferred
Tags:
Comment:
allow front panel to change size in between morphings
Modified paths:
  • /trunk/extensions/UploadWizard/js/jquery/plugins/jquery.morphCrossfade.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/js/jquery/plugins/jquery.morphCrossfade.js
@@ -47,14 +47,17 @@
4848 // the elements that are immediate children are the crossfadables
4949 // they must all be "on top" of each other, so position them relative
5050 this.css( {
51 - 'position' : 'relative',
52 - 'overflow' : 'hidden'
 51+ position : 'relative',
 52+ overflow : 'hidden',
 53+ scroll: 'none'
5354 } );
5455 this.children().css( {
55 - 'opacity': 0,
56 - 'position': 'absolute',
 56+ position: 'absolute',
5757 'top': '0px',
58 - 'left' : '0px'
 58+ left : '0px',
 59+ scroll: 'none',
 60+ opacity: 0,
 61+ visibility: 'hidden'
5962 } );
6063
6164 // should achieve the same result as crossfade( this.children().first() ) but without
@@ -66,24 +69,42 @@
6770
6871 /**
6972 * Initialize crossfading of the children of an element
70 - * @param selector should be an immediate child of the crossfader element
 73+ * @param selector of new thing to show; should be an immediate child of the crossfader element
7174 * @param speed (optional) how fast to crossfade, in milliseconds
7275 */
73 - $.fn.morphCrossfade = function( selector, speed ) {
 76+ $.fn.morphCrossfade = function( newPanelSelector, speed ) {
 77+ var container = this;
7478 if ( typeof speed === 'undefined' ) {
7579 speed = 400;
7680 }
7781
78 - if ( this.data( 'crossfadeDisplay' ) ) {
 82+ container.css( { 'overflow' : 'hidden' } );
 83+
 84+ $oldPanel = $( container.data( 'crossfadeDisplay' ) );
 85+ if ( $oldPanel ) {
 86+ // remove auto setting of height from container, and
 87+ // make doubly sure that the container height is equal to oldPanel
 88+ container.css( { height: $oldPanel.outerHeight() } );
 89+ // take it out of the flow
 90+ $oldPanel.css( { position: 'absolute' } );
7991 // fade WITHOUT hiding when opacity = 0
80 - $( this.data( 'crossfadeDisplay' ) ).animate( { opacity: 0 }, speed );
 92+ $oldPanel.animate( { opacity: 0 }, speed, 'linear', function() {
 93+ $oldPanel.css( { visibility: 'hidden'} )
 94+ } );
8195 }
82 - this.data( 'crossfadeDisplay', selector );
 96+ container.data( 'crossfadeDisplay', newPanelSelector );
8397
84 - this.animate( { height: $( selector ).outerHeight() }, speed );
85 - $( selector ).animate( { opacity: 1 }, speed );
 98+ var $newPanel = $( newPanelSelector );
 99+ $newPanel.css( { visibility: 'visible' } );
 100+ container.animate( { height: $newPanel.outerHeight() }, speed, 'linear', function() {
 101+ // we place it back into the flow, in case its size changes.
 102+ $newPanel.css( { position: 'relative' } );
 103+ // and allow the container to grow with it.
 104+ container.css( { height : 'auto' } );
 105+ } );
 106+ $newPanel.animate( { opacity: 1 }, speed );
86107
87 - return this;
 108+ return container;
88109 };
89110
90111 } )( jQuery );

Status & tagging log