+++ /dev/null
-/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-CKEDITOR.dialog.add( 'textfield', function( editor )\r
-{\r
- var autoAttributes =\r
- {\r
- value : 1,\r
- size : 1,\r
- maxLength : 1\r
- };\r
-\r
- var acceptedTypes =\r
- {\r
- text : 1,\r
- password : 1\r
- };\r
-\r
- return {\r
- title : editor.lang.textfield.title,\r
- minWidth : 350,\r
- minHeight : 150,\r
- onShow : function()\r
- {\r
- delete this.textField;\r
-\r
- var element = this.getParentEditor().getSelection().getSelectedElement();\r
- if ( element && element.getName() == "input" &&\r
- ( acceptedTypes[ element.getAttribute( 'type' ) ] || !element.getAttribute( 'type' ) ) )\r
- {\r
- this.textField = element;\r
- this.setupContent( element );\r
- }\r
- },\r
- onOk : function()\r
- {\r
- var editor,\r
- element = this.textField,\r
- isInsertMode = !element;\r
-\r
- if ( isInsertMode )\r
- {\r
- editor = this.getParentEditor();\r
- element = editor.document.createElement( 'input' );\r
- element.setAttribute( 'type', 'text' );\r
- }\r
-\r
- if ( isInsertMode )\r
- editor.insertElement( element );\r
- this.commitContent( { element : element } );\r
- },\r
- onLoad : function()\r
- {\r
- var autoSetup = function( element )\r
- {\r
- var value = element.hasAttribute( this.id ) && element.getAttribute( this.id );\r
- this.setValue( value || '' );\r
- };\r
-\r
- var autoCommit = function( data )\r
- {\r
- var element = data.element;\r
- var value = this.getValue();\r
-\r
- if ( value )\r
- element.setAttribute( this.id, value );\r
- else\r
- element.removeAttribute( this.id );\r
- };\r
-\r
- this.foreach( function( contentObj )\r
- {\r
- if ( autoAttributes[ contentObj.id ] )\r
- {\r
- contentObj.setup = autoSetup;\r
- contentObj.commit = autoCommit;\r
- }\r
- } );\r
- },\r
- contents : [\r
- {\r
- id : 'info',\r
- label : editor.lang.textfield.title,\r
- title : editor.lang.textfield.title,\r
- elements : [\r
- {\r
- type : 'hbox',\r
- widths : [ '50%', '50%' ],\r
- children :\r
- [\r
- {\r
- id : '_cke_saved_name',\r
- type : 'text',\r
- label : editor.lang.textfield.name,\r
- 'default' : '',\r
- accessKey : 'N',\r
- setup : function( element )\r
- {\r
- this.setValue(\r
- element.data( 'cke-saved-name' ) ||\r
- element.getAttribute( 'name' ) ||\r
- '' );\r
- },\r
- commit : function( data )\r
- {\r
- var element = data.element;\r
-\r
- if ( this.getValue() )\r
- element.data( 'cke-saved-name', this.getValue() );\r
- else\r
- {\r
- element.data( 'cke-saved-name', false );\r
- element.removeAttribute( 'name' );\r
- }\r
- }\r
- },\r
- {\r
- id : 'value',\r
- type : 'text',\r
- label : editor.lang.textfield.value,\r
- 'default' : '',\r
- accessKey : 'V'\r
- }\r
- ]\r
- },\r
- {\r
- type : 'hbox',\r
- widths : [ '50%', '50%' ],\r
- children :\r
- [\r
- {\r
- id : 'size',\r
- type : 'text',\r
- label : editor.lang.textfield.charWidth,\r
- 'default' : '',\r
- accessKey : 'C',\r
- style : 'width:50px',\r
- validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed )\r
- },\r
- {\r
- id : 'maxLength',\r
- type : 'text',\r
- label : editor.lang.textfield.maxChars,\r
- 'default' : '',\r
- accessKey : 'M',\r
- style : 'width:50px',\r
- validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed )\r
- }\r
- ],\r
- onLoad : function()\r
- {\r
- // Repaint the style for IE7 (#6068)\r
- if ( CKEDITOR.env.ie7Compat )\r
- this.getElement().setStyle( 'zoom', '100%' );\r
- }\r
- },\r
- {\r
- id : 'type',\r
- type : 'select',\r
- label : editor.lang.textfield.type,\r
- 'default' : 'text',\r
- accessKey : 'M',\r
- items :\r
- [\r
- [ editor.lang.textfield.typeText, 'text' ],\r
- [ editor.lang.textfield.typePass, 'password' ]\r
- ],\r
- setup : function( element )\r
- {\r
- this.setValue( element.getAttribute( 'type' ) );\r
- },\r
- commit : function( data )\r
- {\r
- var element = data.element;\r
-\r
- if ( CKEDITOR.env.ie )\r
- {\r
- var elementType = element.getAttribute( 'type' );\r
- var myType = this.getValue();\r
-\r
- if ( elementType != myType )\r
- {\r
- var replace = CKEDITOR.dom.element.createFromHtml( '<input type="' + myType + '"></input>', editor.document );\r
- element.copyAttributes( replace, { type : 1 } );\r
- replace.replace( element );\r
- editor.getSelection().selectElement( replace );\r
- data.element = replace;\r
- }\r
- }\r
- else\r
- element.setAttribute( 'type', this.getValue() );\r
- }\r
- }\r
- ]\r
- }\r
- ]\r
- };\r
-});\r