730864f6ce5e1948327da81fa5d9033dc3d71db3
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
5 CKEDITOR
.dialog
.add( 'button', function( editor
)
7 function commitAttributes( element
)
9 var val
= this.getValue();
12 element
.attributes
[ this.id
] = val
;
13 if ( this.id
== 'name' )
14 element
.attributes
[ 'data-cke-saved-name' ] = val
;
18 delete element
.attributes
[ this.id
];
19 if ( this.id
== 'name' )
20 delete element
.attributes
[ 'data-cke-saved-name' ];
25 title
: editor
.lang
.button
.title
,
31 var element
= this.getParentEditor().getSelection().getSelectedElement();
32 if ( element
&& element
.is( 'input' ) )
34 var type
= element
.getAttribute( 'type' );
35 if ( type
in { button
:1, reset
:1, submit
:1 } )
37 this.button
= element
;
38 this.setupContent( element
);
44 var editor
= this.getParentEditor(),
45 element
= this.button
,
46 isInsertMode
= !element
;
48 var fake
= element
? CKEDITOR
.htmlParser
.fragment
.fromHtml( element
.getOuterHtml() ).children
[ 0 ]
49 : new CKEDITOR
.htmlParser
.element( 'input' );
50 this.commitContent( fake
);
52 var writer
= new CKEDITOR
.htmlParser
.basicWriter();
53 fake
.writeHtml( writer
);
54 var newElement
= CKEDITOR
.dom
.element
.createFromHtml( writer
.getHtml(), editor
.document
);
57 editor
.insertElement( newElement
);
60 newElement
.replace( element
);
61 editor
.getSelection().selectElement( newElement
);
67 label
: editor
.lang
.button
.title
,
68 title
: editor
.lang
.button
.title
,
73 label
: editor
.lang
.common
.name
,
75 setup : function( element
)
78 element
.data( 'cke-saved-name' ) ||
79 element
.getAttribute( 'name' ) ||
82 commit
: commitAttributes
87 label
: editor
.lang
.button
.text
,
90 setup : function( element
)
92 this.setValue( element
.getAttribute( 'value' ) || '' );
94 commit
: commitAttributes
99 label
: editor
.lang
.button
.type
,
100 'default' : 'button',
104 [ editor
.lang
.button
.typeBtn
, 'button' ],
105 [ editor
.lang
.button
.typeSbm
, 'submit' ],
106 [ editor
.lang
.button
.typeRst
, 'reset' ]
108 setup : function( element
)
110 this.setValue( element
.getAttribute( 'type' ) || '' );
112 commit
: commitAttributes