PageSourceSearch

https://baviux.com/wp-content/themes/grizzly-theme/libs/supersubs.js?ver=3.1.1

js baviux.com collected 2026-10-01 12:37:08 UTC 3,297 bytes, 89 lines download raw bytes

1/*
2 * Supersubs v0.2b - jQuery plugin
3 * Copyright (c) 2008 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 *
10 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
11 * their longest list item children. If you use this, please expect bugs and report them
12 * to the jQuery Google Group with the word 'Superfish' in the subject line.
13 *
14 */
15
16;(function($){ // $ will refer to jQuery within this closure
17
18	$.fn.supersubs = function(options){
19		var opts = $.extend({}, $.fn.supersubs.defaults, options);
20		// return original object to support chaining
21		return this.each(function() {
22			// cache selections
23			var $$ = $(this);
24			// support metadata
25			var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
26			// get the font size of menu.
27			// .css('fontSize') returns various results cross-browser, so measure an em dash instead
28			var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
29				'padding' : 0,
30				'position' : 'absolute',
31				'top' : '-999em',
32				'width' : 'auto'
33			}).appendTo($$).width(); //clientWidth is faster, but was incorrect here
34			// remove em dash
35			$('#menu-fontsize').remove();
36			// cache all ul elements
37			$ULs = $$.find('ul');
38			// loop through each ul in menu
39			$ULs.each(function(i) {	
40				// cache this ul
41				var $ul = $ULs.eq(i);
42				// get all (li) children of this ul
43				var $LIs = $ul.children();
44				// get all anchor grand-children
45				var $As = $LIs.children('a');
46				// force content to one line and save current float property
47				var liFloat = $LIs.css('white-space','nowrap').css('float');
48				// remove width restrictions and floats so elements remain vertically stacked
49				var emWidth = $ul.add($LIs).add($As).css({
50					'float' : 'none',
51					'width'	: 'auto'
52				})
53				// this ul will now be shrink-wrapped to longest li due to position:absolute
54				// so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
55				.end().end()[0].clientWidth / fontsize;
56				// add more width to ensure lines don't turn over at certain sizes in various browsers
57				emWidth += o.extraWidth;
58				// restrict to at least minWidth and at most maxWidth
59				if (emWidth > o.maxWidth)		{ emWidth = o.maxWidth; }
60				else if (emWidth < o.minWidth)	{ emWidth = o.minWidth; }
61				emWidth += 'em';
62				// set ul to width in ems
63				$ul.css('width',emWidth);
64				// restore li floats to avoid IE bugs
65				// set li width to full width of this ul
66				// revert white-space to normal
67				$LIs.css({
68					'float' : liFloat,
69					'width' : '100%',
70					'white-space' : 'normal'
71				})
72				// update offset position of descendant ul to reflect new width of parent
73				.each(function(){
74					var $childUl = $('>ul',this);
75					var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
76					$childUl.css(offsetDirection,emWidth);
77				});
78			});
79			
80		});
81	};
82	// expose defaults
83	$.fn.supersubs.defaults = {
84		minWidth		: 9,		// requires em unit.
85		maxWidth		: 25,		// requires em unit.
86		extraWidth		: 0			// extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
87	};
88	
89})(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.