2 Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.md or http://ckeditor.com/license
6 CKEDITOR.dialog.add("templates", function(c) {
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() {
23 var b = CKEDITOR.dialog.getCurrent();
24 b.getValueOf("selectTpl", "chkInsertOpt") ? (c.fire("saveSnapshot"), c.setData(a, function() {
26 var a = c.createRange();
27 a.moveToElementEditStart(c.editable());
29 setTimeout(function() {
30 c.fire("saveSnapshot")
32 })) : (c.insertHtml(a), b.hide())
36 var b = a.data.getTarget(),
38 if (c || g.contains(b)) {
39 var d = a.data.getKeystroke(),
40 f = g.getElementsByTag("a"),
43 if (c) e = f.getItem(0);
55 e && (e.focus(), a.data.preventDefault())
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(),
66 title: c.lang.templates.title,
67 minWidth: CKEDITOR.env.ie ? 440 : 400,
78 html: "\x3cspan\x3e" + f.selectPromptMsg + "\x3c/span\x3e"
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"
88 label: f.insertOption,
89 "default": n.templates_replaceContent
93 buttons: [CKEDITOR.dialog.cancelButton],
95 var a = this.getContentElement("selectTpl", "templatesList");
97 CKEDITOR.loadTemplates(n.templates_files, function() {
98 var b = (n.templates || "default").split(",");
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++) {
105 p.setAttribute("aria-posinset", l + 1);
106 p.setAttribute("aria-setsize", q);
110 } else g.setHtml('\x3cdiv class\x3d"cke_tpl_empty"\x3e\x3cspan\x3e' + f.emptyListMsg + "\x3c/span\x3e\x3c/div\x3e")
112 this._.element.on("keydown", k)
115 this._.element.removeListener("keydown", k)