initial commit
[namibia] / public / scripts / ckeditor / _source / plugins / forms / dialogs / textarea.js
1 /*
2 Copyright (c) 2003-2011, 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 : 220,
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.data( 'cke-saved-name' ) ||
54                                                                         element.getAttribute( 'name' ) ||
55                                                                         '' );
56                                                 },
57                                                 commit : function( element )
58                                                 {
59                                                         if ( this.getValue() )
60                                                                 element.data( 'cke-saved-name', this.getValue() );
61                                                         else
62                                                         {
63                                                                 element.data( 'cke-saved-name', false );
64                                                                 element.removeAttribute( 'name' );
65                                                         }
66                                                 }
67                                         },
68                                         {
69                                                 type : 'hbox',
70                                                 widths:['50%','50%'],
71                                                 children:[
72                                                         {
73                                                                 id : 'cols',
74                                                                 type : 'text',
75                                                                 label : editor.lang.textarea.cols,
76                                                                 'default' : '',
77                                                                 accessKey : 'C',
78                                                                 style : 'width:50px',
79                                                                 validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ),
80                                                                 setup : function( element )
81                                                                 {
82                                                                         var value = element.hasAttribute( 'cols' ) && element.getAttribute( 'cols' );
83                                                                         this.setValue( value || '' );
84                                                                 },
85                                                                 commit : function( element )
86                                                                 {
87                                                                         if ( this.getValue() )
88                                                                                 element.setAttribute( 'cols', this.getValue() );
89                                                                         else
90                                                                                 element.removeAttribute( 'cols' );
91                                                                 }
92                                                         },
93                                                         {
94                                                                 id : 'rows',
95                                                                 type : 'text',
96                                                                 label : editor.lang.textarea.rows,
97                                                                 'default' : '',
98                                                                 accessKey : 'R',
99                                                                 style : 'width:50px',
100                                                                 validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ),
101                                                                 setup : function( element )
102                                                                 {
103                                                                         var value = element.hasAttribute( 'rows' ) && element.getAttribute( 'rows' );
104                                                                         this.setValue( value || '' );
105                                                                 },
106                                                                 commit : function( element )
107                                                                 {
108                                                                         if ( this.getValue() )
109                                                                                 element.setAttribute( 'rows', this.getValue() );
110                                                                         else
111                                                                                 element.removeAttribute( 'rows' );
112                                                                 }
113                                                         }
114                                                 ]
115                                         },
116                                         {
117                                                 id : 'value',
118                                                 type : 'textarea',
119                                                 label : editor.lang.textfield.value,
120                                                 'default' : '',
121                                                 setup : function( element )
122                                                 {
123                                                         this.setValue( element.$.defaultValue );
124                                                 },
125                                                 commit : function( element )
126                                                 {
127                                                         element.$.value = element.$.defaultValue = this.getValue() ;
128                                                 }
129                                         }
130
131                                 ]
132                         }
133                 ]
134         };
135 });