//-------------参数配置---begin-----------
// 接口
var context = context ? context : "/sipspf";
var searchUrl = context + "/web/pub/hall/search";
var detailUrl = context + "/web/pub/hall/yewu";
var winUrl = context + "/web/pub/hall/window";
var allWinUrl = context + "/web/pub/hall/windows";
// home test
//var context = "/sipspf_test";
//var searchUrl = context + "/jsp/dating/search.jsp";
//var detailUrl = context + "/jsp/dating/ywdetail.jsp";
//var winUrl = context + "/jsp/dating/windetail.jsp";
//var allWinUrl = context + "/jsp/dating/win.jsp";
// 搜索结果刷新间隔
var interval = 60000;
// 放大/缩小倍率
var rate = 1.6;
var levelConfig = {
0 : {
"row" : 8,
"col" : 1,
"width" : 999,
"height" : 118,
"minRate" : 0,
"maxRate" : 0,
"mapbase" : context + "/jsp/dating/resources/images/maps0/"
},
1 : {
"row" : 1,
"col" : 1,
"width" : 3040,
"height" : 2900,
"minRate" : -2,
"maxRate" : 0,
"mapbase" : context + "/jsp/dating/resources/images/maps1/"
},
2 : {
"row" : 1,
"col" : 1,
"width" : 3040,
"height" : 2900,
"minRate" : -2,
"maxRate" : 0,
"mapbase" : context + "/jsp/dating/resources/images/maps2/"
},
3 : {
"row" : 2,
"col" : 1,
"width" : 999,
"height" : 470,
"minRate" : 0,
"maxRate" : 0,
"mapbase" : context + "/jsp/dating/resources/images/maps3/"
}
}
//-------------参数配置---end-----------
//-------------全局变量---begin---------
//当前楼层, 0, 1, 2
var level = 0;
//当前缩放等级: >0 放大, <0 缩小, =0 原始比率
var zoomRate = 0;
// 是否显示办事窗口提示信息
var bShowWinBox = false;
// 拖拽停止后300毫秒可点击
var dragstoptime = 300;
var canClick = true;
var searchword = "all";
var timer;
//-------------全局变量---end-----------
//-------------初始化-------begin-------
//初始化窗口数据
var wins;
function initAllWin() {
$.post(allWinUrl, function(data) {
if (data.result == 1) {
wins = data.bean;
} else {
alert(data.description);
}
}, "json");
}
//初始化地图图片
function initMap(l, callback) {
zoomRate = 0;
l = l == undefined ? 0 : l;
// if ($("div.map img").length != 0)
// cacheMap(level);
// if ($("div.cache div.mapcache[name=level" + l + "]").length == 0) {
// loadMap(l, callback);
// } else {
// loadMap(l, callback);
// }
// level = l;
loadMap2(l, callback);
if (levelConfig[l].minRate == levelConfig[l].maxRate)
$("div.actions div.zoomIn, div.actions div.zoomOut").hide();
else
$("div.actions div.zoomIn, div.actions div.zoomOut").show();
}
function cacheMap(level) {
if ($("div.cache div.mapcache[name=level" + level + "]").length == 0)
$("div.cache").append("
");
$("div.map img.map").appendTo("div.cache div.mapcache[name=level" + level + "]");
}
function loadCache(level) {
$("div.cache div.mapcache[name=level" + level + "] img").appendTo("div.map");
if (callback && $.isFunction(callback))
callback();
}
function loadMap2(l, callback) {
$(".navs a[title=" + l + "]").addClass("hover").siblings().removeClass("hover");
rows = levelConfig[l].row;
cols = levelConfig[l].col;
var width = levelConfig[l].width;
var height = levelConfig[l].height;
var maxRate = levelConfig[l].maxRate;
var minRate = levelConfig[l].minRate;
var mapbase = levelConfig[l].mapbase;
// if (maxRate == minRate)
// $("div.zoomIn, div.zoomOut").hide();
// else
// $("div.zoomIn, div.zoomOut").show();
hideWins();
hideWinBox();
if (l != level) {
$("div.cache div.mapcache[name=level" + level + "]").append($("div.map img"));
$("div.map").append($("div.cache div.mapcache[name=level" + l + "] img"));
level = l;
}
if ($("div.map img").length == 0) {
$("div.map").append($("div.cache div.mapcache[name=level0] img"));
}
var index = 0;
$("div.map img").each(function(n){
$(this).css({
"top" : height * (n / cols),
"left" : width * (n % cols),
"height" : height,
"width" : width
});
/*
if (init) {
$(this).load(function(){
index++;
if (index == rows * cols
&& callback && $.isFunction(callback)) {
callback();
}
});
}
*/
});
if (callback && $.isFunction(callback)) {
callback();
}
// var index = 0;
// for (var i = 0; i < rows; i++) {
// for (var j = 0; j < cols; j++) {
// $("
").load(function() {
// var rowcol = $(this).attr("id").split("_");
// $(this).css({
// top : $(this).height() * rowcol[1],
// left : $(this).width() * rowcol[2]
// });
// index++;
// if (index == rows * cols
// && callback && $.isFunction(callback)) {
// callback();
// }
// }).attr({
// "id" : "map_" + i + "_" + j,
// "src" : mapbase + "map_" + i + "_" + j + ".jpg",
// "class" : "map",
// "width" : width,
// "height" : height,
// "hidefocus" : true
// }).appendTo($("div.map"));
// }
// }
}
function loadMap(level, callback) {
$(".navs a[title=" + level + "]").addClass("hover").siblings().removeClass("hover");
rows = levelConfig[level].row;
cols = levelConfig[level].col;
var width = levelConfig[level].width;
var height = levelConfig[level].height;
var maxRate = levelConfig[level].maxRate;
var minRate = levelConfig[level].minRate;
var mapbase = levelConfig[level].mapbase;
// if (maxRate == minRate)
// $("div.zoomIn, div.zoomOut").hide();
// else
// $("div.zoomIn, div.zoomOut").show();
$("div.map img").remove();
hideWins();
hideWinBox();
var index = 0;
for (var i = 0; i < rows; i++) {
for (var j = 0; j < cols; j++) {
$("
").load(function() {
var rowcol = $(this).attr("alt").split("_");
$(this).css({
top : $(this).height() * rowcol[1],
left : $(this).width() * rowcol[2]
});
index++;
if (index == rows * cols
&& callback && $.isFunction(callback)) {
callback();
}
}).attr({
"alt" : "map_" + i + "_" + j,
"src" : mapbase + "map_" + i + "_" + j + ".jpg",
"class" : "map",
"width" : width,
"height" : height,
"hidefocus" : true,
"usemap" : "#mm_" + i + "_" + j
}).appendTo($("div.map"));
}
}
}
//-------------初始化数据---end---------
function changeLevel(n) {
canClick = true;
initMap(n, function() {
zoomInMax(0, 0, function(){
flashMapXY("center", "bottom", true, function(){
switch (n) {
case 0:
case "0":
showInfo("help");
bindLevel();
break;
case 3:
case "3":
searchFor("all");
bindLevel();
break;
default:
searchFor("all");
}
});
});
});
}
// 示意图窗口底部中央显示提示信息
function showMsg(msg) {
var showMapWidth = $(".dating").width() / 2;
if (!$(".detail").is(":hidden"))
showMapWidth -= $(".detail").width() / 2;
var bottom = $(".footer").height() + 12;
var left = $(".dating").offset().left + showMapWidth - $("div.msg").width() / 2;
$("div.msg").text(msg).css({
// top : $(".dating").height() - $(".navs").height() - $(".navs").css("top").replace("px", ""),
bottom : bottom,
left : left
// width : $(".detail").offset().left - $(".dating").offset().left
}).show('fast', function() {
setTimeout(function(){
$("div.msg").hide('slow');
}, 4000);
});
}
// 显示右侧详细信息窗口
// show: true 显示, false 隐藏
function showDetail(show) {
if (show) {
$(".detail").css({
left : $(".dating").offset().left + $(".dating").width() - $(".detail").width()
}).show();
$(".hider").css({
left : $(".dating").offset().left + $(".dating").width() - $(".hider").width() - $(".detail").width() + 1
});
$(".hider .pointer").css({
"background-position" : "-24px -352px"
});
} else {
var flash = false;
if (!$(".detail").is(":hidden")) {
flash = true;
}
$(".detail").css({
left : $(".dating").offset().left + $(".dating").width()
}).hide();
$(".hider").css({
left : $(".dating").offset().left + $(".dating").width() - $(".hider").width() + 1
});
$(".hider .pointer").css({
"background-position" : "-14px -352px"
});
if (flash)
flashMap();
}
}
// 改变窗口大小
function resize() {
var width = $(window).width();
var height = $(window).height();
$(".main").height(height - $(".header").height() - $(".footer").height());
$(".dating").outerHeight(height - $(".header").height() - $(".footer").height());
$(".info").outerHeight($(".dating").height() - $(".search").outerHeight());
if ($(".info .inner").outerHeight() > $(".info").innerHeight()) {
$(".info").css({
"overflow-y" : "scroll"
});
} else {
$(".info").css({
"overflow-y" : "hidden"
});
}
$(".navs").css({
"top" : $(".dating").offset().top + 28
});
$(".detail").css({
"top" : $(".dating").offset().top
});
$(".actions").css({
"bottom" : $(".footer").height() + 120
});
$(".hider").css({
"top" : $(".dating").offset().top + ($(".dating").height() - $(".hider").height()) / 2
});
}
// 绑定楼层图点击效果
function bindLevel() {
var mapbase = levelConfig[0].mapbase;
var level1 = $("div.map img.map_7_0");
var level2 = $("div.map img.map_6_0");
switch (level) {
case 0:
case "0":
break;
case 3:
case "3":
level1 = $("div.map img.map_1_0");
level2 = $("div.map img.map_0_0");
break;
default:
return;
}
level1.unbind("click").click(function() {
if (canClick)
changeLevel(1);
}).mouseenter(function(e){
$(this).css("cursor", "pointer");
if (level == 0) {
$(this).attr("src", mapbase + "map_7_0_1.jpg");
}
var top = $(this).offset().top;
var left = $(".hider").offset().left;
showWinBox("公积金中心一楼办事大厅", "公积金中心一楼办事大厅可办理业务咨询、业务预审、医疗、工伤、信息维护及缴费等业务", 1, top, left, true);
$("div.win").unbind("mouseover");
$("div.map").unbind("mouseout,mouseleave");
}).mouseleave(function(){
if (level == 0) {
$(this).attr("src", mapbase + "map_7_0.jpg").css("cursor", "grab");
}
hideWinBox();
});
level2.unbind("click").click(function() {
if (canClick)
changeLevel(2);
}).mouseenter(function(e){
$(this).css("cursor", "pointer");
if (level == 0) {
$(this).attr("src", mapbase + "map_6_0_1.jpg");
}
var top = $(this).offset().top;
var left = $(".hider").offset().left;
showWinBox("公积金中心二楼办事大厅", "公积金中心二楼办事大厅可办理区外转出转入、出国一次性提取、财务收缴支出、社会化服务、缴费稽核及投诉等业务", 1, top, left, true);
$("div.win").unbind("mouseover");
$("div.map").unbind("mouseout,mouseleave");
}).mouseleave(function(){
$(this).css("cursor", "grab");
if (level == 0) {
$(this).attr("src", mapbase + "map_6_0.jpg");
}
hideWinBox();
});
}
// 刷新地图位置
function flashMap() {
var oX = $("div.map").css("left").replace("px", "");
var oY = $("div.map").css("top").replace("px", "");
flashMapXY(oX, oY, true);
}
function flashMapXY(oX, oY, animate, callback) {
if ($("img.map").length == 0)
return;
var imgLeftMax = - $("img.map").eq(0).css("left").replace("px", "");
var imgTopMax = - $("img.map").eq(0).css("top").replace("px", "");
var infoWidth = $(".detail").width();
//$("div.content").is(":hidden") ? 0 : $("div.content").outerWidth();
if ($(".detail").is(":hidden"))
infoWidth = 0;
var imgLeftMin = imgLeftMax - ($("img.map").width() * cols - $("div.dating").width() + infoWidth);
var imgTopMin = imgTopMax - ($("img.map").height() * rows - $("div.dating").height());
switch (oX) {
case "left":
oX = imgLeftMin;
break;
case "right":
oX = imgLeftMax;
break;
case "center":
oX = (imgLeftMax + imgLeftMin) / 2;
break;
default:
oX = oX < imgLeftMin ? imgLeftMin : oX;
oX = oX > imgLeftMax ? imgLeftMax : oX;
break;
}
switch (oY) {
case "top":
oY = imgTopMax;
break;
case "bottom":
oY = imgTopMin;
break;
case "center":
oY = (imgTopMax + imgTopMin) / 2;
break;
default:
oY = oY < imgTopMin ? imgTopMin : oY;
oY = oY > imgTopMax ? imgTopMax : oY;
break;
}
hideWins();
if (animate) {
$("div.map").animate({
"left" : oX + "px",
"top" : oY + "px"
}, 'fast', function(){
flashWins();
if (callback && $.isFunction(callback))
callback();
});
} else {
$("div.map").css({
"left" : oX + "px",
"top" : oY + "px"
});
if (callback && $.isFunction(callback))
callback();
}
}
// 放大缩小函数
// (x, y)缩放中心坐标,rate缩放比率
// num: 缩放次数
function zoom(x, y, curRate, callback) {
hideWins();
$(".dating img.map").each(function(n) {
var t = $(this).offset().top;
var l = $(this).offset().left;
var offsetX = $("div.map").offset().left;
var offsetY = $("div.map").offset().top;
var top = t - offsetY - (y - t) * (curRate - 1);
var left = l - offsetX - (x - l) * (curRate - 1);
$(this).animate({
height : $(this).height() * curRate,
width : $(this).width() * curRate,
top : top,
left : left
}, 'fast', function(){
if (n == $(".dating img.map").length - 1) {
flashMap();
if (callback && $.isFunction(callback))
callback();
}
});
});
}
// 缩小
function zoomIn(x, y, callback) {
zoomRate--;
if (zoomRate < levelConfig[level].minRate) {
zoomRate = levelConfig[level].minRate;
showMsg("已是最小比率,无法再缩小");
return;
}
zoom(x, y, 1/rate, callback);
}
function zoomInMax(x, y, callback) {
var zoomNum = levelConfig[level].minRate - zoomRate;
if (zoomNum) {
zoomRate = levelConfig[level].minRate;
var curRate = Math.pow(rate, zoomNum);
zoom(x, y, curRate, callback);
} else if (callback && $.isFunction(callback)) {
callback();
}
}
// 放大
function zoomOut(x, y, callback) {
zoomRate++;
if (zoomRate > levelConfig[level].maxRate) {
zoomRate = levelConfig[level].maxRate;
showMsg("已是最大比率,无法再放大");
return;
}
zoom(x, y, rate, callback);
}
function zoomOutMax(x, y, callback) {
var zoomNum = levelConfig[level].maxRate - zoomRate;
if (zoomNum) {
zoomRate = levelConfig[level].maxRate;
var curRate = Math.pow(rate, zoomNum);
zoom(x, y, curRate, callback);
} else if (callback && $.isFunction(callback)) {
callback();
}
}
var curWinid = -1;
function showWinDetail(winid) {
if (winid != curWinid) {
curWinid = winid;
$.ajax({
url : winUrl + "?random=" + new Date().getTime(),
data : {"id" : winid},
dataType : "json",
method : "post",
success : function(data){
if (!data.result) {
return;
}
var window = data.bean;
var room = $("div.info div.inner div.room");
$("h3.title", room).text(window.windowposition + "楼"
+ window.windowname.substring(0, 1) + "区"
+ window.windowname + "窗口");
$("p.summary", room).text(window.summary ? window.summary : "");
// 业务
var yewus = data.array;
var bus = $("dl.business", room);
$("dd, dt", bus).remove();
if (yewus && yewus.length != 0) {
for (var b in yewus) {
var yw = "
";
yw += (parseInt(b) + 1) + ". " + yewus[b].ywname + "";
yw += "
排队情况当前等候人数 | "
+ (yewus[b].waitNum ? yewus[b].waitNum : 0) + " |
";
$(bus).append(yw);
}
bus.show();
} else {
bus.append("
该窗口暂不办理中心业务").show();
}
showInfo("room");
},
error : function(data) {
alert(data.msg);
}
});
} else {
showInfo("room");
}
}
var curYwid = -1;
function showYwDetail(ywid) {
if (ywid != curYwid) {
curYwid = ywid;
$.ajax({
url : detailUrl + "?random=" + new Date().getTime(),
data : {"id" : ywid},
dataType : "json",
method : "post",
success : function(data, status){
if (data.result != 1) {
alert(data.description);
} else {
var json = data.bean;
// 基本信息、政策、指南、下载、在线办理
var zzxD = ["bs", "zc", "zn", "xz", "ol"];
for (var i in zzxD) {
json[zzxD[i]] = new Array();
}
for (var i in json.yewudetail) {
var detail = json.yewudetail[i];
var obj = new Object();
obj.name = detail.title;
obj.url = detail.info;
var zzx = zzxD[detail.status];
json[zzx].push(obj);
}
var ywinfo = $("div.info div.inner div.ywinfo");
$("h3.title", ywinfo).text(json.ywname);
// 政策、指南、下载
var zcznxz = ["zc", "zn", "xz"];
for (var i in zcznxz) {
var dl = $("dl." + zcznxz[i], ywinfo);
if (json[zcznxz[i]] && json[zcznxz[i]].length != 0) {
var ul = $("ul", dl);
ul.empty();
for (var zi in json[zcznxz[i]]) {
ul.append("
"
+ json[zcznxz[i]][zi].name + "");
}
dl.show();
} else {
dl.hide();
}
}
// 在线办理
if (json.ol && json.ol.length != 0) {
$("a.online", ywinfo).attr("href", json.ol[0].url).show();
} else {
$("a.online", ywinfo).hide();
}
showInfo("ywinfo");
bindWinLocate();
}
},
error : function(data) {
alert(data.msg);
}
});
} else {
showInfo("ywinfo");
}
}
// 刷新窗口位置
var winOffsetX = 0;
var winOffsetY = 0;
function flashWins() {
if (wins) {
var windows = $("div.windows");
windows.empty();
hideWins();
windows.offset($("img.map_0_0").offset());
var curRate = Math.pow(rate, zoomRate)
// var areawins = $("ul.area_wins").empty();
for (var win in wins) {
if (wins[win].windowposition != level) {
continue;
}
var window = wins[win];
var winTop = parseInt(wins[win].yinfo) * curRate - 10;
var winLeft = parseInt(wins[win].xinfo) * curRate - 10;
var leftMin = $(".dating").offset().left - windows.offset().left;
var topMin = $(".dating").offset().top - windows.offset().top;
var leftMax = leftMin + $(".dating").width() - 40;
if (!$(".detail").is(":hidden")) {
leftMax -= $(".detail").width();
}
var topMax = topMin + $(".dating").height() - 20;
if (winTop > topMin && winLeft > leftMin && winTop < topMax && winLeft < leftMax) {
windows.append('
'
+ window.windowname + '
');
// areawins.append('
'
// + window.windowposition + "楼"
// + window.windowname.substring(0, 1) + "区"
// + window.windowname + "窗口" + '');
}
}
showWins();
bindWins();
// if ($("li", areawins).length == 0) {
// areawins.append('
当前区域内无办事窗口');
// } else {
// bindAreaWins();
// }
// if ($(".info .inner").outerHeight() > $(".info").innerHeight()) {
// $(".info").css({
// "overflow-y" : "scroll"
// });
// } else {
// $(".info").css({
// "overflow-y" : "hidden"
// });
// }
//bindWinLocate();
}
}
function hideWins() {
$("div.windows").css("visibility", "hidden");
}
function showWins() {
$("div.windows").css("visibility", "visible");
}
function bindAreaWins() {
$("ul.area_wins li").css({
"cursor" : "pointer"
}).mouseover(function(){
$(this).css({
"color" : "red"
});
$("div.window[value=" +$(this).attr("alt")+ "]").addClass("winhover");
}).mouseout(function(){
$(this).css({
"color" : "black"
});
$("div.window[value=" +$(this).attr("alt")+ "]").removeClass("winhover");
}).click(function() {
var winid = $(this).attr("alt");
showWinDetail(winid);
});
}
// 鼠标滑动窗口时,浮现层显示窗口信息
// top, left:相对页面左上角的坐标
function showWinBox(title, summary, yewus, top, left, alwaysshow) {
$("div.win h3.title").text(title);
$("div.win p.summary").text(summary ? summary : "");
$("div.win ul.bussiness").empty();
if (yewus == 1) {
$("div.win dl").hide();
} else if (yewus && yewus.length != 0) {
for (var b in yewus) {
$("div.win ul.bussiness").append("
" + yewus[b].ywname + "");
}
$("div.win dl").show();
} else {
$("div.win ul.bussiness").append("
该窗口暂不办理中心业务");
$("div.win dl").show();
}
// 转换成相对显示区域dating左上角的坐标
top -= $(".dating").offset().top;
left -= $(".dating").offset().left;
top = top < 0 ? 0 : top;
left = left < 0 ? 0 : left;
var detailWidth = 0;
if (!$(".detail").is(":hidden")) {
detailWidth = $(".detail").width();
}
if (left + $(".win").width() > $(".dating").width() - detailWidth) {
left -= $(".win").width() + 2;
} else {
left += 2;
}
if (top + $(".win").height() > $(".dating").height()) {
top -= $(".win").height() + 2;
} else {
top += 2;
}
$("div.win").css({
"top" : top,
"left" : left
}).show();
if (!alwaysshow) {
$("div.win").mouseover(function(){
if (yewus != 1) {
hideWinBox();
}
});
$("div.map").unbind("mouseout").mouseout(hideWinBox);
$("div.map").unbind("mouseleave").mouseleave(hideWinBox);
$("div.detail, div.header, div.footer").unbind("mouseover").mouseover(hideWinBox);
}
}
function hideWinBox() {
bShowWinBox = false;
$("div.win").hide();
}
function bindWins() {
// 办事窗口信息提示窗口
$("div.window").mouseenter(function(e) {
$(".dating").css({
"cursor" : "pointer"
});
$(this).addClass("winhover");
// 获取窗口信息
var winid = $(this).attr("value");
bShowWinBox = true;
$.ajax({
url : winUrl + "?random=" + new Date().getTime(),
data : {"id" : winid},
dataType : "json",
method : "post",
success : function(json){
if (!json.result) {
return;
}
var window = json.bean;
var yewus = json.array;
if (bShowWinBox) {
if (!yewus && window.windowid >= 14 && window.windowid <= 23) {
showWinBox(window.windowposition + "楼"
+ window.windowname.substring(0, 1) + "区"
+ window.windowname + "窗口", "银行业务窗口", 1,
e.clientY, e.clientX);
} else if (!yewus && window.windowid >= 58 && window.windowid <= 66) {
showWinBox(window.windowposition + "楼"
+ window.windowname.substring(0, 1) + "区"
+ window.windowname + "窗口", "自助服务窗口", 1,
e.clientY, e.clientX);
} else {
showWinBox(window.windowposition + "楼"
+ window.windowname.substring(0, 1) + "区"
+ window.windowname + "窗口", window.summary, yewus,
e.clientY, e.clientX);
$("div.win").unbind("mouseleave").mouseleave(function (){
$(this).hide();
});
}
}
},
error : function(data) {
}
});
}).mouseleave(function() {
$("div.win").hide();
$(".dating").css({
"cursor" : "grab"
});
$(this).removeClass("winhover");
}).click(function() {
showWinDetail($(this).attr("value"));
showDetail(true);
});
}
var backArray = new Array();
var curr = "";
function showInfo(name, nopush) {
$("div.inner div." + name).show().siblings().hide();
bind(name);
curr = name;
backArray.push(name);
resize();
}
function back() {
var name = backArray.pop();
while(curr == name)
name = backArray.pop();
showInfo(name);
}
// 绑定info事件
function bind(name) {
switch(name) {
case "winlist":
backArray = new Array();//.fill();
break;
case "room":
bindRoom(true);
break;
case "result":
bindResult();
backArray = new Array();//.fill();
break;
case "ywinfo":
bindYwInfo(true);
break;
default:
break;
}
}
function bindResult() {
$("div.result dl.yw01").unbind("hover").hover(function(){
$(this).css({
"background" : "#fff0ed"
});
}, function(){
$(this).css({
"background-color" : "white"
});
});
$("div.result dl.yw02").unbind("hover").hover(function(){
$(this).css({
"background" : "#fff0ed"
});
}, function(){
$(this).css({
"background-color" : "#eeeeee"
});
});
$("div.result dl.yw dd.yewudetail").unbind("click").click(function(){
showYwDetail($(this).attr("value"));
//showInfo("ywinfo");
});
}
function bindYwInfo(back) {
// 返回搜索结果
if (back) {
$("div.ywinfo i.back").show();
} else {
$("div.ywinfo i.back").hide();
}
// 办事窗口
$("div.ywinfo dl.winid dd").unbind("hover").hover(function(){
$(this).css({
"color" : "red"
});
}, function(){
$(this).css({
"color" : "black"
});
}).unbind("click").click(function(){
showWinDetail($(this).attr("value"));
return true;
});
}
function bindRoom(back) {
// 返回
if (back) {
$("div.room i.back").show();
} else {
$("div.room i.back").hide();
}
// 查看业务详情
// $("div.room dl.business dd").unbind("hover").hover(function(){
// $(this).css({
// "background" : "#f0f0f0"
// });
// }, function(){
// $(this).css({
// "background" : "none"
// });
// }).unbind("click").click(function(){
// showYwDetail($(this).attr("value"));
// });
}
// 点击信息区域窗口跳转
function bindWinLocate() {
$("dd.winlocate").unbind("click").click(function(){
var winid = $(this).attr("value");
var win = wins[winid];
if (!win)
win = wins[$(this).attr("alt")];
var showMapWidth = $(".dating").width() / 2;
if (!$(".detail").is(":hidden"))
showMapWidth -= $(".detail").width() / 2;
var showMapHeight = $(".dating").height() / 2;
initMap(win.windowposition, function(){
flashMapXY(showMapWidth - win.xinfo, showMapHeight - win.yinfo, true, function() {
$("div.window[value=" + winid + "]").addClass("winhover");
});
});
}).mouseover(function(){
$(this).addClass("winhover");
$("div.window[value=" + $(this).attr("value") + "]").addClass("winhover");
}).mouseout(function(){
$(this).removeClass("winhover");
$("div.window[value=" + $(this).attr("value") + "]").removeClass("winhover");
});
}
// 点击搜索业务的网上业务、业务指南、互动交流、政策法规、下载专区
function bindYewuSearch() {
$("dd.yewusearch").unbind("click").click(function(){
$("div.searchForm input#q").val($(this).attr("value"));
$("div.searchForm input#adinfq").val("tabName:*" + $(this).text() + "*");
$("div.searchForm form").submit();
});
}
function searchFor(keyword) {
keyword = keyword ? keyword : "";
searchword = keyword;
$.post(searchUrl, {
"busi" : keyword
}, function(data) {
if (data.result == 1) {
var yewus = data.bean;
if (yewus) {
if (keyword == "all") {
$(".result h3.title").html("").hide();
} else {
$(".result h3.title").html('"
' + keyword + '"的搜索结果(共
' + yewus.length + "个相关业务)");
}
$(".result .yw").remove();
for (i in yewus) {
var yewu = yewus[i];
var dl = '
';
dl += '- ' + (parseInt(i) + 1) + '.' + yewu.ywname + '
';
dl += '排队情况当前等候人数 | '
+ yewu.waitNum + ' |
';
dl += '- 网上业务
';
dl += '- 业务指南
';
dl += '- 互动交流
';
dl += '- 政策法规
';
dl += '- 下载专区
';
if (yewu.windows != null && yewu.windows.length > 0) {
dl += '- 可办理该业务的窗口有:
';
for (j in yewu.windows) {
dl += '- '
+ yewu.windows[j].windowposition + "楼"
+ yewu.windows[j].windowname.substring(0, 1) + "区"
+ yewu.windows[j].windowname + '窗口
';
}
dl += '
';
} else {
dl += "";
}
dl += '
';
$(".result").append(dl);
}
}
$("div.info").scrollTop(0);
showInfo("result");
bindYewuSearch();
bindWinLocate();
} else {
alert(data.description);
}
clearInterval(timer);
timer = setInterval(function(){
if (!$("div.result").is(":hidden"))
searchFor(searchword);
}, interval);
}, "json");
}
$(function() {
// 双击放大
$("div.map").dblclick(function(e) {
var e = e || window.event;
var x = e.clientX;
var y = e.clientY;
zoomOut(x, y);
})
// 去除右键点击及选中效果
$(".dating *").attr('unselectable', 'on').css({
'-moz-user-select' : '-moz-none',
'-moz-user-select' : 'none',
'-o-user-select' : 'none',
'-khtml-user-select' : 'none', /* you could also put this in a class */
'-webkit-user-select' : 'none',/* and add the CSS class here instead */
'-ms-user-select' : 'none',
'user-select' : 'none'
}).bind('selectstart', function() {
return false;
}).bind('contextmenu', function(e) {
return false;
});
// 右键双击缩小
var dbl = 0;
$("div.map").attr('unselectable', 'on').css({
'-moz-user-select' : '-moz-none',
'-moz-user-select' : 'none',
'-o-user-select' : 'none',
'-khtml-user-select' : 'none', /* you could also put this in a class */
'-webkit-user-select' : 'none',/* and add the CSS class here instead */
'-ms-user-select' : 'none',
'user-select' : 'none'
}).bind('selectstart', function() {
return false;
}).bind('contextmenu', function(e) {
return false;
}).mousedown(function(e) {
var e = e || window.event;
var x = e.clientX;
var y = e.clientY;
if (3 == e.which) {
dbl++;
if (dbl >= 2) {
dbl = 0;
zoomIn(x, y);
}
setTimeout(function() {
dbl = 0;
}, 1000);
}
})
// 拖拽效果
var dragging = false;
var iX, iY;
$("div.map").mousedown(function(e) {
if (3 != e.which) {
dragging = true;
iX = e.clientX - $(this).css("left").replace("px", "");
iY = e.clientY - $(this).css("top").replace("px", "");
this.setCapture && this.setCapture();
$(".dating").css({
"cursor" : "grabbing"
});
return false;
}
});
$("div.map").mousemove(function(e) {
if (dragging && 3 != e.which) {
var e = e || window.event;
var oX = e.clientX - iX;
var oY = e.clientY - iY;
flashMapXY(oX, oY, false);
canClick = false;
return false;
}
});
$("div.map").mouseup(function(e) {
dragging = false;
flashWins();
$("div.map")[0].releaseCapture();
e.cancelBubble = true;
$(".dating").css({
"cursor" : "grab"
});
setTimeout(function(){
canClick = true;
}, dragstoptime);
});
// 切换右侧信息区域
var hider = false;
$(".hider").click(function() {
if (!hider) {
showDetail(hider);
hider = true;
} else {
showDetail(hider);
hider = false;
}
}).mouseenter(function() {
if (hider) {
$(".hider .pointer").css({
"background-position" : "-5px -352px"
});
} else {
$(".hider .pointer").css({
"background-position" : "-33px -352px"
});
}
}).mouseleave(function() {
if (hider) {
$(".hider .pointer").css({
"background-position" : "-14px -352px"
});
} else {
$(".hider .pointer").css({
"background-position" : "-24px -352px"
});
}
});
// 操作按钮:放大缩小
$(".zoomIn").mousedown(function(e){
e.cancelBubble=true;
}).click(function(){
var x = $(".dating").offset().left + $(".detail").css("left").replace("px", "") / 2;
var y = $(".dating").offset().top + $(".dating").height() / 2;
zoomOut(x, y);
return true;
});
$(".zoomOut").mousedown(function(e){
e.cancelBubble=true;
}).click(function(){
var x = $(".dating").offset().left + $(".detail").css("left").replace("px", "") / 2;
var y = $(".dating").offset().top + $(".dating").height() / 2;
zoomIn(x, y);
return true;
});
// 操作按钮:上下左右中
var step = 200;
$(".actions div").click(function() {
var oX = parseInt($("div.map").css("left").replace("px", ""));
var oY = parseInt($("div.map").css("top").replace("px", ""));
switch($(this).attr("class")) {
case 'up' :
flashMapXY(oX, oY + step, true);
break;
case 'down' :
flashMapXY(oX, oY - step, true);
break;
case 'left' :
flashMapXY(oX + step, oY, true);
break;
case 'right' :
flashMapXY(oX - step, oY, true);
break;
case 'center' :
flashMapXY("center", "center", true);
break;
}
});
// 操作按钮鼠标悬浮效果
$(".actions div.zoomIn").mouseover(function() {
$(this).css({
"background-position" : "0 -287px"
});
}).mouseout(function() {
$(this).css({
"background-position" : "0 -265px"
});
});
$(".actions div.zoomOut").mouseover(function() {
$(this).css({
"background-position" : "0 -331px"
});
}).mouseout(function() {
$(this).css({
"background-position" : "0 -309px"
});
});
$(".actions div.direct div").each(function(n){
var top = - 44 * (n + 1);
$(this).mouseover(function(e) {
$(this).parent().css({
"background-position" : "0 " + top + "px"
});
}).mouseout(function() {
$(this).parent().css({
"background-position" : "0 0px"
});
});
});
// 楼层图切换
$(".navs a").each(function(n) {
$(this).click(function(){
changeLevel($(this).attr("title"));
});
});
// 窗口改变大小时重新定位
$(window).resize(resize);
// 搜索业务
$("form#search button.submit").click(function(){
var keyword = $("#keyword").val();
searchFor(keyword);
return false;
});
$("form#search").submit(function(){
$("form#search button.submit").click();
return false;
});
// 后退
$("div.inner i.back").unbind("hover").hover(function(){
$(this).css({
"color" : "red"
});
}, function(){
$(this).css({
"color" : "black"
});
}).unbind("click").click(function(){
back();
});
// 初始化办事窗口数据
resize();
initAllWin();
showDetail(true);
changeLevel(0);
});