2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
9 function setupAdvParams( element )
11 var attrName = this.att;
13 var value = element && element.hasAttribute( attrName ) && element.getAttribute( attrName ) || '';
15 if ( value !== undefined )
16 this.setValue( value );
19 function commitAdvParams()
21 // Dialogs may use different parameters in the commit list, so, by
22 // definition, we take the first CKEDITOR.dom.element available.
25 for ( var i = 0 ; i < arguments.length ; i++ )
27 if ( arguments[ i ] instanceof CKEDITOR.dom.element )
29 element = arguments[ i ];
36 var attrName = this.att,
37 value = this.getValue();
40 element.setAttribute( attrName, value );
42 element.removeAttribute( attrName, value );
46 CKEDITOR.plugins.add( 'dialogadvtab',
51 * id, dir, classes, styles
53 createAdvancedTab : function( editor, tabConfig )
56 tabConfig = { id:1, dir:1, classes:1, styles:1 };
58 var lang = editor.lang.common;
63 label : lang.advancedTab,
64 title : lang.advancedTab,
77 if ( tabConfig.id || tabConfig.dir )
87 setup : setupAdvParams,
88 commit : commitAdvParams
101 style : 'width:100%',
105 [ lang.langDirLTR, 'ltr' ],
106 [ lang.langDirRTL, 'rtl' ]
108 setup : setupAdvParams,
109 commit : commitAdvParams
113 result.elements[ 0 ].children.push(
116 widths : [ '50%', '50%' ],
117 children : [].concat( contents )
121 if ( tabConfig.styles || tabConfig.classes )
125 if ( tabConfig.styles )
135 validate : CKEDITOR.dialog.validate.inlineStyle( lang.invalidInlineStyle ),
136 onChange : function(){},
138 getStyle : function( name, defaultValue )
140 var match = this.getValue().match( new RegExp( name + '\\s*:\\s*([^;]*)', 'i') );
141 return match ? match[ 1 ] : defaultValue;
144 updateStyle : function( name, value )
146 var styles = this.getValue();
148 // Remove the current value.
152 .replace( new RegExp( '\\s*' + name + '\s*:[^;]*(?:$|;\s*)', 'i' ), '' )
153 .replace( /^[;\s]+/, '' )
154 .replace( /\s+$/, '' );
159 styles && !(/;\s*$/).test( styles ) && ( styles += '; ' );
160 styles += name + ': ' + value;
163 this.setValue( styles, 1 );
167 setup : setupAdvParams,
169 commit : commitAdvParams
174 if ( tabConfig.classes )
179 widths : [ '45%', '55%' ],
183 id : 'advCSSClasses',
186 label : lang.cssClasses,
188 setup : setupAdvParams,
189 commit : commitAdvParams
196 result.elements[ 0 ].children.push(
199 widths : [ '50%', '50%' ],
200 children : [].concat( contents )