| 1 |
jQuery(document).ready(function ($) { |
| 2 |
var wpforo_wrap = $('#wpforo-wrap'); |
| 3 |
// Like |
| 4 |
wpforo_wrap.on('click', '.wpforo-like', function () { |
| 5 |
$("#wpf-msg-box").hide(); |
| 6 |
$('#wpforo-load').visible(); |
| 7 |
var postid = $(this).data('postid'), |
| 8 |
that = $(this); |
| 9 |
$.ajax({ |
| 10 |
type: 'POST', |
| 11 |
url: wpf_ajax_obj.url, |
| 12 |
data: { |
| 13 |
postid: postid, |
| 14 |
likestatus: 1, |
| 15 |
action: 'wpforo_like_ajax' |
| 16 |
} |
| 17 |
}).done(function (response) { |
| 18 |
try { |
| 19 |
response = $.parseJSON(response); |
| 20 |
} catch (e) { |
| 21 |
console.log(e); |
| 22 |
} |
| 23 |
if (response.stat === 1) { |
| 24 |
that.find('.wpforo-like-ico').removeClass('fa-thumbs-up').addClass('fa-thumbs-down'); |
| 25 |
that.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Unlike')); |
| 26 |
that.parents('.post-wrap').find('.bleft').html(response.likers); |
| 27 |
that.removeClass('wpforo-like').addClass('wpforo-unlike'); |
| 28 |
} |
| 29 |
$('#wpforo-load').invisible(); |
| 30 |
wpforo_notice_show(response.notice); |
| 31 |
}); |
| 32 |
}); |
| 33 |
// unlike |
| 34 |
wpforo_wrap.on('click', '.wpforo-unlike', function () { |
| 35 |
$("#wpf-msg-box").hide(); |
| 36 |
$('#wpforo-load').visible(); |
| 37 |
var postid = $(this).data('postid'), |
| 38 |
that = $(this); |
| 39 |
$.ajax({ |
| 40 |
type: 'POST', |
| 41 |
url: wpf_ajax_obj.url, |
| 42 |
data: { |
| 43 |
postid: postid, |
| 44 |
likestatus: 0, |
| 45 |
action: 'wpforo_like_ajax' |
| 46 |
} |
| 47 |
}).done(function (response) { |
| 48 |
try { |
| 49 |
response = $.parseJSON(response); |
| 50 |
} catch (e) { |
| 51 |
console.log(e); |
| 52 |
} |
| 53 |
if (response.stat === 1) { |
| 54 |
that.find('.wpforo-like-ico').removeClass('fa-thumbs-down').addClass('fa-thumbs-up'); |
| 55 |
that.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Like')); |
| 56 |
that.parents('.post-wrap').find('.bleft').html(response.likers); |
| 57 |
that.removeClass('wpforo-unlike').addClass('wpforo-like'); |
| 58 |
} |
| 59 |
$('#wpforo-load').invisible(); |
| 60 |
wpforo_notice_show(response.notice); |
| 61 |
}); |
| 62 |
}); |
| 63 |
|
| 64 |
|
| 65 |
// Vote |
| 66 |
wpforo_wrap.on('click', '.wpforo-voteup', function () { |
| 67 |
$("#wpf-msg-box").hide(); |
| 68 |
$('#wpforo-load').visible(); |
| 69 |
var type = $(this).data('type'), |
| 70 |
postid = $(this).data('postid'), |
| 71 |
that = $(this); |
| 72 |
$.ajax({ |
| 73 |
type: 'POST', |
| 74 |
url: wpf_ajax_obj.url, |
| 75 |
data: { |
| 76 |
itemtype: type, |
| 77 |
postid: postid, |
| 78 |
votestatus: 'up', |
| 79 |
action: 'wpforo_vote_ajax' |
| 80 |
} |
| 81 |
}).done(function (response) { |
| 82 |
try { |
| 83 |
response = $.parseJSON(response); |
| 84 |
} catch (e) { |
| 85 |
console.log(e); |
| 86 |
} |
| 87 |
if (response.stat === 1) { |
| 88 |
var wpfvote_num = that.parents('.post-wrap').find('.wpfvote-num'), |
| 89 |
count = wpfvote_num.text(); |
| 90 |
wpfvote_num.text(++count).fadeIn(); |
| 91 |
} |
| 92 |
$('#wpforo-load').invisible(); |
| 93 |
wpforo_notice_show(response.notice); |
| 94 |
}); |
| 95 |
}); |
| 96 |
|
| 97 |
wpforo_wrap.on('click', '.wpforo-votedown', function () { |
| 98 |
$("#wpf-msg-box").hide(); |
| 99 |
$('#wpforo-load').visible(); |
| 100 |
var type = $(this).data('type'), |
| 101 |
postid = $(this).data('postid'), |
| 102 |
that = $(this); |
| 103 |
$.ajax({ |
| 104 |
type: 'POST', |
| 105 |
url: wpf_ajax_obj.url, |
| 106 |
data: { |
| 107 |
itemtype: type, |
| 108 |
postid: postid, |
| 109 |
votestatus: 'down', |
| 110 |
action: 'wpforo_vote_ajax' |
| 111 |
} |
| 112 |
}).done(function (response) { |
| 113 |
try { |
| 114 |
response = $.parseJSON(response); |
| 115 |
} catch (e) { |
| 116 |
console.log(e); |
| 117 |
} |
| 118 |
if (response.stat === 1) { |
| 119 |
var wpfvote_num = that.parents('.post-wrap').find('.wpfvote-num'), |
| 120 |
count = wpfvote_num.text(); |
| 121 |
wpfvote_num.text(--count).fadeIn(); |
| 122 |
} |
| 123 |
$('#wpforo-load').invisible(); |
| 124 |
wpforo_notice_show(response.notice); |
| 125 |
}); |
| 126 |
}); |
| 127 |
|
| 128 |
|
| 129 |
// Answer |
| 130 |
wpforo_wrap.on('click', '.wpf-toggle-answer', function () { |
| 131 |
$("#wpf-msg-box").hide(); |
| 132 |
$('#wpforo-load').visible(); |
| 133 |
var postid = $(this).data('postid'), |
| 134 |
that = $(this); |
| 135 |
$.ajax({ |
| 136 |
type: 'POST', |
| 137 |
url: wpf_ajax_obj.url, |
| 138 |
data: { |
| 139 |
postid: postid, |
| 140 |
answerstatus: 0, |
| 141 |
action: 'wpforo_answer_ajax' |
| 142 |
} |
| 143 |
}).done(function (response) { |
| 144 |
try { |
| 145 |
response = $.parseJSON(response); |
| 146 |
} catch (e) { |
| 147 |
console.log(e); |
| 148 |
} |
| 149 |
if (response.stat === 1) { |
| 150 |
that.removeClass('wpf-toggle-answer').addClass('wpf-toggle-not-answer'); |
| 151 |
} |
| 152 |
$('#wpforo-load').invisible(); |
| 153 |
wpforo_notice_show(response.notice); |
| 154 |
}); |
| 155 |
}); |
| 156 |
|
| 157 |
wpforo_wrap.on('click', '.wpf-toggle-not-answer', function () { |
| 158 |
$("#wpf-msg-box").hide(); |
| 159 |
$('#wpforo-load').visible(); |
| 160 |
var postid = $(this).data('postid'), |
| 161 |
that = $(this); |
| 162 |
$.ajax({ |
| 163 |
type: 'POST', |
| 164 |
url: wpf_ajax_obj.url, |
| 165 |
data: { |
| 166 |
postid: postid, |
| 167 |
answerstatus: 1, |
| 168 |
action: 'wpforo_answer_ajax' |
| 169 |
} |
| 170 |
}).done(function (response) { |
| 171 |
try { |
| 172 |
response = $.parseJSON(response); |
| 173 |
} catch (e) { |
| 174 |
console.log(e); |
| 175 |
} |
| 176 |
if (response.stat === 1) { |
| 177 |
that.removeClass('wpf-toggle-not-answer').addClass('wpf-toggle-answer'); |
| 178 |
} |
| 179 |
$('#wpforo-load').invisible(); |
| 180 |
wpforo_notice_show(response.notice); |
| 181 |
}); |
| 182 |
}); |
| 183 |
|
| 184 |
|
| 185 |
// Quote |
| 186 |
wpforo_wrap.on('click', '.wpforo-quote', function () { |
| 187 |
$("#wpf-msg-box").hide(); |
| 188 |
$("#wpforo-load").visible(); |
| 189 |
var postid = $(this).data('postid'); |
| 190 |
$.ajax({ |
| 191 |
type: 'POST', |
| 192 |
url: wpf_ajax_obj.url, |
| 193 |
data: { |
| 194 |
postid: postid, |
| 195 |
action: 'wpforo_quote_ajax' |
| 196 |
} |
| 197 |
}).done(function (response) { |
| 198 |
tinyMCE.activeEditor.setContent(response); |
| 199 |
|
| 200 |
var phrase = wpforo_phrase('Reply with quote'); |
| 201 |
phrase = phrase.charAt(0).toUpperCase() + phrase.slice(1); |
| 202 |
$("#wpf-reply-form-title").html(phrase); |
| 203 |
|
| 204 |
$(".wpf-topic-sbs").show(); |
| 205 |
$("#wpf-topic-sbs").prop("disabled", false); |
| 206 |
|
| 207 |
var wpf_formaction = $("#wpf_formaction"), |
| 208 |
wpf_formtopicid = $("#wpf_formtopicid"), |
| 209 |
wpf_formbutton = $("#wpf_formbutton"), |
| 210 |
wpf_title = $("#wpf_title"); |
| 211 |
|
| 212 |
wpf_formaction.attr('name', 'post[action]'); |
| 213 |
wpf_formtopicid.attr('name', 'post[topicid]'); |
| 214 |
wpf_formbutton.attr('name', 'post[save]'); |
| 215 |
wpf_formbutton.val(wpforo_phrase('Save')); |
| 216 |
wpf_title.attr('name', 'post[title]'); |
| 217 |
wpf_title.val(wpforo_phrase('re') + ": " + wpf_title.attr('placeholder').replace(wpforo_phrase('re') + ": ", "").replace(wpforo_phrase('answer to') + ": ", "")); |
| 218 |
$('html, body').animate({scrollTop: $("#wpf-form-wrapper").offset().top}, 1000); |
| 219 |
|
| 220 |
tinymce.execCommand('mceFocus', false, 'postbody'); |
| 221 |
tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true); |
| 222 |
tinyMCE.activeEditor.selection.collapse(false); |
| 223 |
$('#wpforo-load').invisible(); |
| 224 |
}); |
| 225 |
}); |
| 226 |
|
| 227 |
// Report |
| 228 |
wpforo_wrap.on('click', '.wpforo-report', function(){ |
| 229 |
var wpforo_load = $('#wpforo-load'); |
| 230 |
$("#wpf-msg-box").hide(); |
| 231 |
wpforo_load.visible(); |
| 232 |
var postid = $(this).data('postid'); |
| 233 |
$('#wpf_reportpostid').attr('value', postid); |
| 234 |
|
| 235 |
var dialog; |
| 236 |
var w = jQuery(window).width(); |
| 237 |
var h = jQuery(window).height(); |
| 238 |
var dialogWidth = 600; |
| 239 |
var dialogHeight = 250; |
| 240 |
H = ( dialogHeight < h ) ? dialogHeight : (h-40); |
| 241 |
W = ( dialogWidth < w ) ? dialogWidth : (w-20); |
| 242 |
|
| 243 |
dialog = jQuery( "#wpf_reportdialog" ).dialog({ |
| 244 |
create: function(event, ui) { |
| 245 |
jQuery(event.target).parent().css('position', 'fixed'); |
| 246 |
}, |
| 247 |
autoOpen: false, |
| 248 |
height: H, |
| 249 |
width: W, |
| 250 |
modal: true, |
| 251 |
dialogClass:'wpforo-dialog wpforo-dialog-report' |
| 252 |
}); |
| 253 |
|
| 254 |
dialog.dialog( "open" ); |
| 255 |
wpforo_load.invisible(); |
| 256 |
}); |
| 257 |
|
| 258 |
$("#wpf_reportdialog").on('click', '#wpf_sendreport', function () { |
| 259 |
$("#wpf-msg-box").hide(); |
| 260 |
$('#wpforo-load').visible(); |
| 261 |
var postid = $('#wpf_reportpostid').attr('value'); |
| 262 |
var messagecontent = $('#wpf_reportmessagecontent').attr('value'); |
| 263 |
|
| 264 |
$.ajax({ |
| 265 |
type: 'POST', |
| 266 |
url: wpf_ajax_obj.url, |
| 267 |
data: { |
| 268 |
postid: postid, |
| 269 |
reportmsg: messagecontent, |
| 270 |
action: 'wpforo_report_ajax' |
| 271 |
} |
| 272 |
}).done(function (response) { |
| 273 |
try { |
| 274 |
response = $.parseJSON(response); |
| 275 |
} catch (e) { |
| 276 |
console.log(e); |
| 277 |
} |
| 278 |
$("#wpf_reportdialog").dialog('close'); |
| 279 |
$('#wpforo-load').invisible(); |
| 280 |
wpforo_notice_show(response); |
| 281 |
}); |
| 282 |
}); |
| 283 |
|
| 284 |
|
| 285 |
// Sticky |
| 286 |
wpforo_wrap.on('click', '.wpforo-sticky', function () { |
| 287 |
$("#wpf-msg-box").hide(); |
| 288 |
$('#wpforo-load').visible(); |
| 289 |
var topicid = $(this).data('topicid'), |
| 290 |
that = $(this); |
| 291 |
|
| 292 |
$.ajax({ |
| 293 |
type: 'POST', |
| 294 |
url: wpf_ajax_obj.url, |
| 295 |
data: { |
| 296 |
topicid: topicid, |
| 297 |
status: 'sticky', |
| 298 |
action: 'wpforo_sticky_ajax' |
| 299 |
} |
| 300 |
}).done(function (response) { |
| 301 |
try { |
| 302 |
response = $.parseJSON(response); |
| 303 |
} catch (e) { |
| 304 |
console.log(e); |
| 305 |
} |
| 306 |
if (response.stat === 1) { |
| 307 |
that.find('.wpforo-sticky-txt').text(' ' + wpforo_phrase('Unsticky')); |
| 308 |
that.removeClass('wpforo-sticky').addClass('wpforo-unsticky'); |
| 309 |
} |
| 310 |
$('#wpforo-load').invisible(); |
| 311 |
wpforo_notice_show(response.notice); |
| 312 |
}); |
| 313 |
}); |
| 314 |
|
| 315 |
|
| 316 |
wpforo_wrap.on('click', '.wpforo-unsticky', function () { |
| 317 |
$("#wpf-msg-box").hide(); |
| 318 |
$('#wpforo-load').visible(); |
| 319 |
var topicid = $(this).data('topicid'), |
| 320 |
that = $(this); |
| 321 |
|
| 322 |
$.ajax({ |
| 323 |
type: 'POST', |
| 324 |
url: wpf_ajax_obj.url, |
| 325 |
data: { |
| 326 |
topicid: topicid, |
| 327 |
status: 'unsticky', |
| 328 |
action: 'wpforo_sticky_ajax' |
| 329 |
} |
| 330 |
}).done(function (response) { |
| 331 |
try { |
| 332 |
response = $.parseJSON(response); |
| 333 |
} catch (e) { |
| 334 |
console.log(e); |
| 335 |
} |
| 336 |
if (response.stat === 1) { |
| 337 |
that.find('.wpforo-sticky-txt').text(' ' + wpforo_phrase('Sticky')); |
| 338 |
that.removeClass('wpforo-unsticky').addClass('wpforo-sticky'); |
| 339 |
} |
| 340 |
$('#wpforo-load').invisible(); |
| 341 |
wpforo_notice_show(response.notice); |
| 342 |
}); |
| 343 |
}); |
| 344 |
|
| 345 |
// Approve |
| 346 |
wpforo_wrap.on('click','.wpforo-approve', function(){ |
| 347 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 348 |
var status_value = 'approve'; |
| 349 |
var postid_value = $(this).attr('id'); |
| 350 |
var postid = postid_value.replace("wpfapprove", ""); |
| 351 |
|
| 352 |
$.ajax({ |
| 353 |
type: 'POST', |
| 354 |
url: wpf_ajax_obj.url, |
| 355 |
data:{ |
| 356 |
postid: postid, |
| 357 |
status: status_value, |
| 358 |
action: 'wpforo_approve_ajax' |
| 359 |
} |
| 360 |
}).done(function(response){ |
| 361 |
if(response !== 0){ |
| 362 |
$("#" + postid_value).removeClass('wpforo-approve').addClass('wpforo-unapprove'); |
| 363 |
$("#approveicon" + postid).removeClass('fa-check').addClass('fa-exclamation-circle'); |
| 364 |
$("#wpforo-wrap #post-" + postid + " .wpf-mod-message").hide(); |
| 365 |
$("#wpforo-wrap .wpf-status-title").hide(); |
| 366 |
$("#approvetext" + postid).text( ' ' + wpforo_phrase('Unapprove') ); |
| 367 |
} |
| 368 |
$('#wpforo-load').invisible(); |
| 369 |
}); |
| 370 |
}); |
| 371 |
|
| 372 |
// Unapprove |
| 373 |
wpforo_wrap.on('click','.wpforo-unapprove', function(){ |
| 374 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 375 |
var status_value = 'unapprove'; |
| 376 |
var postid_value = $(this).attr('id'); |
| 377 |
var postid = postid_value.replace("wpfapprove", ""); |
| 378 |
|
| 379 |
$.ajax({ |
| 380 |
type: 'POST', |
| 381 |
url: wpf_ajax_obj.url, |
| 382 |
data:{ |
| 383 |
postid: postid, |
| 384 |
status: status_value, |
| 385 |
action: 'wpforo_approve_ajax' |
| 386 |
} |
| 387 |
}).done(function(response){ |
| 388 |
if(response != 0){ |
| 389 |
$("#" + postid_value).removeClass('wpforo-unapprove').addClass('wpforo-approve'); |
| 390 |
$("#approveicon" + postid).removeClass('fa-exclamation-circle').addClass('fa-check'); |
| 391 |
$('#wpforo-wrap #post-' + postid + ' .wpf-mod-message').visible(); |
| 392 |
$('#wpforo-wrap .wpf-status-title').visible(); |
| 393 |
$("#approvetext" + postid).text( ' ' + wpforo_phrase('Approve') ); |
| 394 |
} |
| 395 |
$('#wpforo-load').invisible(); |
| 396 |
location.reload(); |
| 397 |
}); |
| 398 |
}); |
| 399 |
|
| 400 |
|
| 401 |
// Private |
| 402 |
wpforo_wrap.on('click','.wpforo-private', function(){ |
| 403 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 404 |
var status_value = 'private'; |
| 405 |
var postid_value = $(this).attr('id'); |
| 406 |
var postid = postid_value.replace("wpfprivate", ""); |
| 407 |
|
| 408 |
$.ajax({ |
| 409 |
type: 'POST', |
| 410 |
url: wpf_ajax_obj.url, |
| 411 |
data:{ |
| 412 |
postid: postid, |
| 413 |
status: status_value, |
| 414 |
action: 'wpforo_private_ajax' |
| 415 |
} |
| 416 |
}).done(function(response){ |
| 417 |
if(response != 0){ |
| 418 |
$("#" + postid_value).removeClass('wpforo-private').addClass('wpforo-public'); |
| 419 |
$("#privateicon" + postid).removeClass('fa-eye-slash').addClass('fa-eye'); |
| 420 |
$("#privatetext" + postid).text( ' ' + wpforo_phrase('Public') ); |
| 421 |
} |
| 422 |
$('#wpforo-load').invisible(); |
| 423 |
}); |
| 424 |
}); |
| 425 |
|
| 426 |
wpforo_wrap.on('click','.wpforo-public', function(){ |
| 427 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 428 |
var status_value = 'public'; |
| 429 |
var postid_value = $(this).attr('id'); |
| 430 |
var postid = postid_value.replace("wpfprivate", ""); |
| 431 |
|
| 432 |
$.ajax({ |
| 433 |
type: 'POST', |
| 434 |
url: wpf_ajax_obj.url, |
| 435 |
data:{ |
| 436 |
postid: postid, |
| 437 |
status: status_value, |
| 438 |
action: 'wpforo_private_ajax' |
| 439 |
} |
| 440 |
}).done(function(response){ |
| 441 |
if(response != 0){ |
| 442 |
$("#" + postid_value).removeClass('wpforo-public').addClass('wpforo-private'); |
| 443 |
$("#privateicon" + postid).removeClass('fa-eye').addClass('fa-eye-slash'); |
| 444 |
$("#privatetext" + postid).text( ' ' + wpforo_phrase('Private') ); |
| 445 |
} |
| 446 |
$('#wpforo-load').invisible(); |
| 447 |
}); |
| 448 |
}); |
| 449 |
|
| 450 |
// Solved |
| 451 |
wpforo_wrap.on('click','.wpforo-solved', function(){ |
| 452 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 453 |
var status_value = 'solved'; |
| 454 |
var postid_value = $(this).attr('id'); |
| 455 |
var postid = postid_value.replace("wpfsolved", ""); |
| 456 |
|
| 457 |
$.ajax({ |
| 458 |
type: 'POST', |
| 459 |
url: wpf_ajax_obj.url, |
| 460 |
data:{ |
| 461 |
postid: postid, |
| 462 |
status: status_value, |
| 463 |
action: 'wpforo_solved_ajax' |
| 464 |
} |
| 465 |
}).done(function(response){ |
| 466 |
if(response != 0){ |
| 467 |
$("#" + postid_value).removeClass('wpforo-solved').addClass('wpforo-unsolved'); |
| 468 |
$("#solvedtext" + postid).text( ' ' + wpforo_phrase('Unsolved') ); |
| 469 |
} |
| 470 |
$('#wpforo-load').invisible(); |
| 471 |
}); |
| 472 |
}); |
| 473 |
|
| 474 |
wpforo_wrap.on('click','.wpforo-unsolved', function(){ |
| 475 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 476 |
var status_value = 'unsolved'; |
| 477 |
var postid_value = $(this).attr('id'); |
| 478 |
var postid = postid_value.replace("wpfsolved", ""); |
| 479 |
|
| 480 |
$.ajax({ |
| 481 |
type: 'POST', |
| 482 |
url: wpf_ajax_obj.url, |
| 483 |
data:{ |
| 484 |
postid: postid, |
| 485 |
status: status_value, |
| 486 |
action: 'wpforo_solved_ajax' |
| 487 |
} |
| 488 |
}).done(function(response){ |
| 489 |
if(response != 0){ |
| 490 |
$("#" + postid_value).removeClass('wpforo-unsolved').addClass('wpforo-solved'); |
| 491 |
$("#solvedtext" + postid).text( ' ' + wpforo_phrase('Solved') ); |
| 492 |
} |
| 493 |
$('#wpforo-load').invisible(); |
| 494 |
}); |
| 495 |
}); |
| 496 |
|
| 497 |
|
| 498 |
// Close |
| 499 |
wpforo_wrap.on('click','.wpforo-close', function(){ |
| 500 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 501 |
var status_value = 'close'; |
| 502 |
var postid_value = $(this).attr('id'); |
| 503 |
var postid = postid_value.replace("wpfclose", ""); |
| 504 |
$.ajax({ |
| 505 |
type: 'POST', |
| 506 |
url: wpf_ajax_obj.url, |
| 507 |
data:{ |
| 508 |
postid: postid, |
| 509 |
status: status_value, |
| 510 |
action: 'wpforo_close_ajax' |
| 511 |
} |
| 512 |
}).done(function(response){ |
| 513 |
if(response != 0){ |
| 514 |
$("#" + postid_value).removeClass('wpforo-close').addClass('wpforo-open'); |
| 515 |
$("#closeicon" + postid).removeClass('fa-lock').addClass('fa-unlock'); |
| 516 |
$("#closetext" + postid).text( ' ' + wpforo_phrase('Open') ); |
| 517 |
$("#wpf-form-wrapper").remove(); |
| 518 |
$(".wpforo-reply").remove(); |
| 519 |
$(".wpforo-quote").remove(); |
| 520 |
$(".wpforo-edit").remove(); |
| 521 |
} |
| 522 |
$('#wpforo-load').invisible(); |
| 523 |
}); |
| 524 |
}); |
| 525 |
|
| 526 |
wpforo_wrap.on('click','.wpforo-open', function(){ |
| 527 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 528 |
var status_value = 'closed'; |
| 529 |
var postid_value = $(this).attr('id'); |
| 530 |
var postid = postid_value.replace("wpfclose", ""); |
| 531 |
$.ajax({ |
| 532 |
type: 'POST', |
| 533 |
url: wpf_ajax_obj.url, |
| 534 |
data:{ |
| 535 |
postid: postid, |
| 536 |
status: status_value, |
| 537 |
action: 'wpforo_close_ajax' |
| 538 |
} |
| 539 |
}).done(function(response){ |
| 540 |
if(response != 0){ |
| 541 |
/*$("#" + postid_value).removeClass('wpforo-open').addClass('wpforo-close'); |
| 542 |
$("#closeicon" + postid).removeClass('fa-unlock').addClass('fa-lock'); |
| 543 |
$("#closetext" + postid).text( ' ' + wpforo_phrase('Close') );*/ |
| 544 |
window.location.assign(response); |
| 545 |
} |
| 546 |
$('#wpforo-load').invisible(); |
| 547 |
|
| 548 |
}); |
| 549 |
}); |
| 550 |
|
| 551 |
|
| 552 |
// Edit |
| 553 |
wpforo_wrap.on('click','.wpforo-edit', function(){ |
| 554 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 555 |
|
| 556 |
var phrase = wpforo_phrase('Edit post'); |
| 557 |
phrase = phrase.charAt(0).toUpperCase() + phrase.slice(1); |
| 558 |
$("#wpf-reply-form-title").html( phrase ); |
| 559 |
var postid_value = $(this).attr('id'); |
| 560 |
var is_topic = postid_value.indexOf("topic"); |
| 561 |
|
| 562 |
if(is_topic == -1){ |
| 563 |
var postid = postid_value.replace("wpfedit", ""); |
| 564 |
}else{ |
| 565 |
var postid = postid_value.replace("wpfedittopicpid", ""); |
| 566 |
} |
| 567 |
$.ajax({ |
| 568 |
type: 'POST', |
| 569 |
url: wpf_ajax_obj.url, |
| 570 |
data: { |
| 571 |
postid: postid, |
| 572 |
action: 'wpforo_edit_ajax' |
| 573 |
} |
| 574 |
}).done(function(response){ |
| 575 |
if(response != 0){ |
| 576 |
try{ |
| 577 |
response = $.parseJSON(response); |
| 578 |
}catch(e){ |
| 579 |
console.log(e); |
| 580 |
} |
| 581 |
tinyMCE.activeEditor.setContent( response.body ); |
| 582 |
$( ".wpf-topic-sbs" ).hide(); |
| 583 |
$( "#wpf-topic-sbs" ).prop("disabled", true); |
| 584 |
|
| 585 |
$( "#wpf_formaction" ).val( 'edit' ); |
| 586 |
$( "#wpf_formpostid" ).val( postid ); |
| 587 |
$( "#wpf_formbutton" ).val( wpforo_phrase('Update') ); |
| 588 |
$( 'html, body' ).animate({scrollTop: $("#wpf-form-wrapper").offset().top}, 1000); |
| 589 |
if(is_topic == -1){ |
| 590 |
$( "#wpf_title").val( response.post_title ); |
| 591 |
$( "#wpf_formaction" ).attr('name', 'post[action]'); |
| 592 |
$( "#wpf_formbutton" ).attr('name', 'post[save]'); |
| 593 |
$( "#wpf_formtopicid" ).attr('name', 'post[topicid]'); |
| 594 |
$( "#wpf_title" ).attr('name', 'post[title]'); |
| 595 |
if( $( "#wpf_user_name" ).length ) { $( "#wpf_user_name" ).attr('name', 'post[name]'); } |
| 596 |
if( $( "#wpf_user_email" ).length ) { $( "#wpf_user_email" ).attr('name', 'post[email]'); } |
| 597 |
}else{ |
| 598 |
$( "#wpf_title").val( response.topic_title ); |
| 599 |
$( "#wpf_formaction" ).attr('name', 'topic[action]'); |
| 600 |
$( "#wpf_formbutton" ).attr('name', 'topic[save]'); |
| 601 |
$( "#wpf_formtopicid" ).attr('name', 'topic[topicid]'); |
| 602 |
$( "#wpf_title" ).attr('name', 'topic[title]'); |
| 603 |
if( $( "#wpf_user_name" ).length ) { $( "#wpf_user_name" ).attr('name', 'topic[name]'); } |
| 604 |
if( $( "#wpf_user_email" ).length ) { $( "#wpf_user_email" ).attr('name', 'topic[email]'); } |
| 605 |
} |
| 606 |
|
| 607 |
tinymce.execCommand('mceFocus',false,'postbody'); |
| 608 |
tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true); |
| 609 |
tinyMCE.activeEditor.selection.collapse(false); |
| 610 |
} |
| 611 |
|
| 612 |
$('#wpforo-load').invisible(); |
| 613 |
|
| 614 |
}); |
| 615 |
}); |
| 616 |
|
| 617 |
|
| 618 |
// Delete |
| 619 |
wpforo_wrap.on('click','.wpforo-delete', function(){ |
| 620 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 621 |
|
| 622 |
var ok = confirm(wpforo_ucwords( wpforo_phrase('are you sure you want to delete?') )); |
| 623 |
|
| 624 |
if (ok == true){ |
| 625 |
var postid_value = $(this).attr('id'); |
| 626 |
var is_topic = postid_value.indexOf("topic"); |
| 627 |
|
| 628 |
if(is_topic == -1){ |
| 629 |
var postid = postid_value.replace("wpfreplydelete", ""); |
| 630 |
var status_value = 'reply'; |
| 631 |
}else{ |
| 632 |
var postid = postid_value.replace("wpftopicdelete", ""); |
| 633 |
var status_value = 'topic'; |
| 634 |
} |
| 635 |
|
| 636 |
var forumid = $("input[type='hidden']#wpf_parent").val(); |
| 637 |
|
| 638 |
$.ajax({ |
| 639 |
type: 'POST', |
| 640 |
url: wpf_ajax_obj.url, |
| 641 |
data:{ |
| 642 |
forumid: forumid, |
| 643 |
postid: postid, |
| 644 |
status: status_value, |
| 645 |
action: 'wpforo_delete_ajax' |
| 646 |
} |
| 647 |
}).done(function(response){ |
| 648 |
try{ |
| 649 |
response = $.parseJSON(response); |
| 650 |
} catch (e) { |
| 651 |
console.log(e); |
| 652 |
} |
| 653 |
if( response.stat == 1 ){ |
| 654 |
if(is_topic == -1){ |
| 655 |
$('#post-'+response.postid).fadeOut().delay(200); |
| 656 |
}else{ |
| 657 |
window.location.assign(response.location); |
| 658 |
} |
| 659 |
$('#wpforo-load').invisible(); |
| 660 |
}else{ |
| 661 |
$('#wpforo-load').invisible(); |
| 662 |
} |
| 663 |
|
| 664 |
wpforo_notice_show(response.notice); |
| 665 |
}); |
| 666 |
}else{ |
| 667 |
$('#wpforo-load').invisible(); |
| 668 |
} |
| 669 |
}); |
| 670 |
|
| 671 |
|
| 672 |
// Subscribe |
| 673 |
wpforo_wrap.on('click','.wpf-subscribe-forum, .wpf-subscribe-topic', function(){ |
| 674 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 675 |
var type = ''; |
| 676 |
var status = 'subscribe'; |
| 677 |
var clases = $(this).attr('class'); |
| 678 |
|
| 679 |
if( clases.indexOf("wpf-subscribe-forum") > -1 ){ |
| 680 |
type = 'forum'; |
| 681 |
} |
| 682 |
if( clases.indexOf("wpf-subscribe-topic") > -1 ){ |
| 683 |
type = 'topic'; |
| 684 |
} |
| 685 |
|
| 686 |
var postid_value = $(this).attr('id'); |
| 687 |
var itemid = postid_value.replace("wpfsubscribe-", ""); |
| 688 |
|
| 689 |
$.ajax({ |
| 690 |
type: 'POST', |
| 691 |
url: wpf_ajax_obj.url, |
| 692 |
data: { |
| 693 |
itemid: itemid, |
| 694 |
type: type, |
| 695 |
status: status, |
| 696 |
action: 'wpforo_subscribe_ajax' |
| 697 |
} |
| 698 |
}).done(function(response){ |
| 699 |
try{ |
| 700 |
response = $.parseJSON(response); |
| 701 |
} catch (e) { |
| 702 |
console.log(e); |
| 703 |
} |
| 704 |
if( response.stat == 1 ){ |
| 705 |
$("#wpfsubscribe-" + itemid).removeClass('wpf-subscribe-' + type).addClass('wpf-unsubscribe-' + type); |
| 706 |
$("#wpfsubscribe-" + itemid).text( ' ' + wpforo_phrase('Unsubscribe') ); |
| 707 |
$('#wpforo-load').invisible(); |
| 708 |
}else{ |
| 709 |
$('#wpforo-load').invisible(); |
| 710 |
} |
| 711 |
|
| 712 |
wpforo_notice_show(response.notice); |
| 713 |
}); |
| 714 |
|
| 715 |
}); |
| 716 |
|
| 717 |
wpforo_wrap.on('click','.wpf-unsubscribe-forum, .wpf-unsubscribe-topic', function(){ |
| 718 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 719 |
var type = ''; |
| 720 |
var button_phrase = ''; |
| 721 |
var status = 'unsubscribe'; |
| 722 |
var clases = $(this).attr('class'); |
| 723 |
if( clases.indexOf("wpf-unsubscribe-forum") > -1 ){ |
| 724 |
type = 'forum'; |
| 725 |
button_phrase = wpforo_ucwords( wpforo_phrase('Subscribe for new topics') ); |
| 726 |
} |
| 727 |
if( clases.indexOf("wpf-unsubscribe-topic") > -1 ){ |
| 728 |
type = 'topic'; |
| 729 |
button_phrase = wpforo_ucwords( wpforo_phrase('Subscribe for new replies') ); |
| 730 |
} |
| 731 |
var postid_value = $(this).attr('id'); |
| 732 |
var itemid = postid_value.replace("wpfsubscribe-", ""); |
| 733 |
|
| 734 |
$.ajax({ |
| 735 |
type: 'POST', |
| 736 |
url: wpf_ajax_obj.url, |
| 737 |
data: { |
| 738 |
itemid: itemid, |
| 739 |
type: type, |
| 740 |
status: status, |
| 741 |
action: 'wpforo_subscribe_ajax' |
| 742 |
} |
| 743 |
}).done(function(response){ |
| 744 |
try{ |
| 745 |
response = $.parseJSON(response); |
| 746 |
} catch (e) { |
| 747 |
console.log(e); |
| 748 |
} |
| 749 |
if( response.stat == 1 ){ |
| 750 |
$("#wpfsubscribe-" + itemid).removeClass('wpf-unsubscribe-' + type).addClass('wpf-subscribe-' + type); |
| 751 |
$("#wpfsubscribe-" + itemid).text( ' ' + button_phrase ); |
| 752 |
$('#wpforo-load').invisible(); |
| 753 |
}else{ |
| 754 |
$('#wpforo-load').invisible(); |
| 755 |
} |
| 756 |
|
| 757 |
wpforo_notice_show(response.notice); |
| 758 |
}); |
| 759 |
}); |
| 760 |
|
| 761 |
wpforo_wrap.on('click', '.wpforo-tools', function () { |
| 762 |
var tools = $('#wpf_moderation_tools'); |
| 763 |
if( tools.is(':visible') ){ |
| 764 |
tools.slideUp(250, 'linear'); |
| 765 |
}else{ |
| 766 |
$("#wpf-msg-box").hide(); $('#wpforo-load').visible(); |
| 767 |
tools.find('.wpf-tool-tabs .wpf-tool-tab').removeClass('wpf-tt-active'); |
| 768 |
tools.find('.wpf-tool-tabs .wpf-tool-tab:first-child').addClass('wpf-tt-active'); |
| 769 |
wpforo_topic_tools_tab_load(); |
| 770 |
} |
| 771 |
}); |
| 772 |
|
| 773 |
wpforo_wrap.on('click', '#wpf_moderation_tools .wpf-tool-tabs .wpf-tool-tab:not(.wpf-tt-active)', function () { |
| 774 |
$("#wpf-msg-box").hide(); |
| 775 |
$(this).siblings('.wpf-tool-tab').removeClass('wpf-tt-active'); |
| 776 |
if( !$(this).hasClass('wpf-tt-active') ) $(this).addClass('wpf-tt-active'); |
| 777 |
wpforo_topic_tools_tab_load(); |
| 778 |
}); |
| 779 |
|
| 780 |
wpforo_topic_tools_tab_load(); |
| 781 |
}); |
| 782 |
|
| 783 |
function wpforo_ucwords (str) { |
| 784 |
return (str + '').replace(/^([a-z])|\s+([a-z])/, function ($1) { |
| 785 |
return $1.toUpperCase(); |
| 786 |
}); |
| 787 |
} |
| 788 |
|
| 789 |
function wpforo_topic_tools_tab_load() { |
| 790 |
var active_tab = jQuery('#wpf_moderation_tools').find('.wpf-tool-tab.wpf-tt-active'); |
| 791 |
if( active_tab.length ){ |
| 792 |
var active_tab_id = active_tab.attr('id'); |
| 793 |
if( active_tab_id ){ |
| 794 |
jQuery("#wpf-msg-box").hide(); |
| 795 |
jQuery('#wpf_tool_tab_content_wrap').html('<i class="fas fa-spinner fa-spin wpf-icon-spinner"></i>'); |
| 796 |
jQuery.ajax({ |
| 797 |
type: 'POST', |
| 798 |
url: wpf_ajax_obj.url, |
| 799 |
data: { |
| 800 |
active_tab_id: active_tab_id, |
| 801 |
action: 'wpforo_active_tab_content_ajax' |
| 802 |
} |
| 803 |
}).done(function(response){ |
| 804 |
if( response ){ |
| 805 |
jQuery('#wpf_tool_tab_content_wrap').html(response); |
| 806 |
jQuery('#wpf_moderation_tools').slideDown(400, 'linear'); |
| 807 |
} |
| 808 |
jQuery('#wpforo-load').invisible(); |
| 809 |
}); |
| 810 |
} |
| 811 |
} |
| 812 |
} |