-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.js
More file actions
79 lines (63 loc) · 1.88 KB
/
common.js
File metadata and controls
79 lines (63 loc) · 1.88 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
75
76
77
78
79
import $ from 'jquery'
function toggleHeaderActive() {
let path = location.pathname
let mpath = path.substr(path.lastIndexOf('/') + 1)
$(`.header-container a`).children().removeClass('active')
$(`.header-container a[href$="${mpath}"]`).children().addClass('active')
}
let mapstimer
function maps() {
let map = new AMap.Map($('.map-container')[0],{
resizeEnable: true,
zoom: 10,
center: [112.5650543, 37.81794196]
})
let marker = new AMap.Marker({
position:[112.5650543, 37.81794196]
})
let info = new AMap.InfoWindow({
content: '<div class="title">高德地图</div><div class="content">'+
'高德是中国领先的数字地图内容、导航和位置服务解决方案提供商。<br/>',
offset:new AMap.Pixel(0,-28),
size:new AMap.Size(200,0)
})
marker.setMap(map)
map.setFitView()
info.open(map, marker.getPosition())
}
function toggleMaps() {
$('.map-overlay').on('click', function() {
$('.map').height(460)
$('.map-container').height(460).empty()
$('.map-dd').show()
$(this).hide()
clearTimeout(mapstimer)
mapstimer = setTimeout(maps, 1000)
})
$('.map-dd').on('click', function() {
$('.map').height(90)
$('.map-container').height(90).empty()
$('.map-overlay').show()
$(this).hide()
clearTimeout(mapstimer)
mapstimer = setTimeout(maps, 1000)
})
}
function sidebar() {
$('.home-0-block').on('mouseenter mouseleave', function(evt) {
let $elem = $(this).find('img')
let src = $elem.prop('src')
let matched = src.match(/(.*?home-0-)([\w|-]+)(.png)/)
$elem.prop('src', matched[1] +
(matched[2].length === 1 ? matched[2] + '-active' : matched[2].substr(0, matched[2].indexOf('-'))) +
matched[3])
})
}
function main() {
sidebar()
toggleHeaderActive()
toggleMaps()
clearTimeout(mapstimer)
mapstimer = setTimeout(maps, 1000)
}
main()