Ticket #2819: 2819.patch
File 2819.patch, 4.8 KB (added by , 15 years ago) |
---|
-
image.js
49 49 CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); 50 50 51 51 // New image -> new domensions 52 if ( this.forceResetSize ) {52 if ( this.forceResetSize ) 53 53 resetSize( this ); 54 } 54 55 updatePreview( this ); 56 if ( this.firstLoad ) 57 switchLockRatio( this, 'check' ); 58 this.firstLoad = false; 55 59 } 56 60 var onImgLoadError = function() 57 61 { … … 146 150 { 147 151 if ( !dialog.editObj[ 'imagePreview' ] ) 148 152 return 1; 149 150 var oImageOriginal = dialog.editObj[ 'imageOriginal' ]; 151 if ( oImageOriginal && oImageOriginal.getCustomData( 'isReady' ) == 'true' && showPreview ) 153 if ( showPreview ) 152 154 { 155 var imageOriginal = dialog.editObj[ 'imageOriginal' ]; 153 156 var width = dialog.getValueOf( 'info', 'txtWidth' ); 154 157 var height = dialog.getValueOf( 'info', 'txtHeight' ); 155 158 156 if ( width == '' && oImageOriginal ) 157 width = oImageOriginal.$.width; 158 if ( height == '' && oImageOriginal ) 159 height = oImageOriginal.$.height; 159 if ( !!imageOriginal && dialog.editObj[ 'imageOriginal' ].getCustomData( 'isReady' ) == 'true' ) 160 { 161 if ( width == '' ) 162 width = imageOriginal.$.width; 163 if ( height == '' ) 164 height = imageOriginal.$.height; 165 } 160 166 161 167 dialog.editObj[ 'imagePreview' ].setStyle( 'width', width + 'px'); 162 168 dialog.editObj[ 'imagePreview' ].setStyle( 'height', height + 'px'); … … 228 234 var oImageOriginal = dialog.editObj[ 'imageOriginal' ]; 229 235 if ( oImageOriginal && oImageOriginal.getCustomData( 'isReady' ) == 'true' ) 230 236 { 231 if ( value != undefined ) 237 if ( value == 'check' ) 238 { 239 dialog.imageLockRatio = false; // Default: unlock ratio 240 241 var width = dialog.getValueOf( 'info', 'txtWidth' ); 242 var height = dialog.getValueOf( 'info', 'txtHeight' ); 243 var originalRatio = oImageOriginal.$.width * 1000 / oImageOriginal.$.height; 244 var thisRatio = width * 1000 / height; 245 246 if ( width == 0 && height == 0 ) 247 dialog.imageLockRatio = true; 248 else if ( !isNaN( originalRatio ) && !isNaN( thisRatio )) 249 if ( Math.round( originalRatio ) == Math.round( thisRatio ) ) 250 dialog.imageLockRatio = true; 251 } 252 else if ( value != undefined ) 232 253 dialog.imageLockRatio = value 233 254 else 234 255 dialog.imageLockRatio = !dialog.imageLockRatio; 235 256 } 236 else 257 else if ( value != 'check' ) 237 258 dialog.imageLockRatio = false; 238 259 239 260 var ratioButton = CKEDITOR.document.getById( 'btnLockSizes' ); … … 255 276 dialog.setValueOf( 'info', 'txtHeight', oImageOriginal.$.height ); 256 277 dialog.allowOnChange = true; 257 278 } 258 updatePreview( dialog );259 279 } 260 280 var readSize = function( dialog ) 261 281 { … … 385 405 if ( !this.editObj[ 'image' ] ) 386 406 this.editObj[ 'image' ] = element; 387 407 388 updateOriginal( this, true );389 readSize( this );390 391 408 var imgObject = this.editObj[ 'image' ]; 392 409 393 410 // Fill out all fields. … … 410 427 411 428 readAttribute.apply( this, [ 'advanced', 'class', 'txtGenClass', imgObject ] ); 412 429 readAttribute.apply( this, [ 'advanced', 'title', 'txtGenTitle', imgObject ] ); 430 431 updateOriginal( this, false ); 432 readSize( this ); 413 433 } 414 updatePreview( this );415 434 416 435 return false; 417 436 }; … … 558 577 this.dimensionsInStyle[ 'width' ] = false; 559 578 this.dimensionsInStyle[ 'height' ] = false; 560 579 this.forceResetSize = false; 580 this.firstLoad = true; 561 581 562 582 // IE BUG: Selection must be in the editor for getSelection() to work. 563 583 this.restoreSelection(); … … 606 626 } 607 627 } 608 628 updateOriginal( this, false ); 609 updatePreview( this );610 629 611 630 if ( !showPreview ) 612 631 { … … 642 661 resetButton.on( 'click', function() 643 662 { 644 663 resetSize( this ); 664 updatePreview( this ); 645 665 }, this ); 646 666 resetButton.on( 'mouseover', function() 647 667 { … … 659 679 { 660 680 ratioButton.on( 'click', function() 661 681 { 662 var btnLockSizes = CKEDITOR.document.getById( 'btnLockSizes' );663 682 switchLockRatio( this ); 664 683 }, this ); 665 684 ratioButton.on( 'mouseover', function() … … 783 802 id : 'txtWidth', 784 803 labelLayout : 'horizontal', 785 804 label : editor.lang.image.width, 786 on Change: function()805 onKeyUp : function() 787 806 { 788 807 onSizeChange( this ); 789 808 }, … … 808 827 id : 'txtHeight', 809 828 labelLayout : 'horizontal', 810 829 label : editor.lang.image.height, 811 on Change: function()830 onKeyUp : function() 812 831 { 813 832 onSizeChange( this ); 814 833 },