* msg updates
authorMichael Dale <dale@users.mediawiki.org>
Sat, 15 Aug 2009 23:27:54 +0000 (23:27 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Sat, 15 Aug 2009 23:27:54 +0000 (23:27 +0000)
* firefogg updates for add-media-wizard usage
* more support for simpleUploadFrom usage in add-media-wizard
* some header updates

js2/editPage.js
js2/mwApiProxy.html [new file with mode: 0644]
js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
js2/mwEmbed/libAddMedia/mvFirefogg.js
js2/mwEmbed/libAddMedia/remoteSearchDriver.js
js2/mwEmbed/libAddMedia/simpleUploadForm.js
js2/mwEmbed/libClipEdit/colorpicker/js/colorpicker.js
js2/mwEmbed/libSequencer/mvPlayList.js
js2/mwEmbed/mv_embed.js
js2/mwEmbed/mwHostProxy.html [new file with mode: 0644]
js2/mwEmbed/php/languages/mwEmbed.i18n.php

index d9e90cb..e7055ba 100644 (file)
@@ -32,8 +32,8 @@ var mwEditPageHelper = {
                );              
                                
                //add to new toolbar (need to use api) 
-               //$j('[rel=insert] .tool-file').addMediaWiz( 
-               //              mwAddMediaConfig 
-               //);                            
+               /*$j('[rel=insert] tool-file').addMediaWiz( 
+                               mwAddMediaConfig 
+               );*/                            
        }
 }
diff --git a/js2/mwApiProxy.html b/js2/mwApiProxy.html
new file mode 100644 (file)
index 0000000..7d66d13
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+       <title>Javascript Api Proxy</title>
+       <style type="text/css">
+               body{
+                       font-size:80%;
+               }
+               img  {
+                       border:medium none;
+               }
+       </style>                        
+       <script type="text/javascript">
+               var domainList = [
+                       '127.0.0.1'
+               ];
+       </script> 
+</head>
+<body>
+<h3> This file proxies api and html output for source domains: </h3>
+<div id="domainList"></div>
+       <script type="text/javascript">
+               var o='';
+               for( var i in domainList){
+                       o+='<br><i>'+ domainList[i] + '</i>';
+               }
+       </script>
+</body>
+</html>
+
index 9a8681e..69ee3bb 100644 (file)
@@ -31,6 +31,7 @@ loadGM({
        "ignorewarning" : "Ignore warning and save file anyway",
        "file-thumbnail-no" :  "The filename begins with <b><tt>$1</tt></b>",
        "go-to-resource" : "Go to Resource Page",
+       "upload-misc-error" : "Unknown upload error",
 
        "wgfogg_waring_bad_extension" : "You have selected a file with an unsuported extension (<a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types\">more information</a>).",
        
@@ -696,7 +697,7 @@ mvBaseUploadInterface.prototype = {
           };
           return cancelBtn;
        },      
-       cancel_action:function(dlElm){
+       cancel_action : function( dlElm ){
                //confirm:      
                if( confirm( gM('mv-cancel-confim') )){                 
                        //@@todo (cancel the encode / upload)
index d5c2801..6f142dd 100644 (file)
@@ -25,7 +25,7 @@ var firefogg_install_links =  {
 
 var default_firefogg_options = {
        //what to do when finished uploading
-       'upload_done_action':'redirect',
+       'done_upload_cb':false,
        //if firefoog is enabled
        'fogg_enabled':false,
        //the api url to upload to
@@ -476,7 +476,8 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                                get_mw_token(
                                        'File:'+ _this.formData['wpDestFile'], 
                                        _this.api_url, 
-                                       function( eToken ){                                                                             
+                                       function( eToken ){             
+                                               if(eToken==)                                                            
                                                _this.etoken = eToken;
                                                _this.doChunkWithFormData();
                                        }
@@ -631,9 +632,18 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                                                        buttons[gM('go-to-resource')] =  function(){
                                                                window.location = _this.fogg.resultUrl;
                                                        }
-                                                       var go_to_url_txt = gM('go-to-resource');                          
-                                                  //should have an json result:
-                                                  _this.updateProgressWin( gM('successfulupload'),  gM( 'mv_upload_done', _this.fogg.resultUrl),buttons);      
+                                                       var go_to_url_txt = gM('go-to-resource');                                                                          
+                                                       if( typeof _this.done_upload_cb == 'function' ){
+                                                               //if done action return 'true'
+                                                               if( _this.done_upload_cb() ){                                                                           
+                                                                       //update status
+                                                                       _this.updateProgressWin( gM('successfulupload'),  gM( 'mv_upload_done', _this.fogg.resultUrl),buttons); 
+                                                               }else{
+                                                                       //if done action returns 'false' //close progress window
+                                                                       this.action_done = true;                                                                        
+                                                               $j('#upProgressDialog').dialog('close');        
+                                                               } 
+                                                       }
                                           }else{
                                                   //done state with error? ..not really possible given how firefogg works
                                                   js_log(" upload done, in chunks mode, but no resultUrl!");
@@ -682,14 +692,14 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                _this.updateProgressWin( gM('mv_upload_completed'), result_txt );
                                                                                                
                if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){   
-                       js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.upload_done_action );                                                                              
-                       if( _this.upload_done_action == 'redirect' ){
+                       js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.done_upload_cb );                                                                          
+                       if( _this.done_upload_cb == 'redirect' ){
                                $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + result_txt + '<br>' + form_txt);
                                window.location = wgArticlePath.replace( /\$1/, 'File:' + _this.formData['wpDestFile'] );
                        }else{
                                //check if the add_done_action is a callback:
-                               if( typeof _this.upload_done_action == 'function' )
-                                       _this.upload_done_action();
+                               if( typeof _this.done_upload_cb == 'function' )
+                                       _this.done_upload_cb();
                        }                                                                       
                }else{                                                          
                        //js_log( 'upload page error: did not find: ' +sstring + ' in ' + "\n" + result_page );                                 
index 5da7e34..45329ad 100644 (file)
@@ -577,18 +577,25 @@ remoteSearchDriver.prototype = {
                        $j('#tab-upload').html( gM('rsd_config_error', 'bad_api_url') );
                        return false;
                }
-               //output the form 
-               mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){
-                       //set the form action based on domain: 
-                       if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){
+               //output the form               
+               //set the form action based on domain: 
+               if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){
+                       mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){
                                //deal with the api form upload form directly:
                                $j('#tab-upload').simpleUploadForm({
-                                       "api_target" :  _this.upload_api_target 
+                                       "api_target" :  _this.upload_api_target ,
+                                       "ondone_cb"     : function( resultData ){
+                                               var cat = resultData;
+                                               debugger;                                               
+                                               return false;
+                                       }
                                })
-                       }else{
-                               //setup the proxy  
-                       }
-               });                                                                     
+                       });
+               }else{
+                       //setup the proxy  
+                       js_log('do proxy:: ' + parseUri( _this.upload_api_target ).host);
+                       $j('#tab-upload').html('proxy upload not yet ready');
+               }                                                       
        },
        runSearch: function(){          
                js_log("f:runSearch::" + this.disp_item);
@@ -1352,8 +1359,7 @@ remoteSearchDriver.prototype = {
                mvJsLoader.doLoad([
                        'mvBaseUploadInterface',                
                        '$j.ui.progressbar'     
-               ],function(){    
-                       
+               ],function(){                           
                        //initicate a download similar to url copy:
                        myUp = new mvBaseUploadInterface({
                                'api_url' : _this.local_wiki_api_url,
@@ -1363,7 +1369,9 @@ remoteSearchDriver.prototype = {
                                   //close up the rsd_resource_import
                                   $j('#rsd_resource_import').remove();
                                   //run the parent callback:
-                                  cir_callback(); 
+                                  cir_callback();
+                                  //return false to avoid BaseUploadInterface done actions
+                                  return false;
                                }
                        });
                        //set the edit token if we have it handy
index 7ea8a0d..3094599 100644 (file)
@@ -11,13 +11,15 @@ loadGM({
        "licence_cc-by-sa"              : "Creative Commons Share Alike (3.0)",         
        "upload"                                : "Upload File",
        "destfilename"                  : "Destination filename:",
-       "summary"                               : "Summary"
+       "summary"                               : "Summary",
+       "error_not_loggedin"    : "You don't appear to be logged in or don't have upload privlages."
 });
  
 var default_form_options = {
        'enable_fogg'    : true,
        'licence_options':['cc-by-sa'],
-       'api_target' : false    
+       'api_target' : false,
+       'ondone_cb' : null
 };
 
 (function($) {
@@ -32,55 +34,66 @@ var default_form_options = {
                if(!opt.api_target){
                        $(this.selector).html('Error: Missing api target');
                        return false;
-               }                               
-               
+               }               
                                        
                //@@todo this is just a proof of concept
                //much todo to improved this web form
-               var o = '<div style="margin: 0 auto;">'+
-                       '<form id="suf-upload" enctype="multipart/form-data" action="" method="post">'  +       
-                       '<label for="wpUploadFile">' + gM('select_file') + '</label><br>'+                                                                      
-                       '<input type="file" style="display: inline;" name="wpUploadFile" id="wpUploadFile" size="10"/><br>' +           
-                       '<label for="wpDestFile">' +gM('destfilename') + '</label><br>'+
-                               '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
-                       '<label for="wpUploadDescription">' + gM('summary') + ':</label><br>' +
-                               '<textarea cols="30" rows="3" id="wpUploadDescription" name="wpUploadDescription" tabindex="3"/><br>'+ 
-                               gM('select_ownwork') + '<br>' + 
-                       '<input type="checkbox" id="wpLicence" name="wpLicence" value="cc-by-sa">' + gM('licence_cc-by-sa') + '<br>' +                  
-                                               
-                       '<input type="submit" accesskey="s" value="' + gM('upload') + '" name="wpUploadBtn" id="wpUploadBtn"  tabindex="9"/>' +
-                       //close the form and div  
-                       '</form></div>';        
+               get_mw_token('File:MyRandomFileTokenCheck', opt.api_target, function(eToken){           
+                       debugger;       
+                       if( !eToken || eToken == '+\\' ){
+                               $(this.selector).html( gM('error_not_loggedin') );
+                               return false;
+                       }
                        
-               //set the target with the form output:
-               $(this.selector).html( o );                     
-               //by default dissable: 
-               $j('#wpUploadBtn').attr('disabled', 'disabled');
-               
-               //set up basic binding:
-               $j('#wpLicence').click(function(){
-                       if( $j(this).is(':checked') ){
-                               $j('#wpUploadBtn').removeAttr('disabled');                              
-                       }else{                          
-                               $j('#wpUploadBtn').attr('disabled', 'disabled');
-                       }                       
-               });
+                       var o = '<div style="margin: 0 auto;width:450px;">'+
+                               '<form id="suf-upload" enctype="multipart/form-data" action="" method="post">'  +       
+                               '<label for="wpUploadFile">' + gM('select_file') + '</label><br>'+                                                                      
+                               '<input type="file" style="display: inline;" name="wpUploadFile" id="wpUploadFile" size="10"/><br>' +           
+                               '<label for="wpDestFile">' +gM('destfilename') + '</label><br>'+
+                                       '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
+                               '<label for="wpUploadDescription">' + gM('summary') + ':</label><br>' +
+                                       '<textarea cols="30" rows="3" id="wpUploadDescription" name="wpUploadDescription" tabindex="3"/><br>'+ 
+                                       gM('select_ownwork') + '<br>' + 
+                               '<input type="checkbox" id="wpLicence" name="wpLicence" value="cc-by-sa">' + gM('licence_cc-by-sa') + '<br>' +                  
+                                                       
+                               '<input type="submit" accesskey="s" value="' + gM('upload') + '" name="wpUploadBtn" id="wpUploadBtn"  tabindex="9"/>' +
+                               //close the form and div  
+                               '</form></div>';                
+                               
+                       //set the target with the form output:
+                       $( this.selector ).html( o );                   
+                       //by default dissable: 
+                       $j('#wpUploadBtn').attr('disabled', 'disabled');
                        
-               //set up the binding per the config
-               if( opt.enable_fogg ){                  
-                       $j('#wpUploadFile').firefogg({ 
-                               //an api url (we won't submit directly to action of the form)
-                               'api_url' : opt.api_target,
-                               'form_rewrite': true,   
-                               'target_edit_from' : '#suf-upload',                     
-                               'new_source_cb' : function( orgFilename, oggName ){                                                                                     
-                                               $j('#wpDestFile').val( oggName );
-                                               //@@TODO: 
-                                               //mwUploadHelper.doDestCheck();
-                               }
-                       });             
-               }else{
-                       //simple web form rewrite               
-               }               
+                       //set up basic binding:
+                       $j('#wpLicence').click(function(){
+                               if( $j(this).is(':checked') ){
+                                       $j('#wpUploadBtn').removeAttr('disabled');                              
+                               }else{                          
+                                       $j('#wpUploadBtn').attr('disabled', 'disabled');
+                               }                       
+                       });
+                       
+                       if(typeof opt.ondone_cb == 'undefined')
+                               opt.ondone_cb = false;
+                               
+                       //set up the binding per the config
+                       if( opt.enable_fogg ){
+                               $j('#wpUploadFile').firefogg({ 
+                                       //an api url (we won't submit directly to action of the form)
+                                       'api_url' : opt.api_target,
+                                       'form_rewrite': true,   
+                                       'target_edit_from' : '#suf-upload',                     
+                                       'new_source_cb' : function( orgFilename, oggName ){                                                                                     
+                                                       $j('#wpDestFile').val( oggName );
+                                                       //@@TODO: 
+                                                       //mwUploadHelper.doDestCheck();
+                                       },
+                                       'done_upload_cb' : opt.ondone_cb
+                               });             
+                       }else{
+                               //simple web form rewrite               
+                       }
+               });                     
        }
 })(jQuery);
\ No newline at end of file
index aec4dc8..3d0d259 100644 (file)
@@ -6,7 +6,6 @@
  * Dual licensed under the MIT and GPL licenses
  * 
  */
 (function ($) {
        var ColorPicker = function () {
                var
index 0f80723..f0a7e8a 100644 (file)
@@ -2,10 +2,13 @@
  * the mvPlayList object code 
  * only included if playlist object found
  * 
- * part of mv_embed: 
- * http://metavid.org/wiki/index.php/Mv_embed 
+ * part of mwEmbed media projects see:  
+ * http://www.mediawiki.org/wiki/Media_Projects_Overview
+ * 
+ * @author: Michael Dale  mdale@wikimedia.org
+ * @license GPL2
  */
-var mv_default_playlist_attributes = {
+var mv_default_playlist_attributes = { 
        //playlist attributes :
        "id":null,
        "title":null,
@@ -27,6 +30,7 @@ var MV_ANIMATION_CB_RATE = 33;
 //globals:
 //10 possible colors for clips: (can be in hexadecimal)
 var mv_clip_colors = new Array('aqua', 'blue', 'fuchsia', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red');
+
 //the base url for requesting stream metadata 
 if(typeof wgServer=='undefined'){
        var defaultMetaDataProvider = 'http://metavid.org/overlay/archive_browser/export_cmml?stream_name=';
@@ -1980,8 +1984,9 @@ var mv_smil_ref_supported_attributes = new Array(
                'fill',
                'dur',
                'title',
-               
+               //some custom attributes:
                'uri',                  
+               'durationHint',
                'poster'
 );
 /* extension to mvClip to support smil properties */
@@ -2039,7 +2044,10 @@ mvSMILClip.prototype = {
                }               
                //parse duration / begin times: 
                if( this.dur )
-                       this.dur = smilParseTime( this.dur );                                                                   
+                       this.dur = smilParseTime( this.dur );           
+               //parse the media duration hint ( the source media length) 
+               if( this.durationHint )
+                       this.durationHint = smilParseTime( this.durationHint );                                                         
                
                //conform type to vido/ogg:
                if( this.type == 'application/ogg' )
@@ -2077,7 +2085,7 @@ mvSMILClip.prototype = {
                if( this.dur )
                        return this.dur;                        
                return this.embed.getDuration();                                        
-       },
+       },      
        //gets the duration of the clip subracting transitions
        getSoloDuration:function(){
                var fulldur = this.getDuration();
@@ -2087,6 +2095,13 @@ mvSMILClip.prototype = {
 
                //js_log("getSoloDuration:: td: " + this.getDuration() + ' sd:' + fulldur);
                return fulldur;
+       },
+       //gets the duration of the original media asset (usefull for bounding setting of in-out-points)
+       getSourceDuration:function(){
+               if( this.durationHint )
+                       return this.durationHint;
+               //if we have no source duration just return the media dur: 
+               return this.getDuration();
        }
 }
 /*
index f3b6666..eb167a8 100644 (file)
@@ -232,8 +232,9 @@ lcPaths( 'libTimedText/', [
 
 //depencency mapping for css files for self contained included plugins:
 lcCssPath({
-       '$j.Jcrop'              : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
-       '$j.fn.ColorPicker': 'libClipEdit/colorpicker/css/colorpicker.css'
+       '$j.ui'                         : 'jquery/' + jQueryUiVN + '.custom.css',
+       '$j.Jcrop'                      : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
+       '$j.fn.ColorPicker'     : 'libClipEdit/colorpicker/css/colorpicker.css'
 })
 
 /**
@@ -1191,7 +1192,7 @@ function do_request(req_url, callback){
                //prepend json_ to feed_format if not already requesting json format
                if( req_url.indexOf("feed_format=")!=-1 &&  req_url.indexOf("feed_format=json")==-1)
                        req_url = req_url.replace(/feed_format=/, 'feed_format=json_');                                                                                                 
-               loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1));                    
+               loadExternalJs( req_url + '&cb=mv_jsdata_cb&cb_inx=' + (global_req_cb.length-1));                       
        }
 }
 
@@ -1238,7 +1239,7 @@ function mv_jsdata_cb(response){
        global_req_cb[response['cb_inx']]( response['pay_load'] );
 }
 //load external js via dom injection
-function loadExternalJs( url ){
+function loadExternalJs( url, callback ){
          js_log('load js: '+ url);
        //if(window['$j']) //use jquery call:   
           /*$j.ajax({
@@ -1251,11 +1252,13 @@ function loadExternalJs( url ){
                var e = document.createElement("script");
                e.setAttribute('src', url);
                e.setAttribute('type',"text/javascript");
+               /*if(callback)
+                       e.onload = callback;
+               */
                //e.setAttribute('defer', true);
-               document.getElementsByTagName("head")[0].appendChild(e);
+               document.getElementsByTagName("head")[0].appendChild(e);                
    // }
 }
-
 function styleSheetPresent(url){
        style_elements = document.getElementsByTagName('link');
        if( style_elements.length > 0) {
diff --git a/js2/mwEmbed/mwHostProxy.html b/js2/mwEmbed/mwHostProxy.html
new file mode 100644 (file)
index 0000000..b02dbea
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+       <title></title>                         
+       <script type="text/javascript">
+       /*
+         XDCommsChild - Cross Domain Communication, Child Object.
+       
+          Create this in the child window with the address of the xdomaincomms.html file on the same domain as the parent window
+       */
+       var XDCommsChild = function(xdomaincommsAddress) {
+           this.xdomaincommsAddress = xdomaincommsAddress;
+       
+           this.isIe = isInternetExplorer();
+       
+           if (isIe) {
+               // need hidden frame for communication. IE8 is supposed to support postMessage, but I can't get it to work properly
+               document.writeln("")
+           }
+       
+           this.postBack = function(data) {
+               if (isIe) {
+                   // this method tested against IE6,7 & 8
+                   window.open(this.xdomaincommsAddress + '#data=' + data, 'xdcomms'); // MUST use window.open. frame.src or frame.location both fail
+               } else {
+                   // for everything else - tested against Firefox 3, Chrome, Safari
+                   window.opener.postMessage(data, '*'); // should really restrict the domain data can come from here
+               }
+           }
+       
+           this.postBackAndCloseWindow = function(data){
+               this.postBack(data);
+               setTimeout("window.close()", 200); // need to use a timeout to make sure the javascript in the frame has executed if we are using that communication model
+           }
+       }
+       </script> 
+</head>
+<body>
+<h3> This file should be inclued by external sites that want to be proxied: </h3>
+</body>
+</html>
+
index c009de5..c452374 100644 (file)
@@ -41,6 +41,7 @@ $messages['en'] = array(
        'ignorewarning' => 'Ignore warning and save file anyway',
        'file-thumbnail-no' => 'The filename begins with <b><tt>$1</tt></b>',
        'go-to-resource' => 'Go to Resource Page',
+       'upload-misc-error' => 'Unknown upload error',
        'wgfogg_waring_bad_extension' => 'You have selected a file with an unsuported extension (<a href="http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types">more information</a>).',
        'cancel-button' => 'Cancel',
        'ok-button' => 'OK',