Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | result[ 'link' ] = result[ 'item_details_page' ]; |
261 | 261 | |
262 | 262 | var fileExtension = _this.getMimeExtension( result[ 'mime' ] ); |
263 | | - result[ 'titleKey' ] = result[ 'title' ] + '.' + fileExtension; |
| 263 | + result[ 'titleKey' ] = result[ 'titleKey' ] || ( result[ 'title' ] + '.' + fileExtension ); |
264 | 264 | |
265 | 265 | this.num_results++; |
266 | 266 | _this.resultsObj[ resource_id ] = result; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -1034,7 +1034,7 @@ |
1035 | 1035 | // Redraw ( with added result if new ) |
1036 | 1036 | _this.showResults(); |
1037 | 1037 | // Pull up resource editor: |
1038 | | - _this.showResourceEditor( resource, $j( '#res_this_wiki__' + resource.id ).get( 0 ) ); |
| 1038 | + _this.showResourceEditor( resource ); |
1039 | 1039 | } ); |
1040 | 1040 | // Return false to close progress window: |
1041 | 1041 | return false; |
— | — | @@ -1572,7 +1572,7 @@ |
1573 | 1573 | // Resource click action: (bring up the resource editor) |
1574 | 1574 | $j( '.rsd_res_item' ).unbind().click( function() { |
1575 | 1575 | var resource = _this.getResourceFromId( $j( this ).attr( "id" ) ); |
1576 | | - _this.showResourceEditor( resource, this ); |
| 1576 | + _this.showResourceEditor( resource ); |
1577 | 1577 | return false; |
1578 | 1578 | } ); |
1579 | 1579 | }, |
— | — | @@ -1682,12 +1682,11 @@ |
1683 | 1683 | /** |
1684 | 1684 | * Show the resource editor |
1685 | 1685 | * @param {Object} resource Resource to be edited |
1686 | | - * @param {Object} rsdElement Element Image to be swaped with "edit" version of resource |
1687 | 1686 | */ |
1688 | | - showResourceEditor: function( resource, rsdElement ) { |
| 1687 | + showResourceEditor: function( resource ) { |
1689 | 1688 | mw.log( 'f:showResourceEditor:' + resource.title ); |
1690 | 1689 | var _this = this; |
1691 | | - |
| 1690 | + |
1692 | 1691 | // Remove any existing resource edit interface |
1693 | 1692 | _this.removeResourceEditor(); |
1694 | 1693 | |
— | — | @@ -1703,42 +1702,20 @@ |
1704 | 1703 | |
1705 | 1704 | mw.log( 'did append to: ' + _this.target_container ); |
1706 | 1705 | |
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 | | - |
1736 | 1706 | if ( mediaType == 'image' ) { |
1737 | 1707 | _this.loadHighQualityImage( |
1738 | 1708 | resource, |
1739 | 1709 | { 'width': maxWidth }, |
1740 | 1710 | 'rsd_edit_img', |
1741 | | - function() { |
| 1711 | + function( img_src ) { |
1742 | 1712 | $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 | + |
1743 | 1720 | } |
1744 | 1721 | ); |
1745 | 1722 | } |
— | — | @@ -1790,13 +1767,12 @@ |
1791 | 1768 | 'height': imObj.height + 'px' |
1792 | 1769 | }); |
1793 | 1770 | } |
1794 | | - // Don't swap it in until its loaded: |
| 1771 | + // Don't swap it in until its loaded |
1795 | 1772 | var img = new Image(); |
1796 | | - // Load the image image: |
| 1773 | + // Load the image |
1797 | 1774 | $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 ); |
1801 | 1777 | } ).error( function () { |
1802 | 1778 | mw.log( "Error with: " + resource.edit_url ); |
1803 | 1779 | } ).attr( 'src', resource.edit_url ); |