r81370 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81369‎ | r81370 | r81371 >
Date:02:26, 2 February 2011
Author:dale
Status:deferred
Tags:
Comment:
ported timed text module to RL_17
Modified paths:
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/EmbedPlayer/EmbedPlayer.loader.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/EmbedPlayer/players/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/MediaWikiSupport/resources/MediaWikiSupportPlayer.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/MediaWikiSupport/tests/Player_mwtitle.html (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/MwEmbedSupport/mwEmbedSupport.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/TimedText.config.php (added) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/TimedText.loader.js (added) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/TimedText.php (added) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/loader.js (deleted) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/EmbedPlayer/players/mw.EmbedPlayer.js
@@ -147,10 +147,8 @@
148148 // also see: http://wiki.xiph.org/ROE
149149 "roe" : null,
150150
151 - // If serving an ogg_chop segment use this to offset the presentation
152 - // time
153 - // ( for some plugins that use ogg page time rather than presentation
154 - // time )
 151+ // If serving an ogg_chop segment use this to offset the presentation time
 152+ // ( for some plugins that use ogg page time rather than presentation time )
155153 "startOffset" : 0,
156154
157155 // Thumbnail (same as poster)
@@ -1345,9 +1343,9 @@
13461344 }
13471345
13481346 if ( !_this.duration && $( element ).attr( 'data-durationhint' ) ) {
1349 - _this.data-durationhint = $( element ).attr( 'data-durationhint' );
 1347+ _this['data-durationhint'] = $( element ).attr( 'data-durationhint' );
13501348 // Convert duration hint if needed:
1351 - _this.duration = mw.npt2seconds( _this.data-durationhint );
 1349+ _this.duration = mw.npt2seconds( _this['data-durationhint'] );
13521350 }
13531351
13541352 // Make sure duration is a float:
@@ -2386,7 +2384,7 @@
23872385 }
23882386
23892387 if( this.duration ) {
2390 - params.data-durationhint = parseFloat( this.duration );
 2388+ params['data-durationhint'] = parseFloat( this.duration );
23912389 }
23922390 iframeUrl += $j.param( params );
23932391
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/EmbedPlayer/EmbedPlayer.loader.js
@@ -108,7 +108,7 @@
109109 mediaWiki.loader.using( dependencySet, function(){
110110 setTimeout( function(){
111111 mw.processEmbedPlayers( playerSelect, readyCallback );
112 - }, 300);
 112+ }, 500);
113113 });
114114 };
115115
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/MediaWikiSupport/tests/Player_mwtitle.html
@@ -1,9 +1,18 @@
 2+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 3+"http://www.w3.org/TR/html4/loose.dtd">
 4+<html>
 5+<head>
 6+ <title> Sample Player with assets loaded from commons </title>
 7+ <script type="text/javascript" src="../../../load.php?modules=startup&only=scripts"></script>
 8+</head>
 9+<body>
 10+<h3> Sample Player with assets loaded from commons </h3>
211
3 -
4 -
512 <video id="v0" tabindex="0" style="width: 512px; height: 288px;"
613 data-durationhint="7:52"
7 -data-="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultural_Experience.ogg"
8 -apiprovider="commons"
 14+data-mwtitle="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultural_Experience.ogg"
 15+data-mwprovider="commons"
916 class="kskin">
10 -</video>
\ No newline at end of file
 17+</video>
 18+</body>
 19+</html>
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/MediaWikiSupport/resources/MediaWikiSupportPlayer.js
@@ -94,7 +94,7 @@
9595 }
9696
9797 // Update the css for the player interface
98 - $( embedPlayer ).css( 'height', _this.height);
 98+ $( embedPlayer ).css( 'height', embedPlayer.height);
9999
100100 callback();
101101 });
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/loader.js
@@ -1,125 +0,0 @@
2 -/**
3 -* TimedText loader.
4 -*/
5 -// Scope everything in "mw" ( keeps the global namespace clean )
6 -( function( mw, $ ) {
7 -
8 - mw.addResourcePaths( {
9 - "mw.TimedText" : "mw.TimedText.js",
10 - "mw.style.TimedText" : "css/mw.style.TimedText.css",
11 -
12 - "mw.TimedTextEdit" : "mw.TimedTextEdit.js",
13 - "mw.style.TimedTextEdit" : "css/mw.style.TimedTextEdit.css",
14 -
15 - "RemoteMwTimedText" : "remotes/RemoteMwTimedText.js"
16 - } );
17 -
18 - // Merge in timed text related attributes: TODO add merge config support with some way to
19 - // clasify configuration as "default" vs custom.
20 - var sourceAttr = mw.getConfig( 'EmbedPlayer.SourceAttributes');
21 - mw.setConfig( 'EmbedPlayer.SourceAttributes', $j.extend( sourceAttr, [
22 - 'srclang',
23 - 'category'
24 - ]) );
25 -
26 - mw.setDefaultConfig( {
27 - // If the Timed Text interface should be displayed:
28 - // 'always' Displays link and call to contribute always
29 - // 'auto' Looks for child timed text elements or "apiTitleKey" & load interface
30 - // 'off' Does not display the timed text interface
31 - "TimedText.showInterface" : "auto",
32 -
33 - /**
34 - * If the "add timed text" link / interface should be exposed
35 - */
36 - 'TimedText.showAddTextLink' : true,
37 -
38 - // The category for listing videos that need transcription:
39 - 'TimedText.NeedsTranscriptCategory' : 'Videos needing subtitles'
40 - });
41 -
42 - var mwTimedTextRequestSet = [
43 - '$j.fn.menu',
44 - 'mw.TimedText',
45 - 'mw.style.TimedText',
46 - 'mw.style.jquerymenu'
47 - ];
48 -
49 - // TimedText module
50 - mw.addModuleLoader( 'TimedText', mwTimedTextRequestSet );
51 -
52 - /**
53 - * Setup the load embedPlayer visit tag addSetupHook function
54 - *
55 - * Check if the video tags in the page support timed text
56 - * this way we can add our timed text libraries to the player
57 - * library request.
58 - */
59 -
60 - // Update the player loader request with timedText library if the embedPlayer
61 - // includes timedText tracks.
62 - $( mw ).bind( 'EmbedPlayerUpdateDependencies', function( event, playerElement, classRequest ) {
63 - if( mw.isTimedTextSupported( playerElement ) ) {
64 - classRequest = $j.merge( classRequest, mwTimedTextRequestSet );
65 - }
66 - } );
67 -
68 - // On new embed player check if we need to add timedText
69 - $( mw ).bind( 'EmbedPlayerNewPlayer', function( event, embedPlayer ){
70 - if( mw.isTimedTextSupported( embedPlayer) ){
71 - if( ! embedPlayer.timedText && mw.TimedText ) {
72 - embedPlayer.timedText = new mw.TimedText( embedPlayer );
73 - }
74 - }
75 - });
76 -
77 - /**
78 - * Check if we should load the timedText interface or not.
79 - *
80 - * Note we check for text sources outside of
81 - */
82 - mw.isTimedTextSupported = function( embedPlayer ) {
83 - if( mw.getConfig( 'TimedText.showInterface' ) == 'always' ) {
84 - return true;
85 - }
86 - // Check for timed text sources or api/ roe url
87 - if (
88 - (
89 - $( embedPlayer ).attr('apititlekey')
90 - ||
91 - $( embedPlayer ).attr('apiTitleKey' )
92 - )
93 - ||
94 - ( embedPlayer.mediaElement && embedPlayer.mediaElement.textSourceExists() )
95 - ||
96 - $( embedPlayer ).find( 'track' ).length != 0
97 - ) {
98 - return true;
99 - } else {
100 - return false;
101 - }
102 - };
103 -
104 - // TimedText editor:
105 - mw.addModuleLoader( 'TimedText.Edit', [
106 - [
107 - '$j.ui',
108 - '$j.widget',
109 - '$j.ui.mouse',
110 - '$j.ui.position',
111 - '$j.fn.menu',
112 - "mw.style.jquerymenu",
113 -
114 - 'mw.TimedText',
115 - 'mw.style.TimedText',
116 -
117 - 'mw.TimedTextEdit',
118 - 'mw.style.TimedTextEdit'
119 - ],
120 - [
121 - '$j.ui.dialog',
122 - '$j.ui.tabs'
123 - ]
124 - ]);
125 -
126 -} )( window.mediaWiki, window.jQuery );
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/TimedText.config.php
@@ -0,0 +1,21 @@
 2+<?php
 3+ /**
 4+ * Do not edit this file instead use LocalSettings.php and
 5+ * $wgMwEmbedModuleConfig[ {configuration name} ] = value; format
 6+ */
 7+
 8+ return array(
 9+ // If the Timed Text interface should be displayed:
 10+ // 'always' Displays link and call to contribute always
 11+ // 'auto' Looks for child timed text elements or "apiTitleKey" & load interface
 12+ // 'off' Does not display the timed text interface
 13+ "TimedText.ShowInterface" => "auto",
 14+
 15+ /**
 16+ * If the "add timed text" link / interface should be exposed
 17+ */
 18+ 'TimedText.showAddTextLink' => true,
 19+
 20+ // The category for listing videos that need transcription:
 21+ 'TimedText.NeedsTranscriptCategory' => 'Videos needing subtitles'
 22+ );
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js
@@ -11,10 +11,8 @@
1212 *
1313 */
1414
15 -mw.includeAllModuleMessages();
16 -
1715 // Bind to mw ( for uncluttered global namespace )
18 -( function( $ ) {
 16+( function( mw, $ ) {
1917
2018 /**
2119 * Timed Text Object
@@ -23,6 +21,7 @@
2422 mw.TimedText = function( embedPlayer, options ) {
2523 return this.init( embedPlayer, options);
2624 };
 25+
2726 mw.TimedText.prototype = {
2827
2928 /**
@@ -162,7 +161,7 @@
163162 }) ).css({
164163 // Get the text size scale then set it to control bar height + 10 px;
165164 'bottom': ( _this.embedPlayer.controlBuilder.getHeight() + textOffset ) + 'px'
166 - })
 165+ });
167166
168167 });
169168
@@ -225,7 +224,7 @@
226225 return $textButton;
227226
228227 }
229 - }
 228+ };
230229 },
231230
232231 bindTextButton: function($textButton){
@@ -644,7 +643,7 @@
645644 }
646645
647646 // Put in the "Make Transcript" link if config enabled and we have an api key
648 - if( mw.getConfig( 'TimedText.showAddTextLink' ) && _this.embedPlayer.apiTitleKey ){
 647+ if( mw.getConfig( 'TimedText.ShowAddTextLink' ) && _this.embedPlayer.apiTitleKey ){
649648 $menu.append(
650649 _this.getLiAddText()
651650 );
@@ -1625,13 +1624,6 @@
16261625 }
16271626 };
16281627
1629 -
1630 -} )( window.mw );
1631 -
1632 -/**
1633 -* jQuery entry point for timedText interface:
1634 -*/
1635 -( function( $ ) {
16361628 /**
16371629 * jquery timedText binding.
16381630 * Calls mw.timedText on the given selector
@@ -1645,15 +1637,15 @@
16461638 }
16471639 if( typeof options == 'undefined' )
16481640 options = {};
1649 -
 1641+
16501642 $( this.selector ).each(function() {
16511643 var embedPlayer = $(this).get(0);
1652 -
 1644+
16531645 // Setup timed text for the given player:
16541646 if( ! embedPlayer.timedText ) {
16551647 embedPlayer.timedText = new mw.TimedText( embedPlayer, options);
16561648 }
1657 -
 1649+
16581650 // Show the timedText menu
16591651 if( action == 'showMenu' ) {
16601652 // Bind the menu to the target with autoShow = true
@@ -1661,5 +1653,6 @@
16621654 embedPlayer.timedText.bindMenu( target, true );
16631655 }
16641656 } );
1665 - }
1666 -} )( jQuery );
 1657+ };
 1658+
 1659+} )( window.mediaWiki, window.jQuery );
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/TimedText.loader.js
@@ -0,0 +1,63 @@
 2+/**
 3+* TimedText loader.
 4+*/
 5+// Scope everything in "mw" ( keeps the global namespace clean )
 6+( function( mw, $ ) {
 7+ debugger;
 8+ // Merge in timed text related attributes:
 9+ mw.mergeConfig( 'EmbedPlayer.SourceAttributes', [
 10+ 'srclang',
 11+ 'category'
 12+ ]);
 13+
 14+ /**
 15+ * Check if the video tags in the page support timed text
 16+ * this way we can add our timed text libraries to the player
 17+ * library request.
 18+ */
 19+
 20+ // Update the player loader request with timedText library if the embedPlayer
 21+ // includes timedText tracks.
 22+ $( mw ).bind( 'EmbedPlayerUpdateDependencies', function( event, playerElement, classRequest ) {
 23+ if( mw.isTimedTextSupported( playerElement ) ) {
 24+ classRequest = $j.merge( classRequest, ['mw.TimedText'] );
 25+ }
 26+ } );
 27+
 28+ // On new embed player check if we need to add timedText
 29+ $( mw ).bind( 'EmbedPlayerNewPlayer', function( event, embedPlayer ){
 30+ if( mw.isTimedTextSupported( embedPlayer) ){
 31+ if( ! embedPlayer.timedText && mw.TimedText ) {
 32+ embedPlayer.timedText = new mw.TimedText( embedPlayer );
 33+ }
 34+ }
 35+ });
 36+
 37+ /**
 38+ * Check if we should load the timedText interface or not.
 39+ *
 40+ * Note we check for text sources outside of
 41+ */
 42+ mw.isTimedTextSupported = function( embedPlayer ) {
 43+ if( mw.getConfig( 'TimedText.ShowInterface' ) == 'always' ) {
 44+ return true;
 45+ }
 46+ // Check for timed text sources or api
 47+ if (
 48+ (
 49+ $( embedPlayer ).attr('apititlekey')
 50+ ||
 51+ $( embedPlayer ).attr('apiTitleKey' )
 52+ )
 53+ ||
 54+ ( embedPlayer.mediaElement && embedPlayer.mediaElement.textSourceExists() )
 55+ ||
 56+ $( embedPlayer ).find( 'track' ).length != 0
 57+ ) {
 58+ return true;
 59+ } else {
 60+ return false;
 61+ }
 62+ };
 63+
 64+} )( window.mediaWiki, window.jQuery );
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/TimedText/TimedText.php
@@ -0,0 +1,24 @@
 2+<?php
 3+
 4+ // Register all the timedText modules
 5+ return array(
 6+ "mw.TimedText" => array(
 7+ 'scripts' => "mw.TimedText.js",
 8+ 'styles' => "css/mw.style.TimedText.css",
 9+ 'dependencies' => array(
 10+ 'mw.EmbedPlayer'
 11+ )
 12+ ),
 13+ "mw.TimedTextEdit" => array(
 14+ 'scripts' => "mw.TimedTextEdit.js",
 15+ 'styles' => "css/mw.style.TimedTextEdit.css",
 16+ 'dependencies' => array(
 17+ 'mw.TimedText',
 18+ 'jquery.ui.dialog',
 19+ 'jquery.ui.tabs'
 20+ )
 21+ ),
 22+ "RemoteMwTimedText" =>array(
 23+ 'scripts' => "remotes/RemoteMwTimedText.js"
 24+ )
 25+ );
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/modules/MwEmbedSupport/mwEmbedSupport.js
@@ -126,8 +126,7 @@
127127 mw.setConfig( name, $.extend( mediaWiki.config.get( name ), value ) );
128128 }
129129 };
130 -
131 -
 130+
132131 /**
133132 * gM ( get Message ) in js2 conflated jQuery return type with string return type
134133 * Do a legacy check for input parameters and 'do the right thing'
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -105,7 +105,7 @@
106106 // No subtitle editor ( cross domain issues )
107107 mw.setConfig( 'MiroSubs.EnableUniversalSubsEditor', false );
108108 // No subtile upload either ( for now )
109 - mw.setConfig( 'TimedText.showAddTextLink', false );
 109+ mw.setConfig( 'TimedText.ShowAddTextLink', false );
110110 }
111111
112112

Status & tagging log