r62694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62693‎ | r62694 | r62695 >
Date:05:54, 19 February 2010
Author:dale
Status:deferred
Tags:
Comment:
~ unstable commit ~
* partial refactor of player embedding logic
* skin and control handler refactor
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/genericEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/htmlEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/omtkEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/vlcEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/kskin/EmbedPlayer.css (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/loader.js
@@ -33,10 +33,69 @@
3434 'ApiProxy',
3535 'Sequencer',
3636 'TimedText'
37 -];
 37+];
3838
39 -mw.setConfig( 'enabledModules', mwEnabledModuleList );
 39+/**
 40+* mwEmbed default config values.
 41+*/
 42+mw.setDefaultConfig ( {
 43+ // Default enabled modules:
 44+ "enabledModules" : mwEnabledModuleList,
 45+
 46+ // Default skin name
 47+ "skinName" : "mvpcf",
 48+
 49+ // Default jquery ui skin name
 50+ "jQueryUISkin" : "redmond",
 51+
 52+ /**
 53+ * If jQuery / mwEmbed should be loaded.
 54+ *
 55+ * This flag is automatically set to true if:
 56+ * Any script calls mw.ready ( callback_function )
 57+ * Page DOM includes any tags set in config.rewritePlayerTags at onDomReady
 58+ * ( embedPlayer module )
 59+ *
 60+ * This flag increases page performance on pages that do not use mwEmbed
 61+ * and don't already load jQuery
 62+ *
 63+ * For example when including the mwEmbed.js in your blog template
 64+ * mwEmbed will only load extra js on blog posts that include the video tag.
 65+ *
 66+ * NOTE: Future architecture will probably do away with this flag and refactor it into
 67+ * a smaller "remotePageMwEmbed.js" script similar to ../remoteMwEmbed.js
 68+ */
 69+ "runSetupMwEmbed" : false,
4070
 71+ // The mediaWiki path of mwEmbed
 72+ "mediaWikiEmbedPath" : "js/mwEmbed/",
 73+
 74+ // Api actions that must be submitted in a POST, and need an api proxy for cross domain calls
 75+ 'apiPostActions': [ 'login', 'purge', 'rollback', 'delete', 'undelete',
 76+ 'protect', 'block', 'unblock', 'move', 'edit', 'upload', 'emailuser',
 77+ 'import', 'userrights' ],
 78+
 79+ //If we are in debug mode ( results in fresh debug javascript includes )
 80+ 'debug' : false,
 81+
 82+ // Valid language codes ( has a file in /includes/languages/classes/Language{code}.js )
 83+ // TODO: mirror the mediaWiki language "fallback" system
 84+ 'languageCodeList': ['en', 'am', 'ar', 'bat_smg', 'be_tarak', 'be', 'bh',
 85+ 'bs', 'cs', 'cu', 'cy', 'dsb', 'fr', 'ga', 'gd', 'gv', 'he', 'hi',
 86+ 'hr', 'hsb', 'hy', 'ksh', 'ln', 'lt', 'lv', 'mg', 'mk', 'mo', 'mt',
 87+ 'nso', 'pl', 'pt_br', 'ro', 'ru', 'se', 'sh', 'sk', 'sl', 'sma',
 88+ 'sr_ec', 'sr_el', 'sr', 'ti', 'tl', 'uk', 'wa'
 89+ ],
 90+
 91+ // Default user language is "en" Can be overwritten by:
 92+ // "uselang" url param
 93+ // wgUserLang global
 94+ 'userLanguage' : 'en',
 95+
 96+ // Set the default providers ( you can add more provider via {provider_id}_apiurl = $api_url
 97+ 'commons_apiurl' : 'http://commons.wikimedia.org/w/api.php'
 98+} );
 99+
41100 /**
42101 * -- Load Class Paths --
43102 *
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html
@@ -2,15 +2,19 @@
33 "http://www.w3.org/TR/html4/loose.dtd">
44 <html>
55 <head>
6 - <title>Sample Themed Player</title>
7 - <!-- Pre-loading demo ( stuff ) likely needed for video display
8 - <script type="text/javascript" src="../jsScriptLoader.php?urid=1.1d&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script>
 6+ <title> Sample Themed Player </title>
 7+ Pre-loading demo ( stuff ) likely needed for video display
 8+ <!-- <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script>
 9+
 10+ <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=mwEmbed"></script>
911 <link rel="stylesheet" href="../skins/styles.css" type="text/css" media="screen" />
1012 <link rel="stylesheet" href="../skins/mvpcf/EmbedPlayer.css" type="text/css" media="screen" />
1113 <link rel="stylesheet" href="../skins/kskin/EmbedPlayer.css" type="text/css" media="screen" />
1214 -->
13 - <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
14 -
 15+
 16+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
 17+
 18+
1519 </head>
1620 <script type="text/javascript">
1721 </script>
@@ -19,14 +23,15 @@
2024 To play with dynamic Themes install <a href="http://jqueryui.com/themeroller/developertool/">Themeroller</a><p><p>
2125
2226 <div style="width:450px;float:left">
23 -<video
24 - src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
 27+<video
 28+ src="http://localhost/lucky.ogv"
2529 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
2630 apiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
2731 apiProvider="commons"
28 - durationHint="60">
 32+ durationHint="60" >
2933 </video>
3034
 35+<!--
3136 <video
3237 style="width:208px;height:160px;float:left"
3338 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
@@ -57,7 +62,7 @@
5863 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
5964 durationHint="60">
6065 </video>
61 -
 66+ -->
6267 <b>(kskin) Source Code used:</b><br>
6368 <textarea cols="50" rows="7"><video class="kskin" style="width:400px;height:288px" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
6469 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"></video></textarea>
Index: branches/js2-work/phase3/js/mwEmbed/skins/kskin/EmbedPlayer.css
@@ -358,6 +358,11 @@
359359 font-size: 1em;
360360 }
361361
 362+.k-player .menu-screen {
 363+ height: 100%;
 364+ overflow: auto;
 365+}
 366+
362367 .k-player .menu-screen.menu-share div.ui-state-highlight {
363368 background: none repeat scroll 0 0 transparent;
364369 border-color: #554926;
Index: branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js
@@ -3,8 +3,7 @@
44 */
55
66 mw.addMessages( {
7 - "mwe-credit-title" : "Title: $1",
8 - "mwe-kaltura-platform-title" : "Kaltura open source video platform"
 7+ "mwe-credit-title" : "Title: $1"
98 } );
109
1110 var kskinConfig = {
@@ -30,68 +29,108 @@
3130
3231 // Extends base components with kskin specific options:
3332 components: {
34 - 'play-btn-large' : {
 33+ 'playButtonLarge' : {
3534 'h' : 55
3635 },
3736 'options': {
3837 'w':50,
3938 'o':function() {
40 - return '<div class="ui-state-default ui-corner-bl rButton k-options" title="' + gM( 'mwe-player_options' ) + '" >' +
41 - '<span>' + gM( 'mwe-menu_btn' ) + '</span>' +
42 - '</div>'
 39+ return $j( '<div />' )
 40+ .attr( 'title', gM( 'mwe-player_options' ) )
 41+ .addClass( "ui-state-default ui-corner-bl rButton k-options" )
 42+ .append(
 43+ $j( '<span />' )
 44+ .text( gM( 'mwe-menu_btn' ) )
 45+ )
4346 }
4447 },
45 - 'volume_control':{
 48+ 'volumeControl':{
4649 'w':40
4750 },
48 - 'time_display': {
 51+ // No kalturaAttribution component for kSkin ( its integrated into the credits screen )
 52+ 'kalturaAttribution' : false,
 53+ 'timeDisplay': {
4954 'w':45
5055 },
5156 /*
5257 * The playhead html
5358 */
54 - 'play_head': {
 59+ 'playHead': {
5560 'w':0, // special case (takes up remaining space)
5661 'o':function( ctrlObj ) {
57 - return '<div class="play_head" style="width: ' + ( ctrlObj.available_width - 10 ) + 'px;"></div>';
 62+ return $j( '<div />' )
 63+ .addClass( "play_head" )
 64+ .css( "width", parseInt( ctrlObj.available_width - 10 ) + 'px' )
5865 }
5966 },
60 - 'options_menu': {
61 - 'w':0,
62 - 'o':function( ctrlObj ) {
 67+ 'optionsMenu': {
 68+ 'w' : 0,
 69+ 'o' : function( ctrlObj ) {
6370 var embedPlayer = ctrlObj.embedPlayer;
6471
65 - // Setup menu offset ( if player height < getOverlayHeight )
 72+
6673 var menuOffset = ( embedPlayer.getPlayerHeight() < ctrlObj.getOverlayHeight() ) ?
67 - 'top:' + ( embedPlayer.getPlayerHeight() + ctrlObj.getControlBarHeight() ) + 'px;' : '';
 74+ 'top:' + + 'px;' : '';
6875
69 - // Special common overflow hack:
70 - // NOTE: should re-factor to just append menu to top body when it does not "fit" in the player
71 - if( menuOffset != '' )
72 - $j( embedPlayer ).parents( '.thumbinner' ).css( 'overflow', 'visible' );
73 -
74 - var o = '' +
75 - '<div id="blackbg_' + embedPlayer.id +'" class="k-menu ui-widget-content" ' +
76 - 'style="width:' + ctrlObj.getOverlayWidth() + 'px; height:' + ctrlObj.getOverlayHeight() + 'px;' + menuOffset + '">' +
77 - '<ul class="k-menu-bar">';
78 - // Output menu item containers:
79 - for ( i = 0; i < ctrlObj.menu_items.length; i++ ) {
80 - var mk = ctrlObj.menu_items[i];
81 - o += '<li class="k-' + mk + '-btn" rel="' + mk + '">' +
82 - '<a href="#" title="' + gM( 'mwe-' + mk ) + '">' + gM( 'mwe-' + mk ) + '</a></li>';
83 - }
84 - o += '</ul>' +
85 - // We have to subtract the width of the k-menu-bar
86 - '<div class="k-menu-screens" style="width:' + ( ctrlObj.getOverlayWidth() - 75 ) +
87 - 'px; height:' + ( ctrlObj.getOverlayHeight() - ctrlObj.getControlBarHeight() ) + 'px;">';
88 -
89 - // Output menu item containers:
90 - for ( i = 0; i < ctrlObj.menu_items.length; i++ ) {
91 - o += '<div class="menu-screen menu-' + ctrlObj.menu_items[i] + '"></div>';
92 - }
93 - '</div>' +
94 - '</div>';
95 - return o;
 76+
 77+
 78+ $menuOverlay = $j( '<div />')
 79+ .attr('id', 'blackbg_' + embedPlayer.id )
 80+ .addClass( 'k-menu ui-widget-content' )
 81+ .css( {
 82+ 'width' : ctrlObj.getOverlayWidth(),
 83+ 'height' : ctrlObj.getOverlayHeight(),
 84+ } );
 85+
 86+ // Setup menu offset ( if player height < getOverlayHeight )
 87+ // This displays the menu outside of the player on small embeds
 88+ if ( embedPlayer.getPlayerHeight() < ctrlObj.getOverlayHeight() ) {
 89+ $menuOverlay.css( 'top', parseInt( embedPlayer.getPlayerHeight() + ctrlObj.getControlBarHeight() ) + 'px' );
 90+
 91+ // Special common overflow hack for thumbnail display of player
 92+ $j( embedPlayer ).parents( '.thumbinner' ).css( 'overflow', 'visible' );
 93+ }
 94+ $menuBar = $j( '<ul />' )
 95+ .addClass( 'k-menu-bar' );
 96+
 97+ // Output menu item containers:
 98+ for ( i = 0; i < ctrlObj.menu_items.length; i++ ) {
 99+ var mk = ctrlObj.menu_items[i];
 100+ $menuBar.append(
 101+ $j( '<li />')
 102+ // Add the menu item class:
 103+ .addClass( 'k-' + mk + '-btn' )
 104+ .attr( 'rel', mk )
 105+ .append(
 106+ $j( '<a />' )
 107+ .attr( {
 108+ 'title' : gM( 'mwe-' + mk ),
 109+ 'href' : '#'
 110+ })
 111+ )
 112+ );
 113+ }
 114+
 115+ // Add the menuBar to the menuOverlay
 116+ $menuOverlay.append( $menuBar );
 117+
 118+ var $menuScreens = $j( '<div />' )
 119+ .addClass( 'k-menu-screens' )
 120+ .css({
 121+ 'width' : ( ctrlObj.getOverlayWidth() - 75 ),
 122+ 'height' : ( ctrlObj.getOverlayHeight() - ctrlObj.getControlBarHeight() )
 123+ })
 124+ for ( i = 0; i < ctrlObj.menu_items.length; i++ ) {
 125+ $menuScreens.append(
 126+ $j( '<div />' )
 127+ .addClass( 'menu-screen menu-' + ctrlObj.menu_items[i] )
 128+ );
 129+ }
 130+
 131+ // Add the menuScreens to the menuOverlay
 132+ $menuOverlay.append( $menuScreens );
 133+
 134+ return $menuOverlay;
96135 }
97136 }
98137 },
@@ -127,10 +166,12 @@
128167 .unbind()
129168 .click( function() {
130169 if ( _this.$playerTarget.find( '.k-menu' ).length == 0 ) {
 170+
131171 // Stop the player if it does not support overlays:
132172 if ( !embedPlayer.supports['overlays'] ){
133173 embedPlayer.stop();
134174 }
 175+
135176 // Add the menu binding
136177 _this.addMeunBinding();
137178 }
@@ -147,7 +188,7 @@
148189 /**
149190 * Close the menu overlay
150191 */
151 - closeMenuOverlay: function( ){
 192+ closeMenuOverlay: function( ) {
152193 var $optionsMenu = this.$playerTarget.find( '.k-options' );
153194 this.$kmenu.fadeOut( "fast", function() {
154195 $optionsMenu.find( 'span' )
@@ -155,10 +196,11 @@
156197 } );
157198 this.$playerTarget.find( '.play-btn-large' ).fadeIn( 'fast' );
158199 },
 200+
159201 /**
160202 * Show the menu overlay
161203 */
162 - showMenuOverlay: function( $ktxt ){
 204+ showMenuOverlay: function( $ktxt ) {
163205 var $optionsMenu = this.$playerTarget.find( '.k-options' );
164206 this.$kmenu.fadeIn( "fast", function() {
165207 $optionsMenu.find( 'span' )
@@ -184,10 +226,9 @@
185227
186228 // Add options menu to top of player target children:
187229 $playerTarget.prepend(
188 - _this.components[ 'options_menu' ].o( _this )
 230+ _this.getComponent( 'optionsMenu' )
189231 );
190232
191 -
192233 // By default its hidden:
193234 $playerTarget.find( '.k-menu' ).hide();
194235
@@ -216,7 +257,7 @@
217258 *
218259 * @param {String} menu_itme Menu item key to display
219260 */
220 - showMenuItem:function( menu_item ) {
 261+ showMenuItem:function( menu_item ) {
221262 var embedPlayer = this.embedPlayer;
222263 //handle special k-skin specific display;
223264 if( menu_item == 'credits'){
@@ -231,6 +272,7 @@
232273
233274 /**
234275 * Show the "edit with kaltura" screen ( specific to kaltura skin )
 276+ * NOTE: stub function
235277 */
236278 showKalturaEdit: function(){
237279
@@ -253,7 +295,7 @@
254296 .loadingSpinner()
255297 );
256298
257 - if( mw.getConfig( 'k_attribution' ) == true ){
 299+ if( mw.getConfig( 'kalturaAttribution' ) == true ){
258300 $target.append(
259301 $j( '<div />' )
260302 .addClass( 'k-attribution' )
Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -31,10 +31,17 @@
3232 // Default control bar height is 33
3333 height: 33,
3434
35 - // Default supported components is merged with embedPlayerect supported types
 35+ // Default supported components is merged with embedPlayer set of supported types
3636 supportedComponets: {
37 - 'options':true,
38 - 'borders':true
 37+
 38+ // All playback types support options
 39+ 'options':true,
 40+
 41+ // All playback types support kalturaAttribution
 42+ // to enable or disable use mw.setConfig( 'kalturaAttribution', [true|false] )
 43+ 'kalturaAttribution' : true,
 44+
 45+ 'playButtonLarge' : true
3946 },
4047 /**
4148 * Initialization Object for the control builder
@@ -69,7 +76,7 @@
7077 var _this = this;
7178
7279 // Remove any old controls:
73 - embedPlayer.$interface.find('.control-bar').remove();
 80+ embedPlayer.$interface.find( '.control-bar' ).remove();
7481
7582 // Add some space to control_wrap for the control bar:
7683 embedPlayer.$interface.css( {
@@ -103,6 +110,7 @@
104111
105112 // Make pointer to the embedPlayer
106113 this.embedPlayer = embedPlayer;
 114+
107115 var _this = this;
108116 this.supportedComponets = $j.extend(this.supportedComponets, embedPlayer.supports);
109117
@@ -113,19 +121,28 @@
114122
115123 // Append options to body (if not already there)
116124 if ( this.external_options && $j( '#mv_vid_options_' + this.id ).length == 0 ){
117 - $j( 'body' ).append( this.components[ 'options_menu' ].o( this ) );
 125+ $j( 'body' ).append( this.getComponent( 'optionsMenu' ) );
118126 }
119127
 128+
 129+
120130 // Build component output:
121131 for ( var component_id in this.components ) {
 132+
 133+ // Special case with playhead skip if we have > 30px of space for it
 134+ if ( component_id == 'playHead' && this.available_width < 30 ){
 135+ continue;
 136+ }
 137+
 138+ // Special case of kalturaAttribution skip if set in configuration
 139+ if( component_id == 'kalturaAttribution' && mw.getConfig( 'kalturaAttribution' ) == false ){
 140+ continue;
 141+ }
 142+
122143 // Make sure the given components is supported:
123144 if ( this.supportedComponets[ component_id ] ) {
124 - if ( this.available_width > this.components[ component_id ].w ) {
125 - // Special case with playhead don't add unless we have 30px
126 - if ( component_id == 'play_head' && this.available_width < 30 ){
127 - continue;
128 - }
129 - // Append the component
 145+ if ( this.available_width > this.components[ component_id ].w ) {
 146+ // Append the component
130147 $controlBar.append(
131148 _this.getComponent( component_id )
132149 );
@@ -511,24 +528,24 @@
512529 /**
513530 * The large play button in center of the player
514531 */
515 - 'play-btn-large': {
 532+ 'playButtonLarge': {
516533 'w' : 130,
517534 'h' : 96,
518 - 'o' : function( ctrlObj ) {
519 - // Get dynamic position for big play button
 535+ 'o' : function( ctrlObj ) {
520536 return $j( '<div/>' )
521 - .attr( {
522 - 'title' : gM( 'mwe-play_clip' ),
523 - 'class' : "ui-state-default play-btn-large"
524 - } )
525 - .css( {
526 - 'left' : ( ( ctrlObj.embedPlayer.getPlayerWidth() - this.w ) / 2 ),
527 - 'top' : ( ( ctrlObj.embedPlayer.getPlayerHeight() - this.h ) / 2 )
528 - } )
529 - // Add play hook:
530 - .buttonHover().click( function() {
531 - ctrlObj.embedPlayer.play();
532 - } );
 537+ .attr( {
 538+ 'title' : gM( 'mwe-play_clip' ),
 539+ 'class' : "ui-state-default play-btn-large"
 540+ } )
 541+ // Get dynamic position for big play button
 542+ .css( {
 543+ 'left' : ( ( ctrlObj.embedPlayer.getPlayerWidth() - this.w ) / 2 ),
 544+ 'top' : ( ( ctrlObj.embedPlayer.getPlayerHeight() - this.h ) / 2 )
 545+ } )
 546+ // Add play hook:
 547+ .buttonHover().click( function() {
 548+ ctrlObj.embedPlayer.play();
 549+ } );
533550 }
534551 },
535552
@@ -536,7 +553,7 @@
537554 * The options for the player, includes player selection,
538555 * download, and share options
539556 */
540 - 'options_menu': {
 557+ 'optionsMenu': {
541558 'w' : 0,
542559 'o' : function( ctrlObj ) {
543560 var o = '<div id="mv_vid_options_' + ctrlObj.embedPlayer.id + '" class="videoOptions">' +
@@ -563,6 +580,24 @@
564581 },
565582
566583 /**
 584+ * The kaltura attribution button
 585+ */
 586+ 'kalturaAttribution' : {
 587+ 'w' : 28,
 588+ 'o' : function( ctrlObj ){
 589+ return $j( '<div />' )
 590+ .attr( 'title', gM( 'mwe-kaltura-platform-title' ) )
 591+ .addClass( 'ui-state-default ui-corner-all ui-icon_link rButton k-attribution' )
 592+ .append(
 593+ $j('<span />')
 594+ .addClass( 'ui-icon k-attribution' )
 595+ )
 596+ .click( function( ) {
 597+ window.location = 'http://kaltura.com';
 598+ } );
 599+ }
 600+ },
 601+ /**
567602 * The options button, invokes display of the options menu
568603 */
569604 'options': {
@@ -574,7 +609,7 @@
575610 .append(
576611 $j('<span />')
577612 .addClass( 'ui-icon ui-icon-wrench' )
578 - )
 613+ )
579614 }
580615 },
581616
@@ -630,7 +665,7 @@
631666 /**
632667 * The volume control interface html
633668 */
634 - 'volume_control': {
 669+ 'volumeControl': {
635670 'w' : 28,
636671 'o' : function( ctrlObj ) {
637672 $volumeOut = $j( '<div />' );
@@ -673,9 +708,9 @@
674709 /*
675710 * The time display area
676711 */
677 - 'time_display': {
678 - 'w':90,
679 - 'o':function( ctrlObj ) {
 712+ 'timeDisplay': {
 713+ 'w' : 90,
 714+ 'o' : function( ctrlObj ) {
680715 return $j( '<div />' )
681716 .addClass( "ui-widget time-disp" )
682717 .append(
@@ -685,9 +720,9 @@
686721 }
687722 },
688723 /*
689 - * The playhead html
 724+ * The playhead component
690725 */
691 - 'play_head': {
 726+ 'playHead': {
692727 'w':0, // special case (takes up remaining space)
693728 'o':function( ctrlObj ) {
694729 return $j( '<div />' )
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js
@@ -1209,7 +1209,6 @@
12101210 var request = {};
12111211 var _this = this;
12121212 this.getSourcePages( assetKey, function( sourcePages ){
1213 - mw.log(' got sub pages... ');
12141213 if( ! sourcePages.query.allpages ){
12151214 //Check if a shared asset
12161215 mw.log( 'no subtitle pages found');
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js
@@ -18,24 +18,13 @@
1919 },
2020
2121 /*
22 - * Get the Embed html by wraping the embed code in the embed container:
 22+ * Write the Embed html to the target
2323 */
24 - getEmbedHTML : function () {
 24+ doEmbedHTML : function () {
2525 var _this = this;
26 - setTimeout(function(){
27 - _this.postEmbedJS();
28 - }, 50);
29 - var embed_code = this.getEmbedObj();
30 - mw.log( "return embed html: " + embed_code );
31 - return embed_code;
32 - },
33 -
34 - /**
35 - * Get the plugin embed html
36 - */
37 - getEmbedObj:function() {
3826 var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player';
39 - return '<object width="' + this.width + '" height="' + this.height + '" '+
 27+ $j( this ).html(
 28+ '<object width="' + this.width + '" height="' + this.height + '" '+
4029 'data="' + playerPath + '/wrapper.swf" allowfullscreen="true" '+
4130 'allownetworking="all" allowscriptaccess="always" '+
4231 'type="application/x-shockwave-flash" '+
@@ -52,11 +41,15 @@
5342 '" ' +
5443 'name="flashVars"/>'+
5544 '<param value="opaque" name="wmode"/>'+
56 - '</object>';
57 - },
 45+ '</object>'
 46+ )
 47+ setTimeout(function(){
 48+ _this.postEmbedJS();
 49+ }, 50);
 50+ },
5851
5952 /**
60 - * javascript run post player embeding
 53+ * javascript run post player embedding
6154 */
6255 postEmbedJS:function() {
6356 var _this = this;
@@ -84,6 +77,7 @@
8578 // Start the monitor
8679 this.monitor();
8780 }else{
 81+ // Keep trying to get the html:
8882 //mw.log('insert media: not defiend:' + typeof this.playerElement.insertMedia );
8983 setTimeout( function(){
9084 _this.postEmbedJS();
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -1,31 +1,35 @@
22 /**
3 -* libEmbedPlayer loader
4 -*
 3+* EmbedPlayer loader
54 */
65
76 /**
8 -* Default player module configuration:
9 -*/
 7+* Default player module configuration
 8+*/
 9+
 10+mw.setDefaultConfig( {
 11+ // If the Timed Text interface should be displayed:
 12+ // 'always' Displays link and call to contribute always
 13+ // 'auto' Looks for child timed text elements or "apiTitleKey" & load interface
 14+ // 'off' Does not display the timed text interface
 15+ "textInterface" : "auto",
1016
11 -//If the Timed Text interface should be displayed:
12 -// 'always' Displays link and call to contribute always
13 -// 'auto' Looks for child timed text elements or "apiTitleKey" & load interface
14 -// 'off' Does not display the timed text interface
15 -mw.setConfig( 'textInterface', 'auto' );
 17+ // Timed Text provider presently just "commons",
 18+ // NOTE: Each player instance can also specify a provider
 19+ "timedTextProvider" : "commons",
1620
17 -// Timed Text provider presently just "commons",
18 -// NOTE: Each player instance can also specify a provider
19 -mw.setConfig( 'timedTextProvider', 'commons' );
 21+ // What tags will be re-written to video player by default
 22+ // Set to empty string or null to avoid automatic video tag rewrites to embedPlayer
 23+ "rewritePlayerTags" : "video,audio,playlist",
2024
21 -// What tags will be re-written to video player by default
22 -// Set to empty string or null to avoid automatic tag rewrites
23 -mw.setConfig( 'rewritePlayerTags', 'video,audio,playlist' );
 25+ // Default video size ( if no size provided )
 26+ "video_size" : "400x300",
2427
25 -// Default video size ( if no size provided )
26 -mw.setConfig( 'video_size', '400x300' );
27 -
28 -// If the k-skin video player should attribute kaltura
29 -mw.setConfig( 'k_attribution', true );
 28+ // If the video player should attribute kaltura
 29+ "kalturaAttribution" : true,
 30+
 31+ // Set the browser player warning flag to true by default ( applies to all players so its not part of attribute defaults above )
 32+ 'show_player_warning' : true
 33+} );
3034
3135
3236 // Add class file paths
@@ -41,6 +45,7 @@
4246 "vlcEmbed" : "modules/EmbedPlayer/vlcEmbed.js"
4347 } );
4448
 49+
4550 // Add style sheet dependencies ( From ROOT )
4651 mw.addClassStyleSheets( {
4752 "kskinConfig" : "skins/kskin/EmbedPlayer.css",
@@ -53,18 +58,24 @@
5459 * NOTE: this function can be part of setup can run prior to jQuery being ready
5560 */
5661 mw.documentHasPlayerTags = function(){
57 - var rewriteTags = mw.getConfig( 'rewritePlayerTags' );
 62+ var rewriteTags = mw.getConfig( 'rewritePlayerTags' );
5863 if( rewriteTags ){
5964 var jtags = rewriteTags.split( ',' );
60 - for ( var i = 0; i < jtags.length; i++ ) {
61 - if( document.getElementsByTagName( jtags[i] )[0] )
 65+ for ( var i = 0; i < jtags.length; i++ ) {
 66+ if( document.getElementsByTagName( jtags[i] )[0] ){
6267 return true;
63 - };
 68+ }
 69+ }
6470 }
6571 return false;
6672 }
6773
68 -// Add a dom ready check for player tags
 74+/**
 75+* Add a DOM ready check for player tags
 76+
 77+* We use mw.addDOMReadyHook instead of mw.ready so that
 78+* player interfaces are ready once mw.ready is called.
 79+*/
6980 mw.addDOMReadyHook( function(){
7081 if( mw.documentHasPlayerTags() ) {
7182 // Add the setup hook since we have player tags
@@ -79,13 +90,14 @@
8091 });
8192
8293 // Tell mwEmbed to run setup
83 - mw.setConfig( 'runSetupMwEmbed', true );
 94+ mw.setConfig( 'runSetupMwEmbed', true );
 95+ mw.log(" run setup is: " + mw.getConfig( 'runSetupMwEmbed' ) );
8496 }
8597 });
8698
87 -
88 -
89 -// Add the module loader function:
 99+/**
 100+* Add the module loader function:
 101+*/
90102 mw.addModuleLoader( 'EmbedPlayer', function( callback ){
91103 var _this = this;
92104
@@ -99,6 +111,7 @@
100112 'mw.EmbedPlayer',
101113 'ctrlBuilder',
102114 '$j.cookie',
 115+ // Add JSON lib if browsers does not define "JSON" natively
103116 'JSON'
104117 ],
105118 [
@@ -107,8 +120,11 @@
108121 ]
109122 ];
110123
 124+
 125+
 126+
111127 var addTimedTextReqFlag = false;
112 -
 128+
113129 // Merge in the timed text libs
114130 if( mw.getConfig( 'textInterface' ) == 'always' ){
115131 addTimedTextReqFlag = true;
@@ -168,7 +184,7 @@
169185
170186 // Load the video libs:
171187 mw.load( dependencyRequest, function() {
172 - //Setup userConfig
 188+ // Setup userConfig
173189 mw.setupUserConfig( function(){
174190 // Remove no video html elements:
175191 $j( '.videonojs' ).remove();
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/omtkEmbed.js
@@ -11,43 +11,36 @@
1212
1313 // Supported player features
1414 supports: {
15 - 'pause':true,
16 - 'time_display':true
 15+ 'pause' : true,
 16+ 'timeDisplay' : true
1717 },
1818
1919 /**
2020 * Wrap the embed code
2121 */
22 - getEmbedHTML : function () {
 22+ doEmbedHTML : function () {
2323 var _this = this;
24 - var embed_code = this.getEmbedObj();
25 - // Need omtk to fire an onReady event.
 24+ var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/omtk-fx/omtkp.swf';
 25+ $j( this ).html(
 26+ '<object id="' + this.pid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1">' +
 27+ '<param name="movie" value="' + playerPath + '" />' + "\n" +
 28+ '<!--[if !IE]>-->' + "\n" +
 29+ '<object id="' + this.pid + '_ie" type="application/x-shockwave-flash" data="' + playerPath + '" width="1" height="1">' + "\n" +
 30+ '<!--<![endif]-->' + "\n" +
 31+ '<p>Error with Display of Flash Plugin</p>' + "\n" +
 32+ '<!--[if !IE]>-->' + "\n" +
 33+ '</object>' + "\n" +
 34+ '<!--<![endif]-->' + "\n" +
 35+ '</object>'
 36+ )
 37+ // omtk needs to fire an onReady event.
2638 setTimeout( function(){
2739 _this.postEmbedJS();
2840 }, 2000 );
2941 return embed_code;
30 - },
 42+ },
3143
3244 /**
33 - * Get the embed object html
34 - */
35 - getEmbedObj:function() {
36 - var player_path = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/omtk-fx/omtkp.swf';
37 - // player_path = 'omtkp.swf';
38 - mw.log( "player path: " + player_path );
39 - return '<object id="' + this.pid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1">' +
40 - '<param name="movie" value="' + player_path + '" />' + "\n" +
41 - '<!--[if !IE]>-->' + "\n" +
42 - '<object id="' + this.pid + '_ie" type="application/x-shockwave-flash" data="' + player_path + '" width="1" height="1">' + "\n" +
43 - '<!--<![endif]-->' + "\n" +
44 - '<p>Error with Display of Flash Plugin</p>' + "\n" +
45 - '<!--[if !IE]>-->' + "\n" +
46 - '</object>' + "\n" +
47 - '<!--<![endif]-->' + "\n" +
48 - '</object>';
49 - },
50 -
51 - /**
5245 * Run post embed javascript
5346 */
5447 postEmbedJS:function() {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/genericEmbed.js
@@ -4,12 +4,12 @@
55 var genericEmbed = {
66 // List of supported features of the generic plugin
77 supports: {
8 - 'play_head':false,
 8+ 'playHead':false,
99 'pause':false,
1010 'stop':true,
1111 'fullscreen':false,
12 - 'time_display':false,
13 - 'volume_control':false
 12+ 'timeDisplay':false,
 13+ 'volumeControl':false
1414 },
1515
1616 // Instance name:
@@ -21,9 +21,11 @@
2222 * @return {String}
2323 * embed code for genneric ogg plugin
2424 */
25 - getEmbedHTML:function() {
26 - return '<object type="application/ogg" ' +
 25+ doEmbedHTML: function() {
 26+ $j( this ).html(
 27+ '<object type="application/ogg" ' +
2728 'width="' + this.width + '" height="' + this.height + '" ' +
28 - 'data="' + this.getSrc( this.seek_time_sec ) + '"></object>';
 29+ 'data="' + this.getSrc( this.seek_time_sec ) + '"></object>'
 30+ );
2931 }
3032 };
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -8,9 +8,6 @@
99 *
1010 */
1111
12 -// The global player list per page
13 -mw.playerList = new Array();
14 -
1512 mw.addMessages( {
1613 "mwe-loading_plugin" : "loading plugin ...",
1714 "mwe-select_playback" : "Set playback preference",
@@ -42,6 +39,7 @@
4340 "mwe-no-player" : "No player available for $1",
4441 "mwe-share_this_video" : "Share this video",
4542 "mwe-video_credits" : "Video credits",
 43+ "mwe-kaltura-platform-title" : "Kaltura open source video platform",
4644 "mwe-menu_btn" : "Menu",
4745 "mwe-close_btn" : "Close",
4846 "mwe-ogg-player-vlc-player" : "VLC player",
@@ -171,7 +169,7 @@
172170 * The base source attribute checks
173171 * also see: http://dev.w3.org/html5/spec/Overview.html#the-source-element
174172 */
175 -var default_source_attributes = new Array(
 173+var default_source_attributes = [
176174 // source id
177175 'id',
178176
@@ -210,16 +208,13 @@
211209 // titleKey ( used for api lookups )
212210 'titleKey',
213211
214 - // The provider type ( for what type of api querie to make )
 212+ // The provider type ( for what type of api query to make )
215213 'provider_type',
216214
217215 // The api url for the provider
218216 'provider_url'
219 -);
 217+];
220218
221 -// Set the browser player warning flag to true by default ( applies to all players so its not part of attribute defaults above )
222 -mw.setConfig( 'show_player_warning', true );
223 -
224219 /**
225220 * Adds jQuery binding for embedPlayer
226221 */
@@ -397,7 +392,8 @@
398393 switch( element.tagName.toLowerCase() ) {
399394 case 'playlist':
400395 // Make sure we have the necessary playlist libs loaded:
401 - mw.load( 'mw.PlayList', function() {
 396+ mw.load( 'mw.PlayList', function() {
 397+
402398 // Create playlist player interface
403399 var playlistPlayer = new mw.PlayList( element, attributes );
404400
@@ -427,7 +423,7 @@
428424 }
429425
430426 if( waitForMeta ){
431 - mw.log(" WaitForMeta ( video missing height, width or duration )");
 427+ mw.log(" WaitForMeta ( video missing height, width or duration )" );
432428 element.removeEventListener( "loadedmetadata", runPlayerSwap, true );
433429 element.addEventListener( "loadedmetadata", runPlayerSwap, true );
434430 // Time-out of 5 seconds ( maybe still playable but no timely metadata )
@@ -460,15 +456,9 @@
461457 swapPlayerElement[ method ] = playerInterface[ method ];
462458 }
463459 }
464 -
 460+
465461 // Remove the targetElement
466462 $j( targetElement ).replaceWith( swapPlayerElement );
467 -
468 - // Now Swap out the video element for the embed_video obj:
469 - //$j( targetElement )
470 - // Put the swapPlayerElement after the targetElement
471 - //.after( swapPlayerElement );
472 - //$j( targetElement ).remove();
473463
474464 // Set swapPlayerElement has height / width set and set to loading:
475465 $j( swapPlayerElement ).css( {
@@ -1578,8 +1568,8 @@
15791569 /**
15801570 * Get the plugin embed html ( should be implemented by embed player interface )
15811571 */
1582 - getEmbedHTML : function() {
1583 - return 'Error: function getEmbedHTML should be implemented by embed player interface ';
 1572+ doEmbedHTML : function() {
 1573+ return 'Error: function doEmbedHTML should be implemented by embed player interface ';
15841574 },
15851575
15861576 /**
@@ -1628,8 +1618,8 @@
16291619
16301620 // Make sure the player is
16311621 mw.log( 'performing embed for ' + _this.id );
1632 - // mw.log('should embed:' + embed_code);
1633 - $j( '#' + _this.id ).html( _this.getEmbedHTML() );
 1622+ // mw.log('should embed:' + embed_code);
 1623+ _this.doEmbedHTML()
16341624 },
16351625 /**
16361626 * Searches for related clips from titleKey
@@ -1711,7 +1701,7 @@
17121702 onClipDone:function() {
17131703 mw.log( 'base:onClipDone' );
17141704
1715 - // stop the clip (load the thumbnail etc)
 1705+ // Stop the clip (load the thumbnail etc)
17161706 this.stop();
17171707 this.seek_time_sec = 0;
17181708 this.updatePlayHead( 0 );
@@ -1723,21 +1713,22 @@
17241714 this.thumbnail_disp = true;
17251715
17261716 // make sure we are not in preview mode( no end clip actions in preview mode)
1727 - if ( this.preview_mode )
 1717+ if ( this.preview_mode ){
17281718 return ;
1729 -
1730 - //if k-attribution and k-skin show the "credits" screen:
1731 - if( mw.getConfig( 'k_attribution' ) && this.ctrlBuilder.showCredits ){
1732 - // Call a "credit" menu display:
1733 - this.$interface.find( '.k-options' ).click();
 1719+ }
 1720+
 1721+ // Call the ctrlBuilder end event::
 1722+
 1723+ //if kalturaAttribution and k-skin show the "credits" screen:
 1724+ if( this.ctrlBuilder.showCredits ){
17341725 this.ctrlBuilder.showCredits();
17351726 return ;
17361727 }
1737 -
 1728+ // Related videos:
17381729 $j( '#img_thumb_' + this.id ).css( 'zindex', 1 );
17391730 this.$interface.find( '.play-btn-large' ).hide();
17401731
1741 - // add black background
 1732+ // Add black background
17421733 $j( '#dc_' + this.id ).append( '<div id="black_back_' + this.id + '" ' +
17431734 'style="z-index:-2;position:absolute;background:#000;' +
17441735 'top:0px;left:0px;width:' + parseInt( this.width ) + 'px;' +
@@ -2009,7 +2000,7 @@
20102001 })
20112002 )
20122003 }
2013 - //Set up local jQuery refrence to "interface_wrap"
 2004+ //Set up local jQuery object reference to "interface_wrap"
20142005 this.$interface = $j(this).parent('.interface_wrap');
20152006
20162007 // Update Thumbnail for the "player"
@@ -2337,7 +2328,7 @@
23382329 * Show the "share" msg
23392330 *
23402331 * TODO share should be enabled via <embed> tag usage to be compatible
2341 - * with sites that enable sharing flash embeds
 2332+ * with sites social networking sites that allow <embed> tags but not js
23422333 *
23432334 * @param {Object} $target Target jQuery object to set share html
23442335 */
@@ -2605,7 +2596,7 @@
26062597 },
26072598
26082599 /**
2609 - * loads sources and calls showDownloadWithSources
 2600+ * Loads sources and calls showDownloadWithSources
26102601 * @param {Object} $target jQuery target to output to
26112602 */
26122603 showDownload:function( $target ) {
@@ -2623,13 +2614,14 @@
26242615 _this.showDownloadWithSources( $target );
26252616 }
26262617 },
 2618+
26272619 /**
26282620 * Shows the download interface with sources loaded
26292621 * @param {Object} $target jQuery target to output to
26302622 */
26312623 showDownloadWithSources : function( $target ) {
26322624 var _this = this;
2633 - $target.append(
 2625+ $target.empty().append(
26342626 $j('<div />')
26352627 .css({
26362628 "color":"white"
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js
@@ -2,9 +2,7 @@
33 * List of domains and hosted location of cortado. Lets clients avoid the security warning for cross domain cortado
44 */
55 window.cortadoDomainLocations = {
6 - 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar',
7 - 'tinyvid.tv' : 'http://tinyvid.tv/static/cortado.jar',
8 - 'media.tinyvid.tv' : 'http://media.tinyvid.tv/cortado.jar'
 6+ 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar'
97 }
108
119 var javaEmbed = {
@@ -14,41 +12,79 @@
1513
1614 // Supported feature set of the cortado applet:
1715 supports: {
18 - 'play_head' : true,
 16+ 'playHead' : true,
1917 'pause' : true,
2018 'stop' : true,
2119 'fullscreen' : false,
22 - 'time_display' : true,
23 - 'volume_control' : false
 20+ 'timeDisplay' : true,
 21+ 'volumeControl' : false
2422 },
2523
2624 /**
27 - * Wraps the embed object html output:
 25+ * Output the the embed html
2826 */
29 - getEmbedHTML: function () {
 27+ doEmbedHTML: function () {
3028 var _this = this;
31 - // big delay on embed html cuz its just for status updates and ie6 is crazy.
32 - if ( this.controls ){
33 - setTimeout( function(){
34 - _this.postEmbedJS();
35 - }, 250);
36 - }
37 - // set a default duration of 30 seconds: cortao should detect duration.
38 - return this.getEmbedObj();
39 - },
40 -
41 - /**
42 - * Get the embed html code:
43 - */
44 - getEmbedObj: function() {
4529 mw.log( "java play url:" + this.getSrc( this.seek_time_sec ) );
4630 // get the duration
4731 this.getDuration();
4832 // if still unset set to an arbitrary time 60 seconds:
4933 if ( !this.duration )this.duration = 60;
50 - // @@todo we should have src property in our base embed object
51 - var mediaSrc = this.getSrc();
5234
 35+ var applet_loc = this.getAppletLocation();
 36+
 37+ mw.log('Applet location: ' + applet_loc );
 38+ mw.log('Play media: ' + this.getSrc() );
 39+
 40+ // load directly in the page..
 41+ // (media must be on the same server or applet must be signed)
 42+ var appletCode = '' +
 43+ '<applet id="' + this.pid + '" code="com.fluendo.player.Cortado.class" archive="' + applet_loc + '" width="' + this.width + '" height="' + this.height + '"> ' + "\n" +
 44+ '<param name="url" value="' + this.getSrc() + '" /> ' + "\n" +
 45+ '<param name="local" value="false"/>' + "\n" +
 46+ '<param name="keepaspect" value="true" />' + "\n" +
 47+ '<param name="video" value="true" />' + "\n" +
 48+ '<param name="showStatus" value="hide" />' + "\n" +
 49+ '<param name="audio" value="true" />' + "\n" +
 50+ '<param name="seekable" value="true" />' + "\n" +
 51+ '<param name="duration" value="' + this.duration + '" />' + "\n" +
 52+ '<param name="bufferSize" value="4096" />' + "\n" +
 53+ '</applet>';
 54+
 55+ // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar
 56+ // Doesn't work in MSIE or Safari/Mac or Opera 9.5
 57+ if ( $j.browser.mozilla ) {
 58+ var iframe = document.createElement( 'iframe' );
 59+ iframe.setAttribute( 'width', this.width );
 60+ iframe.setAttribute( 'height', this.height );
 61+ iframe.setAttribute( 'scrolling', 'no' );
 62+ iframe.setAttribute( 'frameborder', 0 );
 63+ iframe.setAttribute( 'marginWidth', 0 );
 64+ iframe.setAttribute( 'marginHeight', 0 );
 65+ iframe.setAttribute( 'id', 'cframe_' + this.id )
 66+
 67+ // Append the iframe to the embed object:
 68+ $j( this ).html( iframe );
 69+
 70+ // Write out the iframe content:
 71+ var newDoc = iframe.contentDocument;
 72+ newDoc.open();
 73+ newDoc.write( '<html><body>' + appletCode + '</body></html>' );
 74+ // spurious error in some versions of FF, no workaround known
 75+ newDoc.close();
 76+ } else {
 77+ $j( this ).html( appletCode );
 78+ }
 79+
 80+ // Start the monitor:
 81+ this.monitor();
 82+ },
 83+
 84+ /**
 85+ * Get the applet location
 86+ */
 87+ getAppletLocation: function(){
 88+ var mediaSrc = this.getSrc()
5389 if ( mediaSrc.indexOf( '://' ) != -1 & !mw.isLocalDomain( mediaSrc ) ) {
5490 if ( window.cortadoDomainLocations[ mw.parseUri( mediaSrc ).host ] ) {
5591 applet_loc = window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host];
@@ -59,60 +95,18 @@
6096 // should be identical to cortado.jar
6197 applet_loc = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
6298 }
63 - // load directly in the page..
64 - // (media must be on the same server or applet must be signed)
65 - var appplet_code = '' +
66 - '<applet id="' + this.pid + '" code="com.fluendo.player.Cortado.class" archive="' + applet_loc + '" width="' + this.width + '" height="' + this.height + '"> ' + "\n" +
67 - '<param name="url" value="' + mediaSrc + '" /> ' + "\n" +
68 - '<param name="local" value="false"/>' + "\n" +
69 - '<param name="keepaspect" value="true" />' + "\n" +
70 - '<param name="video" value="true" />' + "\n" +
71 - '<param name="showStatus" value="hide" />' + "\n" +
72 - '<param name="audio" value="true" />' + "\n" +
73 - '<param name="seekable" value="true" />' + "\n" +
74 - '<param name="duration" value="' + this.duration + '" />' + "\n" +
75 - '<param name="bufferSize" value="4096" />' + "\n" +
76 - '</applet>';
77 -
78 - // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar
79 - // Doesn't work in MSIE or Safari/Mac or Opera 9.5
80 - if ( $j.browser.mozilla ) {
81 - var iframe = document.createElement( 'iframe' );
82 - iframe.setAttribute( 'width', params.width );
83 - iframe.setAttribute( 'height', playerHeight );
84 - iframe.setAttribute( 'scrolling', 'no' );
85 - iframe.setAttribute( 'frameborder', 0 );
86 - iframe.setAttribute( 'marginWidth', 0 );
87 - iframe.setAttribute( 'marginHeight', 0 );
88 - iframe.setAttribute( 'id', 'cframe_' + this.id )
89 - elt.appendChild( iframe );
90 - var newDoc = iframe.contentDocument;
91 - newDoc.open();
92 - newDoc.write( '<html><body>' + appplet_code + '</body></html>' );
93 - newDoc.close(); // spurious error in some versions of FF, no workaround known
94 - } else {
95 - return appplet_code;
96 - }
 99+ return applet_loc;
97100 },
98101
99102 /**
100 - * Once the applet has been embed start monitoring playback
101 - */
102 - postEmbedJS:function() {
103 - // start monitor:
104 - this.monitor();
105 - },
106 -
107 - /**
108103 * Monitor applet playback, and update currentTime
109104 */
110 - monitor:function() {
111 - this.getPlayerElement();
112 - if ( this.isPlaying() ) {
113 - if ( this.playerElement ) {
 105+ monitor: function() {
 106+ this.getPlayerElement();
 107+ if ( this.playerElement ) {
114108 try {
115109 // java reads ogg media time.. so no need to add the start or seek offset:
116 - // mw.log(' ct: ' + this.playerElement.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
 110+ mw.log(' ct: ' + this.playerElement.getPlayPosition() + ' ' + this.supportsURLTimeEncoding());
117111 this.currentTime = this.playerElement.getPlayPosition();
118112 if ( this.playerElement.getPlayPosition() < 0 ) {
119113 mw.log( 'pp:' + this.playerElement.getPlayPosition() );
@@ -120,17 +114,18 @@
121115 this.onClipDone();
122116 }
123117 } catch ( e ) {
124 - mw.log( 'could not get time from jPlayer: ' );
 118+ mw.log( 'could not get time from jPlayer: ' + e );
125119 }
126 - }
127 - }
128 - // once currentTime is updated call parent_monitor
 120+ }else{
 121+ mw.log(" could not find playerElement " );
 122+ }
 123+ // Once currentTime is updated call parent_monitor
129124 this.parent_monitor();
130125 },
131126
132127 /**
133128 * Seek in the ogg stream
134 - * (Cortado seek does not seem to work very well)
 129+ * ( Cortado seek does not seem to work very well )
135130 * @param {Float} percentage Percentage to seek into the stream
136131 */
137132 doSeek:function( percentage ) {
@@ -138,10 +133,7 @@
139134 this.getPlayerElement();
140135
141136 if ( this.supportsURLTimeEncoding() ) {
142 - this.parent_doSeek( percentage );
143 - // this.seek_time_sec = mw.npt2seconds( this.start_ntp ) + parseFloat( percentage * this.getDuration() );
144 - // this.playerElement.setParam('url', this.getSrc( this.seek_time_sec ))
145 - // this.playerElement.restart();
 137+ this.parent_doSeek( percentage );
146138 } else if ( this.playerElement ) {
147139 // do a (generally broken) local seek:
148140 mw.log( "cortado javascript seems to always fail ... but here we go... doSeek(" + ( percentage * parseFloat( this.getDuration() ) ) );
@@ -183,7 +175,7 @@
184176 */
185177 getPlayerElement:function() {
186178 if ( $j.browser.mozilla ) {
187 - this.playerElement = window.frames['cframe_' + this.id ].document.getElementById( this.pid );
 179+ this.playerElement = $j('#cframe_' + this.id).contents().find( '#' + this.pid );
188180 } else {
189181 this.playerElement = $j( '#' + this.pid ).get( 0 );
190182 }
@@ -205,11 +197,12 @@
206198 * Issue the doPlay request to the playerElement
207199 * calls parent_play to update interface
208200 */
209 - play:function() {
 201+ play: function() {
210202 this.getPlayerElement();
211203 this.parent_play();
212 - if ( this.playerElement )
213 - this.playerElement.doPlay();
 204+ if ( this.playerElement && this.playerElement.play ){
 205+ this.playerElement.play();
 206+ }
214207 },
215208
216209 /**
@@ -218,8 +211,11 @@
219212 */
220213 pause:function() {
221214 this.getPlayerElement();
 215+ // Update the interface
222216 this.parent_pause();
223 - if ( this.playerElement && this.playerElement.doPause )
224 - this.playerElement.doPause();
 217+ // Call the pause function if it exists:
 218+ if ( this.playerElement && this.playerElement.pause ){
 219+ this.playerElement.pause();
 220+ }
225221 }
226222 };
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/htmlEmbed.js
@@ -11,11 +11,11 @@
1212
1313 // List of supported features
1414 supports: {
15 - 'play_head':true,
 15+ 'playHead':true,
1616 'pause':true,
1717 'fullscreen':false,
18 - 'time_display':true,
19 - 'volume_control':true,
 18+ 'timeDisplay':true,
 19+ 'volumeControl':true,
2020
2121 'overlays':true,
2222
@@ -199,8 +199,8 @@
200200 /**
201201 * Get the "embed" html for the html player
202202 */
203 - getEmbedHTML:function() {
204 - mw.log( 'f:html:getEmbedHTML: ' + this.id );
 203+ doEmbedHTML: function() {
 204+ mw.log( 'f:html:doEmbedHTML: ' + this.id );
205205 // set up the css for our parent div:
206206 $j( this ).css( {
207207 'width':this.pc.pp.width,
@@ -242,14 +242,6 @@
243243 this.getEmbedHTML();
244244 },
245245
246 - /**
247 - * Display the "embed" html right away
248 - */
249 - getHTML:function() {
250 - mw.log( 'htmlEmbed::getHTML() ' + this.id );
251 - this.getEmbedHTML();
252 - },
253 -
254246 /**
255247 * Get the media duration
256248 */
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/vlcEmbed.js
@@ -10,12 +10,12 @@
1111
1212 //What the vlc player / plug-in supports:
1313 supports : {
14 - 'play_head':true,
 14+ 'playHead':true,
1515 'pause':true,
1616 'stop':true,
1717 'fullscreen':true,
18 - 'time_display':true,
19 - 'volume_control':true,
 18+ 'timeDisplay':true,
 19+ 'volumeControl':true,
2020
2121 'playlist_driver':true, // if the object supports playlist functions
2222 'overlay':false
@@ -30,43 +30,45 @@
3131 /**
3232 * Get embed HTML
3333 */
34 - getEmbedHTML: function() {
35 - var _this = this;
 34+ doEmbedHTML: function() {
 35+ var _this = this;
 36+ /*$j( this ).html(
 37+ '<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" ' +
 38+ 'codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,6,0" ' +
 39+ 'id="' + this.pid + '" events="True" height="' + this.height + '" width="' + this.width + '"' +
 40+ '>' +
 41+ '<param name="MRL" value="">' +
 42+ '<param name="ShowDisplay" value="True">' +
 43+ '<param name="AutoLoop" value="False">' +
 44+ '<param name="AutoPlay" value="False">' +
 45+ '<param name="Volume" value="50">' +
 46+ '<param name="StartTime" value="0">' +
 47+ '<embed pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" ' +
 48+ 'progid="VideoLAN.VLCPlugin.2" name="' + this.pid + '" ' +
 49+ 'height="' + this.height + '" width="' + this.width + '" ' +
 50+ // set the style too 'just to be sure'
 51+ 'style="width:' + this.width + 'px;height:' + this.height + 'px;" ' +
 52+ '>' +
 53+ '</object>'
 54+ )*/
 55+ $j( this ).html(
 56+ '<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" '+
 57+ 'width="' + this.width +'" ' +
 58+ 'height="' + this.height + '" ' +
 59+ 'id="' + this.pid + '"> ' +
 60+ '</embed>'
 61+ );
 62+
 63+
3664 // give VLC 150ms to initialize before we start playback
3765 // @@todo should be able to do this as an ready event
3866 this.waitForVlcCount = 0;
3967 setTimeout( function(){
4068 _this.postEmbedJS();
4169 }, 150 );
42 - return this.getEmbedObj();
43 - },
 70+ },
4471
4572 /**
46 - * Function to get embed object code
47 - */
48 - getEmbedObj:function() {
49 - var embed_code = '<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" ' +
50 - 'codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,6,0" ' +
51 - 'id="' + this.pid + '" events="True" height="' + this.height + '" width="' + this.width + '"' +
52 - '>' +
53 - '<param name="MRL" value="">' +
54 - '<param name="ShowDisplay" value="True">' +
55 - '<param name="AutoLoop" value="False">' +
56 - '<param name="AutoPlay" value="False">' +
57 - '<param name="Volume" value="50">' +
58 - '<param name="StartTime" value="0">' +
59 - '<embed pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" ' +
60 - 'progid="VideoLAN.VLCPlugin.2" name="' + this.pid + '" ' +
61 - 'height="' + this.height + '" width="' + this.width + '" ' +
62 - // set the style too 'just to be sure'
63 - 'style="width:' + this.width + 'px;height:' + this.height + 'px;" ' +
64 - '>' +
65 - '</object>';
66 - mw.log( 'embed with: ' + embed_code );
67 - return embed_code;
68 - },
69 -
70 - /**
7173 * Javascript to run post vlc embedding
7274 * Inserts the requested src to the embed instance
7375 */
@@ -74,12 +76,15 @@
7577 var _this = this;
7678 // load a pointer to the vlc into the object (this.playerElement)
7779 this.getPlayerElement();
78 - if ( this.playerElement.log ) {
 80+ if ( this.playerElement && this.playerElement.playlist) {
7981 // manipulate the dom object to make sure vlc has the correct size:
8082 this.playerElement.style.width = this.width;
8183 this.playerElement.style.height = this.height;
8284 this.playerElement.playlist.items.clear();
 85+
 86+ // VLC likes absolute urls:
8387 var src = mw.absoluteUrl( this.getSrc() ) ;
 88+
8489 // @@todo if client supports seeking no need to send seek_offset to URI
8590 mw.log( 'vlc play::' + src );
8691 var itemId = this.playerElement.playlist.add( src );
@@ -93,7 +98,7 @@
9499 _this.monitor();
95100 }, 100 );
96101 } else {
97 - mw.log( 'postEmbedJS:vlc not ready' );
 102+ mw.log( 'postEmbedJS: vlc not ready' );
98103 this.waitForVlcCount++;
99104 if ( this.waitForVlcCount < 10 ) {
100105 setTimeout( function(){
@@ -299,7 +304,7 @@
300305
301306 /**
302307 * Update the player volume
303 - * @pram {Float} percent Percet of total volume
 308+ * @pram {Float} percent Percent of total volume
304309 */
305310 updateVolumen:function( percent ) {
306311 if ( this.getPlayerElement() )
@@ -330,10 +335,7 @@
331336 * Get the embed vlc object
332337 */
333338 getPlayerElement : function() {
334 - this.playerElement = $j('#' + this.pid ).get(0);
335 - if( this.playerElement )
336 - return true;
337 - else
338 - return false;
 339+ this.playerElement = $j( '#' + this.pid ).get(0);
 340+ return this.playerElement;
339341 }
340342 };
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -27,48 +27,45 @@
2828
2929 // Native player supported feature set
3030 supports: {
31 - 'play_head':true,
32 - 'pause':true,
33 - 'fullscreen':false,
34 - 'time_display':true,
35 - 'volume_control':true,
 31+ 'playHead' : true,
 32+ 'pause' : true,
 33+ 'fullscreen' : false,
 34+ 'timeDisplay' : true,
 35+ 'volumeControl' : true,
3636
37 - 'overlays':true,
38 - 'playlist_swap_loader':true // if the object supports playlist functions
 37+ 'overlays' : true,
 38+ // if the object supports playlist functions
 39+ 'playlist_swap_loader' : true
3940 },
4041
4142 /**
4243 * Return the embed code
4344 */
44 - getEmbedHTML : function () {
 45+ doEmbedHTML : function () {
4546 var _this = this;
46 - var embed_code = this.getEmbedObj();
47 - mw.log( "embed code: " + embed_code )
 47+
 48+ mw.log( "native play url:" + this.getSrc() + ' startOffset: ' + this.start_ntp + ' end: ' + this.end_ntp );
 49+
 50+ $j( this ).html(
 51+ $j( '<video />' )
 52+ .attr( {
 53+ 'id' : this.pid,
 54+ 'autoplay' : "true",
 55+ 'src' : this.getSrc()
 56+ } )
 57+ .css( {
 58+ 'width' : this.width,
 59+ 'height' : this.height
 60+ } )
 61+ )
 62+ mw.log( "Embed code: " + $j( this ).html() )
 63+
4864 setTimeout( function(){
4965 _this.postEmbedJS();
50 - }, 150 );
51 - return embed_code;
 66+ }, 150 );
5267 },
5368
5469 /**
55 - * Get the native embed code
56 - */
57 - getEmbedObj: function() {
58 - // We want to let mwEmbed handle the controls so notice the absence of control attribute
59 - // controls=false results in controls being displayed:
60 - // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-August/016159.html
61 - mw.log( "native play url:" + this.getSrc() + ' startOffset: ' + this.start_ntp + ' end: ' + this.end_ntp );
62 - var eb = '<video ' +
63 - 'id="' + this.pid + '" ' +
64 - 'style="width:' + this.width + 'px;height:' + this.height + 'px;" ' +
65 - 'width="' + this.width + '" height="' + this.height + '" ' +
66 - 'autoplay="true" ' +
67 - 'src="' + this.getSrc() + '" >' +
68 - '</video>';
69 - return eb;
70 - },
71 -
72 - /**
7370 * Post element javascript, binds event listeners and starts monitor
7471 */
7572 postEmbedJS: function() {
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js
@@ -462,9 +462,10 @@
463463 serverBrowseFile();
464464 return true;
465465 }
466 - // Else do a normal api request :
 466+ // Else do an api request :
467467 return serverApiRequest();
468468 }
 469+
469470 /**
470471 * Api iFrame request:
471472 */
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -28,69 +28,9 @@
2929 /*
3030 * Set the mwEmbedVersion ( not set by stopgap )
3131 */
32 -var MW_EMBED_VERSION = '1.1a';
 32+var MW_EMBED_VERSION = '1.1d';
3333
3434 /**
35 -* Default global config values. Configuration values are set via mw.setConfig
36 -* Configuration values should generally be set prior to dom-ready
37 -*/
38 -var mwDefaultConf = {
39 -
40 - // Default skin name
41 - 'skinName' : 'mvpcf',
42 -
43 - // Default jquery ui skin name
44 - 'jQueryUISkin' : 'redmond',
45 -
46 - /**
47 - * If jQuery / mwEmbed should be loaded.
48 - *
49 - * This flag is automatically set to true if:
50 - * Any script calls mw.ready ( callback_function )
51 - * Page DOM includes any tags set in config.rewritePlayerTags at onDomReady
52 - * ( embedPlayer module )
53 - *
54 - * This flag increases page performance on pages that do not use mwEmbed
55 - * and don't already load jQuery
56 - *
57 - * For example when including the mwEmbed.js in your blog template
58 - * mwEmbed will only load extra js on blog posts that include the video tag.
59 - *
60 - * NOTE: Future architecture will probably do away with this flag and refactor it into
61 - * a smaller "remotePageMwEmbed.js" script similar to ../remoteMwEmbed.js
62 - */
63 - 'runSetupMwEmbed' : false,
64 -
65 - // The mediaWiki path of mvEmbed
66 - 'mediaWiki_mwEmbedPath' : 'js/mwEmbed/',
67 -
68 - // Api actions that must be submitted in a POST, and need an api proxy for cross domain calls
69 - 'apiPostActions': [ 'login', 'purge', 'rollback', 'delete', 'undelete',
70 - 'protect', 'block', 'unblock', 'move', 'edit', 'upload', 'emailuser',
71 - 'import', 'userrights' ],
72 -
73 - //If we are in debug mode ( results in fresh debug javascript includes )
74 - 'debug' : false,
75 -
76 - // Valid language codes ( has a file in /includes/languages/classes/Language{code}.js )
77 - // TODO: mirror the mediaWiki language "fallback" system
78 - 'languageCodeList': ['en', 'am', 'ar', 'bat_smg', 'be_tarak', 'be', 'bh',
79 - 'bs', 'cs', 'cu', 'cy', 'dsb', 'fr', 'ga', 'gd', 'gv', 'he', 'hi',
80 - 'hr', 'hsb', 'hy', 'ksh', 'ln', 'lt', 'lv', 'mg', 'mk', 'mo', 'mt',
81 - 'nso', 'pl', 'pt_br', 'ro', 'ru', 'se', 'sh', 'sk', 'sl', 'sma',
82 - 'sr_ec', 'sr_el', 'sr', 'ti', 'tl', 'uk', 'wa'
83 - ],
84 -
85 - // Default user language is "en" Can be overwritten by:
86 - // "uselang" url param
87 - // wgUserLang global
88 - 'userLanguage' : 'en',
89 -
90 - // Set the default providers ( you can add more provider via {provider_id}_apiurl = $api_url
91 - 'commons_apiurl' : 'http://commons.wikimedia.org/w/api.php'
92 -};
93 -
94 -/**
9535 * The global mw object:
9636 *
9737 * Any global functions/classes that are not jQuery plugins should make
@@ -102,7 +42,7 @@
10343 mw.valid_skins = [ 'mvpcf', 'kskin' ];
10444
10545 // The version of mwEmbed
106 - mw.version = '1.1';
 46+ mw.version = MW_EMBED_VERSION
10747
10848 /**
10949 * Configuration System:
@@ -119,22 +59,45 @@
12060 //Local scope mwUserConfig var. Stores user configuration
12161 var mwUserConfig = { };
12262
123 - for( var i in mwDefaultConf ){
124 - if( typeof mwConfig[ i ] == 'undefined' )
125 - mwConfig[ i ] = mwDefaultConf[ i ];
126 - }
127 -
12863 /**
12964 * Setter for configuration values
13065 *
131 - * @param {String} name Name of configuration value
 66+ * @param [Mixed] name Name of configuration value
 67+ * {Object} Will iderate through each key and call setConfig
 68+ * {String} Will set configuration by string name to value
13269 * @param {String} value Value of configuration name
13370 */
134 - mw.setConfig = function ( name, value ){
 71+ mw.setConfig = function ( name, value ) {
 72+ if( typeof name == 'object' ){
 73+ for( var i in name ){
 74+ mw.setConfig( i, name[ i ] );
 75+ }
 76+ }
13577 mwConfig[ name ] = value;
13678 }
13779
13880 /**
 81+ * Set a default config value
 82+ * Will only update configuration if no value is present
 83+ * @param [Mixed] name
 84+ * {Object} Will iderate through each key and call setDefaultConfig
 85+ * {String} Will set configuration by string name to value
 86+ * @param [Mixed] value Set configuration name to value
 87+ */
 88+ mw.setDefaultConfig = function( name, value ) {
 89+ if( typeof name == 'object' ){
 90+ for( var i in name ){
 91+ mw.setDefaultConfig( i, name[ i ] );
 92+ }
 93+ return ;
 94+ }
 95+ // Name is a string update the config directly
 96+ if( ! mwConfig[ name ] ){
 97+ mwConfig[ name ] = value;
 98+ }
 99+ }
 100+
 101+ /**
139102 * Getter for configuration values
140103 *
141104 * @param {String} name of configuration value to get
@@ -277,11 +240,11 @@
278241 * Swap in an array of values for $1, $2, $n for a given msg key
279242 *
280243 * @param string msgKey The msg key to lookup
281 - * @param [mixed] args An array of string or jquery objects to be swaped in
 244+ * @param [mixed] args An array of string or jquery objects to be swapped in
282245 * @return string
283246 */
284247 mw.lang.msgReplaceArgs = function( message , args ) {
285 - // replace values
 248+ // Replace Values
286249 if ( typeof args == 'object' || typeof args == 'array' ) {
287250 for ( var v =0; v < args.length; v++ ) {
288251 if( typeof args[v] == 'undefined' ){
@@ -523,9 +486,11 @@
524487 size = Math.round( size * p ) / p;
525488 return gM( msg , size );
526489 };
 490+
527491 /**
528492 * Format a number
529493 * @param {Number} num Number to be formated
 494+ * NOTE: add il8n support to includes/lanuages/class/Language{langCode}.js
530495 */
531496 mw.lang.formatNumber = function( num ) {
532497 /*
@@ -569,9 +534,10 @@
570535 // invalidate the output (will force a re-parse )
571536 this.pOut = '';
572537 },
 538+
573539 /**
574540 * Quickly recursive / parse out templates:
575 - * This parser only really only tested against msg templates see tests/testLang.html
 541+ * This parser is only tested against msg templates see tests/testLang.html
576542 */
577543 parse : function() {
578544 function rdpp ( txt , cn ) {
@@ -594,7 +560,7 @@
595561 }
596562 if ( !node['t'] )
597563 node['t'] = '';
598 - // don't put closures into output:
 564+ // Don't put }} closures into output:
599565 if ( txt[a] && txt[a] != '}' )
600566 node['t'] += txt[a];
601567
@@ -692,12 +658,14 @@
693659 return getMagicTxtFromTempNode( node );
694660 }
695661 }
696 - // parse out the template node structure:
 662+
 663+ // Parse out the template node structure:
697664 this.pNode = rdpp ( this.wikiText );
698 - // strip out the parent from the root
 665+
 666+ // Strip out the parent from the root
699667 this.pNode['p'] = null;
700668
701 - // do the recursive magic swap text:
 669+ // Do the recursive magic swap text:
702670 this.pOut = recurse_magic_swap( this.pNode );
703671 },
704672
@@ -835,7 +803,7 @@
836804 }
837805
838806 /**
839 - * Runs all the hooks by a given name with refrence to the host object
 807+ * Runs all the hooks by a given name with reference to the host object
840808 *
841809 * Should be called by the host object at named execution points
842810 *
@@ -935,7 +903,7 @@
936904 typeof ( this.moduleLoaders[ loadRequest ] ) == 'function'
937905 ){
938906 mw.log("mw.load: loadModule:" + loadRequest );
939 - //Run the module with the parent callback
 907+ // Run the module with the parent callback
940908 this.moduleLoaders[ loadRequest ]( callback );
941909 return ;
942910 }
@@ -995,8 +963,9 @@
996964 loadStates[ loadName ] = 0;
997965 }
998966 }
 967+
999968 // We are infact loading many:
1000 - mw.log("mw.load: LoadMany:: " + loadSet );
 969+ mw.log("mw.load: LoadMany:: " + loadSet );
1001970
1002971 // Issue the load request check check loadStates to see if we are "done"
1003972 for( var loadName in loadStates ){
@@ -1280,7 +1249,7 @@
12811250 callback( requestName )
12821251 }
12831252 // Add it to the function queue
1284 - if( ! mwLoadDoneCB[ requestName ] ){
 1253+ if( ! mwLoadDoneCB[ requestName ] || mwLoadDoneCB[ requestName ].length ){
12851254 mwLoadDoneCB[ requestName ] = [];
12861255 }
12871256 mwLoadDoneCB[ requestName ].push( callback );
@@ -1332,11 +1301,11 @@
13331302
13341303 /**
13351304 *
1336 - * Shortcut to latest revision text of a given title
 1305+ * Shortcut to latest revision text for a given title
13371306 *
13381307 * Assumes "follow redirects"
13391308 *
1340 - * $j.getTitleText( [url], title, callback )
 1309+ * $j.getTitleText( [apiUrl], title, callback )
13411310 *
13421311 * @param {String} url or title key
13431312 * @parma {Mixed} title or callback function
@@ -1970,7 +1939,7 @@
19711940 // Check for scriptLoader include of mwEmbed:
19721941 if ( src.indexOf( 'mwScriptLoader.php' ) !== -1 ) {
19731942 // Script loader is in the root of MediaWiki, Include the default mwEmbed extension path:
1974 - mwpath = src.substr( 0, src.indexOf( 'mwScriptLoader.php' ) ) + mw.getConfig( 'mediaWiki_mwEmbedPath' );
 1943+ mwpath = src.substr( 0, src.indexOf( 'mwScriptLoader.php' ) ) + mw.getConfig( 'mediaWikiEmbedPath' );
19751944 }
19761945
19771946 // Script-loader has jsScriptLoader name when local:
@@ -2415,12 +2384,15 @@
24162385 mw.log( 'doLoaderCheck::' );
24172386 // Check if we are using scriptloader ( handles loader include automatically )
24182387 if( mw.getScriptLoaderPath() ){
2419 - callback();
 2388+ // Do a async call to callback in cases where DOM is ready before we get to
 2389+ // loader config code in the same file.
 2390+ setTimeout(function(){
 2391+ callback();
 2392+ }, 1000);
24202393 return ;
24212394 }
24222395 // Add the Core loader to the request
2423 - mw.load( 'loader.js', function(){
2424 -
 2396+ mw.load( 'loader.js', function(){
24252397 // Load all the "loaders" of the enabled modules:
24262398 var loaderRequest = [];
24272399 var enabledModules = mw.getConfig( 'enabledModules' );
@@ -2439,6 +2411,9 @@
24402412
24412413 mw.setConfig('loaderContext', '' );
24422414 mw.load( loaderRequest, function(){
 2415+ mw.log( 'Done moduleLoaderCheck request' );
 2416+ // Set the mwModuleLoaderCheckFlag flag to true
 2417+ mwModuleLoaderCheckFlag = true;
24432418 callback();
24442419 } );
24452420 } );
@@ -2484,7 +2459,10 @@
24852460 // Flag to register the domReady has been called
24862461 var mwDomReadyFlag = false;
24872462
2488 - // Functions to run on DOM ready
 2463+ // Flag to register if the domreadyHooks have been called
 2464+ var mwModuleLoaderCheckFlag = false;
 2465+
 2466+ // Functions to run on DOM ready
24892467 var mwOnDOMReadyFunctions = [];
24902468
24912469 /**
@@ -2496,12 +2474,13 @@
24972475 *
24982476 * @param {Function} callback Function to be called at dom ready
24992477 */
2500 - mw.addDOMReadyHook = function( callback ) {
2501 - //mw.log( 'addDOMReadyHook::' );
2502 - if ( ! mwDomReadyFlag ) {
2503 - mwOnDOMReadyFunctions.push( callback );
2504 - } else {
 2478+ mw.addDOMReadyHook = function( callback ) {
 2479+ if ( mwModuleLoaderCheckFlag ) {
 2480+ mw.log( "Possible Error: calling mw.addDOMReadyHook after moduleLoader check" );
25052481 callback ( );
 2482+ } else {
 2483+ // Add the dom ready check to the function queue:
 2484+ mwOnDOMReadyFunctions.push( callback );
25062485 }
25072486 }
25082487
@@ -2510,22 +2489,22 @@
25112490 * Will check configuration and issue a mw.setupMwEmbed call if needed
25122491 */
25132492 mw.domReady = function ( ) {
2514 - if( mwDomReadyFlag )
2515 - return ;
2516 - mw.log( 'run:domReady' );
 2493+ if( mwDomReadyFlag ){
 2494+ return ;
 2495+ }
 2496+ mw.log( 'run:domReady:: ' + document.getElementsByTagName('video').length );
25172497 // Set the onDomReady Flag
25182498 mwDomReadyFlag = true;
25192499
25202500 // Make sure we have all the module loader.js files included
25212501 // ( where we are not using the script-loader )
2522 - mw.moduleLoaderCheck( function( ) {
2523 -
 2502+ mw.moduleLoaderCheck( function( ) {
 2503+
25242504 // Run dom ready hooks:
25252505 while( mwOnDOMReadyFunctions.length ) {
25262506 mwOnDOMReadyFunctions.pop()();
25272507 }
2528 -
2529 -
 2508+
25302509 // Check for the force setup flag:
25312510 if ( mw.getConfig( 'runSetupMwEmbed' ) ) {
25322511 mw.setupMwEmbed();
@@ -2742,10 +2721,11 @@
27432722 window.onload = i;
27442723 }
27452724 })( domReadyCheck );
 2725+
27462726 // As a backup check if "body" is not null ( for dynamic inserts )
27472727 // ( mw.domReady ignores multiple ready calls )
27482728 var mwCheckBody = function( ) {
2749 - if( document.getElementsByTagName('body')[0] ){
 2729+ if( document.getElementsByTagName( 'body' )[0] ){
27502730 mw.domReady();
27512731 }else{
27522732 setTimeout( function( ) {
@@ -2753,6 +2733,10 @@
27542734 }, 25);
27552735 }
27562736 }
2757 -mwCheckBody();
 2737+// Call with substatial timeout of 250ms
 2738+// ( This is just fallback method for
 2739+// dynamic inserts of mwEmbed ( rare ) )
 2740+setTimeout( function( ) {
 2741+ mwCheckBody();
 2742+}, 250);
27582743
2759 -

Status & tagging log