source: branches/2.2/filemanager/tp/ckeditor/_source/plugins/forms/dialogs/radio.js @ 3019

Revision 3019, 3.5 KB checked in by amuller, 14 years ago (diff)

Ticket #1135 - Corrigindo CSS e adicionando filemanager

Line 
1/*
2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.html or http://ckeditor.com/license
4*/
5CKEDITOR.dialog.add( 'radio', function( editor )
6{
7        return {
8                title : editor.lang.checkboxAndRadio.radioTitle,
9                minWidth : 350,
10                minHeight : 140,
11                onShow : function()
12                {
13                        delete this.radioButton;
14
15                        var element = this.getParentEditor().getSelection().getSelectedElement();
16                        if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "radio" )
17                        {
18                                this.radioButton = element;
19                                this.setupContent( element );
20                        }
21                },
22                onOk : function()
23                {
24                        var editor,
25                                element = this.radioButton,
26                                isInsertMode = !element;
27
28                        if ( isInsertMode )
29                        {
30                                editor = this.getParentEditor();
31                                element = editor.document.createElement( 'input' );
32                                element.setAttribute( 'type', 'radio' );
33                        }
34
35                        if ( isInsertMode )
36                                editor.insertElement( element );
37                        this.commitContent( { element : element } );
38                },
39                contents : [
40                        {
41                                id : 'info',
42                                label : editor.lang.checkboxAndRadio.radioTitle,
43                                title : editor.lang.checkboxAndRadio.radioTitle,
44                                elements : [
45                                        {
46                                                id : 'name',
47                                                type : 'text',
48                                                label : editor.lang.common.name,
49                                                'default' : '',
50                                                accessKey : 'N',
51                                                setup : function( element )
52                                                {
53                                                        this.setValue(
54                                                                        element.getAttribute( '_cke_saved_name' ) ||
55                                                                        element.getAttribute( 'name' ) ||
56                                                                        '' );
57                                                },
58                                                commit : function( data )
59                                                {
60                                                        var element = data.element;
61
62                                                        if ( this.getValue() )
63                                                                element.setAttribute( '_cke_saved_name', this.getValue() );
64                                                        else
65                                                        {
66                                                                element.removeAttribute( '_cke_saved_name' );
67                                                                element.removeAttribute( 'name' );
68                                                        }
69                                                }
70                                        },
71                                        {
72                                                id : 'value',
73                                                type : 'text',
74                                                label : editor.lang.checkboxAndRadio.value,
75                                                'default' : '',
76                                                accessKey : 'V',
77                                                setup : function( element )
78                                                {
79                                                        this.setValue( element.getAttribute( 'value' ) || '' );
80                                                },
81                                                commit : function( data )
82                                                {
83                                                        var element = data.element;
84
85                                                        if ( this.getValue() )
86                                                                element.setAttribute( 'value', this.getValue() );
87                                                        else
88                                                                element.removeAttribute( 'value' );
89                                                }
90                                        },
91                                        {
92                                                id : 'checked',
93                                                type : 'checkbox',
94                                                label : editor.lang.checkboxAndRadio.selected,
95                                                'default' : '',
96                                                accessKey : 'S',
97                                                value : "checked",
98                                                setup : function( element )
99                                                {
100                                                        this.setValue( element.getAttribute( 'checked' ) );
101                                                },
102                                                commit : function( data )
103                                                {
104                                                        var element = data.element;
105
106                                                        if ( !CKEDITOR.env.ie )
107                                                        {
108                                                                if ( this.getValue() )
109                                                                        element.setAttribute( 'checked', 'checked' );
110                                                                else
111                                                                        element.removeAttribute( 'checked' );
112                                                        }
113                                                        else
114                                                        {
115                                                                var isElementChecked = element.getAttribute( 'checked' );
116                                                                var isChecked = !!this.getValue();
117
118                                                                if ( isElementChecked != isChecked )
119                                                                {
120                                                                        var replace = CKEDITOR.dom.element.createFromHtml( '<input type="radio"'
121                                                                                        + ( isChecked ? ' checked="checked"' : '' )
122                                                                                        + '></input>', editor.document );
123                                                                        element.copyAttributes( replace, { type : 1, checked : 1 } );
124                                                                        replace.replace( element );
125                                                                        editor.getSelection().selectElement( replace );
126                                                                        data.element = replace;
127                                                                }
128                                                        }
129                                                }
130                                        }
131                                ]
132                        }
133                ]
134        };
135});
Note: See TracBrowser for help on using the repository browser.