2 Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.md or http://ckeditor.com/license
5 CKEDITOR.dialog.add("select", function(c) {
6 function h(a, b, e, d, c) {
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));
16 for (var b = g(a), e = a.getChildren().count() - 1; 0 <=
17 e; e--) a.getChild(e).$.selected && a.getChild(e).remove();
21 function q(a, b, e, d) {
31 for (a = f(a); a.getChild(0) && a.getChild(0).remove(););
40 b = b >= a.getChildCount() ? a.getChildCount() - 1 : b;
41 if (d == b) return !1;
42 var d = a.getChild(d),
46 d = h(a, c, r, e ? e : null, b);
52 return (a = f(a)) ? a.$.selectedIndex : -1
57 if (0 > b) return null;
58 var e = a.getChildren().count();
59 a.$.selectedIndex = b >= e ? e - 1 : b;
64 return (a = f(a)) ? a.getChildren() : !1
68 return a && a.domId && a.getInputElement().$ ? a.getInputElement() : a && a.$ ? a : !1
71 title: c.lang.forms.select.title,
72 minWidth: CKEDITOR.env.ie ? 460 : 395,
73 minHeight: CKEDITOR.env.ie ? 320 : 300,
75 delete this.selectBox;
76 this.setupContent("clear");
77 var a = this.getParentEditor().getSelection().getSelectedElement();
78 if (a && "select" == a.getName()) {
81 this.setupContent(a.getName(), a);
82 for (var a = n(a), b = 0; b < a.count(); b++) this.setupContent("option", a.getItem(b))
86 var a = this.getParentEditor(),
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() {
101 label: c.lang.forms.select.selectInfo,
102 title: c.lang.forms.select.selectInfo,
107 widths: ["25%", "75%"],
108 labelLayout: "horizontal",
109 label: c.lang.common.name,
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") || "")
116 commit: function(a) {
117 this.getValue() ? a.data("cke-saved-name", this.getValue()) : (a.data("cke-saved-name", !1), a.removeAttribute("name"))
122 widths: ["25%", "75%"],
123 labelLayout: "horizontal",
124 label: c.lang.forms.select.value,
125 style: "width:350px",
127 className: "cke_disabled",
129 this.getInputElement().setAttribute("readOnly", !0)
131 setup: function(a, b) {
132 "clear" == a ? this.setValue("") : "option" == a && b.getAttribute("selected") && this.setValue(b.$.value)
136 className: "cke_dialog_forms_select_order_txtsize",
137 widths: ["175px", "170px"],
141 labelLayout: "horizontal",
142 label: c.lang.forms.select.size,
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)
150 setup: function(a, b) {
151 "select" == a && this.setValue(b.getAttribute("size") || "");
152 CKEDITOR.env.webkit && this.getInputElement().setStyle("width", "86px")
154 commit: function(a) {
155 this.getValue() ? a.setAttribute("size", this.getValue()) : a.removeAttribute("size")
159 html: "\x3cspan\x3e" + CKEDITOR.tools.htmlEncode(c.lang.forms.select.lines) + "\x3c/span\x3e"
163 html: "\x3cspan\x3e" + CKEDITOR.tools.htmlEncode(c.lang.forms.select.opAvail) + "\x3c/span\x3e"
166 widths: ["115px", "115px", "100px"],
167 className: "cke_dialog_forms_select_order",
173 label: c.lang.forms.select.opText,
174 style: "width:115px",
176 "clear" == a && this.setValue("")
184 style: "width:115px;height:75px",
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"),
193 e.setValue(this.getValue());
194 a.setValue(b.getValue())
196 setup: function(a, b) {
197 "clear" == a ? m(this) : "option" == a && h(this, b.getText(), b.getText(), this.getDialog().getParentEditor().document)
199 commit: function(a) {
200 var b = this.getDialog(),
202 d = n(b.getContentElement("info", "cmbValue")),
203 c = b.getContentElement("info", "txtValue").getValue();
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)
217 label: c.lang.forms.select.opValue,
218 style: "width:115px",
220 "clear" == a && this.setValue("")
227 style: "width:115px;height:75px",
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"),
236 e.setValue(b.getValue());
237 a.setValue(this.getValue())
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)
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",
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);
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"),
280 a.getContentElement("info", "cmbName"),
281 a = a.getContentElement("info", "cmbValue"),
283 0 <= c && (q(d, c, b.getValue(), b.getValue()), q(a, c, e.getValue(), e.getValue()))
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)
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)
315 widths: ["40%", "20%", "40%"],
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())
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");
347 label: c.lang.forms.select.chkMulti,
351 setup: function(a, b) {
352 "select" == a && this.setValue(b.getAttribute("multiple"))
354 commit: function(a) {
355 this.getValue() ? a.setAttribute("multiple", this.getValue()) : a.removeAttribute("multiple")
360 label: c.lang.forms.select.required,
364 setup: function(a, b) {
365 "select" == a && this.setValue(b.getAttribute("required"))
367 commit: function(a) {
368 this.getValue() ? a.setAttribute("required", "required") : a.removeAttribute("required")