2
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
3
For licensing, see LICENSE.html or http://ckeditor.com/license
5
CKEDITOR.dialog.add( 'textfield', function( editor )
21
title : editor.lang.textfield.title,
26
delete this.textField;
28
var element = this.getParentEditor().getSelection().getSelectedElement();
29
if ( element && element.getName() == "input" &&
30
( acceptedTypes[ element.getAttribute( 'type' ) ] || !element.getAttribute( 'type' ) ) )
32
this.textField = element;
33
this.setupContent( element );
39
element = this.textField,
40
isInsertMode = !element;
44
editor = this.getParentEditor();
45
element = editor.document.createElement( 'input' );
46
element.setAttribute( 'type', 'text' );
50
editor.insertElement( element );
51
this.commitContent( { element : element } );
55
var autoSetup = function( element )
57
var value = element.hasAttribute( this.id ) && element.getAttribute( this.id );
58
this.setValue( value || '' );
61
var autoCommit = function( data )
63
var element = data.element;
64
var value = this.getValue();
67
element.setAttribute( this.id, value );
69
element.removeAttribute( this.id );
72
this.foreach( function( contentObj )
74
if ( autoAttributes[ contentObj.id ] )
76
contentObj.setup = autoSetup;
77
contentObj.commit = autoCommit;
84
label : editor.lang.textfield.title,
85
title : editor.lang.textfield.title,
89
widths : [ '50%', '50%' ],
93
id : '_cke_saved_name',
95
label : editor.lang.textfield.name,
98
setup : function( element )
101
element.getAttribute( '_cke_saved_name' ) ||
102
element.getAttribute( 'name' ) ||
105
commit : function( data )
107
var element = data.element;
109
if ( this.getValue() )
110
element.setAttribute( '_cke_saved_name', this.getValue() );
113
element.removeAttribute( '_cke_saved_name' );
114
element.removeAttribute( 'name' );
121
label : editor.lang.textfield.value,
129
widths : [ '50%', '50%' ],
135
label : editor.lang.textfield.charWidth,
138
style : 'width:50px',
139
validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed )
144
label : editor.lang.textfield.maxChars,
147
style : 'width:50px',
148
validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed )
155
label : editor.lang.textfield.type,
160
[ editor.lang.textfield.typeText, 'text' ],
161
[ editor.lang.textfield.typePass, 'password' ]
163
setup : function( element )
165
this.setValue( element.getAttribute( 'type' ) );
167
commit : function( data )
169
var element = data.element;
171
if ( CKEDITOR.env.ie )
173
var elementType = element.getAttribute( 'type' );
174
var myType = this.getValue();
176
if ( elementType != myType )
178
var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + myType + '"></input>', editor.document );
179
element.copyAttributes( replace, { type : 1 } );
180
replace.replace( element );
181
editor.getSelection().selectElement( replace );
182
data.element = element;
186
element.setAttribute( 'type', this.getValue() );