From a5f917bbc55e295896b8084f6657eb8b6abaf8a8 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 15 Jul 2016 15:33:36 -0300 Subject: Add TimedMediaHandler extension that allows display audio and video files in wiki pages, using the same syntax as for image files --- .../resources/mw.TMHGalleryHook.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 extensions/TimedMediaHandler/resources/mw.TMHGalleryHook.js (limited to 'extensions/TimedMediaHandler/resources/mw.TMHGalleryHook.js') diff --git a/extensions/TimedMediaHandler/resources/mw.TMHGalleryHook.js b/extensions/TimedMediaHandler/resources/mw.TMHGalleryHook.js new file mode 100644 index 00000000..fd23690e --- /dev/null +++ b/extensions/TimedMediaHandler/resources/mw.TMHGalleryHook.js @@ -0,0 +1,46 @@ +/** +* Simple script to add pop-up video dialog link support for video thumbnails +*/ +( function ( mw ) { + // Hook to allow dynamically resizing videos in image galleries + mw.hook( 'mediawiki.page.gallery.resize' ).add( function ( info ) { + var $mwPlayerContainer, + $popUp, + $tmhVideo, + $mwContainer = info.$imageDiv.find( '.mediaContainer' ); + if ( info.resolved ) { + // Everything is already done here. + return; + } + + $mwContainer = info.$imageDiv.find( '.mediaContainer' ); + if ( $mwContainer.length ) { + // Add some padding, so caption doesn't overlap video controls if + // we are overlaying the caption on top of the image. + if ( !info.$outerDiv.parent().hasClass( 'mw-gallery-packed' ) ) { + info.$outerDiv.find( 'div.gallerytext' ).css( 'padding-bottom', '20px' ); + } + + info.$imageDiv.width( info.imgWidth ); + $mwContainer.width( info.imgWidth ); + $mwPlayerContainer = $mwContainer.children( '.mwPlayerContainer' ); + if ( $mwPlayerContainer.length ) { + // Case 1: HTML5 player already loaded + $mwPlayerContainer.width( info.imgWidth ).height( info.imgHeight ); + $mwPlayerContainer.find( 'img.playerPoster' ).width( info.imgWidth ).height( info.imgHeight ); + } else { + // Case 2: Raw video element + $tmhVideo = info.$imageDiv.find( 'video' ); + $tmhVideo.width( info.imgWidth ).height( info.imgHeight ); + } + info.resolved = true; + return; + } + + $popUp = info.$imageDiv.find( '.PopUpMediaTransform' ); + if ( $popUp.length ) { + info.$imageDiv.width( info.imgWidth ); + $popUp.add( $popUp.find( 'img' ) ).width( info.imgWidth ).height( info.imgHeight ); + } + } ); +} )( mediaWiki ); -- cgit v1.2.3-54-g00ecf