PageSourceSearch

https://mxdm999.com/usr/themes/Joe-master/assets/js/joe.post.directories.js?version=1.3294

js mxdm999.com collected 2026-10-06 13:15:07 UTC 4,724 bytes, 165 lines download raw bytes

1//严格模式
2'use strict';
3
4function section_navs(selector) {
5
6	var navbox_selector = '.posts-nav-box';
7	var _body = $('body');
8	var nav_class = 'posts-nav-lists';
9	var nav_selector = '.' + nav_class;
10	var selector_s = selector + ' h1,' + selector + ' h2,' + selector + ' h3,' + selector + ' h4,' + selector + ' h5,' + selector + ' h6';
11
12	var index = 0;
13
14	function scrollTo(o, t, l) {
15		var scrollTop = 0;
16		var _body = $('body,html');
17		l = l || 300;
18		t = t || 0;
19
20		if (o) {
21			var _o = o instanceof jQuery ? o : $(o);
22			// scrollTop = _o.length ? _o.offset().top + t - (_body.hasClass('nav-fixed') ? $('.header').innerHeight() + 20 : 0) : 0;
23			// scrollTop = _o.length ? (_o.offset().top + t - $('.joe_header').innerHeight() + 20) : 0;
24			scrollTop = _o.length ? (_o.offset().top + t - $('.joe_header').innerHeight() - (window.Joe.IS_MOBILE ? 10 : 5)) : 0;
25		}
26		_body.animate(
27			{
28				scrollTop: scrollTop,
29			},
30			l,
31			'swing'
32		);
33	}
34
35	function aotu_scrollTo() {
36		var hash = window.location.hash;
37		if (hash && $(hash).length) {
38			$('a[href="' + hash + '"]').click();
39		}
40	}
41
42	function getHiddenElementHeight($element) {
43		let innerHeight = $element.innerHeight();
44		if (innerHeight > 0) {
45			return innerHeight;
46		} else {
47			$('.posts-nav-switcher>.zib-widget').css({
48				'visibility': 'hidden',
49				'display': 'block',
50			});
51			const height = $element.innerHeight();
52			$('.posts-nav-switcher>.zib-widget').css({
53				'visibility': '',
54				'display': 'none',
55			});
56			return height;
57		}
58	}
59
60	var add_box = function () {
61		var navs_lists = GetnavsLists();
62		if (!navs_lists) return;
63
64		$(navbox_selector).each(function () {
65			var _this = $(this);
66			var name = _this.attr('data-title') || '';
67			name = name && '<div class="box-body notop"><div class="title-theme">' + name + '</div></div>';
68			_this.append(name + '<div class="zib-widget"><div class="' + nav_class + ' scroll-y mini-scrollbar list-unstyled"></div></div>');
69		});
70		add_lists(navs_lists);
71		setTimeout(function () {
72			aotu_scrollTo();
73		}, 20);
74	};
75
76	//设置排除的元素
77	function isExcludedElement(el) {
78		return el.hasClass('item-heading') || el.parents('.no-nav').length;
79	}
80
81	function GetnavsLists() {
82		var navs_lists = '';
83		$(selector_s).each(function (indexInArray) {
84			var _this = $(this);
85			if (!isExcludedElement(_this)) {
86				var tag = _this.prop('tagName');
87				var text = _this.text();
88				var _class = 'n-' + tag;
89				_class += indexInArray == 1 ? ' active' : '';
90				index = indexInArray;
91				_this.attr('id', 'wznav_' + index);
92				navs_lists += '<li class="' + _class + '"><a class="text-ellipsis" href="#wznav_' + index + '">
92' + text + '</a></li>';
93			}
94		});
95		return navs_lists;
96	}
97
98	var add_lists = function (navs_lists) {
99		$(nav_selector).html('<ul class="bl relative nav">' + navs_lists + '</ul>');
100		$(nav_selector + ' a').on('click', function (event) {
101			event.preventDefault();
102			var _href = $($(this).attr('href'));
103			_href.parents('.panel').each(function () {
104				var _collapse = $(this).find('.collapse');
105				if (_collapse.length) {
106					_collapse.collapse('show');
107				}
108			});
109
110			$('.read-more-open').click();
111			scrollTo(_href);
112			if (window.Joe.IS_MOBILE) {
113				$('.joe_action_item.posts-nav-switcher>.zib-widget').fadeOut(200);
114			}
115			return false;
116		});
117
118		// 监测滚动自动为目录添加类名 active 
119		_body.scrollspy({
120			target: nav_selector,
121			// 抵消顶栏高度
122			offset: $('.joe_header').innerHeight() + (window.Joe.IS_MOBILE ? 10 : 5) + 1,
123		});
124		collapse();
125	};
126
127	//显示折叠内容
128	var collapse = function () {
129		var find_selector = '.n-H1,.n-H2';
130		$(nav_selector + ' .bl').each(function () {
131			var _this = $(this);
132			let height = getHiddenElementHeight(_this);
133			if (height > 380) {
134				_this.find(find_selector).each(function () {
135					var _this = $(this);
136					var _n_h2 = _this.nextUntil(find_selector);
137					if (_n_h2.length) {
138						_n_h2.addClass('yc');
139						_this.append('<i class="fa fa-angle-right nav-toggle-collapse"></i>');
140					}
141				});
142			}
143		});
144
145		_body.on('click', nav_selector + ' .nav-toggle-collapse', function () {
146			$(this).toggleClass('fa-rotate-90').parent().nextUntil(find_selector).toggleClass('yc');
147		});
148	};
149
150	if ($(selector_s).length > 2) {
151		add_box();
152		if (window.Joe.IS_MOBILE) {
153			$('.joe_action_item.posts-nav-switcher,.joe_action_item.posts-nav-switcher>i').click(function (event) {
154				if (event.target !== this) return;
155				$('.posts-nav-switcher>.zib-widget').css('display') == 'none' ? $('.joe_action').css('z-index', '100') : $('.joe_action').css('z-index', '98');
156				$('.posts-nav-switcher>.zib-widget').fadeToggle(200);
157			});
158		}
159	} else {
160		$(navbox_selector).remove();
161	}
162
163}
164
165section_navs('[data-nav]');

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.