1/* global wpforo */ 2 3$wpf.ajaxSetup({ 4 url: wpforo.ajax_url, 5 data:{ 6 referer: window.location.origin + window.location.pathname 7 } 8}); 9 10function wpforo_post_url_fixer(hash) { 11 var postid = 0; 12 var match = hash.match(/^#post-(\d+)$/); 13 if ( match && (postid = match[1]) ) { 14 if (!$wpf(hash).length && $wpf.active === 0) { 15 $wpf.ajax({ 16 type: 'POST', 17 data: { 18 postid: postid, 19 action: 'wpforo_post_url_fixer', 20 _wpfnonce: wpforo['nonces']['wpforo_post_url_fixer'], 21 } 22 }).done(function (response) { 23 if( /^https?:\/\/[^\r\n\t\s\0'"]+$/.test(response) ){ 24 window.location.assign(response); 25 } 26 }); 27 } 28 } 29} 30 31$wpf(document).ready(function ($) { 32 var wpforo_wrap = $('#wpforo-wrap'); 33 34 //location hash ajax redirect fix 35 setTimeout(function(){ 36 wpforo_post_url_fixer(window.location.hash); 37 }, 500); 38 window.onhashchange = function(){ 39 wpforo_post_url_fixer(window.location.hash); 40 }; 41 42// Reactions 43 wpforo_wrap.on('click', '.wpforo-reaction .wpf-react:not(.wpf-processing)', function(){ 44 var $this = $( this ); 45 var wrap = $this.closest( '.wpf-reaction-wrap' ); 46 var type = $this.data( 'type' ); 47 if( !type.trim() ) type = 'up'; 48 var postid = $this.closest( '[data-postid]' ).data('postid'); 49 50 $this.addClass( 'wpf-processing' ); 51 $.ajax({
52 type: 'POST', 53 data: { 54 postid, 55 type, 56 action: 'wpforo_react', 57 _wpfnonce: wpforo['nonces']['wpforo_react'], 58 } 59 }).done(function( response ){ 60 if( response.success ){ 61 $( '.reacted-users', wrap.closest( '.wpforo-post' ) ).html( response.data['likers'] ); 62 wrap.replaceWith( response.data['like_button'] ); 63 } 64 }).always(function(){ 65 $this.removeClass( 'wpf-processing' ); 66 }); 67 }); 68 69 wpforo_wrap.on('click', '.wpforo-reaction .wpf-unreact:not(.wpf-processing)', function(){ 70 var $this = $( this ); 71 var wrap = $this.closest( '.wpf-reaction-wrap' ); 72 var postid = $this.closest( '[data-postid]' ).data('postid'); 73 74 $this.addClass( 'wpf-processing' ); 75 $.ajax({ 76 type: 'POST', 77 data: { 78 postid, 79 action: 'wpforo_unreact', 80 _wpfnonce: wpforo['nonces']['wpforo_unreact'], 81 } 82 }).done(function( response ){ 83 if( response.success ){ 84 $( '.reacted-users', wrap.closest( '.wpforo-post' ) ).html( response.data['likers'] ); 85 wrap.replaceWith( response.data['like_button'] ); 86 } 87 }).always(function(){ 88 $this.removeClass( 'wpf-processing' ); 89 }); 90 }); 91 92// Like 93 wpforo_wrap.on('click', '.wpforo-like:not(.wpf-processing)', function () { 94 wpforo_load_show(); 95 var postid = $(this).data('postid'), 96 $this = $(this); 97 $this.addClass('wpf-processing'); 98 $.ajax({
99 type: 'POST', 100 url: wpforo.ajax_url, 101 data: { 102 postid: postid, 103 likestatus: 1, 104 action: 'wpforo_like_ajax', 105 _wpfnonce: wpforo['nonces']['wpforo_like_ajax'], 106 } 107 }).done(function (response) { 108 if (response.success) { 109 $this.find('.wpforo-like-ico').removeClass('far').addClass('fas'); 110 $this.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Unlike')); 111 $this.parents('.wpforo-post').find('.reacted-users').html(response.data.likers); 112 $this.removeClass('wpforo-like').addClass('wpforo-unlike'); 113 if( $this.children(".wpf-like-icon").is("[wpf-tooltip]") ) { 114 $this.children(".wpf-like-icon").attr("wpf-tooltip", wpforo_phrase('Unlike') ); 115 }else{ 116 $this.find('.wpforo-like-ico').removeClass('fa-thumbs-up').addClass('fa-thumbs-down'); 117 } 118 $this.children(".wpf-like-count").text(response.data.count); 119 } 120 wpforo_load_hide(); 121 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 122 $this.removeClass('wpf-processing'); 123 }); 124 }); 125// unlike 126 wpforo_wrap.on('click', '.wpforo-unlike:not(.wpf-processing)', function () { 127 wpforo_load_show(); 128 var postid = $(this).data('postid'), 129 $this = $(this); 130 $this.addClass('wpf-processing'); 131 $.ajax({
132 type: 'POST', 133 url: wpforo.ajax_url, 134 data: { 135 postid: postid, 136 likestatus: 0, 137 action: 'wpforo_like_ajax', 138 _wpfnonce: wpforo['nonces']['wpforo_like_ajax'], 139 } 140 }).done(function (response) { 141 if (response.success) { 142 $this.find('.wpforo-like-ico').removeClass('fas').addClass('far'); 143 $this.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Like')); 144 $this.parents('.wpforo-post').find('.reacted-users').html(response.data.likers); 145 $this.removeClass('wpforo-unlike').addClass('wpforo-like'); 146 if( $this.children(".wpf-like-icon").is("[wpf-tooltip]") ) { 147 $this.children(".wpf-like-icon").attr("wpf-tooltip", wpforo_phrase('Like') ); 148 }else{ 149 $this.find('.wpforo-like-ico').removeClass('fa-thumbs-down').addClass('fa-thumbs-up'); 150 } 151 $this.children(".wpf-like-count").text(response.data.count); 152 } 153 wpforo_load_hide(); 154 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 155 $this.removeClass('wpf-processing'); 156 }); 157 }); 158 159 160// Vote 161 wpforo_wrap.on('click', '.wpforo-voteup:not(.wpf-processing)', function () { 162 wpforo_load_show(); 163 var type = $(this).data('type'), 164 postid = $(this).data('postid'), 165 $this = $(this); 166 var buttons = $('.wpforo-voteup, .wpforo-votedown', $this.closest('.wpforo-post-voting')); 167 buttons.addClass('wpf-processing'); 168 var votestatus = ($this.hasClass('wpf-vote-active') ? 'clear' : 'up'); 169 $.ajax({
170 type: 'POST', 171 url: wpforo.ajax_url, 172 data: { 173 itemtype: type, 174 postid, 175 votestatus, 176 action: 'wpforo_vote_ajax', 177 _wpfnonce: wpforo['nonces']['wpforo_vote_ajax'], 178 } 179 }).done(function (response) { 180 if( response.success ) { 181 $this.parents('.post-wrap').find('.wpfvote-num').text(response.data.votes).fadeIn(); 182 var buttons_wrap = $this.closest( '.wpforo-post-voting' ); 183 if( buttons_wrap.length ){ 184 var vote_active_buttons = $( '.wpf-vote-active', buttons_wrap ); 185 if( vote_active_buttons.length ) vote_active_buttons.removeClass('wpf-vote-active'); 186 } 187 if( votestatus !== 'clear' ) $this.addClass('wpf-vote-active'); 188 } 189 wpforo_load_hide(); 190 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 191 buttons.removeClass('wpf-processing'); 192 }); 193 }); 194 195 wpforo_wrap.on('click', '.wpforo-votedown:not(.wpf-processing)', function () { 196 wpforo_load_show(); 197 var type = $(this).data('type'), 198 postid = $(this).data('postid'), 199 $this = $(this); 200 var buttons = $('.wpforo-voteup, .wpforo-votedown', $this.closest('.wpforo-post-voting')); 201 buttons.addClass('wpf-processing'); 202 var votestatus = ($this.hasClass('wpf-vote-active') ? 'clear' : 'down'); 203 $.ajax({
204 type: 'POST', 205 url: wpforo.ajax_url, 206 data: { 207 itemtype: type, 208 postid, 209 votestatus, 210 action: 'wpforo_vote_ajax', 211 _wpfnonce: wpforo['nonces']['wpforo_vote_ajax'], 212 } 213 }).done(function (response) { 214 if( response.success ) { 215 $this.parents('.post-wrap').find('.wpfvote-num').text(response.data.votes).fadeIn(); 216 var buttons_wrap = $this.closest( '.wpforo-post-voting' ); 217 if( buttons_wrap.length ){ 218 var vote_active_buttons = $( '.wpf-vote-active', buttons_wrap ); 219 if( vote_active_buttons.length ) vote_active_buttons.removeClass('wpf-vote-active'); 220 } 221 if( votestatus !== 'clear' ) $this.addClass('wpf-vote-active'); 222 } 223 wpforo_load_hide(); 224 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 225 buttons.removeClass('wpf-processing'); 226 }); 227 }); 228 229 230// Answer 231 wpforo_wrap.on('click', '.wpf-toggle-answer:not(.wpf-processing)', function () { 232 wpforo_load_show(); 233 var postid = $(this).data('postid'), 234 $this = $(this); 235 $this.addClass('wpf-processing'); 236 $.ajax({
237 type: 'POST', 238 url: wpforo.ajax_url, 239 data: { 240 postid: postid, 241 answerstatus: 0, 242 action: 'wpforo_answer_ajax', 243 _wpfnonce: wpforo['nonces']['wpforo_answer_ajax'], 244 } 245 }).done(function (response) { 246 if (response.success) { 247 $this.removeClass('wpf-toggle-answer').addClass('wpf-toggle-not-answer'); 248 setTimeout(function () { 249 window.location.reload(); 250 }, 300); 251 } 252 wpforo_load_hide(); 253 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 254 $this.removeClass('wpf-processing'); 255 }); 256 }); 257 258 wpforo_wrap.on('click', '.wpf-toggle-not-answer:not(.wpf-processing)', function () { 259 wpforo_load_show(); 260 var postid = $(this).data('postid'), 261 $this = $(this); 262 $this.addClass('wpf-processing'); 263 $.ajax({ 264 type: 'POST', 265 url: wpforo.ajax_url, 266 data: { 267 postid: postid, 268 answerstatus: 1, 269 action: 'wpforo_answer_ajax', 270 _wpfnonce: wpforo['nonces']['wpforo_answer_ajax'], 271 } 272 }).done(function (response) { 273 if (response.success) { 274 $this.removeClass('wpf-toggle-not-answer').addClass('wpf-toggle-answer'); 275 setTimeout(function () { 276 window.location.reload(); 277 }, 300); 278 } 279 wpforo_load_hide(); 280 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 281 $this.removeClass('wpf-processing'); 282 }); 283 }); 284 285 286// Quote 287 wpforo_wrap.on('click', '.wpforo-quote:not(.wpf-processing)', function () { 288 wpforo_load_show(); 289 290 var $this = $(this); 291 $this.addClass('wpf-processing'); 292 293 var main_form = $('form.wpforo-main-form[data-textareaid]'); 294 var wrap = main_form.closest('.wpf-form-wrapper'); 295 wrap.show(); 296 297 var post_wrap = $(this).closest('[id^=post-][data-postid]'); 298 var postid = post_wrap.data('postid'); 299 if( !postid ) postid = 0; 300 $(".wpf-form-post-parentid").val( postid ); 301 $.ajax({
302 type: 'POST', 303 url: wpforo.ajax_url, 304 data: { 305 postid: postid, 306 action: 'wpforo_quote_ajax', 307 _wpfnonce: wpforo['nonces']['wpforo_quote_ajax'], 308 } 309 }).done(function (response) { 310 var phrase = wpforo_phrase('Reply with quote'); 311 phrase = phrase.charAt(0).toUpperCase() + phrase.slice(1); 312 $(".wpf-reply-form-title").html(phrase); 313 $(".wpf-form-postid", main_form).val(0); 314 315 wpforo_editor.set_content(response.data); 316 wpforo_load_hide(); 317 $this.removeClass('wpf-processing'); 318 }); 319 }); 320 321// Report 322 wpforo_wrap.on('click', '.wpforo-report', function(){ 323 wpforo_load_show(); 324 var form = $("form#wpforo-report"); 325 $("#wpforo-report-postid", form).val( $(this).data('postid') ); 326 wpforo_dialog_show('', form, '45%', '295px'); 327 $("#wpforo-report-content", form).trigger("focus"); 328 wpforo_load_hide(); 329 }); 330 331 $(document).on('click', '#wpforo-report-send:not(.wpf-processing)', wpforo_report_send); 332 $(document).on('keydown', 'form#wpforo-report', function (e) { 333 if ( (e.ctrlKey || e.metaKey) && ( e.code === 'Enter' || e.code === 'NumpadEnter' ) ) { 334 $('#wpforo-report-send').trigger('click'); 335 } 336 }); 337 338 function wpforo_report_send(){ 339 wpforo_load_show(); 340 var $this = $(this); 341 $this.addClass('wpf-processing'); 342 343 var postid = $('#wpforo-report-postid').val(); 344 var messagecontent = $('#wpforo-report-content').val(); 345 346 $.ajax({
347 type: 'POST', 348 url: wpforo.ajax_url, 349 data: { 350 postid: postid, 351 reportmsg: messagecontent, 352 action: 'wpforo_report_ajax', 353 _wpfnonce: wpforo['nonces']['wpforo_report_ajax'], 354 } 355 }).done(function (response) { 356 wpforo_dialog_hide(); 357 $('#wpforo-report-content').val(''); 358 wpforo_load_hide(); 359 wpforo_notice_show(response.data, (response.success ? 'success' : 'error')); 360 $this.removeClass('wpf-processing'); 361 }); 362 } 363 364// Sticky 365 wpforo_wrap.on('click', '.wpforo-sticky:not(.wpf-processing)', function () { 366 wpforo_load_show(); 367 var topicid = $(this).data('topicid'), 368 $this = $(this); 369 370 $this.addClass('wpf-processing'); 371 372 $.ajax({ 373 type: 'POST', 374 url: wpforo.ajax_url, 375 data: { 376 topicid: topicid, 377 status: 'sticky', 378 action: 'wpforo_sticky_ajax', 379 _wpfnonce: wpforo['nonces']['wpforo_sticky_ajax'], 380 } 381 }).done(function (response) { 382 if (response.success) { 383 $this.find('.wpforo-sticky-txt').text(' ' + wpforo_phrase('Unsticky')); 384 $this.removeClass('wpforo-sticky').addClass('wpforo-unsticky'); 385 if ($this.is("[wpf-tooltip]")) { 386 $this.attr("wpf-tooltip", wpforo_phrase('Unsticky')); 387 } 388 } 389 wpforo_load_hide(); 390 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 391 $this.removeClass('wpf-processing'); 392 }); 393 }); 394 395 396 wpforo_wrap.on('click', '.wpforo-unsticky:not(.wpf-processing)', function () { 397 wpforo_load_show(); 398 var topicid = $(this).data('topicid'), 399 $this = $(this); 400 401 $this.addClass('wpf-processing'); 402 403 $.ajax({
404 type: 'POST', 405 url: wpforo.ajax_url, 406 data: { 407 topicid: topicid, 408 status: 'unsticky', 409 action: 'wpforo_sticky_ajax', 410 _wpfnonce: wpforo['nonces']['wpforo_sticky_ajax'], 411 } 412 }).done(function (response) { 413 if (response.success) { 414 $this.find('.wpforo-sticky-txt').text(' ' + wpforo_phrase('Sticky')); 415 $this.removeClass('wpforo-unsticky').addClass('wpforo-sticky'); 416 if ($this.is("[wpf-tooltip]")) { 417 $this.attr("wpf-tooltip", wpforo_phrase('Sticky')); 418 } 419 } 420 wpforo_load_hide(); 421 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 422 $this.removeClass('wpf-processing'); 423 }); 424 }); 425 426// Approve 427 wpforo_wrap.on('click','.wpforo-approve:not(.wpf-processing)', function(){ 428 wpforo_load_show(); 429 var postid_value = $(this).attr('id'), 430 $this = $(this); 431 var postid = postid_value.replace("wpfapprove", ""); 432 433 $this.addClass('wpf-processing'); 434 435 $.ajax({
436 type: 'POST', 437 url: wpforo.ajax_url, 438 data: { 439 postid: postid, 440 status: 'approve', 441 action: 'wpforo_approve_ajax', 442 _wpfnonce: wpforo['nonces']['wpforo_approve_ajax'], 443 } 444 }).done(function (response) { 445 if (response.success) { 446 $("#" + postid_value).removeClass('wpforo-approve').addClass('wpforo-unapprove'); 447 $("#approveicon" + postid).removeClass('fa-check').addClass('fa-exclamation-circle'); 448 $("#wpforo-wrap #post-" + postid + " .wpf-mod-message").hide(); 449 $("#wpforo-wrap .wpf-status-title").hide(); 450 $("#approvetext" + postid).text(' ' + wpforo_phrase('Unapprove')); 451 if ($this.is("[wpf-tooltip]")) { 452 $this.attr("wpf-tooltip", wpforo_phrase('Unapprove')); 453 } 454 } 455 wpforo_load_hide(); 456 window.location.reload(); 457 $this.removeClass('wpf-processing'); 458 }); 459 }); 460 461// Unapprove 462 wpforo_wrap.on('click','.wpforo-unapprove:not(.wpf-processing)', function(){ 463 wpforo_load_show(); 464 var postid_value = $(this).attr('id'), 465 $this = $(this); 466 var postid = postid_value.replace("wpfapprove", ""); 467 468 $this.addClass('wpf-processing'); 469 470 $.ajax({
471 type: 'POST', 472 url: wpforo.ajax_url, 473 data: { 474 postid: postid, 475 status: 'unapprove', 476 action: 'wpforo_approve_ajax', 477 _wpfnonce: wpforo['nonces']['wpforo_approve_ajax'], 478 } 479 }).done(function (response) { 480 if( response.success ){ 481 $("#" + postid_value).removeClass('wpforo-unapprove').addClass('wpforo-approve'); 482 $("#approveicon" + postid).removeClass('fa-exclamation-circle').addClass('fa-check'); 483 $('#wpforo-wrap #post-' + postid + ' .wpf-mod-message').visible(); 484 $('#wpforo-wrap .wpf-status-title').visible(); 485 $("#approvetext" + postid).text(' ' + wpforo_phrase('Approve')); 486 if ($this.is("[wpf-tooltip]")) { 487 $this.attr("wpf-tooltip", wpforo_phrase('Approve')); 488 } 489 } 490 wpforo_load_hide(); 491 window.location.reload(); 492 $this.removeClass('wpf-processing'); 493 }); 494 }); 495 496 497// Private 498 wpforo_wrap.on('click','.wpforo-private:not(.wpf-processing)', function(){ 499 wpforo_load_show(); 500 var postid_value = $(this).attr('id'), 501 $this = $(this); 502 var topicid = postid_value.replace("wpfprivate", ""); 503 504 $this.addClass('wpf-processing'); 505 506 $.ajax({
507 type: 'POST', 508 url: wpforo.ajax_url, 509 data: { 510 topicid: topicid, 511 status: 'private', 512 action: 'wpforo_private_ajax', 513 _wpfnonce: wpforo['nonces']['wpforo_private_ajax'], 514 } 515 }).done(function (response) { 516 if( response.success ){ 517 $("#" + postid_value).removeClass('wpforo-private').addClass('wpforo-public'); 518 $("#privateicon" + topicid).removeClass('fa-eye-slash').addClass('fa-eye'); 519 $("#privatetext" + topicid).text(' ' + wpforo_phrase('Public')); 520 if ($this.is("[wpf-tooltip]")) { 521 $this.attr("wpf-tooltip", wpforo_phrase('Public')); 522 } 523 } 524 wpforo_load_hide(); 525 $this.removeClass('wpf-processing'); 526 }); 527 }); 528 529 wpforo_wrap.on('click','.wpforo-public:not(.wpf-processing)', function(){ 530 wpforo_load_show(); 531 var postid_value = $(this).attr('id'), 532 $this = $(this); 533 var topicid = postid_value.replace("wpfprivate", ""); 534 535 $this.addClass('wpf-processing'); 536 537 $.ajax({
538 type: 'POST', 539 url: wpforo.ajax_url, 540 data: { 541 topicid: topicid, 542 status: 'public', 543 action: 'wpforo_private_ajax', 544 _wpfnonce: wpforo['nonces']['wpforo_private_ajax'], 545 } 546 }).done(function (response) { 547 if( response.success ){ 548 $("#" + postid_value).removeClass('wpforo-public').addClass('wpforo-private'); 549 $("#privateicon" + topicid).removeClass('fa-eye').addClass('fa-eye-slash'); 550 $("#privatetext" + topicid).text(' ' + wpforo_phrase('Private')); 551 if ($this.is("[wpf-tooltip]")) { 552 $this.attr("wpf-tooltip", wpforo_phrase('Private')); 553 } 554 } 555 wpforo_load_hide(); 556 $this.removeClass('wpf-processing'); 557 }); 558 }); 559 560// Solved 561 wpforo_wrap.on('click','.wpforo-solved:not(.wpf-processing)', function(){ 562 wpforo_load_show(); 563 var postid_value = $(this).attr('id'), 564 $this = $(this); 565 var postid = postid_value.replace("wpfsolved", ""); 566 567 $this.addClass('wpf-processing'); 568 569 $.ajax({
570 type: 'POST', 571 url: wpforo.ajax_url, 572 data: { 573 postid: postid, 574 status: 'solved', 575 action: 'wpforo_solved_ajax', 576 _wpfnonce: wpforo['nonces']['wpforo_solved_ajax'], 577 } 578 }).done(function (response) { 579 if( response.success ) { 580 $("#" + postid_value).removeClass('wpforo-solved').addClass('wpforo-unsolved'); 581 $("#solvedtext" + postid).text(' ' + wpforo_phrase('Unsolved')); 582 if ($this.is("[wpf-tooltip]")) { 583 $this.attr("wpf-tooltip", wpforo_phrase('Unsolved')); 584 } 585 } 586 wpforo_load_hide(); 587 $this.removeClass('wpf-processing'); 588 }); 589 }); 590 591 wpforo_wrap.on('click','.wpforo-unsolved:not(.wpf-processing)', function(){ 592 wpforo_load_show(); 593 var postid_value = $(this).attr('id'), 594 $this = $(this); 595 var postid = postid_value.replace("wpfsolved", ""); 596 597 $this.addClass('wpf-processing'); 598 599 $.ajax({
600 type: 'POST', 601 url: wpforo.ajax_url, 602 data: { 603 postid: postid, 604 status: 'unsolved', 605 action: 'wpforo_solved_ajax', 606 _wpfnonce: wpforo['nonces']['wpforo_solved_ajax'], 607 } 608 }).done(function (response) { 609 if( response.success ){ 610 $("#" + postid_value).removeClass('wpforo-unsolved').addClass('wpforo-solved'); 611 $("#solvedtext" + postid).text(' ' + wpforo_phrase('Solved')); 612 if ($this.is("[wpf-tooltip]")) { 613 $this.attr("wpf-tooltip", wpforo_phrase('Solved')); 614 } 615 } 616 wpforo_load_hide(); 617 $this.removeClass('wpf-processing'); 618 }); 619 }); 620 621 622// Close 623 wpforo_wrap.on('click','.wpforo-close:not(.wpf-processing)', function(){ 624 wpforo_load_show(); 625 var postid_value = $(this).attr('id'), 626 $this = $(this); 627 var topicid = postid_value.replace("wpfclose", ""); 628 629 $this.addClass('wpf-processing'); 630 631 $.ajax({
632 type: 'POST', 633 url: wpforo.ajax_url, 634 data: { 635 topicid: topicid, 636 status: 'close', 637 action: 'wpforo_close_ajax', 638 _wpfnonce: wpforo['nonces']['wpforo_close_ajax'], 639 } 640 }).done(function (response) { 641 if( response.success ){ 642 $("#" + postid_value).removeClass('wpforo-close').addClass('wpforo-open'); 643 $("#closeicon" + topicid).removeClass('fa-lock').addClass('fa-unlock'); 644 $("#closetext" + topicid).text(' ' + wpforo_phrase('Open')); 645 if ($this.is("[wpf-tooltip]")) { 646 $this.attr("wpf-tooltip", wpforo_phrase('Open')); 647 } 648 $(".wpf-form-wrapper").remove(); 649 $(".wpforo-reply").remove(); 650 $(".wpforo-quote").remove(); 651 $(".wpforo-edit").remove(); 652 $(".wpf-answer-button").remove(); 653 $(".wpf-add-comment-button").remove(); 654 } 655 wpforo_load_hide(); 656 $this.removeClass('wpf-processing'); 657 }); 658 }); 659 660 wpforo_wrap.on('click','.wpforo-open:not(.wpf-processing)', function(){ 661 wpforo_load_show(); 662 var postid_value = $(this).attr('id'), 663 $this = $(this); 664 var topicid = postid_value.replace("wpfclose", ""); 665 666 $this.addClass('wpf-processing'); 667 668 $.ajax({
669 type: 'POST', 670 url: wpforo.ajax_url, 671 data: { 672 topicid: topicid, 673 status: 'closed', 674 action: 'wpforo_close_ajax', 675 _wpfnonce: wpforo['nonces']['wpforo_close_ajax'], 676 } 677 }).done(function (response) { 678 if( response.success ){ 679 if ($this.is("[wpf-tooltip]")) { 680 $this.attr("wpf-tooltip", wpforo_phrase('Close')); 681 } 682 window.location.reload(); 683 } 684 wpforo_load_hide(); 685 $this.removeClass('wpf-processing'); 686 }); 687 }); 688 689 // Edit post 690 wpforo_wrap.on('click','.wpforo-edit:not(.wpf-processing)', function(){ 691 var $this = $(this); 692 var wrap = $(this).closest('[id^=post-][data-postid]'); 693 if( wrap.length ){ 694 $this.addClass('wpf-processing'); 695 var children = wrap.contents().not(":hidden"); 696 var loading = $('<div class="wpforo-loading-portable"><i class="fas fa-3x fa-circle-notch fa-spin"></i></div>'); 697 wrap.append(loading); 698 699 var show_form = function(form, init){ 700 loading.remove(); 701 children.fadeOut('fast'); 702 var f = $(form); 703 f.on('click', '.wpf-edit-post-cancel', function(e){ 704 e.stopPropagation(); 705 e.preventDefault(); 706 f.fadeOut('fast'); 707 children.fadeIn('slow'); 708 wpforo_editor.set_active( wpforo_editor.get_main() ); 709 $('html').scrollTop( (wrap.offset().top - 80) ); 710 }); 711 if( init ){ 712 f.appendTo(wrap); 713 wpforo_trigger_custom_event(document, 'wpforo_topic_portable_form', f); 714 } 715 f.fadeIn('slow'); 716 $('html').scrollTop( (wrap.offset().top - 80) ); 717 $this.removeClass('wpf-processing'); 718 } 719 720 var f = $('.wpf-form-wrapper', wrap); 721 if( f.length ){ 722 show_form(f); 723 }else{ 724 $.ajax({
725 type: 'POST', 726 url: wpforo.ajax_url, 727 data: { 728 postid: parseInt(wrap.data('postid')), 729 action: 'wpforo_post_edit', 730 _wpfnonce: wpforo['nonces']['wpforo_post_edit'], 731 } 732 }).done(function(response){ 733 if( response.success ) show_form(response.data.html, true); 734 }); 735 } 736 } 737 }); 738 739// Delete 740 wpforo_wrap.on('click', '.wpforo-delete:not(.wpf-processing)', function(){ 741 if( confirm(wpforo_ucwords( wpforo_phrase('are you sure you want to delete?') )) ){ 742 wpforo_load_show(); 743 var $this = $(this); 744 $this.addClass('wpf-processing'); 745 746 var postid_value = $(this).attr('id'); 747 var is_topic = postid_value.indexOf("topic"); 748 749 var postid, status_value; 750 if(is_topic === -1){ 751 postid = postid_value.replace("wpfreplydelete", ""); 752 status_value = 'reply'; 753 }else{ 754 postid = postid_value.replace("wpftopicdelete", ""); 755 status_value = 'topic'; 756 } 757 758 var forumid = 0; 759 var wpf_forumid = $("input[type='hidden'].wpf-form-forumid"); 760 if( wpf_forumid.length ) forumid = wpf_forumid.val(); 761 762 $.ajax({
763 type: 'POST', 764 url: wpforo.ajax_url, 765 data:{ 766 forumid: forumid, 767 postid: postid, 768 status: status_value, 769 action: 'wpforo_delete_ajax', 770 _wpfnonce: wpforo['nonces']['wpforo_delete_ajax'], 771 } 772 }).done(function(response){ 773 if( response.success ){ 774 if(is_topic === -1){ 775 var to_be_removed = $('#post-' + response.data.postid); 776 if( to_be_removed.hasClass('wpf-answer-wrap') ){ 777 var qa_item_wrap = to_be_removed.parents('.wpforo-qa-item-wrap'); 778 if( qa_item_wrap.length ) to_be_removed = qa_item_wrap; 779 } 780 to_be_removed.remove().delay(200); 781 $('#wpf-post-replies-'+response.data.postid).remove().delay(100); 782 $('#wpf-ttgg-'+response.data.root+' .wpf-post-replies-count').text( response.data.root_count ); 783 }else{ 784 window.location.assign(response.data.location); 785 } 786 } 787 wpforo_load_hide(); 788 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 789 $this.removeClass('wpf-processing'); 790 }); 791 } 792 }); 793 794 795// Subscribe 796 wpforo_wrap.on('click','.wpf-subscribe-forum:not(.wpf-processing), .wpf-subscribe-topic:not(.wpf-processing), .wpf-subscribe-user:not(.wpf-processing)', function(){ 797 wpforo_load_show(); 798 799 var $this = $(this); 800 $this.addClass('wpf-processing'); 801 802 var type = $this.data('type'); 803 var itemid = $this.data('itemid'); 804 805 $.ajax({
806 type: 'POST', 807 url: wpforo.ajax_url, 808 data: { 809 itemid, 810 type, 811 status: 'subscribe', 812 action: 'wpforo_subscribe_ajax', 813 _wpfnonce: wpforo['nonces']['wpforo_subscribe_ajax'], 814 } 815 }).done(function (response) { 816 if( response.success ){ 817 $this.removeClass('wpfcl-5').removeClass('wpf-subscribe-' + type).addClass('wpf-unsubscribe-' + type).text(' ' + wpforo_phrase('Unsubscribe')); 818 } 819 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 820 }).always(function(){ 821 wpforo_load_hide(); 822 $this.removeClass('wpf-processing'); 823 }); 824 }); 825 826 wpforo_wrap.on('click','.wpf-unsubscribe-forum:not(.wpf-processing), .wpf-unsubscribe-topic:not(.wpf-processing), .wpf-unsubscribe-user:not(.wpf-processing)', function(){ 827 wpforo_load_show(); 828 829 var $this = $(this); 830 $this.addClass('wpf-processing'); 831 832 var type = $this.data('type'); 833 var itemid = $this.data('itemid'); 834 var button_phrase = ''; 835 if( type === 'forum' ){ 836 button_phrase = wpforo_ucwords( wpforo_phrase('Subscribe for new topics') ); 837 }else if( type === 'topic' ){ 838 button_phrase = wpforo_ucwords( wpforo_phrase('Subscribe for new replies') ); 839 }else if( type === 'user' ){ 840 button_phrase = wpforo_ucwords( wpforo_phrase('Subscribe for new posts') ); 841 } 842 $.ajax({
843 type: 'POST', 844 url: wpforo.ajax_url, 845 data: { 846 itemid, 847 type, 848 status: 'unsubscribe', 849 action: 'wpforo_subscribe_ajax', 850 _wpfnonce: wpforo['nonces']['wpforo_subscribe_ajax'], 851 } 852 }).done(function (response) { 853 if( response.success ){ 854 $this.removeClass('wpf-unsubscribe-' + type).addClass('wpf-subscribe-' + type).addClass('wpfcl-5').text(' ' + button_phrase); 855 } 856 wpforo_notice_show(response.data.notice, (response.success ? 'success' : 'error')); 857 }).always(function(){ 858 wpforo_load_hide(); 859 $this.removeClass('wpf-processing'); 860 }); 861 }); 862 863 wpforo_wrap.on('change', '.wpf-topic-form-forumid', function () { 864 var $this = $(this); 865 var form_wrap = $this.closest('.wpf-topic-form-extra-wrap'); 866 var form_ajax_wrap = $('.wpf-topic-form-ajax-wrap', form_wrap); 867 var l = $('<i class="fas fa-spinner fa-spin wpf-icon-spinner"></i>'); 868 form_ajax_wrap.empty(); 869 l.appendTo(form_ajax_wrap); 870 $this.attr('disabled', true); 871 $('.wpf-topic-form-no-selected-forum', form_wrap).hide(); 872 873 var forumid = parseInt( $this.val() ); 874 if( forumid ){ 875 $.ajax({
876 type: 'POST', 877 data: { 878 forumid: forumid, 879 action: 'wpforo_topic_portable_form', 880 _wpfnonce: wpforo['nonces']['wpforo_topic_portable_form'], 881 } 882 }).done(function (response) { 883 l.remove(); 884 if( response.success ){ 885 var f = $(response.data); 886 form_ajax_wrap.empty(); 887 f.appendTo(form_ajax_wrap); 888 f.fadeIn('slow'); 889 wpforo_trigger_custom_event(document, 'wpforo_topic_portable_form', f); 890 } 891 $this.attr('disabled', false); 892 }) 893 } 894 }); 895 896 wpforo_wrap.on('click', '.wpforo-tools', function () { 897 var tools = $('#wpf_moderation_tools'); 898 if( tools.is(':visible') ){ 899 tools.slideUp(250, 'linear'); 900 }else{ 901 wpforo_load_show(); 902 tools.find('.wpf-tool-tabs .wpf-tool-tab').removeClass('wpf-tt-active'); 903 tools.find('.wpf-tool-tabs .wpf-tool-tab:first-child').addClass('wpf-tt-active'); 904 wpforo_topic_tools_tab_load(); 905 } 906 }); 907 908 wpforo_wrap.on('click', '#wpf_moderation_tools .wpf-tool-tabs .wpf-tool-tab:not(.wpf-tt-active)', function () { 909 wpforo_notice_hide(); 910 $(this).siblings('.wpf-tool-tab').removeClass('wpf-tt-active'); 911 if( !$(this).hasClass('wpf-tt-active') ) $(this).addClass('wpf-tt-active'); 912 wpforo_topic_tools_tab_load(); 913 }); 914 915 wpforo_topic_tools_tab_load(); 916 917 wpforo_wrap.on('click', 'div.wpfl-4:not(.wpf-processing) .wpf-load-threads a.wpf-threads-filter', function () { 918 var wrap = $(this).parents('div.wpfl-4'); 919 var topics_list = $('.wpf-thread-list', wrap); 920 topics_list.data('paged', 0); 921 topics_list.data('filter', $(this).data('filter')); 922 $('.wpf-more-topics > a', wrap).trigger("click"); 923 $(this).siblings('a.wpf-threads-filter').removeClass('wpf-active'); 924 $(this).addClass('wpf-active'); 925 }); 926 927 wpforo_wrap.on('click', 'div.wpfl-4:not(.wpf-processing) .wpf-more-topics > a', function () { 928 var $this = $(this); 929 var wrap = $this.parents('div.wpfl-4'); 930 wrap.addClass('wpf-processing'); 931 var topics_list = $('.wpf-thread-list', wrap); 932 var filter = topics_list.data('filter'); 933 var forumid = topics_list.data('forumid'); 934 var paged = topics_list.data('paged'); 935 var append = paged !== 0; 936 topics_list.data('paged', ++paged); 937 938 var load_msg = wpforo_phrase('Loading Topics'); 939 940 wpforo_load_show(load_msg); 941 942 var i = $('.wpf-load-threads a.wpf-threads-filter[data-filter="' + filter + '"] i', wrap); 943 var i_class = i.attr('class'); 944 var i_spin_class = 'fas fa-circle-notch fa-spin'; 945 var i_toggle_class = i_class + ' ' + i_spin_class; 946 947 var i2 = $('i', $this); 948 var i2_class = i2.attr('class'); 949 var i2_toggle_class = i2_class + ' ' + i_spin_class; 950 951 wpforo_notice_hide(); 952 953 i.toggleClass(i_toggle_class); 954 if(append) i2.toggleClass(i2_toggle_class); 955 956 $.ajax({
957 type: 'POST', 958 data: { 959 forumid: forumid, 960 filter: filter, 961 paged: paged, 962 action: 'wpforo_layout4_loadmore', 963 _wpfnonce: wpforo['nonces']['wpforo_layout4_loadmore'], 964 } 965 }).done(function (response) { 966 if (response.success) { 967 if (append) { 968 topics_list.append(response.data.output_html); 969 } else { 970 topics_list.html(response.data.output_html); 971 $this.show(); 972 } 973 } else { 974 if (!append) { 975 topics_list.html('<span class="wpf-no-thread">' + wpforo_phrase('No threads found') + '</span>'); 976 } 977 } 978 979 if (response.data.no_more) { 980 $this.hide(); 981 } 982 983 i.toggleClass(i_toggle_class); 984 if (append) i2.toggleClass(i2_toggle_class); 985 wpforo_load_hide(); 986 wrap.removeClass('wpf-processing'); 987 }); 988 }); 989 990 wpforo_wrap.on('click', '.wpforo-qa-show-rest-comments:not(.wpf-processing)', function () { 991 wpforo_load_show(); 992 var $this = $(this); 993 $this.addClass('wpf-processing'); 994 var wrap = $this.parents('.wpforo-qa-item-wrap'); 995 var root_wrap = wrap.children('.post-wrap'); 996 var comments_list = $('.wpforo-qa-comments', wrap); 997 var parentid = root_wrap.data('postid'); 998 $.ajax({
999 type: 'POST', 1000 data: { 1001 parentid: parentid, 1002 action: 'wpforo_qa_comment_loadrest', 1003 _wpfnonce: wpforo['nonces']['wpforo_qa_comment_loadrest'], 1004 } 1005 }).done(function (response) { 1006 if (response.success) { 1007 comments_list.append(response.data['output_html']); 1008 $this.remove(); 1009 wpforo_load_hide(); 1010 } 1011 $this.removeClass('wpf-processing'); 1012 }); 1013 }); 1014 1015 wpforo_wrap.on('click', 'form[data-textareaid] .wpforo_post_preview:not(.wpf-disabled):not(.wpf-processing)', function(){ 1016 var $this = $(this); 1017 var ico = $('.wpf-rev-preview-ico', $this); 1018 var form = $this.closest('form[data-textareaid]'); 1019 1020 //$('.wpforo_save_revision', form).trigger("click"); 1021 1022 var textareaid = form.data('textareaid'); 1023 var postid = $( 'input.wpf-form-postid', form ).val(); 1024 var body = wpforo_editor.get_content('raw'); 1025 var body_info = wpforo_editor.get_stats(); 1026 1027 if( textareaid && body_info.has_content){ 1028 $this.addClass('wpf-processing'); 1029 wpforo_load_show(); 1030 ico.toggleClass('fa-eye fa-circle-notch fa-spin'); 1031 $.ajax({
1032 type: 'POST', 1033 data: { 1034 textareaid: textareaid, 1035 postid: postid, 1036 body: body, 1037 action: 'wpforo_post_preview', 1038 _wpfnonce: wpforo['nonces']['wpforo_post_preview'], 1039 } 1040 }).done(function (response) { 1041 if( response.success ) { 1042 $('.wpforo-revisions-action-buttons .wpforo-revision-action-button', form).removeClass('wpf-rev-button-active'); 1043 $this.addClass('wpf-rev-button-active'); 1044 $('.wpforo-revisions-preview-wrap', form).html(response.data); 1045 } 1046 }).always(function(){ 1047 wpforo_load_hide(); 1048 ico.toggleClass('fa-eye fa-circle-notch fa-spin'); 1049 $this.removeClass('wpf-processing'); 1050 }); 1051 } 1052 1053 }); 1054 1055 wpforo_wrap.on('click', 'form[data-textareaid] .wpforo_save_revision:not(.wpf-processing)', function () { 1056 var $this = $(this); 1057 if( $this.is(':visible') ){ 1058 var ico = $('.wpf-rev-save-ico', $this); 1059 var form = $this.closest('form[data-textareaid]'); 1060 var textareaid = form.data('textareaid'); 1061 var postid = $( 'input.wpf-form-postid', form ).val(); 1062 var body = wpforo_editor.get_content('raw'); 1063 var body_info = wpforo_editor.get_stats(); 1064 if( textareaid && body_info.has_content ){ 1065 $this.addClass('wpf-processing'); 1066 wpforo_load_show('Saving Draft'); 1067 ico.toggleClass('fa-save fa-circle-notch fa-spin'); 1068 $.ajax({
1069 type: 'POST', 1070 data: { 1071 textareaid: textareaid, 1072 postid: postid, 1073 body: body, 1074 action: 'wpforo_save_revision', 1075 _wpfnonce: wpforo['nonces']['wpforo_save_revision'], 1076 } 1077 }).done(function (response) { 1078 if( response.success ) { 1079 wpforo_deactivate_revision_action_buttons(form); 1080 $('.wpf-rev-history-count', form).text(response.data.revisions_count); 1081 if( response.data.revisionhtml && $('.wpforo_revisions_history', form).hasClass('wpf-rev-button-active') ){ 1082 var revisions_preview_wrap = $('.wpforo-revisions-preview-wrap', form); 1083 revisions_preview_wrap.prepend(response.data.revisionhtml); 1084 var wpforo_revision = $('.wpforo-revision', revisions_preview_wrap); 1085 if( wpforo_revision.length >= wpforo.revision_options.max_drafts_per_page ){ 1086 wpforo_revision.each(function (i) { 1087 if( i >= wpforo.revision_options.max_drafts_per_page ) $(this).remove(); 1088 }); 1089 } 1090 } 1091 } 1092 }).always(function(){ 1093 wpforo_load_hide(); 1094 ico.toggleClass('fa-save fa-circle-notch fa-spin'); 1095 $this.removeClass('wpf-processing'); 1096 }); 1097 } 1098 } 1099 }); 1100 1101 wpforo_wrap.on('click', 'form[data-textareaid] .wpforo_revisions_history:not(.wpf-processing)', function(){ 1102 var $this = $(this); 1103 var ico = $('.wpf-rev-ico', $this); 1104 var form = $this.closest('form[data-textareaid]'); 1105 var textareaid = form.data('textareaid'); 1106 var postid = $( 'input.wpf-form-postid', form ).val(); 1107 1108 if( textareaid ){ 1109 $this.addClass('wpf-processing'); 1110 wpforo_load_show(); 1111 ico.toggleClass('fa-history fa-circle-notch fa-spin'); 1112 $.ajax({
1113 type: 'POST', 1114 data: { 1115 textareaid: textareaid, 1116 postid: postid, 1117 action: 'wpforo_get_revisions_history', 1118 _wpfnonce: wpforo['nonces']['wpforo_get_revisions_history'], 1119 } 1120 }).done(function (response) { 1121 if( response.success ) { 1122 $('.wpf-rev-history-count', form).text(response.data.revisions_count); 1123 $('.wpforo-revisions-action-buttons .wpforo-revision-action-button', form).removeClass('wpf-rev-button-active'); 1124 $this.addClass('wpf-rev-button-active'); 1125 $('.wpforo-revisions-preview-wrap', form).html(response.data.revisionhtml); 1126 } 1127 }).always(function(){ 1128 wpforo_load_hide(); 1129 ico.toggleClass('fa-history fa-circle-notch fa-spin'); 1130 $this.removeClass('wpf-processing'); 1131 }); 1132 } 1133 }); 1134 1135 wpforo_wrap.on('click', 'form[data-textareaid] .wpforo-revision-action-restore:not(.wpf-processing)', function(){ 1136 var $this = $(this); 1137 var ico = $('.wpf-rev-ico', $this); 1138 var form = $this.closest('form[data-textareaid]'); 1139 var rev_wrap = $this.closest('.wpforo-revision[data-revisionid]'); 1140 if( rev_wrap.length ){ 1141 $this.addClass('wpf-processing'); 1142 wpforo_load_show('Restore Revision'); 1143 ico.toggleClass('fa-history fa-circle-notch fa-spin'); 1144 var revisionid = rev_wrap.data('revisionid'); 1145 $.ajax({
1146 type: 'POST', 1147 data: { 1148 revisionid: revisionid, 1149 action: 'wpforo_get_revision', 1150 _wpfnonce: wpforo['nonces']['wpforo_get_revision'], 1151 } 1152 }).done(function (response) { 1153 if( response.success ){ 1154 wpforo_editor.set_content(response.data.body); 1155 } 1156 }).always(function(){ 1157 wpforo_load_hide(); 1158 ico.toggleClass('fa-history fa-circle-notch fa-spin'); 1159 $this.removeClass('wpf-processing'); 1160 }); 1161 } 1162 }); 1163 1164 wpforo_wrap.on('click', 'form[data-textareaid] .wpforo-revision-action-delete:not(.wpf-processing)', function(){ 1165 var $this = $(this); 1166 var ico = $('.wpf-rev-ico', $this); 1167 var form = $this.closest('form[data-textareaid]'); 1168 var rev_wrap = $this.closest('.wpforo-revision[data-revisionid]'); 1169 if( rev_wrap.length ){ 1170 $this.addClass('wpf-processing'); 1171 wpforo_load_show('Deleting Revision'); 1172 ico.toggleClass('fa-trash fa-circle-notch fa-spin'); 1173 var revisionid = rev_wrap.data('revisionid'); 1174 $.ajax({
1175 type: 'POST', 1176 data: { 1177 revisionid: revisionid, 1178 action: 'wpforo_delete_revision', 1179 _wpfnonce: wpforo['nonces']['wpforo_delete_revision'], 1180 } 1181 }).done(function (response) { 1182 if( response.success ){ 1183 rev_wrap.fadeOut(500, function(){ 1184 rev_wrap.remove(); 1185 $('.wpf-rev-history-count', form).text(response.data.revisions_count); 1186 }); 1187 } 1188 }).always(function(){ 1189 wpforo_load_hide(); 1190 ico.toggleClass('fa-trash fa-circle-notch fa-spin'); 1191 $this.removeClass('wpf-processing'); 1192 }); 1193 } 1194 }); 1195 1196 wpforo_wrap.on('click', '.wpforo-user-actions .wpf-ab-mute_mention:not(.wpf-processing)', function(){ 1197 var $this = $(this); 1198 var currentstate = parseInt( $this.data('currentstate') ); 1199 if( isNaN( currentstate ) ) currentstate = 0; 1200 $this.addClass('wpf-processing'); 1201 wpforo_load_show(); 1202 $.ajax({
1203 type: 'POST', 1204 data: { 1205 currentstate, 1206 action: 'wpforo_mute_mentions', 1207 _wpfnonce: wpforo['nonces']['wpforo_mute_mentions'], 1208 } 1209 }).done(function (response) { 1210 if (response.success) { 1211 $( '> i', $this ).replaceWith(response.data['ico']); 1212 wpforo_setAttr( $this, 'data-currentstate', response.data['currentstate'] ); 1213 var label = $this.data( ( response.data['currentstate'] ? 'active_label' : 'inactive_label' ) ) 1214 wpforo_setAttr( $this, 'wpf-tooltip', label ); 1215 } 1216 }).always(function(){ 1217 wpforo_load_hide(); 1218 $this.removeClass('wpf-processing'); 1219 }); 1220 }); 1221 1222 wpforo_wrap.on('click', '.wpforo-user-actions .wpf-ab-ban:not(.wpf-processing)', function(){ 1223 var $this = $(this); 1224 var currentstate = parseInt( $this.data('currentstate') ); 1225 if( isNaN( currentstate ) ) currentstate = 1; 1226 $this.addClass('wpf-processing'); 1227 wpforo_load_show(); 1228 $.ajax({
1229 type: 'POST', 1230 data: { 1231 currentstate, 1232 action: 'wpforo_user_ban', 1233 _wpfnonce: wpforo['nonces']['wpforo_user_ban'], 1234 } 1235 }).done(function(response){ 1236 if (response.success) { 1237 wpforo_setAttr( $this, 'data-currentstate', response.data['currentstate'] ); 1238 var label = $this.data( ( response.data['currentstate'] ? 'active_label' : 'inactive_label' ) ) 1239 wpforo_setAttr( $this, 'wpf-tooltip', label ); 1240 } 1241 wpforo_notice_show( response.data['notice'] ); 1242 }).always(function(){ 1243 wpforo_load_hide(); 1244 $this.removeClass('wpf-processing'); 1245 }); 1246 }); 1247 1248 function wpforo_activate_revision_action_buttons(form){ 1249 var rev_saved = $('.wpforo_revision_saved', form); 1250 if( rev_saved.is(':visible') ){ 1251 rev_saved.fadeOut(1000, function(){ 1252 var save_revision = $('.wpforo_save_revision', form); 1253 save_revision.show(); 1254 1255 if( wpforo.revision_options.is_draft_on && parseInt(wpforo.revision_options.auto_draft_interval) && !save_revision.data('auto_draft') ){ 1256 setInterval(function(){ 1257 save_revision.trigger("click"); 1258 }, wpforo.revision_options.auto_draft_interval); 1259 save_revision.data('auto_draft', true); 1260 } 1261 }); 1262 } 1263 } 1264 1265 function wpforo_deactivate_revision_action_buttons(form){ 1266 $('.wpforo_revision_saved', form).show(); 1267 $('.wpforo_save_revision', form).hide(); 1268 } 1269 1270 function wpforo_content_changed(){ 1271 var form = $('form[data-textareaid="'+ wpforo_editor.get_active_textareaid() +'"]'); 1272 if( wpforo_editor.get_stats().has_content ){ 1273 wpforo_activate_revision_action_buttons(form); 1274 $('.wpforo_post_preview', form).removeClass('wpf-disabled'); 1275 }else{ 1276 wpforo_deactivate_revision_action_buttons(form); 1277 $('.wpforo_post_preview', form).addClass('wpf-disabled'); 1278 } 1279 } 1280 1281 function wpforo_content_ctrl_s(){ 1282 $('form[data-textareaid="'+ wpforo_editor.get_active_textareaid() +'"] .wpforo_save_revision').trigger("click"); 1283 } 1284 1285 wpforo_wrap.on('change input propertychange', 'form[data-textareaid] textarea', function (e) { 1286 wpforo_trigger_custom_event(document,'wpforo_textarea_content_changed', e); 1287 }); 1288 1289 document.addEventListener('wpforo_tinymce_content_changed', wpforo_content_changed); 1290 document.addEventListener('wpforo_textarea_content_changed', wpforo_content_changed); 1291 document.addEventListener('wpforo_tinymce_ctrl_s', wpforo_content_ctrl_s); 1292 document.addEventListener('wpforo_textarea_ctrl_s', wpforo_content_ctrl_s); 1293 1294 wpforo_tags_suggest(); 1295 document.addEventListener('wpforo_topic_portable_form', function(e){ 1296 wpforo_tags_suggest(); 1297 window.wpforo_fix_form_data_attributes(); 1298 var f = e.detail; 1299 if( f && f.length ){ 1300 var t = $('[type="text"][required]', f); 1301 if( t.length && t.val().length ){ 1302 wpforo_tinymce_initializeIt('[data-wpforoeditor="tinymce"]'); 1303 }else{ 1304 wpforo_tinymce_initializeIt('[data-wpforoeditor="tinymce"]', true); 1305 t.trigger("focus"); 1306 } 1307 } 1308 }); 1309 1310 wpforo_wrap.on('click', '.wpforo-rcn-wrap .wpforo-rcn-dismiss-button:not(.wpf-processing)', function () { 1311 var $this = $(this); 1312 $this.addClass('wpf-processing'); 1313 wpforo_load_show(); 1314 var wrap = $(this).closest('.wpforo-rcn-wrap'); 1315 $.ajax({
1316 type: 'POST', 1317 data: { 1318 backend: 0, 1319 action: 'wpforo_dissmiss_recaptcha_note' 1320 } 1321 }).done(function (response) { 1322 if( response.success ) { 1323 wrap.remove(); 1324 wpforo_notice_show('done', 'success'); 1325 } 1326 }).always(function () { 1327 wpforo_load_hide(); 1328 $this.removeClass('wpf-processing'); 1329 }); 1330 }); 1331 1332 wpforo_wrap.on('click', '.wpf-admincp .wpf-acp-toggle:not(.wpf-processing)', function(){ 1333 var $this = $(this); 1334 $this.addClass('wpf-processing'); 1335 var wrap = $this.closest('.wpf-admincp'); 1336 $('.wpf-acp-body', wrap).slideToggle(function(){ 1337 $('.fas', $this).toggleClass('fa-minus-square fa-plus-square'); 1338 var toggle_status = $(this).is(':visible') ? 'open' : 'close'; 1339 $.ajax({ 1340 type: 'POST', 1341 data:{ 1342 toggle_status: toggle_status, 1343 action: 'wpforo_acp_toggle', 1344 _wpfnonce: wpforo['nonces']['wpforo_acp_toggle'], 1345 } 1346 }).always(function(){ 1347 $this.removeClass('wpf-processing'); 1348 }); 1349 }); 1350 }); 1351 1352 /* -- #################################################### -- */ 1353 /* image adjust and upload from frontend */ 1354 1355 function processfile( file, max_width, max_height, quality, callback ) { 1356 if( !( /image/i ).test( file.type ) ) { 1357 alert( "File "+ file.name +" is not an image." ); 1358 return false; 1359 } 1360 1361 // read the files 1362 var reader = new FileReader(); 1363 reader.readAsArrayBuffer(file); 1364 1365 reader.onload = function (event) { 1366 // blob stuff 1367 var blob = new Blob([event.target.result]); // create blob... 1368 window.URL = window.URL || window.webkitURL; 1369 var blobURL = window.URL.createObjectURL(blob); // and get its URL 1370 1371 // helper Image object 1372 var image = new Image(); 1373 image.src = blobURL; 1374 //preview.appendChild(image); // preview commented out, I am using the canvas instead 1375 image.onload = function() { 1376 // have to wait till it's loaded 1377 var resized = resizeMe(image, max_width, max_height, quality); // send it to canvas 1378 callback( resized ); 1379 } 1380 }; 1381 } 1382 1383 // === RESIZE ==== 1384 function resizeMe( img, max_width, max_height, quality ) { 1385 var canvas = document.createElement('canvas'); 1386 var width = img.width; 1387 var height = img.height; 1388 1389 // calculate the width and height, constraining the proportions 1390 if(width > height) { 1391 if (width > max_width) { 1392 //height *= max_width / width; 1393 height = Math.round(height *= max_width / width); 1394 width = max_width; 1395 } 1396 } else { 1397 if (height > max_height) { 1398 //width *= max_height / height; 1399 width = Math.round(width *= max_height / height); 1400 height = max_height; 1401 } 1402 } 1403 1404 // resize the canvas and draw the image data into it 1405 canvas.width = width; 1406 canvas.height = height; 1407 var ctx = canvas.getContext("2d"); 1408 ctx.drawImage(img, 0, 0, width, height); 1409 1410 return canvas.toDataURL("image/jpeg", quality); // get the data from canvas as 70% JPG (can be also PNG, etc.) 1411 } 1412 1413 function OpenFileDialog (accept, callback) { 1414 // this function must be called from a user 1415 // activation event (ie an onclick event) 1416 1417 // Create an input element 1418 var inputElement = document.createElement("input"); 1419 1420 // Set its type to file 1421 inputElement.type = "file"; 1422 1423 // Set accept to the file types you want the user to select. 1424 // Include both the file extension and the mime type 1425 inputElement.accept = accept; 1426 1427 // set onchange event to call callback when user has selected file 1428 inputElement.addEventListener("change", callback) 1429 1430 // dispatch a click event to open the file dialog 1431 inputElement.dispatchEvent(new MouseEvent("click")); 1432 } 1433 1434 wpforo_wrap.on( 'click', '.wpforo-profile .wpforo-profile-head .wpf-edit-cover:not(.wpf-processing)', function( e ){ 1435 if( e.target.dataset['action'] === 'editcover' ){ 1436 var options = $( '.wpf-edit-cover-options', $( this ) ); 1437 options.css( 'display', ( options.is( ':visible' ) ? 'none' : 'flex') ); 1438 } 1439 });
1440 1441 wpforo_wrap.on( 'click', '.wpforo-profile .wpforo-profile-head .wpf-edit-cover .wpf-upload-cover:not(.wpf-processing)', function(){ 1442 if ( !( window.File && window.FileReader && window.FileList && window.Blob ) ) { 1443 alert('The File APIs are not fully supported in this browser.'); 1444 return false; 1445 } 1446 var that = $( this ); 1447 that.closest( '.wpf-edit-cover-options' ).hide(); 1448 OpenFileDialog('image/png,image/jpg,image/jpeg,image/gif', function(){ 1449 if( this.files.length ) { 1450 that.addClass( 'wpf-processing' ); 1451 wpforo_load_show('Uploading...'); 1452 processfile(this.files[0], 1120, 460, 0.7, function (imageblob) { 1453 $wpf.ajax({ 1454 type: 'POST', 1455 data: { 1456 image_blob: imageblob, 1457 action: 'wpforo_profile_cover_upload', 1458 _wpfnonce: wpforo['nonces']['wpforo_profile_cover_upload'], 1459 } 1460 }).done(function(){ 1461 that.closest('.wpforo-profile-head').css('background-image', 'url(\'' + imageblob + '\')'); 1462 }).always(function(){ 1463 that.removeClass('wpf-processing'); 1464 wpforo_load_hide(); 1465 }); 1466 }) 1467 } 1468 }); 1469 }); 1470 1471 wpforo_wrap.on( 'click', '.wpforo-profile .wpforo-profile-head .wpf-edit-cover .wpf-delete-cover:not(.wpf-processing)', function(){ 1472 var that = $( this ); 1473 that.closest( '.wpf-edit-cover-options' ).hide(); 1474 that.addClass( 'wpf-processing' ); 1475 wpforo_load_show('Uploading...'); 1476 $wpf.ajax({ 1477 type: 'POST', 1478 data: { 1479 action: 'wpforo_profile_cover_delete', 1480 _wpfnonce: wpforo['nonces']['wpforo_profile_cover_delete'], 1481 } 1482 }).done(function( r ){ 1483 if( r.success ) that.closest('.wpforo-profile-head').css('background-image', 'url(\'' + r.data['background_url'] + '\')'); 1484 }).always(function(){ 1485 that.removeClass('wpf-processing'); 1486 wpforo_load_hide(); 1487 }); 1488 }); 1489 1490 wpforo_wrap.on( 'click', '.wpforo-profile .wpforo-follow-user:not(.wpf-processing)', function(){ 1491 if( document.body.classList.contains( 'logged-in' ) ){ 1492 var that = $( this ); 1493 var userid = parseInt( that.data('userid') ); 1494 var stat = !parseInt( that.data('stat') ); 1495 that.addClass( 'wpf-processing' ); 1496 wpforo_load_show(); 1497 $wpf.ajax({ 1498 type: 'POST', 1499 data: { 1500 userid, 1501 stat: ( stat ? 1 : 0 ), 1502 action: 'wpforo_follow_unfollow_user', 1503 _wpfnonce: wpforo['nonces']['wpforo_follow_unfollow_user'], 1504 } 1505 }).done(function( r ){ 1506 if( r.success ){ 1507 that.data( 'stat', r.data['stat'] ); 1508 that.prop( 'stat', r.data['stat'] ); 1509 that.attr( 'stat', r.data['stat'] ); 1510 $( '.wpforo-follow-user-label', that ).text( r.data['phrase'] ); 1511 $( '.wpforo-follow-user-followers-count', that.closest( '.wpforo-follow-wrap' ) ).text( r.data['followers_count'] ); 1512 } 1513 wpforo_notice_show( r.data['notice'], ( r.success ? 'success' : 'error' ) ); 1514 }).always(function(){ 1515 that.removeClass('wpf-processing'); 1516 wpforo_load_hide(); 1517 }); 1518 }else{ 1519 wpforo_notice_show( wpforo['notice']['login_or_register'] ); 1520 } 1521 }); 1522 1523 wpforo_wrap.on('click', '.wpforo-post-head .wpf-pb-more', function(){ 1524 var that = $( this ); 1525 var wrap = that.closest( '.wpforo-post-head' ); 1526 var topicid = parseInt( that.closest( '.wpforo-topic-head-wrap[data-topicid]' ).data('topicid') ); 1527 1528 if( ! isNaN( topicid ) && topicid ){ 1529 1530 that.find('span > svg').toggle(); 1531 1532 var more = $( '.wpf-topic-more-info', wrap ); 1533 var already_loaded = !! more.html().trim(); 1534 if( ! ( ! already_loaded && more.is( ':visible' ) ) ) more.toggle(
1534); 1535 1536 if( ! already_loaded ){ 1537 more.addClass( 'wpforo-section-loading' ); 1538 1539 $wpf.ajax({ 1540 type: 'POST', 1541 data: { 1542 topicid, 1543 action: 'wpforo_get_topic_head_more_info', 1544 _wpfnonce: wpforo['nonces']['wpforo_get_topic_head_more_info'], 1545 } 1546 }).done(function( r ){ 1547 if( r.success ){ 1548 more.html( r.data['html'] ); 1549 } 1550 }).always(function(){ 1551 more.removeClass('wpforo-section-loading'); 1552 }); 1553 } 1554 1555 var ico = $( 'i.fa-chevron-up, i.fa-chevron-down', that); 1556 var label = $( 'span', that ); 1557 if( more.is( ':visible' ) ){ 1558 ico.removeClass( 'fa-chevron-down' ).addClass( 'fa-chevron-up' ); 1559 }else{ 1560 ico.removeClass( 'fa-chevron-up' ).addClass( 'fa-chevron-down' ); 1561 } 1562 } 1563 }); 1564 1565 var topic_head_more_info = $( '.wpforo-topic-head-wrap .wpf-topic-more-info', wpforo_wrap ); 1566 if( topic_head_more_info.is( ':visible' ) && !topic_head_more_info.html().trim() ) { 1567 $( '.wpforo-post-head .wpf-pb-more', wpforo_wrap ).trigger( 'click' ); 1568 } 1569 1570 wpforo_wrap.on('click', '.wpf-tmi-overview .wpf-action.wpf-topic-overview-load-more:not(.wpf-processing)', function(){ 1571 var that = $( this ); 1572 var wrap = that.closest( '.wpf-tmi-overview' ); 1573 var tree = $( '.wpf-topic-overview-tree', wrap ); 1574 var nomore = parseInt( tree.data( 'nomore' ) ); 1575 if( ! nomore ){ 1576 var topicid = parseInt( that.closest( '.wpforo-topic-head-wrap[data-topicid]' ).data('topicid') ); 1577 if( ! isNaN( topicid ) ){ 1578 that.addClass( 'wpf-processing' ); 1579 wpforo_load_show(); 1580 1581 var chunksize = parseInt( tree.data( 'chunksize' ) ); 1582 var offset = parseInt( tree.data( 'offset' ) ); 1583 if( isNaN( chunksize ) ) chunksize = 5; 1584 if( isNaN( offset ) ) offset = 0; 1585 offset = offset + chunksize; 1586 1587 $wpf.ajax({ 1588 type : 'POST', 1589 data : { 1590 topicid, 1591 chunksize, 1592 offset, 1593 action: 'wpforo_get_topic_overview_chunk', 1594 _wpfnonce: wpforo['nonces']['wpforo_get_topic_overview_chunk'], 1595 } 1596 }).done(function( r ){ 1597 if( r.success ){ 1598 var nomore = r.data['nomore'] ? 1 : 0; 1599 tree.append( r.data['html'] ); 1600 1601 wpforo_setAttr( tree, 'data-offset', offset ); 1602 wpforo_setAttr( tree, 'data-chunksize', chunksize ); 1603 wpforo_setAttr( tree, 'data-nomore', nomore ); 1604 } 1605 }).always(function(){ 1606 that.removeClass('wpf-processing'); 1607 wpforo_load_hide(); 1608 }); 1609 } 1610 } 1611 }); 1612 1613 wpforo_wrap.on( 'click', '.wpf-tmi-overview .wpf-topic-overview-tree .wpf-tmi-item .wpf-link.wpf-tmi-item-body-excerpt:not(.wpf-processing)', function(){ 1614 var $this = $( this ); 1615 var postid = parseInt( $this.data( 'postid' ) ); 1616 if( !isNaN( postid ) ){ 1617 if( !wpforo['overview'] ) wpforo['overview'] = []; 1618 var overview = wpforo['overview'][postid]; 1619 if( !overview ){ 1620 $this.addClass( 'wpf-processing' ); 1621 wpforo_load_show(); 1622 $.ajax({
1623 type: 'POST', 1624 data: { 1625 postid, 1626 action: 'wpforo_get_overview', 1627 _wpfnonce: wpforo['nonces']['wpforo_get_overview'], 1628 } 1629 }).done(function( r ){ 1630 if( r.success ){ 1631 wpforo['overview'][postid] = r.data; 1632 wpforo_dialog_show( r.data['title'], r.data['content'], '50%', '350px' ); 1633 } 1634 }).always(function(){ 1635 $this.removeClass( 'wpf-processing' ); 1636 wpforo_load_hide(); 1637 }); 1638 }else{ 1639 wpforo_dialog_show( overview['title'], overview['content'], '50%', '350px' ); 1640 } 1641 } 1642 } ); 1643 1644 wpforo_wrap.on( 'click', '.wpf-action.wpforo-bookmark:not(.wpf-processing), .wpf-action.wpforo-unbookmark:not(.wpf-processing)', {}, function(){ 1645 var $this = $( this ); 1646 var wrap = $this.closest( '.post-wrap[data-postid], .reply-wrap[data-postid], .comment-wrap[data-postid]' ); 1647 if( wrap.length ){ 1648 var postid = parseInt( wrap.data( 'postid' ) ); 1649 if( ! isNaN( postid ) ){ 1650 $this.addClass( 'wpf-processing' ); 1651 var _action = ( $this.hasClass( 'wpforo-bookmark' ) ? 'wpforo_bookmark' : 'wpforo_unbookmark' ); 1652 $.ajax( { 1653 type: 'POST', 1654 data: { 1655 postid, 1656 action: _action, 1657 _wpfnonce: wpforo['nonces'][_action], 1658 } 1659 } ).done( function( r ){ 1660 if( r.success ) $this.replaceWith( r.data['button'] ); 1661 } ).always( function(){ 1662 $this.removeClass( 'wpf-processing' ); 1663 } ); 1664 } 1665 } 1666 } ); 1667 1668 wpforo_wrap.on( 'click', '.sbn-action .wpf-sbn-unsbscrb:not(.wpf-processing)', {}, function(){ 1669 var $this = $( this ); 1670 var wrap = $this.closest( '.wpforo-sb' ); 1671 var key = $this.data( 'key' ); 1672 var boardid = $this.data( 'boardid' ); 1673 if( key ){ 1674 $this.addClass( 'wpf-processing' ); 1675 $.ajax({
1676 type: 'POST', 1677 data: { 1678 key, 1679 boardid, 1680 action: 'wpforo_unsubscribe', 1681 _wpfnonce: wpforo['nonces']['wpforo_unsubscribe'], 1682 } 1683 }).done(function( r ){ 1684 if( r.success ) wrap.remove(); 1685 wpforo_notice_show( r.data['notice'], ( r.success ? 'success' : 'error' ) ); 1686 }).always(function(){ 1687 $this.removeClass( 'wpf-processing' ); 1688 }); 1689 } 1690 } ); 1691 1692 function action_get_member_template( $this, wrap, href ){ 1693 if( $this && $this.length && wrap && wrap.length && href ){ 1694 $this.addClass( 'wpf-processing' ); 1695 wpforo_load_show(); 1696 $.ajax({ 1697 type: 'POST', 1698 data: { 1699 href, 1700 'action': 'wpforo_get_member_template', 1701 _wpfnonce: wpforo['nonces']['wpforo_get_member_template'], 1702 } 1703 }).done(function( r ){ 1704 if( r.success ){ 1705 $this.siblings().removeClass( 'wpf-active' ); 1706 $this.addClass( 'wpf-active' ); 1707 wrap.html( r.data['html'] ); 1708 } 1709 }).always(function(){ 1710 $this.removeClass( 'wpf-processing' ); 1711 wpforo_load_hide(); 1712 }); 1713 } 1714 } 1715 1716 wpforo_wrap.on('click', '.wpf-member-template-link.wpf-ajax-link:not(.wpf-processing)', {}, function(e){ 1717 e.preventDefault(); 1718 var $this = $( this ); 1719 var wrap = $this.closest( '.wpf-profile-body' ); 1720 var href = e.target.href; 1721 action_get_member_template( $this, wrap, href ); 1722 }); 1723 1724 wpforo_wrap.on('click', '.wpf-member-template-link.wpf-ajax-link .wpf-navi .wpf-navi-dropdown', {}, function(){ 1725 this.onchange = false; 1726 }); 1727 1728 wpforo_wrap.on( 'change', '.wpf-member-template-link.wpf-ajax-link .wpf-navi .wpf-navi-dropdown', {}, function( e ){ 1729 var $this = $( this ).closest( '.wpf-member-template-link.wpf-ajax-link' ); 1730 var wrap = $this.closest( '.wpf-profile-body' ); 1731 action_get_member_template( $this, wrap, e.target.value ); 1732 }); 1733 1734 let ts_input_old_value = ''; 1735 let ts_request; 1736 wpforo_wrap.on('input propertychange', '.wpf-topic-create form .wpf-field-name-title input[type="text"]', {}, function(){ 1737 if( $( 'input[name=wpfaction][value=topic_add]', $(this).closest( 'form' ) ).length ){ 1738 if( ts_request && ts_request.readyState !== 4 ) ts_request.abort(); 1739 setTimeout( () => { 1740 const $this = $( this ); 1741 let input_value = $this.val().trim(); 1742 if( input_value.length && ts_input_old_value !== input_value ){ 1743 wpforo_load_show(); 1744 ts_request = $.ajax({ 1745 type: 'POST', 1746 data: { 1747 title: input_value, 1748 action: 'wpforo_search_existed_topics', 1749 _wpfnonce: wpforo['nonces']['wpforo_search_existed_topics'], 1750 }, 1751 }).done(function(r){ 1752 const tlist = document.createElement('div'); 1753 tlist.classList.add( 'wpf-suggested-topics-list' ); 1754 $this.siblings( '.wpf-suggested-topics-list' ).remove(); 1755 $this.after( tlist ); 1756 if( r.success ){ 1757 tlist.innerHTML = '<div class="wpf-suggested-topics-title">' + wpforo_phrase('Discussions that may already have the information you are looking for') + ' <i class="fa-solid fa-angles-down"></i></div>'; 1758 r.data.forEach(function( topic ){ 1759 const node = document.createElement( 'div' ); 1760 node.classList.add( 'wpf-suggested-topic-node' ); 1761 node.innerHTML = `<i class="fa-solid fa-caret-right"></i> <a href="${topic['url']}" target="_blank">${topic['title']}</a>`; 1762 tlist.append( node ); 1763 }); 1764 } 1765 }).always(function(){ 1766 wpforo_load_hide(); 1767 }); 1768 1769 ts_input_old_value = input_value; 1770 } 1771 }, 700); 1772 wpforo_load_hide(); 1773 } 1774 });
1775 1776 wpforo_wrap.on('focusout', '.wpf-topic-create form .wpf-field-name-title', {}, function(){ 1777 setTimeout(function(){ 1778 $( '.wpf-topic-create form .wpf-field-name-title .wpf-suggested-topics-list' ).remove(); 1779 }, 100); 1780 }); 1781 1782}); 1783 1784function wpforo_init_phrases(){ 1785 if( $wpf.active === 0 ) { 1786 $wpf.ajax({ 1787 url: wpforo.ajax_url, 1788 type: 'POST', 1789 dataType: 'json', 1790 async: false, 1791 data: { 1792 action: 'wpforo_get_phrases', 1793 _wpfnonce: wpforo['nonces']['wpforo_get_phrases'], 1794 } 1795 }).done(function (r) { 1796 window.wpforo_phrases = r; 1797 }); 1798 } 1799} 1800 1801function wpforo_ucwords (str) { 1802 return (str + '').replace(/^([a-z])|\s+([a-z])/, function ($1) { 1803 return $1.toUpperCase(); 1804 }); 1805} 1806 1807function wpforo_topic_tools_tab_load() { 1808 var active_tab = $wpf('#wpf_moderation_tools').find('.wpf-tool-tab.wpf-tt-active'); 1809 if( active_tab.length ){ 1810 var active_tab_id = active_tab.attr('id'); 1811 if( active_tab_id && $wpf.active === 0 ){ 1812 wpforo_notice_hide(); 1813 $wpf('#wpf_tool_tab_content_wrap').html('<i class="fas fa-spinner fa-spin wpf-icon-spinner"></i>'); 1814 $wpf.ajax({ 1815 type: 'POST', 1816 data: { 1817 active_tab_id: active_tab_id, 1818 action: 'wpforo_active_tab_content_ajax', 1819 _wpfnonce: wpforo['nonces']['wpforo_active_tab_content_ajax'], 1820 } 1821 }).done(function(response){ 1822 if( response ){ 1823 $wpf('#wpf_tool_tab_content_wrap').html(response); 1824 $wpf('#wpf_moderation_tools').slideDown(400, 'linear'); 1825 } 1826 wpforo_load_hide(); 1827 }); 1828 } 1829 } 1830} 1831 1832function wpforo_tags_suggest(){ 1833 var wpf_tags = $wpf('.wpf-tags'); 1834 wpf_tags.suggest( 1835 wpforo.ajax_url + ( /\?/.test( wpforo.ajax_url ) ? "&" : "?" ) + "action=wpforo_tag_search", 1836 { multiple:true, 1837 multipleSep: ",", 1838 resultsClass: 'wpf_ac_results', 1839 selectClass: 'wpf_ac_over', 1840 matchClass: 'wpf_ac_match', 1841 onSelect: function() {} 1842 } 1843 ); 1844 $wpf('.wpf_ac_results').on("blur", function() { 1845 wpf_tags.removeClass( 'wpf-ac-loading' ); 1846 }); 1847 wpf_tags.on("blur", function() { 1848 wpf_tags.removeClass( 'wpf-ac-loading' ); 1849 }); 1850 wpf_tags.on("keydown", 1851 function ( e ) { 1852 var tags = wpf_tags.val(); 1853 if( tags.length >= 1 ){ 1854 switch(e.code) { 1855 case 'ArrowUp': // up 1856 case 'ArrowDown': // down 1857 case 'Backspace': // backspace 1858 case 'Tab': // tab 1859 case 'Enter': // return 1860 case 'NumpadEnter': // return 1861 case 'Escape': // escape 1862 case 'Space': // space 1863 case 'Comma': // comma 1864 wpf_tags.removeClass( 'wpf-ac-loading' ); break; 1865 default: 1866 wpf_tags.addClass( 'wpf-ac-loading' ); 1867 } 1868 } 1869 setTimeout(function() { wpf_tags.removeClass( 'wpf-ac-loading' ); }, 1000); 1870 } 1871 ); 1872}
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.