r57411 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57410‎ | r57411 | r57412 >
Date:23:03, 5 October 2009
Author:dale
Status:deferred
Tags:
Comment:
* usability compatibility updates
* language Test updates for multiple arguments
* make advanced firefogg display to include firefogg-logo
Modified paths:
  • /trunk/phase3/js2/editPage.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/mv_embed.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png (added) (history)
  • /trunk/phase3/js2/mwEmbed/tests/testLang.html (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html
@@ -77,7 +77,11 @@
7878 </script>
7979 </head><body>
8080 <div id="main">
81 - <h1>Make Ogg Video</h1>
 81+ <h1>
 82+<a href="http://firefogg.org/index.html">
 83+ <img alt="Firefogg" src="../skins/mvpcf/images/firefogg_logo.png"/>
 84+</a><br>
 85+Make Ogg Video</h1>
8286 <br>
8387 <br>
8488 <div style="margin-right:auto;margin-left:auto;width:500px;" id="loadFogg">Loading firefogg<blink>...</blink></div>
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js
@@ -826,12 +826,11 @@
827827 }else{
828828 this.action_done = true;
829829 this.fogg.cancel();
830 - $j(dlElm).empty().dialog('close');
831 - return false;
 830+ $j(dlElm).empty().dialog('close');
832831 }
833 - } else{
834 - return false;
835832 }
 833+ //dont' follow the link:
 834+ return false;
836835 },
837836 /**
838837 * procPageResponse should be faded out in favor of the upload api soon..
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -683,7 +683,7 @@
684684 if( event.button==0 && _this.action_done === false){
685685 return _this.cancel_action();
686686 }else{
687 - //click on button (dont do close action);
 687+ //click on button (don't do close action);
688688 return true;
689689 }
690690 },
@@ -718,11 +718,10 @@
719719 //confirm:
720720 if( confirm( gM('mwe-cancel-confim') )){
721721 //@@todo (cancel the encode / upload)
722 - $j(this).empty().dialog('close');
723 - return false;
724 - }else{
725 - return true;
 722+ $j(this).empty().dialog('close');
726723 }
 724+ //dont' follow the link;
 725+ return false;
727726 }
728727 };
729728
Index: trunk/phase3/js2/mwEmbed/tests/testLang.html
@@ -12,50 +12,58 @@
1313 var langKey = 'en';
1414 js2AddOnloadHook( function(){
1515 //build table output:
16 - var o = '<table>';
17 - var msgTestSet = [ 'test_plural_msg', 'undelete_short', 'category-subcat-count' ];
18 - var testNumberSet = [ 0, 1, 2, 5, 21, 30 ];
 16+ var o = '<table>';
 17+ var msgTestSet = {
 18+ 'test_plural_msg':[ 0, 1, 2, 5, 21, 30 ],
 19+ 'undelete_short': [ 0, 1, 2, 5, 21, 30 ],
 20+ //category-subcat-count' has two params:
 21+ 'category-subcat-count' : [
 22+ [0,10],
 23+ [1,2],
 24+ [3,30] ]
 25+ };
 26+
1927 var passTest=0;
2028 var failTest=0;
2129 var testCount=0;
2230 //now for each langage msg:
23 - $j.each(msgTestSet, function(inx, mKey){
 31+ $j.each(msgTestSet, function(mKey, mTestSet){
2432 //output table names:
2533 o+='<tr>'+
2634 '<td>$1:</td>'+
27 - '<td>Msg key</td>'+
28 - '<td>Msg text</td>'+
29 - '<td>Msg Transform JS</td>'+
30 - '<td>Msg Transform Mw</td>'+
 35+ '<td width="14%">Msg key</td>'+
 36+ '<td width="34%">Msg text</td>'+
 37+ '<td width="24%">Msg Transform JS</td>'+
 38+ '<td width="24%">Msg Transform Mw</td>'+
3139 '</tr>';
3240
3341 //for each number value
34 - for(var i in testNumberSet){
35 - var numVal = testNumberSet[i];
 42+ for(var i in mTestSet){
 43+ var numVal = mTestSet[i];
 44+ var numKey = (typeof numVal== 'object')? numVal.join( '_' ) : numVal;
3645 o+='<tr>'+
3746 '<td>' + numVal + '</td>' +
3847 '<td>' + mKey + '</td>' +
3948 '<td>' + $mw.lang.gMsgNoTrans( mKey ) + '</td>' +
40 - '<td id="' + mKey + '_' + numVal + '_js">' + $mw.lang.gM( mKey, numVal ) + '</td>';
 49+ '<td id="' + mKey + '_' + numKey + '_js">' + $mw.lang.gM( mKey, numVal ) + '</td>';
4150 //show mw col:
4251 if( mKey.substr(0, 5) == 'test_' ){
4352 o+='<td> (test msg) </td>';
4453 }else{
45 - o+='<td id="' + mKey + '_' + numVal + '">loading<blink>...</blink></td>';
 54+ o+='<td id="' + mKey + '_' + numKey + '">loading<blink>...</blink></td>';
4655
4756 //get transform from mw (& compare and highlight)
48 - function doPopWmMsg(mKey, numVal){
 57+ function doPopWmMsg(mKey, numVal, numKey){
4958 testCount++;
50 - $j('#score_card').html('Running Tests <span id="perc_done">0</sapn>% done');
 59+ $j('#score_card').html('Running Tests <span id="perc_done">0</sapn>% done');
5160 do_api_req({
5261 'data': {
5362 'action':'parse',
5463 'text': $mw.lang.gMsgSwap( mKey, numVal)
5564 },
5665 'url' : '../../../api.php'
57 - }, function( data ) {
58 - js_log("got data::" + data.parse.text['*']);
59 - var t = '#'+ mKey + '_'+ numVal;
 66+ }, function( data ) {
 67+ var t = '#'+ mKey + '_'+ numKey;
6068 if(data.parse && data.parse.text && data.parse.text['*']){
6169 $j(t).html( data.parse.text['*'] );
6270 //just get the part in the <p> to compare with js version
@@ -78,7 +86,7 @@
7987 });
8088 };
8189 //pop off an anonymous function call:
82 - doPopWmMsg(mKey, numVal);
 90+ doPopWmMsg(mKey, numVal, numKey);
8391 }
8492 o+='</tr>';
8593 }
Index: trunk/phase3/js2/mwEmbed/skins/ctrlBuilder.js
@@ -1,6 +1,9 @@
22 //set the dismissNativeWarn flag:
33 _global['dismissNativeWarn'] = false;
44
 5+/**
 6+* Msg text is inhereited from embedVideo (we should move it here (although can't load ctrlBuilder without parent EmbedVideo obj)
 7+/
58
69 /**
710 * base ctrlBuilder object
Index: trunk/phase3/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/phase3/js2/mwEmbed/skins/mvpcf/images/firefogg_logo.png
___________________________________________________________________
Name: svn:mime-type
811 + application/octet-stream
Index: trunk/phase3/js2/mwEmbed/mv_embed.js
@@ -139,7 +139,7 @@
140140 *
141141 * it take a msg key and array of replacement values of form
142142 * $1, $2 and does relevant msgkey transformation returning
143 - * the usser msg.
 143+ * the user msg.
144144 *
145145 * @param string key The msg key as set by loadGm
146146 * @param [mixed] args An array of replacement strings
@@ -152,7 +152,7 @@
153153 //swap in the arg values
154154 var ms = $.lang.gMsgSwap( key, args);
155155 //a quick check to see if we need to send the msg via the 'parser'
156 - //(we can add more detailed check once we suport more wiki syntax)
 156+ //(we can add more detailed check once we support more wiki syntax)
157157 if(ms.indexOf('{{')==-1)
158158 return ms;
159159
@@ -174,13 +174,13 @@
175175 if(! gMsg[ key ])
176176 return '&lt;' + key + '&gt;';// Missing key placeholder
177177 //get the messege string:
178 - ms = gMsg[ key ];
 178+ var ms = gMsg[ key ];
179179
180180 //replace values
181181 if( typeof args == 'object' || typeof args == 'array' ) {
182182 for( var v in args ) {
183183 // Message test replace arguments start at 1 instead of zero:
184 - var rep = '\$'+ ( parseInt(v) + 1 );
 184+ var rep = new RegExp('\\$'+ ( parseInt(v) + 1 ), 'g');
185185 ms = ms.replace( rep, args[v] );
186186 }
187187 } else if( typeof args =='string' || typeof args =='number' ) {
@@ -237,20 +237,23 @@
238238 /**
239239 * Maps a given rule Index to template params:
240240 *
 241+ * if index is out of range return last param
241242 * @param
242243 */
243 - function getTempParamFromRuleInx( ruleInx ){
244 - //var naturalOrder = ['zero', 'one', 'two', 'few', 'many', 'other'];
245 - //js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length );
 244+ function getTempParamFromRuleInx(tObj, ruleInx ){
 245+ //js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length );
 246+ if( ruleInx >= tObj.param.length )
 247+ return tObj.param[ tObj.param.length -1 ];
 248+ //else return the requested index:
246249 return tObj.param[ ruleInx ];
247250 }
248251 var rCount=0
249 - //run the acutal rule lookup:
 252+ //run the actual rule lookup:
250253 for(var ruleInx in rs){
251254 cRule = rs[ruleInx];
252255 if( matchRuleTest( cRule, tObj.arg ) ){
253256 js_log("matched rule: " + ruleInx );
254 - return getTempParamFromRuleInx( rCount );
 257+ return getTempParamFromRuleInx(tObj, rCount );
255258 }
256259 rCount ++;
257260 }
@@ -539,6 +542,10 @@
540543 var loadGM = $mw.lang.loadGM;
541544 var gM = $mw.lang.gM;
542545
 546+//if some no-js2 script defined and loaded gMsg in global space:
 547+if( _global['gMsg'] ){
 548+ loadGM( _global['gMsg'] );
 549+}
543550
544551 // All default messages in [English] should be overwritten by the CMS language message system.
545552 $mw.lang.loadGM({
@@ -718,7 +725,7 @@
719726 // Base lib flags
720727 onReadyEvents: new Array(),
721728 doneReadyEvents: false,
722 - jQueryCheckFlag: false,
 729+ jQuerySetupFlag: false,
723730
724731 // To keep consistency across threads
725732 ptime: 0,
@@ -743,7 +750,7 @@
744751 }
745752 }
746753 if( all_libs_loaded ) {
747 - js_log( 'All libraries already loaded, skipping load request' );
 754+ //js_log( 'Libraries ( ' + loadLibs + ') already loaded... skipping load request' );
748755 callback();
749756 return;
750757 }
@@ -892,6 +899,7 @@
893900 * checks for jQuery and adds the $j noConflict var
894901 */
895902 jQueryCheck: function( callback ) {
 903+ //js_log( 'jQueryCheck::' );
896904 // Skip stuff if $j is already loaded:
897905 if( _global['$j'] && callback )
898906 callback();
@@ -903,7 +911,9 @@
904912 //only do the $j setup once:
905913 if(!_global['$j']){
906914 _global['$j'] = jQuery.noConflict();
907 -
 915+ }
 916+ if( _this.jQuerySetupFlag == false){
 917+ js_log('setup mv_embed jQuery bindings');
908918 //setup our global settings using the (jQuery helper)
909919 mwConfig = $j.extend( mwDefaultConfig, mwConfig);
910920
@@ -928,6 +938,7 @@
929939 js_log( 'jQuery loaded into $j' );
930940 // Set up mvEmbed jQuery bindings and config based dependencies
931941 mv_jqueryBindings();
 942+ _this.jQuerySetupFlag = true;
932943 }
933944 // Run the callback
934945 if( callback ) {
@@ -937,7 +948,7 @@
938949 },
939950 embedVideoCheck:function( callback ) {
940951 var _this = this;
941 - js_log( 'embedVideoCheck:' );
 952+ js_log( 'embedVideoCheck:' );
942953 // Make sure we have jQuery
943954 _this.jQueryCheck( function() {
944955 //set class videonojs to hidden
@@ -976,14 +987,10 @@
977988 // unless js2AddOnloadHook was used or there is video on the page.
978989 runQueuedFunctions: function() {
979990 var _this = this;
980 - this.doneReadyEvents = true;
981 - if( this.jQueryCheckFlag ) {
982 - this.jQueryCheck( function() {
983 - _this.runReadyEvents();
984 - });
985 - } else {
986 - this.runReadyEvents();
987 - }
 991+ this.doneReadyEvents = true;
 992+ this.jQueryCheck( function() {
 993+ _this.runReadyEvents();
 994+ });
988995 },
989996 runReadyEvents: function() {
990997 js_log( "runReadyEvents" );
@@ -1050,8 +1057,6 @@
10511058 func();
10521059 });
10531060 } else {
1054 - // If we are using js2AddOnloadHook we need to get jQuery into place (if it's not already included)
1055 - mvJsLoader.jQueryCheckFlag = true;
10561061 mvJsLoader.addLoadEvent( func );
10571062 }
10581063 }
Index: trunk/phase3/js2/editPage.js
@@ -19,17 +19,12 @@
2020 // The local wiki API URL:
2121 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
2222 };
23 -js2AddOnloadHook( function() {
24 - mwEditPageHelper.init(
25 - $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig )
26 - );
27 -});
2823 var mwEditPageHelper = {
2924 init: function( amwConf ) {
3025 var _this = this;
3126 // kind of tricky, it would be nice to use run on ready "loader" call here
3227 if( typeof $j.wikiEditor != 'undefined' ) {
33 - setTimeout( function() {
 28+ setTimeout( function() {
3429 $j( '.wikiEditor-ui [rel=file]' ).unbind().addMediaWiz(
3530 amwConf
3631 );
@@ -49,3 +44,9 @@
5045 );*/
5146 }
5247 }
 48+
 49+js2AddOnloadHook( function() {
 50+ mwEditPageHelper.init(
 51+ $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig )
 52+ );
 53+});

Status & tagging log