r63791 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63790‎ | r63791 | r63792 >
Date:00:26, 16 March 2010
Author:dale
Status:deferred
Tags:
Comment:
some resource edit aspect fixes ( just a stop-gap until we support setting size as a tool /control )
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -156,7 +156,10 @@
157157 'default_provider': null,
158158
159159 // The timeout for search providers ( in seconds )
160 - 'search_provider_timeout': 10
 160+ 'search_provider_timeout': 10,
 161+
 162+ // Default edit image width
 163+ 'defaultEditImageWidth' : 400
161164 };
162165
163166 /**
@@ -421,10 +424,10 @@
422425 thumb_width: 80,
423426
424427 // The width of an image when editing
425 - image_edit_width: 400,
 428+ defaultImageEditWidth: 400,
426429
427430 // The width of the video embed while editing the resource
428 - video_edit_width: 400,
 431+ defaultVideoEditWidth: 400,
429432
430433 // The insert position of the asset (overwritten by cursor position)
431434 insert_text_pos: 0,
@@ -1959,12 +1962,12 @@
19601963 *
19611964 * @param {Object} resource get width of resource
19621965 */
1963 - getMaxEditWidth: function( resource ) {
 1966+ getDefaultEditWidth: function( resource ) {
19641967 var mediaType = this.getMediaType( resource );
19651968 if ( mediaType == 'image' ) {
1966 - return this.image_edit_width;
 1969+ return this.defaultImageEditWidth;
19671970 } else {
1968 - return this.video_edit_width;
 1971+ return this.defaultVideoEditWidth;
19691972 }
19701973 },
19711974
@@ -2011,23 +2014,17 @@
20122015 mw.log("done adding resource editor");
20132016
20142017 var mediaType = _this.getMediaType( resource );
2015 - var width = _this.getMaxEditWidth( resource );
 2018+ var width = _this.getDefaultEditWidth( resource );
20162019
2017 - // if maxWidth makes height > available height resize request:
2018 -
2019 - var width = resource.width;
2020 - var height = parseInt( width * ( resource.width / resource.height ) );
2021 -
2022 - // Update the resource size constrained by clip_edit_disp
2023 - if( width > $j('#clip_edit_disp').width() ){
2024 - width = $j('#clip_edit_disp').width();
2025 - height = parseInt( width * ( height / width ) );
2026 - }
 2020+ var height = parseInt( width * ( resource.height / resource.width ) );
 2021+
20272022 if( height > $j('#clip_edit_disp').height() ){
20282023 height = $j('#clip_edit_disp').height();
2029 - width = height * ( width / height );
 2024+ width = height * ( resource.width / resource.height);
20302025 }
20312026
 2027+ //mw.log("org h/w" + resource.width + ' / ' + resource.height +' new w' + width + ' new h:' + height );
 2028+
20322029 // Update add media wizard title:
20332030 var dialogTitle = gM( 'mwe-add_media_wizard' ) + ': ' +
20342031 gM( 'rsd_resource_edit', resource.title );

Status & tagging log