PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.5
ووسلام – همگام سازی ووکامرس و باسلام v1.10.5
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / assets / js / logs.js

logs.js in ووسلام – همگام سازی ووکامرس و باسلام 1.10.5, at assets/js/logs.js

127 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function ($) {
2 $(document).on("click", ".log-basalam-context-toggle-modern", function () {
3 var contextDiv = $(this)
4 .closest(".log-basalam-log-item-modern")
5 .find(".log-basalam-log-context-modern");
6 contextDiv.toggleClass("log-basalam-show");
7
8 if (contextDiv.hasClass("log-basalam-show")) {
9 $(this).text("�
10 خفی کردن");
11 } else {
12 $(this).text("جزئیات");
13 }
14 });
15
16 $(document).on("click", ".basalam-context-toggle", function () {
17 var contextDiv = $(this)
18 .closest(".basalam-log-item")
19 .find(".basalam-log-context");
20 contextDiv.toggleClass("Basalam-show");
21
22 if (contextDiv.hasClass("Basalam-show")) {
23 $(this).text("�
24 خفی کردن");
25 } else {
26 $(this).text("جزئیات");
27 }
28 });
29
30 var modal = $("#basalam-clear-logs-modal");
31 var clearBtn = $("#basalam-clear-logs-btn");
32 var cancelBtn = $("#basalam-cancel-clear");
33 var confirmBtn = $("#basalam-confirm-clear");
34 var closeBtn = $(".log-basalam-modal-close");
35
36 clearBtn.on("click", function () {
37 modal.show();
38 });
39
40 function hideModal() {
41 modal.hide();
42 }
43
44 cancelBtn.on("click", hideModal);
45 closeBtn.on("click", hideModal);
46
47 modal.on("click", function (e) {
48 if (e.target === this) {
49 hideModal();
50 }
51 });
52
53 confirmBtn.on("click", function () {
54 var nonce = clearBtn.data("nonce");
55 var button = $(this);
56 var originalText = button.text();
57
58 button.prop("disabled", true).text("در حال حذف...");
59
60 $.ajax({
61 url: ajaxurl,
62 type: "POST",
63 data: {
64 action: "basalam_clear_logs",
65 _wpnonce: nonce,
66 },
67 success: function (response) {
68 if (response.success) {
69 showNotification(response.data.message, "success");
70 setTimeout(function () {
71 location.reload();
72 }, 1500);
73 } else {
74 showNotification(
75 response.data.message || "خطا در حذف لاگ‌ها",
76 "error"
77 );
78 }
79 },
80 error: function () {
81 showNotification("خطا در ارتباط با سرور", "error");
82 },
83 complete: function () {
84 button.prop("disabled", false).text(originalText);
85 hideModal();
86 },
87 });
88 });
89
90 function showNotification(message, type) {
91 $(".basalam-notification").remove();
92
93 var notificationClass =
94 type === "success" ? "notice-success" : "notice-error";
95 var icon = type === "success" ? "" : "";
96
97 var notification = $(
98 '<div class="basalam-notification notice ' +
99 notificationClass +
100 ' is-dismissible">' +
101 "<p><strong>" +
102 icon +
103 "</strong> " +
104 message +
105 "</p>" +
106 '<button type="button" class="notice-dismiss">' +
107 '<span class="screen-reader-text">بستن این اعلان.</span>' +
108 "</button>" +
109 "</div>"
110 );
111
112 $(".basalam-container").prepend(notification);
113
114 setTimeout(function () {
115 notification.fadeOut(function () {
116 $(this).remove();
117 });
118 }, 5000);
119
120 notification.find(".notice-dismiss").on("click", function () {
121 notification.fadeOut(function () {
122 $(this).remove();
123 });
124 });
125 }
126 });
127