* usability compatibility updates
authorMichael Dale <dale@users.mediawiki.org>
Mon, 5 Oct 2009 23:03:20 +0000 (23:03 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Mon, 5 Oct 2009 23:03:20 +0000 (23:03 +0000)
* language Test updates for multiple arguments
* make advanced firefogg display to include firefogg-logo

js2/editPage.js
js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html
js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
js2/mwEmbed/libAddMedia/mvFirefogg.js
js2/mwEmbed/mv_embed.js
js2/mwEmbed/skins/ctrlBuilder.js
js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png [new file with mode: 0644]
js2/mwEmbed/tests/testLang.html

index b3e3995..77716df 100644 (file)
@@ -19,17 +19,12 @@ var defaultAddMediaConfig = {
                // The local wiki API URL:
                'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
 };
-js2AddOnloadHook( function() {
-       mwEditPageHelper.init(
-               $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig )
-       );
-});
 var mwEditPageHelper = {
        init: function( amwConf ) {
                var _this = this;               
                // kind of tricky, it would be nice to use run on ready "loader" call here
                if( typeof $j.wikiEditor != 'undefined' ) {
-                       setTimeout( function() {
+                       setTimeout( function() {                                
                                $j( '.wikiEditor-ui [rel=file]' ).unbind().addMediaWiz(
                                        amwConf
                                );
@@ -49,3 +44,9 @@ var mwEditPageHelper = {
                );*/
        }
 }
+
+js2AddOnloadHook( function() {
+       mwEditPageHelper.init(
+               $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig )
+       );
+});
index d40c9cb..1451fff 100644 (file)
@@ -77,7 +77,11 @@ mwAddOnloadHook(function(){
 </script>
 </head><body>
 <div id="main">
-  <h1>Make Ogg Video</h1>
+  <h1>
+<a href="http://firefogg.org/index.html">
+       <img alt="Firefogg" src="../skins/mvpcf/images/firefogg_logo.png"/>
+</a><br>
+Make Ogg Video</h1>
 <br>   
        <br>
        <div style="margin-right:auto;margin-left:auto;width:500px;" id="loadFogg">Loading firefogg<blink>...</blink></div>     
index 1955f0f..fe22e5a 100644 (file)
@@ -683,7 +683,7 @@ mvBaseUploadInterface.prototype = {
                          if( event.button==0 && _this.action_done === false){
                                return _this.cancel_action();
                          }else{
-                                //click on button (dont do close action);
+                                //click on button (don't do close action);
                                 return true;
                          }
                  },
@@ -718,11 +718,10 @@ mvBaseUploadInterface.prototype = {
                //confirm:
                if( confirm( gM('mwe-cancel-confim') )){
                        //@@todo (cancel the encode / upload)
-                       $j(this).empty().dialog('close');
-                       return false;
-               }else{
-                       return true;
+                       $j(this).empty().dialog('close');               
                }
+               //dont' follow the link; 
+               return false;
        }
 };
 
index 21421b0..db44289 100644 (file)
@@ -826,12 +826,11 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface
                    }else{
                        this.action_done = true;
                        this.fogg.cancel();
-                       $j(dlElm).empty().dialog('close');
-                       return false;
+                       $j(dlElm).empty().dialog('close');                     
                    }
-               } else{
-                       return false;
                }
+               //dont' follow the link:
+               return false;
        },
        /**
        * procPageResponse should be faded out in favor of the upload api soon..
index 1942b64..5cf4a4a 100644 (file)
@@ -139,7 +139,7 @@ if( !mv_embed_path ) {
         *
         * it take a msg key and array of replacement values of form
         * $1, $2 and does relevant msgkey transformation returning 
-        * the usser msg. 
+        * the user msg. 
         *
         * @param string key The msg key as set by loadGm
         * @param [mixed] args  An array of replacement strings
@@ -152,7 +152,7 @@ if( !mv_embed_path ) {
                //swap in the arg values
                var ms = $.lang.gMsgSwap( key, args);           
                //a quick check to see if we need to send the msg via the 'parser'
-               //(we can add more detailed check once we suport more wiki syntax)
+               //(we can add more detailed check once we support more wiki syntax)
                if(ms.indexOf('{{')==-1)
                        return ms;
                                        
@@ -174,13 +174,13 @@ if( !mv_embed_path ) {
                if(! gMsg[ key ])
                        return '&lt;' + key + '&gt;';// Missing key placeholder
                //get the messege string:
-               ms = gMsg[ key ];
+               var ms = gMsg[ key ];
                
                //replace values 
                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 );
+                               var rep = new RegExp('\\$'+ ( parseInt(v) + 1 ), 'g');
                                ms = ms.replace( rep, args[v] );
                        }
                } else if( typeof args =='string' || typeof args =='number' ) {
@@ -237,20 +237,23 @@ if( !mv_embed_path ) {
                /**
                 * Maps a given rule Index to template params:
                 * 
+                * if index is out of range return last param
                 * @param 
                 */ 
-               function getTempParamFromRuleInx( ruleInx ){
-                       //var naturalOrder = ['zero', 'one', 'two', 'few', 'many', 'other'];                    
-                       //js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length );            
+               function getTempParamFromRuleInx(tObj, ruleInx ){                                       
+                       //js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length );
+                       if( ruleInx     >= tObj.param.length )
+                               return  tObj.param[  tObj.param.length -1 ];
+                       //else return the requested index:
                        return tObj.param[ ruleInx ];
                }                                               
                var rCount=0
-               //run the acutal rule lookup:           
+               //run the actual rule lookup:           
                for(var ruleInx in rs){
                        cRule = rs[ruleInx];                    
                        if( matchRuleTest( cRule, tObj.arg ) ){
                                js_log("matched rule: " + ruleInx );                            
-                               return getTempParamFromRuleInx( rCount );                                       
+                               return getTempParamFromRuleInx(tObj, rCount );                                  
                        }
                        rCount ++;
                }                       
@@ -539,6 +542,10 @@ if( !mv_embed_path ) {
 var loadGM = $mw.lang.loadGM;
 var gM = $mw.lang.gM;
 
+//if some no-js2 script defined and loaded gMsg in global space: 
+if( _global['gMsg'] ){
+       loadGM( _global['gMsg'] );
+}
 
 // All default messages in [English] should be overwritten by the CMS language message system.
 $mw.lang.loadGM({
@@ -718,7 +725,7 @@ var mvJsLoader = {
        // Base lib flags
        onReadyEvents: new Array(),
        doneReadyEvents: false,
-       jQueryCheckFlag: false,
+       jQuerySetupFlag: false,
 
        // To keep consistency across threads
        ptime: 0,
@@ -743,7 +750,7 @@ var mvJsLoader = {
                                }
                        }
                        if( all_libs_loaded ) {
-                               js_log( 'All libraries already loaded, skipping load request' );
+                               //js_log( 'Libraries ( ' + loadLibs  +  ') already loaded... skipping load request' );
                                callback();
                                return;
                        }
@@ -892,6 +899,7 @@ var mvJsLoader = {
         * checks for jQuery and adds the $j noConflict var
         */
        jQueryCheck: function( callback ) {
+               //js_log( 'jQueryCheck::' );
                // Skip stuff if $j is already loaded:
                if( _global['$j'] && callback )
                        callback();                                     
@@ -903,7 +911,9 @@ var mvJsLoader = {
                        //only do the $j setup once: 
                        if(!_global['$j']){
                                _global['$j'] = jQuery.noConflict();
-                               
+                       }
+                       if( _this.jQuerySetupFlag == false){
+                               js_log('setup mv_embed jQuery bindings');
                                //setup our global settings using the (jQuery helper) 
                                mwConfig = $j.extend( mwDefaultConfig, mwConfig);                                                               
                                
@@ -928,6 +938,7 @@ var mvJsLoader = {
                                js_log( 'jQuery loaded into $j' );
                                // Set up mvEmbed jQuery bindings and config based dependencies
                                mv_jqueryBindings();
+                               _this.jQuerySetupFlag = true;
                        }
                        // Run the callback
                        if( callback ) {
@@ -937,7 +948,7 @@ var mvJsLoader = {
        },
        embedVideoCheck:function( callback ) {
                var _this = this;
-               js_log( 'embedVideoCheck:' );           
+               js_log( 'embedVideoCheck:' );                           
                // Make sure we have jQuery
                _this.jQueryCheck( function() {
                        //set class videonojs to hidden
@@ -976,14 +987,10 @@ var mvJsLoader = {
        // unless js2AddOnloadHook was used or there is video on the page.
        runQueuedFunctions: function() {
                var _this = this;
-               this.doneReadyEvents = true;
-               if( this.jQueryCheckFlag ) {
-                       this.jQueryCheck( function() {
-                               _this.runReadyEvents();
-                       });
-               } else {
-                       this.runReadyEvents();
-               }
+               this.doneReadyEvents = true;            
+               this.jQueryCheck( function() {
+                       _this.runReadyEvents();
+               });
        },
        runReadyEvents: function() {
                js_log( "runReadyEvents" );
@@ -1050,8 +1057,6 @@ function js2AddOnloadHook( func ) {
                        func();
                });
        } else {
-               // If we are using js2AddOnloadHook we need to get jQuery into place (if it's not already included)
-               mvJsLoader.jQueryCheckFlag = true;
                mvJsLoader.addLoadEvent( func );
        }
 }
index f136982..77cd0da 100644 (file)
@@ -1,6 +1,9 @@
 //set the dismissNativeWarn flag:
 _global['dismissNativeWarn'] = false;
 
+/**
+* Msg text is inhereited from embedVideo (we should move it here (although can't load ctrlBuilder without parent EmbedVideo obj)
+/
 
 /** 
 * base ctrlBuilder object
diff --git a/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png b/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png
new file mode 100644 (file)
index 0000000..de50deb
Binary files /dev/null and b/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png differ
index 8b13283..1049c71 100644 (file)
@@ -12,50 +12,58 @@ td{
        var langKey = 'en';
 js2AddOnloadHook( function(){
                //build table output: 
-               var o = '<table>';
-               var msgTestSet = [ 'test_plural_msg', 'undelete_short', 'category-subcat-count' ];
-               var testNumberSet = [ 0, 1, 2, 5, 21, 30 ];                     
+               var o = '<table>';              
+               var msgTestSet = { 
+                       'test_plural_msg':[ 0, 1, 2, 5, 21, 30 ], 
+                       'undelete_short': [ 0, 1, 2, 5, 21, 30 ], 
+                       //category-subcat-count' has two params:
+                       'category-subcat-count' : [ 
+                               [0,10], 
+                               [1,2], 
+                               [3,30] ]
+                       };
+                                       
                var passTest=0;
                var failTest=0;
                var testCount=0;        
                //now for each langage msg: 
-               $j.each(msgTestSet, function(inx, mKey){
+               $j.each(msgTestSet, function(mKey, mTestSet){
                        //output table names:
                        o+='<tr>'+
                                        '<td>$1:</td>'+
-                                       '<td>Msg key</td>'+
-                                       '<td>Msg text</td>'+
-                                       '<td>Msg Transform JS</td>'+
-                                       '<td>Msg Transform Mw</td>'+
+                                       '<td width="14%">Msg key</td>'+
+                                       '<td width="34%">Msg text</td>'+
+                                       '<td width="24%">Msg Transform JS</td>'+
+                                       '<td width="24%">Msg Transform Mw</td>'+
                                '</tr>';
                
                        //for each number value
-                       for(var i in testNumberSet){
-                               var numVal = testNumberSet[i];                                                                          
+                       for(var i in mTestSet){
+                               var numVal = mTestSet[i];                                               
+                               var numKey = (typeof numVal== 'object')? numVal.join( '_' ) : numVal;                                                                                   
                                o+='<tr>'+
                                                '<td>' + numVal + '</td>' + 
                                                '<td>' + mKey + '</td>' + 
                                                '<td>' + $mw.lang.gMsgNoTrans( mKey ) + '</td>' + 
-                                               '<td id="' + mKey + '_' + numVal + '_js">' + $mw.lang.gM( mKey, numVal ) + '</td>';
+                                               '<td id="' + mKey + '_' + numKey + '_js">' + $mw.lang.gM( mKey, numVal ) + '</td>';
                                //show mw col:                                          
                                if( mKey.substr(0, 5) == 'test_' ){
                                        o+='<td> (test msg) </td>';
                                }else{  
-                                       o+='<td id="' + mKey + '_' + numVal + '">loading<blink>...</blink></td>';                                       
+                                       o+='<td id="' + mKey + '_' + numKey + '">loading<blink>...</blink></td>';                                       
                                        
                                        //get transform from mw (& compare and highlight)
-                                       function doPopWmMsg(mKey, numVal){ 
+                                       function doPopWmMsg(mKey, numVal, numKey){ 
                                                testCount++;
-                                               $j('#score_card').html('Running Tests <span id="perc_done">0</sapn>% done');
+                                               $j('#score_card').html('Running Tests <span id="perc_done">0</sapn>% done');                                                                                            
                                                do_api_req({
                                                        'data': {
                                                                'action':'parse',
                                                                'text': $mw.lang.gMsgSwap( mKey, numVal)
                                                        },
                                                        'url' : '../../../api.php'                                      
-                                               }, function( data ) {
-                                                       js_log("got data::" + data.parse.text['*']);
-                                                       var t = '#'+ mKey + '_'+ numVal; 
+                                               }, function( data ) {                                                   
+                                                       var t = '#'+ mKey + '_'+ numKey; 
                                                        if(data.parse && data.parse.text && data.parse.text['*']){
                                                                $j(t).html( data.parse.text['*'] );
                                                                //just get the part in the <p> to compare with js version
@@ -78,7 +86,7 @@ js2AddOnloadHook( function(){
                                                });
                                        };
                                        //pop off an anonymous function call: 
-                                       doPopWmMsg(mKey, numVal);
+                                       doPopWmMsg(mKey, numVal, numKey);
                                } 
                                o+='</tr>';                                                                             
                        }