[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/styles/prosilver/template/ -> forum_fn.js (source)

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


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1