]>
git.immae.eu Git - perso/Immae/Projets/packagist/piedsjaloux-ckeditor-component.git/blob - sources/plugins/dialogadvtab/plugin.js
2d4bcabc694cd33b63916e66123009363ee31ab8
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
8 function setupAdvParams( element
) {
9 var attrName
= this.att
;
11 var value
= element
&& element
.hasAttribute( attrName
) && element
.getAttribute( attrName
) || '';
13 if ( value
!== undefined )
14 this.setValue( value
);
17 function commitAdvParams() {
18 // Dialogs may use different parameters in the commit list, so, by
19 // definition, we take the first CKEDITOR.dom.element available.
22 for ( var i
= 0; i
< arguments
.length
; i
++ ) {
23 if ( arguments
[ i
] instanceof CKEDITOR
.dom
.element
) {
24 element
= arguments
[ i
];
30 var attrName
= this.att
,
31 value
= this.getValue();
34 element
.setAttribute( attrName
, value
);
36 element
.removeAttribute( attrName
, value
);
40 var defaultTabConfig
= { id: 1, dir: 1, classes: 1, styles: 1 };
42 CKEDITOR
.plugins
.add( 'dialogadvtab', {
45 // Returns allowed content rule for the content created by this plugin.
46 allowedContent: function( tabConfig
) {
48 tabConfig
= defaultTabConfig
;
50 var allowedAttrs
= [];
52 allowedAttrs
.push( 'id' );
54 allowedAttrs
.push( 'dir' );
58 if ( allowedAttrs
.length
)
59 allowed
+= '[' + allowedAttrs
.join( ',' ) + ']';
61 if ( tabConfig
.classes
)
63 if ( tabConfig
.styles
)
70 // id, dir, classes, styles
71 createAdvancedTab: function( editor
, tabConfig
, element
) {
73 tabConfig
= defaultTabConfig
;
75 var lang
= editor
.lang
.common
;
79 label: lang
.advancedTab
,
80 title: lang
.advancedTab
,
90 if ( tabConfig
.id
|| tabConfig
.dir
) {
96 requiredContent: element
? element
+ '[id]' : null,
98 setup: setupAdvParams
,
99 commit: commitAdvParams
103 if ( tabConfig
.dir
) {
108 requiredContent: element
? element
+ '[dir]' : null,
114 [ lang
.langDirLTR
, 'ltr' ],
115 [ lang
.langDirRTL
, 'rtl' ]
117 setup: setupAdvParams
,
118 commit: commitAdvParams
122 result
.elements
[ 0 ].children
.push( {
124 widths: [ '50%', '50%' ],
125 children: [].concat( contents
)
129 if ( tabConfig
.styles
|| tabConfig
.classes
) {
132 if ( tabConfig
.styles
) {
137 requiredContent: element
? element
+ '{cke-xyz}' : null,
141 validate: CKEDITOR
.dialog
.validate
.inlineStyle( lang
.invalidInlineStyle
),
142 onChange: function() {},
144 getStyle: function( name
, defaultValue
) {
145 var match
= this.getValue().match( new RegExp( '(?:^|;)\\s*' + name
+ '\\s*:\\s*([^;]*)', 'i' ) );
146 return match
? match
[ 1 ] : defaultValue
;
149 updateStyle: function( name
, value
) {
150 var styles
= this.getValue();
152 var tmp
= editor
.document
.createElement( 'span' );
153 tmp
.setAttribute( 'style', styles
);
154 tmp
.setStyle( name
, value
);
155 styles
= CKEDITOR
.tools
.normalizeCssText( tmp
.getAttribute( 'style' ) );
157 this.setValue( styles
, 1 );
160 setup: setupAdvParams
,
162 commit: commitAdvParams
167 if ( tabConfig
.classes
) {
170 widths: [ '45%', '55%' ],
175 requiredContent: element
? element
+ '(cke-xyz)' : null,
176 label: lang
.cssClasses
,
178 setup: setupAdvParams
,
179 commit: commitAdvParams
185 result
.elements
[ 0 ].children
.push( {
187 widths: [ '50%', '50%' ],
188 children: [].concat( contents
)