]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blame - sources/plugins/forms/dialogs/form.js
Initial commit
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / forms / dialogs / form.js
CommitLineData
7adcb81e
IB
1/**\r
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r
3 * For licensing, see LICENSE.md or http://ckeditor.com/license\r
4 */\r
5\r
6CKEDITOR.dialog.add( 'form', function( editor ) {\r
7 var autoAttributes = { action: 1, id: 1, method: 1, enctype: 1, target: 1 };\r
8\r
9 return {\r
10 title: editor.lang.forms.form.title,\r
11 minWidth: 350,\r
12 minHeight: 200,\r
13 onShow: function() {\r
14 delete this.form;\r
15\r
16 var path = this.getParentEditor().elementPath(),\r
17 form = path.contains( 'form', 1 );\r
18\r
19 if ( form ) {\r
20 this.form = form;\r
21 this.setupContent( form );\r
22 }\r
23 },\r
24 onOk: function() {\r
25 var editor,\r
26 element = this.form,\r
27 isInsertMode = !element;\r
28\r
29 if ( isInsertMode ) {\r
30 editor = this.getParentEditor();\r
31 element = editor.document.createElement( 'form' );\r
32 element.appendBogus();\r
33 }\r
34\r
35 if ( isInsertMode )\r
36 editor.insertElement( element );\r
37 this.commitContent( element );\r
38 },\r
39 onLoad: function() {\r
40 function autoSetup( element ) {\r
41 this.setValue( element.getAttribute( this.id ) || '' );\r
42 }\r
43\r
44 function autoCommit( element ) {\r
45 if ( this.getValue() )\r
46 element.setAttribute( this.id, this.getValue() );\r
47 else\r
48 element.removeAttribute( this.id );\r
49 }\r
50\r
51 this.foreach( function( contentObj ) {\r
52 if ( autoAttributes[ contentObj.id ] ) {\r
53 contentObj.setup = autoSetup;\r
54 contentObj.commit = autoCommit;\r
55 }\r
56 } );\r
57 },\r
58 contents: [ {\r
59 id: 'info',\r
60 label: editor.lang.forms.form.title,\r
61 title: editor.lang.forms.form.title,\r
62 elements: [ {\r
63 id: 'txtName',\r
64 bidi: true,\r
65 type: 'text',\r
66 label: editor.lang.common.name,\r
67 'default': '',\r
68 accessKey: 'N',\r
69 setup: function( element ) {\r
70 this.setValue( element.data( 'cke-saved-name' ) || element.getAttribute( 'name' ) || '' );\r
71 },\r
72 commit: function( element ) {\r
73 if ( this.getValue() )\r
74 element.data( 'cke-saved-name', this.getValue() );\r
75 else {\r
76 element.data( 'cke-saved-name', false );\r
77 element.removeAttribute( 'name' );\r
78 }\r
79 }\r
80 },\r
81 {\r
82 id: 'action',\r
83 type: 'text',\r
84 label: editor.lang.forms.form.action,\r
85 'default': '',\r
86 accessKey: 'T'\r
87 },\r
88 {\r
89 type: 'hbox',\r
90 widths: [ '45%', '55%' ],\r
91 children: [ {\r
92 id: 'id',\r
93 type: 'text',\r
94 label: editor.lang.common.id,\r
95 'default': '',\r
96 accessKey: 'I'\r
97 },\r
98 {\r
99 id: 'enctype',\r
100 type: 'select',\r
101 label: editor.lang.forms.form.encoding,\r
102 style: 'width:100%',\r
103 accessKey: 'E',\r
104 'default': '',\r
105 items: [\r
106 [ '' ],\r
107 [ 'text/plain' ],\r
108 [ 'multipart/form-data' ],\r
109 [ 'application/x-www-form-urlencoded' ]\r
110 ]\r
111 } ]\r
112 },\r
113 {\r
114 type: 'hbox',\r
115 widths: [ '45%', '55%' ],\r
116 children: [ {\r
117 id: 'target',\r
118 type: 'select',\r
119 label: editor.lang.common.target,\r
120 style: 'width:100%',\r
121 accessKey: 'M',\r
122 'default': '',\r
123 items: [\r
124 [ editor.lang.common.notSet, '' ],\r
125 [ editor.lang.common.targetNew, '_blank' ],\r
126 [ editor.lang.common.targetTop, '_top' ],\r
127 [ editor.lang.common.targetSelf, '_self' ],\r
128 [ editor.lang.common.targetParent, '_parent' ]\r
129 ]\r
130 },\r
131 {\r
132 id: 'method',\r
133 type: 'select',\r
134 label: editor.lang.forms.form.method,\r
135 accessKey: 'M',\r
136 'default': 'GET',\r
137 items: [\r
138 [ 'GET', 'get' ],\r
139 [ 'POST', 'post' ]\r
140 ]\r
141 } ]\r
142 } ]\r
143 } ]\r
144 };\r
145} );\r