Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/mediaWikiSearch.js |
— | — | @@ -194,13 +194,20 @@ |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Skip if its an empty or missing imageinfo: |
198 | | - if ( !page.imageinfo ) |
| 198 | + if ( !page.imageinfo ){ |
199 | 199 | continue; |
| 200 | + } |
| 201 | + |
| 202 | + // Get the url safe titleKey from the descriptionurl |
| 203 | + var titleKey = page.imageinfo[0].descriptionurl.split( '/' ); |
| 204 | + titleKey = unescape( titleKey[ titleKey.length - 1 ] ); |
| 205 | + titleKey = titleKey.replace( /File:|Image:/, '' ); |
| 206 | + |
200 | 207 | var resource = { |
201 | 208 | 'id' : page_id, |
202 | | - 'titleKey' : page.title, |
| 209 | + 'titleKey' : titleKey, |
203 | 210 | 'link' : page.imageinfo[0].descriptionurl, |
204 | | - 'title' : page.title.replace(/File:.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''), |
| 211 | + 'title' : page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''), |
205 | 212 | 'poster' : page.imageinfo[0].thumburl, |
206 | 213 | 'thumbwidth' : page.imageinfo[0].thumbwidth, |
207 | 214 | 'thumbheight': page.imageinfo[0].thumbheight, |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js |
— | — | @@ -241,22 +241,33 @@ |
242 | 242 | outHtml = this.getImageEmbedHTML( resource, options ); |
243 | 243 | } |
244 | 244 | |
245 | | - if ( resource.mime == 'application/ogg' || resource.mime == 'video/ogg' || resource.mime == 'audio/ogg' ) { |
| 245 | + if ( resource.mime == 'application/ogg' |
| 246 | + || resource.mime == 'video/ogg' |
| 247 | + || resource.mime == 'audio/ogg' |
| 248 | + ) { |
246 | 249 | // Setup the attribute html |
247 | 250 | // NOTE: Can't use jQuery builder for video element, ( does not work consistently ) |
248 | 251 | var ahtml = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; |
249 | | - ahtml+= 'src="' + mw.escapeQuotesHTML( resource.src ) + '" ' + |
250 | | - //'class="' + mw.getConfig( 'skinName' ) + '" ' + |
251 | | - // mannualy set kskin (while mw.setConfig is not available on all pages ) |
252 | | - 'class="kskin" '+ |
| 252 | + ahtml+= 'src="' + mw.escapeQuotesHTML( resource.src ) + '" ' + |
| 253 | + // Mannualy set kskin, NOTE: should be config option |
| 254 | + 'class="kskin" ' + |
253 | 255 | 'style="' + options.style + '" ' + |
254 | 256 | 'poster="' + mw.escapeQuotesHTML( resource.poster ) + '" '+ |
255 | 257 | 'type="' + mw.escapeQuotesHTML( resource.mime ) + '" '; |
256 | | - |
| 258 | + |
| 259 | + |
257 | 260 | // Add the api title key if available: |
258 | 261 | if( resource.titleKey ) { |
259 | | - 'apiTitleKey="' + mw.escapeQuotesHTML( resource.titleKey ) + '" '; |
260 | | - } |
| 262 | + ahtml+= 'apiTitleKey="' + mw.escapeQuotesHTML( resource.titleKey ) + '" '; |
| 263 | + } |
| 264 | + |
| 265 | + // Add the commons apiProvider if the resource is from commons |
| 266 | + // ( so that subtitles can be displayed / edited ) |
| 267 | + if( resource.pSobj.provider.id == 'wiki_commons' |
| 268 | + || resource.commonsShareRepoFlag |
| 269 | + ){ |
| 270 | + ahtml+= 'apiProvider="commons" '; |
| 271 | + } |
261 | 272 | |
262 | 273 | if ( resource.mime == 'application/ogg' || resource.mime == 'video/ogg' ) { |
263 | 274 | outHtml = '<video ' + ahtml + '></video>'; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -156,10 +156,7 @@ |
157 | 157 | 'default_provider': null, |
158 | 158 | |
159 | 159 | // The timeout for search providers ( in seconds ) |
160 | | - 'search_provider_timeout': 10, |
161 | | - |
162 | | - // Default edit image width |
163 | | - 'defaultEditImageWidth' : 400 |
| 160 | + 'search_provider_timeout': 10 |
164 | 161 | }; |
165 | 162 | |
166 | 163 | /** |
— | — | @@ -1782,9 +1779,12 @@ |
1783 | 1780 | .attr( { |
1784 | 1781 | id: 'res_' + provider.id + '__' + resIndex, |
1785 | 1782 | title: resource.title, |
1786 | | - src: provider.sObj.getImageTransform( resource, { 'width': this.thumb_width } ) |
| 1783 | + src: provider.sObj.getImageTransform( resource, { |
| 1784 | + 'width': this.thumb_width |
| 1785 | + } ) |
1787 | 1786 | } ) |
1788 | | - .width( this.thumb_width ); |
| 1787 | + .width( this.thumb_width ) |
| 1788 | + .height( parseInt( this.thumb_width * ( resource.height / resource.width ) ) ) |
1789 | 1789 | |
1790 | 1790 | $resultBox.append( $resultThumb ); |
1791 | 1791 | |
— | — | @@ -2014,13 +2014,13 @@ |
2015 | 2015 | mw.log("done adding resource editor"); |
2016 | 2016 | |
2017 | 2017 | var mediaType = _this.getMediaType( resource ); |
2018 | | - var width = _this.getDefaultEditWidth( resource ); |
| 2018 | + var targetWidth = _this.getDefaultEditWidth( resource ); |
2019 | 2019 | |
2020 | | - var height = parseInt( width * ( resource.height / resource.width ) ); |
| 2020 | + var targetHeight = parseInt( targetWidth * ( resource.height / resource.width ) ); |
2021 | 2021 | |
2022 | | - if( height > $j('#clip_edit_disp').height() ){ |
2023 | | - height = $j('#clip_edit_disp').height(); |
2024 | | - width = height * ( resource.width / resource.height); |
| 2022 | + if( targetHeight > $j('#clip_edit_disp').height() ){ |
| 2023 | + targetHeight = $j('#clip_edit_disp').height(); |
| 2024 | + targetWidth = targetHeight * ( resource.width / resource.height); |
2025 | 2025 | } |
2026 | 2026 | |
2027 | 2027 | //mw.log("org h/w" + resource.width + ' / ' + resource.height +' new w' + width + ' new h:' + height ); |
— | — | @@ -2032,28 +2032,40 @@ |
2033 | 2033 | $j( _this.target_container ).dialog( 'option', 'title', dialogTitle ); |
2034 | 2034 | |
2035 | 2035 | mw.log( 'did append to: ' + _this.target_container ); |
2036 | | - |
2037 | | - if ( mediaType == 'image' ) { |
2038 | | - _this.loadHighQualityImage( |
| 2036 | + |
| 2037 | + // issue a loadResourceImage request if needed ( image is > than target display resolution ) |
| 2038 | + if ( mediaType == 'image' && resource.width > targetWidth ) { |
| 2039 | + _this.loadResourceImage( |
2039 | 2040 | resource, |
2040 | 2041 | { |
2041 | | - 'width': width, |
2042 | | - 'height' : height |
| 2042 | + 'width': targetWidth, |
| 2043 | + 'height' : targetHeight |
2043 | 2044 | }, |
2044 | | - 'rsd_edit_img', |
2045 | 2045 | function( img_src ) { |
2046 | | - $j( '.loading_spinner' ).remove(); |
2047 | | - $j( '<img />' ) |
| 2046 | + $j('#clip_edit_disp').empty().append( |
| 2047 | + $j( '<img />' ) |
2048 | 2048 | .attr( { |
2049 | 2049 | 'id' : 'rsd_edit_img', |
2050 | 2050 | 'src' : img_src, |
2051 | | - 'width': width, |
2052 | | - 'height' : height |
| 2051 | + 'width': targetWidth, |
| 2052 | + 'height' : targetHeight |
2053 | 2053 | } ) |
2054 | | - .appendTo( '#clip_edit_disp' ); |
| 2054 | + ); |
2055 | 2055 | } |
2056 | 2056 | ); |
| 2057 | + } else if ( mediaType == 'image' ) { |
| 2058 | + //Just use the asset url directly |
| 2059 | + $j('#clip_edit_disp').empty().append( |
| 2060 | + $j( '<img />' ) |
| 2061 | + .attr( { |
| 2062 | + 'id' : 'rsd_edit_img', |
| 2063 | + 'src' : resource.src, |
| 2064 | + 'width' : resource.width, |
| 2065 | + 'height' : resource.height |
| 2066 | + } ) |
| 2067 | + ) |
2057 | 2068 | } |
| 2069 | + |
2058 | 2070 | // Also fade in the container: |
2059 | 2071 | $j( '#rsd_resource_edit' ).animate( { |
2060 | 2072 | 'opacity': 1, |
— | — | @@ -2070,27 +2082,25 @@ |
2071 | 2083 | }, |
2072 | 2084 | |
2073 | 2085 | /* |
2074 | | - * Loads a higher quality image |
| 2086 | + * Loads a resource image of set size |
2075 | 2087 | * |
2076 | 2088 | * @param {Object} resource requested resource for higher quality image |
2077 | 2089 | * @param {Object} size the requested size of the higher quality image |
2078 | | - * @param {string} target the image id to replace with higher quality image |
2079 | 2090 | * @param {Function} callback the function to be calle once the image is loaded |
2080 | 2091 | */ |
2081 | | - loadHighQualityImage: function( resource, size, target_img_id, callback ) { |
2082 | | - mw.log( "loadHighQualityImage" ); |
2083 | | - // Get the high quality image url: |
| 2092 | + loadResourceImage: function( resource, size, callback ) { |
| 2093 | + mw.log( "loadResourceImage" ); |
| 2094 | + // Get the image url: |
2084 | 2095 | resource.pSobj.getImageObj( resource, size, function( imObj ) { |
2085 | 2096 | resource['edit_url'] = imObj.url; |
2086 | 2097 | |
2087 | 2098 | mw.log( "edit url: " + resource.edit_url ); |
2088 | | - // Update the resource |
| 2099 | + // Update the resource:: |
2089 | 2100 | resource['width'] = imObj.width; |
2090 | 2101 | resource['height'] = imObj.height; |
2091 | 2102 | |
2092 | 2103 | var width = imObj.width; |
2093 | | - var height = imObj.height; |
2094 | | - |
| 2104 | + var height = imObj.height; |
2095 | 2105 | |
2096 | 2106 | // Don't swap it in until its loaded |
2097 | 2107 | var img = new Image(); |
— | — | @@ -2218,7 +2228,8 @@ |
2219 | 2229 | } |
2220 | 2230 | var embedHtml = resource.pSobj.getEmbedHTML( resource, |
2221 | 2231 | { |
2222 | | - 'id' : 'embed_vid' |
| 2232 | + 'id' : 'embed_vid', |
| 2233 | + 'apiTitleKey' : resource.title |
2223 | 2234 | } |
2224 | 2235 | ); |
2225 | 2236 | mw.log( 'append html: ' + embedHtml ); |
— | — | @@ -2227,7 +2238,7 @@ |
2228 | 2239 | mw.log( "about to call $j.embedPlayer::embed_vid" ); |
2229 | 2240 | |
2230 | 2241 | // Rewrite by id |
2231 | | - $j( '#embed_vid').embedPlayer ( function() { |
| 2242 | + $j( '#embed_vid' ).embedPlayer ( function() { |
2232 | 2243 | // Add extra space at the top if the embed player is less than 90px high |
2233 | 2244 | // bug 22189 |
2234 | 2245 | if( $j('#embed_vid').get(0).getPlayerHeight() < 90 ) { |
— | — | @@ -2301,7 +2312,7 @@ |
2302 | 2313 | // Add a loader on top |
2303 | 2314 | mw.addLoaderDialog( gM( 'mwe-checking-resource' ) ); |
2304 | 2315 | |
2305 | | - // Extend the callback, closing the loader dialog before chaining |
| 2316 | + // Extend the callback, closing the loader dialog before calling |
2306 | 2317 | var myCallback = function( status ) { |
2307 | 2318 | mw.closeLoaderDialog(); |
2308 | 2319 | if ( typeof callback == 'function' ) { |
— | — | @@ -2309,7 +2320,7 @@ |
2310 | 2321 | } |
2311 | 2322 | } |
2312 | 2323 | |
2313 | | - // @@todo get the localized File/Image namespace name or do a general {NS}:Title |
| 2324 | + // NOTE: get the localized File/Image namespace name or do a general {NS}:Title |
2314 | 2325 | var provider = resource.pSobj.provider; |
2315 | 2326 | var _this = this; |
2316 | 2327 | |
— | — | @@ -2328,7 +2339,7 @@ |
2329 | 2340 | // or if import mode if just "linking" ( we should already have the 'url' ) |
2330 | 2341 | |
2331 | 2342 | if ( this.isProviderLocal( provider ) || this.import_url_mode == 'remote_link' ) { |
2332 | | - // Local repo, jump directly to the callback: |
| 2343 | + // Local repo or in remote_link mode, jump directly to the callback: |
2333 | 2344 | myCallback( 'local' ); |
2334 | 2345 | return ; |
2335 | 2346 | } else { |
— | — | @@ -2338,6 +2349,7 @@ |
2339 | 2350 | _this.findFileInLocalWiki( fileTitle, function( imagePage ) { |
2340 | 2351 | if ( imagePage && imagePage['imagerepository'] == 'shared' || |
2341 | 2352 | imagePage['imagerepository'] == 'commons') { |
| 2353 | + resource.commonsShareRepoFlag = true; |
2342 | 2354 | myCallback( 'shared' ); |
2343 | 2355 | } else { |
2344 | 2356 | _this.isFileAlreadyImported( resource, myCallback ); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -248,26 +248,29 @@ |
249 | 249 | * |
250 | 250 | */ |
251 | 251 | $.fn.embedPlayer = function( attributes, callback ) { |
252 | | - mw.log('fn:embedPlayer on: ' + this.selector); |
| 252 | + mw.log('embedPlayer on: ' + this.selector); |
253 | 253 | var player_select = this.selector; |
254 | 254 | //Handle optional include of attributes argument: |
255 | | - if( typeof attributes == 'function' && typeof( callback ) != 'function' ) |
| 255 | + if( typeof attributes == 'function' ){ |
256 | 256 | callback = attributes; |
| 257 | + } |
257 | 258 | |
258 | 259 | // Create the Global Embed Player Manager ( if not already created ) |
259 | | - if( ! mw.playerManager ) |
260 | | - mw.playerManager = new EmbedPlayerManager(); |
| 260 | + mw.log( "create the player manager:" ); |
| 261 | + if( ! mw.playerManager ){ |
| 262 | + mw.playerManager = new EmbedPlayerManager(); |
| 263 | + } |
261 | 264 | |
262 | 265 | //Add the embedPlayer ready callback |
263 | 266 | if( typeof callback == 'function' ){ |
264 | 267 | mw.playerManager.addCallback( callback ); |
265 | | - } |
266 | | - |
| 268 | + } |
| 269 | + mw.log("about to run jQuery select on : " + player_select); |
267 | 270 | // Add each selected element to the player manager: |
268 | 271 | $j( player_select ).each( function(na, playerElement) { |
269 | 272 | mw.playerManager.addElement( playerElement, attributes); |
270 | 273 | } ); |
271 | | - |
| 274 | + |
272 | 275 | // Once we are done adding new players start to check if players are ready: |
273 | 276 | mw.playerManager.waitPlayersReadyCallback(); |
274 | 277 | } |
— | — | @@ -411,7 +414,7 @@ |
412 | 415 | var width = $j( element ).css( 'width' ); |
413 | 416 | var height = $j( element ).css( 'height' ); |
414 | 417 | |
415 | | - // Css video defaults: |
| 418 | + // Css video defaults |
416 | 419 | if( $j( element ).css( 'width' ) == '300px' |
417 | 420 | && $j( element ).css( 'height' ) == '150px' |
418 | 421 | ){ |
— | — | @@ -491,7 +494,8 @@ |
492 | 495 | */ |
493 | 496 | waitPlayersReadyCallback: function() { |
494 | 497 | var _this = this; |
495 | | - // mw.log('checkClipsReady'); |
| 498 | + mw.log( 'waitPlayersReadyCallback' ); |
| 499 | + |
496 | 500 | var is_ready = true; |
497 | 501 | for ( var i = 0; i < this.playerList.length; i++ ) { |
498 | 502 | var player = $j( '#' + this.playerList[i] ).get( 0 ); |
— | — | @@ -502,8 +506,10 @@ |
503 | 507 | } |
504 | 508 | if ( is_ready ) { |
505 | 509 | // Run queued functions |
506 | | - while ( this.callbackFunctions.length ) { |
507 | | - this.callbackFunctions.shift()(); |
| 510 | + if( this.callbackFunctions ) { |
| 511 | + while ( this.callbackFunctions.length ) { |
| 512 | + this.callbackFunctions.shift()(); |
| 513 | + } |
508 | 514 | } |
509 | 515 | } else { |
510 | 516 | // Continue checking the playerList |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -620,9 +620,9 @@ |
621 | 621 | function doProcessJs( $str ){ |
622 | 622 | global $wgEnableScriptLocalization; |
623 | 623 | |
624 | | - // Strip out js_log debug lines (if not in debug mode) |
| 624 | + // Strip out mw.log debug lines (if not in debug mode) |
625 | 625 | if( !$this->debug ){ |
626 | | - $str = preg_replace('/\n\s*mw\.log\(([^\)]*\))*\s*[\;\n]/U', "\n", $str); |
| 626 | + //$str = preg_replace('/\n\s*mw\.log\(([^\)]*\))*\s*[\;\n]/U', "\n", $str); |
627 | 627 | } |
628 | 628 | |
629 | 629 | // Do language swap by index: |
— | — | @@ -630,7 +630,7 @@ |
631 | 631 | $inx = self::getAddMessagesIndex( $str ); |
632 | 632 | if($inx){ |
633 | 633 | $translated = $this->languageMsgReplace( substr($str, $inx['s'], ($inx['e']-$inx['s']) )); |
634 | | - //return the final string (without double {}) |
| 634 | + // Return the final string (without double {}) |
635 | 635 | return substr($str, 0, $inx['s']-1) . $translated . substr($str, $inx['e']+1); |
636 | 636 | } |
637 | 637 | } |
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 = 'r109'; |
| 8 | +var mwRemoteVersion = 'r110'; |
9 | 9 | |
10 | 10 | // Log the mwRemote version ( will determine what version of js we get ) |
11 | 11 | if( window.console ){ |