/*
hdPic:高清组图专用脚本
@作者:tomiezhang#tencent.com
*/
/*json begin*/
var JSON=new function(){
this.decode=function(){
var filter,result,self,tmp;
if($$("toString")){
switch(arguments.length){
case 2:
self=arguments[0];
filter=arguments[1];
break;
case 1:
if($[typeof arguments[0]](arguments[0])===Function){
self=this;filter=arguments[0]
}else self=arguments[0];
break;
default:
self=this;
break;
}
if(rc.test(self))
{
try{
result=e("(".concat(self,")"));
if(filter&&result!==null&&(tmp=$[typeof result](result))&&(tmp===Array||tmp===Object))
{
for(self in result)result[self]=v(self,result)?filter(self,result[self]):result[self]
}
}catch(z){}
}else{
throw new JSONError("bad data");
}
};
return result;
}
this.encode=function(){
var self=arguments.length?arguments[0]:this,result,tmp;
if(self===null)
{
result="null";
}else if(self!==undefined&&(tmp=$[typeof self](self)))
{
switch(tmp){
case Array:
result=[];
for(var i=0,j=0,k=self.length;j");
$("h2").html($("h1").html());
},
_hideLast:function(){//隐藏末页推荐
$("#end").animate({top:"-528px"},"slow",function(){
$(".pageLeft").height($("#Main-A").height());
$(".pageLeft span").css("marginTop",parseInt(($("#Main-A").height()-95)/2));
$(".pageLeft-bg").height($("#Main-A").height());
$(".pageRight").height($("#Main-A").height());
$(".pageRight span").css("marginTop",parseInt(($("#Main-A").height()-95)/2));
$(".pageRight-bg").height($("#Main-A").height());
$("#mouseOverleft").height($("#Main-A").height());
$("#mouseOverright").height($("#Main-A").height());
});
},
_clickleft:function(data){//向前点
if(hdPic.fn._pageNow>0){
hdPic.fn._pageNow--;
}else{
hdPic.fn._pageNow = 0;
}
hdPic.fn._showBig(data,hdPic.fn._pageNow);
},
_clickright:function(data){//向后点
if(hdPic.fn._pageNowhdPic.fn._scrollCell){
$(".scrollButton").mousedown(function(e){
hdPic.fn._stopAuto();
//设置捕获范围
if($(".scrollButton").setCapture){
$(".scrollButton").setCapture();
}else if(window.captureEvents){
window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
}
hdPic.fn._isMove = true;
hdPic.fn._dragx = e.pageX-parseInt($(".scrollButton").css("left"));
$(".scrollButton").fadeTo(20, 0.5);
$("a.mask").hide();
//禁用页面选择,防止拖拽时选中附近文字
document[document.all?"onselectstart":"onmousedown"]= function(){return false;}
console.log(hdPic.fn._isMove);
});
$(document).mousemove(function(e){
if(hdPic.fn._isMove){
var x=Math.max(0, Math.min(e.pageX-hdPic.fn._dragx,759));
$(".scrollButton").css({left:x});
hdPic.fn._dragmov();
}
}).mouseup(function(){
if(hdPic.fn._isMove){
//解锁页面选择
document[document.all?"onselectstart":"onmousedown"]=null;
hdPic.fn._isMove=false;
//取消捕获范围
if($(".scrollButton").releaseCapture){
$(".scrollButton").releaseCapture();
}else if(window.captureEvents){
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
$(".scrollButton").fadeTo("fast", 1);
if(parseInt($("#Smailllist").css("left"))%131!==0){
var argleft = parseInt($("#Smailllist").css("left"));
$("#Smailllist").animate({left:argleft+(Math.abs(parseInt($("#Smailllist").css("left"))%131))+"px"},"fast");
};
}
});
};
//自动播放
$(".play").click(function(){
if(!hdPic.fn._isAuto){
hdPic.fn._autoplay(data);
}else{
hdPic.fn._stopAuto();
}
});
//快捷键
$(document).bind("keydown",function(e){
e = window.event || e;
hdPic.fn._stopAuto();
e.keyCode == 37 && hdPic.fn._clickleft(data);
e.keyCode == 39 && hdPic.fn._clickright(data);
e.keyCode == 38 && hdPic.fn._clickleft(data);
e.keyCode == 40 && hdPic.fn._clickright(data);
});
//焦点
var scrollSheet;
var rootNode = document.documentElement;
var body = document.body;
if((/AppleWebKit/i).test(window.navigator.userAgent)){
scrollSheet = body;
}else if(rootNode.offsetHeight>=body.offsetHeight&&rootNode.scrollHeight>=body.scrollHeight){
scrollSheet = rootNode;
}else{
scrollSheet = body;
}
var _topnav = $("#toolBar").offset().top;
$(scrollSheet).animate({scrollTop:_topnav - 10}, 1000);
},
_stopAuto:function(){//停止自动播放
$(".play").text("幻灯播放");
$(".play").removeClass("stop");
hdPic.fn._isAuto = false;
window.clearInterval(hdPic.fn._autoTimer);
},
_autoplay:function(data){//自动播放
$(".play").text("停止播放");
$(".play").addClass("stop");
hdPic.fn._isAuto = true;
this._autoTimer = window.setInterval(function(){
if(hdPic.fn._pageNow'+this._tmpArray[n].showtit+'
');
$("#Main-B").fadeIn("slow");
},
_creatUrl:function(n){//创建组图浏览url标识
var _org = /\#p\=/i.test(window.location.href);
if(!_org){
window.location.href="xjoepx.mpdbujpo.isfg ""#p=1";
}else{
window.location.href="xjoepx.mpdbujpo.isfg.tqmju(""#p=")[0] + "#p="+parseInt(n+1);
}
},
_getUrl:function(){//获得组图url标识
var str = window.location.href.toString(),pos = str.indexOf("#p=");
var nub = 1;
if(pos!==-1){
nub=str.match(/\#p\=(\d{1,})/i)[1];
}
return nub;
},
_Pload:function(data,n){//预加载下一张
if(data.length>3){//大于3张 才预加载
if (n+1 != data.length) {
this._preloadN.src = data[n + 1].bigpic
}
}
},
_showBig:function(data,n){//显示大图、显示成功后设置索引值对应的图注、url、组图当前索引值改写、小图位置、统计
$("#orgPic").attr("href",data[n].bigpic);
$("#PicSrc").attr("src",webpath+"images/tuku/loader.gif");
hdPic.fn._Pload(data,n);
hdPic.fn._hideLast();
$("#PicSrc").load(function(){
hdPic.fn._autoSca($(this),data[n].bigpic);
hdPic.fn._replaceTitle();
$(this).height()>600?$("#Main-A").height($(this).height()):$("#Main-A").height(600);
$(this).css("margin-top",parseInt($("#Main-A").height()-$(this).height())/2+"px");
}).fadeTo("fast", 0, function(){
hdPic.fn._pageNow = n;
hdPic.fn._showSmall(n);
hdPic.fn._showtit(n);
hdPic.fn._creatUrl(n);
$("#PicSrc").attr("src",data[n].bigpic);
$("#PicSrc").fadeTo("fast",1);
});
},
_autoSca:function($this,src){
var img = new Image();
img.src = src;
if (img.width > 0 && img.height > 0) {
if (img.width / img.height >= 980 / 600){
if(img.width>980) {
$this.width(980);
}
}
}
},
_showSmall:function(n){//小图移动切换逻辑
$("a.mask").show();
if(hdPic.fn._tmpArray.length<=hdPic.fn._scrollCell){
$("a.mask").animate({left: (131*n)+4+"px"},"slow");
return false;
}
var _left;
if(n>=3 && n<(hdPic.fn._tmpArray.length)-3){//大于3小于倒数3
$("#Smailllist").animate({left:-131*(n-3)+"px"},"slow",function(){
_left = (131*3)+4+"px";
$("a.mask").animate({left:_left},"fast");
$(".scrollButton").animate({left:_left},"fast");
});
}else{
if(n>=(hdPic.fn._tmpArray.length)-3){
_left = (131*(hdPic.fn._scrollCell-(hdPic.fn._tmpArray.length-n)))+4+"px";
$("#Smailllist").animate({left:-(hdPic.fn._tmpArray.length-hdPic.fn._scrollCell)*131+"px"},"slow");
$("a.mask").animate({left:_left},"slow");
$(".scrollButton").animate({left:_left},"fast");
}else{
if(n<3){
$("#Smailllist").animate({left:"0px"},"slow");
}
_left = (131*n)+4+"px";
$("a.mask").animate({left:_left},"slow");
$(".scrollButton").animate({left:_left},"fast");
}
}
},
_getData:function(data){//第一次加载后,初始化大图、小图、绑定事件、统计等
$("H1").text(hdPic.fn._groupName||"组图");
if(data.length>0){
this._pageNow = parseInt(hdPic.fn._getUrl()-1);
this._getReady();//大图ready
this._small(data);//装载小图
this._showBig(data,this._pageNow);
this._bindClick(data);
}
},
_small:function(data){//第一次加载后初始化小图
var _tmp="",ulLength=131*data.length;
$.each(data,function(i){
if(i==0){
_tmp += '';
}else{
_tmp += '';
}
});
$("#Smailllist").width(ulLength);
$("#Smailllist").html(_tmp);
},
_query:function(){//第一次加载,使用ajax加载数据,并在成功后把数据格式化到本地
var jsonData = tukujsonData;
var length = jsonData.Children.length;//图片数量
for(var i=0;i/i,"").replace(/\<\/p\>/i,"")+''
});
}
hdPic.fn._groupName = jsonData.title;
hdPic.fn._getData(hdPic.fn._tmpArray);
},
init:function(){
window.onerror = function () { return true; };
var func = function(){
$(document).ready(function($){
hdPic.fn._query();
});
};
func();
}// end init
}
hdPic.fn.init.prototype = hdPic.fn;
hdPic();