Index: trunk/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html |
— | — | @@ -77,7 +77,11 @@ |
78 | 78 | </script> |
79 | 79 | </head><body> |
80 | 80 | <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> |
82 | 86 | <br> |
83 | 87 | <br> |
84 | 88 | <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 @@ |
827 | 827 | }else{ |
828 | 828 | this.action_done = true; |
829 | 829 | this.fogg.cancel(); |
830 | | - $j(dlElm).empty().dialog('close'); |
831 | | - return false; |
| 830 | + $j(dlElm).empty().dialog('close'); |
832 | 831 | } |
833 | | - } else{ |
834 | | - return false; |
835 | 832 | } |
| 833 | + //dont' follow the link: |
| 834 | + return false; |
836 | 835 | }, |
837 | 836 | /** |
838 | 837 | * procPageResponse should be faded out in favor of the upload api soon.. |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -683,7 +683,7 @@ |
684 | 684 | if( event.button==0 && _this.action_done === false){ |
685 | 685 | return _this.cancel_action(); |
686 | 686 | }else{ |
687 | | - //click on button (dont do close action); |
| 687 | + //click on button (don't do close action); |
688 | 688 | return true; |
689 | 689 | } |
690 | 690 | }, |
— | — | @@ -718,11 +718,10 @@ |
719 | 719 | //confirm: |
720 | 720 | if( confirm( gM('mwe-cancel-confim') )){ |
721 | 721 | //@@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'); |
726 | 723 | } |
| 724 | + //dont' follow the link; |
| 725 | + return false; |
727 | 726 | } |
728 | 727 | }; |
729 | 728 | |
Index: trunk/phase3/js2/mwEmbed/tests/testLang.html |
— | — | @@ -12,50 +12,58 @@ |
13 | 13 | var langKey = 'en'; |
14 | 14 | js2AddOnloadHook( function(){ |
15 | 15 | //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 | + |
19 | 27 | var passTest=0; |
20 | 28 | var failTest=0; |
21 | 29 | var testCount=0; |
22 | 30 | //now for each langage msg: |
23 | | - $j.each(msgTestSet, function(inx, mKey){ |
| 31 | + $j.each(msgTestSet, function(mKey, mTestSet){ |
24 | 32 | //output table names: |
25 | 33 | o+='<tr>'+ |
26 | 34 | '<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>'+ |
31 | 39 | '</tr>'; |
32 | 40 | |
33 | 41 | //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; |
36 | 45 | o+='<tr>'+ |
37 | 46 | '<td>' + numVal + '</td>' + |
38 | 47 | '<td>' + mKey + '</td>' + |
39 | 48 | '<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>'; |
41 | 50 | //show mw col: |
42 | 51 | if( mKey.substr(0, 5) == 'test_' ){ |
43 | 52 | o+='<td> (test msg) </td>'; |
44 | 53 | }else{ |
45 | | - o+='<td id="' + mKey + '_' + numVal + '">loading<blink>...</blink></td>'; |
| 54 | + o+='<td id="' + mKey + '_' + numKey + '">loading<blink>...</blink></td>'; |
46 | 55 | |
47 | 56 | //get transform from mw (& compare and highlight) |
48 | | - function doPopWmMsg(mKey, numVal){ |
| 57 | + function doPopWmMsg(mKey, numVal, numKey){ |
49 | 58 | 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'); |
51 | 60 | do_api_req({ |
52 | 61 | 'data': { |
53 | 62 | 'action':'parse', |
54 | 63 | 'text': $mw.lang.gMsgSwap( mKey, numVal) |
55 | 64 | }, |
56 | 65 | '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; |
60 | 68 | if(data.parse && data.parse.text && data.parse.text['*']){ |
61 | 69 | $j(t).html( data.parse.text['*'] ); |
62 | 70 | //just get the part in the <p> to compare with js version |
— | — | @@ -78,7 +86,7 @@ |
79 | 87 | }); |
80 | 88 | }; |
81 | 89 | //pop off an anonymous function call: |
82 | | - doPopWmMsg(mKey, numVal); |
| 90 | + doPopWmMsg(mKey, numVal, numKey); |
83 | 91 | } |
84 | 92 | o+='</tr>'; |
85 | 93 | } |
Index: trunk/phase3/js2/mwEmbed/skins/ctrlBuilder.js |
— | — | @@ -1,6 +1,9 @@ |
2 | 2 | //set the dismissNativeWarn flag: |
3 | 3 | _global['dismissNativeWarn'] = false; |
4 | 4 | |
| 5 | +/** |
| 6 | +* Msg text is inhereited from embedVideo (we should move it here (although can't load ctrlBuilder without parent EmbedVideo obj) |
| 7 | +/ |
5 | 8 | |
6 | 9 | /** |
7 | 10 | * 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 |
8 | 11 | + application/octet-stream |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -139,7 +139,7 @@ |
140 | 140 | * |
141 | 141 | * it take a msg key and array of replacement values of form |
142 | 142 | * $1, $2 and does relevant msgkey transformation returning |
143 | | - * the usser msg. |
| 143 | + * the user msg. |
144 | 144 | * |
145 | 145 | * @param string key The msg key as set by loadGm |
146 | 146 | * @param [mixed] args An array of replacement strings |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | //swap in the arg values |
154 | 154 | var ms = $.lang.gMsgSwap( key, args); |
155 | 155 | //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) |
157 | 157 | if(ms.indexOf('{{')==-1) |
158 | 158 | return ms; |
159 | 159 | |
— | — | @@ -174,13 +174,13 @@ |
175 | 175 | if(! gMsg[ key ]) |
176 | 176 | return '<' + key + '>';// Missing key placeholder |
177 | 177 | //get the messege string: |
178 | | - ms = gMsg[ key ]; |
| 178 | + var ms = gMsg[ key ]; |
179 | 179 | |
180 | 180 | //replace values |
181 | 181 | if( typeof args == 'object' || typeof args == 'array' ) { |
182 | 182 | for( var v in args ) { |
183 | 183 | // 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'); |
185 | 185 | ms = ms.replace( rep, args[v] ); |
186 | 186 | } |
187 | 187 | } else if( typeof args =='string' || typeof args =='number' ) { |
— | — | @@ -237,20 +237,23 @@ |
238 | 238 | /** |
239 | 239 | * Maps a given rule Index to template params: |
240 | 240 | * |
| 241 | + * if index is out of range return last param |
241 | 242 | * @param |
242 | 243 | */ |
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: |
246 | 249 | return tObj.param[ ruleInx ]; |
247 | 250 | } |
248 | 251 | var rCount=0 |
249 | | - //run the acutal rule lookup: |
| 252 | + //run the actual rule lookup: |
250 | 253 | for(var ruleInx in rs){ |
251 | 254 | cRule = rs[ruleInx]; |
252 | 255 | if( matchRuleTest( cRule, tObj.arg ) ){ |
253 | 256 | js_log("matched rule: " + ruleInx ); |
254 | | - return getTempParamFromRuleInx( rCount ); |
| 257 | + return getTempParamFromRuleInx(tObj, rCount ); |
255 | 258 | } |
256 | 259 | rCount ++; |
257 | 260 | } |
— | — | @@ -539,6 +542,10 @@ |
540 | 543 | var loadGM = $mw.lang.loadGM; |
541 | 544 | var gM = $mw.lang.gM; |
542 | 545 | |
| 546 | +//if some no-js2 script defined and loaded gMsg in global space: |
| 547 | +if( _global['gMsg'] ){ |
| 548 | + loadGM( _global['gMsg'] ); |
| 549 | +} |
543 | 550 | |
544 | 551 | // All default messages in [English] should be overwritten by the CMS language message system. |
545 | 552 | $mw.lang.loadGM({ |
— | — | @@ -718,7 +725,7 @@ |
719 | 726 | // Base lib flags |
720 | 727 | onReadyEvents: new Array(), |
721 | 728 | doneReadyEvents: false, |
722 | | - jQueryCheckFlag: false, |
| 729 | + jQuerySetupFlag: false, |
723 | 730 | |
724 | 731 | // To keep consistency across threads |
725 | 732 | ptime: 0, |
— | — | @@ -743,7 +750,7 @@ |
744 | 751 | } |
745 | 752 | } |
746 | 753 | if( all_libs_loaded ) { |
747 | | - js_log( 'All libraries already loaded, skipping load request' ); |
| 754 | + //js_log( 'Libraries ( ' + loadLibs + ') already loaded... skipping load request' ); |
748 | 755 | callback(); |
749 | 756 | return; |
750 | 757 | } |
— | — | @@ -892,6 +899,7 @@ |
893 | 900 | * checks for jQuery and adds the $j noConflict var |
894 | 901 | */ |
895 | 902 | jQueryCheck: function( callback ) { |
| 903 | + //js_log( 'jQueryCheck::' ); |
896 | 904 | // Skip stuff if $j is already loaded: |
897 | 905 | if( _global['$j'] && callback ) |
898 | 906 | callback(); |
— | — | @@ -903,7 +911,9 @@ |
904 | 912 | //only do the $j setup once: |
905 | 913 | if(!_global['$j']){ |
906 | 914 | _global['$j'] = jQuery.noConflict(); |
907 | | - |
| 915 | + } |
| 916 | + if( _this.jQuerySetupFlag == false){ |
| 917 | + js_log('setup mv_embed jQuery bindings'); |
908 | 918 | //setup our global settings using the (jQuery helper) |
909 | 919 | mwConfig = $j.extend( mwDefaultConfig, mwConfig); |
910 | 920 | |
— | — | @@ -928,6 +938,7 @@ |
929 | 939 | js_log( 'jQuery loaded into $j' ); |
930 | 940 | // Set up mvEmbed jQuery bindings and config based dependencies |
931 | 941 | mv_jqueryBindings(); |
| 942 | + _this.jQuerySetupFlag = true; |
932 | 943 | } |
933 | 944 | // Run the callback |
934 | 945 | if( callback ) { |
— | — | @@ -937,7 +948,7 @@ |
938 | 949 | }, |
939 | 950 | embedVideoCheck:function( callback ) { |
940 | 951 | var _this = this; |
941 | | - js_log( 'embedVideoCheck:' ); |
| 952 | + js_log( 'embedVideoCheck:' ); |
942 | 953 | // Make sure we have jQuery |
943 | 954 | _this.jQueryCheck( function() { |
944 | 955 | //set class videonojs to hidden |
— | — | @@ -976,14 +987,10 @@ |
977 | 988 | // unless js2AddOnloadHook was used or there is video on the page. |
978 | 989 | runQueuedFunctions: function() { |
979 | 990 | 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 | + }); |
988 | 995 | }, |
989 | 996 | runReadyEvents: function() { |
990 | 997 | js_log( "runReadyEvents" ); |
— | — | @@ -1050,8 +1057,6 @@ |
1051 | 1058 | func(); |
1052 | 1059 | }); |
1053 | 1060 | } else { |
1054 | | - // If we are using js2AddOnloadHook we need to get jQuery into place (if it's not already included) |
1055 | | - mvJsLoader.jQueryCheckFlag = true; |
1056 | 1061 | mvJsLoader.addLoadEvent( func ); |
1057 | 1062 | } |
1058 | 1063 | } |
Index: trunk/phase3/js2/editPage.js |
— | — | @@ -19,17 +19,12 @@ |
20 | 20 | // The local wiki API URL: |
21 | 21 | 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php' |
22 | 22 | }; |
23 | | -js2AddOnloadHook( function() { |
24 | | - mwEditPageHelper.init( |
25 | | - $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ) |
26 | | - ); |
27 | | -}); |
28 | 23 | var mwEditPageHelper = { |
29 | 24 | init: function( amwConf ) { |
30 | 25 | var _this = this; |
31 | 26 | // kind of tricky, it would be nice to use run on ready "loader" call here |
32 | 27 | if( typeof $j.wikiEditor != 'undefined' ) { |
33 | | - setTimeout( function() { |
| 28 | + setTimeout( function() { |
34 | 29 | $j( '.wikiEditor-ui [rel=file]' ).unbind().addMediaWiz( |
35 | 30 | amwConf |
36 | 31 | ); |
— | — | @@ -49,3 +44,9 @@ |
50 | 45 | );*/ |
51 | 46 | } |
52 | 47 | } |
| 48 | + |
| 49 | +js2AddOnloadHook( function() { |
| 50 | + mwEditPageHelper.init( |
| 51 | + $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ) |
| 52 | + ); |
| 53 | +}); |