1'use strict' 2var PENCI = PENCI || {}; 3( 4 function ($) { 5 $.fn.checked = function (value) { 6 if (value === true || value === false) { 7 // Set the value of the checkbox 8 $(this).each(function () { 9 this.checked = value 10 }) 11 } else if (value === undefined || value === 'toggle') { 12 // Toggle the checkbox 13 $(this).each(function () { 14 this.checked = !this.checked 15 }) 16 } 17 } 18 } 19)(jQuery) 20jQuery(document).ready(function ($) { 21 /* Penci Notify 22---------------------------------------------------------------*/ 23 PENCI.notify = function (title, message, type, img = null) { 24 if (Penci_Bf_Vars.popup && title && message && type) { 25 var $icon = type, 26 img_out = '', 27 bmlink = Penci_Bf_Vars.bookmarkpage ? 28 Penci_Bf_Vars.bookmarkpage : 29 '#' 30 31 if (type === 'added_to_cart') { 32 $icon = false 33 } 34 35 if (img) { 36 img_out = 37 '<a href="' + 38 bmlink + 39 '" class="pencpf-popup-thumb" style="background-image: url(' + 40 img + 41 ')"></a>' 42 } 43 44 $.toast({ 45 heading: '', 46 text: 47 '<div class="pencpf-popup-mess-wrapper">' + 48 img_out + 49 '<div class="pencpf-popup-ct-area"><div class="pencpf-popup-mess-title">' + 50 title + 51 '</div><div class="pencpf-popup-mess"><a href="' + 52 bmlink + 53 '">' + 54 message + 55 '</a></div></div></div>', 56 icon: $icon, 57 position: Penci_Bf_Vars.popup_position, 58 textAlign: 'left', 59 showHideTransition: 'fade', 60 loader: false, 61 hideAfter: Penci_Bf_Vars.popup_timeout, 62 bgColor: Penci_Bf_Vars.popup_bg_cl, 63 textColor: Penci_Bf_Vars.popup_text_cl, 64 }) 65 } 66 } 67 68 PENCI.imported_posts_data = function () { 69 var current_saved_ids = Cookies.get('penci-bf-posts-ids') 70 71 if (!current_saved_ids) { 72 return false 73 } 74 75 if (Penci_Bf_Vars.loginflag == 1) { 76 current_saved_ids = JSON.parse(current_saved_ids) 77 78 current_saved_ids.forEach(function (item) { 79 item = parseInt(item) 80 81 var data = { 82 status: 1, 83 action: 'penci_bl_follow_post', 84 nonce: Penci_Bf_Vars.nonce, 85 postid: item, 86 currentpostid: item, 87 } 88 89 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 90 }).done(function () { 91 Cookies.remove('penci-bf-posts-ids') 92 }) 93 }) 94 } 95 } 96 97 PENCI.imported_authors_data = function () { 98 var current_author_saved_ids = Cookies.get('penci-bf-author-ids') 99 100 if (!current_author_saved_ids) { 101 return false 102 } 103 104 if (Penci_Bf_Vars.loginflag == 1) { 105 current_author_saved_ids = JSON.parse(current_author_saved_ids) 106 current_author_saved_ids.forEach(function (item) { 107 item = parseInt(item) 108 109 var data = { 110 status: 1, 111 action: 'penci_bl_follow_author', 112 nonce: Penci_Bf_Vars.nonce, 113 authorid: item, 114 currentpostid: item, 115 } 116 117 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 118 }).success(function () { 119 Cookies.remove('penci-bf-author-ids') 120 }) 121 }) 122 } 123 } 124 125 PENCI.imported_terms_data = function () { 126 var current_terms_saved_ids = Cookies.get('penci-bf-terms-ids') 127 128 if (!current_terms_saved_ids) { 129 return false 130 } 131 132 if (Penci_Bf_Vars.loginflag == 1) { 133 current_terms_saved_ids = JSON.parse(current_terms_saved_ids) 134 current_terms_saved_ids.forEach(function (item) { 135 item = parseInt(item) 136 137 var data = { 138 status: 1, 139 action: 'penci_bl_follow_terms', 140 nonce: Penci_Bf_Vars.nonce, 141 termid: item, 142 currentpostid: item, 143 } 144 145 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 146 }).success(function () { 147 Cookies.remove('penci-bf-terms-ids') 148 }) 149 }) 150 } 151 } 152 153 PENCI.check_class = function () { 154 $('.penci-bf-follow-post-wrapper').each(function (e) { 155 var parent = $(this).closest('div') 156 if (parent.find('.penci-rv-sm-show').length) { 157 $(this).addClass('has-review') 158 } 159 $(this).show() 160 }) 161 162 $('.penci-rv-sm-show').each(function (e) { 163 var parent = $(this).closest('div') 164 if (parent.find('.penci-bf-follow-post-wrapper').length) { 165 $(this).addClass('has-bookmark') 166 } 167 }) 168 169 $('.penci-bf-follow-author-wrapper .penci-bf-guest-btn'). 170 each(function (e) { 171 var authorid = $(this).attr('data-author-id') 172 var current_saved_ids = Cookies.get('penci-bf-author-ids') 173 $(this).hide() 174 175 $(this). 176 addClass('penci-bf-follow-button'). 177 removeClass('penci-bf-following-button') 178 $(this).attr('data-status', 1) 179 $(this). 180 find('.pencibf-following-text'). 181 html($(this).attr('data-follow-text')) 182 183 if (current_saved_ids) { 184 current_saved_ids = JSON.parse(current_saved_ids) 185 if (jQuery.inArray(authorid, current_saved_ids) !== -1) { 186 $(this). 187 removeClass('penci-bf-follow-button'). 188 addClass('penci-bf-following-button') 189 $(this).attr('data-status', 0) 190 $(this). 191 find('.pencibf-following-text'). 192 html($(this).attr('data-following-text')) 193 } 194 } 195 $(this).show() 196 }) 197 198 $('.penci-bf-follow-post-wrapper .penci-bf-guest-btn'). 199 each(function (e) { 200 var postid = $(this).attr('data-postid') 201 var current_saved_ids = Cookies.get('penci-bf-posts-ids') 202 var follow_wrapper = $(this). 203 parents('.penci-bf-follow-post-wrapper') 204 $(this).hide() 205 if (current_saved_ids) { 206 current_saved_ids = JSON.parse(current_saved_ids) 207 if (jQuery.inArray(postid, current_saved_ids) !== -1) { 208 follow_wrapper.find('button'). 209 removeClass('penci-bf-follow-button'). 210 addClass('penci-bf-following-button') 211 $(this).attr('data-status', 0) 212 follow_wrapper.find('.pencibf-following-text'). 213 html(follow_wrapper.find('button'). 214 attr( 215 'data-following-text')) 216 } 217 } 218 $(this).show() 219 }) 220 221 $('.penci-bf-follow-term-wrapper .penci-bf-guest-btn'). 222 each(function (e) { 223 var postid = $(this).attr('data-term-id') 224 var current_saved_ids = Cookies.get('penci-bf-terms-ids') 225 var follow_wrapper = $(this). 226 parents('.penci-bf-follow-term-wrapper') 227 $(this).hide() 228 if (current_saved_ids) { 229 current_saved_ids = JSON.parse(current_saved_ids) 230 if (jQuery.inArray(postid, current_saved_ids) !== -1) { 231 follow_wrapper.find('button'). 232 removeClass('penci-bf-follow-button'). 233 addClass('penci-bf-following-button') 234 $(this).attr('data-status', 0) 235 } 236 } 237 $(this).show() 238 }) 239 } 240 241 function removeElement(array, elem) { 242 var index = array.indexOf(elem) 243 if (index > -1) { 244 array.splice(index, 1) 245 } 246 } 247 248 // Code used for follow post 249 $(document).on( 250 'click', 251 '.penci-bf-follow-post-wrapper .penci-bf-guest-btn', 252 function (e) { 253 e.preventDefault() 254 255 var status = $(this).attr('data-status') 256 var postid = $(this).attr('data-postid') 257 var follow = $(this).attr('data-follow-text') 258 var ptitle = $(this).attr('data-posttitle') 259 var thumb = $(this).attr('data-thumb') 260 var table_row = $(this).closest('.penci-bf-follow-post-row-body') 261 262 var follow_wrapper = $(this). 263 parents('.penci-bf-follow-post-wrapper') 264 var message_popout 265 266 //show loader 267 follow_wrapper.addClass('loading') 268 var current_saved_ids = Cookies.get('penci-bf-posts-ids') 269 270 if (current_saved_ids) { 271 current_saved_ids = JSON.parse(current_saved_ids) 272 if (status === '1') { 273 current_saved_ids.push(postid) 274 message_popout = Penci_Bf_Vars.popup_success_mess 275 } else { 276 removeElement(current_saved_ids, postid) 277 if (table_row) { 278 table_row.remove() 279 } 280 follow_wrapper.find('.pencibf-following-text').html(follow) 281 message_popout = Penci_Bf_Vars.popup_remove_mess 282 } 283 Cookies.set('penci-bf-posts-ids', 284 JSON.stringify(current_saved_ids)) 285 } else { 286 var current_new_saved_ids = [] 287 current_new_saved_ids.push(postid) 288 message_popout = Penci_Bf_Vars.popup_success_mess 289 Cookies.set( 290 'penci-bf-posts-ids', 291 JSON.stringify(current_new_saved_ids), 292 ) 293 } 294 295 if (status === '1') { 296 $(this). 297 removeClass('penci-bf-follow-button'). 298 addClass('penci-bf-following-button') 299 $(this).attr('data-status', '0') 300 301 $(document). 302 find('.penci-bf-follow-post-wrapper'). 303 each(function () { 304 var all_follow_wrapper = $(this) 305 var all_postid = $(this). 306 find('.penci-bf-button'). 307 attr('data-postid') 308 309 if (all_postid === postid) { 310 all_follow_wrapper.find('.penci-bf-button'). 311 attr('data-status', '0') 312 all_follow_wrapper.find('.penci-bf-button'). 313 removeClass('penci-bf-follow-button'). 314 addClass('penci-bf-following-button') 315 } 316 }) 317 } else { 318 $(this). 319 addClass('penci-bf-follow-button'). 320 removeClass('penci-bf-following-button') 321 $(this).attr('data-status', '1') 322 323 $(document). 324 find('.penci-bf-follow-post-wrapper'). 325 each(function () { 326 var all_follow_wrapper = $(this) 327 var all_postid = $(this). 328 find('.penci-bf-button'). 329 attr('data-postid') 330 331 if (all_postid === postid) { 332 all_follow_wrapper.find('.penci-bf-button'). 333 attr('data-status', '1') 334 all_follow_wrapper.find('.penci-bf-button'). 335 addClass('penci-bf-follow-button'). 336 removeClass('penci-bf-following-button') 337 } 338 }) 339 } 340 341 setTimeout(function () { 342 follow_wrapper.removeClass('loading') 343 344 if (message_popout) { 345 PENCI.notify(ptitle, message_popout, 'success', thumb) 346 } 347 }, 600) 348 }, 349 ) 350 351 // Code used for follow post 352 $(document).on( 353 'click', 354 '.penci-bf-follow-post-wrapper .penci-bf-follow-btn:not(.penci-bf-guest-btn)', 355 function () { 356 var onlyfollowing = $(this). 357 parents('.penci-bf-manage-follow-posts'). 358 data('only-following') 359 var status = $(this).attr('data-status') 360 var postid = $(this).attr('data-postid') 361 var currentpostid = $(this).attr('data-current-postid') 362 var follow = $(this).attr('data-follow-text') 363 var following = $(this).attr('data-following-text') 364 var unfollow = $(this).attr('data-unfollow-text') 365 var ptitle = $(this).attr('data-posttitle') 366 var thumb = $(this).attr('data-thumb') 367 var email = '' 368 var follow_wrapper = $(this). 369 closest('.penci-bf-follow-post-wrapper') 370 371 // trigger follow button click event 372 373 if (status === '1') { 374 follow_wrapper.find('.pencibf-following-text').html(following) 375 } else { 376 follow_wrapper.find('.penci-bf-follow-btn'). 377 addClass('penci-bf-follow-button'). 378 removeClass('penci-bf-following-button') 379 } 380 381 var data = { 382 action: 'penci_bl_follow_post', 383 nonce: Penci_Bf_Vars.nonce, 384 status: status, 385 postid: postid, 386 currentpostid: currentpostid, 387 email: email, 388 onlyfollowing: onlyfollowing, 389 } 390 391 //show loader 392 follow_wrapper.addClass('loading') 393 394 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 395 //hide loader 396 follow_wrapper.removeClass('loading') 397 398 if (response !== 'confirm') { 399 //Check if numeric value 400 401 if (status === '1') { 402 follow_wrapper.find('.pencibf-following-text'). 403 html(following) 404 follow_wrapper.find('.penci-bf-follow-btn'). 405 attr('data-status', '0') 406 follow_wrapper.find('.penci-bf-follow-btn'). 407 removeClass('penci-bf-follow-button'). 408 addClass('penci-bf-following-button') 409 410 PENCI.notify( 411 ptitle, 412 Penci_Bf_Vars.popup_success_mess, 413 'success', 414 thumb, 415 ) 416 417 $(document). 418 find('.penci-bf-follow-btn:not(.penci-bf-guest-btn)'). 419 each(function () { 420 var all_follow_wrapper = $(this).closest( 421 '.penci-bf-follow-post-wrapper', 422 ) 423 var all_postid = $(this).attr('data-postid') 424 425 if (all_postid === postid) { 426 all_follow_wrapper.find('.pencibf-following-text'). 427 html(following) 428 all_follow_wrapper.find('.penci-bf-follow-btn'). 429 attr('data-status', '0') 430 all_follow_wrapper.find('.penci-bf-follow-btn'). 431 removeClass( 432 'penci-bf-follow-button'). 433 addClass( 434 'penci-bf-following-button') 435 } 436 }) 437 } else { 438 if (onlyfollowing === 1) { 439 var newresponse = jQuery(response). 440 filter('.penci-bf-manage-follow-posts'). 441 html() 442 jQuery('.penci-bf-manage-follow-posts').html(newresponse) 443 } else { 444 follow_wrapper.find('.pencibf-following-text').html(follow) 445 follow_wrapper.find('.penci-bf-follow-btn'). 446 attr('data-status', '1') 447 follow_wrapper.find('.penci-bf-follow-btn'). 448 removeClass('penci-bf-following-button'). 449 addClass('penci-bf-follow-button') 450 451 $(document). 452 find('.penci-bf-follow-btn:not(.penci-bf-guest-btn)'). 453 each(function () { 454 var all_follow_wrapper = $(this).closest( 455 '.penci-bf-follow-post-wrapper', 456 ) 457 var all_postid = $(this).attr('data-postid') 458 459 if (all_postid === postid) { 460 all_follow_wrapper.find('.pencibf-following-text'). 461 html(follow) 462 all_follow_wrapper.find('.penci-bf-follow-btn'). 463 attr('data-status', '1') 464 all_follow_wrapper.find('.penci-bf-follow-btn'). 465 removeClass( 466 'penci-bf-following-button'). 467 addClass('penci-bf-follow-button') 468 } 469 }) 470 471 PENCI.notify( 472 ptitle, 473 Penci_Bf_Vars.popup_remove_mess, 474 'success', 475 thumb, 476 ) 477 } 478 } 479 } 480 481 // trigger follow button reload event to reload page from 3rd party plugin 482 var follow_wrapper_obj = { this_object: follow_wrapper } 483 follow_wrapper.trigger('penci-bf-follow-btn-reload', [ 484 follow_wrapper_obj, 485 ]) 486 487 follow_wrapper.find('.penci-bf-follow-btn'). 488 removeClass('penci-bf-unfollow-button'). 489 addClass('penci-bf-follow-button') 490 }) 491 }, 492 ) 493 494 // Code used for follow author popup 495 $(document).on( 496 'click', 497 '.penci-bf-follow-author-wrapper .penci-bf-guest-btn', 498 function (e) { 499 e.preventDefault() 500 501 var follow_wrapper = $(this). 502 closest('.penci-bf-follow-author-wrapper') 503 var status = $(this).attr('data-status') 504 var authorid = $(this).attr('data-author-id') 505 var follow = $(this).attr('data-follow-text') 506 var following = $(this).attr('data-following-text') 507 var thumb = $(this).attr('data-thumb') 508 var current_saved_ids = Cookies.get('penci-bf-author-ids') 509 var table_row = '' 510 var message_popout = '' 511 var ptitle = '' 512
512var follow = $(this).attr('data-follow-text') 513 var following = $(this).attr('data-following-text') 514 var unfollow = $(this).attr('data-unfollow-text') 515 516 follow_wrapper.addClass('loading') 517 518 if (current_saved_ids) { 519 current_saved_ids = JSON.parse(current_saved_ids) 520 if (status === '1') { 521 follow_wrapper.find('.pencibf-following-text').html(following) 522 current_saved_ids.push(authorid) 523 ptitle = Penci_Bf_Vars.popup_success_author_title 524 message_popout = Penci_Bf_Vars.popup_success_author_mess 525 } else { 526 follow_wrapper.find('.pencibf-following-text').html(follow) 527 removeElement(current_saved_ids, authorid) 528 if (table_row) { 529 table_row.remove() 530 } 531 follow_wrapper.find('.pencibf-following-text').html(follow) 532 ptitle = Penci_Bf_Vars.popup_remove_author_title 533 message_popout = Penci_Bf_Vars.popup_remove_author_mess 534 } 535 Cookies.set('penci-bf-author-ids', 536 JSON.stringify(current_saved_ids)) 537 } else { 538 var current_new_saved_ids = [] 539 current_new_saved_ids.push(authorid) 540 Cookies.set( 541 'penci-bf-author-ids', 542 JSON.stringify(current_new_saved_ids), 543 ) 544 } 545 546 if (status === '1') { 547 $(this). 548 removeClass('penci-bf-follow-button'). 549 addClass('penci-bf-following-button') 550 $(this).attr('data-status', '0') 551 ptitle = Penci_Bf_Vars.popup_success_author_title 552 message_popout = Penci_Bf_Vars.popup_success_author_mess 553 follow_wrapper.find('.pencibf-following-text').html(following) 554 } else { 555 $(this). 556 addClass('penci-bf-follow-button'). 557 removeClass('penci-bf-following-button') 558 ptitle = Penci_Bf_Vars.popup_remove_author_title 559 message_popout = Penci_Bf_Vars.popup_remove_author_mess 560 $(this).attr('data-status', '1') 561 follow_wrapper.find('.pencibf-following-text').html(follow) 562 } 563 564 setTimeout(function () { 565 follow_wrapper.removeClass('loading') 566 567 if (message_popout) { 568 PENCI.notify(ptitle, message_popout, 'success', thumb) 569 } 570 }, 600) 571 }, 572 ) 573 574 // Code start for follow Author 575 $(document).on( 576 'click', 577 '.penci-bf-follow-author-wrapper .penci-bf-follow-btn', 578 function (e) { 579 e.preventDefault() 580 581 var onlyfollowing = $(this). 582 parents('.penci-bf-manage-follow-authors'). 583 data('only-following') 584 var status = $(this).attr('data-status') 585 var thumb = $(this).attr('data-thumb') 586 var authorid = $(this).attr('data-author-id') 587 var currentpostid = $(this).attr('data-current-postid') 588 var follow = $(this).attr('data-follow-text') 589 var following = $(this).attr('data-following-text') 590 var unfollow = $(this).attr('data-unfollow-text') 591 var email = '' 592 var message_popout = '' 593 var ptitle = '' 594 595 // trigger follow button click event 596 var follow_button_obj = { 597 popup: true, 598 error: false, 599 this_object: this, 600 } 601 $(this). 602 trigger('penci-bf-follow-author-btn-click', [follow_button_obj]) 603 604 var follow_wrapper = $(this). 605 parents('.penci-bf-follow-author-wrapper') 606 607 if (!follow_button_obj.popup) { 608 return false 609 } 610 611 if (follow_button_obj.error) { 612 return false 613 } 614 615 if (status === '1') { 616 follow_wrapper.find('.pencibf-following-text').html(following) 617 ptitle = Penci_Bf_Vars.popup_success_author_title 618 message_popout = Penci_Bf_Vars.popup_success_author_mess 619 } else { 620 follow_wrapper.find('.penci-bf-follow-btn'). 621 addClass('penci-bf-follow-button'). 622 removeClass('penci-bf-following-button') 623 ptitle = Penci_Bf_Vars.popup_remove_author_title 624 message_popout = Penci_Bf_Vars.popup_remove_author_mess 625 } 626 627 var disable_reload = 628 follow_wrapper.find('.penci-bf-guest-btn'). 629 hasClass('disable-reload') || 630 follow_wrapper.parents('.widget').length > 0 631 632 var data = { 633 action: 'penci_bl_follow_author', 634 nonce: Penci_Bf_Vars.nonce, 635 status: status, 636 authorid: authorid, 637 currentpostid: currentpostid, 638 email: email, 639 onlyfollowing: onlyfollowing, 640 } 641 642 //Check if need disable reload and message on same page 643 if (disable_reload) { 644 data.disable_reload = true 645 } 646 647 //show loader 648 follow_wrapper.addClass('loading') 649 650 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 651 if (response != 'confirm') { 652 if (Penci_Bf_Vars.loginflag == '1') { 653 if (status == '1') { 654 follow_wrapper.find('.pencibf-following-text'). 655 html(following) 656 follow_wrapper.find('.penci-bf-follow-btn'). 657 attr('data-status', '0') 658 follow_wrapper.find('.penci-bf-follow-btn'). 659 removeClass('penci-bf-follow-button'). 660 addClass('penci-bf-following-button') 661 ptitle = Penci_Bf_Vars.popup_success_author_title 662 message_popout = Penci_Bf_Vars.popup_success_author_mess 663 } else { 664 ptitle = Penci_Bf_Vars.popup_remove_author_title 665 message_popout = Penci_Bf_Vars.popup_remove_author_mess 666 667 follow_wrapper.find('.pencibf-following-text').html(follow) 668 follow_wrapper.find('.penci-bf-follow-btn'). 669 attr('data-status', '1') 670 follow_wrapper.find('.penci-bf-follow-btn'). 671 removeClass('penci-bf-following-button'). 672 addClass('penci-bf-follow-button') 673 } 674 } 675 } 676 677 // trigger follow button reload event to reload page from 3rd party plugin 678 var follow_wrapper_obj = { this_object: follow_wrapper } 679 follow_wrapper.trigger('penci-bf-follow-author-btn-reload', [ 680 follow_wrapper_obj, 681 ]) 682 683 follow_wrapper.find('.penci-bf-follow-btn'). 684 removeClass('penci-bf-unfollow-button'). 685 addClass('penci-bf-follow-button') 686 687 follow_wrapper.removeClass('loading') 688 if (message_popout) { 689 PENCI.notify(ptitle, message_popout, 'success', thumb) 690 } 691 }) 692 }, 693 ) 694 695 $(document).on('click', '#penci_bl_unsubscribe_submit', function () { 696 $('.penci-bf-unsubscribe-email-error'). 697 removeClass('message_stack_error'). 698 html(''). 699 hide() 700 $('#penci_bl_unsubscribe_email').removeClass('penci_bl_email_error') 701 $('.message_stack_success').hide() 702 $('.message_stack_error').hide() 703 704 var email = $.trim($('#penci_bl_unsubscribe_email').val()) 705 706 if (email == '') { 707 // Check email is empty 708 $('.penci-bf-unsubscribe-email-error'). 709 addClass('message_stack_error'). 710 html(Penci_Bf_Vars.emailempty). 711 show() 712 $('#penci_bl_unsubscribe_email'). 713 addClass('penci_bl_email_error'). 714 show() 715 return false 716 } else { 717 if (!penci_bl_valid_email(email)) { 718 // Check email is valid or not 719 $('.penci-bf-unsubscribe-email-error'). 720 addClass('message_stack_error').
721 html(Penci_Bf_Vars.emailinvalid). 722 show() 723 $('#penci_bl_unsubscribe_email'). 724 addClass('penci_bl_email_error'). 725 show() 726 return false 727 } 728 } 729 }) 730 731 $(document).on('click', '.penci-pf-ajx-loadmore', function (e) { 732 e.preventDefault() 733 var btn = $(this), 734 nomore = btn.attr('data-nomore'), 735 action_name = 'penci_bl_follow_post_next_page', 736 wrapper = $('.penci-bf-manage-follow-posts .pcsl-inner'), 737 post = true, 738 paged = btn.attr('data-paged') 739 740 if (btn.closest('.penci-bf-follows').hasClass('penci-bf-manage-follow-authors')) { 741 action_name = 'penci_bl_follow_author_next_page'; 742 wrapper = $('.penci-bf-follow-author-table tbody'); 743 post = false; 744 } else if (btn.closest('.penci-bf-follows').hasClass('penci-bf-manage-follow-terms')) { 745 action_name = 'penci_bl_follow_term_next_page'; 746 wrapper = $('.penci-bf-manage-follow-terms .pcsl-inner'); 747 } 748 749 var data = { 750 action: action_name, 751 nonce: Penci_Bf_Vars.nonce, 752 paging: paged, 753 } 754 755 $.ajax({ 756 type: 'POST', 757 dataType: 'html', 758 url: Penci_Bf_Vars.ajaxurl, 759 data: data, 760 beforeSend: function () { 761 btn.addClass('loading-posts') 762 }, 763 success: function (response) { 764 var newresponse 765 766 if (post) { 767 newresponse = $(response).find('.pcsl-inner').html() 768 } else { 769 newresponse = $(response). 770 find('.penci-bf-follow-author-table tbody'). 771 html() 772 } 773 774 btn.addClass('loading-posts') 775 776 if ($(newresponse).length) { 777 wrapper.append(newresponse) 778 btn.attr('data-paged', parseInt(paged) + 1) 779 $(document).trigger('penci_bf_check') 780 } else { 781 btn.html(nomore).addClass('disable') 782 setTimeout(function () { 783 btn.closest('.penci-bf-paging').remove() 784 }, 1200) 785 } 786 btn.removeClass('loading-posts') 787 }, 788 }) 789 }) 790 791 //function for follow author ajax pagination 792 function penci_bl_follow_author_ajax_pagination(pid) { 793 var data = { 794 action: 'penci_bl_follow_author_next_page', 795 nonce: Penci_Bf_Vars.nonce, 796 paging: pid, 797 } 798 799 jQuery('.penci-bf-follow-authors-loader').show() 800 jQuery('.penci-bf-follow-authors-paging').hide() 801 802 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 803 var newresponse = jQuery(response). 804 filter('.penci-bf-manage-follow-authors'). 805 html() 806 jQuery('.penci-bf-follow-authors-loader').hide() 807 jQuery('.penci-bf-manage-follow-authors').html(newresponse) 808 }) 809 return false 810 } 811 812 // Code start for follow term 813 $(document).on( 814 'click', 815 '.penci-bf-follow-term-wrapper .penci-bf-follow-btn:not(.penci-bf-guest-btn)', 816 function () { 817 var onlyfollowing = $(this). 818 parents('.penci-bf-manage-follow-terms'). 819 data('only-following') 820 var status = $(this).attr('data-status') 821 var posttype = $(this).attr('data-posttype') 822 var taxonomyslug = $(this).attr('data-taxonomy-slug') 823 var termid = $(this).attr('data-term-id') 824 var currentpostid = $(this).attr('data-current-postid') 825 var thumb = $(this).attr('data-thumb') 826 827 // trigger follow button click event 828 var follow_button_obj = { popup: true, error: false, this_object: this } 829 $(this). 830 trigger('penci-bf-follow-term-btn-click', [follow_button_obj]) 831 var follow_wrapper = $(this). 832 parents('.penci-bf-follow-term-wrapper') 833 834 if (!follow_button_obj.popup) { 835 return false 836 } 837 838 if (follow_button_obj.error) { 839 return false 840 } 841 842 if (status == '1') { 843 } else { 844 } 845 846 follow_wrapper.addClass('loading') 847 848 var disable_reload = 849 follow_wrapper.find('.penci-bf-guest-btn'). 850 hasClass('disable-reload') || 851 follow_wrapper.parents('.widget').length > 0 852 853 var data = { 854 action: 'penci_bl_follow_terms', 855 status: status, 856 posttype: posttype, 857 taxonomyslug: taxonomyslug, 858 termid: termid, 859 currentpostid: currentpostid, 860 onlyfollowing: onlyfollowing, 861 } 862 863 //Check if need disable reload and message on same page 864 if (disable_reload) { 865 data.disable_reload = true 866 } 867 868 jQuery.post(Penci_Bf_Vars.ajaxurl, data, function (response) { 869 //Check if numeric value 870 871 if (Penci_Bf_Vars.loginflag == '1') { 872 if (status == '1') { 873 follow_wrapper.find('.penci-bf-follow-btn'). 874 attr('data-status', '0') 875 follow_wrapper.find('.penci-bf-follow-btn'). 876 removeClass('penci-bf-follow-button'). 877 addClass('penci-bf-following-button') 878 } else { 879 if (onlyfollowing == 1) { 880 var newresponse = jQuery(response). 881 filter('.penci-bf-manage-follow-terms'). 882 html() 883 jQuery('.penci-bf-manage-follow-terms').html(newresponse) 884 } else { 885 follow_wrapper.find('.penci-bf-follow-btn'). 886 attr('data-status', '1') 887 follow_wrapper.find('.penci-bf-follow-btn'). 888 removeClass('penci-bf-following-button'). 889 addClass('penci-bf-follow-button') 890 } 891 } 892 } else { 893 //make text of following and unfollowing to as it is "Follow" & "Unfollow" 894 895 follow_wrapper.find('.penci-bf-follow-btn'). 896 removeClass('penci-bf-following-button'). 897 addClass('penci-bf-follow-button') 898 899 if (disable_reload) { 900 if (!$.isNumeric(response)) { 901 //show confirm email message to user 902 $('.message_stack_success, .message_stack_error').remove() 903 $( 904 '<div class="message_stack_error">' + response + '<div>', 905 ).insertBefore(follow_wrapper) 906 } else { 907 //show confirm email message to user 908 $('.message_stack_success, .message_stack_error').remove() 909 $( 910 '<div class="message_stack_success">' + 911 Penci_Bf_Vars.follow_success + 912 '<div>', 913 ).insertBefore(follow_wrapper) 914 } 915 916 //Hide popup if exists 917 if (follow_wrapper.find('.penci-bf-popup-close').length > 0) { 918 follow_wrapper.find('.penci-bf-popup-close').click() 919 } 920 } else { 921 var msgs = {} 922 if (!$.isNumeric(response)) { 923 //store confirm email message to cookie 924 msgs = { termid: termid, msgs: response } 925 } else { 926 //store confirm email message to cookie 927 msgs = { termid: termid, msgs: Penci_Bf_Vars.follow_success } 928 } 929 930 Cookies.set('penci-bf-follow-term-msgs', 931 JSON.stringify(msgs)) 932 window.location.reload() 933 } 934 } 935 936 // trigger follow button reload event to reload page from 3rd party plugin 937 var follow_wrapper_obj = { this_object: follow_wrapper } 938 follow_wrapper.trigger('penci-bf-follow-term-btn-reload', [ 939 follow_wrapper_obj, 940 ]) 941 942 follow_wrapper.find('.penci-bf-follow-btn'). 943 removeClass('penci-bf-unfollow-button'). 944 addClass('penci-bf-follow-button') 945 946 follow_wrapper.removeClass('loading') 947 }) 948 }, 949 ) 950 951 $(document).on( 952 'click', 953 '.penci-bf-follow-term-wrapper .penci-bf-guest-btn', 954 function (e) { 955 e.preventDefault() 956 957 var follow_wrapper = $(this). 958 closest('.penci-bf-follow-term-wrapper') 959 var status = $(this).attr('data-status') 960 var posttype = $(this).attr('data-posttype') 961 var taxonomyslug = $(this).attr('data-taxonomy-slug') 962 var termid = $(this).attr('data-term-id') 963 var currentpostid = $(this).attr('data-current-postid') 964 var current_saved_ids = Cookies.get('penci-bf-terms-ids') 965 var ptitle = $(this).attr('data-posttitle') 966 var message_popout 967 var thumb = $(this).attr('data-thumb') 968 var table_row = $(this).closest('.penci-bf-follow-term-row-body') 969 var follow = $(this).attr('data-follow-text') 970 var following = $(this).attr('data-following-text') 971 var unfollow = $(this).attr('data-unfollow-text') 972 973 follow_wrapper.addClass('loading') 974 975 if (current_saved_ids) { 976 current_saved_ids = JSON.parse(current_saved_ids) 977 if (status === '1') { 978 current_saved_ids.push(termid) 979 980 ptitle = Penci_Bf_Vars.popup_success_term_title 981 message_popout = Penci_Bf_Vars.popup_success_term_mess 982 } else { 983 removeElement(current_saved_ids, termid) 984 if (table_row) { 985 table_row.remove() 986 } 987 ptitle = Penci_Bf_Vars.popup_remove_term_title 988 message_popout = Penci_Bf_Vars.popup_remove_term_mess 989 } 990 Cookies.set('penci-bf-terms-ids', 991 JSON.stringify(current_saved_ids)) 992 } else { 993 var current_new_saved_ids = [] 994 current_new_saved_ids.push(termid) 995 Cookies.set( 996 'penci-bf-terms-ids', 997 JSON.stringify(current_new_saved_ids), 998 ) 999 } 1000 1001 if (status === '1') { 1002 1003 $(this). 1004 removeClass('penci-bf-follow-button'). 1005 addClass('penci-bf-following-button') 1006 $(this).attr('data-status', '0') 1007 ptitle = Penci_Bf_Vars.popup_success_term_title 1008 message_popout = Penci_Bf_Vars.popup_success_term_mess 1009 } else { 1010 1011 $(this). 1012 addClass('penci-bf-follow-button'). 1013 removeClass('penci-bf-following-button') 1014 ptitle = Penci_Bf_Vars.popup_remove_term_title 1015 message_popout = Penci_Bf_Vars.popup_remove_term_mess 1016 $(this).attr('data-status', '1') 1017 } 1018 1019 setTimeout(function () { 1020 follow_wrapper.removeClass('loading') 1021 1022 if (message_popout) { 1023 PENCI.notify(ptitle, message_popout, 'success', thumb) 1024 } 1025 }, 600) 1026 }, 1027 ) 1028 1029 // validation of email 1030 function penci_bl_valid_email(emailStr) { 1031 var checkTLD = 1 1032 var knownDomsPat = 1033 /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/ 1034 var emailPat = 1035 /(?:((?:[\w-]+(?:\.[\w-]+)*)@(?:(?:[\w-]+\.)*\w[\w-]{0,66})\.(?:[a-z]{2,6}(?:\.[a-z]{2})?));*)/g 1036 var specialChars = '\\(\\)><@,;:\\\\\\"\\.\\[\\]'
1037 var validChars = '[^\\s' + specialChars + ']' 1038 var quotedUser = '("[^"]*")' 1039 var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ 1040 var atom = validChars + '+' 1041 var word = '(' + atom + '|' + quotedUser + ')' 1042 var userPat = new RegExp('^' + word + '(\\.' + word + ')*$') 1043 var domainPat = new RegExp('^' + atom + '(\\.' + atom + ')*$') 1044 var pattern = 1045 /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/ 1046 var matchArray = emailStr.match(emailPat) 1047 1048 if (matchArray) { 1049 return true 1050 } 1051 1052 if (matchArray == null) { 1053 /* Email address seems incorrect (check @ and .'s) */ 1054 return false 1055 } 1056 1057 var user = matchArray[1] 1058 var domain = matchArray[2] 1059 /* Start by checking that only basic ASCII characters are in the strings (0-127). */ 1060 for (i = 0; i < user.length; i++) { 1061 if (user.charCodeAt(i) > 127) { 1062 /* Ths username contains invalid characters in e-mail address. */ 1063 return false 1064 } 1065 } 1066 for (i = 0; i < domain.length; i++) { 1067 if (domain.charCodeAt(i) > 127) { 1068 /* Ths domain name contains invalid characters in e-mail address. */ 1069 return false 1070 } 1071 } 1072 if (user.match(userPat) == null) { 1073 /* The username doesn't seem to be valid in e-mail address. */ 1074 return false 1075 } 1076 var IPArray = domain.match(ipDomainPat) 1077 if (IPArray != null) { 1078 for (var i = 1; i <= 4; i++) { 1079 if (IPArray[i] > 255) { 1080 /* Destination IP address is invalid! */ 1081 return false 1082 } 1083 } 1084 return true 1085 } 1086 var atomPat = new RegExp('^' + atom + '$') 1087 var domArr = domain.split('.') 1088 var len = domArr.length 1089 for (i = 0; i < len; i++) { 1090 if (domArr[i].search(atomPat) == -1) { 1091 /* The domain name does not seem to be valid in e-mail address. */ 1092 return false 1093 } 1094 } 1095 if ( 1096 checkTLD && 1097 domArr[domArr.length - 1].length != 2 && 1098 domArr[domArr.length - 1].search(knownDomsPat) == -1 1099 ) { 1100 /* The address must end in a well-known domain or two letter country. */ 1101 return false 1102 } 1103 1104 if (len < 2) { 1105 /* This e-mail address is missing a hostname! */ 1106 return false 1107 } 1108 1109 return true 1110 } 1111 1112 PENCI.check_class() 1113 PENCI.imported_posts_data() 1114 PENCI.imported_authors_data() 1115 PENCI.imported_terms_data() 1116 1117 $(document).on('penci_bf_check', function () { 1118 PENCI.check_class() 1119 }) 1120 $('body').on('penci_bf_check', function () { 1121 PENCI.check_class() 1122 }) 1123}) 1124 1125jQuery(window).on('elementor/frontend/init', function () { 1126 if (window.elementorFrontend && window.elementorFrontend.isEditMode()) { 1127 const widgets = [ 1128 'penci-custom-sliders.default', 1129 'penci-big-grid.default', 1130 'penci-small-list.default', 1131 'penci-popular-posts.default', 1132 'penci-featured-cat.default', 1133 'penci-latest-posts.default', 1134 'penci-recent-posts.default', 1135 'penci-featured-sliders.default' 1136 ]; 1137 1138 widgets.forEach(function (widget) { 1139 elementorFrontend.hooks.addAction(`frontend/element_ready/${widget}`, function ($scope) { 1140 jQuery('body').trigger('penci_bf_check'); 1141 }); 1142 }); 1143 } 1144});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.