PageSourceSearch

http://028yw.cn/static/js/basic.js

js 028yw.cn collected 2026-10-09 04:34:10 UTC 10,180 bytes, 384 lines download raw bytes

1// JavaScript Document
2
3
4var BASIC = {
5
6
7	// 页面初始化
8	init: function(){
9		var self = this;
10
11		$('#header .nav dl').hover(function(){
12			$('#header .nav dl.active').removeClass('active');
13		}, function(){
14			$('#header .nav dl.on').addClass('active');
15		});
16
17		var IEv = self.IEVersion();
18
19		if (IEv <= 9 && IEv > 0) {
20			$('body').find('.wow-list').removeClass('wow-list');
21			$('body').find('.wow').removeClass('wow');
22		} else {
23			$('.wow-list').each(function(){
24				var $list = $(this),
25					width = $list.width(),
26					$children = $list.children(),
27					className = $(this).data('name') || 'fadeInUp';
28
29				if(!$children.length) return true;
30				var cW = $children.eq(0).width(),
31					num = parseInt(width/cW)
32
33				$children.each(function(index){
34					var time = index % num * 80 + 100,
35						duration = $list.data('wow-duration');
36					$(this).addClass('wow ' + className).attr('data-wow-delay', time + 'ms');
37					if(duration) $(this).attr('data-wow-duration', duration + 'ms');
38				})
39			});
40			new WOW().init();
41		}
42
43		self.setTabWidth();
44		self.setQQ();
45
46		var mobileTxt = $('.sub-nav .sub-list-box').find('li.active').length ? $('.sub-nav .sub-list-box').find('li.active').text() : $('.sub-nav .sub-list-box').find('dd.active').text();
47		$('.sub-nav').find('.mobile-show').text(mobileTxt);
48	},
49
50	IEVersion: function() {
51	var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串  
52	var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器  
53	var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器  
54	var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
55	if(isIE) {
56	var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
57	reIE.test(userAgent);
58	var fIEVersion = parseFloat(RegExp["$1"]);
59	if(fIEVersion == 7) {
60	return 7;
61	} else if(fIEVersion == 8) {
62	return 8;
63	} else if(fIEVersion == 9) {
64	return 9;
65	} else if(fIEVersion == 10) {
66	return 10;
67	} else {
68	return 6;//IE版本<=7
69	}   
70	} else if(isEdge) {
71	return 'edge';//edge
72	} else if(isIE11) {
73	return 11; //IE11  
74	}else{
75	return -1;//不是ie浏览器
76	}
77	},
78
79
80	// 设置tab切换宽度
81	setTabWidth: function() {
82		var self = this;
83		
84		$('.tab-swiper').each(function(){
85			var $innerBox = $(this).find('.inner-box'),
86				innerBoxW = 0;
87
88			if ($(this).css('display') != 'none' && !$(this).data('set')) {
89				$innerBox.find('a').each(function(){
90					innerBoxW += $(this).outerWidth() + 10;
91				});
92				$innerBox.width(innerBoxW + 10).data('set', true);
93			}
94		});
95	},
96
97
98	// 滚动内容页面
99	scrollBody: function(){
100		var self = this,
101			scrollTop = $('body').scrollTop() || $('html').scrollTop(),
102			$top = $('#top'),
103			$header = $('#header'),
104			limit = 500;
105
106		(scrollTop > limit) ? $top.addClass('show') : $top.removeClass('show');
107	},
108
109
110	// 回到顶部
111	toTop: function(){
112		$('body,html').animate({scrollTop: 0}, 300);
113		return false;
114	},
115
116
117	// mobile显示/隐藏菜单
118	mobileNav: function(){
119		$('#header').toggleClass('active');
120	},
121
122
123	// mobile显示/隐藏二级菜单
124	mobileSubNav: function($dl){
125		var self = this;
126		$dl.toggleClass('on').siblings().removeClass('on');
127		$('#header .nav dl').each(function(){
128			var $dl = $(this);
129			if($dl.hasClass('on')){
130				var height = $dl.find('dd > .sub-nav-box').length * 46;
131				if($dl.find('.on').length) {
132					height += $dl.find('.on').find('li').length * 46;
133				}
134				$dl.find('dd').animate({'height': height}, 300, function(){
135					$(this).css({height: 'auto'});
136				});
137			}else{
138				$dl.find('dd').animate({'height': 0}, 300);
139			}
140		});
141	},
142
143
144	// mobile显示/隐藏三级菜单
145	mobileISubNav: function($subNav){
146		var self = this,
147			$dd = $subNav.closest('dd');
148		$subNav.toggleClass('on').siblings().removeClass('on');
149		$dd.find('.sub-nav-box').each(function(){
150			var $this = $(this);
151			if($this.hasClass('on')){
152				var height = $this.find('.i-sub-nav li').length * 46;
153				$this.find('.i-sub-nav').animate({'height': height}, 300);
154			}else{
155				$this.find('.i-sub-nav').animate({'height': 0}, 300);
156			}
157		});
158	},
159
160
161	// 搜索文章
162	searchArticle: function($this){
163		var self = this,
164			$form = $this.closest('form'),
165			search = $('.js-search-text').val().trim();
166
167		if(search) $form.submit();
168	},
169
170
171	// 提交留言
172	submitGuestBook: function($this){
173		var self = this,
174			$form = $this.closest('form'),
175			formUrl = $form.data('action'),
176			data = $form.serializeArray(),
177			sign = true;
178
179		for(var i in data){
180			var val = data[i].value;
181			if(!val){
182				sign = false;
183				break;
184			}
185		}
186		if(!sign){
187			alert('请填写完所有信息后再提交!');
188			return;
189		}
190
191		var tel = $form.find('input[name="tel"]').val();
192		sign = (/^1[3|4|5|6|7|8|9]\d{9}$/.test(tel));
193		if(!sign){
194			alert('请输入正确的手机号');
195			return;
196		}
197
198		var email = $form.find('input[name="email"]').val();
199		sign = (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email));
200		if(!sign){
201			alert('请输入正确的邮箱');
202			return;
203		}
204
205		$.post(formUrl, data, function(result){
206			var msg = result.status ? '提交成功!' : '提交失败,请稍后重试!';
207			alert(msg);
208			if(result.status) $form[0].reset();
209		}).error(function(){
210			alert('网络错误,请稍后重试!');
211		});
212	},
213
214	// 弹出框
215	modalBox: function($obj, callback) {
216		var self = this;
217
218		if (!$('#modal-play-container').hasClass('in')) {
219			$('body').addClass('ovh');
220			$('#modal-play-container').show().data('pending', true);
221
222			$('#modal-play-container .bg').css({
223				transition: 'background .3s ease-out 0s'
224			});
225			$('#modal-play-container .close').css({
226				transition: 'top .2s ease-out .5s'
227			});
228			$('#modal-play-container .prev-btn').css({
229				transition: 'left .2s ease-out .5s'
230			});
231			$('#modal-play-container .next-btn').css({
232				transition: 'right .2s ease-out .5s'
233			});
234			$('#modal-play-container .modal-body').css({
235				transition: 'top .5s cubic-bezier(1, -0.7, 0.5, 1) 0s'
236			});
237
238			setTimeout(function(){
239				$('#modal-play-container').addClass('in').data('pending', false);
240			}, 50);
241		}
242		if (callback && typeof callback == 'function') {
243			self.currentModal = $obj;
244			self.modalCallback = callback;
245			callback($obj);
246		}
247	},
248
249	// 设置qq
250	setQQ: function() {
251		var self = this,
252			w = $(window).width();
253
254		$('.js-qq-btn').each(function() {
255			var qq = $(this).data('qq');
256
257			if (w > 540) {
258				var href = 'http://wpa.qq.com/msgrd?v=3&uin=' + qq + '&site=qq&menu=yes';
259			} else {
260				var href = 'mqqwpa://im/chat?chat_type=wpa&uin=' + qq + '&version=1&src_type=web&web_src=www.028yw.cn';
261			}
262			$(this).attr('href', href);
263		})
264
265	}
266};
267
268
269$(function(){
270
271	BASIC.init();
272
273	$('#header').on('click', '.mobile-nav-btn', function(){
274		BASIC.mobileNav();
275
276	}).on('click', 'dt', function(){
277		var $dl = $(this).closest('dl');
278		BASIC.mobileSubNav($dl);
279
280	}).on('click', '.nav dd .sub-nav-box > a', function(){
281		var $subNav = $(this).closest('.sub-nav-box');
282		BASIC.mobileISubNav($subNav);
283
284	}).on('click', '.js-search-btn', function(){
285		BASIC.searchArticle($(this));
286		
287	}).on('click', 'a.has-sub', function(e) {
288		if ($('#header .mobile-nav-btn').css('display') != 'none') {
289			e.preventDefault();
290		}
291
292	});
293
294	$('#top').on('click', function(){
295		BASIC.toTop();
296	});
297
298	$('#guestbook').on('click', '.submit-btn', function(){
299		BASIC.submitGuestBook($(this));
300
301	})
302
303	$(window).on('scroll', function(){
304		BASIC.scrollBody();
305
306	}).on('resize', function() {
307		BASIC.setTabWidth();
308		BASIC.setQQ();
309		
310	});
311
312	$('#header .nav dl.active dt').trigger('click');
313	$('#header .nav dd .sub-nav-box.active > a.has-sub').trigger('click');
314
315	$('#online_close').on('click', function(){
316		$('#online_lx').css({'right': '-192px'});
317		$('#sshare').css({'transform': 'translate3d(0, 0, 0)'});
318	});
319	$('#sshare').on('click', function(){
320		$('#online_lx').css({'right': '0px'});
321		$('#sshare').css({'transform': 'translate3d(.5rem, 0, 0)'});
322	});
323	$('#sweixin').on('click', function(){
324		$('#fixed_weixin').addClass('show');
325	});
326	$('#fixed_weixin').on('click', '.bg', function(){
327		$('#fixed_weixin').removeClass('show');
328	});
329	
330	$('#modal-play-container').on('click', '.close', function(){
331		if($('#modal-play-container').data('pending')) return;
332		$('#modal-play-container').data('pending', true);
333		
334		$('#modal-play-container .bg').css({
335			transition: 'all .15s ease-out .4s'
336		});
337		$('#modal-play-container .close').css({
338			transition: 'all .2s ease-out 0s'
339		});
340		$('#modal-play-container .switch-btn').css({
341			transition: 'all .2s ease-out 0s'
342		});
343		$('#modal-play-container .modal-body').css({
344			transition: 'top .25s cubic-bezier(1, 0.2, 0.8, 1) .3s'
345		});
346		$('#modal-play-container').removeClass('in');
347
348		$('#modal-play-container .bg').transitionEnd(function(){
349			$('body').removeClass('ovh');
350			$('#modal-play-container').hide().data('pending', false);
351			$('#modal-play-container .modal-body').html('');
352		});
353
354	}).on('click', '.bg', function(){
355		$('#modal-play-container .close').trigger('click');
356
357	}).on('click', '.prev-btn', function(){
358		if (!$(this).hasClass('disabled') && BASIC.modalCallback && typeof BASIC.modalCallback == 'function') {
359			BASIC.modalCallback(BASIC.currentModal.closest('li').prev().find('a'));
360		}
361
362	}).on('click', '.next-btn', function(){
363		if (!$(this).hasClass('disabled') && BASIC.modalCallback && typeof BASIC.modalCallback == 'function') {
364			BASIC.modalCallback(BASIC.currentModal.closest('li').next().find('a'));
365		}
366
367	});
368
369	$('#main').on('touchstart', 'a.more-btn', function(){
370		BASIC.sign = true;
371
372	}).on('touchmove', function(){
373		BASIC.sign = false;
374		
375	}).on('touchend', 'a.more-btn', function(){
376		var $this = $(this),
377			link = $this.attr('href');
378
379		if(BASIC.sign && link){
380			BASIC.sign = false;
381			window.location = link;
382		}
383	});
384});

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.