Built motion from commit 67e5df37.|2.0.63
[motion2.git] / public / assets / plugins / ckeditor / plugins / forms / dialogs / textfield.js
1 /*
2  Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3  For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5 CKEDITOR.dialog.add("textfield", function(b) {
6     function e(a) {
7         a = a.element;
8         var b = this.getValue();
9         b ? a.setAttribute(this.id, b) : a.removeAttribute(this.id)
10     }
11
12     function f(a) {
13         a = a.hasAttribute(this.id) && a.getAttribute(this.id);
14         this.setValue(a || "")
15     }
16     var g = {
17         email: 1,
18         password: 1,
19         search: 1,
20         tel: 1,
21         text: 1,
22         url: 1
23     };
24     return {
25         title: b.lang.forms.textfield.title,
26         minWidth: 350,
27         minHeight: 150,
28         onShow: function() {
29             delete this.textField;
30             var a = this.getParentEditor().getSelection().getSelectedElement();
31             !a || "input" != a.getName() || !g[a.getAttribute("type")] &&
32                 a.getAttribute("type") || (this.textField = a, this.setupContent(a))
33         },
34         onOk: function() {
35             var a = this.getParentEditor(),
36                 b = this.textField,
37                 c = !b;
38             c && (b = a.document.createElement("input"), b.setAttribute("type", "text"));
39             b = {
40                 element: b
41             };
42             c && a.insertElement(b.element);
43             this.commitContent(b);
44             c || a.getSelection().selectElement(b.element)
45         },
46         onLoad: function() {
47             this.foreach(function(a) {
48                 a.getValue && (a.setup || (a.setup = f), a.commit || (a.commit = e))
49             })
50         },
51         contents: [{
52             id: "info",
53             label: b.lang.forms.textfield.title,
54             title: b.lang.forms.textfield.title,
55             elements: [{
56                 type: "hbox",
57                 widths: ["50%", "50%"],
58                 children: [{
59                     id: "_cke_saved_name",
60                     type: "text",
61                     label: b.lang.forms.textfield.name,
62                     "default": "",
63                     accessKey: "N",
64                     setup: function(a) {
65                         this.setValue(a.data("cke-saved-name") || a.getAttribute("name") || "")
66                     },
67                     commit: function(a) {
68                         a = a.element;
69                         this.getValue() ? a.data("cke-saved-name", this.getValue()) : (a.data("cke-saved-name", !1), a.removeAttribute("name"))
70                     }
71                 }, {
72                     id: "value",
73                     type: "text",
74                     label: b.lang.forms.textfield.value,
75                     "default": "",
76                     accessKey: "V",
77                     commit: function(a) {
78                         if (CKEDITOR.env.ie &&
79                             !this.getValue()) {
80                             var d = a.element,
81                                 c = new CKEDITOR.dom.element("input", b.document);
82                             d.copyAttributes(c, {
83                                 value: 1
84                             });
85                             c.replace(d);
86                             a.element = c
87                         } else e.call(this, a)
88                     }
89                 }]
90             }, {
91                 type: "hbox",
92                 widths: ["50%", "50%"],
93                 children: [{
94                     id: "size",
95                     type: "text",
96                     label: b.lang.forms.textfield.charWidth,
97                     "default": "",
98                     accessKey: "C",
99                     style: "width:50px",
100                     validate: CKEDITOR.dialog.validate.integer(b.lang.common.validateNumberFailed)
101                 }, {
102                     id: "maxLength",
103                     type: "text",
104                     label: b.lang.forms.textfield.maxChars,
105                     "default": "",
106                     accessKey: "M",
107                     style: "width:50px",
108                     validate: CKEDITOR.dialog.validate.integer(b.lang.common.validateNumberFailed)
109                 }],
110                 onLoad: function() {
111                     CKEDITOR.env.ie7Compat && this.getElement().setStyle("zoom", "100%")
112                 }
113             }, {
114                 id: "type",
115                 type: "select",
116                 label: b.lang.forms.textfield.type,
117                 "default": "text",
118                 accessKey: "M",
119                 items: [
120                     [b.lang.forms.textfield.typeEmail, "email"],
121                     [b.lang.forms.textfield.typePass, "password"],
122                     [b.lang.forms.textfield.typeSearch, "search"],
123                     [b.lang.forms.textfield.typeTel, "tel"],
124                     [b.lang.forms.textfield.typeText, "text"],
125                     [b.lang.forms.textfield.typeUrl,
126                         "url"
127                     ]
128                 ],
129                 setup: function(a) {
130                     this.setValue(a.getAttribute("type"))
131                 },
132                 commit: function(a) {
133                     var d = a.element;
134                     if (CKEDITOR.env.ie) {
135                         var c = d.getAttribute("type"),
136                             e = this.getValue();
137                         c != e && (c = CKEDITOR.dom.element.createFromHtml('\x3cinput type\x3d"' + e + '"\x3e\x3c/input\x3e', b.document), d.copyAttributes(c, {
138                             type: 1
139                         }), c.replace(d), a.element = c)
140                     } else d.setAttribute("type", this.getValue())
141                 }
142             }, {
143                 id: "required",
144                 type: "checkbox",
145                 label: b.lang.forms.textfield.required,
146                 "default": "",
147                 accessKey: "Q",
148                 value: "required",
149                 setup: function(a) {
150                     this.setValue(a.getAttribute("required"))
151                 },
152                 commit: function(a) {
153                     a = a.element;
154                     this.getValue() ? a.setAttribute("required", "required") : a.removeAttribute("required")
155                 }
156             }]
157         }]
158     }
159 });