header.js
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* 公共头部
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/1
*/
var $ = require('yoho-jquery');
var $searchWrap = $('.search-wrapper'),
$searchForm = $('#search-form'),
$searchKey = $('#search-key'),
$clearInput = $('.clear-input');
var delayer;
$('.yoho-group a').hover(function() {
var data = $(this).data();
$(this).text(data.cn);
}, function() {
var data = $(this).data();
$(this).text(data.en);
});
$('.contain-third').on({
mouseenter: function() {
var $thirdWrapper = $(this).children('.third-nav-wrapper');
delayer = setTimeout(function() {
$thirdWrapper.show();
}, 200);
},
mouseleave: function() {
var $thirdWrapper = $(this).children('.third-nav-wrapper');
if (delayer) {
clearTimeout(delayer);
}
$thirdWrapper.hide();
}
});
$('.search-entry').click(function() {
$searchWrap.show();
});
$searchForm.on('keyup', '#search-key', function(e) {
var key = $searchKey.val();
if (e.which === 13) {
if (key) {
$searchForm.submit();
}
}
if (key) {
$clearInput.show();
} else {
$clearInput.hide();
}
});
$clearInput.click(function() {
$searchKey.val('');
$(this).hide();
});
$(document).click(function(e) {
var $tar = $(e.target);
if (!$tar.closest('.search-entry').length) {
$searchWrap.hide();
}
});