X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fimage%2Fdialogs%2Fimage.js;h=8902f9b3c0d5f4035659e946add277373cd1d8d9;hb=e73319a12b56100b29ef456fd74114fe5519e01c;hp=3ba0dc1f8d0242a01c353140885d40ed99160d73;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;p=ckeditor.git diff --git a/_source/plugins/image/dialogs/image.js b/_source/plugins/image/dialogs/image.js index 3ba0dc1..8902f9b 100644 --- a/_source/plugins/image/dialogs/image.js +++ b/_source/plugins/image/dialogs/image.js @@ -1,206 +1,220 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { - // Load image preview. - var IMAGE = 1, - LINK = 2, - PREVIEW = 4, - CLEANUP = 8, - regexGetSize = /^\s*(\d+)((px)|\%)?\s*$/i, - regexGetSizeOrEmpty = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i, - pxLengthRegex = /^\d+px$/; - - var onSizeChange = function() + var imageDialog = function( editor, dialogType ) { - var value = this.getValue(), // This = input element. - dialog = this.getDialog(), - aMatch = value.match( regexGetSize ); // Check value - if ( aMatch ) + // Load image preview. + var IMAGE = 1, + LINK = 2, + PREVIEW = 4, + CLEANUP = 8, + regexGetSize = /^\s*(\d+)((px)|\%)?\s*$/i, + regexGetSizeOrEmpty = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i, + pxLengthRegex = /^\d+px$/; + + var onSizeChange = function() { - if ( aMatch[2] == '%' ) // % is allowed - > unlock ratio. - switchLockRatio( dialog, false ); // Unlock. - value = aMatch[1]; - } + var value = this.getValue(), // This = input element. + dialog = this.getDialog(), + aMatch = value.match( regexGetSize ); // Check value + if ( aMatch ) + { + if ( aMatch[2] == '%' ) // % is allowed - > unlock ratio. + switchLockRatio( dialog, false ); // Unlock. + value = aMatch[1]; + } - // Only if ratio is locked - if ( dialog.lockRatio ) - { - var oImageOriginal = dialog.originalElement; - if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) + // Only if ratio is locked + if ( dialog.lockRatio ) { - if ( this.id == 'txtHeight' ) - { - if ( value && value != '0' ) - value = Math.round( oImageOriginal.$.width * ( value / oImageOriginal.$.height ) ); - if ( !isNaN( value ) ) - dialog.setValueOf( 'info', 'txtWidth', value ); - } - else //this.id = txtWidth. + var oImageOriginal = dialog.originalElement; + if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) { - if ( value && value != '0' ) - value = Math.round( oImageOriginal.$.height * ( value / oImageOriginal.$.width ) ); - if ( !isNaN( value ) ) - dialog.setValueOf( 'info', 'txtHeight', value ); + if ( this.id == 'txtHeight' ) + { + if ( value && value != '0' ) + value = Math.round( oImageOriginal.$.width * ( value / oImageOriginal.$.height ) ); + if ( !isNaN( value ) ) + dialog.setValueOf( 'info', 'txtWidth', value ); + } + else //this.id = txtWidth. + { + if ( value && value != '0' ) + value = Math.round( oImageOriginal.$.height * ( value / oImageOriginal.$.width ) ); + if ( !isNaN( value ) ) + dialog.setValueOf( 'info', 'txtHeight', value ); + } } } - } - updatePreview( dialog ); - }; - - var updatePreview = function( dialog ) - { - //Don't load before onShow. - if ( !dialog.originalElement || !dialog.preview ) - return 1; + updatePreview( dialog ); + }; - // Read attributes and update imagePreview; - dialog.commitContent( PREVIEW, dialog.preview ); - return 0; - }; + var updatePreview = function( dialog ) + { + //Don't load before onShow. + if ( !dialog.originalElement || !dialog.preview ) + return 1; - // Custom commit dialog logic, where we're intended to give inline style - // field (txtdlgGenStyle) higher priority to avoid overwriting styles contribute - // by other fields. - function commitContent() - { - var args = arguments; - var inlineStyleField = this.getContentElement( 'advanced', 'txtdlgGenStyle' ); - inlineStyleField && inlineStyleField.commit.apply( inlineStyleField, args ); + // Read attributes and update imagePreview; + dialog.commitContent( PREVIEW, dialog.preview ); + return 0; + }; - this.foreach( function( widget ) + // Custom commit dialog logic, where we're intended to give inline style + // field (txtdlgGenStyle) higher priority to avoid overwriting styles contribute + // by other fields. + function commitContent() { - if ( widget.commit && widget.id != 'txtdlgGenStyle' ) - widget.commit.apply( widget, args ); - }); - } - - // Avoid recursions. - var incommit; + var args = arguments; + var inlineStyleField = this.getContentElement( 'advanced', 'txtdlgGenStyle' ); + inlineStyleField && inlineStyleField.commit.apply( inlineStyleField, args ); - // Synchronous field values to other impacted fields is required, e.g. border - // size change should alter inline-style text as well. - function commitInternally( targetFields ) - { - if ( incommit ) - return; + this.foreach( function( widget ) + { + if ( widget.commit && widget.id != 'txtdlgGenStyle' ) + widget.commit.apply( widget, args ); + }); + } - incommit = 1; + // Avoid recursions. + var incommit; - var dialog = this.getDialog(), - element = dialog.imageElement; - if ( element ) + // Synchronous field values to other impacted fields is required, e.g. border + // size change should alter inline-style text as well. + function commitInternally( targetFields ) { - // Commit this field and broadcast to target fields. - this.commit( IMAGE, element ); + if ( incommit ) + return; - targetFields = [].concat( targetFields ); - var length = targetFields.length, - field; - for ( var i = 0; i < length; i++ ) + incommit = 1; + + var dialog = this.getDialog(), + element = dialog.imageElement; + if ( element ) { - field = dialog.getContentElement.apply( dialog, targetFields[ i ].split( ':' ) ); - // May cause recursion. - field && field.setup( IMAGE, element ); + // Commit this field and broadcast to target fields. + this.commit( IMAGE, element ); + + targetFields = [].concat( targetFields ); + var length = targetFields.length, + field; + for ( var i = 0; i < length; i++ ) + { + field = dialog.getContentElement.apply( dialog, targetFields[ i ].split( ':' ) ); + // May cause recursion. + field && field.setup( IMAGE, element ); + } } + + incommit = 0; } - incommit = 0; - } + var switchLockRatio = function( dialog, value ) + { + if ( !dialog.getContentElement( 'info', 'ratioLock' ) ) + return null; - var switchLockRatio = function( dialog, value ) - { - var oImageOriginal = dialog.originalElement, - ratioButton = CKEDITOR.document.getById( 'btnLockSizes' ); + var oImageOriginal = dialog.originalElement; - if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) - { - if ( value == 'check' ) // Check image ratio and original image ratio. + // Dialog may already closed. (#5505) + if( !oImageOriginal ) + return null; + + // Check image ratio and original image ratio, but respecting user's preference. + if ( value == 'check' ) { - var width = dialog.getValueOf( 'info', 'txtWidth' ), - height = dialog.getValueOf( 'info', 'txtHeight' ), - originalRatio = oImageOriginal.$.width * 1000 / oImageOriginal.$.height, - thisRatio = width * 1000 / height; - dialog.lockRatio = false; // Default: unlock ratio - - if ( !width && !height ) - dialog.lockRatio = true; - else if ( !isNaN( originalRatio ) && !isNaN( thisRatio ) ) + if ( !dialog.userlockRatio && oImageOriginal.getCustomData( 'isReady' ) == 'true' ) { - if ( Math.round( originalRatio ) == Math.round( thisRatio ) ) + var width = dialog.getValueOf( 'info', 'txtWidth' ), + height = dialog.getValueOf( 'info', 'txtHeight' ), + originalRatio = oImageOriginal.$.width * 1000 / oImageOriginal.$.height, + thisRatio = width * 1000 / height; + dialog.lockRatio = false; // Default: unlock ratio + + if ( !width && !height ) dialog.lockRatio = true; + else if ( !isNaN( originalRatio ) && !isNaN( thisRatio ) ) + { + if ( Math.round( originalRatio ) == Math.round( thisRatio ) ) + dialog.lockRatio = true; + } } } else if ( value != undefined ) dialog.lockRatio = value; else + { + dialog.userlockRatio = 1; dialog.lockRatio = !dialog.lockRatio; - } - else if ( value != 'check' ) // I can't lock ratio if ratio is unknown. - dialog.lockRatio = false; + } - if ( dialog.lockRatio ) - ratioButton.removeClass( 'cke_btn_unlocked' ); - else - ratioButton.addClass( 'cke_btn_unlocked' ); + var ratioButton = CKEDITOR.document.getById( btnLockSizesId ); + if ( dialog.lockRatio ) + ratioButton.removeClass( 'cke_btn_unlocked' ); + else + ratioButton.addClass( 'cke_btn_unlocked' ); - var lang = dialog._.editor.lang.image, - label = lang[ dialog.lockRatio ? 'unlockRatio' : 'lockRatio' ]; + ratioButton.setAttribute( 'aria-checked', dialog.lockRatio ); - ratioButton.setAttribute( 'title', label ); - ratioButton.getFirst().setText( label ); + // Ratio button hc presentation - WHITE SQUARE / BLACK SQUARE + if ( CKEDITOR.env.hc ) + { + var icon = ratioButton.getChild( 0 ); + icon.setHtml( dialog.lockRatio ? CKEDITOR.env.ie ? '\u25A0': '\u25A3' : CKEDITOR.env.ie ? '\u25A1' : '\u25A2' ); + } - return dialog.lockRatio; - }; + return dialog.lockRatio; + }; - var resetSize = function( dialog ) - { - var oImageOriginal = dialog.originalElement; - if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) + var resetSize = function( dialog ) { - dialog.setValueOf( 'info', 'txtWidth', oImageOriginal.$.width ); - dialog.setValueOf( 'info', 'txtHeight', oImageOriginal.$.height ); - } - updatePreview( dialog ); - }; - - var setupDimension = function( type, element ) - { - if ( type != IMAGE ) - return; + var oImageOriginal = dialog.originalElement; + if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) + { + var widthField = dialog.getContentElement( 'info', 'txtWidth' ), + heightField = dialog.getContentElement( 'info', 'txtHeight' ); + widthField && widthField.setValue( oImageOriginal.$.width ); + heightField && heightField.setValue( oImageOriginal.$.height ); + } + updatePreview( dialog ); + }; - function checkDimension( size, defaultValue ) + var setupDimension = function( type, element ) { - var aMatch = size.match( regexGetSize ); - if ( aMatch ) + if ( type != IMAGE ) + return; + + function checkDimension( size, defaultValue ) { - if ( aMatch[2] == '%' ) // % is allowed. + var aMatch = size.match( regexGetSize ); + if ( aMatch ) { - aMatch[1] += '%'; - switchLockRatio( dialog, false ); // Unlock ratio + if ( aMatch[2] == '%' ) // % is allowed. + { + aMatch[1] += '%'; + switchLockRatio( dialog, false ); // Unlock ratio + } + return aMatch[1]; } - return aMatch[1]; + return defaultValue; } - return defaultValue; - } - var dialog = this.getDialog(), - value = '', - dimension = (( this.id == 'txtWidth' )? 'width' : 'height' ), - size = element.getAttribute( dimension ); + var dialog = this.getDialog(), + value = '', + dimension = this.id == 'txtWidth' ? 'width' : 'height', + size = element.getAttribute( dimension ); - if ( size ) - value = checkDimension( size, value ); - value = checkDimension( element.getStyle( dimension ), value ); + if ( size ) + value = checkDimension( size, value ); + value = checkDimension( element.getStyle( dimension ), value ); - this.setValue( value ); - }; + this.setValue( value ); + }; - var imageDialog = function( editor, dialogType ) - { var previewPreloader; var onImgLoadEvent = function() @@ -213,7 +227,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license original.removeListener( 'abort', onImgLoadErrorEvent ); // Hide loader - CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); + CKEDITOR.document.getById( imagePreviewLoaderId ).setStyle( 'display', 'none' ); // New image -> new domensions if ( !this.dontResetSize ) @@ -241,13 +255,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.preview.setAttribute( 'src', noimage ); // Hide loader - CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); + CKEDITOR.document.getById( imagePreviewLoaderId ).setStyle( 'display', 'none' ); switchLockRatio( this, false ); // Unlock. }; + + var numbering = function( id ) + { + return CKEDITOR.tools.getNextId() + '_' + id; + }, + btnLockSizesId = numbering( 'btnLockSizes' ), + btnResetSizeId = numbering( 'btnResetSize' ), + imagePreviewLoaderId = numbering( 'ImagePreviewLoader' ), + imagePreviewBoxId = numbering( 'ImagePreviewBox' ), + previewLinkId = numbering( 'previewLink' ), + previewImageId = numbering( 'previewImage' ); + return { - title : ( dialogType == 'image' ) ? editor.lang.image.title : editor.lang.image.titleButton, + title : editor.lang.image[ dialogType == 'image' ? 'title' : 'titleButton' ], minWidth : 420, - minHeight : 310, + minHeight : 360, onShow : function() { this.imageElement = false; @@ -258,6 +284,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.linkEditMode = false; this.lockRatio = true; + this.userlockRatio = 0; this.dontResetSize = false; this.firstLoad = true; this.addLink = false; @@ -268,10 +295,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license link = element && element.getAscendant( 'a' ); //Hide loader. - CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); + CKEDITOR.document.getById( imagePreviewLoaderId ).setStyle( 'display', 'none' ); // Create the preview before setup the dialog contents. previewPreloader = new CKEDITOR.dom.element( 'img', editor.document ); - this.preview = CKEDITOR.document.getById( 'previewImage' ); + this.preview = CKEDITOR.document.getById( previewImageId ); // Copy of the image this.originalElement = editor.document.createElement( 'img' ); @@ -302,7 +329,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.setupContent( LINK, link ); } - if ( element && element.getName() == 'img' && !element.getAttribute( '_cke_realelement' ) + if ( element && element.getName() == 'img' && !element.data( 'cke-realelement' ) || element && element.getName() == 'input' && element.getAttribute( 'type' ) == 'image' ) { this.imageEditMode = element.getName(); @@ -318,13 +345,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Fill out all fields. this.setupContent( IMAGE, this.imageElement ); - - // Refresh LockRatio button - switchLockRatio ( this, true ); } else this.imageElement = editor.document.createElement( 'img' ); + // Refresh LockRatio button + switchLockRatio ( this, true ); + // Dont show preview if no URL given. if ( !CKEDITOR.tools.trim( this.getValueOf( 'info', 'txtUrl' ) ) ) { @@ -402,11 +429,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license //Insert a new Link. if ( !this.linkEditMode ) { - editor.insertElement(this.linkElement); - this.linkElement.append(this.imageElement, false); + editor.insertElement( this.linkElement ); + this.linkElement.append( this.imageElement, false ); } else //Link already exists, image not. - editor.insertElement(this.imageElement ); + editor.insertElement( this.imageElement ); } else editor.insertElement( this.imageElement ); @@ -432,8 +459,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( dialogType != 'image' ) this.hidePage( 'Link' ); //Hide Link tab. var doc = this._.element.getDocument(); - this.addFocusable( doc.getById( 'btnResetSize' ), 5 ); - this.addFocusable( doc.getById( 'btnLockSizes' ), 5 ); + + if ( this.getContentElement( 'info', 'ratioLock' ) ) + { + this.addFocusable( doc.getById( btnResetSizeId ), 5 ); + this.addFocusable( doc.getById( btnLockSizesId ), 5 ); + } this.commitContent = commitContent; }, @@ -491,7 +522,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license original.setCustomData( 'isReady', 'false' ); // Show loader - var loader = CKEDITOR.document.getById( 'ImagePreviewLoader' ); + var loader = CKEDITOR.document.getById( imagePreviewLoaderId ); if ( loader ) loader.setStyle( 'display', '' ); @@ -516,7 +547,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( type == IMAGE ) { - var url = element.getAttribute( '_cke_saved_src' ) || element.getAttribute( 'src' ); + var url = element.data( 'cke-saved-src' ) || element.getAttribute( 'src' ); var field = this; this.getDialog().dontResetSize = true; @@ -524,15 +555,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license field.setValue( url ); // And call this.onChange() // Manually set the initial value.(#4191) field.setInitValue(); - field.focus(); } }, commit : function( type, element ) { if ( type == IMAGE && ( this.getValue() || this.isChanged() ) ) { - element.setAttribute( '_cke_saved_src', decodeURI( this.getValue() ) ); - element.setAttribute( 'src', decodeURI( this.getValue() ) ); + element.data( 'cke-saved-src', this.getValue() ); + element.setAttribute( 'src', this.getValue() ); } else if ( type == CLEANUP ) { @@ -561,7 +591,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license id : 'txtAlt', type : 'text', label : editor.lang.image.alt, - accessKey : 'A', + accessKey : 'T', 'default' : '', onChange : function() { @@ -591,17 +621,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, { type : 'hbox', - widths : [ '140px', '240px' ], children : [ { + id : 'basic', type : 'vbox', - padding : 10, children : [ { type : 'hbox', - widths : [ '70%', '30%' ], + widths : [ '50%', '50%' ], children : [ { @@ -613,8 +642,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'text', width: '40px', id : 'txtWidth', - labelLayout : 'horizontal', - label : editor.lang.image.width, + label : editor.lang.common.width, onKeyUp : onSizeChange, onChange : function() { @@ -622,10 +650,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, validate : function() { - var aMatch = this.getValue().match( regexGetSizeOrEmpty ); - if ( !aMatch ) - alert( editor.lang.image.validateWidth ); - return !!aMatch; + var aMatch = this.getValue().match( regexGetSizeOrEmpty ), + isValid = !!( aMatch && parseInt( aMatch[1], 10 ) !== 0 ); + if ( !isValid ) + alert( editor.lang.common.invalidWidth ); + return isValid; }, setup : setupDimension, commit : function( type, element, internalCommit ) @@ -635,7 +664,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( value ) element.setStyle( 'width', CKEDITOR.tools.cssLength( value ) ); - else if ( !value && this.isChanged( ) ) + else element.removeStyle( 'width' ); !internalCommit && element.removeAttribute( 'width' ); @@ -650,7 +679,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license element.setStyle( 'width', oImageOriginal.$.width + 'px'); } else - element.setStyle( 'width', value + 'px'); + element.setStyle( 'width', CKEDITOR.tools.cssLength( value ) ); } else if ( type == CLEANUP ) { @@ -663,8 +692,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'text', id : 'txtHeight', width: '40px', - labelLayout : 'horizontal', - label : editor.lang.image.height, + label : editor.lang.common.height, onKeyUp : onSizeChange, onChange : function() { @@ -672,10 +700,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, validate : function() { - var aMatch = this.getValue().match( regexGetSizeOrEmpty ); - if ( !aMatch ) - alert( editor.lang.image.validateHeight ); - return !!aMatch; + var aMatch = this.getValue().match( regexGetSizeOrEmpty ), + isValid = !!( aMatch && parseInt( aMatch[1], 10 ) !== 0 ); + if ( !isValid ) + alert( editor.lang.common.invalidHeight ); + return isValid; }, setup : setupDimension, commit : function( type, element, internalCommit ) @@ -685,11 +714,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( value ) element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) ); - else if ( !value && this.isChanged( ) ) + else element.removeStyle( 'height' ); - if ( !internalCommit && type == IMAGE ) - element.removeAttribute( 'height' ); + !internalCommit && element.removeAttribute( 'height' ); } else if ( type == PREVIEW ) { @@ -701,7 +729,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license element.setStyle( 'height', oImageOriginal.$.height + 'px' ); } else - element.setStyle( 'height', value + 'px' ); + element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) ); } else if ( type == CLEANUP ) { @@ -713,19 +741,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license ] }, { + id : 'ratioLock', type : 'html', - style : 'margin-top:10px;width:40px;height:40px;', + style : 'margin-top:30px;width:40px;height:40px;', onLoad : function() { // Activate Reset button - var resetButton = CKEDITOR.document.getById( 'btnResetSize' ), - ratioButton = CKEDITOR.document.getById( 'btnLockSizes' ); + var resetButton = CKEDITOR.document.getById( btnResetSizeId ), + ratioButton = CKEDITOR.document.getById( btnLockSizesId ); if ( resetButton ) { - resetButton.on( 'click', function(evt) + resetButton.on( 'click', function( evt ) { resetSize( this ); - evt.data.preventDefault(); + evt.data && evt.data.preventDefault(); }, this.getDialog() ); resetButton.on( 'mouseover', function() { @@ -754,7 +783,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license updatePreview( this ); } } - evt.data.preventDefault(); + evt.data && evt.data.preventDefault(); }, this.getDialog() ); ratioButton.on( 'mouseover', function() { @@ -767,10 +796,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } }, html : '
'+ - '' + editor.lang.image.unlockRatio + '' + + '' + editor.lang.image.lockRatio + '' + '' + editor.lang.image.resetSize + ''+ + '" class="cke_btn_reset" id="' + btnResetSizeId + '" role="button">' + editor.lang.image.resetSize + ''+ '
' } ] @@ -784,7 +813,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'text', id : 'txtBorder', width: '60px', - labelLayout : 'horizontal', label : editor.lang.image.border, 'default' : '', onKeyUp : function() @@ -841,7 +869,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'text', id : 'txtHSpace', width: '60px', - labelLayout : 'horizontal', label : editor.lang.image.hSpace, 'default' : '', onKeyUp : function() @@ -905,7 +932,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'text', id : 'txtVSpace', width : '60px', - labelLayout : 'horizontal', label : editor.lang.image.vSpace, 'default' : '', onKeyUp : function() @@ -967,16 +993,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { id : 'cmbAlign', type : 'select', - labelLayout : 'horizontal', widths : [ '35%','65%' ], style : 'width:90px', - label : editor.lang.image.align, + label : editor.lang.common.align, 'default' : '', items : [ [ editor.lang.common.notSet , ''], - [ editor.lang.image.alignLeft , 'left'], - [ editor.lang.image.alignRight , 'right'] + [ editor.lang.common.alignLeft , 'left'], + [ editor.lang.common.alignRight , 'right'] // Backward compatible with v2 on setup when specified as attribute value, // while these values are no more available as select options. // [ editor.lang.image.alignAbsBottom , 'absBottom'], @@ -1048,12 +1073,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license [ { type : 'html', + id : 'htmlPreview', style : 'width:95%;', html : '
' + CKEDITOR.tools.htmlEncode( editor.lang.common.preview ) +'
'+ - ''+ - '
'+ - ''+ - '' + + ''+ + '
'+ + ''+ + '' + ( editor.config.image_previewText || 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '+ 'Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, '+ @@ -1082,7 +1108,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( type == LINK ) { - var href = element.getAttribute( '_cke_saved_href' ); + var href = element.data( 'cke-saved-href' ); if ( !href ) href = element.getAttribute( 'href' ); this.setValue( href ); @@ -1094,9 +1120,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { if ( this.getValue() || this.isChanged() ) { - element.setAttribute( '_cke_saved_href', decodeURI( this.getValue() ) ); - element.setAttribute( 'href', 'javascript:void(0)/*' + - CKEDITOR.tools.getNextNumber() + '*/' ); + var url = decodeURI( this.getValue() ); + element.data( 'cke-saved-href', url ); + element.setAttribute( 'href', url ); if ( this.getValue() || !editor.config.image_removeLinkByEmptyURL ) this.getDialog().addLink = true; @@ -1111,7 +1137,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { action : 'Browse', target: 'Link:txtUrl', - url: editor.config.filebrowserImageBrowseLinkUrl || editor.config.filebrowserBrowseUrl + url: editor.config.filebrowserImageBrowseLinkUrl }, style : 'float:right', hidden : true, @@ -1133,7 +1159,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license setup : function( type, element ) { if ( type == LINK ) - this.setValue( element.getAttribute( 'target' ) ); + this.setValue( element.getAttribute( 'target' ) || '' ); }, commit : function( type, element ) { @@ -1323,6 +1349,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'text', id : 'txtdlgGenStyle', label : editor.lang.common.cssStyle, + validate : CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ), 'default' : '', setup : function( type, element ) {