* re-factored language code into global $mw with function alias scope
authorMichael Dale <dale@users.mediawiki.org>
Sat, 3 Oct 2009 02:10:15 +0000 (02:10 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Sat, 3 Oct 2009 02:10:15 +0000 (02:10 +0000)
* updated playlist and sequence to work with ctrlBuilder / new skin updates

js2/mwEmbed/libEmbedVideo/javaEmbed.js
js2/mwEmbed/libSequencer/mvPlayList.js
js2/mwEmbed/libSequencer/mvSequencer.js
js2/mwEmbed/mv_embed.js
js2/mwEmbed/skins/ctrlBuilder.js

index c552103..cbba18c 100644 (file)
@@ -152,21 +152,7 @@ var javaEmbed = {
                        this.jce = window.frames['cframe_' + this.id ].document.getElementById( this.pid );
                }else{
                        this.jce = $j('#'+this.pid).get( 0 );
-               }
-               /*if( ! mv_java_iframe ){
-                       
-               }else{
-                       if( $j('#iframe_' + this.pid ).length > 0 )
-                               try{
-                                       this.jce = $j('#iframe_' + this.pid ).get(0).contentWindow.jPlayer;
-                               }catch (e){
-                                       if(!this.logged_domain_error)
-                                               js_log("failed to grab jce we wont have time updates for java");
-                                       this.logged_domain_error = true;
-                               }
-                       else
-                               return false;
-               }   */           
+               }                
        },
        doThumbnailHTML:function(){             
                //empty out player html (jquery with java applets does mix) :                   
index f3fc43a..d2ebc01 100644 (file)
@@ -119,6 +119,9 @@ mvPlayList.prototype = {
                if(this.controls===false){                       
                        this.pl_layout.control_height=0;        
                        this.pl_layout.title_bar_height=0;                      
+               }else{
+                       //setup the controlBuilder object:
+                       this.ctrlBuilder = new ctrlBuilder( this ); 
                }                                                
        },                      
        //the element has now been swapped into the dom: 
@@ -438,7 +441,7 @@ mvPlayList.prototype = {
                                this.cur_clip.embed.getPlayButton()
                );
                //once the controls are in the DOM add hooks: 
-                       ctrlBuilder.addControlHooks(this);
+                       this.ctrlBuilder.addControlHooks(this);
                }else{
                        //just append the video: 
                        $j('#dc_'+_this.id).append(
@@ -901,7 +904,7 @@ mvPlayList.prototype = {
        //next prev button and more status display
        getControlsHTML:function(){
                //get controls from current clip  (add some playlist specific controls:                                 
-               return ctrlBuilder.getControls( this );
+               return this.ctrlBuilder.getControls( this );
        },      
        //ads colors/dividers between tracks
        colorPlayHead: function(){
@@ -938,7 +941,7 @@ mvPlayList.prototype = {
                        barHtml+= 'filter:alpha(opacity=40);'+
                                        '-moz-opacity:.40;">';  
                        
-                       barHtml+= ctrlBuilder.getMvBufferHtml();
+                       barHtml+= _this.ctrlBuilder.getMvBufferHtml();
                        
                        barHtml+='</div>';
                        
index 583c1df..667fe23 100644 (file)
@@ -7,7 +7,7 @@
  * @author Michael Dale
  * @email mdale@wikimedia.org
  *
- * further developed in open source development partnership with kaltura.
+ * Further developed in open source development partnership with kaltura.
  * more info at http://kaltura.com & http://kaltura.org
  *
  * mv_sequencer.js
@@ -1441,7 +1441,7 @@ mvSequencer.prototype = {
                this.plObj.updateBaseStatus();
 
                //once the controls are in the DOM add hooks:
-               ctrlBuilder.addControlHooks(this.plObj);
+               this.plObj.ctrlBuilder.addControlHooks(this.plObj);
 
                //render out the "jump" div
                if(this.timeline_mode=='time'){
index 556d081..8acf477 100644 (file)
@@ -19,8 +19,8 @@ var MV_DO_INIT=true;
 if( MV_EMBED_VERSION ){
        MV_DO_INIT=false;
 }
-// Used to grab fresh copies of scripts. (should be changed on commit)
-var MV_EMBED_VERSION = '1.0r19';
+// Used to grab fresh copies of scripts. 
+var MV_EMBED_VERSION = '1.0r20';
 
 /*
  * Configuration variables should be set by extending mwConfigOptions
@@ -32,26 +32,10 @@ var mwDefaultConfig = {
        'video_size':'400x300'
 }
 
+// (We install the default config values for anything not set in mwConfig once we know we have jquery)
 if( !mwConfig )
        var mwConfig = {};
 
-// Install the default config values for anything not set in mwConfig
-
-// Whether or not to load java from an iframe.
-// Note: this is necessary for remote embedding because of Java's security model)
-if( !mv_java_iframe )
-       var mv_java_iframe = true;
-
-// For use when mv_embed with script-loader is in the root MediaWiki path
-var mediaWiki_mvEmbed_path = 'js2/mwEmbed/';
-
-var global_player_list = new Array(); // The global player list per page
-var global_req_cb = new Array(); // The global request callback array
-var _global = this; // Global obj
-var mv_init_done = false;
-var global_cb_count = 0;
-
-
 // parseUri 1.2.2
 // (c) Steven Levithan <stevenlevithan.com>
 // MIT License
@@ -83,22 +67,169 @@ parseUri.options = {
        }
 };
 
+// For use when mv_embed with script-loader is in the root MediaWiki path
+var mediaWiki_mvEmbed_path = 'js2/mwEmbed/';
+
+
+var _global = this; // Global obj
+
+/*
+* setup the empty global $mw object 
+* will ensure all our functions are properly namespaced
+*/
+if(!_global['$mw']){
+       _global['$mw'] = {}
+}
+
+//@@todo move these into $mw
+var mv_init_done = false;
+var global_cb_count = 0;
+var global_player_list = new Array(); // The global player list per page
+var global_req_cb = new Array(); // The global request callback array
+
 // Get the mv_embed location if it has not been set
 if( !mv_embed_path ) {
        var mv_embed_path = getMvEmbedPath();
 }
 
-// Init the global message table if it has not been initialized already
-if( !gMsg ) {
-       var gMsg = {};
-}
 
-// Language msg loader
-function loadGM( msgSet ) {
-       for( var i in msgSet ) {
-               gMsg[ i ] = msgSet[i];
+/*
+* Language classes $mw.lang
+* 
+* Localized Language suport attempts to mirror the functionality of Language.php in MediaWiki
+* It contains methods for loading and transforming msg text
+* 
+* code style:: 
+*      We could wrap each $mw extend in (function( $ ) { //functions here })($mw); and refrence $mw as $
+*/
+(function( $ ) {
+       $.lang = {};
+       /**
+       * Setup the lang object
+       */
+       var gMsg = {};
+       /**
+       * loadGM function
+       * Loads a set of json messeges into the lang object. 
+       *
+       * @param json msgSet The set of msgs to be loaded 
+       */
+       $.lang.loadGM = function( msgSet ){
+               for( var i in msgSet ) {
+                       gMsg[ i ] = msgSet[i];
+               }
+       },
+       /**
+        * Returns a transformed msg string
+        *
+        * it take a msg key and array of replacement values of form
+        * $1, $2 and does relevant msgkey transformation returning 
+        * the usser msg. 
+        *
+        * @param string key The msg key as set by loadGm
+        * @param [mixed] args  An array of replacement strings
+        * @return string 
+        */
+       $.lang.gM = function( key , args ) {
+               var ms = '';
+               if ( key in gMsg ) {
+                       ms = gMsg[ key ];
+                       //test if we have a special replacement template call
+                       
+                       
+                       if( typeof args == 'object' || typeof args == 'array' ) {
+                               for( var v in args ) { 
+                                       // Message test replace arguments start at 1 instead of zero:
+                                       var rep = '\$'+ ( parseInt(v) + 1 );
+                                       ms = ms.replace( rep, args[v] );
+                               }
+                       } else if( typeof args =='string' || typeof args =='number' ) {
+                               ms = ms.replace(/\$1/, args);
+                       }
+                       return ms;
+               } else {
+                       // Missing key placeholder
+                       return '&lt;' + key + '&gt;';
+               }
+       },
+       /**
+        * gMsgLoadRemote loads remote msg strings
+        * 
+        * @param mixed msgSet the set of msg to load remotely
+        * @param function callback  the callback to issue once string is ready
+        */
+       $.lang.gMsgLoadRemote = function( msgSet, callback ) {
+               var ammessages = '';
+               if( typeof msgSet == 'object' ) {
+                       for( var i in msgSet ) {
+                               ammessages += msgSet[i] + '|';
+                       }
+               } else if( typeof msgSet == 'string' ) {
+                       ammessages += msgSet;
+               }
+               if( ammessages == '' ) {
+                       js_log( 'gMsgLoadRemote: no message set requested' );           
+                       return false;
+               }
+               do_api_req({
+                       'data': {
+                               'meta': 'allmessages',
+                               'ammessages': ammessages
+                       }
+               }, function( data ) {
+                       if( data.query.allmessages ) {
+                               var msgs = data.query.allmessages;
+                               for( var i in msgs ) {
+                                       var ld = {};
+                                       ld[ msgs[i]['name'] ] = msgs[i]['*'];
+                                       loadGM( ld );
+                               }
+                       }
+                       callback();
+               });
+       },
+       /**
+        * Format a size in bytes for output, using an appropriate
+        * unit (B, KB, MB or GB) according to the magnitude in question
+        *
+        * @param size Size to format
+        * @return string Plain text (not HTML)
+        */
+       $.lang.formatSize = function ( size ) {
+               // For small sizes no decimal places are necessary
+               var round = 0;
+               var msg = '';
+               if( size > 1024 ) {
+                       size = size / 1024;
+                       if( size > 1024 ) {
+                               size = size / 1024;
+                               // For MB and bigger two decimal places are smarter
+                               round = 2;
+                               if( size > 1024 ) {
+                                       size = size / 1024;
+                                       msg = 'mwe-size-gigabytes';
+                               } else {
+                                       msg = 'mwe-size-megabytes';
+                               }
+                       } else {
+                               msg = 'mwe-size-kilobytes';
+                       }
+               } else {
+                       msg = 'mwe-size-bytes';
+               }
+               // JavaScript does not let you choose the precision when rounding
+               var p = Math.pow(10,round);
+               var size = Math.round( size * p ) / p;
+               //@@todo we need a formatNum and we need to request some special packaged info to deal with that case.
+               return gM( msg , size );
        }
-}
+})($mw);
+//setup legacy global shortcuts: 
+var loadGM = $mw.lang.loadGM;
+var gM = $mw.lang.gM;
+
+
+
 
 // All default messages in [English] should be overwritten by the CMS language message system.
 loadGM({
@@ -244,102 +375,7 @@ lcCssPath({
        '$j.Jcrop'                      : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
        '$j.fn.ColorPicker'     : 'libClipEdit/colorpicker/css/colorpicker.css'
 })
-/**
- * Language Functions:
- *
- * These functions try to loosely mirror the functionality of Language.php in MediaWiki
- */
-function gM( key , args ) {
-       var ms = '';
-       if ( key in gMsg ) {
-               ms = gMsg[ key ];
-               if( typeof args == 'object' || typeof args == 'array' ) {
-                       for( var v in args ) {
-                               // Message test replace arguments start at 1 instead of zero:
-                               var rep = '\$'+ ( parseInt(v) + 1 );
-                               ms = ms.replace( rep, args[v] );
-                       }
-               } else if( typeof args =='string' || typeof args =='number' ) {
-                       ms = ms.replace(/\$1/, args);
-               }
-               return ms;
-       } else {
-               // Missing key placeholder
-               return '&lt;' + key + '&gt;';
-       }
-}
-/**
- * gMsgLoadRemote loads remote msg strings
- * 
- * @param mixed msgSet the set of msg to load remotely
- * @param function callback  the callback to pass loaded msg to  
- */
-function gMsgLoadRemote( msgSet, callback ) {
-       var ammessages = '';
-       if( typeof msgSet == 'object' ) {
-               for( var i in msgSet ) {
-                       ammessages += msgSet[i] + '|';
-               }
-       } else if( typeof msgSet == 'string' ) {
-               ammessages += msgSet;
-       }
-       if( ammessages == '' ) {
-               js_log( 'gMsgLoadRemote: no message set requested' );           
-               return false;
-       }
-       do_api_req({
-               'data': {
-                       'meta': 'allmessages',
-                       'ammessages': ammessages
-               }
-       }, function( data ) {
-               if( data.query.allmessages ) {
-                       var msgs = data.query.allmessages;
-                       for( var i in msgs ) {
-                               var ld = {};
-                               ld[ msgs[i]['name'] ] = msgs[i]['*'];
-                               loadGM( ld );
-                       }
-               }
-               callback();
-       });
-}
 
-/**
- * Format a size in bytes for output, using an appropriate
- * unit (B, KB, MB or GB) according to the magnitude in question
- *
- * @param size Size to format
- * @return string Plain text (not HTML)
- */
-function formatSize( size ) {
-       // For small sizes no decimal places are necessary
-       var round = 0;
-       var msg = '';
-       if( size > 1024 ) {
-               size = size / 1024;
-               if( size > 1024 ) {
-                       size = size / 1024;
-                       // For MB and bigger two decimal places are smarter
-                       round = 2;
-                       if( size > 1024 ) {
-                               size = size / 1024;
-                               msg = 'mwe-size-gigabytes';
-                       } else {
-                               msg = 'mwe-size-megabytes';
-                       }
-               } else {
-                       msg = 'mwe-size-kilobytes';
-               }
-       } else {
-               msg = 'mwe-size-bytes';
-       }
-       // JavaScript does not let you choose the precision when rounding
-       var p = Math.pow(10,round);
-       var size = Math.round( size * p ) / p;
-       //@@todo we need a formatNum and we need to request some special packaged info to deal with that case.
-       return gM( msg , size );
-}
 
 // Get the loading image
 function mv_get_loading_img( style, class_attr ){
index 747eee7..f136982 100644 (file)
@@ -2,8 +2,9 @@
 _global['dismissNativeWarn'] = false;
 
 
-/** base ctrlBuilder object
-       @param the embedVideo element we are targeting
+/** 
+* base ctrlBuilder object
+*      @param the embedVideo element we are targeting
 */
 var ctrlBuilder = function( embedObj ) {
        return this.init( embedObj );