2012-08-28 07:38:35 +00:00
|
|
|
<%# encoding: utf-8 %>
|
2012-08-20 14:00:57 +00:00
|
|
|
$.extend($.expr[':'], {
|
|
|
|
'containsi': function (elem, i, match, array) {
|
|
|
|
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
|
|
|
}
|
|
|
|
});
|
2012-07-19 07:44:44 +00:00
|
|
|
var galleryAPI = function(){
|
|
|
|
g = this;
|
2012-07-25 08:20:07 +00:00
|
|
|
this.urlVars = rcom.getUrlVars();
|
|
|
|
this.albumArea = $("#orbit_gallery");
|
2012-08-20 14:00:57 +00:00
|
|
|
this.loadArea = null;
|
|
|
|
this.tagList = $("ul#gallery_tag_list");
|
|
|
|
this.initialize = function(callbackFn){
|
2012-07-19 07:44:44 +00:00
|
|
|
$(document).ready(function(){
|
2012-07-25 08:20:07 +00:00
|
|
|
bindHandlers();
|
2012-07-19 07:44:44 +00:00
|
|
|
})
|
|
|
|
var bindHandlers = function(){
|
2012-08-06 09:01:53 +00:00
|
|
|
$("#filter .filter_btns a").click(function(){
|
|
|
|
if(!$(this).hasClass("active")){
|
|
|
|
$(this).addClass("active");
|
2012-08-11 09:28:49 +00:00
|
|
|
if(g.urlVars.length == 0)
|
2012-08-27 15:36:56 +00:00
|
|
|
window.location = "albums?" + $(this).attr("href");
|
2012-08-06 09:01:53 +00:00
|
|
|
else
|
|
|
|
window.location = window.location.href +"&"+ $(this).attr("href");
|
|
|
|
}else{
|
|
|
|
$(this).removeClass("active");
|
|
|
|
var loc = window.location.href;
|
|
|
|
var url = loc.replace($(this).attr("href")+"&","");
|
|
|
|
if(url == loc)
|
|
|
|
url = loc.replace($(this).attr("href"),"");
|
2012-07-19 07:44:44 +00:00
|
|
|
|
2012-08-06 09:01:53 +00:00
|
|
|
if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?")
|
|
|
|
url = url.substr(0,url.length-1);
|
|
|
|
window.location = url;
|
|
|
|
}
|
2012-07-25 08:20:07 +00:00
|
|
|
})
|
2012-09-03 13:49:35 +00:00
|
|
|
$("#filter .filter-clear a").click(function(){
|
|
|
|
var loc = window.location.href;
|
|
|
|
var url = null;
|
|
|
|
var forwhat = $(this).attr("for");
|
|
|
|
$("#filter ."+forwhat+" a.active").each(function(){
|
|
|
|
$(this).removeClass("active");
|
|
|
|
url = loc.replace($(this).attr("href")+"&","");
|
|
|
|
if(url == loc)
|
|
|
|
url = loc.replace($(this).attr("href"),"");
|
2012-08-11 09:28:49 +00:00
|
|
|
|
2012-09-03 13:49:35 +00:00
|
|
|
if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?")
|
|
|
|
url = url.substr(0,url.length-1);
|
|
|
|
loc = url;
|
|
|
|
})
|
|
|
|
window.location = url;
|
2012-08-11 09:28:49 +00:00
|
|
|
})
|
2012-09-03 13:49:35 +00:00
|
|
|
}
|
|
|
|
|
2012-07-25 08:20:07 +00:00
|
|
|
}
|
2012-08-28 13:04:48 +00:00
|
|
|
this.makeNewAlbum = function(path){
|
|
|
|
$.get(path,function(html){
|
2012-10-24 01:47:09 +00:00
|
|
|
rcom.modalWindow({loadHtml:html,width:320,height:320,"closeBtn":false},function(dom){
|
2012-09-03 13:49:35 +00:00
|
|
|
$("form#new_gallery_album").submit(function(){
|
|
|
|
var validated = true;
|
|
|
|
$(this).find(".error").removeClass("error");
|
|
|
|
$(this).find(".validate").each(function(){
|
|
|
|
if(!$(this).val()){
|
|
|
|
validated = false;
|
|
|
|
$(this).parent().addClass("error");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(!validated)
|
|
|
|
return false;
|
|
|
|
})
|
2012-07-25 08:20:07 +00:00
|
|
|
dom.find("#album_name_close_btn").click(function(){
|
|
|
|
rcom.modalWindowClose();
|
|
|
|
})
|
2012-07-19 07:44:44 +00:00
|
|
|
})
|
2012-07-25 08:20:07 +00:00
|
|
|
|
|
|
|
})
|
|
|
|
}
|
2012-07-29 10:52:30 +00:00
|
|
|
this.deleteAlbum = function(id){
|
2012-07-31 13:15:42 +00:00
|
|
|
if(confirm("<%= I18n.t('gallery.del_album?') %>")){
|
2012-08-27 15:36:56 +00:00
|
|
|
$.ajax({
|
|
|
|
type: "DELETE",
|
2012-08-31 14:01:19 +00:00
|
|
|
url : id,
|
2012-08-27 15:36:56 +00:00
|
|
|
success : function(){
|
2012-08-31 14:01:19 +00:00
|
|
|
window.location = "../albums";
|
2012-08-27 15:36:56 +00:00
|
|
|
}
|
2012-07-29 10:52:30 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-25 08:20:07 +00:00
|
|
|
this.loadAlbums = function(id){
|
2012-08-28 13:04:48 +00:00
|
|
|
g.albumArea.find(".rghead .rgfn a").click(function(){g.makeNewAlbum($(this).attr("href"))});
|
2012-08-21 05:56:50 +00:00
|
|
|
g.albumArea.addClass('o_gallery');
|
2012-07-25 08:20:07 +00:00
|
|
|
g.albumArea.find("#imgholder").empty();
|
2012-08-06 09:01:53 +00:00
|
|
|
if(id!="all"){
|
2012-08-11 09:28:49 +00:00
|
|
|
var cids = [];
|
|
|
|
var tids = [];
|
|
|
|
var href = null;
|
2012-09-03 13:49:35 +00:00
|
|
|
console.log(cids);
|
2012-08-06 09:01:53 +00:00
|
|
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
|
|
|
for(var i = 0; i < hashes.length; i++){
|
|
|
|
hash = hashes[i].split('=');
|
2012-08-11 09:28:49 +00:00
|
|
|
if(hash[0]=="cat"){
|
|
|
|
cids.push(hash[1]);
|
|
|
|
href = "cat="+hash[1];
|
|
|
|
}else if(hash[0]=="tag"){
|
|
|
|
tids.push(hash[1]);
|
|
|
|
href = "tag="+hash[1];
|
|
|
|
}
|
2012-08-06 09:01:53 +00:00
|
|
|
$("#filter .filter_btns a[href='"+href+"']").addClass("active");
|
|
|
|
}
|
2012-08-11 09:28:49 +00:00
|
|
|
if(cids.length == 0)
|
|
|
|
cids = "all";
|
2012-08-06 09:01:53 +00:00
|
|
|
}else{
|
2012-08-11 09:28:49 +00:00
|
|
|
var cids = "all";
|
2012-08-06 09:01:53 +00:00
|
|
|
}
|
2012-08-11 09:28:49 +00:00
|
|
|
$.getJSON("get_albums",{cid:cids,tid:tids},function(categories){
|
2012-08-06 09:01:53 +00:00
|
|
|
$.each(categories,function(x,category){
|
|
|
|
$.each(category,function(i,album){
|
2012-09-03 13:49:35 +00:00
|
|
|
album.description = (album.description?album.description:"<%= I18n.t('gallery.no_description') %>")
|
2012-08-06 09:01:53 +00:00
|
|
|
if(album.cover == "default")
|
2012-08-29 09:36:12 +00:00
|
|
|
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='"+album.show_path+"'><img src='../../../assets/gallery/default.jpg' /></a><span class='albumname'>"+album.name+"</span><span class='categoryname'>"+album.category_name+"</span><span class='tagnames'></span></div>");
|
2012-08-06 09:01:53 +00:00
|
|
|
else
|
2012-08-29 09:36:12 +00:00
|
|
|
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='"+album.show_path+"'><img src='"+album.cover_path+"' /></a><span class='albumname'>"+album.name+"</span><span class='categoryname'>"+album.category_name+"</span><span class='tagnames'></span></div>");
|
2012-08-20 14:00:57 +00:00
|
|
|
var tag_string = "";
|
|
|
|
for(tag in album.tag_names){
|
2012-08-21 06:31:25 +00:00
|
|
|
tag_string+= '<span class="label label-tags">' + album.tag_names[tag] + '</span>';
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
2012-08-21 05:56:50 +00:00
|
|
|
$img.find(".tagnames").html(tag_string);
|
2012-08-06 09:01:53 +00:00
|
|
|
g.albumArea.find("#imgholder").append($img);
|
|
|
|
})
|
2012-07-25 08:20:07 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.loadImages = function(id){
|
2012-08-20 14:00:57 +00:00
|
|
|
var panelopen = false;
|
2012-08-27 15:36:56 +00:00
|
|
|
$('.bt-tag').click(function(){
|
|
|
|
$(this).toggleClass("active");
|
|
|
|
var $tag_panel = $('#tag_panel'),
|
|
|
|
tag_panel_position = 0;
|
2012-07-25 08:20:07 +00:00
|
|
|
|
2012-08-27 15:36:56 +00:00
|
|
|
if( $tag_panel.css('right') == '0px' ){
|
|
|
|
tag_panel_position = -200;
|
|
|
|
}
|
|
|
|
$tag_panel.animate({'right':tag_panel_position}, 300);
|
2012-08-13 08:17:23 +00:00
|
|
|
|
2012-08-27 15:36:56 +00:00
|
|
|
g.albumArea
|
|
|
|
.delay(200)
|
|
|
|
.animate({'margin-right':tag_panel_position+200},300);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
g.albumArea.find("#tag_search_box").keyup(function(e){
|
|
|
|
sval = $(this).val();
|
|
|
|
if(sval == "<%= I18n.t('gallery.search_tags') %>")
|
|
|
|
sval = "";
|
|
|
|
sval = sval.replace(/(^\s*)|(\s*$)/g,'');
|
|
|
|
if(sval){
|
|
|
|
var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range
|
|
|
|
var re2 = new RegExp("^[\uE7C7-\uE7F3]*$");
|
|
|
|
if ((re1.test(sval) && (re2.test(sval)))){
|
|
|
|
$("#gallery_tag_list li span:not(:contains("+sval+"))").parent().slideUp();
|
2012-08-20 14:00:57 +00:00
|
|
|
}else{
|
2012-08-27 15:36:56 +00:00
|
|
|
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
2012-08-27 15:36:56 +00:00
|
|
|
}else{
|
|
|
|
$("#gallery_tag_list li").slideDown();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
g.albumArea.find("#tag_panel .bt-save").click(function(){
|
2012-08-28 13:04:48 +00:00
|
|
|
g.saveTags(id,"album");
|
2012-08-27 15:36:56 +00:00
|
|
|
})
|
|
|
|
g.albumArea.find(".rghead .rgfn .bt-add").click(function(){
|
|
|
|
showUploadPanel();
|
|
|
|
})
|
|
|
|
g.albumArea.find(".rghead .rgfn .bt-del").click(function(){
|
|
|
|
g.deleteAlbum(id);
|
2012-08-20 14:00:57 +00:00
|
|
|
})
|
2012-08-27 15:36:56 +00:00
|
|
|
$("#upload_panel_holder").remove();
|
2012-08-07 06:33:30 +00:00
|
|
|
var uploadpanel = $('<div id="upload_panel_holder"><div class="rgfn"><a class="bt-cls btn btn-primary pull-right" title="Close" href="" onclick="return false;"><i class="icon-remove icon-white"></i>Close Panel</a></div></div>');
|
2012-08-27 15:36:56 +00:00
|
|
|
var frame = $('<iframe id="upload_panel" width="100%" scrolling="no" height="294" frameborder="0" src="'+id+'/upload_panel"></iframe>');
|
2012-08-22 07:59:06 +00:00
|
|
|
uploadpanel.find(".bt-cls").click(function(){
|
2012-07-25 08:20:07 +00:00
|
|
|
uploadpanel.hide("slide");
|
|
|
|
frame.remove();
|
|
|
|
g.loadImages(id);
|
|
|
|
panelopen = false;
|
|
|
|
})
|
|
|
|
var showUploadPanel = function(){
|
|
|
|
if(!panelopen){
|
|
|
|
uploadpanel.prepend(frame);
|
|
|
|
uploadpanel.show("slide");
|
|
|
|
panelopen = true;
|
|
|
|
}
|
2012-07-19 07:44:44 +00:00
|
|
|
}
|
2012-07-29 10:52:30 +00:00
|
|
|
|
2012-08-21 05:56:50 +00:00
|
|
|
g.albumArea.addClass('o_album');
|
2012-07-25 08:20:07 +00:00
|
|
|
g.albumArea.find(".rghead .rgfn").append(uploadpanel);
|
|
|
|
g.albumArea.find("#imgholder").empty();
|
2012-08-28 13:04:48 +00:00
|
|
|
$.getJSON(id+"/imgs",function(album){
|
2012-08-20 14:00:57 +00:00
|
|
|
$.each(album.images,function(i,image){
|
2012-07-25 08:20:07 +00:00
|
|
|
var thumb = image.file.thumb.url;
|
2012-09-03 13:49:35 +00:00
|
|
|
image.description = (image.description?image.description:"<%= I18n.t('gallery.no_description') %>")
|
2012-08-28 13:04:48 +00:00
|
|
|
var $img = $("<div class='rgphoto'><a title='"+image.description+"' href='"+image.theater_link+"'><img src='"+thumb+"'/></a></div>");
|
2012-07-25 08:20:07 +00:00
|
|
|
g.albumArea.find("#imgholder").append($img);
|
|
|
|
})
|
2012-08-20 14:00:57 +00:00
|
|
|
g.tagList.find("input").attr("checked",false);
|
2012-08-23 11:25:56 +00:00
|
|
|
if(typeof album.tag_names == "undefined"){
|
|
|
|
$.each(album.tags,function(i,tag){
|
|
|
|
g.tagList.find("li[data-content="+tag+"] input").attr("checked",true);
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
$.each(album.tag_names,function(i,tagname){
|
|
|
|
$li = $("<li><label>"+tagname+"</label><span style='display:none;'>"+tagname+"</span></li>");
|
|
|
|
g.tagList.append($li);
|
|
|
|
})
|
|
|
|
}
|
2012-08-28 13:04:48 +00:00
|
|
|
|
2012-08-20 14:00:57 +00:00
|
|
|
})
|
2012-07-25 08:20:07 +00:00
|
|
|
}
|
|
|
|
this.loadTheater = function(id){
|
2012-07-29 10:52:30 +00:00
|
|
|
var imageArray;
|
|
|
|
var imagecount = 0;
|
|
|
|
var picHeight = 0;
|
|
|
|
var bindHandlers = function(){
|
|
|
|
var $slidelist = $('.slidelist'),
|
|
|
|
$rslide = $('.rslide'),
|
|
|
|
$rslidenav = $('.rslidenav'),
|
2012-07-30 17:15:48 +00:00
|
|
|
$img = $("#main_pic img"),
|
|
|
|
wHeight = $(window).height();
|
|
|
|
|
|
|
|
$("#main_pic").height(picHeight);
|
|
|
|
$img.height("100%");
|
2012-08-20 14:00:57 +00:00
|
|
|
|
|
|
|
$('.bt-tag').click(function(){
|
|
|
|
if(!$(this).hasClass("active"))
|
|
|
|
updatePhotoTag();
|
|
|
|
$(this).toggleClass("active");
|
|
|
|
var $tag_panel = $('#tag_panel'),
|
|
|
|
tag_panel_position = 0;
|
2012-07-30 17:15:48 +00:00
|
|
|
|
2012-08-20 14:00:57 +00:00
|
|
|
if( $tag_panel.css('right') == '0px' ){
|
|
|
|
tag_panel_position = -200;
|
|
|
|
}
|
|
|
|
$tag_panel.animate({'right':tag_panel_position}, 300);
|
|
|
|
|
|
|
|
g.albumArea
|
|
|
|
.delay(200)
|
|
|
|
.animate({'margin-right':tag_panel_position+200},300);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
var updatePhotoTag = function(){
|
|
|
|
var tags = imageArray[imagecount].tag_ids;
|
2012-08-23 13:30:37 +00:00
|
|
|
if(tags.length > 0 && g.tagList.find("li").length == 0){
|
|
|
|
var tagnames = imageArray[imagecount].tag_names;
|
|
|
|
g.tagList.empty();
|
|
|
|
for(i in tagnames){
|
|
|
|
$li = $("<li><label>"+tagnames[i]+"</label><span style='display:none;'>"+tagnames[i]+"</span></li>");
|
|
|
|
g.tagList.append($li);
|
|
|
|
}
|
|
|
|
}else if(tags.length > 0 && g.tagList.find("li").length > 0) {
|
|
|
|
g.tagList.find("input").attr("checked",false);
|
|
|
|
for(tag in tags){
|
|
|
|
g.tagList.find("li[data-content="+tags[tag]+"] input").attr("checked",true);
|
|
|
|
}
|
|
|
|
}else if(tags.length == 0){
|
|
|
|
if(g.tagList.find("input").length == 0)
|
|
|
|
g.tagList.empty();
|
|
|
|
else
|
|
|
|
g.tagList.find("input").attr("checked",false);
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g.albumArea.find("#tag_search_box").keyup(function(e){
|
|
|
|
sval = $(this).val();
|
|
|
|
if(sval == "<%= I18n.t('gallery.search_tags') %>")
|
|
|
|
sval = "";
|
|
|
|
sval = sval.replace(/(^\s*)|(\s*$)/g,'');
|
|
|
|
if(sval){
|
|
|
|
var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range
|
|
|
|
var re2 = new RegExp("^[\uE7C7-\uE7F3]*$");
|
|
|
|
if ((re1.test(sval) && (re2.test(sval)))){
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#gallery_tag_list li span:not(:contains("+sval+"))").parent().slideUp();
|
2012-08-20 14:00:57 +00:00
|
|
|
}else{
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#gallery_tag_list li").slideDown();
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
|
|
|
})
|
2012-08-21 05:56:50 +00:00
|
|
|
g.albumArea.find("#tag_panel .bt-save").click(function(){
|
2012-08-29 09:13:45 +00:00
|
|
|
g.saveTags(imageArray[imagecount]._id,"pic",function(tagids){
|
|
|
|
imageArray[imagecount].tag_ids = tagids;
|
2012-08-23 13:30:37 +00:00
|
|
|
})
|
2012-08-20 14:00:57 +00:00
|
|
|
})
|
2012-07-29 10:52:30 +00:00
|
|
|
$(".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();
|
|
|
|
}
|
|
|
|
})
|
2012-08-22 07:59:06 +00:00
|
|
|
$(".slidectrl .togglescreen").click(function(){
|
2012-07-29 10:52:30 +00:00
|
|
|
toggleFullscreen();
|
|
|
|
})
|
2012-08-22 07:59:06 +00:00
|
|
|
$(".slidectrl .browserfullscreen").click(function(){
|
2012-07-30 17:15:48 +00:00
|
|
|
browserFullScreen();
|
|
|
|
})
|
2012-08-22 07:59:06 +00:00
|
|
|
$slidelist.find(".list_element").click(function(){
|
2012-07-29 10:52:30 +00:00
|
|
|
imagecount = parseInt($(this).parent().attr("for"));
|
|
|
|
changeImage($(this));
|
|
|
|
})
|
2012-08-22 07:59:06 +00:00
|
|
|
$rslidenav.find(".navN").click(function(){
|
2012-07-29 10:52:30 +00:00
|
|
|
nextpic($(this));
|
|
|
|
})
|
|
|
|
$rslidenav.find("a.navP").click(function(){
|
|
|
|
prevpic($(this));
|
|
|
|
})
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#nextpic").click(function(){
|
2012-07-29 10:52:30 +00:00
|
|
|
nextpic($(this));
|
|
|
|
})
|
|
|
|
|
|
|
|
$(document).keydown(function(e){
|
|
|
|
if (e.keyCode == 37){
|
2012-08-22 07:59:06 +00:00
|
|
|
prevpic($rslidenav.find(".navP"));
|
2012-07-29 10:52:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(e.keyCode == 39){
|
2012-08-22 07:59:06 +00:00
|
|
|
nextpic($rslidenav.find(".navN"));
|
2012-07-29 10:52:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(e.keyCode == 27){
|
|
|
|
toggleFullscreen();
|
2012-08-22 07:59:06 +00:00
|
|
|
$rslide.removeClass('browserFullScreen');
|
2012-07-29 10:52:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-07-30 17:15:48 +00:00
|
|
|
if(e.keyCode == 70 || e.keyCode == 102){
|
|
|
|
if($rslide.hasClass("fullscreen"))
|
|
|
|
browserFullScreen();
|
|
|
|
}
|
2012-07-29 10:52:30 +00:00
|
|
|
});
|
2012-07-30 17:15:48 +00:00
|
|
|
var browserFullScreen = function(){
|
|
|
|
var el = document.documentElement,
|
|
|
|
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen;
|
|
|
|
rfs.call(el);
|
|
|
|
}
|
2012-08-23 13:30:37 +00:00
|
|
|
$(window).resize(function(){
|
|
|
|
if(window.innerWidth == screen.width && window.innerHeight == screen.height) {
|
|
|
|
$rslide.addClass('browserFullScreen');
|
|
|
|
} else {
|
|
|
|
$rslide.removeClass('browserFullScreen');
|
|
|
|
}
|
|
|
|
})
|
2012-07-29 10:52:30 +00:00
|
|
|
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");
|
2012-08-22 07:59:06 +00:00
|
|
|
$(".slidectrl .browserfullscreen").hide();
|
2012-07-29 10:52:30 +00:00
|
|
|
$img.css({"padding":""})
|
2012-07-31 13:15:42 +00:00
|
|
|
$("#main_pic").height(picHeight );
|
2012-07-29 10:52:30 +00:00
|
|
|
}else{
|
2012-07-30 17:15:48 +00:00
|
|
|
$("#main_pic").height(wHeight);
|
|
|
|
// $img.height("100%");
|
2012-07-29 10:52:30 +00:00
|
|
|
$rslide.css("position","");
|
|
|
|
$rslide.addClass("fullscreen");
|
|
|
|
$img.css({"padding":($rslide.height()-$img.height())/2})
|
2012-08-22 07:59:06 +00:00
|
|
|
$(".slidectrl .browserfullscreen").show();
|
2012-07-29 10:52:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
var changeImage = function(dom){
|
|
|
|
var pageurl = dom.attr('href');
|
2012-08-31 14:01:19 +00:00
|
|
|
|
2012-07-30 17:15:48 +00:00
|
|
|
$img.fadeOut(200,function(){
|
|
|
|
$img.attr({"src":dom.attr("data-content"),"height":picHeight+"px"});
|
|
|
|
$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();
|
2012-08-31 14:01:19 +00:00
|
|
|
if(rcom.getInternetExplorerVersion() == -1){
|
|
|
|
if(pageurl!=window.location){
|
|
|
|
window.history.pushState({path:pageurl},'',pageurl);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
window.location.hash = pageurl;
|
|
|
|
}
|
2012-07-30 17:15:48 +00:00
|
|
|
// $(".slideinfo b.info").text(imageArray[imagecount].title);
|
2012-08-20 14:00:57 +00:00
|
|
|
if($('.bt-tag').hasClass("active"))
|
|
|
|
updatePhotoTag();
|
2012-08-22 07:59:06 +00:00
|
|
|
$(".slideinfo .info").text(imageArray[imagecount].description);
|
2012-07-31 13:15:42 +00:00
|
|
|
if(imageArray.length > 1)
|
|
|
|
updateNavigation();
|
2012-07-30 17:15:48 +00:00
|
|
|
})
|
2012-08-20 14:00:57 +00:00
|
|
|
|
2012-07-29 10:52:30 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2012-08-28 13:04:48 +00:00
|
|
|
$(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.url});
|
|
|
|
$(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.url});
|
2012-07-29 10:52:30 +00:00
|
|
|
};
|
2012-07-31 13:15:42 +00:00
|
|
|
if(imageArray.length > 1)
|
|
|
|
updateNavigation();
|
2012-07-29 10:52:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var preparestage = function(albumid){
|
2012-08-28 13:04:48 +00:00
|
|
|
$.getJSON("../albums/"+albumid+"/imgs",function(album){
|
2012-08-20 14:00:57 +00:00
|
|
|
imageArray = eval(album.images);
|
|
|
|
$.each(album.images,function(i,image){
|
2012-07-29 10:52:30 +00:00
|
|
|
if(image._id == id)
|
|
|
|
imagecount = i;
|
|
|
|
})
|
|
|
|
bindHandlers();
|
|
|
|
})
|
|
|
|
}
|
2012-08-31 14:01:19 +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;
|
|
|
|
}
|
2012-08-28 13:04:48 +00:00
|
|
|
|
|
|
|
var albumid = $("#main_pic").attr("data-content");
|
|
|
|
g.albumArea.find(".bt-back").attr("href","../albums/"+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());
|
|
|
|
preparestage(albumid);
|
|
|
|
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.editAlbum = function(id){
|
|
|
|
var bindHandlers = function(){
|
|
|
|
$(".nav .nav-tabs a").click(function(){
|
|
|
|
$(".tab_content .tab-pane").hide();
|
|
|
|
})
|
|
|
|
$(".description_loader .edit_fn .bt-cover").click(function(){
|
2012-08-27 15:36:56 +00:00
|
|
|
$(".bt-cover").removeClass("setcover active btn-primary");
|
2012-08-28 13:04:48 +00:00
|
|
|
$(".bt-cover span").removeClass("icon-white icon-star").addClass("icon-star-empty");
|
2012-09-03 13:49:35 +00:00
|
|
|
$(this).addClass("setcover active btn-primary");
|
|
|
|
$(this).find("span").removeClass("icon-star-empty").addClass("icon-white icon-star");
|
2012-08-28 13:04:48 +00:00
|
|
|
$.post("set_cover",{"imageid":$(this).attr("for")});
|
2012-08-20 14:00:57 +00:00
|
|
|
})
|
|
|
|
$(".description_loader .edit_fn .bt-dels").click(function(){
|
2012-08-21 17:15:50 +00:00
|
|
|
$(this)
|
|
|
|
.toggleClass("setdelete btn-danger active")
|
|
|
|
.find('span').toggleClass('icon-white');
|
2012-08-31 14:01:19 +00:00
|
|
|
if($(".description_loader .edit_fn .setdelete").length > 0)
|
|
|
|
g.albumArea.find(".rghead .rgfn .bt-save").show();
|
|
|
|
|
|
|
|
if($(this).hasClass("active")){
|
|
|
|
$(this).parent().parent().find("input.del_field").val(true);
|
2012-08-20 14:00:57 +00:00
|
|
|
}else{
|
2012-08-31 14:01:19 +00:00
|
|
|
$(this).parent().parent().find("input.del_field").val(false);
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
2012-08-31 14:01:19 +00:00
|
|
|
delete_cover();
|
2012-08-20 14:00:57 +00:00
|
|
|
})
|
2012-08-31 14:01:19 +00:00
|
|
|
var delete_cover = function(){
|
|
|
|
if($(".description_loader .setcover").parent().find(".bt-dels").hasClass("active")){
|
|
|
|
$("input.del_cover").val(true);
|
|
|
|
}else{
|
|
|
|
$("input.del_cover").val(false);
|
|
|
|
}
|
|
|
|
}
|
2012-08-28 13:04:48 +00:00
|
|
|
var current_element_for_tags = null;
|
2012-08-29 09:13:45 +00:00
|
|
|
var current_element_no = null;
|
2012-08-10 17:32:53 +00:00
|
|
|
$('.bt-tag').click(function(){
|
2012-08-28 13:04:48 +00:00
|
|
|
var has_class = false;
|
|
|
|
if($(this).hasClass("active"))
|
|
|
|
has_class = true;
|
|
|
|
|
|
|
|
$('.bt-tag').removeClass("active");
|
2012-08-20 14:00:57 +00:00
|
|
|
$(this).toggleClass("active");
|
2012-08-27 15:36:56 +00:00
|
|
|
var count = 0;
|
|
|
|
$('.bt-tag').each(function(){
|
|
|
|
if($(this).hasClass("active"))
|
|
|
|
count++;
|
|
|
|
})
|
2012-08-28 13:04:48 +00:00
|
|
|
if(has_class){
|
|
|
|
$(this).removeClass("active");
|
|
|
|
count = 0;
|
|
|
|
}
|
2012-08-10 17:32:53 +00:00
|
|
|
var $tag_panel = $('#tag_panel'),
|
|
|
|
tag_panel_position = 0;
|
2012-08-27 15:36:56 +00:00
|
|
|
if(count == 1)
|
|
|
|
tag_panel_position = 0
|
|
|
|
else if(count == 0){
|
|
|
|
if( $tag_panel.css('right') == '0px' ){
|
|
|
|
tag_panel_position = -200;
|
|
|
|
}
|
2012-08-22 17:36:39 +00:00
|
|
|
}
|
2012-08-27 15:36:56 +00:00
|
|
|
|
2012-08-10 17:32:53 +00:00
|
|
|
$tag_panel.animate({'right':tag_panel_position}, 300);
|
|
|
|
|
|
|
|
g.albumArea
|
|
|
|
.delay(200)
|
|
|
|
.animate({'margin-right':tag_panel_position+200},300);
|
2012-08-28 13:04:48 +00:00
|
|
|
|
|
|
|
current_element_for_tags = $(this).attr("href");
|
|
|
|
if(count == 1){
|
2012-08-29 09:13:45 +00:00
|
|
|
current_element_no = $(this).parent().attr("no");
|
|
|
|
if(imageTagArray[current_element_no].id == current_element_for_tags){
|
2012-08-28 13:04:48 +00:00
|
|
|
g.tagList.find("input").attr("checked",false);
|
2012-08-29 09:13:45 +00:00
|
|
|
for(tag in imageTagArray[current_element_no].tags){
|
|
|
|
g.tagList.find("li[data-content="+imageTagArray[current_element_no].tags[tag]+"] input").attr("checked",true);
|
2012-08-28 13:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-10 17:32:53 +00:00
|
|
|
return false;
|
|
|
|
});
|
2012-08-20 14:00:57 +00:00
|
|
|
g.albumArea.find("#tag_search_box").keyup(function(e){
|
|
|
|
sval = $(this).val();
|
|
|
|
if(sval == "<%= I18n.t('gallery.search_tags') %>")
|
|
|
|
sval = "";
|
|
|
|
sval = sval.replace(/(^\s*)|(\s*$)/g,'');
|
|
|
|
if(sval){
|
|
|
|
var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range
|
|
|
|
var re2 = new RegExp("^[\uE7C7-\uE7F3]*$");
|
|
|
|
if ((re1.test(sval) && (re2.test(sval)))){
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#gallery_tag_list li span:not(:contains("+sval+"))").parent().slideUp();
|
2012-08-20 14:00:57 +00:00
|
|
|
}else{
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
2012-07-29 10:52:30 +00:00
|
|
|
}else{
|
2012-08-22 07:59:06 +00:00
|
|
|
$("#gallery_tag_list li").slideDown();
|
2012-07-29 10:52:30 +00:00
|
|
|
}
|
|
|
|
})
|
2012-08-21 05:56:50 +00:00
|
|
|
g.albumArea.find("#tag_panel .bt-save").click(function(){
|
2012-08-29 09:13:45 +00:00
|
|
|
g.saveTags(current_element_for_tags,"pic",function(tagids){
|
|
|
|
imageTagArray[current_element_no].tags = tagids;
|
|
|
|
})
|
2012-07-29 10:52:30 +00:00
|
|
|
})
|
|
|
|
var tempval;
|
|
|
|
$(".txtchange").focus(function(){
|
|
|
|
tempval = $(this).val();
|
|
|
|
}).keyup(function(){
|
|
|
|
if($(this).val() != tempval)
|
|
|
|
g.albumArea.find(".rghead .rgfn .bt-save").show();
|
|
|
|
})
|
2012-09-04 13:30:17 +00:00
|
|
|
|
2012-07-29 10:52:30 +00:00
|
|
|
}
|
2012-08-21 05:56:50 +00:00
|
|
|
g.albumArea.addClass('o_album_edit');
|
2012-08-28 13:04:48 +00:00
|
|
|
var imageTagArray = null;
|
|
|
|
$.getJSON("images_tags",function(data){
|
|
|
|
imageTagArray = eval(data);
|
|
|
|
})
|
2012-08-27 15:36:56 +00:00
|
|
|
bindHandlers();
|
2012-07-29 10:52:30 +00:00
|
|
|
}
|
2012-08-29 09:13:45 +00:00
|
|
|
this.saveTags = function(id,tagsfor,callbackFn){
|
2012-08-20 14:00:57 +00:00
|
|
|
var tagids = new Array();
|
|
|
|
g.tagList.find("li input:checked").each(function(){
|
|
|
|
tagids.push($(this).parent().attr("data-content"));
|
|
|
|
})
|
2012-08-29 09:13:45 +00:00
|
|
|
$.post("../save_tags",{"id":id,"tag":tagsfor,"tids":tagids},function(){
|
|
|
|
if(typeof callbackFn == "function")
|
|
|
|
callbackFn.call(this,tagids);
|
|
|
|
})
|
2012-08-20 14:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
galleryAPI.prototype.locale = "en";
|