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