]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/forms/dialogs/radio.js
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
5 CKEDITOR
.dialog
.add( 'radio', function( editor
) {
7 title: editor
.lang
.forms
.checkboxAndRadio
.radioTitle
,
11 delete this.radioButton
;
13 var element
= this.getParentEditor().getSelection().getSelectedElement();
14 if ( element
&& element
.getName() == 'input' && element
.getAttribute( 'type' ) == 'radio' ) {
15 this.radioButton
= element
;
16 this.setupContent( element
);
21 element
= this.radioButton
,
22 isInsertMode
= !element
;
25 editor
= this.getParentEditor();
26 element
= editor
.document
.createElement( 'input' );
27 element
.setAttribute( 'type', 'radio' );
31 editor
.insertElement( element
);
32 this.commitContent( { element: element
} );
36 label: editor
.lang
.forms
.checkboxAndRadio
.radioTitle
,
37 title: editor
.lang
.forms
.checkboxAndRadio
.radioTitle
,
41 label: editor
.lang
.common
.name
,
44 setup: function( element
) {
45 this.setValue( element
.data( 'cke-saved-name' ) || element
.getAttribute( 'name' ) || '' );
47 commit: function( data
) {
48 var element
= data
.element
;
50 if ( this.getValue() )
51 element
.data( 'cke-saved-name', this.getValue() );
53 element
.data( 'cke-saved-name', false );
54 element
.removeAttribute( 'name' );
61 label: editor
.lang
.forms
.checkboxAndRadio
.value
,
64 setup: function( element
) {
65 this.setValue( element
.getAttribute( 'value' ) || '' );
67 commit: function( data
) {
68 var element
= data
.element
;
70 if ( this.getValue() )
71 element
.setAttribute( 'value', this.getValue() );
73 element
.removeAttribute( 'value' );
79 label: editor
.lang
.forms
.checkboxAndRadio
.selected
,
83 setup: function( element
) {
84 this.setValue( element
.getAttribute( 'checked' ) );
86 commit: function( data
) {
87 var element
= data
.element
;
89 if ( !CKEDITOR
.env
.ie
) {
90 if ( this.getValue() )
91 element
.setAttribute( 'checked', 'checked' );
93 element
.removeAttribute( 'checked' );
95 var isElementChecked
= element
.getAttribute( 'checked' );
96 var isChecked
= !!this.getValue();
98 if ( isElementChecked
!= isChecked
) {
99 var replace
= CKEDITOR
.dom
.element
.createFromHtml( '<input type="radio"' + ( isChecked
? ' checked="checked"' : '' ) +
100 '></input>', editor
.document
);
101 element
.copyAttributes( replace
, { type: 1, checked: 1 } );
102 replace
.replace( element
);
103 editor
.getSelection().selectElement( replace
);
104 data
.element
= replace
;
112 label: editor
.lang
.forms
.checkboxAndRadio
.required
,
116 setup: function( element
) {
117 this.setValue( element
.getAttribute( 'required' ) );
119 commit: function( data
) {
120 var element
= data
.element
;
121 if ( this.getValue() )
122 element
.setAttribute( 'required', 'required' );
124 element
.removeAttribute( 'required' );