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 : 400, 10 minHeight : 230, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "textarea" ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 }, 24 onOk : function() 25 { 26 var editor, 27 element = this._element, 28 isInsertMode = !element; 29 30 if ( isInsertMode ) 31 { 32 editor = this.getParentEditor(); 33 element = editor.document.createElement( 'textarea' ); 34 } 35 this.commitContent( element ); 36 37 if ( isInsertMode ) 38 { 39 this.restoreSelection(); 40 this.clearSavedSelection(); 41 editor.insertElement( element ); 42 } 43 }, 44 contents : [ 45 { 46 id : 'info', 47 label : editor.lang.textarea.title, 48 title : editor.lang.textarea.title, 49 elements : [ 50 { 51 id : 'txtName', 52 type : 'text', 53 label : editor.lang.common.name, 54 'default' : '', 55 accessKey : 'N', 56 setup : function( element ) 57 { 58 this.setValue( element.getAttribute( 'name' ) ); 59 this.focus(); 60 }, 61 commit : function( element ) 62 { 63 if ( this.getValue() != '' || this.isChanged() ) 64 element.setAttribute( 'name', this.getValue() ); 65 } 66 }, 67 { 68 id : 'txtColumns', 69 type : 'text', 70 label : editor.lang.textarea.cols, 71 'default' : '', 72 accessKey : 'C', 73 style : 'width:50px', 74 validate: function() 75 { 76 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 77 return func.apply( this ); 78 }, 79 setup : function( element ) 80 { 81 this.setValue( element.getAttribute( 'cols' ) ); 82 }, 83 commit : function( element ) 84 { 85 if ( this.getValue() != '' || this.isChanged() ) 86 element.setAttribute( 'cols', this.getValue() ); 87 } 88 }, 89 { 90 id : 'txtRows', 91 type : 'text', 92 label : editor.lang.textarea.rows, 93 'default' : '', 94 accessKey : 'R', 95 style : 'width:50px', 96 validate: function() 97 { 98 var func = CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ); 99 return func.apply( this ); 100 }, 101 setup : function( element ) 102 { 103 this.setValue( element.getAttribute( 'rows' ) ); 104 }, 105 commit : function( element ) 106 { 107 if ( this.getValue() != '' || this.isChanged() ) 108 element.setAttribute( 'rows', this.getValue() ); 109 } 110 } 111 ] 112 } 113 ] 114 }; 115 }); 116