From: Michael Dale Date: Mon, 5 Oct 2009 23:03:20 +0000 (+0000) Subject: * usability compatibility updates X-Git-Tag: 1.31.0-rc.0~39375 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=a61f190ca7d0f7cc460fee2fce03565cea11c1db;p=lhc%2Fweb%2Fwiklou.git * usability compatibility updates * language Test updates for multiple arguments * make advanced firefogg display to include firefogg-logo --- diff --git a/js2/editPage.js b/js2/editPage.js index b3e3995655..77716df4f3 100644 --- a/js2/editPage.js +++ b/js2/editPage.js @@ -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 ) + ); +}); diff --git a/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html b/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html index d40c9cbc9b..1451fff815 100644 --- a/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html +++ b/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html @@ -77,7 +77,11 @@ mwAddOnloadHook(function(){
-

Make Ogg Video

+

+ + Firefogg +
+Make Ogg Video



Loading firefogg...
diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index 1955f0f3f6..fe22e5a69b 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -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; } }; diff --git a/js2/mwEmbed/libAddMedia/mvFirefogg.js b/js2/mwEmbed/libAddMedia/mvFirefogg.js index 21421b02f8..db44289235 100644 --- a/js2/mwEmbed/libAddMedia/mvFirefogg.js +++ b/js2/mwEmbed/libAddMedia/mvFirefogg.js @@ -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.. diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 1942b64821..5cf4a4a3c6 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -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 '<' + key + '>';// 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 ); } } diff --git a/js2/mwEmbed/skins/ctrlBuilder.js b/js2/mwEmbed/skins/ctrlBuilder.js index f1369829b7..77cd0dac70 100644 --- a/js2/mwEmbed/skins/ctrlBuilder.js +++ b/js2/mwEmbed/skins/ctrlBuilder.js @@ -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 index 0000000000..de50debc84 Binary files /dev/null and b/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png differ diff --git a/js2/mwEmbed/tests/testLang.html b/js2/mwEmbed/tests/testLang.html index 8b13283b38..1049c71681 100644 --- a/js2/mwEmbed/tests/testLang.html +++ b/js2/mwEmbed/tests/testLang.html @@ -12,50 +12,58 @@ td{ var langKey = 'en'; js2AddOnloadHook( function(){ //build table output: - var o = ''; - var msgTestSet = [ 'test_plural_msg', 'undelete_short', 'category-subcat-count' ]; - var testNumberSet = [ 0, 1, 2, 5, 21, 30 ]; + var o = '
'; + 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+=''+ ''+ - ''+ - ''+ - ''+ - ''+ + ''+ + ''+ + ''+ + ''+ ''; //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+=''+ '' + '' + '' + - ''; + ''; //show mw col: if( mKey.substr(0, 5) == 'test_' ){ o+=''; }else{ - o+=''; + o+=''; //get transform from mw (& compare and highlight) - function doPopWmMsg(mKey, numVal){ + function doPopWmMsg(mKey, numVal, numKey){ testCount++; - $j('#score_card').html('Running Tests 0% done'); + $j('#score_card').html('Running Tests 0% 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

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+='

'; }
$1:Msg keyMsg textMsg Transform JSMsg Transform MwMsg keyMsg textMsg Transform JSMsg Transform Mw
' + numVal + '' + mKey + '' + $mw.lang.gMsgNoTrans( mKey ) + '' + $mw.lang.gM( mKey, numVal ) + '' + $mw.lang.gM( mKey, numVal ) + ' (test msg) loading...loading...