1var MyBB = { 2 init: function() 3 { 4 $(function() 5 { 6 MyBB.pageLoaded(); 7 }); 8 9 return true; 10 }, 11 12 pageLoaded: function() 13 { 14 expandables.init(); 15 16 /* Create the Check All feature */ 17 $('[name="allbox"]').each(function(key, value) { 18 var allbox = this; 19 var checked = $(this).is(':checked'); 20 var checkboxes = $(this).closest('form').find(':checkbox').not('[name="allbox"]'); 21 22 checkboxes.on('change', function() { 23 if(checked && !$(this).prop('checked')) 24 { 25 checked = false; 26 $(allbox).trigger('change', ['item']); 27 } 28 }); 29 30 $(this).on('change', function(event, origin) { 31 checked = $(this).is(':checked'); 32 33 if(typeof(origin) == "undefined") 34 { 35 checkboxes.each(function() { 36 if(checked != $(this).is(':checked')) 37 { 38 $(this).prop('checked', checked).trigger('change'); 39 } 40 }); 41 } 42 }); 43 }); 44 45 // Initialise "initial focus" field if we have one 46 var initialfocus = $(".initial_focus"); 47 if(initialfocus.length) 48 { 49 initialfocus.trigger('focus'); 50 } 51 52 if(typeof(use_xmlhttprequest) != "undefined" && use_xmlhttprequest == 1) 53 { 54 mark_read_imgs = $(".ajax_mark_read"); 55 mark_read_imgs.each(function() 56 { 57 var element = $(this); 58 if(element.hasClass('forum_off') || element.hasClass('forum_offclose') || element.hasClass('forum_offlink') || element.hasClass('subforum_minioff') || element.hasClass('subforum_minioffclose') || element.hasClass('subforum_miniofflink') || (element.attr("title") && element.attr("title") == lang.no_new_posts)) return; 59 60 element.on('click', function() 61 { 62 MyBB.markForumRead(this); 63 }); 64 65 element.css("cursor", "pointer"); 66 if(element.attr("title")) 67 { 68 element.attr("title", element.attr("title") + " - "); 69 } 70 element.attr("title", element.attr("title") + lang.click_mark_read); 71 }); 72 } 73 74 if(typeof $.modal !== "undefined") 75 { 76 $(document).on($.modal.OPEN, function(event, modal) { 77 $("body").css("overflow", "hidden"); 78 if(initialfocus.length > 0) 79 { 80 initialfocus.trigger('focus'); 81 } 82 }); 83 84 $(document).on($.modal.CLOSE, function(event, modal) { 85 $("body").css("overflow", "auto"); 86 }); 87 } 88 89 $("a.referralLink").on('click', MyBB.showReferrals); 90 91 if($('.author_avatar').length) 92 { 93 $(".author_avatar img").on('error', function () { 94 $(this).unbind("error").closest('.author_avatar').remove(); 95 }); 96 } 97 }, 98 99 popupWindow: function(url, options, root) 100 { 101 if(!options) options = { fadeDuration: 250, zIndex: (typeof modal_zindex !== 'undefined' ? modal_zindex : 9999) } 102 if(root != true) 103 url = rootpath + url; 104 105 $.get(url, function(html) 106 { 107 $(html).appendTo('body').modal(options); 108 }); 109 }, 110 111 prompt: function(message, options) 112 { 113 var defaults = { fadeDuration: 250, zIndex: (typeof modal_zindex !== 'undefined' ? modal_zindex : 9999) }; 114 var buttonsText = ''; 115 116 for (var i in options.buttons) 117 { 118 buttonsText += templates.modal_button.replace('__title__', options.buttons[i].title); 119 } 120 121 var html = templates.modal.replace('__buttons__', buttonsText).replace('__message__', message); 122 var modal = $(html); 123 modal.modal($.extend(defaults, options)); 124 var buttons = modal.find('.modal_buttons > .button'); 125 buttons.on('click', function(e) 126 { 127 e.preventDefault(); 128 var index = $(this).index(); 129 if (options.submit(e, options.buttons[index].value) == false) 130 return; 131 132 $.modal.close(); 133 }); 134 135 if (buttons[0]) 136 { 137 modal.on($.modal.OPEN, function() 138 { 139 $(buttons[0]).trigger('focus'); 140 }); 141 } 142 143 return modal; 144 }, 145 146 deleteEvent: function(eid) 147 { 148 MyBB.prompt(deleteevent_confirm, { 149 buttons:[ 150 {title: yes_confirm, value: true}, 151 {title: no_confirm, value: false} 152 ], 153 submit: function(e,v,m,f){ 154 if(v == true) 155 { 156 var form = $("<form />", 157 { 158 method: "post", 159 action: "calendar.php", 160 style: "display: none;" 161 }); 162 163 form.append( 164 $("<input />", 165 { 166 name: "action", 167 type: "hidden", 168 value: "do_deleteevent" 169 }) 170 ); 171 172 if(my_post_key) 173 { 174 form.append( 175 $("<input />", 176 { 177 name: "my_post_key", 178 type: "hidden", 179 value: my_post_key 180 }) 181 ); 182 } 183 184 form.append( 185 $("<input />", 186 { 187 name: "eid", 188 type: "hidden", 189 value: eid 190 }) 191 ); 192 193 form.append( 194 $("<input />", 195 { 196 name: "delete", 197 type: "hidden", 198 value: 1 199 }) 200 ); 201 202 $("body").append(form); 203 form.trigger('submit'); 204 } 205 } 206 }); 207 }, 208 209 reputation: function(uid, pid) 210 { 211 if(!pid) 212 { 213 var pid = 0; 214 } 215 216 MyBB.popupWindow("/reputation.php?action=add&uid="+uid+"&pid="+pid+"&modal=1"); 217 }, 218 219 viewNotes: function(uid) 220 { 221 MyBB.popupWindow("/member.php?action=viewnotes&uid="+uid+"&modal=1"); 222 }, 223 224 getIP: function(pid) 225 { 226 MyBB.popupWindow("/moderation.php?action=getip&pid="+pid+"&modal=1"); 227 }, 228 229 getPMIP: function(pmid) 230 { 231 MyBB.popupWindow("/moderation.php?action=getpmip&pmid="+pmid+"&modal=1"); 232 }, 233 234 deleteReputation: function(uid, rid) 235 { 236 MyBB.prompt(delete_reputation_confirm, { 237 buttons:[ 238 {title: yes_confirm, value: true}, 239 {title: no_confirm, value: false} 240 ], 241 submit: function(e,v,m,f){ 242 if(v == true) 243 { 244 var form = $("<form />", 245 { 246 method: "post", 247 action: "reputation.php?action=delete", 248 style: "display: none;" 249 }); 250 251 form.append( 252 $("<input />", 253 { 254 name: "rid", 255 type: "hidden", 256 value: rid 257 }) 258 ); 259 260 if(my_post_key) 261 { 262 form.append( 263 $("<input />", 264 { 265 name: "my_post_key", 266 type: "hidden", 267 value: my_post_key 268 }) 269 ); 270 } 271 272 form.append( 273 $("<input />", 274 { 275 name: "uid", 276 type: "hidden", 277 value: uid 278 }) 279 ); 280 281 $("body").append(form); 282 form.trigger('submit'); 283 } 284 } 285 }); 286 287 return false;
288 }, 289 290 whoPosted: function(tid, sortby) 291 { 292 var sort = "", url, body; 293 294 if(typeof sortby === "undefined") 295 { 296 sortby = ""; 297 } 298 299 if(sortby == "username") 300 { 301 sort = "&sort=" + sortby; 302 } 303 url = "/misc.php?action=whoposted&tid="+tid+sort+"&modal=1"; 304 305 // if the modal is already open just replace the contents 306 if($.modal.isActive()) 307 { 308 // don't waste a query if we are already sorted correctly 309 if(sortby == MyBB.whoPostedSort) 310 { 311 return; 312 } 313 314 MyBB.whoPostedSort = sortby; 315 316 $.get(rootpath + url, function(html) 317 { 318 // just replace the inner div 319 body = $(html).children("div"); 320 $("div.modal").children("div").replaceWith(body); 321 }); 322 return; 323 } 324 MyBB.whoPostedSort = ""; 325 MyBB.popupWindow(url); 326 }, 327 328 markForumRead: function(event) 329 { 330 var element = $(event); 331 if(!element.length) 332 { 333 return false; 334 } 335 var fid = element.attr("id").replace("mark_read_", ""); 336 if(!fid) 337 { 338 return false; 339 } 340 341 $.ajax( 342 { 343 url: 'misc.php?action=markread&fid=' + fid + '&ajax=1&my_post_key=' + my_post_key, 344 async: true, 345 success: function (request) 346 { 347 MyBB.forumMarkedRead(fid, request); 348 } 349 }); 350 }, 351 352 forumMarkedRead: function(fid, request) 353 { 354 if(request == 1) 355 { 356 var markreadfid = $("#mark_read_"+fid); 357 if(markreadfid.hasClass('subforum_minion')) 358 { 359 markreadfid.removeClass('subforum_minion').addClass('subforum_minioff'); 360 } 361 else 362 { 363 markreadfid.removeClass('forum_on').addClass('forum_off'); 364 } 365 markreadfid.css("cursor", "default").attr("title", lang.no_new_posts); 366 } 367 }, 368 369 unHTMLchars: function(text) 370 { 371 text = text.replace(/</g, "<"); 372 text = text.replace(/>/g, ">"); 373 text = text.replace(/ /g, " "); 374 text = text.replace(/"/g, "\""); 375 text = text.replace(/&/g, "&"); 376 return text; 377 }, 378 379 HTMLchars: function(text) 380 { 381 text = text.replace(new RegExp("&(?!#[0-9]+;)", "g"), "&"); 382 text = text.replace(/</g, "<"); 383 text = text.replace(/>/g, ">"); 384 text = text.replace(/"/g, """); 385 return text; 386 }, 387 388 changeLanguage: function() 389 { 390 form = $("#lang_select"); 391 if(!form.length) 392 { 393 return false; 394 } 395 form.trigger('submit'); 396 }, 397 398 changeTheme: function() 399 { 400 form = $("#theme_select"); 401 if(!form.length) 402 { 403 return false; 404 } 405 form.trigger('submit'); 406 }, 407 408 detectDSTChange: function(timezone_with_dst) 409 { 410 var date = new Date(); 411 var local_offset = date.getTimezoneOffset() / 60; 412 if(Math.abs(parseInt(timezone_with_dst) + local_offset) == 1) 413 { 414 $.ajax( 415 { 416 url: 'misc.php?action=dstswitch&ajax=1', 417 async: true, 418 method: 'post', 419 error: function (request) 420 { 421 if(use_xmlhttprequest != 1) 422 { 423 var form = $("<form />", 424 { 425 method: "post", 426 action: "misc.php", 427 style: "display: none;" 428 }); 429 430 form.append( 431 $("<input />", 432 { 433 name: "action", 434 type: "hidden", 435 value: "dstswitch" 436 }) 437 ); 438 439 $("body").append(form); 440 form.trigger('submit'); 441 } 442 } 443 }); 444 } 445 }, 446 447 dismissPMNotice: function(bburl) 448 { 449 var pm_notice = $("#pm_notice"); 450 if(!pm_notice.length) 451 { 452 return false; 453 } 454 455 if(use_xmlhttprequest != 1) 456 { 457 return true; 458 } 459 460 $.ajax( 461 { 462 type: 'post', 463 url: bburl + 'private.php?action=dismiss_notice', 464 data: { ajax: 1, my_post_key: my_post_key }, 465 async: true 466 }); 467 pm_notice.remove(); 468 return false; 469 }, 470 471 submitReputation: function(uid, pid, del) 472 { 473 // Get form, serialize it and send it 474 var datastring = $(".reputation_"+uid+"_"+pid).serialize(); 475 476 if(del == 1) 477 datastring = datastring + '&delete=1'; 478 479 $.ajax({ 480 type: "POST", 481 url: "reputation.php?modal=1", 482 data: datastring, 483 dataType: "html", 484 success: function(data) { 485 // Replace modal HTML (we have to access by class because the modals are appended to the end of the body, and when we get by class we get the last element of that class - which is what we want) 486 $(".modal_"+uid+"_"+pid).fadeOut('slow', function() { 487 $(".modal_"+uid+"_"+pid).html(data); 488 $(".modal_"+uid+"_"+pid).fadeIn('slow'); 489 $(".modal").fadeIn('slow'); 490 }); 491 }, 492 error: function(){ 493 alert(lang.unknown_error); 494 } 495 }); 496 497 return false;
498 }, 499 500 deleteAnnouncement: function(data) 501 { 502 MyBB.prompt(announcement_quickdelete_confirm, { 503 buttons:[ 504 {title: yes_confirm, value: true}, 505 {title: no_confirm, value: false} 506 ], 507 submit: function(e,v,m,f){ 508 if(v == true) 509 { 510 window.location=data.href.replace('action=delete_announcement','action=do_delete_announcement'); 511 } 512 } 513 }); 514 515 return false; 516 }, 517 518 showReferrals: function(e) 519 { 520 var idPieces, uid; 521 522 e.preventDefault(); 523 524 if(typeof this.id == "undefined") 525 { 526 return false; 527 } 528 529 idPieces = this.id.split("_"); 530 uid = parseInt(idPieces[idPieces.length - 1], 10); 531 532 if(uid <= 0) 533 { 534 return false; 535 } 536 537 MyBB.popupWindow("/xmlhttp.php?action=get_referrals&uid="+uid); 538 }, 539 540 // Fixes https://github.com/mybb/mybb/issues/1232 541 select2: function() 542 { 543 if(typeof $.fn.select2 !== "undefined") 544 { 545 $.extend($.fn.select2.defaults, { 546 formatMatches: function (matches) { 547 if(matches == 1) 548 { 549 return lang.select2_match; 550 } 551 else 552 { 553 return lang.select2_matches.replace('{1}',matches); 554 } 555 }, 556 formatNoMatches: function () { 557 return lang.select2_nomatches; 558 }, 559 formatInputTooShort: function (input, min) { 560 var n = min - input.length; 561 if( n == 1) 562 { 563 return lang.select2_inputtooshort_single; 564 } 565 else 566 { 567 return lang.select2_inputtooshort_plural.replace('{1}', n); 568 } 569 }, 570 formatInputTooLong: function (input, max) { 571 var n = input.length - max; 572 if( n == 1) 573 { 574 return lang.select2_inputtoolong_single; 575 } 576 else 577 { 578 return lang.select2_inputtoolong_plural.replace('{1}', n); 579 } 580 }, 581 formatSelectionTooBig: function (limit) { 582 if( limit == 1) 583 { 584 return lang.select2_selectiontoobig_single; 585 } 586 else 587 { 588 return lang.select2_selectiontoobig_plural.replace('{1}', limit); 589 } 590 }, 591 formatLoadMore: function (pageNumber) { 592 return lang.select2_loadmore; 593 }, 594 formatSearching: function () { 595 return lang.select2_searching; 596 } 597 }); 598 } 599 } 600}; 601 602var Cookie = { 603 get: function(name) 604 { 605 name = cookiePrefix + name; 606 return Cookies.get(name); 607 }, 608 609 set: function(name, value, expires) 610 { 611 name = cookiePrefix + name; 612 if(!expires) 613 { 614 expires = 315360000; // 10*365*24*60*60 => 10 years 615 } 616 617 expire = new Date(); 618 expire.setTime(expire.getTime()+(expires*1000)); 619 620 options = { 621 expires: expire, 622 path: cookiePath, 623 domain: cookieDomain, 624 secure: cookieSecureFlag == true, 625 }; 626 627 return Cookies.set(name, value, options); 628 }, 629 630 unset: function(name) 631 { 632 name = cookiePrefix + name; 633 634 options = { 635 path: cookiePath, 636 domain: cookieDomain 637 }; 638 return Cookies.remove(name, options); 639 } 640}; 641 642var expandables = { 643 644 init: function() 645 { 646 var expanders = $(".expcolimage .expander"); 647 if(expanders.length) 648 { 649 expanders.each(function() 650 { 651 var expander = $(this); 652 if(expander.attr("id") == false) 653 { 654 return; 655 } 656 657 expander.on('click', function() 658 { 659 controls = expander.attr("id").replace("_img", ""); 660 expandables.expandCollapse(this, controls); 661 }); 662 663 if(MyBB.browser == "ie") 664 { 665 expander.css("cursor", "hand"); 666 } 667 else 668 { 669 expander.css("cursor", "pointer"); 670 } 671 }); 672 } 673 }, 674 675 expandCollapse: function(e, controls) 676 { 677 element = $(e); 678 679 if(!element || controls == false) 680 { 681 return false; 682 } 683 var expandedItem = $("#"+controls+"_e"); 684 var collapsedItem = $("#"+controls+"_c"); 685 686 if(expandedItem.length && collapsedItem.length) 687 { 688 // Expanding 689 if(expandedItem.is(":hidden")) 690 { 691 expandedItem.toggle("fast"); 692 collapsedItem.toggle("fast"); 693 this.saveCollapsed(controls); 694 } 695 // Collapsing 696 else 697 { 698 expandedItem.toggle("fast"); 699 collapsedItem.toggle("fast"); 700 this.saveCollapsed(controls, 1); 701 } 702 } 703 else if(expandedItem.length && !collapsedItem.length) 704 { 705 // Expanding 706 if(expandedItem.is(":hidden")) 707 { 708 expandedItem.toggle("fast"); 709 element.attr("src", element.attr("src").replace(/collapse_collapsed\.(gif|jpg|jpeg|bmp|png)$/i, "collapse.$1")) 710 .attr("alt", "[-]") 711 .attr("title", "[-]"); 712 element.parent().parent('td').removeClass('tcat_collapse_collapsed'); 713 element.parent().parent('.thead').removeClass('thead_collapsed'); 714 this.saveCollapsed(controls); 715 } 716 // Collapsing 717 else 718 {
719 expandedItem.toggle("fast"); 720 element.attr("src", element.attr("src").replace(/collapse\.(gif|jpg|jpeg|bmp|png)$/i, "collapse_collapsed.$1")) 721 .attr("alt", "[+]") 722 .attr("title", "[+]"); 723 element.parent().parent('td').addClass('tcat_collapse_collapsed'); 724 element.parent().parent('.thead').addClass('thead_collapsed'); 725 this.saveCollapsed(controls, 1); 726 } 727 } 728 return true; 729 }, 730 731 saveCollapsed: function(id, add) 732 { 733 var saved = []; 734 var newCollapsed = []; 735 var collapsed = Cookie.get('collapsed'); 736 737 if(collapsed) 738 { 739 saved = collapsed.split("|"); 740 741 $.each(saved, function(intIndex, objValue) 742 { 743 if(objValue != id && objValue != "") 744 { 745 newCollapsed[newCollapsed.length] = objValue; 746 } 747 }); 748 } 749 750 if(add == 1) 751 { 752 newCollapsed[newCollapsed.length] = id; 753 } 754 Cookie.set('collapsed', newCollapsed.join("|")); 755 } 756}; 757 758/* Lang this! */ 759var lang = { 760 761}; 762 763/* add keepelement to jquery-modal plugin */ 764(function($) { 765 if(typeof $.modal != 'undefined') 766 { 767 $.modal.defaults.keepelement = false; 768 769 $.modal.prototype.oldCloseFunction = $.modal.prototype.close; 770 $.modal.prototype.close = function() 771 { 772 this.oldCloseFunction(); 773 774 // Deletes the element (multi-modal feature: e.g. when you click on multiple report buttons, you will want to see different content for each) 775 if(!this.options.keepelement) 776 { 777 this.$elm.remove(); 778 } 779 }; 780 } 781})(jQuery); 782 783 784MyBB.init();
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.