]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/forms/dialogs/checkbox.js
0bfda9bac344313cd7d6a523a5df2b0007864ba9
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
6 CKEDITOR
.dialog
.add( 'checkbox', function( editor
) {
8 title: editor
.lang
.forms
.checkboxAndRadio
.checkboxTitle
,
14 var element
= this.getParentEditor().getSelection().getSelectedElement();
16 if ( element
&& element
.getAttribute( 'type' ) == 'checkbox' ) {
17 this.checkbox
= element
;
18 this.setupContent( element
);
23 element
= this.checkbox
,
24 isInsertMode
= !element
;
27 editor
= this.getParentEditor();
28 element
= editor
.document
.createElement( 'input' );
29 element
.setAttribute( 'type', 'checkbox' );
30 editor
.insertElement( element
);
32 this.commitContent( { element: element
} );
36 label: editor
.lang
.forms
.checkboxAndRadio
.checkboxTitle
,
37 title: editor
.lang
.forms
.checkboxAndRadio
.checkboxTitle
,
38 startupFocus: 'txtName',
42 label: editor
.lang
.common
.name
,
45 setup: function( element
) {
46 this.setValue( element
.data( 'cke-saved-name' ) || element
.getAttribute( 'name' ) || '' );
48 commit: function( data
) {
49 var element
= data
.element
;
51 // IE failed to update 'name' property on input elements, protect it now.
52 if ( this.getValue() )
53 element
.data( 'cke-saved-name', this.getValue() );
55 element
.data( 'cke-saved-name', false );
56 element
.removeAttribute( 'name' );
63 label: editor
.lang
.forms
.checkboxAndRadio
.value
,
66 setup: function( element
) {
67 var value
= element
.getAttribute( 'value' );
68 // IE Return 'on' as default attr value.
69 this.setValue( CKEDITOR
.env
.ie
&& value
== 'on' ? '' : value
);
71 commit: function( data
) {
72 var element
= data
.element
,
73 value
= this.getValue();
75 if ( value
&& !( CKEDITOR
.env
.ie
&& value
== 'on' ) )
76 element
.setAttribute( 'value', value
);
78 if ( CKEDITOR
.env
.ie
) {
79 // Remove attribute 'value' of checkbox (#4721).
80 var checkbox
= new CKEDITOR
.dom
.element( 'input', element
.getDocument() );
81 element
.copyAttributes( checkbox
, { value: 1 } );
82 checkbox
.replace( element
);
83 editor
.getSelection().selectElement( checkbox
);
84 data
.element
= checkbox
;
86 element
.removeAttribute( 'value' );
94 label: editor
.lang
.forms
.checkboxAndRadio
.selected
,
98 setup: function( element
) {
99 this.setValue( element
.getAttribute( 'checked' ) );
101 commit: function( data
) {
102 var element
= data
.element
;
104 if ( CKEDITOR
.env
.ie
) {
105 var isElementChecked
= !!element
.getAttribute( 'checked' ),
106 isChecked
= !!this.getValue();
108 if ( isElementChecked
!= isChecked
) {
109 var replace
= CKEDITOR
.dom
.element
.createFromHtml( '<input type="checkbox"' + ( isChecked
? ' checked="checked"' : '' ) +
110 '/>', editor
.document
);
112 element
.copyAttributes( replace
, { type: 1, checked: 1 } );
113 replace
.replace( element
);
114 editor
.getSelection().selectElement( replace
);
115 data
.element
= replace
;
118 var value
= this.getValue();
120 element
.setAttribute( 'checked', 'checked' );
122 element
.removeAttribute( 'checked' );
129 label: editor
.lang
.forms
.checkboxAndRadio
.required
,
133 setup: function( element
) {
134 this.setValue( element
.getAttribute( 'required' ) );
136 commit: function( data
) {
137 var element
= data
.element
;
138 if ( this.getValue() )
139 element
.setAttribute( 'required', 'required' );
141 element
.removeAttribute( 'required' );