[ Index ] |
PHP Cross Reference of MyBB 1.8.37 |
[Summary view] [Print] [Text view]
1 var Thread = { 2 init: function() 3 { 4 $(function(){ 5 Thread.quickEdit(); 6 Thread.initQuickReply(); 7 Thread.initMultiQuote(); 8 9 // Set spinner image 10 $('#quickreply_spinner img').attr('src', spinner_image); 11 }); 12 }, 13 14 initMultiQuote: function() 15 { 16 var quoted = Cookie.get('multiquote'); 17 if(quoted) 18 { 19 var post_ids = quoted.split("|"); 20 21 $.each(post_ids, function(key, value) { 22 var mquote_a = $("#multiquote_"+value).closest('a'); 23 if(mquote_a.length) 24 { 25 mquote_a.removeClass('postbit_multiquote').addClass('postbit_multiquote_on'); 26 } 27 }); 28 29 var mquote_quick = $('#quickreply_multiquote'); 30 if(mquote_quick.length) 31 { 32 mquote_quick.show(); 33 } 34 } 35 return true; 36 }, 37 38 multiQuote: function(pid) 39 { 40 var new_post_ids = new Array(); 41 var quoted = Cookie.get("multiquote"); 42 var is_new = true; 43 var deleted = false; 44 if($("#pid" + pid).next("div.post").hasClass('deleted_post')) 45 { 46 $.jGrowl(lang.post_deleted_error, {theme:'jgrowl_error'}); 47 deleted = true; 48 } 49 50 if(quoted && !deleted) 51 { 52 var post_ids = quoted.split("|"); 53 54 $.each(post_ids, function(key, post_id) { 55 if(post_id != pid && post_id != '') 56 { 57 new_post_ids[new_post_ids.length] = post_id; 58 } 59 else if(post_id == pid) 60 { 61 is_new = false; 62 } 63 }); 64 } 65 66 var mquote_a = $("#multiquote_"+pid).closest('a') 67 if(is_new == true && !deleted) 68 { 69 new_post_ids[new_post_ids.length] = pid; 70 mquote_a.removeClass('postbit_multiquote').addClass('postbit_multiquote_on'); 71 } 72 else 73 { 74 mquote_a.removeClass('postbit_multiquote_on').addClass('postbit_multiquote'); 75 } 76 77 var mquote_quick = $('#quickreply_multiquote'); 78 if(mquote_quick.length) 79 { 80 if(new_post_ids.length) 81 { 82 mquote_quick.show(); 83 } 84 else 85 { 86 mquote_quick.hide(); 87 } 88 } 89 Cookie.set("multiquote", new_post_ids.join("|")); 90 }, 91 92 loadMultiQuoted: function() 93 { 94 if(use_xmlhttprequest == 1) 95 { 96 // Spinner! 97 var mquote_spinner = $('#quickreply_spinner'); 98 mquote_spinner.show(); 99 100 $.ajax( 101 { 102 url: 'xmlhttp.php?action=get_multiquoted&load_all=1', 103 type: 'get', 104 complete: function (request, status) 105 { 106 Thread.multiQuotedLoaded(request, status); 107 108 // Get rid of spinner 109 mquote_spinner.hide(); 110 } 111 }); 112 113 return false; 114 } 115 else 116 { 117 return true; 118 } 119 }, 120 121 multiQuotedLoaded: function(request) 122 { 123 var json = JSON.parse(request.responseText); 124 if(typeof json == 'object') 125 { 126 if(json.hasOwnProperty("errors")) 127 { 128 $.each(json.errors, function(i, message) 129 { 130 $.jGrowl(lang.post_fetch_error + ' ' + message, {theme:'jgrowl_error'}); 131 }); 132 return false; 133 } 134 } 135 136 if(typeof MyBBEditor !== 'undefined' && MyBBEditor !== null) 137 { 138 MyBBEditor.insert(json.message); 139 } 140 else 141 { 142 var id = $('#message'); 143 if(id.value) 144 { 145 id.value += "\n"; 146 } 147 id.val(id.val() + json.message); 148 } 149 150 Thread.clearMultiQuoted(); 151 $('#quickreply_multiquote').hide(); 152 $('#quoted_ids').val('all'); 153 154 $('#message').trigger('focus'); 155 }, 156 157 clearMultiQuoted: function() 158 { 159 $('#quickreply_multiquote').hide(); 160 var quoted = Cookie.get("multiquote"); 161 if(quoted) 162 { 163 var post_ids = quoted.split("|"); 164 165 $.each(post_ids, function(key, post_id) { 166 var mquote_a = $("#multiquote_"+post_id).closest('a'); 167 if(mquote_a.length) 168 { 169 mquote_a.removeClass('postbit_multiquote_on').addClass('postbit_multiquote'); 170 } 171 }); 172 } 173 Cookie.unset('multiquote'); 174 }, 175 176 quickEdit: function(el) 177 { 178 if(typeof el === 'undefined' || !el.length) el = '.post_body'; 179 180 $(el).each(function() 181 { 182 // Take pid out of the id attribute 183 id = $(this).attr('id'); 184 pid = id.replace( /[^\d.]/g, ''); 185 186 $('#pid_' + pid).editable("xmlhttp.php?action=edit_post&do=update_post&pid=" + pid + '&my_post_key=' + my_post_key, 187 { 188 indicator: spinner, 189 loadurl: "xmlhttp.php?action=edit_post&do=get_post&pid=" + pid, 190 type: "textarea", 191 rows: 12, 192 submit: lang.save_changes, 193 cancel: lang.cancel_edit, 194 placeholder: "", 195 event: "edit" + pid, // Triggered by the event "edit_[pid]", 196 onblur: "ignore", 197 dataType: "json", 198 submitdata: function (values, settings) 199 { 200 id = $(this).attr('id'); 201 pid = id.replace( /[^\d.]/g, ''); 202 $("#quickedit_" + pid + "_editreason_original").val($("#quickedit_" + pid + "_editreason").val()); 203 return { 204 editreason: $("#quickedit_" + pid + "_editreason").val() 205 } 206 }, 207 callback: function(values, settings) 208 { 209 id = $(this).attr('id'); 210 pid = id.replace( /[^\d.]/g, ''); 211 212 var json = JSON.parse(values); 213 if(typeof json == 'object') 214 { 215 if(json.hasOwnProperty("errors")) 216 { 217 $(".jGrowl").jGrowl("close"); 218 219 $.each(json.errors, function(i, message) 220 { 221 $.jGrowl(lang.quick_edit_update_error + ' ' + message, {theme:'jgrowl_error'}); 222 }); 223 $(this).html($('#pid_' + pid + '_temp').html()); 224 } 225 else if(json.hasOwnProperty("moderation_post")) 226 { 227 $(".jGrowl").jGrowl("close"); 228 229 $(this).html(json.message); 230 231 // No more posts on this page? (testing for "1" as the last post would be removed here) 232 if($('.post').length == 1) 233 { 234 alert(json.moderation_post); 235 window.location = json.url; 236 } 237 else 238 { 239 $.jGrowl(json.moderation_post, {theme:'jgrowl_success'}); 240 $('#post_' + pid).slideToggle(); 241 } 242 } 243 else if(json.hasOwnProperty("moderation_thread")) 244 { 245 $(".jGrowl").jGrowl("close"); 246 247 $(this).html(json.message); 248 249 alert(json.moderation_thread); 250 251 // Redirect user to forum 252 window.location = json.url; 253 } 254 else 255 { 256 // Change html content 257 $(this).html(json.message); 258 $('#edited_by_' + pid).html(json.editedmsg); 259 } 260 } 261 else 262 { 263 // Change html content 264 $(this).html(json.message); 265 $('#edited_by_' + pid).html(json.editedmsg); 266 } 267 $('#pid_' + pid + '_temp').remove(); 268 } 269 }); 270 }); 271 272 $('.quick_edit_button').each(function() 273 { 274 $(this).on("click", function(e) 275 { 276 e.preventDefault(); 277 278 // Take pid out of the id attribute 279 id = $(this).attr('id'); 280 pid = id.replace( /[^\d.]/g, ''); 281 if($("#pid" + pid).next("div.post").hasClass('deleted_post')) 282 { 283 $.jGrowl(lang.post_deleted_error, {theme:'jgrowl_error'}); 284 return false; 285 } 286 287 // Create a copy of the post 288 if($('#pid_' + pid + '_temp').length == 0) 289 { 290 $('#pid_' + pid).clone().attr('id','pid_' + pid + '_temp').appendTo("body").hide(); 291 } 292 293 // Trigger the edit event 294 $('#pid_' + pid).trigger("edit" + pid); 295 296 // Edit Reason 297 $('#pid_' + pid + ' textarea').attr('id', 'quickedit_' + pid); 298 if(allowEditReason == 1 && $('#quickedit_' + pid + '_editreason').length == 0) 299 { 300 edit_el = $('#editreason_' + pid + '_original').clone().attr('id','editreason_' + pid); 301 edit_el.children('#quickedit_' + pid + '_editreason_original').attr('id','quickedit_' + pid + '_editreason'); 302 edit_el.insertAfter('#quickedit_' + pid).show(); 303 } 304 }); 305 }); 306 307 return false; 308 }, 309 310 initQuickReply: function() 311 { 312 if($('#quick_reply_form').length && use_xmlhttprequest == 1) 313 { 314 // Bind closing event to our popup menu 315 $('#quick_reply_submit').on('click', function(e) { 316 return Thread.quickReply(e); 317 }); 318 } 319 }, 320 321 quickReply: function(e) 322 { 323 e.stopPropagation(); 324 325 if(this.quick_replying) 326 { 327 return false; 328 } 329 330 this.quick_replying = 1; 331 var post_body = $('#quick_reply_form').serialize(); 332 333 // Spinner! 334 var qreply_spinner = $('#quickreply_spinner'); 335 qreply_spinner.show(); 336 337 $.ajax( 338 { 339 url: 'newreply.php?ajax=1', 340 type: 'post', 341 data: post_body, 342 dataType: 'html', 343 complete: function (request, status) 344 { 345 Thread.quickReplyDone(request, status); 346 347 // Get rid of spinner 348 qreply_spinner.hide(); 349 } 350 }); 351 352 return false; 353 }, 354 355 quickReplyDone: function(request, status) 356 { 357 this.quick_replying = 0; 358 359 var json = JSON.parse(request.responseText); 360 if(typeof json == 'object') 361 { 362 if(json.hasOwnProperty("errors")) 363 { 364 $(".jGrowl").jGrowl("close"); 365 366 $.each(json.errors, function(i, message) 367 { 368 $.jGrowl(lang.quick_reply_post_error + ' ' + message, {theme:'jgrowl_error'}); 369 }); 370 $('#quickreply_spinner').hide(); 371 } 372 } 373 374 if($('#captcha_trow').length) 375 { 376 cap = json.data.match(/^<captcha>([0-9a-zA-Z]+)(\|([0-9a-zA-Z]+)|)<\/captcha>/); 377 if(cap) 378 { 379 json.data = json.data.replace(/^<captcha>(.*)<\/captcha>/, ''); 380 381 if($("#captcha_img").length) 382 { 383 if(cap[1]) 384 { 385 imghash = cap[1]; 386 $('#imagehash').val(imghash); 387 if(cap[3]) 388 { 389 $('#imagestring').attr('type', 'hidden').val(cap[3]); 390 // hide the captcha 391 $('#captcha_trow').hide(); 392 } 393 else 394 { 395 $('#captcha_img').attr('src', "captcha.php?action=regimage&imagehash="+imghash); 396 $('#imagestring').attr('type', 'text').val(''); 397 $('#captcha_trow').show(); 398 } 399 } 400 } 401 } 402 } 403 404 if(json.hasOwnProperty("errors")) 405 return false; 406 407 if(json.data.match(/id="post_([0-9]+)"/)) 408 { 409 var pid = json.data.match(/id="post_([0-9]+)"/)[1]; 410 var post = document.createElement("div"); 411 412 $('#posts').append(json.data); 413 414 if (typeof inlineModeration != "undefined") // Guests don't have this object defined 415 $("#inlinemod_" + pid).on('change', inlineModeration.checkItem); 416 417 Thread.quickEdit("#pid_" + pid); 418 419 // Eval javascript 420 $(json.data).filter("script").each(function(e) { 421 eval($(this).text()); 422 }); 423 424 $('#quick_reply_form')[0].reset(); 425 426 var lastpid = $('#lastpid'); 427 if(lastpid.length) 428 { 429 lastpid.val(pid); 430 } 431 } 432 else 433 { 434 // Eval javascript 435 $(json.data).filter("script").each(function(e) { 436 eval($(this).text()); 437 }); 438 } 439 440 $(".jGrowl").jGrowl("close"); 441 }, 442 443 showIgnoredPost: function(pid) 444 { 445 $('#ignored_post_'+pid).slideToggle("slow"); 446 $('#post_'+pid).slideToggle("slow"); 447 }, 448 449 showDeletedPost: function(pid) 450 { 451 $('#deleted_post_'+pid).slideToggle("slow"); 452 $('#post_'+pid).slideToggle("slow"); 453 }, 454 455 deletePost: function(pid) 456 { 457 MyBB.prompt(quickdelete_confirm, { 458 buttons:[ 459 {title: yes_confirm, value: true}, 460 {title: no_confirm, value: false} 461 ], 462 submit: function(e,v,m,f){ 463 if(v == true) 464 { 465 $.ajax( 466 { 467 url: 'editpost.php?ajax=1&action=deletepost&delete=1&my_post_key='+my_post_key+'&pid='+pid, 468 type: 'post', 469 complete: function (request, status) 470 { 471 var json = JSON.parse(request.responseText); 472 if(json.hasOwnProperty("errors")) 473 { 474 $.each(json.errors, function(i, message) 475 { 476 $.jGrowl(lang.quick_delete_error + ' ' + message, {theme:'jgrowl_error'}); 477 }); 478 } 479 else if(json.hasOwnProperty("data")) 480 { 481 // Soft deleted 482 if(json.data == 1) 483 { 484 // Change CSS class of div 'post_[pid]' 485 $("#post_"+pid).addClass("unapproved_post deleted_post"); 486 if(json.first == 1) 487 { 488 $("#quick_reply_form, .thread_tools, .new_reply_button, .inline_rating").hide(); 489 $("#moderator_options_selector option.option_mirage").attr("disabled","disabled"); 490 $("#moderator_options_selector option[value='softdeletethread']").val("restorethread").text(lang.restore_thread); 491 } 492 493 $.jGrowl(lang.quick_delete_success, {theme:'jgrowl_success'}); 494 } 495 else if(json.data == 2) 496 { 497 // Actually deleted 498 $('#post_'+pid).slideToggle("slow"); 499 500 $.jGrowl(lang.quick_delete_success, {theme:'jgrowl_success'}); 501 } else if(json.data == 3) 502 { 503 // deleted thread --> redirect 504 505 if(!json.hasOwnProperty("url")) 506 { 507 $.jGrowl(lang.unknown_error, {theme:'jgrowl_error'}); 508 } 509 510 // set timeout for redirect 511 window.setTimeout(function() 512 { 513 window.location = json.url; 514 }, 3000); 515 516 // print success message 517 $.jGrowl(lang.quick_delete_thread_success, {theme:'jgrowl_success'}); 518 } 519 } 520 else 521 { 522 $.jGrowl(lang.unknown_error, {theme:'jgrowl_error'}); 523 } 524 } 525 }); 526 } 527 } 528 }); 529 530 return false; 531 }, 532 533 534 restorePost: function(pid) 535 { 536 MyBB.prompt(quickrestore_confirm, { 537 buttons:[ 538 {title: yes_confirm, value: true}, 539 {title: no_confirm, value: false} 540 ], 541 submit: function(e,v,m,f){ 542 if(v == true) 543 { 544 $.ajax( 545 { 546 url: 'editpost.php?ajax=1&action=restorepost&restore=1&my_post_key='+my_post_key+'&pid='+pid, 547 type: 'post', 548 complete: function (request, status) 549 { 550 var json = JSON.parse(request.responseText); 551 if(json.hasOwnProperty("errors")) 552 { 553 $.each(json.errors, function(i, message) 554 { 555 $.jGrowl(lang.quick_restore_error + ' ' + message, {theme:'jgrowl_error'}); 556 }); 557 } 558 else if(json.hasOwnProperty("data")) 559 { 560 // Change CSS class of div 'post_[pid]' 561 $("#post_"+pid).removeClass("unapproved_post deleted_post"); 562 if(json.first == 1) 563 { 564 $("#quick_reply_form, .thread_tools, .new_reply_button, .inline_rating").show(); 565 $("#moderator_options_selector option.option_mirage").prop("disabled", false); 566 $("#moderator_options_selector option[value='restorethread']").val("softdeletethread").text(lang.softdelete_thread); 567 } 568 569 $.jGrowl(lang.quick_restore_success, {theme:'jgrowl_success'}); 570 } 571 else 572 { 573 $.jGrowl(lang.unknown_error, {theme:'jgrowl_error'}); 574 } 575 } 576 }); 577 } 578 } 579 }); 580 581 return false; 582 }, 583 584 viewNotes: function(tid) 585 { 586 MyBB.popupWindow("/moderation.php?action=viewthreadnotes&tid="+tid+"&modal=1"); 587 } 588 }; 589 590 Thread.init();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |