| 1 | /* |
| 2 | Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. |
| 3 | For licensing, see LICENSE.html or http://ckeditor.com/license |
| 4 | */ |
| 5 | |
| 6 | CKEDITOR.dialog.add( 'docProps', function( editor ) |
| 7 | { |
| 8 | var lang = editor.lang.docprops, |
| 9 | langCommon = editor.lang.common, |
| 10 | metaHash = {}; |
| 11 | |
| 12 | function getDialogValue( dialogName, callback ) |
| 13 | { |
| 14 | var onOk = function() |
| 15 | { |
| 16 | releaseHandlers( this ); |
| 17 | callback( this, this._.parentDialog ); |
| 18 | }; |
| 19 | var releaseHandlers = function( dialog ) |
| 20 | { |
| 21 | dialog.removeListener( 'ok', onOk ); |
| 22 | dialog.removeListener( 'cancel', releaseHandlers ); |
| 23 | }; |
| 24 | var bindToDialog = function( dialog ) |
| 25 | { |
| 26 | dialog.on( 'ok', onOk ); |
| 27 | dialog.on( 'cancel', releaseHandlers ); |
| 28 | }; |
| 29 | editor.execCommand( dialogName ); |
| 30 | if ( editor._.storedDialogs.colordialog ) |
| 31 | bindToDialog( editor._.storedDialogs.colordialog ); |
| 32 | else |
| 33 | { |
| 34 | CKEDITOR.on( 'dialogDefinition', function( e ) |
| 35 | { |
| 36 | if ( e.data.name != dialogName ) |
| 37 | return; |
| 38 | |
| 39 | var definition = e.data.definition; |
| 40 | |
| 41 | e.removeListener(); |
| 42 | definition.onLoad = CKEDITOR.tools.override( definition.onLoad, function( orginal ) |
| 43 | { |
| 44 | return function() |
| 45 | { |
| 46 | bindToDialog( this ); |
| 47 | definition.onLoad = orginal; |
| 48 | if ( typeof orginal == 'function' ) |
| 49 | orginal.call( this ); |
| 50 | }; |
| 51 | }); |
| 52 | }); |
| 53 | } |
| 54 | } |
| 55 | function handleOther() |
| 56 | { |
| 57 | var dialog = this.getDialog(), |
| 58 | other = dialog.getContentElement( 'general', this.id + 'Other' ); |
| 59 | if ( !other ) |
| 60 | return; |
| 61 | if ( this.getValue() == 'other' ) |
| 62 | { |
| 63 | other.getInputElement().removeAttribute( 'readOnly' ); |
| 64 | other.focus(); |
| 65 | other.getElement().removeClass( 'cke_disabled' ); |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | other.getInputElement().setAttribute( 'readOnly', true ); |
| 70 | other.getElement().addClass( 'cke_disabled' ); |
| 71 | } |
| 72 | } |
| 73 | function commitMeta( name, isHttp, value ) |
| 74 | { |
| 75 | return function( doc, html, head ) |
| 76 | { |
| 77 | var hash = metaHash, |
| 78 | val = typeof value != 'undefined' ? value : this.getValue(); |
| 79 | if ( !val && ( name in hash ) ) |
| 80 | hash[ name ].remove(); |
| 81 | else if ( val && ( name in hash ) ) |
| 82 | hash[ name ].setAttribute( 'content', val ); |
| 83 | else if ( val ) |
| 84 | { |
| 85 | var meta = new CKEDITOR.dom.element( 'meta', editor.document ); |
| 86 | meta.setAttribute( isHttp ? 'http-equiv' : 'name', name ); |
| 87 | meta.setAttribute( 'content', val ); |
| 88 | head.append( meta ); |
| 89 | } |
| 90 | }; |
| 91 | } |
| 92 | function setupMeta( name, ret ) |
| 93 | { |
| 94 | return function() |
| 95 | { |
| 96 | var hash = metaHash, |
| 97 | result = ( name in hash ) ? hash[ name ].getAttribute( 'content' ) || '' : ''; |
| 98 | if ( ret ) |
| 99 | return result; |
| 100 | this.setValue( result ); |
| 101 | }; |
| 102 | } |
| 103 | function commitMargin( name ) |
| 104 | { |
| 105 | return function( doc, html, head, body ) |
| 106 | { |
| 107 | body.removeAttribute( 'margin' + name ); |
| 108 | var val = this.getValue(); |
| 109 | if ( val !== '' ) |
| 110 | body.setStyle( 'margin-' + name, CKEDITOR.tools.cssLength( val ) ); |
| 111 | else |
| 112 | body.removeStyle( 'margin-' + name ); |
| 113 | }; |
| 114 | } |
| 115 | |
| 116 | function createMetaHash( doc ) |
| 117 | { |
| 118 | var hash = {}, |
| 119 | metas = doc.getElementsByTag( 'meta' ), |
| 120 | count = metas.count(); |
| 121 | |
| 122 | for ( var i = 0; i < count; i++ ) |
| 123 | { |
| 124 | var meta = metas.getItem( i ); |
| 125 | hash[ meta.getAttribute( meta.hasAttribute( 'http-equiv' ) ? 'http-equiv' : 'name' ).toLowerCase() ] = meta; |
| 126 | } |
| 127 | return hash; |
| 128 | } |
| 129 | // We cannot just remove the style from the element, as it might be affected from non-inline stylesheets. |
| 130 | // To get the proper result, we should manually set the inline style to its default value. |
| 131 | function resetStyle( element, prop, resetVal ) |
| 132 | { |
| 133 | element.removeStyle( prop ); |
| 134 | if ( element.getComputedStyle( prop ) != resetVal ) |
| 135 | element.setStyle( prop, resetVal ); |
| 136 | } |
| 137 | |
| 138 | // Utilty to shorten the creation of color fields in the dialog. |
| 139 | var colorField = function( id, label, fieldProps ) |
| 140 | { |
| 141 | return { |
| 142 | type : 'hbox', |
| 143 | padding : 0, |
| 144 | widths : [ '60%', '40%' ], |
| 145 | children : [ |
| 146 | CKEDITOR.tools.extend( { |
| 147 | type : 'text', |
| 148 | id : id, |
| 149 | label : lang[ label ] |
| 150 | }, fieldProps || {}, 1 ), |
| 151 | { |
| 152 | type : 'button', |
| 153 | id : id + 'Choose', |
| 154 | label : lang.chooseColor, |
| 155 | className : 'colorChooser', |
| 156 | onClick : function() |
| 157 | { |
| 158 | var self = this; |
| 159 | getDialogValue( 'colordialog', function( colorDialog ) |
| 160 | { |
| 161 | var dialog = self.getDialog(); |
| 162 | dialog.getContentElement( dialog._.currentTabId, id ).setValue( colorDialog.getContentElement( 'picker', 'selectedColor' ).getValue() ); |
| 163 | }); |
| 164 | } |
| 165 | } |
| 166 | ] |
| 167 | }; |
| 168 | }; |
| 169 | var previewSrc = 'javascript:' + |
| 170 | 'void((function(){' + |
| 171 | encodeURIComponent( |
| 172 | 'document.open();' + |
| 173 | ( CKEDITOR.env.isCustomDomain() ? 'document.domain=\'' + document.domain + '\';' : '' ) + |
| 174 | 'document.write( \'<html style="background-color: #ffffff; height: 100%"><head></head><body style="width: 100%; height: 100%; margin: 0px">' + lang.previewHtml + '</body></html>\' );' + |
| 175 | 'document.close();' |
| 176 | ) + |
| 177 | '})())'; |
| 178 | |
| 179 | return { |
| 180 | title : lang.title, |
| 181 | minHeight: 330, |
| 182 | minWidth: 500, |
| 183 | onShow : function() |
| 184 | { |
| 185 | var doc = editor.document, |
| 186 | html = doc.getElementsByTag( 'html' ).getItem( 0 ), |
| 187 | head = doc.getHead(), |
| 188 | body = doc.getBody(); |
| 189 | metaHash = createMetaHash( doc ); |
| 190 | this.setupContent( doc, html, head, body ); |
| 191 | }, |
| 192 | onHide : function() |
| 193 | { |
| 194 | metaHash = {}; |
| 195 | }, |
| 196 | onOk : function() |
| 197 | { |
| 198 | var doc = editor.document, |
| 199 | html = doc.getElementsByTag( 'html' ).getItem( 0 ), |
| 200 | head = doc.getHead(), |
| 201 | body = doc.getBody(); |
| 202 | this.commitContent( doc, html, head, body ); |
| 203 | }, |
| 204 | contents : [ |
| 205 | { |
| 206 | id : 'general', |
| 207 | label : langCommon.generalTab, |
| 208 | elements : [ |
| 209 | { |
| 210 | type : 'text', |
| 211 | id : 'title', |
| 212 | label : lang.docTitle, |
| 213 | setup : function( doc ) |
| 214 | { |
| 215 | this.setValue( doc.getElementsByTag( 'title' ).getItem( 0 ).data( 'cke-title' ) ); |
| 216 | }, |
| 217 | commit : function( doc, html, head, body, isPreview ) |
| 218 | { |
| 219 | if ( isPreview ) |
| 220 | return; |
| 221 | doc.getElementsByTag( 'title' ).getItem( 0 ).data( 'cke-title', this.getValue() ); |
| 222 | } |
| 223 | }, |
| 224 | { |
| 225 | type : 'hbox', |
| 226 | children : [ |
| 227 | { |
| 228 | type : 'select', |
| 229 | id : 'dir', |
| 230 | label : langCommon.langDir, |
| 231 | style : 'width: 100%', |
| 232 | items : [ |
| 233 | [ langCommon.notSet , '' ], |
| 234 | [ langCommon.langDirLtr, 'ltr' ], |
| 235 | [ langCommon.langDirRtl, 'rtl' ] |
| 236 | ], |
| 237 | setup : function( doc, html, head, body ) |
| 238 | { |
| 239 | this.setValue( body.getDirection() || '' ); |
| 240 | }, |
| 241 | commit : function( doc, html, head, body ) |
| 242 | { |
| 243 | var val = this.getValue(); |
| 244 | if ( val ) |
| 245 | body.setAttribute( 'dir', val ); |
| 246 | else |
| 247 | body.removeAttribute( 'dir' ); |
| 248 | body.removeStyle( 'direction' ); |
| 249 | } |
| 250 | }, |
| 251 | { |
| 252 | type : 'text', |
| 253 | id : 'langCode', |
| 254 | label : langCommon.langCode, |
| 255 | setup : function( doc, html ) |
| 256 | { |
| 257 | this.setValue( html.getAttribute( 'xml:lang' ) || html.getAttribute( 'lang' ) || '' ); |
| 258 | }, |
| 259 | commit : function( doc, html, head, body, isPreview ) |
| 260 | { |
| 261 | if ( isPreview ) |
| 262 | return; |
| 263 | var val = this.getValue(); |
| 264 | if ( val ) |
| 265 | html.setAttributes( { 'xml:lang' : val, lang : val } ); |
| 266 | else |
| 267 | html.removeAttributes( { 'xml:lang' : 1, lang : 1 } ); |
| 268 | } |
| 269 | } |
| 270 | ] |
| 271 | }, |
| 272 | { |
| 273 | type : 'hbox', |
| 274 | children : [ |
| 275 | { |
| 276 | type : 'select', |
| 277 | id : 'charset', |
| 278 | label : lang.charset, |
| 279 | style : 'width: 100%', |
| 280 | items : [ |
| 281 | [ langCommon.notSet, '' ], |
| 282 | [ lang.charsetASCII, 'us-ascii' ], |
| 283 | [ lang.charsetCE, 'iso-8859-2' ], |
| 284 | [ lang.charsetCT, 'big5' ], |
| 285 | [ lang.charsetCR, 'iso-8859-5' ], |
| 286 | [ lang.charsetGR, 'iso-8859-7' ], |
| 287 | [ lang.charsetJP, 'iso-2022-jp' ], |
| 288 | [ lang.charsetKR, 'iso-2022-kr' ], |
| 289 | [ lang.charsetTR, 'iso-8859-9' ], |
| 290 | [ lang.charsetUN, 'utf-8' ], |
| 291 | [ lang.charsetWE, 'iso-8859-1' ], |
| 292 | [ lang.other, 'other' ] |
| 293 | ], |
| 294 | 'default' : '', |
| 295 | onChange : function() |
| 296 | { |
| 297 | this.getDialog().selectedCharset = this.getValue() != 'other' ? this.getValue() : ''; |
| 298 | handleOther.call( this ); |
| 299 | }, |
| 300 | setup : function() |
| 301 | { |
| 302 | this.metaCharset = ( 'charset' in metaHash ); |
| 303 | |
| 304 | var func = setupMeta( this.metaCharset ? 'charset' : 'content-type', 1, 1 ), |
| 305 | val = func.call( this ), |
| 306 | match = !this.metaCharset && val.match( /charset=[^=]+$/ ); |
| 307 | |
| 308 | if ( match ) |
| 309 | { |
| 310 | this.savedContentType = val.substring( 0, val.indexOf( ';' ) ); |
| 311 | val = val.substring( val.indexOf( '=' ) + 1 ); |
| 312 | } |
| 313 | |
| 314 | if ( val ) |
| 315 | { |
| 316 | this.setValue( val.toLowerCase() ); |
| 317 | if ( !this.getValue() ) |
| 318 | { |
| 319 | this.setValue( 'other' ); |
| 320 | var other = this.getDialog().getContentElement( 'general', 'charsetOther' ); |
| 321 | other && other.setValue( val ); |
| 322 | } |
| 323 | this.getDialog().selectedCharset = val; |
| 324 | } |
| 325 | |
| 326 | handleOther.call( this ); |
| 327 | }, |
| 328 | commit : function( doc, html, head, body, isPreview ) |
| 329 | { |
| 330 | if ( isPreview ) |
| 331 | return; |
| 332 | var value = this.getValue(), |
| 333 | other = this.getDialog().getContentElement( 'general', 'charsetOther' ); |
| 334 | |
| 335 | value == 'other' && ( value = other ? other.getValue() : '' ); |
| 336 | value && !this.metaCharset && ( value = ( this.savedContentType || 'text/html' ) + '; charset=' + value ); |
| 337 | |
| 338 | var func = commitMeta( this.metaCharset ? 'charset' : 'content-type', 1, value ); |
| 339 | func.call( this, doc, html, head ); |
| 340 | } |
| 341 | }, |
| 342 | { |
| 343 | type : 'text', |
| 344 | id : 'charsetOther', |
| 345 | label : lang.charsetOther, |
| 346 | onChange : function(){ this.getDialog().selectedCharset = this.getValue(); } |
| 347 | } |
| 348 | ] |
| 349 | }, |
| 350 | { |
| 351 | type : 'hbox', |
| 352 | children : [ |
| 353 | { |
| 354 | type : 'select', |
| 355 | id : 'docType', |
| 356 | label : lang.docType, |
| 357 | style : 'width: 100%', |
| 358 | items : [ |
| 359 | [ langCommon.notSet , '' ], |
| 360 | [ 'XHTML 1.1', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' ], |
| 361 | [ 'XHTML 1.0 Transitional', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ], |
| 362 | [ 'XHTML 1.0 Strict', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' ], |
| 363 | [ 'XHTML 1.0 Frameset', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' ], |
| 364 | [ 'HTML 5', '<!DOCTYPE html>' ], |
| 365 | [ 'HTML 4.01 Transitional', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' ], |
| 366 | [ 'HTML 4.01 Strict', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' ], |
| 367 | [ 'HTML 4.01 Frameset', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">' ], |
| 368 | [ 'HTML 3.2', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' ], |
| 369 | [ 'HTML 2.0', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">' ], |
| 370 | [ lang.other, 'other' ] |
| 371 | ], |
| 372 | onChange : handleOther, |
| 373 | setup : function() |
| 374 | { |
| 375 | if ( editor.docType ) |
| 376 | { |
| 377 | this.setValue( editor.docType ); |
| 378 | if ( !this.getValue() ) |
| 379 | { |
| 380 | this.setValue( 'other' ); |
| 381 | var other = this.getDialog().getContentElement( 'general', 'docTypeOther' ); |
| 382 | other && other.setValue( editor.docType ); |
| 383 | } |
| 384 | } |
| 385 | handleOther.call( this ); |
| 386 | }, |
| 387 | commit : function( doc, html, head, body, isPreview ) |
| 388 | { |
| 389 | if ( isPreview ) |
| 390 | return; |
| 391 | var value = this.getValue(), |
| 392 | other = this.getDialog().getContentElement( 'general', 'docTypeOther' ); |
| 393 | editor.docType = value == 'other' ? ( other ? other.getValue() : '' ) : value; |
| 394 | } |
| 395 | }, |
| 396 | { |
| 397 | type : 'text', |
| 398 | id : 'docTypeOther', |
| 399 | label : lang.docTypeOther |
| 400 | } |
| 401 | ] |
| 402 | }, |
| 403 | { |
| 404 | type : 'checkbox', |
| 405 | id : 'xhtmlDec', |
| 406 | label : lang.xhtmlDec, |
| 407 | setup : function() |
| 408 | { |
| 409 | this.setValue( !!editor.xmlDeclaration ); |
| 410 | }, |
| 411 | commit : function( doc, html, head, body, isPreview ) |
| 412 | { |
| 413 | if ( isPreview ) |
| 414 | return; |
| 415 | if ( this.getValue() ) |
| 416 | { |
| 417 | editor.xmlDeclaration = '<?xml version="1.0" encoding="' + ( this.getDialog().selectedCharset || 'utf-8' )+ '"?>' ; |
| 418 | html.setAttribute( 'xmlns', 'http://www.w3.org/1999/xhtml' ); |
| 419 | } |
| 420 | else |
| 421 | { |
| 422 | editor.xmlDeclaration = ''; |
| 423 | html.removeAttribute( 'xmlns' ); |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | ] |
| 428 | }, |
| 429 | { |
| 430 | id : 'design', |
| 431 | label : lang.design, |
| 432 | elements : [ |
| 433 | { |
| 434 | type : 'hbox', |
| 435 | widths : [ '60%', '40%' ], |
| 436 | children : [ |
| 437 | { |
| 438 | type : 'vbox', |
| 439 | children : [ |
| 440 | colorField( 'txtColor', 'txtColor', |
| 441 | { |
| 442 | setup : function( doc, html, head, body ) |
| 443 | { |
| 444 | this.setValue( body.getComputedStyle( 'color' ) ); |
| 445 | }, |
| 446 | commit : function( doc, html, head, body ) |
| 447 | { |
| 448 | body.removeAttribute( 'text' ); |
| 449 | var val = this.getValue(); |
| 450 | if ( val ) |
| 451 | body.setStyle( 'color', val ); |
| 452 | else |
| 453 | body.removeStyle( 'color' ); |
| 454 | } |
| 455 | }), |
| 456 | colorField( 'bgColor', 'bgColor', { |
| 457 | setup : function( doc, html, head, body ) |
| 458 | { |
| 459 | var val = body.getComputedStyle( 'background-color' ) || ''; |
| 460 | this.setValue( val == 'transparent' ? '' : val ); |
| 461 | }, |
| 462 | commit : function( doc, html, head, body ) |
| 463 | { |
| 464 | body.removeAttribute( 'bgcolor' ); |
| 465 | var val = this.getValue(); |
| 466 | if ( val ) |
| 467 | body.setStyle( 'background-color', val ); |
| 468 | else |
| 469 | resetStyle( body, 'background-color', 'transparent' ); |
| 470 | } |
| 471 | }), |
| 472 | { |
| 473 | type : 'hbox', |
| 474 | widths : [ '60%', '40%' ], |
| 475 | padding : 0, |
| 476 | children : [ |
| 477 | { |
| 478 | type : 'text', |
| 479 | id : 'bgImage', |
| 480 | label : lang.bgImage, |
| 481 | setup : function( doc, html, head, body ) |
| 482 | { |
| 483 | var val = body.getComputedStyle( 'background-image' ) || ''; |
| 484 | if ( val == 'none' ) |
| 485 | val = ''; |
| 486 | else |
| 487 | { |
| 488 | val = val.replace( /url\(\s*(["']?)\s*([^\)]*)\s*\1\s*\)/i, function( match, quote, url ) |
| 489 | { |
| 490 | return url; |
| 491 | }); |
| 492 | } |
| 493 | this.setValue( val ); |
| 494 | }, |
| 495 | commit : function( doc, html, head, body ) |
| 496 | { |
| 497 | body.removeAttribute( 'background' ); |
| 498 | var val = this.getValue(); |
| 499 | if ( val ) |
| 500 | body.setStyle( 'background-image', 'url(' + val + ')' ); |
| 501 | else |
| 502 | resetStyle( body, 'background-image', 'none' ); |
| 503 | } |
| 504 | }, |
| 505 | { |
| 506 | type : 'button', |
| 507 | id : 'bgImageChoose', |
| 508 | label : langCommon.browseServer, |
| 509 | style : 'display:inline-block;margin-top:10px;', |
| 510 | hidden : true, |
| 511 | filebrowser : 'bg:bgImage' |
| 512 | } |
| 513 | ] |
| 514 | }, |
| 515 | { |
| 516 | type : 'checkbox', |
| 517 | id : 'bgFixed', |
| 518 | label : lang.bgFixed, |
| 519 | setup : function( doc, html, head, body ) |
| 520 | { |
| 521 | this.setValue( body.getComputedStyle( 'background-attachment' ) == 'fixed' ); |
| 522 | }, |
| 523 | commit : function( doc, html, head, body ) |
| 524 | { |
| 525 | if ( this.getValue() ) |
| 526 | body.setStyle( 'background-attachment', 'fixed' ); |
| 527 | else |
| 528 | resetStyle( body, 'background-attachment', 'scroll' ); |
| 529 | } |
| 530 | } |
| 531 | ] |
| 532 | }, |
| 533 | { |
| 534 | type : 'vbox', |
| 535 | children : [ |
| 536 | { |
| 537 | type : 'html', |
| 538 | id : 'marginTitle', |
| 539 | html : '<div style="text-align: center; margin: 0px auto; font-weight: bold">' + lang.margin + '</div>' |
| 540 | }, |
| 541 | { |
| 542 | type : 'text', |
| 543 | id : 'marginTop', |
| 544 | label : lang.marginTop, |
| 545 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| 546 | controlStyle : 'text-align: center', |
| 547 | setup : function( doc, html, head, body ) |
| 548 | { |
| 549 | this.setValue( body.getStyle( 'margin-top' ) || body.getAttribute( 'margintop' ) || '' ); |
| 550 | }, |
| 551 | commit : commitMargin( 'top' ), |
| 552 | onLoad : function() |
| 553 | { |
| 554 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| 555 | } |
| 556 | }, |
| 557 | { |
| 558 | type : 'hbox', |
| 559 | children : [ |
| 560 | { |
| 561 | type : 'text', |
| 562 | id : 'marginLeft', |
| 563 | label : lang.marginLeft, |
| 564 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| 565 | controlStyle : 'text-align: center', |
| 566 | setup : function( doc, html, head, body ) |
| 567 | { |
| 568 | this.setValue( body.getStyle( 'margin-left' ) || body.getAttribute( 'marginleft' ) || '' ); |
| 569 | }, |
| 570 | commit : commitMargin( 'left' ), |
| 571 | onLoad : function() |
| 572 | { |
| 573 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| 574 | } |
| 575 | }, |
| 576 | { |
| 577 | type : 'text', |
| 578 | id : 'marginRight', |
| 579 | label : lang.marginRight, |
| 580 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| 581 | controlStyle : 'text-align: center', |
| 582 | setup : function( doc, html, head, body ) |
| 583 | { |
| 584 | this.setValue( body.getStyle( 'margin-right' ) || body.getAttribute( 'marginright' ) || '' ); |
| 585 | }, |
| 586 | commit : commitMargin( 'right' ), |
| 587 | onLoad : function() |
| 588 | { |
| 589 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| 590 | } |
| 591 | } |
| 592 | ] |
| 593 | }, |
| 594 | { |
| 595 | type : 'text', |
| 596 | id : 'marginBottom', |
| 597 | label : lang.marginBottom, |
| 598 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| 599 | controlStyle : 'text-align: center', |
| 600 | setup : function( doc, html, head, body ) |
| 601 | { |
| 602 | this.setValue( body.getStyle( 'margin-bottom' ) || body.getAttribute( 'marginbottom' ) || '' ); |
| 603 | }, |
| 604 | commit : commitMargin( 'bottom' ), |
| 605 | onLoad : function() |
| 606 | { |
| 607 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| 608 | } |
| 609 | } |
| 610 | ] |
| 611 | } |
| 612 | ] |
| 613 | } |
| 614 | ] |
| 615 | }, |
| 616 | { |
| 617 | id : 'meta', |
| 618 | label : lang.meta, |
| 619 | elements : [ |
| 620 | { |
| 621 | type : 'textarea', |
| 622 | id : 'metaKeywords', |
| 623 | label : lang.metaKeywords, |
| 624 | setup : setupMeta( 'keywords' ), |
| 625 | commit : commitMeta( 'keywords' ) |
| 626 | }, |
| 627 | { |
| 628 | type : 'textarea', |
| 629 | id : 'metaDescription', |
| 630 | label : lang.metaDescription, |
| 631 | setup : setupMeta( 'description' ), |
| 632 | commit : commitMeta( 'description' ) |
| 633 | }, |
| 634 | { |
| 635 | type : 'text', |
| 636 | id : 'metaAuthor', |
| 637 | label : lang.metaAuthor, |
| 638 | setup : setupMeta( 'author' ), |
| 639 | commit : commitMeta( 'author' ) |
| 640 | }, |
| 641 | { |
| 642 | type : 'text', |
| 643 | id : 'metaCopyright', |
| 644 | label : lang.metaCopyright, |
| 645 | setup : setupMeta( 'copyright' ), |
| 646 | commit : commitMeta( 'copyright' ) |
| 647 | } |
| 648 | ] |
| 649 | }, |
| 650 | { |
| 651 | id : 'preview', |
| 652 | label : langCommon.preview, |
| 653 | elements : [ |
| 654 | { |
| 655 | type : 'html', |
| 656 | id : 'previewHtml', |
| 657 | html : '<iframe src="' + previewSrc + '" style="width: 100%; height: 310px" hidefocus="true" frameborder="0" ' + |
| 658 | 'id="cke_docProps_preview_iframe"></iframe>', |
| 659 | onLoad : function() |
| 660 | { |
| 661 | this.getDialog().on( 'selectPage', function( ev ) |
| 662 | { |
| 663 | if ( ev.data.page == 'preview' ) |
| 664 | { |
| 665 | var self = this; |
| 666 | setTimeout( function() |
| 667 | { |
| 668 | var doc = CKEDITOR.document.getById( 'cke_docProps_preview_iframe' ).getFrameDocument(), |
| 669 | html = doc.getElementsByTag( 'html' ).getItem( 0 ), |
| 670 | head = doc.getHead(), |
| 671 | body = doc.getBody(); |
| 672 | self.commitContent( doc, html, head, body, 1 ); |
| 673 | }, 0 ); |
| 674 | } |
| 675 | }); |
| 676 | CKEDITOR.document.getById( 'cke_docProps_preview_iframe' ).getAscendant( 'table' ).setStyle( 'height', '100%' ); |
| 677 | } |
| 678 | } |
| 679 | ] |
| 680 | } |
| 681 | ] |
| 682 | }; |
| 683 | } ); |