X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fimage%2Fdialogs%2Fimage.js;h=3ba0dc1f8d0242a01c353140885d40ed99160d73;hb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;hp=7507ff290d83e258360e12111c046f013e3cdbac;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git
diff --git a/_source/plugins/image/dialogs/image.js b/_source/plugins/image/dialogs/image.js
index 7507ff2..3ba0dc1 100644
--- a/_source/plugins/image/dialogs/image.js
+++ b/_source/plugins/image/dialogs/image.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -85,14 +85,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// size change should alter inline-style text as well.
function commitInternally( targetFields )
{
- if( incommit )
+ if ( incommit )
return;
incommit = 1;
var dialog = this.getDialog(),
element = dialog.imageElement;
- if( element )
+ if ( element )
{
// Commit this field and broadcast to target fields.
this.commit( IMAGE, element );
@@ -147,6 +147,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
else
ratioButton.addClass( 'cke_btn_unlocked' );
+ var lang = dialog._.editor.lang.image,
+ label = lang[ dialog.lockRatio ? 'unlockRatio' : 'lockRatio' ];
+
+ ratioButton.setAttribute( 'title', label );
+ ratioButton.getFirst().setText( label );
+
return dialog.lockRatio;
};
@@ -195,6 +201,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var imageDialog = function( editor, dialogType )
{
+ var previewPreloader;
+
var onImgLoadEvent = function()
{
// Image is ready.
@@ -212,7 +220,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
resetSize( this );
if ( this.firstLoad )
- switchLockRatio( this, 'check' );
+ CKEDITOR.tools.setTimeout( function(){ switchLockRatio( this, 'check' ); }, 0, this );
+
this.firstLoad = false;
this.dontResetSize = false;
};
@@ -253,16 +262,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
this.firstLoad = true;
this.addLink = false;
- //Hide loader.
- CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' );
- // Preview
- this.preview = CKEDITOR.document.getById( 'previewImage' );
-
var editor = this.getParentEditor(),
sel = this.getParentEditor().getSelection(),
element = sel.getSelectedElement(),
link = element && element.getAscendant( 'a' );
+ //Hide loader.
+ CKEDITOR.document.getById( 'ImagePreviewLoader' ).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' );
+
// Copy of the image
this.originalElement = editor.document.createElement( 'img' );
this.originalElement.setAttribute( 'alt', '' );
@@ -381,7 +391,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
this.commitContent( LINK, this.linkElement );
// Remove empty style attribute.
- if( !this.imageElement.getAttribute( 'style' ) )
+ if ( !this.imageElement.getAttribute( 'style' ) )
this.imageElement.removeAttribute( 'style' );
// Insert a new Image.
@@ -456,10 +466,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
children :
[
{
- type : 'html',
- html : '' + CKEDITOR.tools.htmlEncode( editor.lang.image.url ) + ''
- },
- {
type : 'hbox',
widths : [ '280px', '110px' ],
align : 'right',
@@ -468,7 +474,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
id : 'txtUrl',
type : 'text',
- label : '',
+ label : editor.lang.common.url,
+ required: true,
onChange : function()
{
var dialog = this.getDialog(),
@@ -492,8 +499,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
original.on( 'error', onImgLoadErrorEvent, dialog );
original.on( 'abort', onImgLoadErrorEvent, dialog );
original.setAttribute( 'src', newUrl );
- dialog.preview.setAttribute( 'src', newUrl );
+ // Query the preloader to figure out the url impacted by based href.
+ previewPreloader.setAttribute( 'src', newUrl );
+ dialog.preview.setAttribute( 'src', previewPreloader.$.src );
updatePreview( dialog );
}
// Dont show preview if no URL given.
@@ -536,6 +545,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
type : 'button',
id : 'browse',
+ // v-align with the 'txtUrl' field.
+ // TODO: We need something better than a fixed size here.
+ style : 'display:inline-block;margin-top:10px;',
align : 'center',
label : editor.lang.common.browseServer,
hidden : true,
@@ -608,11 +620,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
commitInternally.call( this, 'advanced:txtdlgGenStyle' );
},
- validate: function()
+ validate : function()
{
var aMatch = this.getValue().match( regexGetSizeOrEmpty );
if ( !aMatch )
- alert( editor.lang.common.validateNumberFailed );
+ alert( editor.lang.image.validateWidth );
return !!aMatch;
},
setup : setupDimension,
@@ -658,11 +670,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
commitInternally.call( this, 'advanced:txtdlgGenStyle' );
},
- validate: function()
+ validate : function()
{
var aMatch = this.getValue().match( regexGetSizeOrEmpty );
if ( !aMatch )
- alert( editor.lang.common.validateNumberFailed );
+ alert( editor.lang.image.validateHeight );
return !!aMatch;
},
setup : setupDimension,
@@ -676,7 +688,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
else if ( !value && this.isChanged( ) )
element.removeStyle( 'height' );
- if( !internalCommit && type == IMAGE )
+ if ( !internalCommit && type == IMAGE )
element.removeAttribute( 'height' );
}
else if ( type == PREVIEW )
@@ -710,9 +722,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
ratioButton = CKEDITOR.document.getById( 'btnLockSizes' );
if ( resetButton )
{
- resetButton.on( 'click', function()
+ resetButton.on( 'click', function(evt)
{
resetSize( this );
+ evt.data.preventDefault();
}, this.getDialog() );
resetButton.on( 'mouseover', function()
{
@@ -726,7 +739,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Activate (Un)LockRatio button
if ( ratioButton )
{
- ratioButton.on( 'click', function()
+ ratioButton.on( 'click', function(evt)
{
var locked = switchLockRatio( this ),
oImageOriginal = this.originalElement,
@@ -741,6 +754,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
updatePreview( this );
}
}
+ evt.data.preventDefault();
}, this.getDialog() );
ratioButton.on( 'mouseover', function()
{
@@ -753,10 +767,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
},
html : '
'
}
]
@@ -781,22 +795,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
commitInternally.call( this, 'advanced:txtdlgGenStyle' );
},
- validate: function()
- {
- var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
- return func.apply( this );
- },
+ validate : CKEDITOR.dialog.validate.integer( editor.lang.image.validateBorder ),
setup : function( type, element )
{
if ( type == IMAGE )
{
var value,
borderStyle = element.getStyle( 'border-width' );
-
borderStyle = borderStyle && borderStyle.match( /^(\d+px)(?: \1 \1 \1)?$/ );
value = borderStyle && parseInt( borderStyle[ 1 ], 10 );
- !value && ( value = element.getAttribute( 'border' ) );
-
+ isNaN ( parseInt( value, 10 ) ) && ( value = element.getAttribute( 'border' ) );
this.setValue( value );
}
},
@@ -805,7 +813,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var value = parseInt( this.getValue(), 10 );
if ( type == IMAGE || type == PREVIEW )
{
- if ( value )
+ if ( !isNaN( value ) )
{
element.setStyle( 'border-width', CKEDITOR.tools.cssLength( value ) );
element.setStyle( 'border-style', 'solid' );
@@ -817,7 +825,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
element.removeStyle( 'border-color' );
}
- if( !internalCommit && type == IMAGE )
+ if ( !internalCommit && type == IMAGE )
element.removeAttribute( 'border' );
}
else if ( type == CLEANUP )
@@ -844,11 +852,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
commitInternally.call( this, 'advanced:txtdlgGenStyle' );
},
- validate: function()
- {
- var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
- return func.apply( this );
- },
+ validate : CKEDITOR.dialog.validate.integer( editor.lang.image.validateHSpace ),
setup : function( type, element )
{
if ( type == IMAGE )
@@ -865,7 +869,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
marginRightPx = parseInt( marginRightStyle, 10 );
value = ( marginLeftPx == marginRightPx ) && marginLeftPx;
- !value && ( value = element.getAttribute( 'hspace' ) );
+ isNaN( parseInt( value, 10 ) ) && ( value = element.getAttribute( 'hspace' ) );
this.setValue( value );
}
@@ -875,7 +879,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var value = parseInt( this.getValue(), 10 );
if ( type == IMAGE || type == PREVIEW )
{
- if ( value )
+ if ( !isNaN( value ) )
{
element.setStyle( 'margin-left', CKEDITOR.tools.cssLength( value ) );
element.setStyle( 'margin-right', CKEDITOR.tools.cssLength( value ) );
@@ -886,7 +890,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
element.removeStyle( 'margin-right' );
}
- if( !internalCommit && type == IMAGE )
+ if ( !internalCommit && type == IMAGE )
element.removeAttribute( 'hspace' );
}
else if ( type == CLEANUP )
@@ -912,11 +916,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
commitInternally.call( this, 'advanced:txtdlgGenStyle' );
},
- validate: function()
- {
- var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed );
- return func.apply( this );
- },
+ validate : CKEDITOR.dialog.validate.integer( editor.lang.image.validateVSpace ),
setup : function( type, element )
{
if ( type == IMAGE )
@@ -933,7 +933,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
marginBottomPx = parseInt( marginBottomStyle, 10 );
value = ( marginTopPx == marginBottomPx ) && marginTopPx;
- !value && ( value = element.getAttribute( 'vspace' ) );
+ isNaN ( parseInt( value, 10 ) ) && ( value = element.getAttribute( 'vspace' ) );
this.setValue( value );
}
},
@@ -942,7 +942,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var value = parseInt( this.getValue(), 10 );
if ( type == IMAGE || type == PREVIEW )
{
- if ( value )
+ if ( !isNaN( value ) )
{
element.setStyle( 'margin-top', CKEDITOR.tools.cssLength( value ) );
element.setStyle( 'margin-bottom', CKEDITOR.tools.cssLength( value ) );
@@ -953,7 +953,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
element.removeStyle( 'margin-bottom' );
}
- if( !internalCommit && type == IMAGE )
+ if ( !internalCommit && type == IMAGE )
element.removeAttribute( 'vspace' );
}
else if ( type == CLEANUP )
@@ -1016,10 +1016,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
if ( value )
element.setStyle( 'float', value );
- else if ( !value && this.isChanged( ) )
+ else
element.removeStyle( 'float' );
- if( !internalCommit && type == IMAGE )
+ if ( !internalCommit && type == IMAGE )
{
value = ( element.getAttribute( 'align' ) || '' ).toLowerCase();
switch( value )
@@ -1049,14 +1049,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
type : 'html',
style : 'width:95%;',
- html : '' + CKEDITOR.tools.htmlEncode( editor.lang.image.preview ) +'
'+
+ html : '
' + CKEDITOR.tools.htmlEncode( editor.lang.common.preview ) +'
'+
'
'+
- '
'+
+ '
'+
''+
- ' Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '+
+ ' ' +
+ ( 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, '+
- 'nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.' +
- ''+''
+ 'nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.' ) +
+ ' |
'
}
]
}
@@ -1073,7 +1075,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
id : 'txtUrl',
type : 'text',
- label : editor.lang.image.url,
+ label : editor.lang.common.url,
style : 'width: 100%',
'default' : '',
setup : function( type, element )
@@ -1105,7 +1107,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
type : 'button',
id : 'browse',
- filebrowser : 'Link:txtUrl',
+ filebrowser :
+ {
+ action : 'Browse',
+ target: 'Link:txtUrl',
+ url: editor.config.filebrowserImageBrowseLinkUrl || editor.config.filebrowserBrowseUrl
+ },
style : 'float:right',
hidden : true,
label : editor.lang.common.browseServer
@@ -1113,15 +1120,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
id : 'cmbTarget',
type : 'select',
- label : editor.lang.link.target,
+ label : editor.lang.common.target,
'default' : '',
items :
[
- [ editor.lang.link.targetNotSet , ''],
- [ editor.lang.link.targetNew , '_blank'],
- [ editor.lang.link.targetTop , '_top'],
- [ editor.lang.link.targetSelf , '_self'],
- [ editor.lang.link.targetParent , '_parent']
+ [ editor.lang.common.notSet , ''],
+ [ editor.lang.common.targetNew , '_blank'],
+ [ editor.lang.common.targetTop , '_top'],
+ [ editor.lang.common.targetSelf , '_self'],
+ [ editor.lang.common.targetParent , '_parent']
],
setup : function( type, element )
{