https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114157
Revision: 114157 Author: jdlrobson Date: 2012-03-19 17:17:17 +0000 (Mon, 19 Mar 2012) Log Message: ----------- provide different animations for references provide a slide animation as well as one with no animation also clear the lastLink as otherwise a 3rd click on a link will not re-reveal it Modified Paths: -------------- trunk/extensions/MobileFrontend/javascripts/references.js Modified: trunk/extensions/MobileFrontend/javascripts/references.js =================================================================== --- trunk/extensions/MobileFrontend/javascripts/references.js 2012-03-19 17:15:33 UTC (rev 114156) +++ trunk/extensions/MobileFrontend/javascripts/references.js 2012-03-19 17:17:17 UTC (rev 114157) @@ -4,6 +4,8 @@ hashtest = window.location.hash.substr(1).match(/refspeed:([0-9]*)/); options.animationSpeed = hashtest ? parseInt( hashtest[1], 10 ) : 500; + hashtest = window.location.hash.substr(1).match(/refanimation:([a-z]*)/); + options.animation = hashtest ? hashtest[1] : null; function collect() { var references = {}; @@ -32,13 +34,23 @@ function init() { $( '<div id="mf-references"><div></div></div>' ).hide().appendTo( document.body ); var close = function() { - $( '#mf-references' ).fadeOut( options.animationSpeed ); + var top; + lastLink = null; + if( options.animation === 'none' ) { + $( '#mf-references' ).hide(); + } else if( options.animation === 'slide' ){ + top = window.innerHeight + window.pageYOffset; + $( '#mf-references' ).show().animate( { top: top }, options.animationSpeed ); + } else { + $( '#mf-references' ).fadeOut( options.animationSpeed ); + } }, lastLink; $( '<button>close</button>' ).click( close ).appendTo( '#mf-references' ); $( '.mw-cite-backlink a' ).click( close ); var data, html, href, references = collect(); $( 'sup a' ).click( function(ev) { + var top, oh; href = $(this).attr( 'href' ); data = href && href.charAt(0) === '#' ? references[ href.substr( 1, href.length ) ] : null; @@ -52,11 +64,20 @@ attr( 'href', href ).appendTo('<div />').parent().html(); } $( '#mf-references div' ).html( html ); - $( '#mf-references' ).fadeIn( options.animationSpeed ); + calculatePosition(); + if( options.animation === 'none' ) { + $( '#mf-references' ).show(); + } else if( options.animation === 'slide' ){ + top = window.innerHeight + window.pageYOffset; + oh = $( '#mf-references' ).outerHeight(); + $( '#mf-references' ).show().css( { 'top': top } ). + animate( { top: top - oh }, options.animationSpeed ); + } else { + $( '#mf-references' ).fadeIn( options.animationSpeed ); + } } else { close(); } - calculatePosition(); ev.preventDefault(); }); } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs