| 1 | /* |
| 2 | Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. |
| 3 | For licensing, see LICENSE.html or http://ckeditor.com/license |
| 4 | */ |
| 5 | |
| 6 | imageDialog = function( editor, dialogType ) |
| 7 | { |
| 8 | // Load image preview. |
| 9 | var IMAGE = 1, |
| 10 | LINK = 2, |
| 11 | PREVIEW = 4, |
| 12 | ORIGINAL = 8, |
| 13 | CLEANUP = 16, |
| 14 | showPreview = editor.config.image.showPreview, |
| 15 | regexGetSize = /^\s*(\d+)((px)|\%)?\s*$/i, |
| 16 | regexGetSizeOrEmpty = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i, |
| 17 | imageDialog = ( dialogType == 'image' ); |
| 18 | |
| 19 | var onImgLoadEvent = function() |
| 20 | { |
| 21 | // Image is ready. |
| 22 | var original = this.originalElement; |
| 23 | original.setCustomData( 'isReady', 'true' ); |
| 24 | original.removeListener( 'load', onImgLoadEvent ); |
| 25 | original.removeListener( 'error', onImgLoadErrorEvent ); |
| 26 | original.removeListener( 'abort', onImgLoadErrorEvent ); |
| 27 | |
| 28 | // Hide loader |
| 29 | CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); |
| 30 | |
| 31 | // New image -> new domensions |
| 32 | if ( this.dontResetSize == false ) |
| 33 | resetSize( this ); |
| 34 | |
| 35 | if ( this.firstLoad ) |
| 36 | switchLockRatio( this, 'check' ); |
| 37 | this.firstLoad = false; |
| 38 | this.dontResetSize = false; |
| 39 | } |
| 40 | var onImgLoadErrorEvent = function() |
| 41 | { |
| 42 | // Error. Image is not loaded. |
| 43 | var original = this.originalElement; |
| 44 | original.removeListener( 'load', onImgLoadEvent ); |
| 45 | original.removeListener( 'error', onImgLoadErrorEvent ); |
| 46 | original.removeListener( 'abort', onImgLoadErrorEvent ); |
| 47 | |
| 48 | // Set Error image. |
| 49 | var noimage = CKEDITOR.getUrl( |
| 50 | '_source/' + // %REMOVE_LINE% |
| 51 | 'skins/' + editor.config.skin + '/images/dialog.noimage.gif' ); |
| 52 | |
| 53 | if ( showPreview && this.preview ) |
| 54 | this.preview.setAttribute( 'src', noimage ); |
| 55 | |
| 56 | // Hide loader |
| 57 | CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); |
| 58 | switchLockRatio( this, false ); // Unlock. |
| 59 | } |
| 60 | var onSizeChange = function() |
| 61 | { |
| 62 | var value = this.getValue(), // This = input element. |
| 63 | dialog = this.getDialog(), |
| 64 | aMatch = value.match( regexGetSize ); // Check value |
| 65 | if ( aMatch ) |
| 66 | { |
| 67 | if ( aMatch[2] == '%' ) // % is allowed - > unlock ratio. |
| 68 | switchLockRatio( dialog, false ); // Unlock. |
| 69 | value = aMatch[1]; |
| 70 | } |
| 71 | |
| 72 | // Only if ratio is locked |
| 73 | if ( dialog.lockRatio ) |
| 74 | { |
| 75 | var oImageOriginal = dialog.originalElement; |
| 76 | if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) |
| 77 | { |
| 78 | if ( this.id == 'txtHeight' ) |
| 79 | { |
| 80 | if ( value != '' && value != 0 ) |
| 81 | value = Math.round( oImageOriginal.$.width * ( value / oImageOriginal.$.height ) ); |
| 82 | if ( !isNaN( value ) ) |
| 83 | dialog.setValueOf( 'info', 'txtWidth', value ); |
| 84 | } |
| 85 | else //this.id = txtWidth. |
| 86 | { |
| 87 | if ( value != '' && value != 0 ) |
| 88 | value = Math.round( oImageOriginal.$.height * ( value / oImageOriginal.$.width ) ); |
| 89 | if ( !isNaN( value ) ) |
| 90 | dialog.setValueOf( 'info', 'txtHeight', value ); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | updatePreview( dialog ); |
| 95 | } |
| 96 | |
| 97 | var updatePreview = function( dialog ) |
| 98 | { |
| 99 | //Don't load before onShow. |
| 100 | if ( !dialog.originalElement || !dialog.preview ) |
| 101 | return 1; |
| 102 | |
| 103 | // Read attributes and update imagePreview; |
| 104 | dialog.commitContent( PREVIEW, dialog.preview ); |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | var switchLockRatio = function( dialog, value ) |
| 109 | { |
| 110 | var oImageOriginal = dialog.originalElement, |
| 111 | ratioButton = CKEDITOR.document.getById( 'btnLockSizes' ); |
| 112 | |
| 113 | if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) |
| 114 | { |
| 115 | if ( value == 'check' ) // Check image ratio and original image ratio. |
| 116 | { |
| 117 | var width = dialog.getValueOf( 'info', 'txtWidth' ), |
| 118 | height = dialog.getValueOf( 'info', 'txtHeight' ), |
| 119 | originalRatio = oImageOriginal.$.width * 1000 / oImageOriginal.$.height, |
| 120 | thisRatio = width * 1000 / height; |
| 121 | dialog.lockRatio = false; // Default: unlock ratio |
| 122 | |
| 123 | if ( width == 0 && height == 0 ) |
| 124 | dialog.lockRatio = true; |
| 125 | else if ( !isNaN( originalRatio ) && !isNaN( thisRatio )) |
| 126 | if ( Math.round( originalRatio ) == Math.round( thisRatio ) ) |
| 127 | dialog.lockRatio = true; |
| 128 | } |
| 129 | else if ( value != undefined ) |
| 130 | dialog.lockRatio = value |
| 131 | else |
| 132 | dialog.lockRatio = !dialog.lockRatio; |
| 133 | } |
| 134 | else if ( value != 'check' ) // I can't lock ratio if ratio is unknown. |
| 135 | dialog.lockRatio = false; |
| 136 | |
| 137 | if ( dialog.lockRatio ) |
| 138 | ratioButton.removeClass( 'BtnUnlocked' ); |
| 139 | else |
| 140 | ratioButton.addClass( 'BtnUnlocked' ); |
| 141 | |
| 142 | return dialog.lockRatio; |
| 143 | } |
| 144 | |
| 145 | var resetSize = function( dialog ) |
| 146 | { |
| 147 | var oImageOriginal = dialog.originalElement; |
| 148 | if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) |
| 149 | { |
| 150 | dialog.setValueOf( 'info', 'txtWidth', oImageOriginal.$.width ); |
| 151 | dialog.setValueOf( 'info', 'txtHeight', oImageOriginal.$.height ); |
| 152 | } |
| 153 | updatePreview( dialog ); |
| 154 | } |
| 155 | |
| 156 | setupDimension = function( type, element ) |
| 157 | { |
| 158 | if ( type != IMAGE ) |
| 159 | return 0; |
| 160 | |
| 161 | var checkDimension = function( size, defaultValue ) |
| 162 | { |
| 163 | var aMatch = size.match( regexGetSize ); |
| 164 | if ( aMatch ) |
| 165 | { |
| 166 | if ( aMatch[2] == '%' ) // % is allowed. |
| 167 | { |
| 168 | aMatch[1] += '%'; |
| 169 | switchLockRatio( dialog, false ); // Unlock ratio |
| 170 | } |
| 171 | return aMatch[1]; |
| 172 | } |
| 173 | return defaultValue; |
| 174 | }, |
| 175 | dialog = this.getDialog(), |
| 176 | value = '', |
| 177 | dimension = (( this.id == 'txtWidth' )? 'width' : 'height' ), |
| 178 | size = element.getAttribute( dimension ); |
| 179 | |
| 180 | if ( size ) |
| 181 | value = checkDimension( size, value ); |
| 182 | value = checkDimension( element.$.style[ dimension ], value ); |
| 183 | |
| 184 | this.setValue( value ); |
| 185 | } |
| 186 | |
| 187 | return { |
| 188 | title : ( imageDialog ) ? editor.lang.image.title : editor.lang.image.titleButton, |
| 189 | minWidth : 450, |
| 190 | minHeight : 400, |
| 191 | onShow : function() |
| 192 | { |
| 193 | this.imageElement = false; |
| 194 | this.linkElement = false; |
| 195 | |
| 196 | // Default: create a new element. |
| 197 | this.imageEditMode = false; |
| 198 | this.linkEditMode = false; |
| 199 | |
| 200 | this.lockRatio = true; |
| 201 | this.dontResetSize = false; |
| 202 | this.firstLoad = true; |
| 203 | this.addLink = false; |
| 204 | |
| 205 | //Hide loader. |
| 206 | CKEDITOR.document.getById( 'ImagePreviewLoader' ).setStyle( 'display', 'none' ); |
| 207 | // Preview |
| 208 | this.preview = CKEDITOR.document.getById( 'previewImage' ); |
| 209 | |
| 210 | // IE BUG: Selection must be in the editor for getSelectedElement() |
| 211 | // to work. |
| 212 | this.restoreSelection(); |
| 213 | |
| 214 | var editor = this.getParentEditor(), |
| 215 | element = this.getParentEditor().getSelection().getSelectedElement(); |
| 216 | |
| 217 | // Copy of the image |
| 218 | this.originalElement = editor.document.createElement( 'img' ); |
| 219 | this.originalElement.setCustomData( 'isReady', 'false' ); |
| 220 | |
| 221 | if ( element && element.getName() == 'a' ) |
| 222 | { |
| 223 | this.linkElement = element; |
| 224 | this.linkEditMode = true; |
| 225 | |
| 226 | // Look for Image element. |
| 227 | var linkChildren = element.getChildren(); |
| 228 | if ( linkChildren.count() == 1 ) // 1 child. |
| 229 | { |
| 230 | var childTagName = linkChildren.getItem( 0 ).getName(); |
| 231 | if ( childTagName == 'img' || childTagName == 'input' ) |
| 232 | { |
| 233 | this.imageElement = linkChildren.getItem( 0 ); |
| 234 | if ( this.imageElement.getName() == 'img' ) |
| 235 | this.imageEditMode = 'img'; |
| 236 | else if ( this.imageElement.getName() == 'input' ) |
| 237 | this.imageEditMode = 'input'; |
| 238 | } |
| 239 | } |
| 240 | // Fill out all fields. |
| 241 | if ( imageDialog ) |
| 242 | this.setupContent( LINK, element ); |
| 243 | } |
| 244 | else if ( element && element.getName() == 'img' && !element.getAttribute( '_cke_protected_html' ) ) |
| 245 | this.imageEditMode = 'img'; |
| 246 | else if ( element && element.getName() == 'input' && element.getAttribute( 'type' ) && element.getAttribute( 'type' ) == 'image' ) |
| 247 | this.imageEditMode = 'input'; |
| 248 | |
| 249 | if ( this.imageEditMode || this.imageElement ) |
| 250 | { |
| 251 | if ( !this.imageElement ) |
| 252 | this.imageElement = element; |
| 253 | |
| 254 | // Fill out all fields. |
| 255 | this.setupContent( IMAGE, this.imageElement ); |
| 256 | |
| 257 | // Refresh LockRatio button |
| 258 | switchLockRatio ( this, true ); |
| 259 | } |
| 260 | if ( !showPreview ) |
| 261 | { |
| 262 | // Show sample image |
| 263 | var defaultImage = CKEDITOR.getUrl( |
| 264 | '_source/' + // %REMOVE_LINE% |
| 265 | 'skins/' + editor.config.skin + '/images/dialog.noimage.gif' ); |
| 266 | this.preview.setAttribute( 'src', defaultImage ); |
| 267 | } |
| 268 | |
| 269 | this.pushDefault(); |
| 270 | }, |
| 271 | onOk : function() |
| 272 | { |
| 273 | // Edit existing Image. |
| 274 | if ( this.imageEditMode ) |
| 275 | { |
| 276 | var imgTagName = this.imageEditMode, |
| 277 | removeObj = this.imageElement; |
| 278 | |
| 279 | // Image dialog and Input element. |
| 280 | if ( imageDialog && imgTagName == 'input' && confirm( editor.lang.image.button2Img ) ) |
| 281 | { |
| 282 | // Replace INPUT-> IMG |
| 283 | imgTagName = 'img'; |
| 284 | this.imageElement = editor.document.createElement( 'img' ); |
| 285 | removeObj.insertBeforeMe( this.imageElement ); |
| 286 | removeObj.remove( false ); |
| 287 | |
| 288 | } |
| 289 | // ImageButton dialog and Image element. |
| 290 | else if ( !imageDialog && imgTagName == 'img' && confirm( editor.lang.image.img2Button )) |
| 291 | { |
| 292 | // Replace IMG -> INPUT |
| 293 | imgTagName = 'input'; |
| 294 | this.imageElement = editor.document.createElement( 'input' ); |
| 295 | this.imageElement.setAttribute ( 'type' ,'image' ); |
| 296 | removeObj.insertBeforeMe( this.imageElement ); |
| 297 | removeObj.remove( false ); |
| 298 | } |
| 299 | } |
| 300 | else // Create a new image. |
| 301 | { |
| 302 | // Image dialog -> create IMG element. |
| 303 | if ( imageDialog ) |
| 304 | this.imageElement = editor.document.createElement( 'img' ); |
| 305 | else |
| 306 | { |
| 307 | this.imageElement = editor.document.createElement( 'input' ); |
| 308 | this.imageElement.setAttribute ( 'type' ,'image' ); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | // Create a new link. |
| 313 | if ( this.linkEditMode == false ) |
| 314 | this.linkElement = editor.document.createElement( 'a' ); |
| 315 | |
| 316 | // Set attributes. |
| 317 | this.commitContent( IMAGE, this.imageElement ); |
| 318 | this.commitContent( LINK, this.linkElement ); |
| 319 | |
| 320 | this.restoreSelection(); |
| 321 | this.clearSavedSelection(); |
| 322 | |
| 323 | // Insert a new Image. |
| 324 | if ( this.imageEditMode == false ) |
| 325 | { |
| 326 | // It doesn't work with IE. |
| 327 | this.restoreSelection(); |
| 328 | this.clearSavedSelection(); |
| 329 | |
| 330 | if ( this.addLink ) |
| 331 | //Insert a new Link. |
| 332 | if ( this.linkEditMode == false ) |
| 333 | { |
| 334 | this.linkElement.append( this.imageElement, false ); |
| 335 | editor.insertElement( this.linkElement ); |
| 336 | } |
| 337 | else //Link already exists, image not. |
| 338 | this.linkElement.append( this.imageElement, false ); |
| 339 | else |
| 340 | editor.insertElement( this.imageElement ); |
| 341 | } |
| 342 | else // Image already exists. |
| 343 | { |
| 344 | //Add a new link element. |
| 345 | if ( this.linkEditMode == false && this.addLink ) |
| 346 | { |
| 347 | this.imageElement.insertBeforeMe( this.linkElement ); |
| 348 | this.imageElement.appendTo( this.linkElement ); |
| 349 | } |
| 350 | //Remove Link, Image exists. |
| 351 | else if ( this.linkEditMode == true && this.addLink == false ) |
| 352 | this.linkElement.remove( true ); |
| 353 | } |
| 354 | }, |
| 355 | onLoad : function() |
| 356 | { |
| 357 | if ( !imageDialog ) |
| 358 | this.hidePage( 'Link' ); //Hide Link tab. |
| 359 | |
| 360 | if ( editor.config.image.uploadTab == false ) |
| 361 | this.hidePage( 'Upload' ); //Hide Upload tab. |
| 362 | }, |
| 363 | onHide : function() |
| 364 | { |
| 365 | if ( this.preview ) |
| 366 | this.commitContent( CLEANUP, this.preview ); |
| 367 | |
| 368 | if ( this.originalElement ) |
| 369 | { |
| 370 | this.originalElement.removeListener( 'load', onImgLoadEvent ); |
| 371 | this.originalElement.removeListener( 'error', onImgLoadErrorEvent ); |
| 372 | this.originalElement.removeListener( 'abort', onImgLoadErrorEvent ); |
| 373 | this.originalElement.remove(); |
| 374 | this.originalElement = false; // Dialog is closed. |
| 375 | } |
| 376 | |
| 377 | this.popDefault(); |
| 378 | }, |
| 379 | contents : [ |
| 380 | { |
| 381 | id : 'info', |
| 382 | label : editor.lang.image.infoTab, |
| 383 | accessKey : 'I', |
| 384 | elements : |
| 385 | [ |
| 386 | { |
| 387 | type : 'vbox', |
| 388 | padding : 0, |
| 389 | children : |
| 390 | [ |
| 391 | { |
| 392 | type : 'html', |
| 393 | html : '<span>' + CKEDITOR.tools.htmlEncode( editor.lang.image.url ) + '</span>' |
| 394 | }, |
| 395 | { |
| 396 | type : 'hbox', |
| 397 | widths : [ '280px', '110px' ], |
| 398 | align : 'right', |
| 399 | children : |
| 400 | [ |
| 401 | { |
| 402 | id : 'txtUrl', |
| 403 | type : 'text', |
| 404 | label : '', |
| 405 | onChange : function() |
| 406 | { |
| 407 | var dialog = this.getDialog(), |
| 408 | newUrl = this.getValue(); |
| 409 | |
| 410 | //Update original image |
| 411 | if ( newUrl.length > 0 ) //Prevent from load before onShow |
| 412 | { |
| 413 | var dialog = this.getDialog(), |
| 414 | original = dialog.originalElement; |
| 415 | |
| 416 | original.setCustomData( 'isReady', 'false' ); |
| 417 | // Show loader |
| 418 | var loader = CKEDITOR.document.getById( 'ImagePreviewLoader' ); |
| 419 | if ( loader && showPreview ) |
| 420 | loader.setStyle( 'display', '' ); |
| 421 | |
| 422 | original.on( 'load', onImgLoadEvent, dialog ); |
| 423 | original.on( 'error', onImgLoadErrorEvent, dialog ); |
| 424 | original.on( 'abort', onImgLoadErrorEvent, dialog ); |
| 425 | original.setAttribute( 'src', newUrl ); |
| 426 | dialog.preview.setAttribute( 'src', newUrl ); |
| 427 | |
| 428 | updatePreview( dialog ); |
| 429 | } |
| 430 | }, |
| 431 | setup : function( type, element ) |
| 432 | { |
| 433 | if ( type == IMAGE ) |
| 434 | { |
| 435 | var dialog = this.getDialog(); |
| 436 | var url = element.getAttribute( '_cke_saved_src' ); |
| 437 | if ( !url ) |
| 438 | url = element.getAttribute( 'src' ); |
| 439 | dialog.dontResetSize = true; |
| 440 | this.setValue( url ); // And call this.onChange() |
| 441 | this.focus(); |
| 442 | } |
| 443 | }, |
| 444 | commit : function( type, element ) |
| 445 | { |
| 446 | if ( type == IMAGE && ( this.getValue() != '' || this.isChanged() ) ) |
| 447 | { |
| 448 | element.setAttribute( '_cke_saved_src', decodeURI( this.getValue() ) ); |
| 449 | element.setAttribute( 'src', decodeURI( this.getValue() ) ); |
| 450 | } |
| 451 | else if ( type == CLEANUP ) |
| 452 | { |
| 453 | element.setAttribute( 'src', '' ); // If removeAttribute doesn't work. |
| 454 | element.removeAttribute( 'src' ); |
| 455 | } |
| 456 | } |
| 457 | }, |
| 458 | { |
| 459 | type : 'button', |
| 460 | id : 'browse', |
| 461 | align : 'center', |
| 462 | label : editor.lang.common.browseServer, |
| 463 | onLoad : function() |
| 464 | { |
| 465 | if ( this.getParentEditor().config.image.browseServer == false ) |
| 466 | this.getContentElement( 'info', 'browse' ).getElement().hide(); |
| 467 | }, |
| 468 | onClick : function() |
| 469 | { |
| 470 | //TODO: remember remove the next line before commit! |
| 471 | this.getDialog().setValueOf( "info", "txtUrl", "http://www.fckeditor.net/images/demo_screenshot.gif" ); |
| 472 | } |
| 473 | } |
| 474 | ] |
| 475 | } |
| 476 | ] |
| 477 | }, |
| 478 | { |
| 479 | id : 'txtAlt', |
| 480 | type : 'text', |
| 481 | label : editor.lang.image.alt, |
| 482 | accessKey : 'A', |
| 483 | 'default' : '', |
| 484 | onChange : function() |
| 485 | { |
| 486 | updatePreview( this.getDialog() ); |
| 487 | }, |
| 488 | setup : function( type, element ) |
| 489 | { |
| 490 | if ( type == IMAGE ) |
| 491 | this.setValue( element.getAttribute( 'alt' ) ); |
| 492 | }, |
| 493 | commit : function( type, element ) |
| 494 | { |
| 495 | if ( type == IMAGE ) |
| 496 | { |
| 497 | if ( this.getValue() != '' || this.isChanged() ) |
| 498 | element.setAttribute( 'alt', this.getValue() ); |
| 499 | } |
| 500 | else if ( type == PREVIEW ) |
| 501 | { |
| 502 | element.setAttribute( 'alt', this.getValue() ); |
| 503 | } |
| 504 | else if ( type == CLEANUP ) |
| 505 | { |
| 506 | element.removeAttribute( 'alt' ); |
| 507 | } |
| 508 | } |
| 509 | }, |
| 510 | { |
| 511 | type : 'hbox', |
| 512 | widths : [ '140px', '240px' ], |
| 513 | children : |
| 514 | [ |
| 515 | { |
| 516 | type : 'vbox', |
| 517 | padding : 10, |
| 518 | children : |
| 519 | [ |
| 520 | { |
| 521 | type : 'hbox', |
| 522 | widths : [ '70%', '30%' ], |
| 523 | children : |
| 524 | [ |
| 525 | { |
| 526 | type : 'vbox', |
| 527 | padding : 1, |
| 528 | children : |
| 529 | [ |
| 530 | { |
| 531 | type : 'text', |
| 532 | id : 'txtWidth', |
| 533 | labelLayout : 'horizontal', |
| 534 | label : editor.lang.image.width, |
| 535 | onKeyUp : onSizeChange, |
| 536 | validate: function() |
| 537 | { |
| 538 | var aMatch = this.getValue().match( regexGetSizeOrEmpty ); |
| 539 | if ( !aMatch ) |
| 540 | alert( editor.lang.common.validateNumberFailed ); |
| 541 | return !!aMatch; |
| 542 | }, |
| 543 | setup : setupDimension, |
| 544 | commit : function( type, element ) |
| 545 | { |
| 546 | if ( type == IMAGE ) |
| 547 | { |
| 548 | var value = this.getValue(); |
| 549 | if ( value != '' && this.isChanged() ) |
| 550 | element.setAttribute( 'width', value ); |
| 551 | else if ( value == '' && this.isChanged() ) |
| 552 | element.removeAttribute( 'width' ); |
| 553 | } |
| 554 | else if ( type == PREVIEW && showPreview ) |
| 555 | { |
| 556 | var value = this.getValue(), |
| 557 | aMatch = value.match( regexGetSize ); |
| 558 | if ( !aMatch ) |
| 559 | { |
| 560 | var oImageOriginal = this.getDialog().originalElement; |
| 561 | if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) |
| 562 | element.setStyle( 'width', oImageOriginal.$.width + 'px'); |
| 563 | } |
| 564 | else |
| 565 | element.setStyle( 'width', value + 'px'); |
| 566 | } |
| 567 | else if ( type == CLEANUP ) |
| 568 | { |
| 569 | element.setStyle( 'width', '0px' ); // If removeAttribute doesn't work. |
| 570 | element.removeAttribute( 'width' ); |
| 571 | element.removeStyle( 'width' ); |
| 572 | } |
| 573 | } |
| 574 | }, |
| 575 | { |
| 576 | type : 'text', |
| 577 | id : 'txtHeight', |
| 578 | labelLayout : 'horizontal', |
| 579 | label : editor.lang.image.height, |
| 580 | onKeyUp : onSizeChange, |
| 581 | validate: function() |
| 582 | { |
| 583 | var aMatch = this.getValue().match( regexGetSizeOrEmpty ); |
| 584 | if ( !aMatch ) |
| 585 | alert( editor.lang.common.validateNumberFailed ); |
| 586 | return !!aMatch; |
| 587 | }, |
| 588 | setup : setupDimension, |
| 589 | commit : function( type, element ) |
| 590 | { |
| 591 | if ( type == IMAGE ) |
| 592 | { |
| 593 | var value = this.getValue(); |
| 594 | if ( value != '' && this.isChanged() ) |
| 595 | element.setAttribute( 'height', value ); |
| 596 | else if ( value == '' && this.isChanged() ) |
| 597 | element.removeAttribute( 'height' ); |
| 598 | } |
| 599 | else if ( ( type == PREVIEW ) && showPreview ) |
| 600 | { |
| 601 | var value = this.getValue(), |
| 602 | aMatch = value.match( regexGetSize ); |
| 603 | if ( !aMatch ) |
| 604 | { |
| 605 | var oImageOriginal = this.getDialog().originalElement; |
| 606 | if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' ) |
| 607 | element.setStyle( 'height', oImageOriginal.$.height + 'px'); |
| 608 | } |
| 609 | else |
| 610 | element.setStyle( 'height', value + 'px'); |
| 611 | } |
| 612 | else if ( type == CLEANUP ) |
| 613 | { |
| 614 | element.setStyle( 'height', '0px' ); // If removeAttribute doesn't work. |
| 615 | element.removeAttribute( 'height' ); |
| 616 | element.removeStyle( 'height' ); |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | ] |
| 621 | }, |
| 622 | { |
| 623 | type : 'html', |
| 624 | style : 'position:relative;top:-10px;height:20px', |
| 625 | onLoad : function() |
| 626 | { |
| 627 | // Activate Reset button |
| 628 | var resetButton = CKEDITOR.document.getById( 'btnResetSize' ); |
| 629 | ratioButton = CKEDITOR.document.getById( 'btnLockSizes' ); |
| 630 | if ( resetButton ) |
| 631 | { |
| 632 | resetButton.on( 'click', function() |
| 633 | { |
| 634 | resetSize( this ); |
| 635 | }, this ); //this = dialog. |
| 636 | resetButton.on( 'mouseover', function() |
| 637 | { |
| 638 | this.addClass( 'BtnOver' ); |
| 639 | }, resetButton ); |
| 640 | resetButton.on( 'mouseout', function() |
| 641 | { |
| 642 | this.removeClass( 'BtnOver' ); |
| 643 | }, resetButton ); |
| 644 | } |
| 645 | // Activate (Un)LockRatio button |
| 646 | if ( ratioButton ) |
| 647 | { |
| 648 | ratioButton.on( 'click', function() |
| 649 | { |
| 650 | var locked = switchLockRatio( this ), |
| 651 | oImageOriginal = this.originalElement, |
| 652 | width = this.getValueOf( 'info', 'txtWidth' ); |
| 653 | |
| 654 | if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' && width ) |
| 655 | { |
| 656 | var height = oImageOriginal.$.height / oImageOriginal.$.width * width; |
| 657 | if ( !isNaN( height ) ) |
| 658 | { |
| 659 | this.setValueOf( 'info', 'txtHeight', Math.round( height ) ); |
| 660 | updatePreview( this ); |
| 661 | } |
| 662 | } |
| 663 | }, this ); |
| 664 | ratioButton.on( 'mouseover', function() |
| 665 | { |
| 666 | this.addClass( 'BtnOver' ); |
| 667 | }, ratioButton ); |
| 668 | ratioButton.on( 'mouseout', function() |
| 669 | { |
| 670 | this.removeClass( 'BtnOver' ); |
| 671 | }, ratioButton ); |
| 672 | } |
| 673 | }, |
| 674 | html : '<div>'+ |
| 675 | '<div title="' + editor.lang.image.lockRatio + |
| 676 | '" class="BtnLocked" id="btnLockSizes"></div>' + |
| 677 | '<div title="' + editor.lang.image.resetSize + |
| 678 | '" class="BtnReset" id="btnResetSize"></div>'+ |
| 679 | '</div>' |
| 680 | } |
| 681 | ] |
| 682 | }, |
| 683 | { |
| 684 | type : 'vbox', |
| 685 | padding : 1, |
| 686 | children : |
| 687 | [ |
| 688 | { |
| 689 | type : 'text', |
| 690 | id : 'txtBorder', |
| 691 | labelLayout : 'horizontal', |
| 692 | label : editor.lang.image.border, |
| 693 | 'default' : '', |
| 694 | onKeyUp : function() |
| 695 | { |
| 696 | updatePreview( this.getDialog() ); |
| 697 | }, |
| 698 | validate: function() |
| 699 | { |
| 700 | var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); |
| 701 | return func.apply( this ); |
| 702 | }, |
| 703 | setup : function( type, element ) |
| 704 | { |
| 705 | if ( type == IMAGE ) |
| 706 | this.setValue( element.getAttribute( 'border' ) ); |
| 707 | }, |
| 708 | commit : function( type, element ) |
| 709 | { |
| 710 | if ( type == IMAGE ) |
| 711 | { |
| 712 | if ( this.getValue() != '' || this.isChanged() ) |
| 713 | element.setAttribute( 'border', this.getValue() ); |
| 714 | } |
| 715 | else if ( type == PREVIEW ) |
| 716 | { |
| 717 | var value = parseInt( this.getValue(), 10 ); |
| 718 | value = isNaN( value ) ? 0 : value; |
| 719 | element.setAttribute( 'border', value ); |
| 720 | element.setStyle( 'border', value + 'px solid black' ); |
| 721 | } |
| 722 | else if ( type == CLEANUP ) |
| 723 | { |
| 724 | element.removeAttribute( 'border' ); |
| 725 | element.removeStyle( 'border' ); |
| 726 | } |
| 727 | } |
| 728 | }, |
| 729 | { |
| 730 | type : 'text', |
| 731 | id : 'txtHSpace', |
| 732 | labelLayout : 'horizontal', |
| 733 | label : editor.lang.image.hSpace, |
| 734 | 'default' : '', |
| 735 | onKeyUp : function() |
| 736 | { |
| 737 | updatePreview( this.getDialog() ); |
| 738 | }, |
| 739 | validate: function() |
| 740 | { |
| 741 | var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); |
| 742 | return func.apply( this ); |
| 743 | }, |
| 744 | setup : function( type, element ) |
| 745 | { |
| 746 | if ( type == IMAGE ) |
| 747 | { |
| 748 | var value = element.getAttribute( 'hspace' ); |
| 749 | if ( value != -1 ) // In IE empty = -1. |
| 750 | this.setValue( value ); |
| 751 | } |
| 752 | }, |
| 753 | commit : function( type, element ) |
| 754 | { |
| 755 | if ( type == IMAGE ) |
| 756 | { |
| 757 | if ( this.getValue() != '' || this.isChanged() ) |
| 758 | element.setAttribute( 'hspace', this.getValue() ); |
| 759 | } |
| 760 | else if ( type == PREVIEW ) |
| 761 | { |
| 762 | var value = parseInt( this.getValue(), 10 ); |
| 763 | value = isNaN( value ) ? 0 : value; |
| 764 | element.setAttribute( 'hspace', value ); |
| 765 | element.setStyle( 'margin-left', value + 'px' ); |
| 766 | element.setStyle( 'margin-right', value + 'px' ); |
| 767 | } |
| 768 | else if ( type == CLEANUP ) |
| 769 | { |
| 770 | element.removeAttribute( 'hspace' ); |
| 771 | element.removeStyle( 'margin-left' ); |
| 772 | element.removeStyle( 'margin-right' ); |
| 773 | } |
| 774 | } |
| 775 | }, |
| 776 | { |
| 777 | type : 'text', |
| 778 | id : 'txtVSpace', |
| 779 | labelLayout : 'horizontal', |
| 780 | label : editor.lang.image.vSpace, |
| 781 | 'default' : '', |
| 782 | onKeyUp : function() |
| 783 | { |
| 784 | updatePreview( this.getDialog() ); |
| 785 | }, |
| 786 | validate: function() |
| 787 | { |
| 788 | var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); |
| 789 | return func.apply( this ); |
| 790 | }, |
| 791 | setup : function( type, element ) |
| 792 | { |
| 793 | if ( type == IMAGE ) |
| 794 | this.setValue( element.getAttribute( 'vspace' ) ); |
| 795 | }, |
| 796 | commit : function( type, element ) |
| 797 | { |
| 798 | if ( type == IMAGE ) |
| 799 | { |
| 800 | if ( this.getValue() != '' || this.isChanged() ) |
| 801 | element.setAttribute( 'vspace', this.getValue() ); |
| 802 | } |
| 803 | else if ( type == PREVIEW ) |
| 804 | { |
| 805 | var value = parseInt( this.getValue(), 10 ); |
| 806 | value = isNaN( value ) ? 0 : value; |
| 807 | element.setAttribute( 'vspace', this.getValue() ); |
| 808 | element.setStyle( 'margin-top', value + 'px' ); |
| 809 | element.setStyle( 'margin-bottom', value + 'px' ); |
| 810 | } |
| 811 | else if ( type == CLEANUP ) |
| 812 | { |
| 813 | element.removeAttribute( 'vspace' ); |
| 814 | element.removeStyle( 'margin-top' ); |
| 815 | element.removeStyle( 'margin-bottom' ); |
| 816 | } |
| 817 | } |
| 818 | }, |
| 819 | { |
| 820 | id : 'cmbAlign', |
| 821 | type : 'select', |
| 822 | labelLayout : 'horizontal', |
| 823 | widths : [ '35%','65%' ], |
| 824 | style : 'width:100%', |
| 825 | label : editor.lang.image.align, |
| 826 | 'default' : '', |
| 827 | items : |
| 828 | [ |
| 829 | [ editor.lang.common.notSet , ''], |
| 830 | [ editor.lang.image.alignLeft , 'left'], |
| 831 | [ editor.lang.image.alignAbsBottom , 'absBottom'], |
| 832 | [ editor.lang.image.alignAbsMiddle , 'absMiddle'], |
| 833 | [ editor.lang.image.alignBaseline , 'baseline'], |
| 834 | [ editor.lang.image.alignBottom , 'bottom'], |
| 835 | [ editor.lang.image.alignMiddle , 'middle'], |
| 836 | [ editor.lang.image.alignRight , 'right'], |
| 837 | [ editor.lang.image.alignTextTop , 'textTop'], |
| 838 | [ editor.lang.image.alignTop , 'top'] |
| 839 | ], |
| 840 | onKeyUp : function() |
| 841 | { |
| 842 | updatePreview( this.getDialog() ); |
| 843 | }, |
| 844 | setup : function( type, element ) |
| 845 | { |
| 846 | if ( type == IMAGE ) |
| 847 | this.setValue( element.getAttribute( 'align' ) ); |
| 848 | }, |
| 849 | commit : function( type, element ) |
| 850 | { |
| 851 | if ( type == IMAGE ) |
| 852 | { |
| 853 | if ( this.getValue() != '' || this.isChanged() ) |
| 854 | element.setAttribute( 'align', this.getValue() ); |
| 855 | } |
| 856 | else if ( type == PREVIEW ) |
| 857 | { |
| 858 | element.setAttribute( 'align', this.getValue() ); |
| 859 | } |
| 860 | else if ( type == CLEANUP ) |
| 861 | { |
| 862 | element.removeAttribute( 'align' ); |
| 863 | } |
| 864 | } |
| 865 | } |
| 866 | ] |
| 867 | } |
| 868 | ] |
| 869 | }, |
| 870 | { |
| 871 | type : 'vbox', |
| 872 | height : '250px', |
| 873 | children : |
| 874 | [ |
| 875 | { |
| 876 | type : 'html', |
| 877 | style : 'width:95%;', |
| 878 | html : '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.image.preview ) +'<br>'+ |
| 879 | '<div id="ImagePreviewLoader" style="display:none"><div class="loading"> </div></div>'+ |
| 880 | '<div id="ImagePreviewBox">'+ |
| 881 | '<a href="javascript:void(0)" target="_blank" onclick="return false;" id="previewLink">'+ |
| 882 | '<img id="previewImage" src="" /></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '+ |
| 883 | 'Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, '+ |
| 884 | '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.' + |
| 885 | '</div>'+'</div>' |
| 886 | } |
| 887 | ] |
| 888 | } |
| 889 | ] |
| 890 | } |
| 891 | ] |
| 892 | }, |
| 893 | { |
| 894 | id : 'Link', |
| 895 | label : editor.lang.link.title, |
| 896 | padding : 0, |
| 897 | elements : |
| 898 | [ |
| 899 | { |
| 900 | id : 'txtUrl', |
| 901 | type : 'text', |
| 902 | label : editor.lang.image.url, |
| 903 | style : 'width: 100%', |
| 904 | 'default' : '', |
| 905 | setup : function( type, element ) |
| 906 | { |
| 907 | if ( type == LINK ) |
| 908 | { |
| 909 | var href = element.getAttribute( '_cke_saved_href' ); |
| 910 | if ( !href ) |
| 911 | href = element.getAttribute( 'href' ); |
| 912 | this.setValue( href ); |
| 913 | } |
| 914 | }, |
| 915 | commit : function( type, element ) |
| 916 | { |
| 917 | if ( type == LINK ) |
| 918 | if ( this.getValue() != '' || this.isChanged() ) |
| 919 | { |
| 920 | element.setAttribute( '_cke_saved_href', decodeURI( this.getValue() ) ); |
| 921 | element.setAttribute( 'href', 'javascript:void(0)/*' + |
| 922 | CKEDITOR.tools.getNextNumber() + '*/' ); |
| 923 | |
| 924 | if ( this.getValue() != '' || editor.config.image.removeLinkByEmptyURL == false ) |
| 925 | this.getDialog().addLink = true; |
| 926 | } |
| 927 | } |
| 928 | }, |
| 929 | { |
| 930 | type : 'button', |
| 931 | id : 'browse', |
| 932 | style : 'float:right', |
| 933 | label : editor.lang.common.browseServer, |
| 934 | onClick : function() |
| 935 | { |
| 936 | // TODO: remove the next line before commit |
| 937 | this.getDialog().setValueOf( "Link", "txtUrl", "http://www.fckeditor.net/" ); |
| 938 | } |
| 939 | }, |
| 940 | { |
| 941 | id : 'cmbTarget', |
| 942 | type : 'select', |
| 943 | label : editor.lang.link.target, |
| 944 | 'default' : '', |
| 945 | items : |
| 946 | [ |
| 947 | [ editor.lang.link.targetNotSet , ''], |
| 948 | [ editor.lang.link.targetNew , '_blank'], |
| 949 | [ editor.lang.link.targetTop , '_top'], |
| 950 | [ editor.lang.link.targetSelf , '_self'], |
| 951 | [ editor.lang.link.targetParent , '_parent'] |
| 952 | ], |
| 953 | setup : function( type, element ) |
| 954 | { |
| 955 | if ( type == LINK ) |
| 956 | this.setValue( element.getAttribute( 'target' ) ); |
| 957 | }, |
| 958 | commit : function( type, element ) |
| 959 | { |
| 960 | if ( type == LINK ) |
| 961 | if ( this.getValue() != '' || this.isChanged() ) |
| 962 | element.setAttribute( 'target', this.getValue() ); |
| 963 | } |
| 964 | } |
| 965 | ] |
| 966 | }, |
| 967 | { |
| 968 | id : 'Upload', |
| 969 | label : editor.lang.image.upload, |
| 970 | elements : |
| 971 | [ |
| 972 | { |
| 973 | type : 'file', |
| 974 | id : 'upload', |
| 975 | label : editor.lang.image.btnUpload, |
| 976 | action : editor.config.image.uploadAction, |
| 977 | size : 38 |
| 978 | }, |
| 979 | { |
| 980 | type : 'fileButton', |
| 981 | id : 'uploadButton', |
| 982 | label : editor.lang.image.btnUpload, |
| 983 | 'for' : [ 'Upload', 'upload' ] |
| 984 | } |
| 985 | ] |
| 986 | }, |
| 987 | { |
| 988 | id : 'advanced', |
| 989 | label : editor.lang.common.advancedTab, |
| 990 | elements : |
| 991 | [ |
| 992 | { |
| 993 | type : 'hbox', |
| 994 | widths : [ '50%', '25%', '25%' ], |
| 995 | children : |
| 996 | [ |
| 997 | { |
| 998 | type : 'text', |
| 999 | id : 'linkId', |
| 1000 | label : editor.lang.common.id, |
| 1001 | setup : function( type, element ) |
| 1002 | { |
| 1003 | if ( type == IMAGE ) |
| 1004 | this.setValue( element.getAttribute( 'id' ) ); |
| 1005 | }, |
| 1006 | commit : function( type, element ) |
| 1007 | { |
| 1008 | if ( type == IMAGE ) |
| 1009 | if ( this.getValue() != '' || this.isChanged() ) |
| 1010 | element.setAttribute( 'id', this.getValue() ); |
| 1011 | } |
| 1012 | }, |
| 1013 | { |
| 1014 | id : 'cmbLangDir', |
| 1015 | type : 'select', |
| 1016 | style : 'width : 100%;', |
| 1017 | label : editor.lang.common.langDir, |
| 1018 | 'default' : '', |
| 1019 | items : |
| 1020 | [ |
| 1021 | [ editor.lang.common.notSet, '' ], |
| 1022 | [ editor.lang.common.langDirLtr, 'ltr' ], |
| 1023 | [ editor.lang.common.langDirRtl, 'rtl' ] |
| 1024 | ], |
| 1025 | setup : function( type, element ) |
| 1026 | { |
| 1027 | if ( type == IMAGE ) |
| 1028 | this.setValue( element.getAttribute( 'dir' ) ); |
| 1029 | }, |
| 1030 | commit : function( type, element ) |
| 1031 | { |
| 1032 | if ( type == IMAGE ) |
| 1033 | if ( this.getValue() != '' || this.isChanged() ) |
| 1034 | element.setAttribute( 'dir', this.getValue() ); |
| 1035 | } |
| 1036 | }, |
| 1037 | { |
| 1038 | type : 'text', |
| 1039 | id : 'txtLangCode', |
| 1040 | label : editor.lang.common.langCode, |
| 1041 | 'default' : '', |
| 1042 | setup : function( type, element ) |
| 1043 | { |
| 1044 | if ( type == IMAGE ) |
| 1045 | this.setValue( element.getAttribute( 'lang' ) ); |
| 1046 | }, |
| 1047 | commit : function( type, element ) |
| 1048 | { |
| 1049 | if ( type == IMAGE ) |
| 1050 | if ( this.getValue() != '' || this.isChanged() ) |
| 1051 | element.setAttribute( 'lang', this.getValue() ); |
| 1052 | } |
| 1053 | } |
| 1054 | ] |
| 1055 | }, |
| 1056 | { |
| 1057 | type : 'text', |
| 1058 | id : 'txtGenLongDescr', |
| 1059 | label : editor.lang.common.longDescr, |
| 1060 | setup : function( type, element ) |
| 1061 | { |
| 1062 | if ( type == IMAGE ) |
| 1063 | this.setValue( element.getAttribute( 'longDesc' ) ); |
| 1064 | }, |
| 1065 | commit : function( type, element ) |
| 1066 | { |
| 1067 | if ( type == IMAGE ) |
| 1068 | if ( this.getValue() != '' || this.isChanged() ) |
| 1069 | element.setAttribute( 'longDesc', this.getValue() ); |
| 1070 | } |
| 1071 | }, |
| 1072 | { |
| 1073 | type : 'hbox', |
| 1074 | widths : [ '50%', '50%' ], |
| 1075 | children : |
| 1076 | [ |
| 1077 | { |
| 1078 | type : 'text', |
| 1079 | id : 'txtGenClass', |
| 1080 | label : editor.lang.common.cssClass, |
| 1081 | 'default' : '', |
| 1082 | setup : function( type, element ) |
| 1083 | { |
| 1084 | if ( type == IMAGE ) |
| 1085 | this.setValue( element.getAttribute( 'class' ) ); |
| 1086 | }, |
| 1087 | commit : function( type, element ) |
| 1088 | { |
| 1089 | if ( type == IMAGE ) |
| 1090 | if ( this.getValue() != '' || this.isChanged() ) |
| 1091 | element.setAttribute( 'class', this.getValue() ); |
| 1092 | } |
| 1093 | }, |
| 1094 | { |
| 1095 | type : 'text', |
| 1096 | id : 'txtGenTitle', |
| 1097 | label : editor.lang.common.advisoryTitle, |
| 1098 | 'default' : '', |
| 1099 | onChange : function() |
| 1100 | { |
| 1101 | updatePreview( this.getDialog() ); |
| 1102 | }, |
| 1103 | setup : function( type, element ) |
| 1104 | { |
| 1105 | if ( type == IMAGE ) |
| 1106 | this.setValue( element.getAttribute( 'title' ) ); |
| 1107 | }, |
| 1108 | commit : function( type, element ) |
| 1109 | { |
| 1110 | if ( type == IMAGE ) |
| 1111 | { |
| 1112 | if ( this.getValue() != '' || this.isChanged() ) |
| 1113 | element.setAttribute( 'title', this.getValue() ); |
| 1114 | } |
| 1115 | else if ( type == PREVIEW ) |
| 1116 | { |
| 1117 | element.setAttribute( 'title', this.getValue() ); |
| 1118 | } |
| 1119 | else if ( type == CLEANUP ) |
| 1120 | { |
| 1121 | element.removeAttribute( 'title' ); |
| 1122 | } |
| 1123 | } |
| 1124 | } |
| 1125 | ] |
| 1126 | }, |
| 1127 | { |
| 1128 | type : 'text', |
| 1129 | id : 'txtdlgGenStyle', |
| 1130 | label : editor.lang.common.cssStyle, |
| 1131 | 'default' : '', |
| 1132 | setup : function( type, element ) |
| 1133 | { |
| 1134 | if ( type == IMAGE ) |
| 1135 | { |
| 1136 | var genStyle = element.getAttribute( 'style' ); |
| 1137 | if ( !genStyle && element.$.style.cssText ) |
| 1138 | genStyle = element.$.style.cssText; |
| 1139 | this.setValue( genStyle ); |
| 1140 | |
| 1141 | var height = element.$.style.height, |
| 1142 | width = element.$.style.width, |
| 1143 | aMatchH = ( height ? height : '' ).match( regexGetSize ), |
| 1144 | aMatchW = ( width ? width : '').match( regexGetSize ); |
| 1145 | |
| 1146 | this.attributesInStyle = |
| 1147 | { |
| 1148 | height : !!aMatchH, |
| 1149 | width : !!aMatchW |
| 1150 | } |
| 1151 | } |
| 1152 | }, |
| 1153 | commit : function( type, element ) |
| 1154 | { |
| 1155 | if ( type == IMAGE && ( this.getValue() != '' || this.isChanged() ) ) |
| 1156 | { |
| 1157 | element.setAttribute( 'style', this.getValue() ); |
| 1158 | |
| 1159 | // Set STYLE dimensions. |
| 1160 | var height = element.getAttribute( 'height' ); |
| 1161 | width = element.getAttribute( 'width' ); |
| 1162 | |
| 1163 | if ( this.attributesInStyle.height ) |
| 1164 | { |
| 1165 | if ( height && height != '' ) |
| 1166 | { |
| 1167 | if ( height.match( regexGetSize )[2] == '%' ) // % is allowed |
| 1168 | element.setStyle( 'height', height + '%' ); |
| 1169 | else |
| 1170 | element.setStyle( 'height', height + 'px' ); |
| 1171 | } |
| 1172 | else |
| 1173 | element.removeStyle( 'height' ); |
| 1174 | } |
| 1175 | if ( this.attributesInStyle.width ) |
| 1176 | { |
| 1177 | if ( width && width != '' ) |
| 1178 | if ( width.match( regexGetSize )[2] == '%' ) // % is allowed |
| 1179 | element.setStyle( 'width', width + '%' ); |
| 1180 | else |
| 1181 | element.setStyle( 'width', width + 'px' ); |
| 1182 | else |
| 1183 | element.removeStyle( 'width' ); |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | ] |
| 1189 | } |
| 1190 | ] |
| 1191 | }; |
| 1192 | }; |
| 1193 | |
| 1194 | CKEDITOR.dialog.add( 'image', function( editor ) |
| 1195 | { |
| 1196 | return imageDialog( editor, 'image' ) |
| 1197 | } |
| 1198 | ); |
| 1199 | |
| 1200 | CKEDITOR.dialog.add( 'imagebutton', function( editor ) |
| 1201 | { |
| 1202 | return imageDialog( editor, 'imagebutton' ) |
| 1203 | } |
| 1204 | ); |