map_pad.js
3.49 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* @fileOverview 首页JS
* @author wei.wang@yoho.cn
* @date 2014-05-21
*/
var $=require("jquery");
//require("lib/ui/touch");
//require("lib/util/jquery.hammer");
require("../public");
require("jquery.imagesloaded");
var currentZoom=0.85;
var OriginalWidth=0,OriginalHeight=0,OriginalMarks={};
window.onresize=function(){
initShopListHeight();
var bodyWidth=document.body.clientWidth;
$("#citymap").width(bodyWidth-$(".city-shop-list").width());
var contentWidth = $(".map-city-content").width();
var currentLeft=parseFloat(contentWidth-$("#citymap").width());
$("#citymap").css({"left":currentLeft,top:0});
}
exports.init=function(){
initShopListHeight();
$(".city-list").find("div").niceScroll();
$(document.body).css({overflow:"hidden"});
var bodyWidth=document.body.clientWidth;
$("#citymap-img").imagesLoaded(function()
{
$(this).width("100%").height("100%");
});
$(".shop").hover(
function(){
$(".mark-tips").hide();
var shopId=$(this).id().replace("shoplist-","mark");
var shopObj=$("#"+shopId);
var top=0;
var left=0;
var _top=parseFloat($("#"+shopId)[0].style.top.replace("%",""));
var _left=parseFloat($("#"+shopId)[0].style.left.replace("%",""));
top=_top/100*$("#citymap").height();
left=_left/100*$("#citymap").width();
console.log(top,left);
console.log(bodyWidth-shopObj.offset().left);
if(top<120&&left<250){
//显示在右下角
$("#"+shopId).find(".mark-tips").attr("class","mark-tips left-bottom");
}
else if(top>120&&left<250)
{
//显示在右上角
$("#"+shopId).find(".mark-tips").attr("class","mark-tips left");
}
else if(top<120&&left>250&&bodyWidth-shopObj.offset().left>250)
{
//显示在左下角
$("#"+shopId).find(".mark-tips").attr("class","mark-tips left-bottom");
}
else if (top<120&&left>250&&bodyWidth-shopObj.offset().left<250) {
$("#"+shopId).find(".mark-tips").attr("class","mark-tips right-bottom");
}
else if(top>120&&left>250&&bodyWidth-shopObj.offset().left>250)
{
//显示在左角
$("#"+shopId).find(".mark-tips").attr("class","mark-tips left");
}
else if(top>120&&left>250&&bodyWidth-shopObj.offset().left<250)
{
//显示在左角
$("#"+shopId).find(".mark-tips").attr("class","mark-tips right");
}
$("#"+shopId).find(".mark-tips").show().unbind().click(function(){
var href=$("a[val='"+$(this).parent().attr("val")+"']").attr("src");
window.open(href);
});
},
function(){
var shopId=$(this).id().replace("shoplist-","mark");
}
);
$("#citymap-img").width("100%").height("100%");
var bodyHeight = document.body.clientHeight - 177;
$(".map-city-content").height(bodyHeight);
$("#citymap").width(bodyWidth-$(".city-shop-list").width());
var contentWidth = $(".map-city-content").width();
var currentLeft=parseFloat(contentWidth-$("#citymap").width());
$("#citymap").css({"left":currentLeft,top:0});
var currentTop=parseFloat($("#citymap").css("top").replace("px",""));
};
function initShopListHeight(){
var currentWidth=document.body.clientWidth;
if(currentWidth>=1190)
{
$(".city-list").height(document.body.clientHeight-310);
}
else if(currentWidth<1190&¤tWidth>=769)
{
$(".city-list").height(document.body.clientHeight-260);
}
else if(currentWidth<=768)
{
$(".city-list").height(document.body.clientHeight-268);
}
}