Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js |
— | — | @@ -170,7 +170,7 @@ |
171 | 171 | this.orig_onsubmit = this.form.onsubmit; |
172 | 172 | } |
173 | 173 | |
174 | | - if( this.selectFileCb ){ |
| 174 | + if( this.selectFileCb ) { |
175 | 175 | this.bindSelectFileCb(); |
176 | 176 | } |
177 | 177 | |
— | — | @@ -186,9 +186,11 @@ |
187 | 187 | */ |
188 | 188 | bindSelectFileCb: function(){ |
189 | 189 | var _this = this; |
| 190 | + |
190 | 191 | // Grab the select file input from the form |
191 | 192 | var $target = $j( this.form ).find( "input[type='file']" ); |
192 | 193 | $target.change( function() { |
| 194 | + |
193 | 195 | var path = $j( this ).val(); |
194 | 196 | // Find trailing part |
195 | 197 | var slash = path.lastIndexOf( '/' ); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js |
— | — | @@ -290,8 +290,9 @@ |
291 | 291 | } catch ( e ) { |
292 | 292 | mw.log( "Error could not parse hashResult" ); |
293 | 293 | } |
| 294 | + |
294 | 295 | // Check for the contextKey |
295 | | - if( ! resultObject.contextKey ) { |
| 296 | + if ( ! resultObject.contextKey ) { |
296 | 297 | mw.log( "Error missing context key in nested callback" ); |
297 | 298 | return false; |
298 | 299 | } |
— | — | @@ -363,7 +364,7 @@ |
364 | 365 | * @param {Object} contextVars Initial contextVars |
365 | 366 | */ |
366 | 367 | function createContext ( contextVars ) { |
367 | | - // Create a ~ sufficently ~ unique context key |
| 368 | + // Create a ~ sufficiently ~ unique context key |
368 | 369 | var contextKey = new Date().getTime() * Math.random(); |
369 | 370 | proxyContext [ contextKey ] = contextVars; |
370 | 371 | |
— | — | @@ -427,8 +428,8 @@ |
428 | 429 | * @param {URL} apiUrl The url of the api server |
429 | 430 | */ |
430 | 431 | // Include gadget js ( in case the user has not enabled the gadget on that domain ) |
431 | | - var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js'; |
432 | | - //var gadgetWithJS = ''; |
| 432 | + //var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js'; |
| 433 | + var gadgetWithJS = ''; |
433 | 434 | function getServerFrame( context ) { |
434 | 435 | if( ! context || ! context.apiUrl ){ |
435 | 436 | mw.log( "Error no context api url " ); |
— | — | @@ -646,6 +647,10 @@ |
647 | 648 | $j.post( wgScriptPath + '/api' + wgScriptExtension, |
648 | 649 | clientRequest.request, |
649 | 650 | function( data ) { |
| 651 | + // Make sure data is in JSON data format ( not a string ) |
| 652 | + if( typeof data != 'object' ){ |
| 653 | + data = JSON.parse( data ); |
| 654 | + } |
650 | 655 | mw.log(" server api request got data: " + JSON.stringify( data ) ); |
651 | 656 | // Send the result data to the client |
652 | 657 | sendClientMsg( data ); |
— | — | @@ -872,7 +877,7 @@ |
873 | 878 | var clientRequest = getClientRequest(); |
874 | 879 | |
875 | 880 | // Get a local reference to the client request |
876 | | - var clientFrame = getClientRequest()['clientFrame']; |
| 881 | + var clientFrame = clientRequest[ 'clientFrame' ]; |
877 | 882 | |
878 | 883 | // Double check that the client is an approved domain before outputting the iframe |
879 | 884 | if( ! isAllowedClientFrame ( clientFrame ) ) { |
— | — | @@ -932,7 +937,7 @@ |
933 | 938 | |
934 | 939 | // Check for frame name: |
935 | 940 | if( ! options[ 'name' ] ) { |
936 | | - options[ 'name' ] = 'mwApiProxyFrame_' + $j('iframe').length; |
| 941 | + options[ 'name' ] = 'mwApiProxyFrame_' + $j( 'iframe' ).length; |
937 | 942 | } |
938 | 943 | |
939 | 944 | // Add the frame name / id: |
— | — | @@ -970,7 +975,7 @@ |
971 | 976 | } |
972 | 977 | var targetName = ( typeof options[ 'target' ] == 'string') ? options[ 'target' ] : $j( options[ 'target' ]).length ; |
973 | 978 | |
974 | | - mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + targetName + " \n WITH REQUEST: " + JSON.stringify( options.request ) ); |
| 979 | + mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + targetName + " \n with data: " + JSON.stringify( options.request ) ); |
975 | 980 | |
976 | 981 | // Append to target |
977 | 982 | $j( options[ 'target' ] ).append( s ); |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | */ |
6 | 6 | var urlparts = getRemoteEmbedPath(); |
7 | 7 | var mwEmbedHostPath = urlparts[0]; |
8 | | -var mwRemoteVersion = 'r118'; |
| 8 | +var mwRemoteVersion = 'r119'; |
9 | 9 | var mwUseScriptLoader = true; |
10 | 10 | |
11 | 11 | // Log the mwRemote version ( will determine what version of js we get ) |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | if ( vidIdList.length > 0 ) { |
147 | 147 | // Reverse order the array so videos at the "top" get swapped first: |
148 | 148 | vidIdList = vidIdList.reverse(); |
149 | | - mwLoadPlayer(function(){ |
| 149 | + mwLoadPlayer( function(){ |
150 | 150 | //Load the "EmbedPlayer" module: |
151 | 151 | // All the actual code was requested in our single script-loader call |
152 | 152 | // but the "load" request applies the setup. |
— | — | @@ -210,7 +210,7 @@ |
211 | 211 | return ; |
212 | 212 | } |
213 | 213 | |
214 | | - |
| 214 | + |
215 | 215 | tag_type = 'video'; |
216 | 216 | |
217 | 217 | // Check type: |
— | — | @@ -243,14 +243,12 @@ |
244 | 244 | apiTitleKey = unescape( apiTitleKey[ apiTitleKey.length - 1 ] ); |
245 | 245 | |
246 | 246 | var re = new RegExp( /length(":?\s*)*([^,]*)/ ); |
247 | | - var dv = re.exec( rewriteHTML )[2]; |
248 | | - if ( dv ) { |
249 | | - duration_attr = 'durationHint="' + dv + '" '; |
250 | | - } |
| 247 | + var dv = parseFloat( re.exec( rewriteHTML )[2] ); |
| 248 | + duration_attr = ( dv )? 'durationHint="' + dv + '" ': ''; |
251 | 249 | |
252 | 250 | var re = new RegExp( /offset(":?\s*)*([^,&]*)/ ); |
253 | | - offset = re.exec( rewriteHTML )[2]; |
254 | | - var offset_attr = offset ? 'startOffset="' + offset + '"' : ''; |
| 251 | + offset = re.exec( rewriteHTML ); |
| 252 | + var offset_attr = ( offset && offset[2] )? 'startOffset="' + offset[2] + '" ' : ''; |
255 | 253 | |
256 | 254 | // Check if file is from commons and therefore should explictly set apiProvider to commons: |
257 | 255 | var apiProviderAttr = ( src.indexOf( 'wikipedia\/commons' ) != -1 )?'apiProvider="commons" ': ''; |
Index: branches/js2-work/phase3/js/apiProxyPage.js |
— | — | @@ -28,11 +28,11 @@ |
29 | 29 | mw.setConfig( 'apiProxyConfig', mwApiProxyConfig); |
30 | 30 | |
31 | 31 | // Do a setTimeout to 0 to call after other zero delay async events |
32 | | - // ( once everyone is doing buildout withthin mwsetup priror to .ready this won't be needed. ) |
| 32 | + // ( once everyone is doing buildout within mwsetup prior to .ready this won't be needed. ) |
33 | 33 | mw.log( 'load ApiProxy' ); |
34 | | - mw.load( 'ApiProxy', function(){ |
| 34 | + mw.load( 'ApiProxy', function() { |
35 | 35 | //Clear out the page content ( not needed for iframe proxy ) |
36 | 36 | $j( 'body' ).html( '' ); |
37 | 37 | mw.ApiProxy.server(); |
38 | | - }); |
| 38 | + } ); |
39 | 39 | } ); |
Index: branches/js2-work/phase3/js/uploadPage.js |
— | — | @@ -33,6 +33,11 @@ |
34 | 34 | |
35 | 35 | // Set the select file callback: |
36 | 36 | 'selectFileCb': function( fileName ) { |
| 37 | + // Check if we are on upload to new version page and don't update target |
| 38 | + // ( bug 23069 ) |
| 39 | + if( mw.parseUri( document.URL ).queryKey['wpDestFile'] ){ |
| 40 | + return false; |
| 41 | + } |
37 | 42 | $j( '#wpDestFile' ).val( fileName ); |
38 | 43 | } |
39 | 44 | } ); |