diff options
Diffstat (limited to 'sources/plugins/forms/dialogs/form.js')
-rw-r--r-- | sources/plugins/forms/dialogs/form.js | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/sources/plugins/forms/dialogs/form.js b/sources/plugins/forms/dialogs/form.js new file mode 100644 index 00000000..256b0544 --- /dev/null +++ b/sources/plugins/forms/dialogs/form.js | |||
@@ -0,0 +1,145 @@ | |||
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 | |||
6 | CKEDITOR.dialog.add( 'form', function( editor ) { | ||
7 | var autoAttributes = { action: 1, id: 1, method: 1, enctype: 1, target: 1 }; | ||
8 | |||
9 | return { | ||
10 | title: editor.lang.forms.form.title, | ||
11 | minWidth: 350, | ||
12 | minHeight: 200, | ||
13 | onShow: function() { | ||
14 | delete this.form; | ||
15 | |||
16 | var path = this.getParentEditor().elementPath(), | ||
17 | form = path.contains( 'form', 1 ); | ||
18 | |||
19 | if ( form ) { | ||
20 | this.form = form; | ||
21 | this.setupContent( form ); | ||
22 | } | ||
23 | }, | ||
24 | onOk: function() { | ||
25 | var editor, | ||
26 | element = this.form, | ||
27 | isInsertMode = !element; | ||
28 | |||
29 | if ( isInsertMode ) { | ||
30 | editor = this.getParentEditor(); | ||
31 | element = editor.document.createElement( 'form' ); | ||
32 | element.appendBogus(); | ||
33 | } | ||
34 | |||
35 | if ( isInsertMode ) | ||
36 | editor.insertElement( element ); | ||
37 | this.commitContent( element ); | ||
38 | }, | ||
39 | onLoad: function() { | ||
40 | function autoSetup( element ) { | ||
41 | this.setValue( element.getAttribute( this.id ) || '' ); | ||
42 | } | ||
43 | |||
44 | function autoCommit( element ) { | ||
45 | if ( this.getValue() ) | ||
46 | element.setAttribute( this.id, this.getValue() ); | ||
47 | else | ||
48 | element.removeAttribute( this.id ); | ||
49 | } | ||
50 | |||
51 | this.foreach( function( contentObj ) { | ||
52 | if ( autoAttributes[ contentObj.id ] ) { | ||
53 | contentObj.setup = autoSetup; | ||
54 | contentObj.commit = autoCommit; | ||
55 | } | ||
56 | } ); | ||
57 | }, | ||
58 | contents: [ { | ||
59 | id: 'info', | ||
60 | label: editor.lang.forms.form.title, | ||
61 | title: editor.lang.forms.form.title, | ||
62 | elements: [ { | ||
63 | id: 'txtName', | ||
64 | bidi: true, | ||
65 | type: 'text', | ||
66 | label: editor.lang.common.name, | ||
67 | 'default': '', | ||
68 | accessKey: 'N', | ||
69 | setup: function( element ) { | ||
70 | this.setValue( element.data( 'cke-saved-name' ) || element.getAttribute( 'name' ) || '' ); | ||
71 | }, | ||
72 | commit: function( element ) { | ||
73 | if ( this.getValue() ) | ||
74 | element.data( 'cke-saved-name', this.getValue() ); | ||
75 | else { | ||
76 | element.data( 'cke-saved-name', false ); | ||
77 | element.removeAttribute( 'name' ); | ||
78 | } | ||
79 | } | ||
80 | }, | ||
81 | { | ||
82 | id: 'action', | ||
83 | type: 'text', | ||
84 | label: editor.lang.forms.form.action, | ||
85 | 'default': '', | ||
86 | accessKey: 'T' | ||
87 | }, | ||
88 | { | ||
89 | type: 'hbox', | ||
90 | widths: [ '45%', '55%' ], | ||
91 | children: [ { | ||
92 | id: 'id', | ||
93 | type: 'text', | ||
94 | label: editor.lang.common.id, | ||
95 | 'default': '', | ||
96 | accessKey: 'I' | ||
97 | }, | ||
98 | { | ||
99 | id: 'enctype', | ||
100 | type: 'select', | ||
101 | label: editor.lang.forms.form.encoding, | ||
102 | style: 'width:100%', | ||
103 | accessKey: 'E', | ||
104 | 'default': '', | ||
105 | items: [ | ||
106 | [ '' ], | ||
107 | [ 'text/plain' ], | ||
108 | [ 'multipart/form-data' ], | ||
109 | [ 'application/x-www-form-urlencoded' ] | ||
110 | ] | ||
111 | } ] | ||
112 | }, | ||
113 | { | ||
114 | type: 'hbox', | ||
115 | widths: [ '45%', '55%' ], | ||
116 | children: [ { | ||
117 | id: 'target', | ||
118 | type: 'select', | ||
119 | label: editor.lang.common.target, | ||
120 | style: 'width:100%', | ||
121 | accessKey: 'M', | ||
122 | 'default': '', | ||
123 | items: [ | ||
124 | [ editor.lang.common.notSet, '' ], | ||
125 | [ editor.lang.common.targetNew, '_blank' ], | ||
126 | [ editor.lang.common.targetTop, '_top' ], | ||
127 | [ editor.lang.common.targetSelf, '_self' ], | ||
128 | [ editor.lang.common.targetParent, '_parent' ] | ||
129 | ] | ||
130 | }, | ||
131 | { | ||
132 | id: 'method', | ||
133 | type: 'select', | ||
134 | label: editor.lang.forms.form.method, | ||
135 | accessKey: 'M', | ||
136 | 'default': 'GET', | ||
137 | items: [ | ||
138 | [ 'GET', 'get' ], | ||
139 | [ 'POST', 'post' ] | ||
140 | ] | ||
141 | } ] | ||
142 | } ] | ||
143 | } ] | ||
144 | }; | ||
145 | } ); | ||