\r
var switchLockRatio = function( dialog, value )\r
{\r
+ if ( !dialog.getContentElement( 'info', 'ratioLock' ) )\r
+ return null;\r
+\r
var oImageOriginal = dialog.originalElement;\r
\r
// Dialog may already closed. (#5505)\r
if( !oImageOriginal )\r
return null;\r
\r
- var ratioButton = CKEDITOR.document.getById( btnLockSizesId );\r
-\r
- if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )\r
+ // Check image ratio and original image ratio, but respecting user's preference.\r
+ if ( value == 'check' )\r
{\r
- if ( value == 'check' ) // Check image ratio and original image ratio.\r
+ if ( !dialog.userlockRatio && oImageOriginal.getCustomData( 'isReady' ) == 'true' )\r
{\r
var width = dialog.getValueOf( 'info', 'txtWidth' ),\r
height = dialog.getValueOf( 'info', 'txtHeight' ),\r
dialog.lockRatio = true;\r
}\r
}\r
- else if ( value != undefined )\r
- dialog.lockRatio = value;\r
- else\r
- dialog.lockRatio = !dialog.lockRatio;\r
}\r
- else if ( value != 'check' ) // I can't lock ratio if ratio is unknown.\r
- dialog.lockRatio = false;\r
+ else if ( value != undefined )\r
+ dialog.lockRatio = value;\r
+ else\r
+ {\r
+ dialog.userlockRatio = 1;\r
+ dialog.lockRatio = !dialog.lockRatio;\r
+ }\r
\r
+ var ratioButton = CKEDITOR.document.getById( btnLockSizesId );\r
if ( dialog.lockRatio )\r
ratioButton.removeClass( 'cke_btn_unlocked' );\r
else\r
var oImageOriginal = dialog.originalElement;\r
if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )\r
{\r
- dialog.setValueOf( 'info', 'txtWidth', oImageOriginal.$.width );\r
- dialog.setValueOf( 'info', 'txtHeight', oImageOriginal.$.height );\r
+ var widthField = dialog.getContentElement( 'info', 'txtWidth' ),\r
+ heightField = dialog.getContentElement( 'info', 'txtHeight' );\r
+ widthField && widthField.setValue( oImageOriginal.$.width );\r
+ heightField && heightField.setValue( oImageOriginal.$.height );\r
}\r
updatePreview( dialog );\r
};\r
\r
var dialog = this.getDialog(),\r
value = '',\r
- dimension = (( this.id == 'txtWidth' )? 'width' : 'height' ),\r
+ dimension = this.id == 'txtWidth' ? 'width' : 'height',\r
size = element.getAttribute( dimension );\r
\r
if ( size )\r
this.linkEditMode = false;\r
\r
this.lockRatio = true;\r
+ this.userlockRatio = 0;\r
this.dontResetSize = false;\r
this.firstLoad = true;\r
this.addLink = false;\r
\r
// Fill out all fields.\r
this.setupContent( IMAGE, this.imageElement );\r
-\r
- // Refresh LockRatio button\r
- switchLockRatio ( this, true );\r
}\r
else\r
this.imageElement = editor.document.createElement( 'img' );\r
\r
+ // Refresh LockRatio button\r
+ switchLockRatio ( this, true );\r
+\r
// Dont show preview if no URL given.\r
if ( !CKEDITOR.tools.trim( this.getValueOf( 'info', 'txtUrl' ) ) )\r
{\r
//Insert a new Link.\r
if ( !this.linkEditMode )\r
{\r
- editor.insertElement(this.linkElement);\r
- this.linkElement.append(this.imageElement, false);\r
+ editor.insertElement( this.linkElement );\r
+ this.linkElement.append( this.imageElement, false );\r
}\r
else //Link already exists, image not.\r
- editor.insertElement(this.imageElement );\r
+ editor.insertElement( this.imageElement );\r
}\r
else\r
editor.insertElement( this.imageElement );\r
if ( dialogType != 'image' )\r
this.hidePage( 'Link' ); //Hide Link tab.\r
var doc = this._.element.getDocument();\r
- this.addFocusable( doc.getById( btnResetSizeId ), 5 );\r
- this.addFocusable( doc.getById( btnLockSizesId ), 5 );\r
+\r
+ if ( this.getContentElement( 'info', 'ratioLock' ) )\r
+ {\r
+ this.addFocusable( doc.getById( btnResetSizeId ), 5 );\r
+ this.addFocusable( doc.getById( btnLockSizesId ), 5 );\r
+ }\r
\r
this.commitContent = commitContent;\r
},\r
children :\r
[\r
{\r
+ id : 'basic',\r
type : 'vbox',\r
children :\r
[\r
},\r
validate : function()\r
{\r
- var aMatch = this.getValue().match( regexGetSizeOrEmpty );\r
- if ( !aMatch )\r
+ var aMatch = this.getValue().match( regexGetSizeOrEmpty ),\r
+ isValid = !!( aMatch && parseInt( aMatch[1], 10 ) !== 0 );\r
+ if ( !isValid )\r
alert( editor.lang.common.invalidWidth );\r
- return !!aMatch;\r
+ return isValid;\r
},\r
setup : setupDimension,\r
commit : function( type, element, internalCommit )\r
{\r
if ( value )\r
element.setStyle( 'width', CKEDITOR.tools.cssLength( value ) );\r
- else if ( !value && this.isChanged( ) )\r
+ else\r
element.removeStyle( 'width' );\r
\r
!internalCommit && element.removeAttribute( 'width' );\r
},\r
validate : function()\r
{\r
- var aMatch = this.getValue().match( regexGetSizeOrEmpty );\r
- if ( !aMatch )\r
+ var aMatch = this.getValue().match( regexGetSizeOrEmpty ),\r
+ isValid = !!( aMatch && parseInt( aMatch[1], 10 ) !== 0 );\r
+ if ( !isValid )\r
alert( editor.lang.common.invalidHeight );\r
- return !!aMatch;\r
+ return isValid;\r
},\r
setup : setupDimension,\r
commit : function( type, element, internalCommit )\r
{\r
if ( value )\r
element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) );\r
- else if ( !value && this.isChanged( ) )\r
+ else\r
element.removeStyle( 'height' );\r
\r
- if ( !internalCommit && type == IMAGE )\r
- element.removeAttribute( 'height' );\r
+ !internalCommit && element.removeAttribute( 'height' );\r
}\r
else if ( type == PREVIEW )\r
{\r
]\r
},\r
{\r
+ id : 'ratioLock',\r
type : 'html',\r
style : 'margin-top:30px;width:40px;height:40px;',\r
onLoad : function()\r
ratioButton = CKEDITOR.document.getById( btnLockSizesId );\r
if ( resetButton )\r
{\r
- resetButton.on( 'click', function(evt)\r
+ resetButton.on( 'click', function( evt )\r
{\r
resetSize( this );\r
- evt.data.preventDefault();\r
+ evt.data && evt.data.preventDefault();\r
}, this.getDialog() );\r
resetButton.on( 'mouseover', function()\r
{\r
[\r
{\r
type : 'html',\r
+ id : 'htmlPreview',\r
style : 'width:95%;',\r
html : '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.common.preview ) +'<br>'+\r
'<div id="' + imagePreviewLoaderId + '" class="ImagePreviewLoader" style="display:none"><div class="loading"> </div></div>'+\r