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