PageSourceSearch

https://www.pet911vet.com/themes/common/javascripts/smb/jquery.dropdown-fit.js?v.80bf8b

js pet911vet.com collected 2026-09-28 13:13:27 UTC 1,366 bytes, 51 lines download raw bytes

1// check if drop down fits in main parent container, and add class if it doesn't
2// !IMPORTANT: works only with first drop down level
3;(function($) {
4	// options
5	function dropdownFit(options) {
6		this.options = $.extend({
7			dropDown: '>li>ul',
8			fitClass: 'set-right'
9		}, options);
10
11		this.init();
12	}
13
14	// prototype
15	dropdownFit.prototype = {
16		init: function() {
17			this.findElements();
18			this.detectOffset();
19		},
20		findElements: function() {
21			this.holder = $(this.options.holder),
22			this.dropdown = this.holder.find(this.options.dropDown),
23			this.dropdownParent = this.dropdown.parents('li');
24		},
25		detectOffset: function() {
26			var self = this,
27				holderWidth = self.holder.width(),
28				holderOffset = self.holder.offset().left;
29
30			self.dropdownParent.each(function() {
31				if (Math.round($(this).offset().left) >= holderOffset) {
32					var test = (Math.round($(this).offset().left) - holderOffset) + self.dropdown.width();
33					if (holderWidth <= test) {
34						$(this).addClass(self.options.fitClass);
35					}
36				}
37			});
38		},
39		destroy: function() {
40			this.dropdownParent.removeClass(this.options.fitClass);
41			this.holder.removeData('dropdownFit');
42		}
43	};
44
45	// jquery plugin
46	$.fn.dropdownFit = function(opt) {
47		return this.each(function() {
48			$(this).data('dropdownFit', new dropdownFit($.extend(opt, { holder: this })));
49		});
50	};
51})(jQuery);

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.