PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.0.8
Forumax – AI Powered Advanced Community Forum Plugin v1.0.8
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.0.8, at assets/js/admin-main.js

329 lines 9.9 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 $('#bbpc-search').on('keyup', function () {
114 var value = $(this).val().toLowerCase();
115 $('.easydocs-accordion-item').filter(function () {
116 $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
117 });
118 });
119
120 // Dropdown Classic UI Filter
121 let bbpc_classic_ui = document.getElementById('bbpc_classic_ui');
122
123 function swithToLink() {
124 window.location.href = this.value;
125 }
126
127 bbpc_classic_ui.onchange = swithToLink;
128 });
129
130 $(document).ready(function (e) {
131 function t(t) {
132 e(t).bind('click', function (t) {
133 t.preventDefault();
134 e(this).parent().fadeOut();
135 });
136 }
137
138 e('.header-notify-icon').click(function () {
139 var t = e(this)
140 .parents('.easydocs-notification')
141 .children('.easydocs-dropdown')
142 .is(':hidden');
143 e('.easydocs-notification .easydocs-dropdown').hide();
144 e('.easydocs-notification .header-notify-icon').removeClass('active');
145 if (t) {
146 e(this)
147 .parents('.easydocs-notification')
148 .children('.easydocs-dropdown')
149 .toggle()
150 .parents('.easydocs-notification')
151 .children('.header-notify-icon')
152 .addClass('active');
153 }
154 });
155 e(document).bind('click', function (t) {
156 var n = e(t.target);
157 if (!n.parents().hasClass('easydocs-notification'))
158 e('.easydocs-notification .easydocs-dropdown').hide();
159 });
160 e(document).bind('click', function (t) {
161 var n = e(t.target);
162 if (!n.parents().hasClass('easydocs-notification'))
163 e('.easydocs-notification .header-notify-icon').removeClass('active');
164 });
165
166 // ADD PARENT FORUM
167 function create_forum() {
168 $(document).on('click', '#bbpc-forum', function (e) {
169 e.preventDefault();
170 let href = $(this).attr('href');
171 Swal.fire({
172 title: bbp_core_local_object.create_forum_title,
173 input: 'text',
174 showCancelButton: true,
175 inputAttributes: {
176 name: 'bbp_parent_title',
177 },
178 }).then((result) => {
179 if (result.value) {
180 document.location.href = href + result.value;
181 }
182 });
183 });
184 }
185 create_forum();
186
187 // SECTION DOC
188 function create_topic() {
189 $(document).on('click', '#bbpc-topic', function (e) {
190 e.preventDefault();
191 let href = $(this).attr('href');
192 Swal.fire({
193 title: bbp_core_local_object.create_topic_title,
194 input: 'text',
195 showCancelButton: true,
196 inputAttributes: {
197 name: 'section',
198 },
199 }).then((result) => {
200 if (result.value) {
201 document.location.href = href + result.value;
202 }
203 });
204 });
205 }
206 create_topic();
207
208 // DELETE FORUM
209 function delete_forum() {
210 $('.forum-delete').on('click', function (e) {
211 e.preventDefault();
212 let href = $(this).attr('href');
213 Swal.fire({
214 title: bbp_core_local_object.forum_delete_title,
215 text: bbp_core_local_object.forum_delete_desc,
216 icon: 'question',
217 showCancelButton: true,
218 confirmButtonColor: '#3085d6',
219 cancelButtonColor: '#d33',
220 confirmButtonText: 'Yes',
221 }).then((result) => {
222 if (result.value) {
223 document.location.href = href;
224 }
225 });
226 });
227 }
228 delete_forum();
229
230 // DELETE TOPIC
231 function delete_topic() {
232 $('.section-delete').on('click', function (e) {
233 e.preventDefault();
234 let href = $(this).attr('href');
235 Swal.fire({
236 title: bbp_core_local_object.forum_delete_title,
237 text: bbp_core_local_object.topic_delete_desc,
238 icon: 'question',
239 showCancelButton: true,
240 confirmButtonColor: '#3085d6',
241 cancelButtonColor: '#d33',
242 confirmButtonText: 'Yes',
243 }).then((result) => {
244 if (result.value) {
245 document.location.href = href;
246 }
247 });
248 });
249 }
250
251 delete_topic();
252
253 // Notification pro alert
254 $('.easydocs-notification.bbp-core-pro-notification').on(
255 'click',
256 function (e) {
257 e.preventDefault();
258 let href = $(this).attr('href');
259 let assets = bbp_core_local_object.BBPC_ASSETS;
260 Swal.fire({
261 title: 'Notification is a Premium feature',
262 html:
263 '<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="' +
264 assets +
265 '/videos/noti.mp4"></video>',
266 icon: false,
267 buttons: false,
268 dangerMode: true,
269 showCloseButton: true,
270 confirmButtonText:
271 '<a href="admin.php?page=bbp-core-pricing">Upgrade to Premium</a>',
272 footer:
273 '<a href="https://spider-themes.net/bbp-core/" target="_blank"> Learn More </a>',
274 customClass: {
275 title: 'upgrade-premium-heading',
276 confirmButton: 'upgrade-premium-button',
277 footer: 'notification-pro-footer-wrap',
278 },
279 confirmButtonColor: '#f1bd6c',
280 Borderless: true,
281 });
282 }
283 );
284 });
285
286 // Click pending replies count to show pending replies.
287 $('[click-target]').click(function () {
288 let id = $(this).attr('click-target');
289 $(`[click-target=${id}]`).toggleClass('active');
290 $(`[reply-target=${id}]`).toggle();
291 });
292
293 // Sidebar Tabs [COOKIE]
294 $(document).on('click', '[cookie-id]', function () {
295 let target = $(this).attr('cookie-id');
296 let item = `[cookie-id=${target}]`;
297 $('[cookie-id]').removeClass('is-active mixitup-control-active');
298 $(item).addClass('is-active mixitup-control-active');
299 $(target).fadeIn('slow').siblings('.easydocs-tab').hide();
300
301 let isActiveTab = $(this).hasClass('is-active');
302 if (isActiveTab === true) {
303 createCookie('bbpc_current_filter', target, 999);
304 }
305
306 return true;
307 });
308
309 $(document).ready(function () {
310 // Keep Last filter item active
311 function keepLastFilterActive() {
312 let bbpcLastActiveFilter = readCookie('bbpc_current_filter');
313 if (bbpcLastActiveFilter) {
314 // Tab item
315 $('[cookie-id]').removeClass('is-active mixitup-control-active');
316 $(`[cookie-id="${bbpcLastActiveFilter}"]`).click();
317 }
318 }
319
320 keepLastFilterActive();
321
322 });
323
324 })(jQuery);
325
326 function menuToggle() {
327 const toggleMenu = document.querySelector('.easydocs-dropdown');
328 toggleMenu.classList.toggle('is-active');
329 }