Built motion from commit 67e5df37.|2.0.66
[motion2.git] / public / assets / plugins / ckeditor / plugins / templates / dialogs / templates.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 (function() {
6     CKEDITOR.dialog.add("templates", function(c) {
7         function r(a, b) {
8             var m = CKEDITOR.dom.element.createFromHtml('\x3ca href\x3d"javascript:void(0)" tabIndex\x3d"-1" role\x3d"option" \x3e\x3cdiv class\x3d"cke_tpl_item"\x3e\x3c/div\x3e\x3c/a\x3e'),
9                 d = '\x3ctable style\x3d"width:350px;" class\x3d"cke_tpl_preview" role\x3d"presentation"\x3e\x3ctr\x3e';
10             a.image && b && (d += '\x3ctd class\x3d"cke_tpl_preview_img"\x3e\x3cimg src\x3d"' + CKEDITOR.getUrl(b + a.image) + '"' + (CKEDITOR.env.ie6Compat ? ' onload\x3d"this.width\x3dthis.width"' :
11                 "") + ' alt\x3d"" title\x3d""\x3e\x3c/td\x3e');
12             d += '\x3ctd style\x3d"white-space:normal;"\x3e\x3cspan class\x3d"cke_tpl_title"\x3e' + a.title + "\x3c/span\x3e\x3cbr/\x3e";
13             a.description && (d += "\x3cspan\x3e" + a.description + "\x3c/span\x3e");
14             d += "\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e";
15             m.getFirst().setHtml(d);
16             m.on("click", function() {
17                 t(a.html)
18             });
19             return m
20         }
21
22         function t(a) {
23             var b = CKEDITOR.dialog.getCurrent();
24             b.getValueOf("selectTpl", "chkInsertOpt") ? (c.fire("saveSnapshot"), c.setData(a, function() {
25                 b.hide();
26                 var a = c.createRange();
27                 a.moveToElementEditStart(c.editable());
28                 a.select();
29                 setTimeout(function() {
30                     c.fire("saveSnapshot")
31                 }, 0)
32             })) : (c.insertHtml(a), b.hide())
33         }
34
35         function k(a) {
36             var b = a.data.getTarget(),
37                 c = g.equals(b);
38             if (c || g.contains(b)) {
39                 var d = a.data.getKeystroke(),
40                     f = g.getElementsByTag("a"),
41                     e;
42                 if (f) {
43                     if (c) e = f.getItem(0);
44                     else switch (d) {
45                         case 40:
46                             e = b.getNext();
47                             break;
48                         case 38:
49                             e = b.getPrevious();
50                             break;
51                         case 13:
52                         case 32:
53                             b.fire("click")
54                     }
55                     e && (e.focus(), a.data.preventDefault())
56                 }
57             }
58         }
59         var h = CKEDITOR.plugins.get("templates");
60         CKEDITOR.document.appendStyleSheet(CKEDITOR.getUrl(h.path +
61             "dialogs/templates.css"));
62         var g, h = "cke_tpl_list_label_" + CKEDITOR.tools.getNextNumber(),
63             f = c.lang.templates,
64             n = c.config;
65         return {
66             title: c.lang.templates.title,
67             minWidth: CKEDITOR.env.ie ? 440 : 400,
68             minHeight: 340,
69             contents: [{
70                 id: "selectTpl",
71                 label: f.title,
72                 elements: [{
73                     type: "vbox",
74                     padding: 5,
75                     children: [{
76                         id: "selectTplText",
77                         type: "html",
78                         html: "\x3cspan\x3e" + f.selectPromptMsg + "\x3c/span\x3e"
79                     }, {
80                         id: "templatesList",
81                         type: "html",
82                         focus: !0,
83                         html: '\x3cdiv class\x3d"cke_tpl_list" tabIndex\x3d"-1" role\x3d"listbox" aria-labelledby\x3d"' +
84                             h + '"\x3e\x3cdiv class\x3d"cke_tpl_loading"\x3e\x3cspan\x3e\x3c/span\x3e\x3c/div\x3e\x3c/div\x3e\x3cspan class\x3d"cke_voice_label" id\x3d"' + h + '"\x3e' + f.options + "\x3c/span\x3e"
85                     }, {
86                         id: "chkInsertOpt",
87                         type: "checkbox",
88                         label: f.insertOption,
89                         "default": n.templates_replaceContent
90                     }]
91                 }]
92             }],
93             buttons: [CKEDITOR.dialog.cancelButton],
94             onShow: function() {
95                 var a = this.getContentElement("selectTpl", "templatesList");
96                 g = a.getElement();
97                 CKEDITOR.loadTemplates(n.templates_files, function() {
98                     var b = (n.templates || "default").split(",");
99                     if (b.length) {
100                         var c = g;
101                         c.setHtml("");
102                         for (var d = 0, h = b.length; d < h; d++)
103                             for (var e = CKEDITOR.getTemplates(b[d]), k = e.imagesPath, e = e.templates, q = e.length, l = 0; l < q; l++) {
104                                 var p = r(e[l], k);
105                                 p.setAttribute("aria-posinset", l + 1);
106                                 p.setAttribute("aria-setsize", q);
107                                 c.append(p)
108                             }
109                         a.focus()
110                     } else g.setHtml('\x3cdiv class\x3d"cke_tpl_empty"\x3e\x3cspan\x3e' + f.emptyListMsg + "\x3c/span\x3e\x3c/div\x3e")
111                 });
112                 this._.element.on("keydown", k)
113             },
114             onHide: function() {
115                 this._.element.removeListener("keydown", k)
116             }
117         }
118     })
119 })();