1/* global phpbb */ 2 3/** 4* phpBB3 forum functions 5*/ 6 7/** 8* Find a member 9*/ 10function find_username(url) { 11 'use strict'; 12 13 popup(url, 760, 570, '_usersearch'); 14 return false; 15} 16 17/** 18* Window popup 19*/ 20function popup(url, width, height, name) { 21 'use strict'; 22 23 if (!name) { 24 name = '_popup'; 25 } 26 27 window.open(url.replace(/&/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width); 28 return false; 29} 30 31/** 32* Jump to page 33*/ 34function pageJump(item) { 35 'use strict'; 36 37 var page = parseInt(item.val(), 10), 38 perPage = item.attr('data-per-page'), 39 baseUrl = item.attr('data-base-url'), 40 startName = item.attr('data-start-name'); 41 42 if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) { 43 if (baseUrl.indexOf('?') === -1) { 44 document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage); 45 } else { 46 document.location.href = baseUrl.replace(/&/g, '&') + '&' + startName + '=' + ((page - 1) * perPage); 47 } 48 } 49} 50 51/** 52* Mark/unmark checklist 53* id = ID of parent container, name = name prefix, state = state [true/false] 54*/ 55function marklist(id, name, state) { 56 'use strict'; 57 58 jQuery('#' + id + ' input[type=checkbox][name]').each(function() { 59 var $this = jQuery(this); 60 if ($this.attr('name').substr(0, name.length) === name) { 61 $this.prop('checked', state); 62 } 63 }); 64} 65 66/** 67* Resize viewable area for attached image or topic review panel (possibly others to come) 68* e = element 69*/ 70function viewableArea(e, itself) { 71 'use strict'; 72 73 if (!e) { 74 return; 75 } 76 77 if (!itself) { 78 e = e.parentNode; 79 } 80 81 if (!e.vaHeight) { 82 // Store viewable area height before changing style to auto 83 e.vaHeight = e.offsetHeight; 84 e.vaMaxHeight = e.style.maxHeight; 85 e.style.height = 'auto'; 86 e.style.maxHeight = 'none'; 87 e.style.overflow = 'visible'; 88 } else { 89 // Restore viewable area height to the default 90 e.style.height = e.vaHeight + 'px'; 91 e.style.overflow = 'auto'; 92 e.style.maxHeight = e.vaMaxHeight; 93 e.vaHeight = false; 94 } 95} 96 97/** 98* Alternate display of subPanels 99*/ 100jQuery(function($) { 101 'use strict'; 102 103 $('.sub-panels').each(function() { 104 105 var $childNodes = $('a[data-subpanel]', this), 106 panels = $childNodes.map(function () { 107 return this.getAttribute('data-subpanel'); 108 }), 109 showPanel = this.getAttribute('data-show-panel'); 110 111 if (panels.length) { 112 activateSubPanel(showPanel, panels); 113 $childNodes.click(function () { 114 activateSubPanel(this.getAttribute('data-subpanel'), panels); 115 return false; 116 }); 117 } 118 }); 119}); 120 121/** 122* Activate specific subPanel 123*/ 124function activateSubPanel(p, panels) { 125 'use strict'; 126 127 var i, showPanel; 128 129 if (typeof p === 'string') { 130 showPanel = p; 131 } 132 $('input[name="show_panel"]').val(showPanel); 133 134 if (typeof panels === 'undefined') { 135 panels = jQuery('.sub-panels a[data-subpanel]').map(function() { 136 return this.getAttribute('data-subpanel'); 137 }); 138 } 139 140 for (i = 0; i < panels.length; i++) { 141 jQuery('#' + panels[i]).css('display', panels[i] === showPanel ? 'block' : 'none'); 142 jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === showPanel); 143 } 144} 145 146function selectCode(a) { 147 'use strict'; 148 149 // Get ID of code block 150 var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; 151 var s, r; 152 153 // Not IE and IE9+ 154 if (window.getSelection) { 155 s = window.getSelection(); 156 // Safari and Chrome 157 if (s.setBaseAndExtent) { 158 var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; 159 try { 160 s.setBaseAndExtent(e, 0, e, l); 161 } catch (error) { 162 s.setBaseAndExtent(e, 0, e, 1); 163 } 164 } 165 // Firefox and Opera 166 else { 167 // workaround for bug # 42885 168 if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') { 169 e.innerHTML = e.innerHTML + ' '; 170 } 171 172 r = document.createRange(); 173 r.selectNodeContents(e); 174 s.removeAllRanges(); 175 s.addRange(r); 176 } 177 } 178 // Some older browsers 179 else if (document.getSelection) { 180 s = document.getSelection(); 181 r = document.createRange(); 182 r.selectNodeContents(e); 183 s.removeAllRanges(); 184 s.addRange(r); 185 } 186 // IE 187 else if (document.selection) { 188 r = document.body.createTextRange(); 189 r.moveToElementText(e); 190 r.select(); 191 } 192} 193 194/** 195* Play quicktime file by determining it's width/height 196* from the displayed rectangle area 197*/ 198function play_qt_file(obj) { 199 'use strict'; 200 201 var rectangle = obj.GetRectangle(); 202 var width, height; 203 204 if (rectangle) { 205 rectangle = rectangle.split(','); 206 var x1 = parseInt(rectangle[0], 10); 207 var x2 = parseInt(rectangle[2], 10); 208 var y1 = parseInt(rectangle[1], 10); 209 var y2 = parseInt(rectangle[3], 10); 210 211 width = (x1 < 0) ? (x1 * -1) + x2 : x2 - x1; 212 height = (y1 < 0) ? (y1 * -1) + y2 : y2 - y1; 213 } else { 214 width = 200; 215 height = 0; 216 } 217 218 obj.width = width; 219 obj.height = height + 16; 220 221 obj.SetControllerVisible(true); 222 obj.Play(); 223} 224 225var inAutocomplete = false;
226var lastKeyEntered = ''; 227 228/** 229* Check event key 230*/ 231function phpbbCheckKey(event) { 232 'use strict'; 233 234 // Keycode is array down or up? 235 if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) { 236 inAutocomplete = true; 237 } 238 239 // Make sure we are not within an "autocompletion" field 240 if (inAutocomplete) { 241 // If return pressed and key changed we reset the autocompletion 242 if (!lastKeyEntered || lastKeyEntered === event.which) { 243 inAutocomplete = false; 244 return true; 245 } 246 } 247 248 // Keycode is not return, then return. ;) 249 if (event.which !== 13) { 250 lastKeyEntered = event.which; 251 return true; 252 } 253 254 return false; 255} 256 257/** 258* Apply onkeypress event for forcing default submit button on ENTER key press 259*/ 260jQuery(function($) { 261 'use strict'; 262 263 $('form input[type=text], form input[type=password]').on('keypress', function (e) { 264 var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); 265 266 if (!defaultButton || defaultButton.length <= 0) { 267 return true; 268 } 269 270 if (phpbbCheckKey(e)) { 271 return true; 272 } 273 274 if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { 275 defaultButton.click(); 276 return false; 277 } 278 279 return true; 280 }); 281}); 282 283/** 284* Functions for user search popup 285*/ 286function insertUser(formId, value) { 287 'use strict'; 288 289 var $form = jQuery(formId), 290 formName = $form.attr('data-form-name'), 291 fieldName = $form.attr('data-field-name'), 292 item = opener.document.forms[formName][fieldName]; 293 294 if (item.value.length && item.type === 'textarea') { 295 value = item.value + '\n' + value; 296 } 297 298 item.value = value; 299} 300 301function insert_marked_users(formId, users) { 302 'use strict'; 303 304 for (var i = 0; i < users.length; i++) { 305 if (users[i].checked) { 306 insertUser(formId, users[i].value); 307 } 308 } 309 310 window.close(); 311} 312 313function insert_single_user(formId, user) { 314 'use strict'; 315 316 insertUser(formId, user); 317 window.close(); 318} 319 320/** 321* Parse document block 322*/ 323function parseDocument($container) { 324 'use strict'; 325 326 var test = document.createElement('div'), 327 oldBrowser = (typeof test.style.borderRadius === 'undefined'), 328 $body = $('body'); 329 330 /** 331 * Reset avatar dimensions when changing URL or EMAIL 332 */ 333 $container.find('input[data-reset-on-edit]').on('keyup', function() { 334 $(this.getAttribute('data-reset-on-edit')).val(''); 335 }); 336 337 /** 338 * Pagination 339 */ 340 $container.find('.pagination .page-jump-form :button').click(function() { 341 var $input = $(this).siblings('input.inputbox'); 342 pageJump($input); 343 }); 344 345 $container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { 346 if (event.which === 13 || event.keyCode === 13) { 347 event.preventDefault(); 348 pageJump($(this)); 349 } 350 }); 351 352 $container.find('.pagination .dropdown-trigger').click(function() { 353 var $dropdownContainer = $(this).parent(); 354 // Wait a little bit to make sure the dropdown has activated 355 setTimeout(function() { 356 if ($dropdownContainer.hasClass('dropdown-visible')) { 357 $dropdownContainer.find('input.inputbox').focus(); 358 } 359 }, 100); 360 }); 361 362 /** 363 * Adjust HTML code for IE8 and older versions 364 */ 365 if (oldBrowser) { 366 // Fix .linklist.bulletin lists 367 $container 368 .find('ul.linklist.bulletin > li') 369 .filter(':first-child, .rightside:last-child') 370 .addClass('no-bulletin'); 371 } 372 373 /** 374 * Resize navigation (breadcrumbs) block to keep all links on same line 375 */ 376 $container.find('.navlinks').each(function() { 377 var $this = $(this), 378 $left = $this.children().not('.rightside'), 379 $right = $this.children('.rightside'); 380 381 if ($left.length !== 1 || !$right.length) { 382 return; 383 } 384 385 function resize() { 386 var width = 0, 387 diff = $left.outerWidth(true) - $left.width(), 388 minWidth = Math.max($this.width() / 3, 240), 389 maxWidth; 390 391 $right.each(function() { 392 var $this = $(this); 393 if ($this.is(':visible')) { 394 width += $this.outerWidth(true); 395 } 396 }); 397 398 maxWidth = $this.width() - width - diff; 399 $left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px'); 400 } 401 402 resize(); 403 $(window).resize(resize); 404 }); 405 406 /** 407 * Makes breadcrumbs responsive 408 */ 409 $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { 410 var $this = $(this), 411 $links = $this.find('.crumb'), 412 length = $links.length, 413 classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'], 414 classesLength = classes.length, 415 maxHeight = 0, 416 lastWidth = false, 417 wrapped = false;
418 419 // Set tooltips 420 $this.find('a').each(function() { 421 var $link = $(this); 422 $link.attr('title', $link.text()); 423 }); 424 425 // Function that checks breadcrumbs 426 function check() { 427 var height = $this.height(), 428 width; 429 430 // Test max-width set in code for .navlinks above 431 width = parseInt($this.css('max-width'), 10); 432 if (!width) { 433 width = $body.width(); 434 } 435 436 maxHeight = parseInt($this.css('line-height'), 10); 437 $links.each(function() { 438 if ($(this).height() > 0) { 439 maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); 440 } 441 }); 442 443 if (height <= maxHeight) { 444 if (!wrapped || lastWidth === false || lastWidth >= width) { 445 return; 446 } 447 } 448 lastWidth = width; 449 450 if (wrapped) { 451 $this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); 452 if ($this.height() <= maxHeight) { 453 return; 454 } 455 } 456 457 wrapped = true; 458 $this.addClass('wrapped'); 459 if ($this.height() <= maxHeight) { 460 return; 461 } 462 463 for (var i = 0; i < classesLength; i++) { 464 for (var j = length - 1; j >= 0; j--) { 465 $links.eq(j).addClass('wrapped ' + classes[i]); 466 if ($this.height() <= maxHeight) { 467 return; 468 } 469 } 470 } 471 } 472 473 // Run function and set event 474 check(); 475 $(window).resize(check); 476 }); 477 478 /** 479 * Responsive link lists 480 */ 481 var selector = '.linklist:not(.navlinks, [data-skip-responsive]),' + 482 '.postbody .post-buttons:not([data-skip-responsive])'; 483 $container.find(selector).each(function() { 484 var $this = $(this), 485 filterSkip = '.breadcrumbs, [data-skip-responsive]', 486 filterLast = '.edit-icon, .quote-icon, [data-last-responsive]', 487 $linksAll = $this.children(), 488 $linksNotSkip = $linksAll.not(filterSkip), // All items that can potentially be hidden 489 $linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first 490 $linksLast = $linksNotSkip.filter(filterLast), // The items that will be hidden last 491 persistent = $this.attr('id') === 'nav-main', // Does this list already have a menu (such as quick-links)? 492 html = '<li class="responsive-menu hidden"><a href="javascript:void(0);" class="responsive-menu-link"> </a><div class="dropdown hidden"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>', 493 slack = 3; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured. 494 495 // Add a hidden drop-down menu to each links list (except those that already have one) 496 if (!persistent) { 497 if ($linksNotSkip.is('.rightside')) { 498 $linksNotSkip.filter('.rightside:first').before(html); 499 $this.children('.responsive-menu').addClass('rightside'); 500 } else { 501 $this.append(html); 502 } 503 } 504 505 // Set some object references and initial states 506 var $menu = $this.children('.responsive-menu'), 507 $menuContents = $menu.find('.dropdown-contents'), 508 persistentContent = $menuContents.find('li:not(.separator)').length, 509 lastWidth = false, 510 compact = false, 511 responsive1 = false, 512 responsive2 = false, 513 copied1 = false, 514 copied2 = false, 515 maxHeight = 0; 516 517 // Find the tallest element in the list (we assume that all elements are roughly the same height) 518 $linksAll.each(function() { 519 if (!$(this).height()) { 520 return; 521 } 522 maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); 523 }); 524 if (maxHeight < 1) { 525 return; // Shouldn't be possible, but just in case, abort 526 } else { 527 maxHeight = maxHeight + slack; 528 } 529 530 function check() { 531 var width = $body.width(); 532 // We can't make it any smaller than this, so just skip 533 if (responsive2 && compact && (width <= lastWidth)) { 534 return; 535 } 536 lastWidth = width; 537 538 // Reset responsive and compact layout 539 if (responsive1 || responsive2) { 540 $linksNotSkip.removeClass('hidden'); 541 $menuContents.children('.clone').addClass('hidden'); 542 responsive1 = responsive2 = false;
543 } 544 if (compact) { 545 $this.removeClass('compact'); 546 compact = false; 547 } 548 549 // Unhide the quick-links menu if it has "persistent" content 550 if (persistent && persistentContent) { 551 $menu.removeClass('hidden'); 552 } else { 553 $menu.addClass('hidden'); 554 } 555 556 // Nothing to resize if block's height is not bigger than tallest element's height 557 if ($this.height() <= maxHeight) { 558 return; 559 } 560 561 // STEP 1: Compact 562 if (!compact) { 563 $this.addClass('compact'); 564 compact = true; 565 } 566 if ($this.height() <= maxHeight) { 567 return; 568 } 569 570 // STEP 2: First responsive set - compact 571 if (compact) { 572 $this.removeClass('compact'); 573 compact = false; 574 } 575 // Copy the list items to the dropdown 576 if (!copied1) { 577 var $clones1 = $linksFirst.clone(); 578 $menuContents.prepend($clones1.addClass('clone clone-first').removeClass('leftside rightside')); 579 580 if ($this.hasClass('post-buttons')) { 581 $('.button', $menuContents).removeClass('button icon-button'); 582 $('.responsive-menu-link', $menu).addClass('button icon-button').prepend('<span></span>'); 583 } 584 copied1 = true; 585 } 586 if (!responsive1) { 587 $linksFirst.addClass('hidden'); 588 responsive1 = true; 589 $menuContents.children('.clone-first').removeClass('hidden'); 590 $menu.removeClass('hidden'); 591 } 592 if ($this.height() <= maxHeight) { 593 return; 594 } 595 596 // STEP 3: First responsive set + compact 597 if (!compact) { 598 $this.addClass('compact'); 599 compact = true; 600 } 601 if ($this.height() <= maxHeight) { 602 return; 603 } 604 605 // STEP 4: Last responsive set - compact 606 if (!$linksLast.length) { 607 return; // No other links to hide, can't do more 608 } 609 if (compact) { 610 $this.removeClass('compact'); 611 compact = false; 612 } 613 // Copy the list items to the dropdown 614 if (!copied2) { 615 var $clones2 = $linksLast.clone(); 616 $menuContents.prepend($clones2.addClass('clone clone-last').removeClass('leftside rightside')); 617 copied2 = true; 618 } 619 if (!responsive2) { 620 $linksLast.addClass('hidden'); 621 responsive2 = true; 622 $menuContents.children('.clone-last').removeClass('hidden'); 623 } 624 if ($this.height() <= maxHeight) { 625 return; 626 } 627 628 // STEP 5: Last responsive set + compact 629 if (!compact) { 630 $this.addClass('compact'); 631 compact = true; 632 } 633 } 634 635 if (!persistent) { 636 phpbb.registerDropdown($menu.find('a.responsive-menu-link'), $menu.find('.dropdown'), false); 637 } 638 639 // If there are any images in the links list, run the check again after they have loaded 640 $linksAll.find('img').each(function() { 641 $(this).load(function() { 642 check(); 643 }); 644 }); 645 646 check(); 647 $(window).resize(check); 648 }); 649 650 /** 651 * Do not run functions below for old browsers 652 */ 653 if (oldBrowser) { 654 return; 655 } 656 657 /** 658 * Adjust topiclist lists with check boxes 659 */ 660 $container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); 661 662 /** 663 * Appends contents of all extra columns to first column in 664 * .topiclist lists for mobile devices. Copies contents as is. 665 * 666 * To add that functionality to .topiclist list simply add 667 * responsive-show-all to list of classes 668 */ 669 $container.find('.topiclist.responsive-show-all > li > dl').each(function() { 670 var $this = $(this), 671 $block = $this.find('dt .responsive-show:last-child'), 672 first = true; 673 674 // Create block that is visible only on mobile devices 675 if (!$block.length) { 676 $this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />'); 677 $block = $this.find('dt .responsive-show:last-child'); 678 } else { 679 first = ($.trim($block.text()).length === 0); 680 } 681 682 // Copy contents of each column 683 $this.find('dd').not('.mark').each(function() { 684 var column = $(this), 685 $children = column.children(), 686 html = column.html(); 687 688 if ($children.length === 1 && $children.text() === column.text()) { 689 html = $children.html(); 690 } 691 692 $block.append((first ? '' : '<br />') + html); 693 694 first = false; 695 }); 696 }); 697 698 /** 699 * Same as above, but prepends text from header to each 700 * column before contents of that column. 701 * 702 * To add that functionality to .topiclist list simply add 703 * responsive-show-columns to list of classes 704 */ 705 $container.find('.topiclist.responsive-show-columns').each(function() { 706 var $list = $(this), 707 headers = [], 708 headersLength = 0; 709 710 // Find all headers, get contents 711 $list.prev('.topiclist').find('li.header dd').not('.mark').each(function() { 712 headers.push($(this).text()); 713 headersLength++; 714 }); 715 716 if (!headersLength) { 717 return; 718 } 719 720 // Parse each row 721 $list.find('dl').each(function() { 722 var $this = $(this), 723 $block = $this.find('dt .responsive-show:last-child'), 724 first = true; 725 726 // Create block that is visible only on mobile devices 727 if (!$block.length) { 728 $this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />'); 729 $block = $this.find('dt .responsive-show:last-child'); 730 } else { 731 first = ($.trim($block.text()).length === 0); 732 } 733 734 // Copy contents of each column 735 $this.find('dd').not('.mark').each(function(i) { 736 var column = $(this), 737 children = column.children(), 738 html = column.html(); 739 740 if (children.length === 1 && children.text() === column.text()) { 741 html = children.html(); 742 } 743 744 // Prepend contents of matching header before contents of column 745 if (i < headersLength) { 746 html = headers[i] + ': <strong>' + html + '</strong>'; 747 } 748 749 $block.append((first ? '' : '<br />') + html); 750 751 first = false;
752 }); 753 }); 754 }); 755 756 /** 757 * Responsive tables 758 */ 759 $container.find('table.table1').not('.not-responsive').each(function() { 760 var $this = $(this), 761 $th = $this.find('thead > tr > th'), 762 headers = [], 763 totalHeaders = 0, 764 i, headersLength; 765 766 // Find each header 767 $th.each(function(column) { 768 var cell = $(this), 769 colspan = parseInt(cell.attr('colspan'), 10), 770 dfn = cell.attr('data-dfn'), 771 text = dfn ? dfn : cell.text(); 772 773 colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; 774 775 for (i = 0; i < colspan; i++) { 776 headers.push(text); 777 } 778 totalHeaders++; 779 780 if (dfn && !column) { 781 $this.addClass('show-header'); 782 } 783 }); 784 785 headersLength = headers.length; 786 787 // Add header text to each cell as <dfn> 788 $this.addClass('responsive'); 789 790 if (totalHeaders < 2) { 791 $this.addClass('show-header'); 792 return; 793 } 794 795 $this.find('tbody > tr').each(function() { 796 var row = $(this), 797 cells = row.children('td'), 798 column = 0; 799 800 if (cells.length === 1) { 801 row.addClass('big-column'); 802 return; 803 } 804 805 cells.each(function() { 806 var cell = $(this), 807 colspan = parseInt(cell.attr('colspan'), 10), 808 text = $.trim(cell.text()); 809 810 if (headersLength <= column) { 811 return; 812 } 813 814 if ((text.length && text !== '-') || cell.children().length) { 815 cell.prepend('<dfn style="display: none;">' + headers[column] + '</dfn>'); 816 } else { 817 cell.addClass('empty'); 818 } 819 820 colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; 821 column += colspan; 822 }); 823 }); 824 }); 825 826 /** 827 * Hide empty responsive tables 828 */ 829 $container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { 830 var $items = $(this).children('tr'); 831 if (!$items.length) { 832 $(this).parent('table:first').addClass('responsive-hide'); 833 } 834 }); 835 836 /** 837 * Responsive tabs 838 */ 839 $container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() { 840 var $this = $(this), 841 $ul = $this.children(), 842 $tabs = $ul.children().not('[data-skip-responsive]'), 843 $links = $tabs.children('a'), 844 $item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'), 845 $menu = $item.find('.dropdown-contents'), 846 maxHeight = 0, 847 lastWidth = false, 848 responsive = false; 849 850 $links.each(function() { 851 var $this = $(this); 852 maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true))); 853 }); 854 855 function check() { 856 var width = $body.width(), 857 height = $this.height(); 858 859 if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { 860 return; 861 } 862 863 $tabs.show(); 864 $item.hide(); 865 866 lastWidth = width; 867 height = $this.height(); 868 if (height <= maxHeight) { 869 if ($item.hasClass('dropdown-visible')) { 870 phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0)); 871 } 872 return; 873 } 874 875 responsive = true; 876 $item.show(); 877 $menu.html(''); 878 879 var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'), 880 total = $availableTabs.length, 881 i, $tab; 882 883 for (i = total - 1; i >= 0; i--) { 884 $tab = $availableTabs.eq(i); 885 $menu.prepend($tab.clone(true).removeClass('tab')); 886 $tab.hide(); 887 if ($this.height() <= maxHeight) { 888 $menu.find('a').click(function() { 889 check(true); 890 }); 891 return; 892 } 893 } 894 $menu.find('a').click(function() { 895 check(true); 896 }); 897 } 898 899 var $tabLink = $item.find('a.responsive-tab-link'); 900 phpbb.registerDropdown($tabLink, $item.find('.dropdown'), { 901 visibleClass: 'activetab' 902 }); 903 904 check(true); 905 $(window).resize(check); 906 }); 907 908 /** 909 * Hide UCP/MCP navigation if there is only 1 item 910 */ 911 $container.find('#navigation').each(function() { 912 var $items = $(this).children('ol, ul').children('li'); 913 if ($items.length === 1) { 914 $(this).addClass('responsive-hide'); 915 } 916 }); 917 918 /** 919 * Replace responsive text 920 */ 921 $container.find('[data-responsive-text]').each(function() { 922 var $this = $(this), 923 fullText = $this.text(), 924 responsiveText = $this.attr('data-responsive-text'), 925 responsive = false;
926 927 function check() { 928 if ($(window).width() > 700) { 929 if (!responsive) { 930 return; 931 } 932 $this.text(fullText); 933 responsive = false; 934 return; 935 } 936 if (responsive) { 937 return; 938 } 939 $this.text(responsiveText); 940 responsive = true; 941 } 942 943 check(); 944 $(window).resize(check); 945 }); 946} 947 948/** 949* Run onload functions 950*/ 951jQuery(function($) { 952 'use strict'; 953 954 // Swap .nojs and .hasjs 955 $('#phpbb.nojs').toggleClass('nojs hasjs'); 956 $('#phpbb').toggleClass('hastouch', phpbb.isTouch); 957 $('#phpbb.hastouch').removeClass('notouch'); 958 959 // Focus forms 960 $('form[data-focus]:first').each(function() { 961 $('#' + this.getAttribute('data-focus')).focus(); 962 }); 963 964 parseDocument($('body')); 965});
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.