PageSourceSearch

http://cvpvm09.ru/wp-content/themes/newsup/js/jquery.smartmenus.bootstrap.js?ver=7.1.2

js cvpvm09.ru collected 2026-09-24 10:40:14 UTC 6,010 bytes, 166 lines download raw bytes

1/*!
2 * SmartMenus jQuery Plugin Bootstrap 4 Addon - v0.1.0 - September 17, 2017
3 * http://www.smartmenus.org/
4 *
5 * Copyright Vasil Dinkov, Vadikom Web Ltd.
6 * http://vadikom.com
7 *
8 * Licensed MIT
9 */
10
11(function(factory) {
12	if (typeof define === 'function' && define.amd) {
13		// AMD
14		define(['jquery', 'smartmenus'], factory);
15	} else if (typeof module === 'object' && typeof module.exports === 'object') {
16		// CommonJS
17		module.exports = factory(require('jquery'));
18	} else {
19		// Global jQuery
20		factory(jQuery);
21	}
22} (function($) {
23
24	$.extend($.SmartMenus.Bootstrap = {}, {
25		keydownFix: false,
26		init: function() {
27			// init all navbars that don't have the "data-sm-skip" attribute set
28			var $navbars = $('ul.navbar-nav:not([data-sm-skip])');
29			$navbars.each(function() {
30				var $this = $(this),
31					obj = $this.data('smartmenus');
32				// if this navbar is not initialized
33				if (!obj) {
34					var skipBehavior = $this.is('[data-sm-skip-collapsible-behavior]'),
35						rightAligned = $this.hasClass('ml-auto') || $this.prevAll('.mr-auto').length > 0;
36
37					$this.smartmenus({
38							// these are some good default options that should work for all
39							subMenusSubOffsetX: 2,
40							subMenusSubOffsetY: -9,
41							subIndicators: !skipBehavior,
42							collapsibleShowFunction: null,
43							collapsibleHideFunction: null,
44							rightToLeftSubMenus: rightAligned,
45							bottomToTopSubMenus: $this.closest('.fixed-bottom').length > 0,
46							// custom option(s) for the Bootstrap 4 addon
47							bootstrapHighlightClasses: 'text-dark bg-light'
48						})
49						.on({
50							// set/unset proper Bootstrap classes for some menu elements
51							'show.smapi': function(e, menu) {
52								var $menu = $(menu),
53									$scrollArrows = $menu.dataSM('scroll-arrows');
54								if ($scrollArrows) {
55									$scrollArrows.css('background-color', $menu.css('background-color'));
56								}
57								$menu.parent().addClass('show');
58								if (obj.opts.keepHighlighted && $menu.dataSM('level') > 2) {
59									$menu.prevAll('a').addClass(obj.opts.bootstrapHighlightClasses);
60								}
61							},
62							'hide.smapi': function(e, menu) {
63								var $menu = $(menu);
64								$menu.parent().removeClass('show');
65								if (obj.opts.keepHighlighted && $menu.dataSM('level') > 2) {
66									$menu.prevAll('a').removeClass(obj.opts.bootstrapHighlightClasses);
67								}
68							}
69						});
70
71					obj = $this.data('smartmenus');
72
73					function onInit() {
74						// set Bootstrap's "active" class to SmartMenus "current" items (should someone decide to enable markCurrentItem: true)
75						$this.find('a.current').each(function() {
76							var $this = $(this);
77							// dropdown items require the class to be set to the A's while for nav items it should be set to the parent LI's
78							($this.hasClass('dropdown-item') ? $this : $this.parent()).addClass('active');
79						});
80						// parent items fixes
81						$this.find('a.has-submenu').each(function() {
82							var $this = $(this);
83							// remove Bootstrap required attributes that might cause conflicting issues with the SmartMenus script
84							if ($this.is('[data-toggle="dropdown"]')) {
85								$this.dataSM('bs-data-toggle-dropdown', true).removeAttr('data-toggle');
86							}
87							// remove Bootstrap's carets generating class
88							if (!skipBehavior && $this.hasClass('dropdown-toggle')) {
89								$this.dataSM('bs-dropdown-toggle', true).removeClass('dropdown-toggle');
90							}
91						});
92					}
93
94					onInit();
95
96					function onBeforeDestroy() {
97						$this.find('a.current').each(function() {
98							var $this = $(this);
99							($this.hasClass('active') ? $this : $this.parent()).removeClass('active');
100						});
101						$this.find('a.has-submenu').each(function() {
102							var $this = $(this);
103							if ($this.dataSM('bs-dropdown-toggle')) {
104								$this.addClass('dropdown-toggle').removeDataSM('bs-dropdown-toggle');
105							}
106							if ($this.dataSM('bs-data-toggle-dropdown')) {
107								$this.attr('data-toggle', 'dropdown').removeDataSM('bs-data-toggle-dropdown');
108							}
109						});
110					}
111
112					// custom "refresh" method for Bootstrap
113					obj.refresh = function() {
114						$.SmartMenus.prototype.refresh.call(this);
115						onInit();
116						// update collapsible detection
117						detectCollapsible(true);
118					};
119
120					// custom "destroy" method for Bootstrap
121					obj.destroy = function(refresh) {
122						onBeforeDestroy();
123						$.SmartMenus.prototype.destroy.call(this, refresh);
124					};
125
126					// keep Bootstrap's default behavior (i.e. use the whole item area just as a sub menu toggle)
127					if (skipBehavior) {
128						obj.opts.collapsibleBehavior = 'toggle';
129					}
130
131					// onresize detect when the navbar becomes collapsible and add it the "sm-collapsible" class
132					var winW;
133					function detectCollapsible(force) {
134						var newW = obj.getViewportWidth();
135						if (newW != winW || force) {
136							if (obj.isCollapsible()) {
137								$this.addClass('sm-collapsible');
138							} else {
139								$this.removeClass('sm-collapsible');
140							}
141							winW = newW;
142						}
143					}
144					detectCollapsible();
145					$(window).on('resize.smartmenus' + obj.rootId, detectCollapsible);
146				}
147			});
148			// keydown fix for Bootstrap 4 conflict
149			if ($navbars.length && !$.SmartMenus.Bootstrap.keydownFix) {
150				// unhook BS keydown handler for all dropdowns
151				$(document).off('keydown.bs.dropdown.data-api', '.dropdown-menu');
152				// restore BS keydown handler for dropdowns that are not inside SmartMenus navbars
153				// SmartMenus won't add the "show" class so it's handy here
154				if ($.fn.dropdown && $.fn.dropdown.Constructor) {
155					$(document).on('keydown.bs.dropdown.data-api', '.dropdown-menu.show', $.fn.dropdown.Constructor._dataApiKeydownHandler);
156				}
157				$.SmartMenus.Bootstrap.keydownFix = true;
158			}
159		}
160	});
161
162	// init ondomready
163	$($.SmartMenus.Bootstrap.init);
164
165	return $;
166}));

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.