From 96eb4b79c37ad8ec47486f7d14994a829b0dadb5 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Fri, 11 Sep 2009 18:00:09 +0000 Subject: [PATCH] * initial configuration via jQuery.extend in mv_embed * re-added example_folder (removed all non-commons external javascript and images calls) ** (The only external js is the commons api query) ** Theme based javascript include request changed to link to external site to install bookmarklet ** Timed text example removed (did jsonp call to get text) *** Will re-add local file based timed text example shortly. --- .../example_usage/Add_Media_Wizard.html | 50 ++++++++++ .../example_usage/Firefogg_Make_Advanced.html | 92 +++++++++++++++++++ .../example_usage/Player_RelatedVideos.html | 29 ++++++ .../example_usage/Player_Simple_Themable.html | 23 +++++ .../example_usage/Sequence_Editor.html | 40 ++++++++ .../example_usage/media/sample_smil.xml | 45 +++++++++ js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 87 ++++++++---------- .../libAddMedia/seqRemoteSearchDriver.js | 4 +- js2/mwEmbed/libSequencer/mvSequencer.js | 4 +- js2/mwEmbed/mv_embed.js | 64 ++++++------- 10 files changed, 350 insertions(+), 88 deletions(-) create mode 100644 js2/mwEmbed/example_usage/Add_Media_Wizard.html create mode 100644 js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html create mode 100644 js2/mwEmbed/example_usage/Player_RelatedVideos.html create mode 100644 js2/mwEmbed/example_usage/Player_Simple_Themable.html create mode 100644 js2/mwEmbed/example_usage/Sequence_Editor.html create mode 100644 js2/mwEmbed/example_usage/media/sample_smil.xml diff --git a/js2/mwEmbed/example_usage/Add_Media_Wizard.html b/js2/mwEmbed/example_usage/Add_Media_Wizard.html new file mode 100644 index 0000000000..898c786bdd --- /dev/null +++ b/js2/mwEmbed/example_usage/Add_Media_Wizard.html @@ -0,0 +1,50 @@ + + + + sample mv embed + + + + + +

Sample Add Media Wizard

+ +Add Media
+note only commons is enabled by default. For more options see source code.

+ + + + + +
Asset OutputHtml Output:
+ + + diff --git a/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html b/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html new file mode 100644 index 0000000000..4eb0dd0ff8 --- /dev/null +++ b/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html @@ -0,0 +1,92 @@ + + + + Firefogg - Make Ogg Video in your Browser + + + + + + +
+

Make Ogg Video

+
+
+
Loading firefogg...
+
+ +
+
Built using firefogg, MwEmbed and jquery.ui. Supports + custom themes via the ThemeRoller Dev Tool + +
+ + diff --git a/js2/mwEmbed/example_usage/Player_RelatedVideos.html b/js2/mwEmbed/example_usage/Player_RelatedVideos.html new file mode 100644 index 0000000000..f36522512e --- /dev/null +++ b/js2/mwEmbed/example_usage/Player_RelatedVideos.html @@ -0,0 +1,29 @@ + + + + Simple Video Tag Usage + + + +

Simple Video Relational Audio and Video the Commons

+This Example search primitive video in the Wikimedia Commons + +
+
+ + + + +
+ Sample Relational Video And Audio
+
The Example Code ::: 
+ <video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" + poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" + src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video> +
+
+













  + + + diff --git a/js2/mwEmbed/example_usage/Player_Simple_Themable.html b/js2/mwEmbed/example_usage/Player_Simple_Themable.html new file mode 100644 index 0000000000..97950467c6 --- /dev/null +++ b/js2/mwEmbed/example_usage/Player_Simple_Themable.html @@ -0,0 +1,23 @@ + + + + Sample Themed Player + + + + +

Sample Simple Themable Player:

+To play with dynamic Themes install Themeroller

+

+ +
+
+Source Code used:
+ +
+ + + diff --git a/js2/mwEmbed/example_usage/Sequence_Editor.html b/js2/mwEmbed/example_usage/Sequence_Editor.html new file mode 100644 index 0000000000..1b5eb7c7cb --- /dev/null +++ b/js2/mwEmbed/example_usage/Sequence_Editor.html @@ -0,0 +1,40 @@ + + + + SMIL Sequence Editor example + + + + + + +

Simple SMIL example

+
+ Loading sequence editor ... +
+ + + + diff --git a/js2/mwEmbed/example_usage/media/sample_smil.xml b/js2/mwEmbed/example_usage/media/sample_smil.xml new file mode 100644 index 0000000000..e141b36334 --- /dev/null +++ b/js2/mwEmbed/example_usage/media/sample_smil.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 3384abbe12..cb822da6b4 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -73,9 +73,12 @@ var default_remote_search_options = { 'p_seq':null, 'cFileNS':'File', //What is the canonical namespace prefix for images //@@todo (should get that from the api or in-page vars) - - 'enable_upload_tab':true, // if we want to enable an uploads tab: - 'upload_api_target' : 'http://localhost/wiki_trunk/api.php' // can be local or the url of the upload api. + + 'upload_api_target': 'http://localhost/wiki_trunk/api.php', // can be local or the url of the upload api. + + 'enabled_cps':'all', //can be keyword 'all' or an array of enabled content provider keys + + 'disp_item':'wiki_commons' //sets the default display item: } if(typeof wgServer == 'undefined') @@ -101,12 +104,7 @@ remoteSearchDriver.prototype = { 'advanced_search':{ 'title': 'Advanced Options' } - }, - /* - * sets the default display item: - * can be any content_providers key or 'all' - */ - disp_item : 'wiki_commons', + }, /** the default content providers list. * * (should be note that special tabs like "upload" and "combined" don't go into the content proviers list: @@ -203,6 +201,12 @@ remoteSearchDriver.prototype = { 'remote_embed_ext': false, //if running the remoteEmbed extension no need to copy local //syntax will be [remoteEmbed:roe_url link title] 'tab_img':true + }, + //special cp "upload" + 'upload':{ + 'enabled':1, + 'checked':1, + 'title' :'Upload' } }, //define the licenses @@ -310,7 +314,7 @@ remoteSearchDriver.prototype = { }; }, //some default layout values: - thumb_width : 80, + thumb_width : 80, image_edit_width : 400, video_edit_width : 400, insert_text_pos : 0, //insert at the start (will be overwritten by the user cursor pos) @@ -320,42 +324,29 @@ remoteSearchDriver.prototype = { cEdit : null, dmodalCss : {}, - init: function( iObj ){ + init: function( options ){ var _this = this; js_log('remoteSearchDriver:init'); - for( var i in default_remote_search_options ) { - if( iObj[i]){ - this[ i ] = iObj[i]; - }else{ - this[ i ] = default_remote_search_options[i]; - } - } + + //merge in the options: + //@@todo for cleaner config we should set _this.opt to the provided options) + $j.extend( _this, default_remote_search_options, options); + //update the base text: if(_this.target_textbox) _this.getTexboxSelection(); - //set up the content provider config: - if( this.cpconfig ){ - for(var cpc in cpconfig){ - for(var cinx in this.cpconfig[cpc]){ - if( this.content_providers[cpc] ) - this.content_providers[ cpc ][ cinx ] = this.cpconfig[cpc][ cinx]; - } - } - } - - //make sure the selected cp has an api to query against (if its a content_provider - if( this.content_providers[ this.disp_item ] && - !this.content_providers[ this.disp_item ].api_url ){ - for(var inx in this.content_providers){ - if( this.content_providers[ inx ].api_url ){ - this.disp_item = inx; - break; + //modify the content provider config based on options: + if(_this.enabled_cps != 'all'){ + for(var i in this.content_providers){ + if( $j.inArray(i, _this.enabled_cps)!= -1){ + this.content_providers[i].enabled = true; + }else{ + this.content_providers[i].enabled = false; } } } - //set up the default model config: this.dmodalCss = { 'width':'auto', @@ -602,13 +593,13 @@ remoteSearchDriver.prototype = { if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){ mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){ - //get extened info about the file + //get extends info about the file var cp = _this.content_providers['this_wiki']; //check for "this_wiki" enabled - if(!cp.enabled){ + /*if(!cp.enabled){ $j('#tab-upload').html('error this_wiki not enabled (can\'t get uploaded file info)'); return false; - } + }*/ //load this_wiki search system to grab the rObj _this.loadSearchLib(cp, function(){ @@ -672,15 +663,14 @@ remoteSearchDriver.prototype = { js_log("f:runSearch::" + this.disp_item); //draw_direct_flag var draw_direct_flag = true; - if( !this.content_providers[this.disp_item] ){ - //check if its the special upload tab case: - if( this.disp_item == 'upload'){ - this.doUploadInteface(); - }else{ - js_log("can't run search for:" + this.disp_item); - } - return false; + + //check if its the special upload tab case: + if( this.disp_item == 'upload'){ + this.doUploadInteface(); + return true; } + //else do runSearch + cp = this.content_providers[this.disp_item]; //check if we need to update: @@ -956,7 +946,8 @@ remoteSearchDriver.prototype = { p = rid.split('__'); var cp_id = p[0]; var rid = p[1]; - + + //Set the upload helper cp_id (to render recent uploads by this user) if(cp_id == 'upload') cp_id = 'this_wiki'; diff --git a/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js b/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js index 90d73e2316..43496f31c7 100644 --- a/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js @@ -17,7 +17,9 @@ seqRemoteSearchDriver.prototype = { 'local_wiki_api_url': this_seq.getLocalApiUrl(), 'instance_name' : this_seq.instance_name + '.mySearch', 'default_query' : this.pSeq.plObj.title - } + } + if(typeof this_seq.amw_conf != 'undefined') + $j.extend(iObj, this_seq.amw_conf); //inherit the remoteSearchDriver properties:n var tmpRSD = new remoteSearchDriver( iObj ); for(var i in tmpRSD){ diff --git a/js2/mwEmbed/libSequencer/mvSequencer.js b/js2/mwEmbed/libSequencer/mvSequencer.js index 2eecbe2e4e..583c1df5ae 100644 --- a/js2/mwEmbed/libSequencer/mvSequencer.js +++ b/js2/mwEmbed/libSequencer/mvSequencer.js @@ -97,7 +97,9 @@ var sequencerDefaultValues = { sequenceEditToken:null, //the time the sequence was last touched (grabbed at time of startup) sequenceTouchedTime:null, - + + //the default config for the add media wizard + amw_conf: {}, //Msg are all the language specific values ... diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index cc9320c8f0..ddeffd0eb0 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -23,21 +23,19 @@ if( MV_EMBED_VERSION ){ var MV_EMBED_VERSION = '1.0r19'; /* - * Configuration variables (can be set from some preceding script). - * Set up mwConfig global, override any of the defaultMwConfig values: - * @@ more config values on the way ;) + * Configuration variables should be set by extending mwConfigOptions + * here is the default config: */ -var defaultMwConfig = { +var mwConfig = { 'skin_name': 'mvpcf', 'jui_skin': 'redmond', 'video_size':'400x300' } -if( !mwConfig ) - var mwConfig = {}; +if( !mwConfigOptions ) + var mwConfigOptions = {}; // Install the default config values for anything not set in mwConfig -checkDefaultMwConfig(); // Whether or not to load java from an iframe. // Note: this is necessary for remote embedding because of Java's security model) @@ -85,19 +83,11 @@ parseUri.options = { } }; - - // Get the mv_embed location if it has not been set if( !mv_embed_path ) { var mv_embed_path = getMvEmbedPath(); } -// Set up the skin path -var mv_jquery_skin_path = mv_embed_path + 'jquery/jquery.ui/themes/' +mwConfig['jui_skin'] + '/'; -var mv_skin_img_path = mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/images/'; -var mv_default_thumb_url = mv_skin_img_path + 'vid_default_thumb.jpg'; - - // Init the global message table if it has not been initialised already if( !gMsg ) { var gMsg = {}; @@ -556,21 +546,35 @@ var mvJsLoader = { * checks for jQuery and adds the $j noConflict var */ jQueryCheck: function( callback ) { - // Skip stuff if $j is already loaded + // Skip stuff if $j is already loaded: if( _global['$j'] && callback ) - callback(); + callback(); var _this = this; // Load jQuery _this.doLoad([ 'window.jQuery' ], function() { _global['$j'] = jQuery.noConflict(); + + //setup our global settings using the (jQuery helper) + $j.extend( mwConfig, mwConfigOptions); + + // Set up the skin path + _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' +mwConfig['jui_skin'] + '/'; + _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/images/'; + _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg'; + + // Make sure the skin/style sheets are always available: + loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); + loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/styles.css' ); + // Set up AJAX to not send dynamic URLs for loading scripts (we control that with // the scriptLoader) $j.ajaxSetup({ cache: true }); - js_log( 'jquery loaded' ); + + js_log( 'jQuery loaded into $j' ); // Set up mvEmbed jQuery bindings: mv_jqueryBindings(); // Run the callback @@ -581,15 +585,11 @@ var mvJsLoader = { }, embedVideoCheck:function( callback ) { var _this = this; - js_log( 'embedVideoCheck:' ); - // Set videonojs to loading - // Issue a style sheet request to get both mv_embed and jQuery styles: - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); - loadExternalCss( mv_embed_path + 'skins/'+mwConfig['skin_name'] + '/styles.css' ); - + js_log( 'embedVideoCheck:' ); // Make sure we have jQuery _this.jQueryCheck( function() { $j('.videonojs').html( gM('mwe-loading_txt') ); + //Set up the embed video player class request: var depReq = [ [ '$j.ui', @@ -604,7 +604,7 @@ var mvJsLoader = { // Add PNG fix if needed: if( $j.browser.msie || $j.browser.version < 7 ) depReq[0].push( '$j.fn.pngFix' ); - + _this.doLoadDepMode( depReq, function() { embedTypes.init(); callback(); @@ -685,11 +685,7 @@ function setSwappableToLoading( e ) { //} } //js2AddOnloadHook: ensure jQuery and the DOM are ready -function js2AddOnloadHook( func ) { - // Make sure the skin/style sheets are always available: - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); - loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/styles.css' ); - +function js2AddOnloadHook( func ) { // If we have already run the DOM-ready function, just run the function directly: if( mvJsLoader.doneReadyEvents ) { // Make sure jQuery is there: @@ -1463,14 +1459,6 @@ function js_log( string ) { return false; } -function checkDefaultMwConfig() { - for( var i in defaultMwConfig ) { - if( typeof( mwConfig[i] ) == 'undefined' ) { - mwConfig[i] = defaultMwConfig[i]; - } - } -} - function js_error( string ) { alert( string ); return false; -- 2.20.1