| 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 |
// CREATE FORUM |
| 170 |
function create_forum() { |
| 171 |
$(document).on('click', '#bbpc-forum', function (e) { |
| 172 |
e.preventDefault(); |
| 173 |
Swal.fire({ |
| 174 |
title: bbp_core_local_object.create_forum_title, |
| 175 |
input: 'text', |
| 176 |
showCancelButton: true, |
| 177 |
inputAttributes: { |
| 178 |
name: 'bbp_forum_title', |
| 179 |
}, |
| 180 |
}).then((result) => { |
| 181 |
if (result.value) { |
| 182 |
$.ajax({ |
| 183 |
url: bbp_core_local_object.ajaxurl, |
| 184 |
type: 'POST', |
| 185 |
data: { |
| 186 |
action: 'bbp_create_forum', |
| 187 |
bbp_forum_title: result.value, |
| 188 |
bbpc_nonce: bbp_core_local_object.nonce |
| 189 |
}, |
| 190 |
beforeSend: function () { |
| 191 |
Swal.fire({ |
| 192 |
title: 'Creating Forum...', |
| 193 |
icon: 'question', |
| 194 |
allowOutsideClick: false, |
| 195 |
showConfirmButton: true, |
| 196 |
didOpen: () => { |
| 197 |
Swal.showLoading(); |
| 198 |
}, |
| 199 |
}); |
| 200 |
}, |
| 201 |
success: function (response) { |
| 202 |
if (response.success) { |
| 203 |
location.reload(); |
| 204 |
} else { |
| 205 |
Swal.fire({ |
| 206 |
title: 'Error!', |
| 207 |
text: response.data, |
| 208 |
icon: 'error', |
| 209 |
}); |
| 210 |
} |
| 211 |
}, |
| 212 |
error: function () { |
| 213 |
Swal.fire({ |
| 214 |
title: 'Error!', |
| 215 |
text: 'Something went wrong. Please try again.', |
| 216 |
icon: 'error', |
| 217 |
}); |
| 218 |
}, |
| 219 |
}); |
| 220 |
} |
| 221 |
}); |
| 222 |
}); |
| 223 |
} |
| 224 |
create_forum(); |
| 225 |
|
| 226 |
// CREATE TOPIC |
| 227 |
function create_topic() { |
| 228 |
$(document).on('click', '#bbpc-topic', function (e) { |
| 229 |
e.preventDefault(); |
| 230 |
let forumID = $(this).attr('bbp_forum_id'); |
| 231 |
Swal.fire({ |
| 232 |
title: bbp_core_local_object.create_topic_title, |
| 233 |
input: 'text', |
| 234 |
showCancelButton: true, |
| 235 |
inputAttributes: { |
| 236 |
name: 'bbp_topic_title', |
| 237 |
}, |
| 238 |
}).then((result) => { |
| 239 |
if (result.value) { |
| 240 |
$.ajax({ |
| 241 |
url: bbp_core_local_object.ajaxurl, |
| 242 |
type: 'POST', |
| 243 |
data: { |
| 244 |
action: 'bbp_create_topic', |
| 245 |
bbp_topic_title: result.value, |
| 246 |
forum_id: forumID, |
| 247 |
bbpc_nonce: bbp_core_local_object.nonce |
| 248 |
}, |
| 249 |
beforeSend: function () { |
| 250 |
Swal.fire({ |
| 251 |
title: 'Creating Topic...', |
| 252 |
icon: 'question', |
| 253 |
allowOutsideClick: false, |
| 254 |
showConfirmButton: true, |
| 255 |
didOpen: () => { |
| 256 |
Swal.showLoading(); |
| 257 |
}, |
| 258 |
}); |
| 259 |
}, |
| 260 |
success: function (response) { |
| 261 |
if (response.success) { |
| 262 |
location.reload(); |
| 263 |
} else { |
| 264 |
Swal.fire({ |
| 265 |
title: 'Error!', |
| 266 |
text: response.data, |
| 267 |
icon: 'error', |
| 268 |
}); |
| 269 |
} |
| 270 |
}, |
| 271 |
error: function () { |
| 272 |
Swal.fire({ |
| 273 |
title: 'Error!', |
| 274 |
text: 'Something went wrong. Please try again.', |
| 275 |
icon: 'error', |
| 276 |
}); |
| 277 |
}, |
| 278 |
}); |
| 279 |
} |
| 280 |
}); |
| 281 |
}); |
| 282 |
} |
| 283 |
create_topic(); |
| 284 |
|
| 285 |
// DELETE FORUM |
| 286 |
function delete_forum() { |
| 287 |
$('.forum-delete').on('click', function (e) { |
| 288 |
e.preventDefault(); |
| 289 |
var forumID = $(this).attr('bbp_forum_id'); |
| 290 |
Swal.fire({ |
| 291 |
title: bbp_core_local_object.forum_delete_title, |
| 292 |
text: bbp_core_local_object.forum_delete_desc, |
| 293 |
icon: 'question', |
| 294 |
showCancelButton: true, |
| 295 |
confirmButtonColor: '#3085d6', |
| 296 |
cancelButtonColor: '#d33', |
| 297 |
confirmButtonText: 'Yes' |
| 298 |
}).then((result) => { |
| 299 |
if (result.value) { |
| 300 |
$.ajax({ |
| 301 |
url: bbp_core_local_object.ajaxurl, |
| 302 |
type: 'POST', |
| 303 |
data: { |
| 304 |
action: 'bbp_delete_forum', |
| 305 |
forum_id: forumID, |
| 306 |
bbpc_nonce: bbp_core_local_object.nonce |
| 307 |
}, |
| 308 |
beforeSend: function () { |
| 309 |
Swal.fire({ |
| 310 |
title: 'Deleting Forum...', |
| 311 |
icon: 'question', |
| 312 |
allowOutsideClick: false, |
| 313 |
showConfirmButton: false, |
| 314 |
didOpen: () => { |
| 315 |
Swal.showLoading(); |
| 316 |
}, |
| 317 |
}); |
| 318 |
}, |
| 319 |
success: function (response) { |
| 320 |
console.log(response); |
| 321 |
if (response.success) { |
| 322 |
location.reload(); |
| 323 |
} else { |
| 324 |
console.log(response) |
| 325 |
Swal.fire({ |
| 326 |
title: 'Error!', |
| 327 |
text: response.data || 'Unexpected error occurred.', |
| 328 |
icon: 'error', |
| 329 |
}); |
| 330 |
} |
| 331 |
}, |
| 332 |
error: function () { |
| 333 |
Swal.fire({ |
| 334 |
title: 'Error!', |
| 335 |
text: 'Something went wrong. Please try again.', |
| 336 |
icon: 'error', |
| 337 |
}); |
| 338 |
}, |
| 339 |
}); |
| 340 |
} |
| 341 |
}); |
| 342 |
}); |
| 343 |
} |
| 344 |
delete_forum(); |
| 345 |
|
| 346 |
|
| 347 |
// DELETE TOPIC |
| 348 |
function delete_topic() { |
| 349 |
$('.section-delete').on('click', function (e) { |
| 350 |
e.preventDefault(); |
| 351 |
var topicID = $(this).attr('bbp_topic_id'); |
| 352 |
Swal.fire({ |
| 353 |
title: bbp_core_local_object.forum_delete_title, |
| 354 |
text: bbp_core_local_object.topic_delete_desc, |
| 355 |
icon: 'question', |
| 356 |
showCancelButton: true, |
| 357 |
confirmButtonColor: '#3085d6', |
| 358 |
cancelButtonColor: '#d33', |
| 359 |
confirmButtonText: 'Yes', |
| 360 |
}).then((result) => { |
| 361 |
if (result.value) { |
| 362 |
$.ajax({ |
| 363 |
url: bbp_core_local_object.ajaxurl, |
| 364 |
type: 'POST', |
| 365 |
data: { |
| 366 |
action: 'bbp_delete_topic', |
| 367 |
topic_id: topicID, |
| 368 |
bbpc_nonce: bbp_core_local_object.nonce |
| 369 |
}, |
| 370 |
beforeSend: function () { |
| 371 |
Swal.fire({ |
| 372 |
title: 'Deleting Topic...', |
| 373 |
icon: 'question', |
| 374 |
allowOutsideClick: false, |
| 375 |
showConfirmButton: false, |
| 376 |
didOpen: () => { |
| 377 |
Swal.showLoading(); |
| 378 |
}, |
| 379 |
}); |
| 380 |
}, |
| 381 |
success: function (response) { |
| 382 |
console.log(response); |
| 383 |
if (response.success) { |
| 384 |
location.reload(); |
| 385 |
} else { |
| 386 |
console.log(response) |
| 387 |
Swal.fire({ |
| 388 |
title: 'Error!', |
| 389 |
text: response.data || 'Unexpected error occurred.', |
| 390 |
icon: 'error', |
| 391 |
}); |
| 392 |
} |
| 393 |
}, |
| 394 |
error: function () { |
| 395 |
Swal.fire({ |
| 396 |
title: 'Error!', |
| 397 |
text: 'Something went wrong. Please try again.', |
| 398 |
icon: 'error', |
| 399 |
}); |
| 400 |
}, |
| 401 |
}); |
| 402 |
} |
| 403 |
}); |
| 404 |
}); |
| 405 |
} |
| 406 |
|
| 407 |
delete_topic(); |
| 408 |
|
| 409 |
// Notification pro alert |
| 410 |
$('.easydocs-notification.bbp-core-pro-notification').on( |
| 411 |
'click', |
| 412 |
function (e) { |
| 413 |
e.preventDefault(); |
| 414 |
let href = $(this).attr('href'); |
| 415 |
let assets = bbp_core_local_object.BBPC_ASSETS; |
| 416 |
Swal.fire({ |
| 417 |
title: 'Notification is a Premium feature', |
| 418 |
html: |
| 419 |
'<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="' + |
| 420 |
assets + |
| 421 |
'/videos/noti.mp4"></video>', |
| 422 |
icon: false, |
| 423 |
buttons: false, |
| 424 |
dangerMode: true, |
| 425 |
showCloseButton: true, |
| 426 |
confirmButtonText: |
| 427 |
'<a href="admin.php?page=bbp-core-pricing">Upgrade to Premium</a>', |
| 428 |
footer: |
| 429 |
'<a href="https://spider-themes.net/bbp-core/" target="_blank"> Learn More </a>', |
| 430 |
customClass: { |
| 431 |
title: 'upgrade-premium-heading', |
| 432 |
confirmButton: 'upgrade-premium-button', |
| 433 |
footer: 'notification-pro-footer-wrap', |
| 434 |
}, |
| 435 |
confirmButtonColor: '#f1bd6c', |
| 436 |
Borderless: true, |
| 437 |
}); |
| 438 |
} |
| 439 |
); |
| 440 |
}); |
| 441 |
|
| 442 |
// Click pending replies count to show pending replies. |
| 443 |
$('[click-target]').click(function () { |
| 444 |
let id = $(this).attr('click-target'); |
| 445 |
$(`[click-target=${id}]`).toggleClass('active'); |
| 446 |
$(`[reply-target=${id}]`).toggle(); |
| 447 |
}); |
| 448 |
|
| 449 |
// Sidebar Tabs [COOKIE] |
| 450 |
$(document).on('click', '[cookie-id]', function () { |
| 451 |
let target = $(this).attr('cookie-id'); |
| 452 |
let item = `[cookie-id=${target}]`; |
| 453 |
$('[cookie-id]').removeClass('is-active mixitup-control-active'); |
| 454 |
$(item).addClass('is-active mixitup-control-active'); |
| 455 |
$(target).fadeIn('slow').siblings('.easydocs-tab').hide(); |
| 456 |
|
| 457 |
let isActiveTab = $(this).hasClass('is-active'); |
| 458 |
if (isActiveTab === true) { |
| 459 |
createCookie('bbpc_current_filter', target, 999); |
| 460 |
} |
| 461 |
|
| 462 |
return true; |
| 463 |
}); |
| 464 |
|
| 465 |
$(document).ready(function () { |
| 466 |
// Keep Last filter item active |
| 467 |
function keepLastFilterActive() { |
| 468 |
let bbpcLastActiveFilter = readCookie('bbpc_current_filter'); |
| 469 |
if (bbpcLastActiveFilter) { |
| 470 |
// Tab item |
| 471 |
$('[cookie-id]').removeClass('is-active mixitup-control-active'); |
| 472 |
$(`[cookie-id="${bbpcLastActiveFilter}"]`).click(); |
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
keepLastFilterActive(); |
| 477 |
|
| 478 |
}); |
| 479 |
|
| 480 |
})(jQuery); |
| 481 |
|
| 482 |
function menuToggle() { |
| 483 |
const toggleMenu = document.querySelector('.easydocs-dropdown'); |
| 484 |
toggleMenu.classList.toggle('is-active'); |
| 485 |
} |