Index: trunk/extensions/MobileFrontend/javascripts/references.js |
— | — | @@ -4,6 +4,8 @@ |
5 | 5 | |
6 | 6 | hashtest = window.location.hash.substr(1).match(/refspeed:([0-9]*)/); |
7 | 7 | options.animationSpeed = hashtest ? parseInt( hashtest[1], 10 ) : 500; |
| 8 | + hashtest = window.location.hash.substr(1).match(/refanimation:([a-z]*)/); |
| 9 | + options.animation = hashtest ? hashtest[1] : null; |
8 | 10 | |
9 | 11 | function collect() { |
10 | 12 | var references = {}; |
— | — | @@ -32,13 +34,23 @@ |
33 | 35 | function init() { |
34 | 36 | $( '<div id="mf-references"><div></div></div>' ).hide().appendTo( document.body ); |
35 | 37 | var close = function() { |
36 | | - $( '#mf-references' ).fadeOut( options.animationSpeed ); |
| 38 | + var top; |
| 39 | + lastLink = null; |
| 40 | + if( options.animation === 'none' ) { |
| 41 | + $( '#mf-references' ).hide(); |
| 42 | + } else if( options.animation === 'slide' ){ |
| 43 | + top = window.innerHeight + window.pageYOffset; |
| 44 | + $( '#mf-references' ).show().animate( { top: top }, options.animationSpeed ); |
| 45 | + } else { |
| 46 | + $( '#mf-references' ).fadeOut( options.animationSpeed ); |
| 47 | + } |
37 | 48 | }, lastLink; |
38 | 49 | $( '<button>close</button>' ).click( close ).appendTo( '#mf-references' ); |
39 | 50 | $( '.mw-cite-backlink a' ).click( close ); |
40 | 51 | |
41 | 52 | var data, html, href, references = collect(); |
42 | 53 | $( 'sup a' ).click( function(ev) { |
| 54 | + var top, oh; |
43 | 55 | href = $(this).attr( 'href' ); |
44 | 56 | data = href && href.charAt(0) === '#' ? |
45 | 57 | references[ href.substr( 1, href.length ) ] : null; |
— | — | @@ -52,11 +64,20 @@ |
53 | 65 | attr( 'href', href ).appendTo('<div />').parent().html(); |
54 | 66 | } |
55 | 67 | $( '#mf-references div' ).html( html ); |
56 | | - $( '#mf-references' ).fadeIn( options.animationSpeed ); |
| 68 | + calculatePosition(); |
| 69 | + if( options.animation === 'none' ) { |
| 70 | + $( '#mf-references' ).show(); |
| 71 | + } else if( options.animation === 'slide' ){ |
| 72 | + top = window.innerHeight + window.pageYOffset; |
| 73 | + oh = $( '#mf-references' ).outerHeight(); |
| 74 | + $( '#mf-references' ).show().css( { 'top': top } ). |
| 75 | + animate( { top: top - oh }, options.animationSpeed ); |
| 76 | + } else { |
| 77 | + $( '#mf-references' ).fadeIn( options.animationSpeed ); |
| 78 | + } |
57 | 79 | } else { |
58 | 80 | close(); |
59 | 81 | } |
60 | | - calculatePosition(); |
61 | 82 | ev.preventDefault(); |
62 | 83 | }); |
63 | 84 | } |