Built motion from commit 67e5df37.|2.0.66
[motion2.git] / public / assets / plugins / ckeditor / plugins / forms / dialogs / checkbox.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("checkbox", function(d) {
6     return {
7         title: d.lang.forms.checkboxAndRadio.checkboxTitle,
8         minWidth: 350,
9         minHeight: 140,
10         onShow: function() {
11             delete this.checkbox;
12             var a = this.getParentEditor().getSelection().getSelectedElement();
13             a && "checkbox" == a.getAttribute("type") && (this.checkbox = a, this.setupContent(a))
14         },
15         onOk: function() {
16             var a, b = this.checkbox;
17             b || (a = this.getParentEditor(), b = a.document.createElement("input"), b.setAttribute("type", "checkbox"), a.insertElement(b));
18             this.commitContent({
19                 element: b
20             })
21         },
22         contents: [{
23             id: "info",
24             label: d.lang.forms.checkboxAndRadio.checkboxTitle,
25             title: d.lang.forms.checkboxAndRadio.checkboxTitle,
26             startupFocus: "txtName",
27             elements: [{
28                 id: "txtName",
29                 type: "text",
30                 label: d.lang.common.name,
31                 "default": "",
32                 accessKey: "N",
33                 setup: function(a) {
34                     this.setValue(a.data("cke-saved-name") || a.getAttribute("name") || "")
35                 },
36                 commit: function(a) {
37                     a = a.element;
38                     this.getValue() ? a.data("cke-saved-name", this.getValue()) : (a.data("cke-saved-name", !1), a.removeAttribute("name"))
39                 }
40             }, {
41                 id: "txtValue",
42                 type: "text",
43                 label: d.lang.forms.checkboxAndRadio.value,
44                 "default": "",
45                 accessKey: "V",
46                 setup: function(a) {
47                     a = a.getAttribute("value");
48                     this.setValue(CKEDITOR.env.ie && "on" == a ? "" : a)
49                 },
50                 commit: function(a) {
51                     var b = a.element,
52                         c = this.getValue();
53                     !c || CKEDITOR.env.ie && "on" == c ? CKEDITOR.env.ie ? (c = new CKEDITOR.dom.element("input", b.getDocument()), b.copyAttributes(c, {
54                         value: 1
55                     }), c.replace(b), d.getSelection().selectElement(c), a.element = c) : b.removeAttribute("value") : b.setAttribute("value", c)
56                 }
57             }, {
58                 id: "cmbSelected",
59                 type: "checkbox",
60                 label: d.lang.forms.checkboxAndRadio.selected,
61                 "default": "",
62                 accessKey: "S",
63                 value: "checked",
64                 setup: function(a) {
65                     this.setValue(a.getAttribute("checked"))
66                 },
67                 commit: function(a) {
68                     var b = a.element;
69                     if (CKEDITOR.env.ie) {
70                         var c = !!b.getAttribute("checked"),
71                             e = !!this.getValue();
72                         c != e && (c = CKEDITOR.dom.element.createFromHtml('\x3cinput type\x3d"checkbox"' + (e ? ' checked\x3d"checked"' : "") + "/\x3e", d.document), b.copyAttributes(c, {
73                             type: 1,
74                             checked: 1
75                         }), c.replace(b), d.getSelection().selectElement(c), a.element = c)
76                     } else a = this.getValue(), CKEDITOR.env.webkit && (b.$.checked = a), a ? b.setAttribute("checked",
77                         "checked") : b.removeAttribute("checked")
78                 }
79             }, {
80                 id: "required",
81                 type: "checkbox",
82                 label: d.lang.forms.checkboxAndRadio.required,
83                 "default": "",
84                 accessKey: "Q",
85                 value: "required",
86                 setup: function(a) {
87                     this.setValue(a.getAttribute("required"))
88                 },
89                 commit: function(a) {
90                     a = a.element;
91                     this.getValue() ? a.setAttribute("required", "required") : a.removeAttribute("required")
92                 }
93             }]
94         }]
95     }
96 });