r78978 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78977‎ | r78978 | r78979 >
Date:22:02, 24 December 2010
Author:dale
Status:deferred
Tags:
Comment:
cleaned up timed text page layout
Modified paths:
  • /branches/MwEmbedStandAlone/modules/TimedText/remotes/RemoteMwTimedText.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/TimedText/remotes/RemoteMwTimedText.js
@@ -7,7 +7,8 @@
88
99 mw.addMessageKeys( [
1010 "mwe-timedtext-language-subtitles-for-clip",
11 - "mwe-timedtext-language-no-subtitles-for-clip"
 11+ "mwe-timedtext-language-no-subtitles-for-clip",
 12+ "mwe-timedtext-all-subtitles"
1213 ]);
1314
1415 RemoteMwTimedText = function( options ) {
@@ -52,20 +53,32 @@
5354 var _this = this;
5455 // Load the player module:
5556 mw.load( 'EmbedPlayer', function() {
 57+ var width = ( resource.width > 500 )? 500 : resource.width;
 58+ var height = width * ( resource.height / resource.width );
5659 // Add the embed code: ( jquery wrapping of "video" fails )
57 - $j( _this.target ).append(
58 - $j( '<div class="videoLoading">').html(
59 - '<video id="timed-text-player-embed" '+
60 - 'style="width:' + resource.width + 'px;height:' + resource.height + 'px;" '+
61 - 'class="kskin" ' + //We need to centrally store this config somewhere
62 - 'poster="' + resource.poster + '" ' +
63 - 'src="' + resource.src + '" ' +
64 - 'apiTitleKey="' + resource.apiTitleKey + '" >' +
65 - '</video><br><br><br><br>'
66 - )
 60+ $j( _this.target ).empty().append(
 61+ $j('<video />').attr({
 62+ 'id': "timed-text-player-embed",
 63+ 'poster': resource.poster,
 64+ 'src': resource.src,
 65+ 'durationHint' : resource.duration,
 66+ 'apiTitleKey' : resource.apiTitleKey
 67+ })
 68+ .css({
 69+ 'width' : width + 'px',
 70+ 'height' : height + 'px'
 71+ })
 72+ .addClass( 'kskin' )
 73+ ,
 74+ $j('<div />').css({
 75+ 'position' : 'relative',
 76+ 'left' : '510px',
 77+ 'top' : -height + 'px'
 78+ })
 79+ .append( _this.orgBody )
6780 );
68 - $j('.videoLoading').hide();
69 - // embed the player with the pre-selected langauge:
 81+
 82+ // embed the player with the pre-selected language:
7083 _this.embedPlayerLang();
7184 });
7285 },
@@ -135,35 +148,21 @@
136149 // Get all the embed details:
137150 var request = {
138151 'titles' : 'File:' + fileTitle,
139 - 'prop' : 'imageinfo|revisions',
140 - 'iiprop' : 'url|mime|size',
 152+ 'prop' : 'imageinfo|revisions|redirects',
 153+ 'iiprop' : 'url|mime|size|metadata',
141154 'iiurlwidth' : mw.getConfig( 'EmbedPlayer.DefaultSize').split('x').pop(),
142155 'rvprop' : 'content'
143156 }
144157 // (only works for commons right now)
145 - mw.getJSON( request, function( data ) {
 158+ mw.getJSON( request, function( data ) {
146159 // Check for "page not found"
147160 if( data.query.pages['-1'] ) {
148161 //restore content:
149162 $j(_this.target).html( _this.orgBody );
150163 return ;
151164 }
152 - // Check for redirect
153165 for ( var i in data.query.pages ) {
154 - var page = data.query.pages[i];
155 - if ( page.revisions[0]['*'] && page.revisions[0]['*'].indexOf( '#REDIRECT' ) === 0 ) {
156 - var re = new RegExp( /[^\[]*\[\[([^\]]*)/ );
157 - var pt = page.revisions[0]['*'].match( re );
158 - if ( pt[1] ) {
159 - mw.log( 'found redirect tyring: ' + pt[1] )
160 - _this.embedByTitle( pt[1], callback);
161 - return ;
162 - } else {
163 - mw.log( 'Error: getTitleResource could not process redirect' );
164 - callback( false );
165 - return false;
166 - }
167 - }
 166+ var page = data.query.pages[i];
168167 mw.log( "should process data result" );
169168 // Else process the result
170169 var resource = _this.getResource( page );
@@ -176,7 +175,7 @@
177176 * Get the embed code from response resource and sends it a callback
178177 */
179178 getResource: function( page ) {
180 - return {
 179+ var resource = {
181180 'apiTitleKey' : page.title.replace(/File:/ig, '' ),
182181 'link' : page.imageinfo[0].descriptionurl,
183182 'poster' : page.imageinfo[0].thumburl,
@@ -184,5 +183,13 @@
185184 'width' : page.imageinfo[0].width,
186185 'height': page.imageinfo[0].height
187186 };
 187+ // check metadata for length:
 188+ for( var i=0; page.imageinfo[0].metadata.length < i ; i++ ){
 189+ var meta = page.imageinfo[0].metadata[i];
 190+ if( meta.name == 'length' ){
 191+ resource.duration = meta.value;
 192+ }
 193+ }
 194+ return resource;
188195 }
189196 };

Status & tagging log