r61847 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61846‎ | r61847 | r61848 >
Date:08:30, 2 February 2010
Author:shmichael
Status:deferred
Tags:
Comment:
* Fixed wiki-commons titleKey not being correctly identified in Kaltura searches
* Changed showResourceEditor (in RemoteSearchDriver) to display a spinner instead
of a thumbnail. This seems to have made the method's second param redundant, so it has
been trimmed.
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js
@@ -259,7 +259,7 @@
260260 result[ 'link' ] = result[ 'item_details_page' ];
261261
262262 var fileExtension = _this.getMimeExtension( result[ 'mime' ] );
263 - result[ 'titleKey' ] = result[ 'title' ] + '.' + fileExtension;
 263+ result[ 'titleKey' ] = result[ 'titleKey' ] || ( result[ 'title' ] + '.' + fileExtension );
264264
265265 this.num_results++;
266266 _this.resultsObj[ resource_id ] = result;
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -1034,7 +1034,7 @@
10351035 // Redraw ( with added result if new )
10361036 _this.showResults();
10371037 // Pull up resource editor:
1038 - _this.showResourceEditor( resource, $j( '#res_this_wiki__' + resource.id ).get( 0 ) );
 1038+ _this.showResourceEditor( resource );
10391039 } );
10401040 // Return false to close progress window:
10411041 return false;
@@ -1572,7 +1572,7 @@
15731573 // Resource click action: (bring up the resource editor)
15741574 $j( '.rsd_res_item' ).unbind().click( function() {
15751575 var resource = _this.getResourceFromId( $j( this ).attr( "id" ) );
1576 - _this.showResourceEditor( resource, this );
 1576+ _this.showResourceEditor( resource );
15771577 return false;
15781578 } );
15791579 },
@@ -1682,12 +1682,11 @@
16831683 /**
16841684 * Show the resource editor
16851685 * @param {Object} resource Resource to be edited
1686 - * @param {Object} rsdElement Element Image to be swaped with "edit" version of resource
16871686 */
1688 - showResourceEditor: function( resource, rsdElement ) {
 1687+ showResourceEditor: function( resource ) {
16891688 mw.log( 'f:showResourceEditor:' + resource.title );
16901689 var _this = this;
1691 -
 1690+
16921691 // Remove any existing resource edit interface
16931692 _this.removeResourceEditor();
16941693
@@ -1703,42 +1702,20 @@
17041703
17051704 mw.log( 'did append to: ' + _this.target_container );
17061705
1707 - // Try and keep aspect ratio for the thumbnail that we clicked:
1708 - var imageRatio = null;
1709 - try {
1710 - imageRatio = $j( rsdElement ).get(0).height / $j( rsdElement ).get(0).width;
1711 - } catch( e ) {
1712 - mw.log( 'Error: browser could not read height or width attribute' ) ;
1713 - }
1714 - if ( !imageRatio ) {
1715 - var imageRatio = 1; // set ratio to 1 if tRatio did not work.
1716 - }
1717 -
1718 - $j( rsdElement )
1719 - .clone()
1720 - .attr( { id : 'rsd_edit_img' } )
1721 - .appendTo( '#clip_edit_disp' )
1722 - .css( {
1723 - 'position':'absolute',
1724 - 'top': '5px',
1725 - 'left': '5px',
1726 - 'cursor': 'default',
1727 - 'opacity': 1,
1728 - 'width': maxWidth + 'px',
1729 - 'height': parseInt( imageRatio * maxWidth ) + 'px'
1730 - } );
1731 -
1732 -
1733 - mw.log( 'Set from ' + imageRatio + ' to init thumbimage to ' +
1734 - maxWidth + ' x ' + parseInt( imageRatio * maxWidth ) );
1735 -
17361706 if ( mediaType == 'image' ) {
17371707 _this.loadHighQualityImage(
17381708 resource,
17391709 { 'width': maxWidth },
17401710 'rsd_edit_img',
1741 - function() {
 1711+ function( img_src ) {
17421712 $j( '.loading_spinner' ).remove();
 1713+ $j( '<img />' )
 1714+ .attr( {
 1715+ id: 'rsd_edit_img',
 1716+ src: img_src
 1717+ } )
 1718+ .appendTo( '#clip_edit_disp' );
 1719+
17431720 }
17441721 );
17451722 }
@@ -1790,13 +1767,12 @@
17911768 'height': imObj.height + 'px'
17921769 });
17931770 }
1794 - // Don't swap it in until its loaded:
 1771+ // Don't swap it in until its loaded
17951772 var img = new Image();
1796 - // Load the image image:
 1773+ // Load the image
17971774 $j( img ).load( function () {
1798 - $j( '#' + target_img_id ).attr( 'src', resource.edit_url );
1799 - // Let the caller know we are done and what size we ended up with:
1800 - callback();
 1775+ // Update changes using the callback
 1776+ callback( resource.edit_url );
18011777 } ).error( function () {
18021778 mw.log( "Error with: " + resource.edit_url );
18031779 } ).attr( 'src', resource.edit_url );

Status & tagging log