1 /*
  2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
  3 For licensing, see LICENSE.html or http://ckeditor.com/license
  4 */
  5 CKEDITOR.dialog.add( 'textarea', function( editor )
  6 {
  7 	return {
  8 		title : editor.lang.textarea.title,
  9 		minWidth : 350,
 10 		minHeight : 150,
 11 		onShow : function()
 12 		{
 13 			delete this.textarea;
 14
 15 			var element = this.getParentEditor().getSelection().getSelectedElement();
 16 			if ( element && element.getName() == "textarea" )
 17 			{
 18 				this.textarea = element;
 19 				this.setupContent( element );
 20 			}
 21 		},
 22 		onOk : function()
 23 		{
 24 			var editor,
 25 				element = this.textarea,
 26 				isInsertMode = !element;
 27
 28 			if ( isInsertMode )
 29 			{
 30 				editor = this.getParentEditor();
 31 				element = editor.document.createElement( 'textarea' );
 32 			}
 33 			this.commitContent( element );
 34
 35 			if ( isInsertMode )
 36 				editor.insertElement( element );
 37 		},
 38 		contents : [
 39 			{
 40 				id : 'info',
 41 				label : editor.lang.textarea.title,
 42 				title : editor.lang.textarea.title,
 43 				elements : [
 44 					{
 45 						id : '_cke_saved_name',
 46 						type : 'text',
 47 						label : editor.lang.common.name,
 48 						'default' : '',
 49 						accessKey : 'N',
 50 						setup : function( element )
 51 						{
 52 							this.setValue(
 53 									element.getAttribute( '_cke_saved_name' ) ||
 54 									element.getAttribute( 'name' ) ||
 55 									'' );
 56 						},
 57 						commit : function( element )
 58 						{
 59 							if ( this.getValue() )
 60 								element.setAttribute( '_cke_saved_name', this.getValue() );
 61 							else
 62 							{
 63 								element.removeAttribute( '_cke_saved_name' );
 64 								element.removeAttribute( 'name' );
 65 							}
 66 						}
 67 					},
 68 					{
 69 						id : 'cols',
 70 						type : 'text',
 71 						label : editor.lang.textarea.cols,
 72 						'default' : '',
 73 						accessKey : 'C',
 74 						style : 'width:50px',
 75 						validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ),
 76 						setup : function( element )
 77 						{
 78 							var value = element.hasAttribute( 'cols' ) && element.getAttribute( 'cols' );
 79 							this.setValue( value || '' );
 80 						},
 81 						commit : function( element )
 82 						{
 83 							if ( this.getValue() )
 84 								element.setAttribute( 'cols', this.getValue() );
 85 							else
 86 								element.removeAttribute( 'cols' );
 87 						}
 88 					},
 89 					{
 90 						id : 'rows',
 91 						type : 'text',
 92 						label : editor.lang.textarea.rows,
 93 						'default' : '',
 94 						accessKey : 'R',
 95 						style : 'width:50px',
 96 						validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ),
 97 						setup : function( element )
 98 						{
 99 							var value = element.hasAttribute( 'rows' ) && element.getAttribute( 'rows' );
100 							this.setValue( value || '' );
101 						},
102 						commit : function( element )
103 						{
104 							if ( this.getValue() )
105 								element.setAttribute( 'rows', this.getValue() );
106 							else
107 								element.removeAttribute( 'rows' );
108 						}
109 					}
110 				]
111 			}
112 		]
113 	};
114 });
115