/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\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
previewImageId = numbering( 'previewImage' );\r
\r
return {\r
- title : ( dialogType == 'image' ) ? editor.lang.image.title : editor.lang.image.titleButton,\r
+ title : editor.lang.image[ dialogType == 'image' ? 'title' : 'titleButton' ],\r
minWidth : 420,\r
- minHeight : 310,\r
+ minHeight : 360,\r
onShow : function()\r
{\r
this.imageElement = false;\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
this.setupContent( LINK, link );\r
}\r
\r
- if ( element && element.getName() == 'img' && !element.getAttribute( '_cke_realelement' )\r
+ if ( element && element.getName() == 'img' && !element.data( 'cke-realelement' )\r
|| element && element.getName() == 'input' && element.getAttribute( 'type' ) == 'image' )\r
{\r
this.imageEditMode = element.getName();\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
{\r
if ( type == IMAGE )\r
{\r
- var url = element.getAttribute( '_cke_saved_src' ) || element.getAttribute( 'src' );\r
+ var url = element.data( 'cke-saved-src' ) || element.getAttribute( 'src' );\r
var field = this;\r
\r
this.getDialog().dontResetSize = true;\r
field.setValue( url ); // And call this.onChange()\r
// Manually set the initial value.(#4191)\r
field.setInitValue();\r
- field.focus();\r
}\r
},\r
commit : function( type, element )\r
{\r
if ( type == IMAGE && ( this.getValue() || this.isChanged() ) )\r
{\r
- element.setAttribute( '_cke_saved_src', decodeURI( this.getValue() ) );\r
- element.setAttribute( 'src', decodeURI( this.getValue() ) );\r
+ element.data( 'cke-saved-src', this.getValue() );\r
+ element.setAttribute( 'src', this.getValue() );\r
}\r
else if ( type == CLEANUP )\r
{\r
},\r
{\r
type : 'hbox',\r
- widths : [ '140px', '240px' ],\r
children :\r
[\r
{\r
+ id : 'basic',\r
type : 'vbox',\r
- padding : 10,\r
children :\r
[\r
{\r
type : 'hbox',\r
- widths : [ '70%', '30%' ],\r
+ widths : [ '50%', '50%' ],\r
children :\r
[\r
{\r
type : 'text',\r
width: '40px',\r
id : 'txtWidth',\r
- labelLayout : 'horizontal',\r
- label : editor.lang.image.width,\r
+ label : editor.lang.common.width,\r
onKeyUp : onSizeChange,\r
onChange : function()\r
{\r
},\r
validate : function()\r
{\r
- var aMatch = this.getValue().match( regexGetSizeOrEmpty );\r
- if ( !aMatch )\r
- alert( editor.lang.image.validateWidth );\r
- return !!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 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
type : 'text',\r
id : 'txtHeight',\r
width: '40px',\r
- labelLayout : 'horizontal',\r
- label : editor.lang.image.height,\r
+ label : editor.lang.common.height,\r
onKeyUp : onSizeChange,\r
onChange : function()\r
{\r
},\r
validate : function()\r
{\r
- var aMatch = this.getValue().match( regexGetSizeOrEmpty );\r
- if ( !aMatch )\r
- alert( editor.lang.image.validateHeight );\r
- return !!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 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:10px;width:40px;height:40px;',\r
+ style : 'margin-top:30px;width:40px;height:40px;',\r
onLoad : function()\r
{\r
// Activate Reset button\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
type : 'text',\r
id : 'txtBorder',\r
width: '60px',\r
- labelLayout : 'horizontal',\r
label : editor.lang.image.border,\r
'default' : '',\r
onKeyUp : function()\r
type : 'text',\r
id : 'txtHSpace',\r
width: '60px',\r
- labelLayout : 'horizontal',\r
label : editor.lang.image.hSpace,\r
'default' : '',\r
onKeyUp : function()\r
type : 'text',\r
id : 'txtVSpace',\r
width : '60px',\r
- labelLayout : 'horizontal',\r
label : editor.lang.image.vSpace,\r
'default' : '',\r
onKeyUp : function()\r
{\r
id : 'cmbAlign',\r
type : 'select',\r
- labelLayout : 'horizontal',\r
widths : [ '35%','65%' ],\r
style : 'width:90px',\r
- label : editor.lang.image.align,\r
+ label : editor.lang.common.align,\r
'default' : '',\r
items :\r
[\r
[ editor.lang.common.notSet , ''],\r
- [ editor.lang.image.alignLeft , 'left'],\r
- [ editor.lang.image.alignRight , 'right']\r
+ [ editor.lang.common.alignLeft , 'left'],\r
+ [ editor.lang.common.alignRight , 'right']\r
// Backward compatible with v2 on setup when specified as attribute value,\r
// while these values are no more available as select options.\r
// [ editor.lang.image.alignAbsBottom , 'absBottom'],\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
{\r
if ( type == LINK )\r
{\r
- var href = element.getAttribute( '_cke_saved_href' );\r
+ var href = element.data( 'cke-saved-href' );\r
if ( !href )\r
href = element.getAttribute( 'href' );\r
this.setValue( href );\r
{\r
if ( this.getValue() || this.isChanged() )\r
{\r
- element.setAttribute( '_cke_saved_href', decodeURI( this.getValue() ) );\r
- element.setAttribute( 'href', 'javascript:void(0)/*' +\r
- CKEDITOR.tools.getNextNumber() + '*/' );\r
+ var url = decodeURI( this.getValue() );\r
+ element.data( 'cke-saved-href', url );\r
+ element.setAttribute( 'href', url );\r
\r
if ( this.getValue() || !editor.config.image_removeLinkByEmptyURL )\r
this.getDialog().addLink = true;\r
{\r
action : 'Browse',\r
target: 'Link:txtUrl',\r
- url: editor.config.filebrowserImageBrowseLinkUrl || editor.config.filebrowserBrowseUrl\r
+ url: editor.config.filebrowserImageBrowseLinkUrl\r
},\r
style : 'float:right',\r
hidden : true,\r
setup : function( type, element )\r
{\r
if ( type == LINK )\r
- this.setValue( element.getAttribute( 'target' ) );\r
+ this.setValue( element.getAttribute( 'target' ) || '' );\r
},\r
commit : function( type, element )\r
{\r