2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
5 CKEDITOR.dialog.add( 'radio', function( editor )
\r
8 title : editor.lang.checkboxAndRadio.radioTitle,
\r
13 delete this.radioButton;
\r
15 var element = this.getParentEditor().getSelection().getSelectedElement();
\r
16 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "radio" )
\r
18 this.radioButton = element;
\r
19 this.setupContent( element );
\r
25 element = this.radioButton,
\r
26 isInsertMode = !element;
\r
30 editor = this.getParentEditor();
\r
31 element = editor.document.createElement( 'input' );
\r
32 element.setAttribute( 'type', 'radio' );
\r
36 editor.insertElement( element );
\r
37 this.commitContent( { element : element } );
\r
42 label : editor.lang.checkboxAndRadio.radioTitle,
\r
43 title : editor.lang.checkboxAndRadio.radioTitle,
\r
48 label : editor.lang.common.name,
\r
51 setup : function( element )
\r
54 element.getAttribute( '_cke_saved_name' ) ||
\r
55 element.getAttribute( 'name' ) ||
\r
58 commit : function( data )
\r
60 var element = data.element;
\r
62 if ( this.getValue() )
\r
63 element.setAttribute( '_cke_saved_name', this.getValue() );
\r
66 element.removeAttribute( '_cke_saved_name' );
\r
67 element.removeAttribute( 'name' );
\r
74 label : editor.lang.checkboxAndRadio.value,
\r
77 setup : function( element )
\r
79 this.setValue( element.getAttribute( 'value' ) || '' );
\r
81 commit : function( data )
\r
83 var element = data.element;
\r
85 if ( this.getValue() )
\r
86 element.setAttribute( 'value', this.getValue() );
\r
88 element.removeAttribute( 'value' );
\r
94 label : editor.lang.checkboxAndRadio.selected,
\r
98 setup : function( element )
\r
100 this.setValue( element.getAttribute( 'checked' ) );
\r
102 commit : function( data )
\r
104 var element = data.element;
\r
106 if ( !CKEDITOR.env.ie )
\r
108 if ( this.getValue() )
\r
109 element.setAttribute( 'checked', 'checked' );
\r
111 element.removeAttribute( 'checked' );
\r
115 var isElementChecked = element.getAttribute( 'checked' );
\r
116 var isChecked = !!this.getValue();
\r
118 if ( isElementChecked != isChecked )
\r
120 var replace = CKEDITOR.dom.element.createFromHtml( '<input type="radio"'
\r
121 + ( isChecked ? ' checked="checked"' : '' )
\r
122 + '></input>', editor.document );
\r
123 element.copyAttributes( replace, { type : 1, checked : 1 } );
\r
124 replace.replace( element );
\r
125 editor.getSelection().selectElement( replace );
\r
126 data.element = replace;
\r