forked from WonderCMS/wondercms-cdn-files
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwcms-admin.js
More file actions
106 lines (97 loc) · 3.77 KB
/
wcms-admin.js
File metadata and controls
106 lines (97 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
function fieldSave(id, newContent, dataTarget, dataMenu, dataVisibility, oldContent) {
if (newContent !== oldContent) {
$("#save").show(), $.post("", {
fieldname: id,
token: token,
content: newContent,
target: dataTarget,
menu: dataMenu,
visibility: dataVisibility
}, function (a) {
}).always(function () {
window.location.reload();
});
} else {
const target = $('#' + id);
target.removeClass('editTextOpen');
target.html(newContent);
}
}
function editableTextArea(editableTarget) {
const data = (
target = editableTarget,
content = target.html(),
title = target.attr("title") ? '"' + target.attr("title") + '" ' : '',
targetId = target.attr('id'),
"<textarea " + title + ' id="' + targetId + "_field\" onblur=\"" +
"fieldSave(targetId,this.value,target.data('target'),target.data('menu'),target.data('visibility'), content);" +
"\">" + content + "</textarea>"
);
editableTarget.html(data);
}
// Open direct tab in modal
$("#settingsModal").on("show.bs.modal", function (t) {
var e = $(t.relatedTarget);
$("a[href='" + e.data("target-tab") + "']").tab("show")
});
$(document).tabOverride(!0, "textarea");
$(document).ready(function () {
// Loader
$("body").on("click", "[data-loader-id]", function (t) {
$("#" + $(t.target).data("loader-id")).show()
});
// Editable fields content save
$("body").on("click", "div.editText:not(.editTextOpen)", function () {
const target = $(this);
target.addClass('editTextOpen');
editableTextArea(target);
target.children(':first').focus();
autosize($('textarea'));
});
// Menu item hidden or visible
$("body").on("click", "i.menu-toggle", function () {
var t = $(this), e = (setTimeout(function () {
window.location.reload()
}, 500), t.attr("data-menu"));
t.hasClass("menu-item-hide") ? (t.removeClass("glyphicon-eye-open menu-item-hide").addClass("glyphicon-eye-close menu-item-show"), t.attr("title", "Hide page from menu").attr("data-visibility", "hide"), $.post("", {
fieldname: "menuItems",
token: token,
content: " ",
target: "menuItemVsbl",
menu: e,
visibility: "hide"
}, function (t) {
})) : t.hasClass("menu-item-show") && (t.removeClass("glyphicon-eye-close menu-item-show").addClass("glyphicon-eye-open menu-item-hide"), t.attr("title", "Show page in menu").attr("data-visibility", "show"), $.post("", {
fieldname: "menuItems",
token: token,
content: " ",
target: "menuItemVsbl",
menu: e,
visibility: "show"
}, function (t) {
}))
});
// Add new page
$("body").on("click", ".menu-item-add", function () {
var t = prompt("Enter page name");
if (!t) return !1;
t = t.replace(/[`~;:'",.<>\{\}\[\]\\\/]/gi, "").trim(), $.post("", {
fieldname: "menuItems",
token: token,
content: t,
target: "menuItem",
menu: "none"
}, function (t) {
}).done(setTimeout(function () {
window.location.reload()
}, 500))
});
// Reorder menu item
$("body").on("click", ".menu-item-up,.menu-item-down", function () {
var t = $(this), e = t.hasClass("menu-item-up") ? "-1" : "1", n = t.attr("data-menu");
$.post("", {fieldname: "menuItems", token: token, content: e, target: "menuItemOrder", menu: n}, function (t) {
}).done(function () {
$("#menuSettings").parent().load("index.php #menuSettings")
})
})
});