source: trunk/admin/inc/ckeditor/_source/plugins/dialogadvtab/plugin.js@ 404

Last change on this file since 404 was 239, checked in by luc, 9 years ago

Admin: correzione visulaizzazione immissione dati spoglio per Chrome e Safari - Aggiornamento dell'editor da FCKeditor a CKeditor , accessibili anche a Chrome e Safari.

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