2014-05-05 06:07:18 +00:00
|
|
|
<%# encoding: utf-8 %>
|
|
|
|
$.extend($.expr[':'], {
|
|
|
|
'containsi': function (elem, i, match, array) {
|
|
|
|
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
|
|
|
}
|
|
|
|
});
|
2021-04-04 05:03:24 +00:00
|
|
|
|
2014-05-05 06:07:18 +00:00
|
|
|
var galleryAPI = function(){
|
|
|
|
g = this;
|
|
|
|
this.urlVars = rcom.getUrlVars();
|
|
|
|
this.albumArea = $("#orbit_gallery");
|
|
|
|
this.loadArea = "theater";
|
|
|
|
this.tagList = $(".taglist ul");
|
|
|
|
this.loading = $("#loading");
|
2014-07-21 08:28:09 +00:00
|
|
|
this.fullscreen_mode = false;
|
2014-05-05 06:07:18 +00:00
|
|
|
// this.authenticated = false;
|
|
|
|
this.initialize = function(callbackFn){
|
|
|
|
if(g.loadArea == "theater"){
|
|
|
|
if(rcom.getInternetExplorerVersion()!=-1){
|
|
|
|
var photo_id = window.location.hash.replace("#","");
|
|
|
|
if(photo_id){
|
|
|
|
var params = rcom.getUrlVars();
|
|
|
|
var url = window.location.href.split("?")[0];
|
|
|
|
params["image_id"] = photo_id;
|
|
|
|
for(i=0;i<params.length;i++){
|
|
|
|
if(i == 0)
|
|
|
|
url+="?"+params[i]+"="+params[params[i]];
|
|
|
|
else
|
|
|
|
url+="&"+params[i]+"="+params[params[i]];
|
|
|
|
|
|
|
|
}
|
|
|
|
window.location.href = url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loadTheater = function(albumid,id){
|
|
|
|
var imageArray;
|
|
|
|
var imagecount = 0;
|
|
|
|
// var picHeight = 0;
|
|
|
|
g.loadstart();
|
|
|
|
var bindHandlers = function(){
|
|
|
|
var $slidelist = $('.slidelist'),
|
|
|
|
$rslide = $('.rslide'),
|
|
|
|
$rslidenav = $('.rslidenav'),
|
|
|
|
$img = $("#main_pic img"),
|
|
|
|
wHeight = $(window).height();
|
|
|
|
|
|
|
|
$("#main_pic").height("auto");
|
|
|
|
$img.css("height","auto");
|
|
|
|
|
|
|
|
var updatePhotoTag = function(){
|
|
|
|
var tags = imageArray[imagecount].tags;
|
|
|
|
g.tagList.empty();
|
|
|
|
for(tag in tags){
|
|
|
|
g.tagList.append("<li>"+tags[tag].name+"</li>");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(".slidectrl a.togglelist").click(function(){
|
|
|
|
var rslide_h = $rslide.outerHeight();
|
|
|
|
if ( $slidelist.height() < 1 ){
|
|
|
|
$slidelist.stop().animate({'height':rslide_h - 30}, 300);
|
|
|
|
$slidelist.find("ul").show();
|
|
|
|
} else {
|
|
|
|
$slidelist.stop().animate({'height':'0px'}, 300);
|
|
|
|
$slidelist.find("ul").hide();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
$(".slidectrl .togglescreen").click(function(){
|
|
|
|
toggleFullscreen();
|
|
|
|
})
|
|
|
|
$(".slidectrl .browserfullscreen").click(function(){
|
|
|
|
browserFullScreen();
|
|
|
|
})
|
|
|
|
$slidelist.find(".list_element").click(function(){
|
|
|
|
imagecount = parseInt($(this).parent().attr("for"));
|
|
|
|
changeImage($(this));
|
|
|
|
})
|
|
|
|
$rslidenav.find(".navN").click(function(){
|
|
|
|
nextpic($(this));
|
|
|
|
})
|
|
|
|
$rslidenav.find("a.navP").click(function(){
|
|
|
|
prevpic($(this));
|
|
|
|
})
|
|
|
|
$("#nextpic").click(function(){
|
|
|
|
nextpic($(this));
|
|
|
|
})
|
|
|
|
|
|
|
|
$(document).keydown(function(e){
|
|
|
|
if (e.keyCode == 37){
|
|
|
|
prevpic($rslidenav.find(".navP"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(e.keyCode == 39){
|
|
|
|
nextpic($rslidenav.find(".navN"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(e.keyCode == 27){
|
|
|
|
toggleFullscreen();
|
|
|
|
$rslide.removeClass('browserFullScreen');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(e.keyCode == 70 || e.keyCode == 102){
|
|
|
|
if($rslide.hasClass("fullscreen"))
|
|
|
|
browserFullScreen();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var browserFullScreen = function(){
|
2014-07-21 08:28:09 +00:00
|
|
|
if(g.fullscreen_mode==false){
|
|
|
|
var el = document.documentElement,
|
2014-05-05 06:07:18 +00:00
|
|
|
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen;
|
|
|
|
rfs.call(el);
|
2014-07-21 08:28:09 +00:00
|
|
|
g.fullscreen_mode = true;
|
|
|
|
}else{
|
|
|
|
var el = document,
|
|
|
|
rfs = el.exitFullscreen || el.msExitFullscreen || el.webkitExitFullscreen || el.mozCancelFullScreen;
|
|
|
|
rfs.call(el);
|
|
|
|
g.fullscreen_mode = false;
|
|
|
|
}
|
2014-05-05 06:07:18 +00:00
|
|
|
}
|
|
|
|
$(window).resize(function(){
|
|
|
|
if(window.innerWidth == screen.width && window.innerHeight == screen.height) {
|
|
|
|
$rslide.addClass('browserFullScreen');
|
|
|
|
} else {
|
|
|
|
$rslide.removeClass('browserFullScreen');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var nextpic = function(dom){
|
|
|
|
if(imagecount == imageArray.length - 1)
|
|
|
|
imagecount = 0;
|
|
|
|
else
|
|
|
|
imagecount++;
|
|
|
|
changeImage(dom);
|
|
|
|
}
|
|
|
|
var prevpic = function(dom){
|
|
|
|
if(imagecount == 0)
|
|
|
|
imagecount = imageArray.length - 1
|
|
|
|
else
|
|
|
|
imagecount--;
|
|
|
|
changeImage(dom);
|
|
|
|
}
|
|
|
|
var toggleFullscreen = function(){
|
|
|
|
if($rslide.hasClass("fullscreen")){
|
|
|
|
$rslide.css("position","relative");
|
|
|
|
$rslide.removeClass("fullscreen");
|
|
|
|
$(".slidectrl .browserfullscreen").hide();
|
|
|
|
$img.css({"padding":""})
|
|
|
|
$("#main_pic").height("auto");
|
|
|
|
}else{
|
|
|
|
$("#main_pic").height(wHeight);
|
|
|
|
$img.css("height","auto");
|
|
|
|
$rslide.css("position","");
|
|
|
|
$rslide.addClass("fullscreen");
|
|
|
|
$img.css({"padding":($rslide.height()-$img.height())/2})
|
|
|
|
$(".slidectrl .browserfullscreen").show();
|
|
|
|
}
|
|
|
|
}
|
2014-08-05 09:50:16 +00:00
|
|
|
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);
|
|
|
|
}
|
2014-05-05 06:07:18 +00:00
|
|
|
var changeImage = function(dom){
|
|
|
|
var pageurl = dom.attr('href');
|
|
|
|
|
2014-08-05 09:50:16 +00:00
|
|
|
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){
|
2014-05-05 06:07:18 +00:00
|
|
|
$img.fadeOut(200,function(){
|
|
|
|
g.loadstart();
|
|
|
|
if($rslide.hasClass("fullscreen")){
|
|
|
|
|
2014-08-05 09:50:16 +00:00
|
|
|
$img.attr({"src":url}).css("height","100%").load(function(){
|
2014-05-05 06:07:18 +00:00
|
|
|
g.loadcomplete();
|
|
|
|
$img.fadeIn(200);
|
|
|
|
});
|
|
|
|
}else{
|
2014-08-05 09:50:16 +00:00
|
|
|
$img.attr({"src":url}).css("height","auto").load(function(){
|
2014-05-05 06:07:18 +00:00
|
|
|
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);
|
|
|
|
updatePhotoTag();
|
|
|
|
if(imageArray[imagecount].description)
|
|
|
|
$(".slideinfo .info").text(imageArray[imagecount].description);
|
|
|
|
else
|
|
|
|
$(".slideinfo .info").text("");
|
|
|
|
if(imageArray.length > 1)
|
|
|
|
updateNavigation();
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
var updateNavigation = function(){
|
|
|
|
var next, prev;
|
|
|
|
if(imagecount == 0){
|
|
|
|
next = 1;
|
|
|
|
prev = imageArray.length - 1;
|
|
|
|
}else if(imagecount == imageArray.length - 1){
|
|
|
|
next = 0
|
|
|
|
prev = imageArray.length - 2;
|
|
|
|
}else{
|
|
|
|
next = imagecount + 1;
|
|
|
|
prev = imagecount - 1;
|
|
|
|
}
|
|
|
|
$(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.theater.url});
|
|
|
|
$(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.theater.url});
|
|
|
|
};
|
|
|
|
if(imageArray.length > 1)
|
|
|
|
updateNavigation();
|
|
|
|
}
|
|
|
|
|
2014-10-20 12:25:58 +00:00
|
|
|
var preparestage = function(images){
|
|
|
|
// $.getJSON("/galleries/imgs?id=" + albumid, function(album){
|
|
|
|
imageArray = images;
|
|
|
|
$.each(images,function(i,image){
|
2014-05-05 06:07:18 +00:00
|
|
|
if(image._id == id)
|
|
|
|
imagecount = i;
|
|
|
|
})
|
|
|
|
bindHandlers();
|
2014-10-20 12:25:58 +00:00
|
|
|
// })
|
2014-05-05 06:07:18 +00:00
|
|
|
}
|
|
|
|
// if(rcom.getInternetExplorerVersion()!=-1){
|
|
|
|
// var url_constructor = window.location.href.split("/");
|
|
|
|
// var url = "";
|
|
|
|
// for(x=0;x<=url_constructor.length-1;x++){
|
|
|
|
// if(x == url_constructor.length-1){
|
|
|
|
// url+="#!/"+url_constructor[x];
|
|
|
|
// }else{
|
|
|
|
// url+=url_constructor[x]+"/";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// window.location.href = url;
|
|
|
|
// }
|
|
|
|
|
|
|
|
var albumid = $("#main_pic").attr("data-content");
|
|
|
|
g.albumArea.css("margin-bottom","0");
|
|
|
|
// picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight());
|
2014-10-20 12:25:58 +00:00
|
|
|
preparestage(json_image_data);
|
2014-05-05 06:07:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
this.loadcomplete = function(){
|
|
|
|
g.loading.hide();
|
|
|
|
}
|
|
|
|
this.loadstart = function(){
|
|
|
|
g.loading.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
galleryAPI.prototype.locale = "en";
|