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,30 +190,39 @@ var galleryAPI = function(){
$(".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 pageurl = dom.attr('href');
if(rcom.getInternetExplorerVersion() == -1){
if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl);
}
}else{
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":dom.attr("data-content"),"height":picHeight+"px"}).load(function(){
$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();
if(rcom.getInternetExplorerVersion() == -1){
if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl);
}
}else{
window.location.hash = pageurl;
}
// $(".slideinfo b.info").text(imageArray[imagecount].title);
if($('.bt-tag').hasClass("active"))
updatePhotoTag();
@ -224,7 +233,6 @@ var galleryAPI = function(){
if(imageArray.length > 1)
updateNavigation();
})
}
var updateNavigation = function(){
var next, prev;
@ -269,7 +277,7 @@ var galleryAPI = function(){
}
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.css("margin-bottom","0");
picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight());

View File

@ -159,19 +159,39 @@ var galleryAPI = function(){
$(".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 pageurl = dom.attr('href');
if(rcom.getInternetExplorerVersion() == -1){
if(pageurl!=window.location){
var segments = window.location.pathname.split("/"),
uid = segments[segments.length-1];
pageurl = window.location.pathname.replace(uid,"-"+pageurl)+"?method=theater";
window.history.pushState({path:pageurl},'',pageurl);
}
}else{
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":dom.attr("data-content")}).css("height","100%").load(function(){
$img.attr({"src":url}).css("height","100%").load(function(){
g.loadcomplete();
$img.fadeIn(200);
});
}else{
$img.attr({"src":dom.attr("data-content")}).css("height","auto").load(function(){
$img.attr({"src":url}).css("height","auto").load(function(){
g.loadcomplete();
$img.fadeIn(200);
});;
@ -181,16 +201,6 @@ var galleryAPI = function(){
}
$slidelist.stop().animate({'height':'0px'}, 300);
$slidelist.find("ul").hide();
if(rcom.getInternetExplorerVersion() == -1){
if(pageurl!=window.location){
var segments = window.location.pathname.split("/"),
uid = segments[segments.length-1];
pageurl = window.location.pathname.replace(uid,"-"+pageurl)+"?method=theater";
window.history.pushState({path:pageurl},'',pageurl);
}
}else{
window.location.hash = pageurl;
}
// $(".slideinfo b.info").text(imageArray[imagecount].title);
updatePhotoTag();
if(imageArray[imagecount].description)