cc250de0fb8cf21fc3333dc722e0cef039e73239
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( '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
.data( 'cke-saved-name' ) ||
102 element
.getAttribute( 'name' ) ||
105 commit : function( data
)
107 var element
= data
.element
;
109 if ( this.getValue() )
110 element
.data( 'cke-saved-name', this.getValue() );
113 element
.data( 'cke-saved-name', false );
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
)
153 // Repaint the style for IE7 (#6068)
154 if ( CKEDITOR
.env
.ie7Compat
)
155 this.getElement().setStyle( 'zoom', '100%' );
161 label
: editor
.lang
.textfield
.type
,
166 [ editor
.lang
.textfield
.typeText
, 'text' ],
167 [ editor
.lang
.textfield
.typePass
, 'password' ]
169 setup : function( element
)
171 this.setValue( element
.getAttribute( 'type' ) );
173 commit : function( data
)
175 var element
= data
.element
;
177 if ( CKEDITOR
.env
.ie
)
179 var elementType
= element
.getAttribute( 'type' );
180 var myType
= this.getValue();
182 if ( elementType
!= myType
)
184 var replace
= CKEDITOR
.dom
.element
.createFromHtml( '<input type="' + myType
+ '"></input>', editor
.document
);
185 element
.copyAttributes( replace
, { type
: 1 } );
186 replace
.replace( element
);
187 editor
.getSelection().selectElement( replace
);
188 data
.element
= replace
;
192 element
.setAttribute( 'type', this.getValue() );