2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
9 function setupAdvParams( element )
\r
11 var attrName = this.att;
\r
13 var value = element && element.hasAttribute( attrName ) && element.getAttribute( attrName ) || '';
\r
15 if ( value !== undefined )
\r
16 this.setValue( value );
\r
19 function commitAdvParams()
\r
21 // Dialogs may use different parameters in the commit list, so, by
\r
22 // definition, we take the first CKEDITOR.dom.element available.
\r
25 for ( var i = 0 ; i < arguments.length ; i++ )
\r
27 if ( arguments[ i ] instanceof CKEDITOR.dom.element )
\r
29 element = arguments[ i ];
\r
36 var attrName = this.att,
\r
37 value = this.getValue();
\r
39 // Broadcast Lang Dir change
\r
40 if ( attrName == 'dir' )
\r
42 var dir = element.getAttribute( attrName );
\r
43 if ( dir != value && element.getParent() )
\r
44 this._.dialog._.editor.fire( 'dirChanged', { node : element, dir : value || element.getDirection( 1 ) } );
\r
48 element.setAttribute( attrName, value );
\r
50 element.removeAttribute( attrName, value );
\r
54 CKEDITOR.plugins.add( 'dialogadvtab',
\r
59 * id, dir, classes, styles
\r
61 createAdvancedTab : function( editor, tabConfig )
\r
64 tabConfig = { id:1, dir:1, classes:1, styles:1 };
\r
66 var lang = editor.lang.common;
\r
71 label : lang.advancedTab,
\r
72 title : lang.advancedTab,
\r
85 if ( tabConfig.id || tabConfig.dir )
\r
95 setup : setupAdvParams,
\r
96 commit : commitAdvParams
\r
100 if ( tabConfig.dir )
\r
107 label : lang.langDir,
\r
109 style : 'width:100%',
\r
112 [ lang.notSet, '' ],
\r
113 [ lang.langDirLTR, 'ltr' ],
\r
114 [ lang.langDirRTL, 'rtl' ]
\r
116 setup : setupAdvParams,
\r
117 commit : commitAdvParams
\r
121 result.elements[ 0 ].children.push(
\r
124 widths : [ '50%', '50%' ],
\r
125 children : [].concat( contents )
\r
129 if ( tabConfig.styles || tabConfig.classes )
\r
133 if ( tabConfig.styles )
\r
140 label : lang.styles,
\r
143 getStyle : function( name, defaultValue )
\r
145 var match = this.getValue().match( new RegExp( name + '\\s*:\s*([^;]*)', 'i') );
\r
146 return match ? match[ 1 ] : defaultValue;
\r
149 updateStyle : function( name, value )
\r
151 var styles = this.getValue();
\r
153 // Remove the current value.
\r
157 .replace( new RegExp( '\\s*' + name + '\s*:[^;]*(?:$|;\s*)', 'i' ), '' )
\r
158 .replace( /^[;\s]+/, '' )
\r
159 .replace( /\s+$/, '' );
\r
164 styles && !(/;\s*$/).test( styles ) && ( styles += '; ' );
\r
165 styles += name + ': ' + value;
\r
168 this.setValue( styles, 1 );
\r
172 setup : setupAdvParams,
\r
174 commit : commitAdvParams
\r
179 if ( tabConfig.classes )
\r
184 widths : [ '45%', '55%' ],
\r
188 id : 'advCSSClasses',
\r
191 label : lang.cssClasses,
\r
193 setup : setupAdvParams,
\r
194 commit : commitAdvParams
\r
201 result.elements[ 0 ].children.push(
\r
204 widths : [ '50%', '50%' ],
\r
205 children : [].concat( contents )
\r