Built motion from commit 67e5df37.|2.0.66
[motion2.git] / public / assets / plugins / ckeditor / plugins / forms / dialogs / select.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("select", function(c) {
6     function h(a, b, e, d, c) {
7         a = f(a);
8         d = d ? d.createElement("OPTION") : document.createElement("OPTION");
9         if (a && d && "option" == d.getName()) CKEDITOR.env.ie ? (isNaN(parseInt(c, 10)) ? a.$.options.add(d.$) : a.$.options.add(d.$, c), d.$.innerHTML = 0 < b.length ? b : "", d.$.value = e) : (null !== c && c < a.getChildCount() ? a.getChild(0 > c ? 0 : c).insertBeforeMe(d) : a.append(d), d.setText(0 < b.length ? b : ""), d.setValue(e));
10         else return !1;
11         return d
12     }
13
14     function p(a) {
15         a = f(a);
16         for (var b = g(a), e = a.getChildren().count() - 1; 0 <=
17             e; e--) a.getChild(e).$.selected && a.getChild(e).remove();
18         k(a, b)
19     }
20
21     function q(a, b, e, d) {
22         a = f(a);
23         if (0 > b) return !1;
24         a = a.getChild(b);
25         a.setText(e);
26         a.setValue(d);
27         return a
28     }
29
30     function m(a) {
31         for (a = f(a); a.getChild(0) && a.getChild(0).remove(););
32     }
33
34     function l(a, b, e) {
35         a = f(a);
36         var d = g(a);
37         if (0 > d) return !1;
38         b = d + b;
39         b = 0 > b ? 0 : b;
40         b = b >= a.getChildCount() ? a.getChildCount() - 1 : b;
41         if (d == b) return !1;
42         var d = a.getChild(d),
43             c = d.getText(),
44             r = d.getValue();
45         d.remove();
46         d = h(a, c, r, e ? e : null, b);
47         k(a, b);
48         return d
49     }
50
51     function g(a) {
52         return (a = f(a)) ? a.$.selectedIndex : -1
53     }
54
55     function k(a, b) {
56         a = f(a);
57         if (0 > b) return null;
58         var e = a.getChildren().count();
59         a.$.selectedIndex = b >= e ? e - 1 : b;
60         return a
61     }
62
63     function n(a) {
64         return (a = f(a)) ? a.getChildren() : !1
65     }
66
67     function f(a) {
68         return a && a.domId && a.getInputElement().$ ? a.getInputElement() : a && a.$ ? a : !1
69     }
70     return {
71         title: c.lang.forms.select.title,
72         minWidth: CKEDITOR.env.ie ? 460 : 395,
73         minHeight: CKEDITOR.env.ie ? 320 : 300,
74         onShow: function() {
75             delete this.selectBox;
76             this.setupContent("clear");
77             var a = this.getParentEditor().getSelection().getSelectedElement();
78             if (a && "select" == a.getName()) {
79                 this.selectBox =
80                     a;
81                 this.setupContent(a.getName(), a);
82                 for (var a = n(a), b = 0; b < a.count(); b++) this.setupContent("option", a.getItem(b))
83             }
84         },
85         onOk: function() {
86             var a = this.getParentEditor(),
87                 b = this.selectBox,
88                 e = !b;
89             e && (b = a.document.createElement("select"));
90             this.commitContent(b);
91             if (e && (a.insertElement(b), CKEDITOR.env.ie)) {
92                 var d = a.getSelection(),
93                     c = d.createBookmarks();
94                 setTimeout(function() {
95                     d.selectBookmarks(c)
96                 }, 0)
97             }
98         },
99         contents: [{
100             id: "info",
101             label: c.lang.forms.select.selectInfo,
102             title: c.lang.forms.select.selectInfo,
103             accessKey: "",
104             elements: [{
105                 id: "txtName",
106                 type: "text",
107                 widths: ["25%", "75%"],
108                 labelLayout: "horizontal",
109                 label: c.lang.common.name,
110                 "default": "",
111                 accessKey: "N",
112                 style: "width:350px",
113                 setup: function(a, b) {
114                     "clear" == a ? this.setValue(this["default"] || "") : "select" == a && this.setValue(b.data("cke-saved-name") || b.getAttribute("name") || "")
115                 },
116                 commit: function(a) {
117                     this.getValue() ? a.data("cke-saved-name", this.getValue()) : (a.data("cke-saved-name", !1), a.removeAttribute("name"))
118                 }
119             }, {
120                 id: "txtValue",
121                 type: "text",
122                 widths: ["25%", "75%"],
123                 labelLayout: "horizontal",
124                 label: c.lang.forms.select.value,
125                 style: "width:350px",
126                 "default": "",
127                 className: "cke_disabled",
128                 onLoad: function() {
129                     this.getInputElement().setAttribute("readOnly", !0)
130                 },
131                 setup: function(a, b) {
132                     "clear" == a ? this.setValue("") : "option" == a && b.getAttribute("selected") && this.setValue(b.$.value)
133                 }
134             }, {
135                 type: "hbox",
136                 className: "cke_dialog_forms_select_order_txtsize",
137                 widths: ["175px", "170px"],
138                 children: [{
139                     id: "txtSize",
140                     type: "text",
141                     labelLayout: "horizontal",
142                     label: c.lang.forms.select.size,
143                     "default": "",
144                     accessKey: "S",
145                     style: "width:175px",
146                     validate: function() {
147                         var a = CKEDITOR.dialog.validate.integer(c.lang.common.validateNumberFailed);
148                         return "" === this.getValue() || a.apply(this)
149                     },
150                     setup: function(a, b) {
151                         "select" == a && this.setValue(b.getAttribute("size") || "");
152                         CKEDITOR.env.webkit && this.getInputElement().setStyle("width", "86px")
153                     },
154                     commit: function(a) {
155                         this.getValue() ? a.setAttribute("size", this.getValue()) : a.removeAttribute("size")
156                     }
157                 }, {
158                     type: "html",
159                     html: "\x3cspan\x3e" + CKEDITOR.tools.htmlEncode(c.lang.forms.select.lines) + "\x3c/span\x3e"
160                 }]
161             }, {
162                 type: "html",
163                 html: "\x3cspan\x3e" + CKEDITOR.tools.htmlEncode(c.lang.forms.select.opAvail) + "\x3c/span\x3e"
164             }, {
165                 type: "hbox",
166                 widths: ["115px", "115px", "100px"],
167                 className: "cke_dialog_forms_select_order",
168                 children: [{
169                     type: "vbox",
170                     children: [{
171                         id: "txtOptName",
172                         type: "text",
173                         label: c.lang.forms.select.opText,
174                         style: "width:115px",
175                         setup: function(a) {
176                             "clear" == a && this.setValue("")
177                         }
178                     }, {
179                         type: "select",
180                         id: "cmbName",
181                         label: "",
182                         title: "",
183                         size: 5,
184                         style: "width:115px;height:75px",
185                         items: [],
186                         onChange: function() {
187                             var a = this.getDialog(),
188                                 b = a.getContentElement("info", "cmbValue"),
189                                 e = a.getContentElement("info", "txtOptName"),
190                                 a = a.getContentElement("info", "txtOptValue"),
191                                 d = g(this);
192                             k(b, d);
193                             e.setValue(this.getValue());
194                             a.setValue(b.getValue())
195                         },
196                         setup: function(a, b) {
197                             "clear" == a ? m(this) : "option" == a && h(this, b.getText(), b.getText(), this.getDialog().getParentEditor().document)
198                         },
199                         commit: function(a) {
200                             var b = this.getDialog(),
201                                 e = n(this),
202                                 d = n(b.getContentElement("info", "cmbValue")),
203                                 c = b.getContentElement("info", "txtValue").getValue();
204                             m(a);
205                             for (var f = 0; f < e.count(); f++) {
206                                 var g = h(a, e.getItem(f).getValue(), d.getItem(f).getValue(), b.getParentEditor().document);
207                                 d.getItem(f).getValue() == c && (g.setAttribute("selected",
208                                     "selected"), g.selected = !0)
209                             }
210                         }
211                     }]
212                 }, {
213                     type: "vbox",
214                     children: [{
215                         id: "txtOptValue",
216                         type: "text",
217                         label: c.lang.forms.select.opValue,
218                         style: "width:115px",
219                         setup: function(a) {
220                             "clear" == a && this.setValue("")
221                         }
222                     }, {
223                         type: "select",
224                         id: "cmbValue",
225                         label: "",
226                         size: 5,
227                         style: "width:115px;height:75px",
228                         items: [],
229                         onChange: function() {
230                             var a = this.getDialog(),
231                                 b = a.getContentElement("info", "cmbName"),
232                                 e = a.getContentElement("info", "txtOptName"),
233                                 a = a.getContentElement("info", "txtOptValue"),
234                                 d = g(this);
235                             k(b, d);
236                             e.setValue(b.getValue());
237                             a.setValue(this.getValue())
238                         },
239                         setup: function(a, b) {
240                             if ("clear" == a) m(this);
241                             else if ("option" == a) {
242                                 var e = b.getValue();
243                                 h(this, e, e, this.getDialog().getParentEditor().document);
244                                 "selected" == b.getAttribute("selected") && this.getDialog().getContentElement("info", "txtValue").setValue(e)
245                             }
246                         }
247                     }]
248                 }, {
249                     type: "vbox",
250                     padding: 5,
251                     children: [{
252                         type: "button",
253                         id: "btnAdd",
254                         label: c.lang.forms.select.btnAdd,
255                         title: c.lang.forms.select.btnAdd,
256                         style: "width:100%;",
257                         onClick: function() {
258                             var a = this.getDialog(),
259                                 b = a.getContentElement("info", "txtOptName"),
260                                 e = a.getContentElement("info",
261                                     "txtOptValue"),
262                                 d = a.getContentElement("info", "cmbName"),
263                                 c = a.getContentElement("info", "cmbValue");
264                             h(d, b.getValue(), b.getValue(), a.getParentEditor().document);
265                             h(c, e.getValue(), e.getValue(), a.getParentEditor().document);
266                             b.setValue("");
267                             e.setValue("")
268                         }
269                     }, {
270                         type: "button",
271                         id: "btnModify",
272                         label: c.lang.forms.select.btnModify,
273                         title: c.lang.forms.select.btnModify,
274                         style: "width:100%;",
275                         onClick: function() {
276                             var a = this.getDialog(),
277                                 b = a.getContentElement("info", "txtOptName"),
278                                 e = a.getContentElement("info", "txtOptValue"),
279                                 d =
280                                 a.getContentElement("info", "cmbName"),
281                                 a = a.getContentElement("info", "cmbValue"),
282                                 c = g(d);
283                             0 <= c && (q(d, c, b.getValue(), b.getValue()), q(a, c, e.getValue(), e.getValue()))
284                         }
285                     }, {
286                         type: "button",
287                         id: "btnUp",
288                         style: "width:100%;",
289                         label: c.lang.forms.select.btnUp,
290                         title: c.lang.forms.select.btnUp,
291                         onClick: function() {
292                             var a = this.getDialog(),
293                                 b = a.getContentElement("info", "cmbName"),
294                                 c = a.getContentElement("info", "cmbValue");
295                             l(b, -1, a.getParentEditor().document);
296                             l(c, -1, a.getParentEditor().document)
297                         }
298                     }, {
299                         type: "button",
300                         id: "btnDown",
301                         style: "width:100%;",
302                         label: c.lang.forms.select.btnDown,
303                         title: c.lang.forms.select.btnDown,
304                         onClick: function() {
305                             var a = this.getDialog(),
306                                 b = a.getContentElement("info", "cmbName"),
307                                 c = a.getContentElement("info", "cmbValue");
308                             l(b, 1, a.getParentEditor().document);
309                             l(c, 1, a.getParentEditor().document)
310                         }
311                     }]
312                 }]
313             }, {
314                 type: "hbox",
315                 widths: ["40%", "20%", "40%"],
316                 children: [{
317                     type: "button",
318                     id: "btnSetValue",
319                     label: c.lang.forms.select.btnSetValue,
320                     title: c.lang.forms.select.btnSetValue,
321                     onClick: function() {
322                         var a = this.getDialog(),
323                             b = a.getContentElement("info", "cmbValue");
324                         a.getContentElement("info", "txtValue").setValue(b.getValue())
325                     }
326                 }, {
327                     type: "button",
328                     id: "btnDelete",
329                     label: c.lang.forms.select.btnDelete,
330                     title: c.lang.forms.select.btnDelete,
331                     onClick: function() {
332                         var a = this.getDialog(),
333                             b = a.getContentElement("info", "cmbName"),
334                             c = a.getContentElement("info", "cmbValue"),
335                             d = a.getContentElement("info", "txtOptName"),
336                             a = a.getContentElement("info", "txtOptValue");
337                         p(b);
338                         p(c);
339                         d.setValue("");
340                         a.setValue("")
341                     }
342                 }, {
343                     type: "vbox",
344                     children: [{
345                         id: "chkMulti",
346                         type: "checkbox",
347                         label: c.lang.forms.select.chkMulti,
348                         "default": "",
349                         accessKey: "M",
350                         value: "checked",
351                         setup: function(a, b) {
352                             "select" == a && this.setValue(b.getAttribute("multiple"))
353                         },
354                         commit: function(a) {
355                             this.getValue() ? a.setAttribute("multiple", this.getValue()) : a.removeAttribute("multiple")
356                         }
357                     }, {
358                         id: "required",
359                         type: "checkbox",
360                         label: c.lang.forms.select.required,
361                         "default": "",
362                         accessKey: "Q",
363                         value: "checked",
364                         setup: function(a, b) {
365                             "select" == a && this.setValue(b.getAttribute("required"))
366                         },
367                         commit: function(a) {
368                             this.getValue() ? a.setAttribute("required", "required") : a.removeAttribute("required")
369                         }
370                     }]
371                 }]
372             }]
373         }]
374     }
375 });