PageSourceSearch

https://learningspiral.co.in/wp-content/plugins/rt-mega-menu/public/assets/js/rtmega-accordion.js?ver=1.5.3

js learningspiral.co.in collected 2026-09-25 03:02:42 UTC 2,923 bytes, 112 lines download raw bytes

1(function ($) {
2
3	$.fn.mgaccordion = function (options) {
4
5		var defaults = {
6			theme: "flat",
7			leaveOpen: false
8		};
9
10		var settings = $.extend({}, defaults, options);
11		var openIcon, closeIcon;
12
13		this.initialize = function () {
14			if (!this.is('ul') && !this.is('ol')) {
15				console.log('Element is not a list');
16				return;
17			}
18
19			this.removeClass('mg-accordion mg-tree mg-flat');
20			this.addClass('mg-accordion');
21
22			var theme = settings.theme;
23			var leaveOpen = settings.leaveOpen;
24
25			if (theme === 'tree') {
26				this.addClass('mg-tree');
27			} else {
28				this.addClass('mg-flat');
29			}
30
31			$.each(this.find('li'), function () {
32				var $li = $(this);
33				var $a = $li.children('a');
34				var $icon = $a.find('.submenu-parent-icon');
35
36				if ($li.children('ul').length) {
37					$li.addClass('dropdown');
38					$li.find('ul').addClass('submenu');
39
40					var href = $a.attr('href');
41
42
43					if (typeof href === 'undefined' || href === '' || href === '#') {
44						$a.off('click').on('click', function (e) {
45							e.preventDefault();
46							e.stopImmediatePropagation();
47
48							if (leaveOpen === false) {
49								closeOther($(this));
50							}
51							$(this).siblings('ul.submenu').stop(true, true).slideToggle(function () {
52								$(this).toggleClass('closed', $(this).is(':visible'));
53							});
54							updateIcons($(this));
55						});
56					} else {
57						$icon.off('click').on('click', function (e) {
58							e.preventDefault();
59							e.stopPropagation();
60							e.stopImmediatePropagation();
61
62							if (leaveOpen === false) {
63								closeOther($a);
64							}
65							$a.siblings('ul.submenu').stop(true, true).slideToggle(function () {
66								$(this).toggleClass('closed', $(this).is(':visible'));
67							});
68							updateIcons($a);
69						});
70					}
71				}
72			});
73
74			return this;
75		};
76
77
78		var setIcons = function () {
79			if (settings.theme === 'tree') {
80				openIcon = '<span class="toggler"><i class="fa fa-plus-circle"></i> </span>';
81				closeIcon = '<span class="toggler"><i class="fa fa-minus-circle"></i> </span>';
82			} else if (settings.theme === 'flat') {
83				openIcon = '<span class="toggler"><i class="fa fa-arrow-circle-down"></i> </span>';
84				closeIcon = '<span class="toggler"> <i class="fa fa-arrow-circle-up"></i></span>';
85			}
86		}
87
88		var closeOther = function (obj) {
89			setIcons();
90			var items = obj.parent().siblings().find('ul.submenu');
91			items.each(function () {
92				if ($(this).is(':visible')) {
93					$(this).slideUp('slow').removeClass('closed')
94						.parent().find('a').removeClass('openItem');
95				}
96			});
97		}
98
99		var updateIcons = function (obj) {
100			if (settings.theme === 'flat') {
101				if (obj.siblings('.submenu').is(':visible')) {
102					obj.addClass('openItem');
103				} else {
104					obj.removeClass('openItem');
105				}
106			}
107		}
108
109		return this.initialize();
110	};
111
112}(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.