]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/forms/dialogs/button.js
7bc64d4cb5571b1c8917f1b1abe14629556f5443
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
6 CKEDITOR
.dialog
.add( 'button', function( editor
) {
7 function commitAttributes( element
) {
8 var val
= this.getValue();
10 element
.attributes
[ this.id
] = val
;
11 if ( this.id
== 'name' )
12 element
.attributes
[ 'data-cke-saved-name' ] = val
;
14 delete element
.attributes
[ this.id
];
15 if ( this.id
== 'name' )
16 delete element
.attributes
[ 'data-cke-saved-name' ];
21 title: editor
.lang
.forms
.button
.title
,
26 var element
= this.getParentEditor().getSelection().getSelectedElement();
27 if ( element
&& element
.is( 'input' ) ) {
28 var type
= element
.getAttribute( 'type' );
29 if ( type
in { button: 1, reset: 1, submit: 1 } ) {
30 this.button
= element
;
31 this.setupContent( element
);
36 var editor
= this.getParentEditor(),
37 element
= this.button
,
38 isInsertMode
= !element
;
40 var fake
= element
? CKEDITOR
.htmlParser
.fragment
.fromHtml( element
.getOuterHtml() ).children
[ 0 ] : new CKEDITOR
.htmlParser
.element( 'input' );
41 this.commitContent( fake
);
43 var writer
= new CKEDITOR
.htmlParser
.basicWriter();
44 fake
.writeHtml( writer
);
45 var newElement
= CKEDITOR
.dom
.element
.createFromHtml( writer
.getHtml(), editor
.document
);
48 editor
.insertElement( newElement
);
50 newElement
.replace( element
);
51 editor
.getSelection().selectElement( newElement
);
56 label: editor
.lang
.forms
.button
.title
,
57 title: editor
.lang
.forms
.button
.title
,
63 label: editor
.lang
.common
.name
,
65 setup: function( element
) {
66 this.setValue( element
.data( 'cke-saved-name' ) || element
.getAttribute( 'name' ) || '' );
68 commit: commitAttributes
73 label: editor
.lang
.forms
.button
.text
,
76 setup: function( element
) {
77 this.setValue( element
.getAttribute( 'value' ) || '' );
79 commit: commitAttributes
84 label: editor
.lang
.forms
.button
.type
,
88 [ editor
.lang
.forms
.button
.typeBtn
, 'button' ],
89 [ editor
.lang
.forms
.button
.typeSbm
, 'submit' ],
90 [ editor
.lang
.forms
.button
.typeRst
, 'reset' ]
92 setup: function( element
) {
93 this.setValue( element
.getAttribute( 'type' ) || '' );
95 commit: commitAttributes