From b4aa482194debf69425381f5dc81ae2ed21866e9 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Sat, 3 Oct 2009 02:10:15 +0000 Subject: [PATCH] * re-factored language code into global $mw with function alias scope * updated playlist and sequence to work with ctrlBuilder / new skin updates --- js2/mwEmbed/libEmbedVideo/javaEmbed.js | 16 +- js2/mwEmbed/libSequencer/mvPlayList.js | 9 +- js2/mwEmbed/libSequencer/mvSequencer.js | 4 +- js2/mwEmbed/mv_embed.js | 282 +++++++++++++----------- js2/mwEmbed/skins/ctrlBuilder.js | 5 +- 5 files changed, 171 insertions(+), 145 deletions(-) diff --git a/js2/mwEmbed/libEmbedVideo/javaEmbed.js b/js2/mwEmbed/libEmbedVideo/javaEmbed.js index c55210385f..cbba18c9ec 100644 --- a/js2/mwEmbed/libEmbedVideo/javaEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/javaEmbed.js @@ -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) : diff --git a/js2/mwEmbed/libSequencer/mvPlayList.js b/js2/mwEmbed/libSequencer/mvPlayList.js index f3fc43ab67..d2ebc01644 100644 --- a/js2/mwEmbed/libSequencer/mvPlayList.js +++ b/js2/mwEmbed/libSequencer/mvPlayList.js @@ -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+=''; diff --git a/js2/mwEmbed/libSequencer/mvSequencer.js b/js2/mwEmbed/libSequencer/mvSequencer.js index 583c1df5ae..667fe233dd 100644 --- a/js2/mwEmbed/libSequencer/mvSequencer.js +++ b/js2/mwEmbed/libSequencer/mvSequencer.js @@ -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'){ diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 556d081c8d..8acf477153 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -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 // 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 '<' + key + '>'; + } + }, + /** + * 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 '<' + key + '>'; - } -} -/** - * 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 ){ diff --git a/js2/mwEmbed/skins/ctrlBuilder.js b/js2/mwEmbed/skins/ctrlBuilder.js index 747eee783b..f1369829b7 100644 --- a/js2/mwEmbed/skins/ctrlBuilder.js +++ b/js2/mwEmbed/skins/ctrlBuilder.js @@ -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 ); -- 2.20.1