TheDJ has uploaded a new change for review. https://gerrit.wikimedia.org/r/173509
Change subject: JSCS cleanup for timed media handler ...................................................................... JSCS cleanup for timed media handler Change-Id: Ia6b22c951e33e4f1fdfbf57cd5562f125dc5f656 --- M resources/ext.tmh.transcodetable.js M resources/mw.MediaWikiPlayer.loader.js M resources/mw.MediaWikiPlayerSupport.js M resources/mw.PopUpThumbVideo.js 4 files changed, 175 insertions(+), 174 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/09/173509/1 diff --git a/resources/ext.tmh.transcodetable.js b/resources/ext.tmh.transcodetable.js index 5b1e443..ed0e901 100644 --- a/resources/ext.tmh.transcodetable.js +++ b/resources/ext.tmh.transcodetable.js @@ -1,23 +1,23 @@ /** * Javascript to support transcode table on image page */ -$(document).ready(function(){ +$( document ).ready( function () { var errorPopup, $errorLink; errorPopup = function () { // pop up dialog - mw.addDialog({ - 'width' : '640', - 'height' : '480', - 'title' : $(this).attr('title'), - 'content' : $('<textarea />') - .css({ + mw.addDialog( { + 'width': '640', + 'height': '480', + 'title': $(this).attr( 'title' ), + 'content': $('<textarea />') + .css( { 'width':'99%', 'height':'99%' - }) + } ) .text( $(this).attr('data-error') ) - }) - .css('overflow', 'hidden'); + } ) + .css( 'overflow', 'hidden' ); return false; } @@ -25,32 +25,32 @@ $( '.mw-filepage-transcodestatus .errorlink' ).click( errorPopup ); // New version. $errorLink = $( '.mw-filepage-transcodestatus .mw-tmh-pseudo-error-link' ); - $errorLink.wrapInner( function() { - var $this = $(this); + $errorLink.wrapInner( function () { + var $this = $( this ); return $( '<a />' ).attr( { href: '#', title: $this.text(), - 'data-error': $this.attr('data-error') + 'data-error': $this.attr( 'data-error' ) } ).click( errorPopup ); } ); // Reset transcode action: - $('.mw-filepage-transcodereset a').click( function(){ - var tKey = $(this).attr('data-transcodekey'); + $( '.mw-filepage-transcodereset a' ).click( function () { + var tKey = $( this ).attr( 'data-transcodekey' ); var buttons = {}; - buttons[ mw.msg('mwe-ok') ] = function(){ + buttons[ mw.msg( 'mwe-ok' ) ] = function () { var _thisDialog = this; // Only show cancel button while loading: var cancelBtn = {}; - cancelBtn[ mw.msg('mwe-cancel') ] = function() { - $(this).dialog("close"); + cancelBtn[ mw.msg( 'mwe-cancel' ) ] = function () { + $(this).dialog( 'close' ); } - $( _thisDialog ).dialog( "option", "buttons", cancelBtn ); + $( _thisDialog ).dialog( 'option', 'buttons', cancelBtn ); $( this ).loadingSpinner(); - var apiUrl = mw.config.get('wgServer') + mw.config.get( 'wgScriptPath' ) + '/api.php'; + var apiUrl = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php'; // Do an api post action: $.post( apiUrl, { 'action' : 'transcodereset', @@ -58,7 +58,7 @@ 'title' : mw.config.get('wgPageName'), 'token' : mw.user.tokens.get('editToken'), 'format' : 'json' - }, function( data ){ + }, function ( data ) { if( data && data['success'] ){ // refresh the page window.location.reload(); @@ -69,23 +69,23 @@ $( _thisDialog ).text( mw.msg( 'timedmedia-reset-error' ) ); } var okBtn = {}; - okBtn[ mw.msg('mwe-ok') ] = function() { $(this).dialog("close"); } - $( _thisDialog ).dialog( "option", "buttons", okBtn ); + okBtn[ mw.msg('mwe-ok') ] = function() { $(this).dialog( 'close' ); } + $( _thisDialog ).dialog( 'option', 'buttons', okBtn ); } }) }; - buttons[ mw.msg('mwe-cancel') ] =function(){ - $(this).dialog('close'); + buttons[ mw.msg( 'mwe-cancel' ) ] = function () { + $( this ).dialog( 'close' ); } // pop up dialog - mw.addDialog({ - 'width' : '400', - 'height' : '200', - 'title' : mw.msg('timedmedia-reset'), - 'content' : mw.msg('timedmedia-reset-confirm'), + mw.addDialog( { + 'width': '400', + 'height': '200', + 'title': mw.msg( 'timedmedia-reset' ), + 'content': mw.msg( 'timedmedia-reset-confirm' ), 'buttons': buttons - }) - .css('overflow', 'hidden'); + } ) + .css( 'overflow', 'hidden' ); return false; }) }) diff --git a/resources/mw.MediaWikiPlayer.loader.js b/resources/mw.MediaWikiPlayer.loader.js index 26e0991..6167418 100644 --- a/resources/mw.MediaWikiPlayer.loader.js +++ b/resources/mw.MediaWikiPlayer.loader.js @@ -1,8 +1,8 @@ -( function( mw, $ ) { +( function ( mw, $ ) { // Add MediaWikiSupportPlayer dependency on players with a mediaWiki title - $( mw ).bind( 'EmbedPlayerUpdateDependencies', function( event, embedPlayer, dependencySet ){ - if( $( embedPlayer ).attr( 'data-mwtitle' ) ){ + $( mw ).bind( 'EmbedPlayerUpdateDependencies', function ( event, embedPlayer, dependencySet ) { + if ( $( embedPlayer ).attr( 'data-mwtitle' ) ) { $.merge( dependencySet, ['mw.MediaWikiPlayerSupport'] ); } - }); -} )( window.mediaWiki, jQuery ); \ No newline at end of file + } ); +} )( mediaWiki, jQuery ); diff --git a/resources/mw.MediaWikiPlayerSupport.js b/resources/mw.MediaWikiPlayerSupport.js index 02cf920..727def4 100644 --- a/resources/mw.MediaWikiPlayerSupport.js +++ b/resources/mw.MediaWikiPlayerSupport.js @@ -1,35 +1,36 @@ -( function( mw, $ ) { +( function ( mw, $ ) { /** * Merge in the default video attributes supported by embedPlayer: */ mw.mergeConfig( 'EmbedPlayer.Attributes', { // A apiTitleKey for looking up subtitles, credits and related videos - "data-mwtitle" : null, + 'data-mwtitle': null, // The apiProvider where to lookup the title key - "data-mwprovider" : null - }); + 'data-mwprovider': null + } ); // Add mediaWiki player support to target embedPlayer - $( mw ).bind( 'EmbedPlayerNewPlayer', function( event, embedPlayer ){ + $( mw ).bind( 'EmbedPlayerNewPlayer', function ( event, embedPlayer ) { mw.addMediaWikiPlayerSupport( embedPlayer ); }); /** * Closure function wraps mediaWiki embedPlayer bindings */ - mw.addMediaWikiPlayerSupport = function( embedPlayer ){ + mw.addMediaWikiPlayerSupport = function ( embedPlayer ) { + var apiTitleKey, apiProvider, $creditsCache = false; // Set some local variables: - if( ! embedPlayer['data-mwtitle'] ){ + if ( !embedPlayer['data-mwtitle'] ) { return false; } else { - var apiTitleKey = embedPlayer['data-mwtitle']; + apiTitleKey = embedPlayer['data-mwtitle']; // legacy support ( set as attribute ) embedPlayer.apiTitleKey = apiTitleKey; } // Set local apiProvider via config if not defined - var apiProvider = embedPlayer['data-mwprovider']; - if( !apiProvider ){ + apiProvider = embedPlayer['data-mwprovider']; + if ( !apiProvider ) { apiProvider = mw.config.get( 'EmbedPlayer.ApiProvider' ); } @@ -37,37 +38,38 @@ * Loads mediaWiki sources for a given embedPlayer * @param {function} callback Function called once player sources have been added */ - function loadPlayerSources( callback ){ + function loadPlayerSources( callback ) { // Setup the request var request = { 'prop': 'imageinfo', // In case the user added File: or Image: to the apiKey: - 'titles': 'File:' + decodeURIComponent( apiTitleKey ).replace( /^(File:|Image:)/ , '' ), + 'titles': 'File:' + decodeURIComponent( apiTitleKey ).replace( /^(File:|Image:)/, '' ), 'iiprop': 'url|size|dimensions|metadata', 'iiurlwidth': embedPlayer.getWidth(), - 'redirects' : true // automatically resolve redirects + 'redirects': true // automatically resolve redirects }; // Run the request: - mw.getJSON( mw.getApiProviderURL( apiProvider ), request, function( data ){ + mw.getJSON( mw.getApiProviderURL( apiProvider ), request, function ( data ) { + var i, page, imageinfo; if ( data.query.pages ) { - for ( var i in data.query.pages ) { - if( i == '-1' ) { + for ( i in data.query.pages ) { + if ( i == '-1' ) { callback( false ); return ; } - var page = data.query.pages[i]; + page = data.query.pages[i]; } } else { callback( false ); return ; } // Make sure we have imageinfo: - if( ! page.imageinfo || !page.imageinfo[0] ){ + if ( !page.imageinfo || !page.imageinfo[0] ) { callback( false ); return ; } - var imageinfo = page.imageinfo[0]; + imageinfo = page.imageinfo[0]; // TODO these should call public methods rather than update internals: @@ -76,29 +78,28 @@ // Add the media src embedPlayer.mediaElement.tryAddSource( - $('<source />') + $( '<source />' ) .attr( 'src', imageinfo.url ) .get( 0 ) ); // Set the duration - if( imageinfo.metadata[2]['name'] == 'length' ) { - embedPlayer.duration = imageinfo.metadata[2]['value']; + if ( imageinfo.metadata[2].name == 'length' ) { + embedPlayer.duration = imageinfo.metadata[2].value; } // Set the width height // Make sure we have an accurate aspect ratio - if( imageinfo.height != 0 && imageinfo.width != 0 ) { + if ( imageinfo.height != 0 && imageinfo.width != 0 ) { embedPlayer.height = parseInt( embedPlayer.width * ( imageinfo.height / imageinfo.width ) ); } // Update the css for the player interface - $( embedPlayer ).css( 'height', embedPlayer.height); + $( embedPlayer ).css( 'height', embedPlayer.height ); callback(); }); } - /** * Build a clip credit from the resource wikiText page @@ -107,23 +108,24 @@ * * @param {String} resourceHTML Resource wiki text page contents */ - function doCreditLine( resourceHTML, articleUrl ){ + function doCreditLine( resourceHTML, articleUrl ) { + var authUrl, $page, $author, $links, $date, $authorLink + imgSize = { }, // Get the title string ( again a "Title" like js object could help out here. ) - var titleStr = embedPlayer.apiTitleKey.replace(/_/g, ' '); - + titleStr = embedPlayer.apiTitleKey.replace( /_/g, ' ' ), // Setup the initial credits line: - var $creditLine = $( '<div />'); + $creditLine = $( '<div />' ); // Add the title: $creditLine.append( - $('<span>').html( - mw.msg( 'mwe-embedplayer-credit-title' , + $( '<span>' ).html( + mw.msg( 'mwe-embedplayer-credit-title', // get the link - $('<div>').append( - $('<a/>').attr({ - 'href' : articleUrl, - 'title' : titleStr - }) + $( '<div>' ).append( + $( '<a/>' ).attr( { + 'href': articleUrl, + 'title': titleStr + } ) .text( titleStr ) )[0].innerHTML ) @@ -131,62 +133,60 @@ ); // Parse some data from the page info template if possible: - var $page = $( resourceHTML ); + $page = $( resourceHTML ); // Look for author: - var $author = $page.find('#fileinfotpl_aut'); - if( $author.length ){ + $author = $page.find( '#fileinfotpl_aut' ); + if ( $author.length ) { // Get the real author sibling of fileinfotpl_aut $authorText = $author.next() // Remove white space: - $authorText.find('br').remove(); + $authorText.find( 'br' ).remove(); // Update link to be absolute per page url context: - var $links = $authorText.find('a'); - if( $links.length ) { - $links.each(function(i, authorLink) { - var $authorLink = $(authorLink); - var authUrl = $authorLink.attr('href'); + $links = $authorText.find( 'a' ); + if ( $links.length ) { + $links.each( function ( i, authorLink ) { + $authorLink = $( authorLink ); + authUrl = $authorLink.attr( 'href' ); authUrl = mw.absoluteUrl( authUrl, articleUrl ); - $authorLink.attr('href', authUrl); + $authorLink.attr( 'href', authUrl ); }); } $creditLine.append( $( '<br />' ), - mw.msg('mwe-embedplayer-credit-author', $authorText.html() ) + mw.msg( 'mwe-embedplayer-credit-author', $authorText.html() ) ) } // Look for date: - var $date =$page.find('#fileinfotpl_date'); - if( $date.length ){ + $date = $page.find( '#fileinfotpl_date' ); + if ( $date.length ) { // Get the real date sibling of fileinfotpl_date $date = $date.next(); // remove white space: - $date.find('br').remove(); + $date.find( 'br' ).remove(); $creditLine.append( $( '<br />' ), - mw.msg('mwe-embedplayer-credit-date', $date.html() ) + mw.msg( 'mwe-embedplayer-credit-date', $date.html() ) ) } - // Build out the image and credit line - var imgSize = { }; - if( embedPlayer.isAudio() ){ + if ( embedPlayer.isAudio() ) { imgSize.height = imgSize.width = ( embedPlayer.controlBuilder.getOverlayWidth() < 250 ) ? 45 : 80; - } else{ + } else { imgSize.width = ( embedPlayer.controlBuilder.getOverlayWidth() < 250 ) ? 45 : 120; - imgSize.height = parseInt( imgSize.width * ( embedPlayer.getHeight()/ embedPlayer.getWidth() ) ); + imgSize.height = parseInt( imgSize.width * ( embedPlayer.getHeight() / embedPlayer.getWidth() ) ); } return $( '<div/>' ).addClass( 'creditline' ) .append( - $('<a/>').attr({ - 'href' : articleUrl, - 'title' : titleStr - }).html( - $('<img/>').attr( { + $( '<a/>' ).attr( { + 'href': articleUrl, + 'title': titleStr + } ).html( + $( '<img/>' ).attr( { 'border': 0, - 'src' : embedPlayer.poster + 'src': embedPlayer.poster } ).css( imgSize ) ) ) @@ -198,29 +198,28 @@ /** * Issues a request to populate the credits box */ - var $creditsCache = false; - function showCredits( $target, callback ){ - if( $creditsCache ){ + function showCredits( $target, callback ) { + var apiUrl, fileTitle, request, articleUrl = ''; + if ( $creditsCache ) { $target.html( $creditsCache ); callback( true ); return; } // Setup shortcuts: - var apiUrl = mw.getApiProviderURL( apiProvider ); - var fileTitle = 'File:' + decodeURIComponent( apiTitleKey).replace(/^File:|^Image:/, ''); + apiUrl = mw.getApiProviderURL( apiProvider ); + fileTitle = 'File:' + decodeURIComponent( apiTitleKey ).replace( /^File:|^Image:/, ''); // Get the image page ( cache for 1 hour ) - var request = { + request = { 'action': 'parse', 'page': fileTitle, - 'smaxage' : 3600, - 'maxage' : 3600 + 'smaxage': 3600, + 'maxage': 3600 }; - var articleUrl = ''; - mw.getJSON( apiUrl, request, function( data ){ + mw.getJSON( apiUrl, request, function ( data ) { descUrl = apiUrl.replace( 'api.php', 'index.php'); - descUrl+= '?title=' + encodeURIComponent( fileTitle ); + descUrl += '?title=' + encodeURIComponent( fileTitle ); if ( data && data.parse && data.parse.text && data.parse.text['*'] ) { // TODO improve provider 'concept' to support page title link $creditsCache = doCreditLine( data.parse.text['*'], descUrl ); @@ -236,25 +235,25 @@ */ // Show credits when requested - $( embedPlayer ).bindQueueCallback( 'showCredits', function( $target, callback ) { - if( $target.data('playerId') != embedPlayer.id ){ + $( embedPlayer ).bindQueueCallback( 'showCredits', function ( $target, callback ) { + if ( $target.data( 'playerId') != embedPlayer.id ) { // bad event trigger return ; } // Only request the credits once: - showCredits( $target, callback); + showCredits( $target, callback ); }); // Show credits on clip complete: - $( embedPlayer ).bind('onEndedDone', function( event, id ){ - if( embedPlayer.id != id ){ + $( embedPlayer ).bind( 'onEndedDone', function ( event, id ) { + if ( embedPlayer.id != id ) { // possible event trigger error. ( skip ) return ; } // dont show credits for audio elements, // seek to begining instead - if( embedPlayer.isAudio() ){ - embedPlayer.setCurrentTime(0); + if ( embedPlayer.isAudio() ) { + embedPlayer.setCurrentTime( 0 ); return ; } var cb = embedPlayer.controlBuilder; @@ -263,16 +262,16 @@ cb.showMenuItem( 'credits' ); }); - $( embedPlayer ).bind('showInlineDownloadLink', function(){ + $( embedPlayer ).bind( 'showInlineDownloadLink', function () { // Add recommend HTML5 player if we have non-native playback: if ( embedPlayer.controlBuilder.checkNativeWarning( ) ) { embedPlayer.controlBuilder.addWarningBinding( 'EmbedPlayer.ShowNativeWarning', mw.msg( 'mwe-embedplayer-for_best_experience', - $('<div>').append( - $('<a />').attr({ + $( '<div>' ).append( + $( '<a />' ).attr({ 'href': 'http://www.mediawiki.org/wiki/Extension:TimedMediaHandler/Client_download', - 'target' : '_new' + 'target': '_new' }) )[0].innerHTML ), @@ -281,95 +280,97 @@ } }); - $( embedPlayer ).bind( 'TimedText_BuildCCMenu', function(event, $menu, id ){ - if( id != embedPlayer.id ){ - _this = $('#' + id )[0].timedText; + $( embedPlayer ).bind( 'TimedText_BuildCCMenu', function ( event, $menu, id ) { + var pageTitle, + addTextPage, + $li; + if ( id != embedPlayer.id ) { + _this = $( '#' + id )[0].timedText; embedPlayer = _this.embedPlayer; } // Put in the "Make Transcript" link if config enabled and we have an api key - if( embedPlayer.apiTitleKey ){ + if ( embedPlayer.apiTitleKey ) { // check if not already there: - if( $menu.find( '.add-timed-text' ).length ){ + if ( $menu.find( '.add-timed-text' ).length ) { // add text link already present return ; } - var pageTitle = 'TimedText:' + - decodeURIComponent( embedPlayer.apiTitleKey ).replace(/^File:|^Image:/, ''); - var addTextPage = mw.getApiProviderURL( apiProvider ) + pageTitle = 'TimedText:' + + decodeURIComponent( embedPlayer.apiTitleKey ).replace( /^File:|^Image:/, '' ); + addTextPage = mw.getApiProviderURL( apiProvider ) .replace( 'api.php', 'index.php') + '?title=' + encodeURIComponent( pageTitle ); - var $li = $.getLineItem( mw.msg( 'mwe-timedtext-upload-timed-text'), 'script', function() { + $li = $.getLineItem( mw.msg( 'mwe-timedtext-upload-timed-text'), 'script', function () { window.location = addTextPage; }); $li.addClass( 'add-timed-text') - .find( "a" ) + .find( 'a' ) .attr( { 'href': addTextPage, - 'target' : '_new' - }); + 'target': '_new' + } ); $menu.append( $li ); } }); - $( embedPlayer ).bindQueueCallback( 'checkPlayerSourcesEvent', function( callback ) { + $( embedPlayer ).bindQueueCallback( 'checkPlayerSourcesEvent', function ( callback ) { // Only load source if none are available: - if( embedPlayer.mediaElement.sources.length == 0 ){ + if ( embedPlayer.mediaElement.sources.length == 0 ) { loadPlayerSources( callback ); } else { // No source to load, issue callback directly callback(); } - }); - $( mw ).bindQueueCallback( 'TimedText_LoadTextSource', function( source, callback ) { - if( !source['mwtitle'] || !source['mwprovider'] ){ + } ); + $( mw ).bindQueueCallback( 'TimedText_LoadTextSource', function ( source, callback ) { + if ( !source.mwtitle || !source.mwprovider ) { callback(); return ; } // Load via api - var apiUrl = mw.getApiProviderURL( source['mwprovider'] ); + var apiUrl = mw.getApiProviderURL( source.mwprovider ), // Get the image page ( cache for 1 hour ) - var request = { + request = { 'action': 'parse', - 'page': source['mwtitle'], - 'smaxage' : 3600, - 'maxage' : 3600 + 'page': source.mwtitle, + 'smaxage': 3600, + 'maxage': 3600 }; - mw.getJSON( apiUrl, request, function( data ){ - if( data && data['parse'] && data['parse']['text'] && data['parse']['text']['*'] ){ + mw.getJSON( apiUrl, request, function ( data ) { + if ( data && data.parse && data.parse.text && data.parse.text['*'] ) { source.loaded = true; source.mimeType = 'text/mw-srt'; - source.captions = source.getCaptions( data['parse']['text']['*'] ); + source.captions = source.getCaptions( data.parse.text['*'] ); callback(); } else { - mw.log( "Error: MediaWiki api error in getting timed text:", data ); + mw.log( 'Error: MediaWiki api error in getting timed text:', data ); callback(); } }); }); - - $( embedPlayer ).bind( 'getShareIframeSrc', function(event, callback, id){ - if( id != embedPlayer.id ){ - embedPlayer = $('#' + id)[0]; + $( embedPlayer ).bind( 'getShareIframeSrc', function ( event, callback, id ) { + if ( id != embedPlayer.id ) { + embedPlayer = $( '#' + id )[0]; } var iframeUrl = false; // Do a special check for wikimediacommons provider as a known shared reop - if( embedPlayer['data-mwprovider'] == 'wikimediacommons' ){ - iframeUrl = '//commons.wikimedia.org/wiki/File:' + decodeURIComponent( embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/ , '' ); + if ( embedPlayer['data-mwprovider'] == 'wikimediacommons' ) { + iframeUrl = '//commons.wikimedia.org/wiki/File:' + decodeURIComponent( embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/, '' ); } else { // use the local wiki: - if( mw.config.get('wgServer') && mw.config.get('wgArticlePath') ){ - iframeUrl = mw.config.get('wgServer') + - mw.config.get('wgArticlePath').replace( /\$1/, 'File:' + - decodeURIComponent( embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/ , '' ) ) + if ( mw.config.get( 'wgServer' ) && mw.config.get( 'wgArticlePath' ) ) { + iframeUrl = mw.config.get( 'wgServer' ) + + mw.config.get( 'wgArticlePath' ).replace( /\$1/, 'File:' + + decodeURIComponent( embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/, '' ) ) } } - if( iframeUrl ){ + if ( iframeUrl ) { iframeUrl += '?embedplayer=yes'; } callback( iframeUrl ); diff --git a/resources/mw.PopUpThumbVideo.js b/resources/mw.PopUpThumbVideo.js index 457ddd2..1217eee 100644 --- a/resources/mw.PopUpThumbVideo.js +++ b/resources/mw.PopUpThumbVideo.js @@ -1,32 +1,32 @@ /** * Simple script to add pop-up video dialog link support for video thumbnails */ -( function( mw, $ ) { - $(document).ready(function(){ - $('.PopUpMediaTransform a').each( function(){ - var parent = $(this).parent(); +( function ( mw, $ ) { + $( document ).ready( function () { + $('.PopUpMediaTransform a').each( function () { + var parent = $( this ).parent(); if ( parent.attr( 'videopayload' ) ) { - $( this ).click( function( event ){ + $( 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 pause the video on close ( so that playback does not continue ) - var domEl = $( this ).find( 'video,audio' ).get(0); - if( domEl && domEl.pause ) { + 'width': 'auto', + 'height': 'auto', + 'title': mw.html.escape( $videoContainer.find( 'video, audio' ).attr( 'data-mwtitle' ) ), + 'content': $videoContainer, + 'close': function () { + // On close pause the video ( so that playback does not continue ) + var domEl = $( this ).find( 'video, audio' ).get( 0 ); + if ( domEl && domEl.pause ) { domEl.pause(); } return true; } }) - .css('overflow', 'hidden') - .find('video,audio').embedPlayer(); + .css( 'overflow', 'hidden' ) + .find( 'video, audio' ).embedPlayer(); } ); // don't follow file link return false; @@ -39,5 +39,5 @@ } } /* else fall back to linking directly to media file */ } ); - }); + } ); } )( mediaWiki, jQuery ); -- To view, visit https://gerrit.wikimedia.org/r/173509 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia6b22c951e33e4f1fdfbf57cd5562f125dc5f656 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits