r66430 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66429‎ | r66430 | r66431 >
Date:18:21, 14 May 2010
Author:dale
Status:deferred
Tags:
Comment:
fixed some firefogg gui bugs in updating width height
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.FirefoggGUI.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/ApiProxy/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedTextEdit.js (modified) (history)
  • /branches/MwEmbedStandAlone/tests/Firefogg_GUI.html (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/tests/Firefogg_GUI.html
@@ -2,8 +2,8 @@
33 <html><head>
44 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
55 <title>Firefogg - Make Ogg Video in your Browser</title>
6 - <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed"></script>
7 - <!-- <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> -->
 6+ <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed"></script>
 7+ <!--<script type="text/javascript" src="../mwEmbed.js?debug=true"></script> -->
88 <style type="text/css" media="all">
99 body {
1010 margin: 0;
Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedTextEdit.js
@@ -426,7 +426,7 @@
427427
428428 // Build cancel button
429429 var cancelButton = {};
430 - var cancelText = gM( 'mwe-timedtext-cancel' );
 430+ var cancelText = gM( 'mwe-cancel' );
431431 cancelButton[ cancelText ] = function() {
432432 _this.onCancelClipEdit();
433433 };
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.FirefoggGUI.js
@@ -487,7 +487,7 @@
488488 'maxlength="' + maxDigits + '" ' +
489489 'size="' + maxDigits + '" ' +
490490 'class="_' + configKey + ' text ui-widget-content ui-corner-all" ' +
491 - 'style="display:inline;border:0; color:#f6931f; font-weight:bold;" ' +
 491+ 'style="display:inline; color:#f6931f; padding: 2px; font-weight:bold;" ' +
492492 'value="' + defaultValue + '" >' +
493493 '<div class="slider_' + configKey + '"></div>';
494494 break;
@@ -574,7 +574,7 @@
575575 $j( this.target_input_file_name ).width( 250 );
576576
577577 // Special preset action
578 - $j( this.selector + ' ._preset_select' ).change( function() {
 578+ $j( this.selector + ' ._preset_select' ).change( function() {
579579 _this.updatePresetSelection( $j( this ).val() );
580580 });
581581
@@ -634,7 +634,7 @@
635635 $j( this.selector + ' ._' + configKey)
636636 .click( function() {
637637 _this.updateLocalValue( _this.getClassId( this ),
638 - $j( this ).is( ":checked" ) );
 638+ $j( this ).is( ":checked" ) );
639639 _this.updatePresetSelection( 'custom' );
640640 });
641641 break;
@@ -643,10 +643,11 @@
644644 case 'int':
645645 case 'float':
646646 // Check if we have a validate function on the string
647 - $j( this.selector + ' ._' + configKey ).change( function() {
 647+ $j( this.selector + ' ._' + configKey ).change( function() {
648648 $j( this ).val( _this.updateLocalValue(
649649 _this.getClassId( this ),
650 - $j( this ).val() ) );
 650+ $j( this ).val() )
 651+ );
651652 _this.updatePresetSelection( 'custom' );
652653 })
653654 break;
@@ -660,8 +661,30 @@
661662 }
662663 });
663664 break;
664 - case 'slider':
665 - //var sliderId = _this.getClassId( this, 'slider_' );
 665+ case 'slider':
 666+ /**
 667+ * Return true or false of out of range and update the related value
 668+ */
 669+ var keepAspectRatio = function( sliderId, value ){
 670+ // Maintain source video aspect ratio
 671+ if ( sliderId == 'width' ) {
 672+ var sourceHeight = _this.sourceFileInfo.video[0]['height'];
 673+ var sourceWidth = _this.sourceFileInfo.video[0]['width'];
 674+ var newHeight = parseInt( sourceHeight / sourceWidth * value );
 675+ // Reject the update if the new height is above the maximum
 676+ if ( newHeight > _this.updateInterfaceValue( 'height', newHeight ) )
 677+ return false;
 678+ }
 679+ if ( sliderId == 'height' ) {
 680+ var sourceHeight = _this.sourceFileInfo.video[0]['height'];
 681+ var sourceWidth = _this.sourceFileInfo.video[0]['width'];
 682+ var newWidth = parseInt( sourceWidth / sourceHeight * value );
 683+ // Reject the update if the new width is above the maximum
 684+ if ( newWidth > _this.updateInterfaceValue( 'width', newWidth ) )
 685+ return false;
 686+ }
 687+ };
 688+
666689 $j( this.selector + ' .slider_' + configKey ).slider({
667690 range: "min",
668691 animate: true,
@@ -670,27 +693,13 @@
671694 min: this.default_encoder_config[ configKey ].range.min,
672695 max: this.default_encoder_config[ configKey ].range.max,
673696 slide: function( event, ui ) {
 697+ var sliderId = _this.getClassId( this, 'slider_' );
674698 $j( _this.selector + ' ._' + sliderId ).val( ui.value );
675699
676 - // Maintain source video aspect ratio
677 - if ( sliderId == 'width' ) {
678 - var sourceHeight = _this.sourceFileInfo.video[0]['height'];
679 - var sourceWidth = _this.sourceFileInfo.video[0]['width'];
680 - var newHeight = parseInt( sourceHeight / sourceWidth * ui.value );
681 - // Reject the update if the new height is above the maximum
682 - if ( newHeight > _this.updateInterfaceValue( 'height', newHeight ) )
683 - return false;
684 - }
685 - if ( sliderId == 'height' ) {
686 - var sourceHeight = _this.sourceFileInfo.video[0]['height'];
687 - var sourceWidth = _this.sourceFileInfo.video[0]['width'];
688 - var newWidth = parseInt( sourceWidth / sourceHeight * ui.value );
689 - // Reject the update if the new width is above the maximum
690 - if ( newWidth > _this.updateInterfaceValue( 'width', wv ) )
691 - return false;
692 - }
 700+ keepAspectRatio( sliderId, ui.value );
693701 },
694702 change: function( event, ui ) {
 703+ var sliderId = _this.getClassId( this, 'slider_' );
695704 _this.updateLocalValue( sliderId, ui.value );
696705 _this.updatePresetSelection( 'custom' );
697706 }
@@ -698,15 +707,18 @@
699708
700709 $j( this.selector + ' ._' + configKey ).change( function() {
701710 var classId = _this.getClassId( this );
702 - var validValue = _this.updateLocalValue( classId.substr( 1 ),
703 - $j( this ).val() );
 711+ var validValue = _this.updateLocalValue( classId,
 712+ $j( this ).val()
 713+ );
704714 _this.updatePresetSelection( 'custom' );
705715 // Change it to the validated value
706716 $j( this ).val( validValue );
707717 // update the slider
708 - mw.log( "update: " + _this.selector + ' .slider' + classId );
709 - $j( _this.selector + ' .slider' + classId )
710 - .slider( 'option', 'value', validValue );
 718+ //mw.log( "update: " + _this.selector + ' .slider' + classId );
 719+ $j( _this.selector + ' .slider_' + classId )
 720+ .slider('value', validValue );
 721+ // Keep aspect ratio:
 722+ keepAspectRatio( classId, validValue );
711723 });
712724 break;
713725 }
@@ -729,7 +741,7 @@
730742 updatePresetSelection: function( presetKey ) {
731743 // Update the local configuration
732744 this.local_settings['default'] = presetKey;
733 - // mw.log( 'update preset desc: ' + presetKey );
 745+ mw.log( 'update preset desc: ' + presetKey );
734746 var presetDesc = '';
735747 if ( this.local_settings.presets[presetKey].desc ) {
736748 presetDesc = this.local_settings.presets[presetKey].desc;
@@ -778,8 +790,8 @@
779791 * range if required. Update the configuration with the validated value and
780792 * return it.
781793 */
782 - updateLocalValue: function( confKey, value ) {
783 - if ( typeof this.default_encoder_config[confKey] == 'undefined' ) {
 794+ updateLocalValue: function( confKey, value ) {
 795+ if ( typeof this.default_encoder_config[confKey] == 'undefined' ) {
784796 mw.log( "Error: could not update conf key: " + confKey )
785797 return value;
786798 }
@@ -824,14 +836,14 @@
825837 * If no prefix is given, "_" is assumed.
826838 */
827839 getClassId: function( element, prefix ) {
828 - var eltClass = $j( element ).attr( "class" ).split( ' ' ).slice( 0, 1 ).toString();
829 -
 840+
 841+ var eltClass = $j( element ).attr( "class" ).split( ' ' ).slice( 0, 1 ).toString();
830842 if ( !prefix ) {
831843 prefix = '_';
832844 }
833845 if ( eltClass.substr( 0, prefix.length ) == prefix ) {
834846 eltClass = eltClass.substr( prefix.length );
835 - }
 847+ }
836848 return eltClass;
837849 },
838850
@@ -985,7 +997,7 @@
986998 var pKey = this.local_settings[ 'default' ];
987999 this.updatePresetSelection( pKey );
9881000
989 - // set the actual HTML & widgets based on any local settings values:
 1001+ // Set the actual HTML & widgets based on any local settings values:
9901002 $j.each( _this.local_settings.presets['custom']['conf'], function( inx, val ) {
9911003 if ( $j( _this.selector + ' ._' + inx ).length != 0 ) {
9921004 $j( _this.selector + ' ._' + inx ).val( val );
Index: branches/MwEmbedStandAlone/modules/ApiProxy/loader.js
@@ -1,7 +1,7 @@
22 /* apiProxy Loader */
33
44 mw.addClassFilePaths( {
5 - "mw.ApiProxy" : "mw.ApiProxy.js",
 5+ "mw.ApiProxy" : "mw.ApiProxy.js"
66 } );
77
88 mw.addModuleLoader( 'ApiProxy', function( callback ) {
Index: branches/MwEmbedStandAlone/modules/ApiProxy/mw.ApiProxy.js
@@ -17,18 +17,21 @@
1818 * having a separate class for "server" and "client" api usage
1919 *
2020 */
21 -
 21+/*
2222 mw.addMessages( {
23 - "mwe-setting-up-proxy" : "Setting up proxy...",
24 - "mwe-re-try" : "Retry API request",
25 - "mwe-re-trying" : "Retrying API request...",
26 - "mwe-proxy-not-ready" : "Proxy is not configured",
27 - "mwe-please-login" : "The request failed. Are you logged in on $1 ? Please $2 and try again",
28 - "mwe-log-in-link" : "log in",
29 - "mwe-remember-loging" : "General security reminder: Only login to web sites when your address bar displays that site's address."
 23+ "mwe-apiproxy-setting-up-proxy" : "Setting up proxy...",
 24+ "mwe-apiproxy-re-try" : "Retry API request",
 25+ "mwe-apiproxy-re-trying" : "Retrying API request...",
 26+ "mwe-apiproxy-proxy-not-ready" : "Proxy is not configured",
 27+ "mwe-apiproxy-please-login" : "The request failed. Are you logged in on $1 ? Please $2 and try again",
 28+ "mwe-apiproxy-log-in-link" : "log in",
 29+ "mwe-apiproxy-remember-loging" : "General security reminder: Only login to web sites when your address bar displays that site's address."
3030 } );
 31+*/
3132
 33+mw.includeAllModuleMsgs();
3234
 35+
3336 /**
3437 * apiProxy jQuery binding
3538 *
@@ -556,12 +559,12 @@
557560 }
558561
559562 var buttons = { };
560 - buttons[ gM( 'mwe-re-try' ) ] = function() {
561 - mw.addLoaderDialog( gM( 'mwe-re-trying' ) );
 563+ buttons[ gM( 'mwe-apiproxy-re-try' ) ] = function() {
 564+ mw.addLoaderDialog( gM( 'mwe-apiproxy-re-trying' ) );
562565 // Re try the same context request:
563566 doFrameProxy( context );
564567 }
565 - buttons[ gM( 'mwe-cancel' ) ] = function() {
 568+ buttons[ gM( 'mwe-apiproxy-cancel' ) ] = function() {
566569 mw.closeLoaderDialog ( );
567570 }
568571
@@ -572,7 +575,7 @@
573576
574577 var $dialogMsg = $j('<p />');
575578 $dialogMsg.append(
576 - gM( 'mwe-please-login',
 579+ gM( 'mwe-apiproxy-please-login',
577580 pUri.host,
578581
579582 // Add log-in link:
@@ -581,17 +584,17 @@
582585 'href' : login_url,
583586 'target' : '_new'
584587 } )
585 - .text( gM('mwe-log-in-link') )
 588+ .text( gM('mwe-apiproxy-log-in-link') )
586589 )
587590 )
588591 // Add the security note as well:
589592 $dialogMsg.append(
590593 $j('<br />'),
591 - gM( 'mwe-remember-loging' )
 594+ gM( 'mwe-apiproxy-remember-loging' )
592595 )
593596
594597 mw.addDialog(
595 - gM( 'mwe-proxy-not-ready' ),
 598+ gM( 'mwe-apiproxy-proxy-not-ready' ),
596599 $dialogMsg,
597600 buttons
598601 )

Status & tagging log