diff options
Diffstat (limited to 'extensions/TimedMediaHandler/resources/mw.PopUpThumbVideo.js')
-rw-r--r-- | extensions/TimedMediaHandler/resources/mw.PopUpThumbVideo.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/extensions/TimedMediaHandler/resources/mw.PopUpThumbVideo.js b/extensions/TimedMediaHandler/resources/mw.PopUpThumbVideo.js new file mode 100644 index 00000000..c0aa30df --- /dev/null +++ b/extensions/TimedMediaHandler/resources/mw.PopUpThumbVideo.js @@ -0,0 +1,44 @@ +/** +* Simple script to add pop-up video dialog link support for video thumbnails +*/ +( function ( mw, $ ) { + $( document ).ready( function () { + $('.PopUpMediaTransform a').each( function () { + var link, title, + parent = $( this ).parent(); + if ( parent.attr( 'videopayload' ) ) { + $( this ).click( function ( /*event*/ ) { + var thisref = this; + + mw.loader.using( 'mw.MwEmbedSupport', function () { + var $videoContainer = $( $( thisref ).parent().attr( 'videopayload' ) ); + mw.addDialog({ + 'width': 'auto', + 'height': 'auto', + 'title': mw.html.escape( $videoContainer.find( 'video, audio' ).attr( 'data-mwtitle' ) ), + 'content': $videoContainer, + 'close': function(){ + // On close destroy the dialog rather than just hiding it, + // so it doesn't eat up resources or keep playing. + $( this ).remove(); + return true; + }, + 'open': function() { + $( this ).find( 'video, audio' ).embedPlayer(); + } + }) + .css( 'overflow', 'hidden' ); + } ); + // don't follow file link + return false; + } ); + } else if ( parent.attr( 'data-videopayload' ) ) { + link = $( this ).attr( 'href' ); + title = mw.Title.newFromImg( { src: link } ); + if ( title && title.getPrefixedDb() !== mw.config.get( 'wgPageName' ) ) { + $( this ).attr( 'href', title.getUrl() ); + } + } /* else fall back to linking directly to media file */ + } ); + } ); +} )( mediaWiki, jQuery ); |