PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.5
Forumax – AI Powered Advanced Community Forum Plugin v1.2.5
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / assets / js / admin-main.js

admin-main.js in Forumax – AI Powered Advanced Community Forum Plugin 1.2.5, at assets/js/admin-main.js

332 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 'use strict';
3
4 /*------------ Cookie functions and color js ------------*/
5 function createCookie(name, value, days) {
6 var expires = '';
7 if (days) {
8 var date = new Date();
9 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
10 expires = '; expires=' + date.toUTCString();
11 }
12 document.cookie = name + '=' + value + expires + '; path=/';
13 }
14
15 function readCookie(name) {
16 var nameEQ = name + '=';
17 var ca = document.cookie.split(';');
18 for (var i = 0; i < ca.length; i++) {
19 var c = ca[i];
20 while (c.charAt(0) == ' ') c = c.substring(1, c.length);
21 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
22 }
23 return null;
24 }
25
26 function eraseCookie(name) {
27 createCookie(name, '', -1);
28 }
29
30 var prefersDark =
31 window.matchMedia &&
32 window.matchMedia('(prefers-color-scheme: dark)').matches;
33 var selectedNightTheme = readCookie('body_dark');
34
35 if (
36 selectedNightTheme == 'true' ||
37 (selectedNightTheme === null && prefersDark)
38 ) {
39 applyNight();
40 $('.dark_mode_switcher').prop('checked', true);
41 } else {
42 applyDay();
43 $('.dark_mode_switcher').prop('checked', false);
44 }
45
46 function applyNight() {
47 if ($('.js-darkmode-btn .ball').length) {
48 $('.js-darkmode-btn .ball').css('left', '45px');
49 }
50 $('body').addClass('body_dark');
51 }
52
53 function applyDay() {
54 if ($('.js-darkmode-btn .ball').length) {
55 $('.js-darkmode-btn .ball').css('left', '4px');
56 }
57 $('body').removeClass('body_dark');
58 }
59
60 $('.dark_mode_switcher').change(function () {
61 if ($(this).is(':checked')) {
62 applyNight();
63 createCookie('body_dark', true, 999);
64 } else {
65 applyDay();
66 createCookie('body_dark', false, 999);
67 }
68 });
69
70 // Filter Select
71 $('select').niceSelect();
72
73 // Sidebar Tabs [COOKIE]
74 $(document).on('click', '.tab-menu .easydocs-navitem', function () {
75 let target = $(this).attr('data-rel');
76 $('.tab-menu .easydocs-navitem').removeClass('is-active');
77 $(this).addClass('is-active');
78 $('#' + target)
79 .fadeIn('slow')
80 .siblings('.easydocs-tab')
81 .hide();
82
83 let is_active_tab = $('.tab-menu .easydocs-navitem').hasClass('is-active');
84 if ( is_active_tab === true ) {
85 let active_tab_id = $('.easydocs-navitem.is-active').attr('data-rel');
86 createCookie('eazydocs_doc_current_tab', active_tab_id, 999);
87 }
88
89 return true;
90 });
91
92 // Remain the last active doc tab
93 function keep_last_active_doc_tab() {
94 let doc_last_current_tab = readCookie('eazydocs_doc_current_tab');
95 if ( doc_last_current_tab != '' ) {
96 // Tab item
97 $('.tab-menu .easydocs-navitem').removeClass('is-active');
98 $(
99 '.tab-menu .easydocs-navitem[data-rel=' + doc_last_current_tab + ']'
100 ).addClass('is-active');
101 // Tab content
102 $('.easydocs-tab-content .easydocs-tab').removeClass('tab-active');
103 $('#' + doc_last_current_tab).addClass('tab-active');
104 }
105 }
106 keep_last_active_doc_tab();
107
108 $('.tab-menu .easydocs-navitem .parent-delete').on('click', function () {
109 return false;
110 });
111
112 $(document).ready(function () {
113
114 if ( $('#bbpc-search').length ) {
115 $('#bbpc-search').on('keyup', function () {
116 var value = $(this).val().toLowerCase();
117 $('.easydocs-accordion-item').filter(function () {
118 $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
119 });
120 });
121
122 // Dropdown Classic UI Filter
123 let bbpc_classic_ui = document.getElementById('bbpc_classic_ui');
124
125 function swithToLink() {
126 window.location.href = this.value;
127 }
128
129 bbpc_classic_ui.onchange = swithToLink;
130 }
131 })
132
133 $(document).ready(function (e) {
134 function t(t) {
135 e(t).bind('click', function (t) {
136 t.preventDefault();
137 e(this).parent().fadeOut();
138 });
139 }
140
141 e('.header-notify-icon').click(function () {
142 var t = e(this)
143 .parents('.easydocs-notification')
144 .children('.easydocs-dropdown')
145 .is(':hidden');
146 e('.easydocs-notification .easydocs-dropdown').hide();
147 e('.easydocs-notification .header-notify-icon').removeClass('active');
148 if (t) {
149 e(this)
150 .parents('.easydocs-notification')
151 .children('.easydocs-dropdown')
152 .toggle()
153 .parents('.easydocs-notification')
154 .children('.header-notify-icon')
155 .addClass('active');
156 }
157 });
158 e(document).bind('click', function (t) {
159 var n = e(t.target);
160 if (!n.parents().hasClass('easydocs-notification'))
161 e('.easydocs-notification .easydocs-dropdown').hide();
162 });
163 e(document).bind('click', function (t) {
164 var n = e(t.target);
165 if (!n.parents().hasClass('easydocs-notification'))
166 e('.easydocs-notification .header-notify-icon').removeClass('active');
167 });
168
169 // ADD PARENT FORUM
170 function create_forum() {
171 $(document).on('click', '#bbpc-forum', function (e) {
172 e.preventDefault();
173 let href = $(this).attr('href');
174 Swal.fire({
175 title: bbp_core_local_object.create_forum_title,
176 input: 'text',
177 showCancelButton: true,
178 inputAttributes: {
179 name: 'bbp_parent_title',
180 },
181 }).then((result) => {
182 if (result.value) {
183 document.location.href = href + result.value;
184 }
185 });
186 });
187 }
188 create_forum();
189
190 // SECTION DOC
191 function create_topic() {
192 $(document).on('click', '#bbpc-topic', function (e) {
193 e.preventDefault();
194 let href = $(this).attr('href');
195 Swal.fire({
196 title: bbp_core_local_object.create_topic_title,
197 input: 'text',
198 showCancelButton: true,
199 inputAttributes: {
200 name: 'section',
201 },
202 }).then((result) => {
203 if (result.value) {
204 document.location.href = href + result.value;
205 }
206 });
207 });
208 }
209 create_topic();
210
211 // DELETE FORUM
212 function delete_forum() {
213 $('.forum-delete').on('click', function (e) {
214 e.preventDefault();
215 let href = $(this).attr('href');
216 Swal.fire({
217 title: bbp_core_local_object.forum_delete_title,
218 text: bbp_core_local_object.forum_delete_desc,
219 icon: 'question',
220 showCancelButton: true,
221 confirmButtonColor: '#3085d6',
222 cancelButtonColor: '#d33',
223 confirmButtonText: 'Yes',
224 }).then((result) => {
225 if (result.value) {
226 document.location.href = href;
227 }
228 });
229 });
230 }
231 delete_forum();
232
233 // DELETE TOPIC
234 function delete_topic() {
235 $('.section-delete').on('click', function (e) {
236 e.preventDefault();
237 let href = $(this).attr('href');
238 Swal.fire({
239 title: bbp_core_local_object.forum_delete_title,
240 text: bbp_core_local_object.topic_delete_desc,
241 icon: 'question',
242 showCancelButton: true,
243 confirmButtonColor: '#3085d6',
244 cancelButtonColor: '#d33',
245 confirmButtonText: 'Yes',
246 }).then((result) => {
247 if (result.value) {
248 document.location.href = href;
249 }
250 });
251 });
252 }
253
254 delete_topic();
255
256 // Notification pro alert
257 $('.easydocs-notification.bbp-core-pro-notification').on(
258 'click',
259 function (e) {
260 e.preventDefault();
261 let href = $(this).attr('href');
262 let assets = bbp_core_local_object.BBPC_ASSETS;
263 Swal.fire({
264 title: 'Notification is a Premium feature',
265 html:
266 '<span class="pro-notification-body-text">You need to Upgrade the Premium Version to use this feature</span><video height="400px" autoplay="autoplay" loop="loop" src="' +
267 assets +
268 '/videos/noti.mp4"></video>',
269 icon: false,
270 buttons: false,
271 dangerMode: true,
272 showCloseButton: true,
273 confirmButtonText:
274 '<a href="admin.php?page=bbp-core-pricing">Upgrade to Premium</a>',
275 footer:
276 '<a href="https://spider-themes.net/bbp-core/" target="_blank"> Learn More </a>',
277 customClass: {
278 title: 'upgrade-premium-heading',
279 confirmButton: 'upgrade-premium-button',
280 footer: 'notification-pro-footer-wrap',
281 },
282 confirmButtonColor: '#f1bd6c',
283 Borderless: true,
284 });
285 }
286 );
287 });
288
289 // Click pending replies count to show pending replies.
290 $('[click-target]').click(function () {
291 let id = $(this).attr('click-target');
292 $(`[click-target=${id}]`).toggleClass('active');
293 $(`[reply-target=${id}]`).toggle();
294 });
295
296 // Sidebar Tabs [COOKIE]
297 $(document).on('click', '[cookie-id]', function () {
298 let target = $(this).attr('cookie-id');
299 let item = `[cookie-id=${target}]`;
300 $('[cookie-id]').removeClass('is-active mixitup-control-active');
301 $(item).addClass('is-active mixitup-control-active');
302 $(target).fadeIn('slow').siblings('.easydocs-tab').hide();
303
304 let isActiveTab = $(this).hasClass('is-active');
305 if (isActiveTab === true) {
306 createCookie('bbpc_current_filter', target, 999);
307 }
308
309 return true;
310 });
311
312 $(document).ready(function () {
313 // Keep Last filter item active
314 function keepLastFilterActive() {
315 let bbpcLastActiveFilter = readCookie('bbpc_current_filter');
316 if (bbpcLastActiveFilter) {
317 // Tab item
318 $('[cookie-id]').removeClass('is-active mixitup-control-active');
319 $(`[cookie-id="${bbpcLastActiveFilter}"]`).click();
320 }
321 }
322
323 keepLastFilterActive();
324
325 });
326
327 })(jQuery);
328
329 function menuToggle() {
330 const toggleMenu = document.querySelector('.easydocs-dropdown');
331 toggleMenu.classList.toggle('is-active');
332 }