| | 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 | var func = setupMeta( 'content-type', 1, 1 ), |
| | 303 | val = func.call( this ), |
| | 304 | match = val.match( /charset=[^=]+$/ ); |
| | 305 | if ( match ) |
| | 306 | { |
| | 307 | val = val.substring( val.indexOf( '=' ) + 1 ); |
| | 308 | this.setValue( val.toLowerCase() ); |
| | 309 | if ( !this.getValue() ) |
| | 310 | { |
| | 311 | this.setValue( 'other' ); |
| | 312 | var other = this.getDialog().getContentElement( 'general', 'charsetOther' ); |
| | 313 | other && other.setValue( val ); |
| | 314 | } |
| | 315 | this.getDialog().selectedCharset = val; |
| | 316 | } |
| | 317 | handleOther.call( this ); |
| | 318 | }, |
| | 319 | commit : function( doc, html, head, body, isPreview ) |
| | 320 | { |
| | 321 | if ( isPreview ) |
| | 322 | return; |
| | 323 | var value = this.getValue(), |
| | 324 | other = this.getDialog().getContentElement( 'general', 'charsetOther' ); |
| | 325 | var func = commitMeta( 'content-type', 1, 'text/html; charset=' + ( value == 'other' ? ( other ? other.getValue() : '' ) : value ) ); |
| | 326 | func.call( this, doc, html, head ); |
| | 327 | } |
| | 328 | }, |
| | 329 | { |
| | 330 | type : 'text', |
| | 331 | id : 'charsetOther', |
| | 332 | label : lang.charsetOther, |
| | 333 | onChange : function(){ this.getDialog().selectedCharset = this.getValue(); } |
| | 334 | } |
| | 335 | ] |
| | 336 | }, |
| | 337 | { |
| | 338 | type : 'hbox', |
| | 339 | children : [ |
| | 340 | { |
| | 341 | type : 'select', |
| | 342 | id : 'docType', |
| | 343 | label : lang.docType, |
| | 344 | style : 'width: 100%', |
| | 345 | items : [ |
| | 346 | [ langCommon.notSet , '' ], |
| | 347 | [ 'XHTML 1.1', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' ], |
| | 348 | [ 'XHTML 1.0 Transitional', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ], |
| | 349 | [ 'XHTML 1.0 Strict', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' ], |
| | 350 | [ 'XHTML 1.0 Frameset', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' ], |
| | 351 | [ 'HTML 5', '<!DOCTYPE html>' ], |
| | 352 | [ 'HTML 4.01 Transitional', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' ], |
| | 353 | [ 'HTML 4.01 Strict', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' ], |
| | 354 | [ 'HTML 4.01 Frameset', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">' ], |
| | 355 | [ 'HTML 3.2', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' ], |
| | 356 | [ 'HTML 2.0', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">' ], |
| | 357 | [ lang.other, 'other' ] |
| | 358 | ], |
| | 359 | onChange : handleOther, |
| | 360 | setup : function() |
| | 361 | { |
| | 362 | if ( editor.docType ) |
| | 363 | { |
| | 364 | this.setValue( editor.docType ); |
| | 365 | if ( !this.getValue() ) |
| | 366 | { |
| | 367 | this.setValue( 'other' ); |
| | 368 | var other = this.getDialog().getContentElement( 'general', 'docTypeOther' ); |
| | 369 | other && other.setValue( editor.docType ); |
| | 370 | } |
| | 371 | } |
| | 372 | handleOther.call( this ); |
| | 373 | }, |
| | 374 | commit : function( doc, html, head, body, isPreview ) |
| | 375 | { |
| | 376 | if ( isPreview ) |
| | 377 | return; |
| | 378 | var value = this.getValue(), |
| | 379 | other = this.getDialog().getContentElement( 'general', 'docTypeOther' ); |
| | 380 | editor.docType = value == 'other' ? ( other ? other.getValue() : '' ) : value; |
| | 381 | } |
| | 382 | }, |
| | 383 | { |
| | 384 | type : 'text', |
| | 385 | id : 'docTypeOther', |
| | 386 | label : lang.docTypeOther |
| | 387 | } |
| | 388 | ] |
| | 389 | }, |
| | 390 | { |
| | 391 | type : 'checkbox', |
| | 392 | id : 'xhtmlDec', |
| | 393 | label : lang.xhtmlDec, |
| | 394 | setup : function() |
| | 395 | { |
| | 396 | this.setValue( !!editor.xmlDeclaration ); |
| | 397 | }, |
| | 398 | commit : function( doc, html, head, body, isPreview ) |
| | 399 | { |
| | 400 | if ( isPreview ) |
| | 401 | return; |
| | 402 | if ( this.getValue() ) |
| | 403 | { |
| | 404 | editor.xmlDeclaration = '<?xml version="1.0" encoding="' + ( this.getDialog().selectedCharset || 'utf-8' )+ '"?>' ; |
| | 405 | html.setAttribute( 'xmlns', 'http://www.w3.org/1999/xhtml' ); |
| | 406 | } |
| | 407 | else |
| | 408 | { |
| | 409 | editor.xmlDeclaration = ''; |
| | 410 | html.removeAttribute( 'xmlns' ); |
| | 411 | } |
| | 412 | } |
| | 413 | } |
| | 414 | ] |
| | 415 | }, |
| | 416 | { |
| | 417 | id : 'design', |
| | 418 | label : lang.design, |
| | 419 | elements : [ |
| | 420 | { |
| | 421 | type : 'hbox', |
| | 422 | widths : [ '60%', '40%' ], |
| | 423 | children : [ |
| | 424 | { |
| | 425 | type : 'vbox', |
| | 426 | children : [ |
| | 427 | colorField( 'txtColor', 'txtColor', |
| | 428 | { |
| | 429 | setup : function( doc, html, head, body ) |
| | 430 | { |
| | 431 | this.setValue( body.getComputedStyle( 'color' ) ); |
| | 432 | }, |
| | 433 | commit : function( doc, html, head, body ) |
| | 434 | { |
| | 435 | body.removeAttribute( 'text' ); |
| | 436 | var val = this.getValue(); |
| | 437 | if ( val ) |
| | 438 | body.setStyle( 'color', val ); |
| | 439 | else |
| | 440 | body.removeStyle( 'color' ); |
| | 441 | } |
| | 442 | }), |
| | 443 | colorField( 'bgColor', 'bgColor', { |
| | 444 | setup : function( doc, html, head, body ) |
| | 445 | { |
| | 446 | var val = body.getComputedStyle( 'background-color' ) || ''; |
| | 447 | this.setValue( val == 'transparent' ? '' : val ); |
| | 448 | }, |
| | 449 | commit : function( doc, html, head, body ) |
| | 450 | { |
| | 451 | body.removeAttribute( 'bgcolor' ); |
| | 452 | var val = this.getValue(); |
| | 453 | if ( val ) |
| | 454 | body.setStyle( 'background-color', val ); |
| | 455 | else |
| | 456 | resetStyle( body, 'background-color', 'transparent' ); |
| | 457 | } |
| | 458 | }), |
| | 459 | { |
| | 460 | type : 'hbox', |
| | 461 | widths : [ '60%', '40%' ], |
| | 462 | padding : 0, |
| | 463 | children : [ |
| | 464 | { |
| | 465 | type : 'text', |
| | 466 | id : 'bgImage', |
| | 467 | label : lang.bgImage, |
| | 468 | setup : function( doc, html, head, body ) |
| | 469 | { |
| | 470 | var val = body.getComputedStyle( 'background-image' ) || ''; |
| | 471 | if ( val == 'none' ) |
| | 472 | val = ''; |
| | 473 | else |
| | 474 | { |
| | 475 | val = val.replace( /url\(\s*(["']?)\s*([^\)]*)\s*\1\s*\)/i, function( match, quote, url ) |
| | 476 | { |
| | 477 | return url; |
| | 478 | }); |
| | 479 | } |
| | 480 | this.setValue( val ); |
| | 481 | }, |
| | 482 | commit : function( doc, html, head, body ) |
| | 483 | { |
| | 484 | body.removeAttribute( 'background' ); |
| | 485 | var val = this.getValue(); |
| | 486 | if ( val ) |
| | 487 | body.setStyle( 'background-image', 'url(' + val + ')' ); |
| | 488 | else |
| | 489 | resetStyle( body, 'background-image', 'none' ); |
| | 490 | } |
| | 491 | }, |
| | 492 | { |
| | 493 | type : 'button', |
| | 494 | id : 'bgImageChoose', |
| | 495 | label : langCommon.browseServer, |
| | 496 | style : 'display:inline-block;margin-top:10px;', |
| | 497 | hidden : true, |
| | 498 | filebrowser : 'bg:bgImage' |
| | 499 | } |
| | 500 | ] |
| | 501 | }, |
| | 502 | { |
| | 503 | type : 'checkbox', |
| | 504 | id : 'bgFixed', |
| | 505 | label : lang.bgFixed, |
| | 506 | setup : function( doc, html, head, body ) |
| | 507 | { |
| | 508 | this.setValue( body.getComputedStyle( 'background-attachment' ) == 'fixed' ); |
| | 509 | }, |
| | 510 | commit : function( doc, html, head, body ) |
| | 511 | { |
| | 512 | if ( this.getValue() ) |
| | 513 | body.setStyle( 'background-attachment', 'fixed' ); |
| | 514 | else |
| | 515 | resetStyle( body, 'background-attachment', 'scroll' ); |
| | 516 | } |
| | 517 | } |
| | 518 | ] |
| | 519 | }, |
| | 520 | { |
| | 521 | type : 'vbox', |
| | 522 | children : [ |
| | 523 | { |
| | 524 | type : 'html', |
| | 525 | id : 'marginTitle', |
| | 526 | html : '<div style="text-align: center; margin: 0px auto; font-weight: bold">' + lang.margin + '</div>' |
| | 527 | }, |
| | 528 | { |
| | 529 | type : 'text', |
| | 530 | id : 'marginTop', |
| | 531 | label : lang.marginTop, |
| | 532 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| | 533 | controlStyle : 'text-align: center', |
| | 534 | setup : function( doc, html, head, body ) |
| | 535 | { |
| | 536 | this.setValue( body.getStyle( 'margin-top' ) || body.getAttribute( 'margintop' ) || '' ); |
| | 537 | }, |
| | 538 | commit : commitMargin( 'top' ), |
| | 539 | onLoad : function() |
| | 540 | { |
| | 541 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| | 542 | } |
| | 543 | }, |
| | 544 | { |
| | 545 | type : 'hbox', |
| | 546 | children : [ |
| | 547 | { |
| | 548 | type : 'text', |
| | 549 | id : 'marginLeft', |
| | 550 | label : lang.marginLeft, |
| | 551 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| | 552 | controlStyle : 'text-align: center', |
| | 553 | setup : function( doc, html, head, body ) |
| | 554 | { |
| | 555 | this.setValue( body.getStyle( 'margin-left' ) || body.getAttribute( 'marginleft' ) || '' ); |
| | 556 | }, |
| | 557 | commit : commitMargin( 'left' ), |
| | 558 | onLoad : function() |
| | 559 | { |
| | 560 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| | 561 | } |
| | 562 | }, |
| | 563 | { |
| | 564 | type : 'text', |
| | 565 | id : 'marginRight', |
| | 566 | label : lang.marginRight, |
| | 567 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| | 568 | controlStyle : 'text-align: center', |
| | 569 | setup : function( doc, html, head, body ) |
| | 570 | { |
| | 571 | this.setValue( body.getStyle( 'margin-right' ) || body.getAttribute( 'marginright' ) || '' ); |
| | 572 | }, |
| | 573 | commit : commitMargin( 'right' ), |
| | 574 | onLoad : function() |
| | 575 | { |
| | 576 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| | 577 | } |
| | 578 | } |
| | 579 | ] |
| | 580 | }, |
| | 581 | { |
| | 582 | type : 'text', |
| | 583 | id : 'marginBottom', |
| | 584 | label : lang.marginBottom, |
| | 585 | style : 'width: 80px; text-align: center; margin: 0px auto', |
| | 586 | controlStyle : 'text-align: center', |
| | 587 | setup : function( doc, html, head, body ) |
| | 588 | { |
| | 589 | this.setValue( body.getStyle( 'margin-bottom' ) || body.getAttribute( 'marginbottom' ) || '' ); |
| | 590 | }, |
| | 591 | commit : commitMargin( 'bottom' ), |
| | 592 | onLoad : function() |
| | 593 | { |
| | 594 | this.getElement().getParent().setStyle( 'text-align', 'center' ); |
| | 595 | } |
| | 596 | } |
| | 597 | ] |
| | 598 | } |
| | 599 | ] |
| | 600 | } |
| | 601 | ] |
| | 602 | }, |
| | 603 | { |
| | 604 | id : 'meta', |
| | 605 | label : lang.meta, |
| | 606 | elements : [ |
| | 607 | { |
| | 608 | type : 'textarea', |
| | 609 | id : 'metaKeywords', |
| | 610 | label : lang.metaKeywords, |
| | 611 | setup : setupMeta( 'keywords' ), |
| | 612 | commit : commitMeta( 'keywords' ) |
| | 613 | }, |
| | 614 | { |
| | 615 | type : 'textarea', |
| | 616 | id : 'metaDescription', |
| | 617 | label : lang.metaDescription, |
| | 618 | setup : setupMeta( 'description' ), |
| | 619 | commit : commitMeta( 'description' ) |
| | 620 | }, |
| | 621 | { |
| | 622 | type : 'text', |
| | 623 | id : 'metaAuthor', |
| | 624 | label : lang.metaAuthor, |
| | 625 | setup : setupMeta( 'author' ), |
| | 626 | commit : commitMeta( 'author' ) |
| | 627 | }, |
| | 628 | { |
| | 629 | type : 'text', |
| | 630 | id : 'metaCopyright', |
| | 631 | label : lang.metaCopyright, |
| | 632 | setup : setupMeta( 'copyright' ), |
| | 633 | commit : commitMeta( 'copyright' ) |
| | 634 | } |
| | 635 | ] |
| | 636 | }, |
| | 637 | { |
| | 638 | id : 'preview', |
| | 639 | label : langCommon.preview, |
| | 640 | elements : [ |
| | 641 | { |
| | 642 | type : 'html', |
| | 643 | id : 'previewHtml', |
| | 644 | html : '<iframe src="' + previewSrc + '" style="width: 100%; height: 310px" hidefocus="true" frameborder="0" ' + |
| | 645 | 'id="cke_docProps_preview_iframe"></iframe>', |
| | 646 | onLoad : function() |
| | 647 | { |
| | 648 | this.getDialog().on( 'selectPage', function( ev ) |
| | 649 | { |
| | 650 | if ( ev.data.page == 'preview' ) |
| | 651 | { |
| | 652 | var self = this; |
| | 653 | setTimeout( function() |
| | 654 | { |
| | 655 | var doc = CKEDITOR.document.getById( 'cke_docProps_preview_iframe' ).getFrameDocument(), |
| | 656 | html = doc.getElementsByTag( 'html' ).getItem( 0 ), |
| | 657 | head = doc.getHead(), |
| | 658 | body = doc.getBody(); |
| | 659 | self.commitContent( doc, html, head, body, 1 ); |
| | 660 | }, 0 ); |
| | 661 | } |
| | 662 | }); |
| | 663 | CKEDITOR.document.getById( 'cke_docProps_preview_iframe' ).getAscendant( 'table' ).setStyle( 'height', '100%' ); |
| | 664 | } |
| | 665 | } |
| | 666 | ] |
| | 667 | } |
| | 668 | ] |
| | 669 | }; |
| | 670 | } ); |