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