/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, 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
ratioButton.addClass( 'cke_btn_unlocked' );\r
\r
- var lang = dialog._.editor.lang.image,\r
- label = lang[ dialog.lockRatio ? 'unlockRatio' : 'lockRatio' ];\r
+ ratioButton.setAttribute( 'aria-checked', dialog.lockRatio );\r
\r
- ratioButton.setAttribute( 'title', label );\r
- ratioButton.getFirst().setText( label );\r
+ // Ratio button hc presentation - WHITE SQUARE / BLACK SQUARE\r
+ if ( CKEDITOR.env.hc )\r
+ {\r
+ var icon = ratioButton.getChild( 0 );\r
+ icon.setHtml( dialog.lockRatio ? CKEDITOR.env.ie ? '\u25A0': '\u25A3' : CKEDITOR.env.ie ? '\u25A1' : '\u25A2' );\r
+ }\r
\r
return dialog.lockRatio;\r
};\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
btnLockSizesId = numbering( 'btnLockSizes' ),\r
btnResetSizeId = numbering( 'btnResetSize' ),\r
imagePreviewLoaderId = numbering( 'ImagePreviewLoader' ),\r
- imagePreviewBoxId = numbering( 'ImagePreviewBox' ),\r
previewLinkId = numbering( 'previewLink' ),\r
previewImageId = numbering( 'previewImage' );\r
\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
var editor = this.getParentEditor(),\r
- sel = this.getParentEditor().getSelection(),\r
- element = sel.getSelectedElement(),\r
+ sel = editor.getSelection(),\r
+ element = sel && sel.getSelectedElement(),\r
link = element && element.getAscendant( 'a' );\r
\r
//Hide loader.\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
updatePreview( this );\r
}\r
}\r
- evt.data.preventDefault();\r
+ evt.data && evt.data.preventDefault();\r
}, this.getDialog() );\r
ratioButton.on( 'mouseover', function()\r
{\r
}\r
},\r
html : '<div>'+\r
- '<a href="javascript:void(0)" tabindex="-1" title="' + editor.lang.image.unlockRatio +\r
- '" class="cke_btn_locked" id="' + btnLockSizesId + '" role="button"><span class="cke_label">' + editor.lang.image.unlockRatio + '</span></a>' +\r
+ '<a href="javascript:void(0)" tabindex="-1" title="' + editor.lang.image.lockRatio +\r
+ '" class="cke_btn_locked" id="' + btnLockSizesId + '" role="checkbox"><span class="cke_icon"></span><span class="cke_label">' + editor.lang.image.lockRatio + '</span></a>' +\r
'<a href="javascript:void(0)" tabindex="-1" title="' + editor.lang.image.resetSize +\r
'" class="cke_btn_reset" id="' + btnResetSizeId + '" role="button"><span class="cke_label">' + editor.lang.image.resetSize + '</span></a>'+\r
'</div>'\r
element.setStyle( 'border-style', 'solid' );\r
}\r
else if ( !value && this.isChanged() )\r
- {\r
- element.removeStyle( 'border-width' );\r
- element.removeStyle( 'border-style' );\r
- element.removeStyle( 'border-color' );\r
- }\r
+ element.removeStyle( 'border' );\r
\r
if ( !internalCommit && type == IMAGE )\r
element.removeAttribute( 'border' );\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
- '<div id="' + imagePreviewBoxId + '" class="ImagePreviewBox"><table><tr><td>'+\r
+ '<div class="ImagePreviewBox"><table><tr><td>'+\r
'<a href="javascript:void(0)" target="_blank" onclick="return false;" id="' + previewLinkId + '">'+\r
'<img id="' + previewImageId + '" alt="" /></a>' +\r
( editor.config.image_previewText ||\r
type : 'text',\r
id : 'txtdlgGenStyle',\r
label : editor.lang.common.cssStyle,\r
+ validate : CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ),\r
'default' : '',\r
setup : function( type, element )\r
{\r