PageSourceSearch

https://gmina.wilamowice.pl/libraries/Superfish/supersubs.js?thhi2u

js wilamowice.pl collected 2026-10-02 12:38:16 UTC 4,968 bytes, 117 lines download raw bytes

1/*
2 * Supersubs v0.4b - jQuery plugin
3 * Copyright (c) 2013 Joel Birch
4 *
5 * Dual licensed under the MIT and GPL licenses:
6 *  http://www.opensource.org/licenses/mit-license.php
7 *  http://www.gnu.org/licenses/gpl.html
8 *
9 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
10 * their longest list item children. If you use this, please expect bugs and report them
11 * to the jQuery Google Group with the word 'Superfish' in the subject line.
12 *
13 */
14/*
15 * This is not the original jQuery Supersubs plugin.
16 * Please refer to the README for more information.
17 */
18
19(function($){ // $ will refer to jQuery within this closure
20  $.fn.supersubs = function(options){
21    var opts = $.extend({}, $.fn.supersubs.defaults, options);
22    // return original object to support chaining
23    // Although this is unnecessary due to the way the module uses these plugins.
24    for (var a = 0; a < this.length; a++) {
25      // cache selections
26      var $$ = $(this).eq(a),
27      // support metadata
28      o = $.meta ? $.extend({}, opts, $$.data()) : opts;
29      // Jump one level if it's a "NavBar"
30      if ($$.hasClass('sf-navbar')) {
31        $$ = $$.children('li').children('ul');
32      }
33      // cache all ul elements
34      var $ULs = $$.find('ul');
35      if ($ULs.length) {
36        // get the font size of menu.
37        // .css('fontSize') returns various results cross-browser, so measure an em dash instead
38        var fontsize = $('<li id="menu-fontsize">&#8212;</li>'),
39        size = fontsize.attr('style','padding:0;position:absolute;top:-99999em;width:auto;')
40        .appendTo($$)[0].clientWidth; //clientWidth is faster than width()
41        // remove em dash
42        fontsize.remove();
43
44        // loop through each ul in menu
45        for (var b = 0; b < $ULs.length; b++) {
46          var
47          // cache this ul
48          $ul = $ULs.eq(b);
49          // If a multi-column sub-menu, and only if correctly configured.
50          if (o.multicolumn && $ul.hasClass('sf-multicolumn') && $ul.find('.sf-multicolumn-column').length > 0){
51            // Look through each column.
52            var $column = $ul.find('div.sf-multicolumn-column > ol'),
53            // Overall width.
54            mwWidth = 0;
55            for (var d = 0; d < $column.length; d++){
56              resize($column.eq(d));
57              // New column width, in pixels.
58              var colWidth = $column.width();
59              // Just a trick to convert em unit to px.
60              $column.css({width:colWidth})
61              // Making column parents the same size.
62              .parents('.sf-multicolumn-column').css({width:colWidth});
63              // Overall width.
64              mwWidth += parseInt(colWidth);
65            }
66            // Resizing the columns container too.
67            $ul.add($ul.find('li.sf-multicolumn-wrapper, li.sf-multicolumn-wrapper > ol')).css({width:mwWidth});
68          }
69          else {
70            resize($ul);
71          }
72        }
73      }
74    }
75    function resize($ul){
76      var
77      // get all (li) children of this ul
78      $LIs = $ul.children(),
79      // get all anchor grand-children
80      $As = $LIs.children('a');
81      // force content to one line and save current float property
82      $LIs.css('white-space','nowrap');
83      // remove width restrictions and floats so elements remain vertically stacked
84      $ul.add($LIs).add($As).css({float:'none',width:'auto'});
85      // this ul will now be shrink-wrapped to longest li due to position:absolute
86      // so save its width as ems.
87      var emWidth = $ul.get(0).clientWidth / size;
88      // add more width to ensure lines don't turn over at certain sizes in various browsers
89      emWidth += o.extraWidth;
90      // restrict to at least minWidth and at most maxWidth
91      if (emWidth > o.maxWidth) {emWidth = o.maxWidth;}
92      else if (emWidth < o.minWidth) {emWidth = o.minWidth;}
93      emWidth += 'em';
94      // set ul to width in ems
95      $ul.css({width:emWidth});
96      // restore li floats to avoid IE bugs
97      // set li width to full width of this ul
98      // revert white-space to normal
99      $LIs.add($As).css({float:'',width:'',whiteSpace:''});
100      // update offset position of descendant ul to reflect new width of parent.
101      // set it to 100% in case it isn't already set to this in the CSS
102      for (var c = 0; c < $LIs.length; c++) {
103        var $childUl = $LIs.eq(c).children('ul');
104        var offsetDirection = $childUl.css('left') !== undefined ? 'left' : 'right';
105        $childUl.css(offsetDirection,'100%');
106      }
107    }
108    return this;
109  };
110  // expose defaults
111  $.fn.supersubs.defaults = {
112    multicolumn: true, // define width for multi-column sub-menus and their columns.
113    minWidth: 12, // requires em unit.
114    maxWidth: 27, // requires em unit.
115    extraWidth: 1 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
116  };
117})(jQuery); // plugin code ends

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.