Fix window popstate

This commit is contained in:
manson 2014-08-05 17:50:16 +08:00
parent 01bb50fdec
commit 82874d33a1
2 changed files with 41 additions and 23 deletions

View File

@ -190,23 +190,15 @@ var galleryAPI = function(){
$(".slidectrl .browserfullscreen").show(); $(".slidectrl .browserfullscreen").show();
} }
} }
window.onpopstate = function(){
var image_id = document.URL.split('/')[document.URL.split('/').length-1];
var image = imageArray.filter(function(a){return a._id == image_id})[0];
imagecount = imageArray.indexOf(image);
changeTheaterImage(image.file.theater.url);
}
var changeImage = function(dom){ var changeImage = function(dom){
var pageurl = dom.attr('href'); var pageurl = dom.attr('href');
$img.fadeOut(200,function(){
g.loadstart();
$img.attr("src","");
$img.attr({"src":dom.attr("data-content"),"height":picHeight+"px"}).load(function(){
$img.fadeIn(200);
g.loadcomplete();
});
if($rslide.hasClass("fullscreen")){
$img.css({"padding":($rslide.height()-$img.height())/2})
}
$slidelist.stop().animate({'height':'0px'}, 300);
$slidelist.find("ul").hide();
if(rcom.getInternetExplorerVersion() == -1){ if(rcom.getInternetExplorerVersion() == -1){
if(pageurl!=window.location){ if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl); window.history.pushState({path:pageurl},'',pageurl);
@ -214,6 +206,23 @@ var galleryAPI = function(){
}else{ }else{
window.location.hash = pageurl; window.location.hash = pageurl;
} }
changeTheaterImage(dom.attr("data-content"));
}
var changeTheaterImage = function(url){
$img.fadeOut(200,function(){
g.loadstart();
$img.attr("src","");
$img.attr({"src":url,"height":picHeight+"px"}).load(function(){
$img.fadeIn(200);
g.loadcomplete();
});
if($rslide.hasClass("fullscreen")){
$img.css({"padding":($rslide.height()-$img.height())/2})
}
$slidelist.stop().animate({'height':'0px'}, 300);
$slidelist.find("ul").hide();
// $(".slideinfo b.info").text(imageArray[imagecount].title); // $(".slideinfo b.info").text(imageArray[imagecount].title);
if($('.bt-tag').hasClass("active")) if($('.bt-tag').hasClass("active"))
updatePhotoTag(); updatePhotoTag();
@ -224,7 +233,6 @@ var galleryAPI = function(){
if(imageArray.length > 1) if(imageArray.length > 1)
updateNavigation(); updateNavigation();
}) })
} }
var updateNavigation = function(){ var updateNavigation = function(){
var next, prev; var next, prev;
@ -269,7 +277,7 @@ var galleryAPI = function(){
} }
var albumid = $("#main_pic").attr("data-content"); var albumid = $("#main_pic").attr("data-content");
g.albumArea.find(".bt-back").attr("href","../galleries/"+albumid); g.albumArea.find(".bt-back").attr("href",'/'+g.locale+"/admin/galleries/"+albumid);
g.albumArea.find(".bt-edit").attr("href","../albums/"+albumid+"/edit"); g.albumArea.find(".bt-edit").attr("href","../albums/"+albumid+"/edit");
g.albumArea.css("margin-bottom","0"); g.albumArea.css("margin-bottom","0");
picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight()); picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight());

View File

@ -159,28 +159,15 @@ var galleryAPI = function(){
$(".slidectrl .browserfullscreen").show(); $(".slidectrl .browserfullscreen").show();
} }
} }
window.onpopstate = function(){
var image_id = window.location.pathname.split('/')[window.location.pathname.split('/').length-1].split('-');
var image = imageArray.filter(function(a){return a._id == image_id[1]})[0];
imagecount = imageArray.indexOf(image);
changeTheaterImage(image.file.theater.url);
}
var changeImage = function(dom){ var changeImage = function(dom){
var pageurl = dom.attr('href'); var pageurl = dom.attr('href');
$img.fadeOut(200,function(){
g.loadstart();
if($rslide.hasClass("fullscreen")){
$img.attr({"src":dom.attr("data-content")}).css("height","100%").load(function(){
g.loadcomplete();
$img.fadeIn(200);
});
}else{
$img.attr({"src":dom.attr("data-content")}).css("height","auto").load(function(){
g.loadcomplete();
$img.fadeIn(200);
});;
}
if($rslide.hasClass("fullscreen")){
$img.css({"padding":($rslide.height()-$img.height())/2})
}
$slidelist.stop().animate({'height':'0px'}, 300);
$slidelist.find("ul").hide();
if(rcom.getInternetExplorerVersion() == -1){ if(rcom.getInternetExplorerVersion() == -1){
if(pageurl!=window.location){ if(pageurl!=window.location){
var segments = window.location.pathname.split("/"), var segments = window.location.pathname.split("/"),
@ -191,6 +178,29 @@ var galleryAPI = function(){
}else{ }else{
window.location.hash = pageurl; window.location.hash = pageurl;
} }
changeTheaterImage(dom.attr("data-content"));
}
var changeTheaterImage = function(url){
$img.fadeOut(200,function(){
g.loadstart();
if($rslide.hasClass("fullscreen")){
$img.attr({"src":url}).css("height","100%").load(function(){
g.loadcomplete();
$img.fadeIn(200);
});
}else{
$img.attr({"src":url}).css("height","auto").load(function(){
g.loadcomplete();
$img.fadeIn(200);
});;
}
if($rslide.hasClass("fullscreen")){
$img.css({"padding":($rslide.height()-$img.height())/2})
}
$slidelist.stop().animate({'height':'0px'}, 300);
$slidelist.find("ul").hide();
// $(".slideinfo b.info").text(imageArray[imagecount].title); // $(".slideinfo b.info").text(imageArray[imagecount].title);
updatePhotoTag(); updatePhotoTag();
if(imageArray[imagecount].description) if(imageArray[imagecount].description)