X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fimage%2Fdialogs%2Fimage.js;h=3ba0dc1f8d0242a01c353140885d40ed99160d73;hb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;hp=9b127c983e9cdfc08d10baddc78c30a905a81e6d;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/image/dialogs/image.js b/_source/plugins/image/dialogs/image.js index 9b127c9..3ba0dc1 100644 --- a/_source/plugins/image/dialogs/image.js +++ b/_source/plugins/image/dialogs/image.js @@ -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; }; @@ -385,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. @@ -460,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', @@ -472,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(), @@ -542,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, @@ -614,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, @@ -664,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, @@ -682,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 ) @@ -716,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() { @@ -732,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, @@ -747,6 +754,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license updatePreview( this ); } } + evt.data.preventDefault(); }, this.getDialog() ); ratioButton.on( 'mouseover', function() { @@ -759,10 +767,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } }, html : '
'+ - '' + + '' + editor.lang.image.unlockRatio + '' + ''+ + '" class="cke_btn_reset" id="btnResetSize" role="button">' + editor.lang.image.resetSize + ''+ '
' } ] @@ -787,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 ); } }, @@ -811,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' ); @@ -823,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 ) @@ -850,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 ) @@ -871,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 ); } @@ -881,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 ) ); @@ -892,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 ) @@ -918,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 ) @@ -939,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 ); } }, @@ -948,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 ) ); @@ -959,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 ) @@ -1022,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 ) @@ -1055,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.' ) + + '
' } ] } @@ -1079,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 ) @@ -1111,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 @@ -1119,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 ) {