41d3d30e3be744072a96b0e40d8face1bc8bdfef.svn-base
3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
function setupAdvParams( element )
{
var attrName = this.att;
var value = element && element.hasAttribute( attrName ) && element.getAttribute( attrName ) || '';
if ( value !== undefined )
this.setValue( value );
}
function commitAdvParams()
{
// Dialogs may use different parameters in the commit list, so, by
// definition, we take the first CKEDITOR.dom.element available.
var element;
for ( var i = 0 ; i < arguments.length ; i++ )
{
if ( arguments[ i ] instanceof CKEDITOR.dom.element )
{
element = arguments[ i ];
break;
}
}
if ( element )
{
var attrName = this.att,
value = this.getValue();
if ( value )
element.setAttribute( attrName, value );
else
element.removeAttribute( attrName, value );
}
}
CKEDITOR.plugins.add( 'dialogadvtab',
{
/**
*
* @param tabConfig
* id, dir, classes, styles
*/
createAdvancedTab : function( editor, tabConfig )
{
if ( !tabConfig )
tabConfig = { id:1, dir:1, classes:1, styles:1 };
var lang = editor.lang.common;
var result =
{
id : 'advanced',
label : lang.advancedTab,
title : lang.advancedTab,
elements :
[
{
type : 'vbox',
padding : 1,
children : []
}
]
};
var contents = [];
if ( tabConfig.id || tabConfig.dir )
{
if ( tabConfig.id )
{
contents.push(
{
id : 'advId',
att : 'id',
type : 'text',
label : lang.id,
setup : setupAdvParams,
commit : commitAdvParams
});
}
if ( tabConfig.dir )
{
contents.push(
{
id : 'advLangDir',
att : 'dir',
type : 'select',
label : lang.langDir,
'default' : '',
style : 'width:100%',
items :
[
[ lang.notSet, '' ],
[ lang.langDirLTR, 'ltr' ],
[ lang.langDirRTL, 'rtl' ]
],
setup : setupAdvParams,
commit : commitAdvParams
});
}
result.elements[ 0 ].children.push(
{
type : 'hbox',
widths : [ '50%', '50%' ],
children : [].concat( contents )
});
}
if ( tabConfig.styles || tabConfig.classes )
{
contents = [];
if ( tabConfig.styles )
{
contents.push(
{
id : 'advStyles',
att : 'style',
type : 'text',
label : lang.styles,
'default' : '',
validate : CKEDITOR.dialog.validate.inlineStyle( lang.invalidInlineStyle ),
onChange : function(){},
getStyle : function( name, defaultValue )
{
var match = this.getValue().match( new RegExp( name + '\\s*:\\s*([^;]*)', 'i') );
return match ? match[ 1 ] : defaultValue;
},
updateStyle : function( name, value )
{
var styles = this.getValue();
// Remove the current value.
if ( styles )
{
styles = styles
.replace( new RegExp( '\\s*' + name + '\s*:[^;]*(?:$|;\s*)', 'i' ), '' )
.replace( /^[;\s]+/, '' )
.replace( /\s+$/, '' );
}
if ( value )
{
styles && !(/;\s*$/).test( styles ) && ( styles += '; ' );
styles += name + ': ' + value;
}
this.setValue( styles, 1 );
},
setup : setupAdvParams,
commit : commitAdvParams
});
}
if ( tabConfig.classes )
{
contents.push(
{
type : 'hbox',
widths : [ '45%', '55%' ],
children :
[
{
id : 'advCSSClasses',
att : 'class',
type : 'text',
label : lang.cssClasses,
'default' : '',
setup : setupAdvParams,
commit : commitAdvParams
}
]
});
}
result.elements[ 0 ].children.push(
{
type : 'hbox',
widths : [ '50%', '50%' ],
children : [].concat( contents )
});
}
return result;
}
});
})();