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