frontend updates

This commit is contained in:
Harry Bomrah 2012-08-23 01:36:39 +08:00 committed by Christophe Vilayphiou
parent 29c5126455
commit 8caa798c08
12 changed files with 1380 additions and 21 deletions

View File

@ -1,4 +1,7 @@
<%# encoding: utf-8 %>
// refresh the imagesArray
// viewonly tags
$.extend($.expr[':'], {
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
@ -160,9 +163,9 @@ var galleryAPI = function(){
$.each(categories,function(x,category){
$.each(category,function(i,album){
if(album.cover == "default")
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='../../../assets/gallery/default.jpg' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span><span class='tagnames'></span></div>");
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='../../../assets/gallery/default.jpg' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span><span class='categoryname'>"+album.category_name+"</span><span class='tagnames'></span></div>");
else
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='"+album.cover_path+"' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span><span class='tagnames'></span></div>");
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='"+album.cover_path+"' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span><span class='categoryname'>"+album.category_name+"</span><span class='tagnames'></span></div>");
var tag_string = "";
for(tag in album.tag_names){
tag_string+= '<span class="label label-tags">' + album.tag_names[tag] + '</span>';
@ -514,20 +517,26 @@ var galleryAPI = function(){
// })
})
var tag_panel_hidden = true;
var last_clicked = null;
$('.bt-tag').click(function(){
$(this).toggleClass("active");
var $tag_panel = $('#tag_panel'),
tag_panel_position = 0;
if( $tag_panel.css('right') == '0px' ){
tag_panel_position = -200;
}
if( $tag_panel.css('right') == '0px' ){
tag_panel_position = -200;
}
if(last_clicked == $(this))
alert("same")
else
alert("no")
$tag_panel.animate({'right':tag_panel_position}, 300);
g.albumArea
.delay(200)
.animate({'margin-right':tag_panel_position+200},300);
return false;
});
g.albumArea.find("#tag_search_box").keyup(function(e){

View File

@ -0,0 +1,617 @@
<%# encoding: utf-8 %>
$.extend($.expr[':'], {
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
var galleryAPI = function(){
g = this;
this.urlVars = rcom.getUrlVars();
this.albumArea = $("#orbit_gallery");
this.loadArea = null;
this.tagList = $("ul#gallery_tag_list");
// this.authenticated = false;
this.initialize = function(callbackFn){
$(document).ready(function(){
bindHandlers();
var passid = null;
if(typeof g.urlVars['cat']!= "undefined"){
g.loadArea = "albums";
passid = g.urlVars['cat'];
g.loadAlbums(g.urlVars['cat']);
}else if(typeof g.urlVars['album']!= "undefined"){
g.loadArea = "images";
passid = g.urlVars['album'];
g.loadImages(g.urlVars['album']);
}else if(typeof g.urlVars['theater']!= "undefined"){
g.loadArea = "theater";
passid = g.urlVars['theater'];
g.loadTheater(g.urlVars['theater']);
}else if(typeof g.urlVars['edit']!= "undefined"){
g.loadArea = "edit";
passid = g.urlVars['edit'];
g.editAlbum(g.urlVars['edit']);
}else if(typeof g.urlVars['tag']!= "undefined"){
g.loadArea = "albums";
passid = g.urlVars['tag'];
g.loadAlbums(g.urlVars['tag']);
}else if(g.urlVars["locale"]){
g.loadArea = "albums";
g.loadAlbums("all");
}else if(g.urlVars.length == 0) {
g.loadArea = "albums";
g.loadAlbums("all");
}
if(typeof callbackFn == "function"){
callbackFn.call(this,g.loadArea,passid);
}
})
var bindHandlers = function(){
$("#filter .filter_btns a").click(function(){
if(!$(this).hasClass("active")){
$(this).addClass("active");
if(g.urlVars.length == 0)
window.location = "orbit_gallery?" + $(this).attr("href");
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"),"");
if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?")
url = url.substr(0,url.length-1);
window.location = url;
}
})
}
$("#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"),"");
if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?")
url = url.substr(0,url.length-1);
loc = url;
})
window.location = url;
})
}
this.makeNewAlbum = function(){
$.get("add_album",function(html){
rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){
dom.find("#album_name_save_btn").click(function(){
var options ={
cid : dom.find("select#category_list").val(),
albumname : {
"en" : dom.find("#name_en").val(),
"zh_tw" : dom.find("#name_zh_tw").val()
},
albumdesc : {
"en" : dom.find("#desc_en").val(),
"zh_tw" : dom.find("#desc_zh_tw").val()
}
}
if(options.cid){
$.post("create_album",options,function(response){
if(g.loadArea == "albums")
g.loadAlbums("all");
rcom.modalWindowClose();
})
}
})
dom.find("#album_name_close_btn").click(function(){
rcom.modalWindowClose();
})
})
})
}
this.deleteAlbum = function(id){
if(confirm("<%= I18n.t('gallery.del_album?') %>")){
$.post("delete_album",{aid:id},function(){
window.location = "orbit_gallery";
})
}
}
this.loadAlbums = function(id){
g.loadFooterPanel(g.loadArea,id,function(headbtn){
headbtn = $(headbtn);
headbtn.click(function(){g.makeNewAlbum();})
g.albumArea.find(".rghead .rgfn").html(headbtn);
})
g.albumArea.addClass('o_gallery');
g.albumArea.find("#imgholder").empty();
// var $addsign = $('<div class="rgalbum"><a id="global_add" class="rgui bt-addnew" href="add" onclick="return false;">Add Album</a></div>');
// $addsign.find("a").click(function(){g.makeNewAlbum();})
if(id!="all"){
var cids = [];
var tids = [];
var href = null;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++){
hash = hashes[i].split('=');
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];
}
$("#filter .filter_btns a[href='"+href+"']").addClass("active");
}
if(cids.length == 0)
cids = "all";
}else{
var cids = "all";
}
$.getJSON("panel/gallery/front_end/get_albums",{cid:cids,tid:tids,"inner":true},function(categories){
$.each(categories,function(x,category){
$.each(category,function(i,album){
if(album.cover == "default")
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='../../../assets/gallery/default.jpg' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span><span class='categoryname'>"+album.category_name+"</span><span class='tagnames'></span></div>");
else
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='"+album.cover_path+"' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span><span class='categoryname'>"+album.category_name+"</span><span class='tagnames'></span></div>");
var tag_string = "";
for(tag in album.tag_names){
tag_string+= '<span class="label label-tags">' + album.tag_names[tag] + '</span>';
}
$img.find(".tagnames").html(tag_string);
g.albumArea.find("#imgholder").append($img);
})
})
// g.albumArea.find("#imgholder").append($addsign);
})
}
this.loadImages = function(id){
var panelopen = false;
g.loadFooterPanel(g.loadArea,id,function(headerPanel){
headarea = $(headerPanel);
g.albumArea.find(".rghead .rgfn").html(headarea);
$('.bt-tag').click(function(){
$(this).toggleClass("active");
var $tag_panel = $('#tag_panel'),
tag_panel_position = 0;
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;
});
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();
}else{
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
}
}else{
$("#gallery_tag_list li").slideDown();
}
})
g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(id,g.loadArea);
})
g.albumArea.find(".rghead .rgfn .bt-add").click(function(){
showUploadPanel();
})
g.albumArea.find(".rghead .rgfn .bt-del").click(function(){
g.deleteAlbum(id);
})
})
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>');
var frame = $('<iframe id="upload_panel" width="100%" scrolling="no" height="294" frameborder="0" src="upload_panel"></iframe>');
uploadpanel.find(".bt-cls").click(function(){
uploadpanel.hide("slide");
frame.remove();
g.loadImages(id);
panelopen = false;
})
var showUploadPanel = function(){
if(!panelopen){
uploadpanel.prepend(frame);
uploadpanel.show("slide");
panelopen = true;
}
}
g.albumArea.addClass('o_album');
g.albumArea.find(".rghead .rgfn").append(uploadpanel);
g.albumArea.find("#imgholder").empty();
$("#filter").remove();
g.albumArea.css("margin-top","");
// var $addsign = $('<div class="rgalbum"><a id="global_add" class="rgui bt-addnew" href="add" onclick="return false;">Add Album</a></div>');
// $addsign.find("a").click(function(){showUploadPanel();})
$.getJSON("get_images",{aid:id},function(album){
$.each(album.images,function(i,image){
var thumb = image.file.thumb.url;
var $img = $("<div class='rgphoto'><a title='"+image.description+"' href='?theater="+image._id+"'><img src='"+thumb+"'/></a></div>");
g.albumArea.find("#imgholder").append($img);
})
g.tagList.find("input").attr("checked",false);
$.each(album.tags,function(i,tag){
g.tagList.find("li[data-content="+tag+"] input").attr("checked",true);
})
// g.albumArea.find("#imgholder").append($addsign);
})
// g.albumArea.find("#imgholder").append($addsign);
// tag
}
this.loadTheater = function(id){
var imageArray;
var imagecount = 0;
var picHeight = 0;
var bindHandlers = function(){
var $slidelist = $('.slidelist'),
$rslide = $('.rslide'),
$rslidenav = $('.rslidenav'),
$img = $("#main_pic img"),
wHeight = $(window).height();
$("#main_pic").height(picHeight);
$img.height("100%");
$('.bt-tag').click(function(){
if(!$(this).hasClass("active"))
updatePhotoTag();
$(this).toggleClass("active");
var $tag_panel = $('#tag_panel'),
tag_panel_position = 0;
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;
g.tagList.find("input").attr("checked",false);
for(tag in tags){
g.tagList.find("li[data-content="+tags[tag]+"] input").attr("checked",true);
}
}
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();
}else{
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
}
}else{
$("#gallery_tag_list li").slideDown();
}
})
g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(imageArray[imagecount]._id,g.loadArea);
})
$(".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(){
var el = document.documentElement,
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen;
rfs.call(el);
$rslide.addClass('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(picHeight );
}else{
$("#main_pic").height(wHeight);
// $img.height("100%");
$rslide.css("position","");
$rslide.addClass("fullscreen");
$img.css({"padding":($rslide.height()-$img.height())/2})
$(".slidectrl .browserfullscreen").show();
}
}
var changeImage = function(dom){
var pageurl = dom.attr('href');
$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();
if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl);
}
// $(".slideinfo b.info").text(imageArray[imagecount].title);
if($('.bt-tag').hasClass("active"))
updatePhotoTag();
$(".slideinfo .info").text(imageArray[imagecount].description);
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":"orbit_gallery?theater="+imageArray[next]._id,"data-content":imageArray[next].file.url});
$(".navP").attr({"href":"orbit_gallery?theater="+imageArray[prev]._id,"data-content":imageArray[prev].file.url});
};
if(imageArray.length > 1)
updateNavigation();
}
var preparestage = function(albumid){
$.getJSON("get_images",{aid:albumid},function(album){
imageArray = eval(album.images);
$.each(album.images,function(i,image){
if(image._id == id)
imagecount = i;
})
bindHandlers();
})
}
g.albumArea.find("#imgholder").load("theater?pic="+id,function(theater,response,xhr){
if(xhr.status == 404){
$(this).text("<%= I18n.t('gallery.pic_not_found') %>.");
return false;
}
$("#filter").remove();
g.albumArea.css("margin-top","");
var albumid = $(theater).find("#main_pic").attr("data-content");
g.loadFooterPanel(g.loadArea,id,function(head){
head = $(head);
g.albumArea.find(".rghead .rgfn").html(head);
g.albumArea.find(".bt-back").attr("href","orbit_gallery?album="+albumid);
g.albumArea.find(".bt-edit").attr("href","orbit_gallery?edit="+albumid);
})
g.albumArea.css("margin-bottom","0");
picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight());
preparestage(albumid);
});
}
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(){
$(".bt-cover").removeClass("setcover");
$(this).addClass("setcover");
$.post("set_cover",{"imageid":$(this).attr("href"),"aid":id},function(){})
})
$(".description_loader .edit_fn .bt-dels").click(function(){
$(this)
.toggleClass("setdelete btn-danger active")
.find('span').toggleClass('icon-white');
if($(".description_loader .edit_fn .setdelete").length > 0){
g.albumArea.find(".rghead .rgfn .bt-delete").show();
}else{
g.albumArea.find(".rghead .rgfn .bt-delete").hide();
}
})
g.albumArea.find(".rghead .rgfn .bt-save").click(function(){
// var dataArray = Array();
// $(".description_loader .en .txtchange").each(function(){
// var thisid = $(this).attr("for");
// dataArray.push({"id":thisid,"text":{"en":$(this).val(),"zh_tw":$(".description_loader .zh_tw .txtchange[for="+thisid+"]").val()}});
// })
// var albumnm = Array();
// $(".albumname_edit .txtchange").each(function(){
// albumnm.push($(this).val())
// })
// var dataArray = $("form#edit_album").serialize();
// $.post("update_album",{"data":dataArray},function(){
// })
})
$('.bt-tag').click(function(){
$(this).toggleClass("active");
var $tag_panel = $('#tag_panel'),
tag_panel_position = 0;
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;
});
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();
}else{
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
}
}else{
$("#gallery_tag_list li").slideDown();
}
})
g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(imageArray[imagecount]._id,g.loadArea);
})
var tempval;
$(".txtchange").focus(function(){
tempval = $(this).val();
}).keyup(function(){
if($(this).val() != tempval)
g.albumArea.find(".rghead .rgfn .bt-save").show();
})
g.albumArea.find(".rghead .rgfn .bt-delete").click(function(){
var images_to_delete = new Array();
var delete_cover = false;
var doms_to_delete = new Array();
var thiscover = $(".description_loader .edit_fn .setcover").attr("href");
$(".description_loader .edit_fn .bt-dels").each(function(){
if($(this).hasClass("setdelete")){
images_to_delete.push($(this).attr("href"));
doms_to_delete.push($(this).parent().parent());
if(thiscover == $(this).attr("href"))
delete_cover = true;
}
})
if(confirm("Deleting "+images_to_delete.length+" image(s)?")){
$.post("delete_images",{"images":images_to_delete,"delete_cover":delete_cover,"aid":id},function(response){
if(response.success){
for(dom in doms_to_delete){
doms_to_delete[dom].hide("slide",function(){$(this).remove();})
}
}
g.albumArea.find(".rghead .rgfn .bt-delete").hide();
})
}
})
}
$("#filter").remove();
g.albumArea.addClass('o_album_edit');
g.albumArea.css("margin-top","");
var head ='<a href="orbit_gallery?album='+id+'" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a></div>';
head+='<a class="bt-del bt-delete btn btn-primary pull-right" onclick="return false;" style="display:none;" title="<%= I18n.t("gallery.delete_selected") %>" href=""><i class="icon-trash icon-white"></i><%= I18n.t("gallery.delete_selected") %></a>';
head+='<a class="bt-save btn btn-primary pull-right" onclick="return false;" style="display:none;" title="Save" href=""><i class="icon-ok icon-white"></i>Save</a>';
g.albumArea.find(".rghead .rgfn").html(head);
g.albumArea.find("#imgholder").load("edit_album?aid="+id,function(data,response,xhr){
if(xhr.status == 404){
$(this).text("<%= I18n.t('gallery.album_not_found') %>");
return false;
}
bindHandlers();
})
}
this.saveTags = function(id,tagsfor){
var tagids = new Array();
g.tagList.find("li input:checked").each(function(){
tagids.push($(this).parent().attr("data-content"));
})
var tag = null;
if(g.loadArea == "images")
tag = "album";
else if(g.loadArea == "theater")
tag = "pic";
$.post("save_tags",{"id":id,"tag":tag,"tids":tagids},function(){
})
}
}
galleryAPI.prototype.locale = "en";

View File

@ -90,24 +90,20 @@ include AdminHelper
end
end
end
i = 0
@output = Array.new
@albums.each do |album|
@albs = Array.new
album.each do |values|
# if values.tag_ids.kind_of?(Array)
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
# end
values.tag_names = tags
values.save
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
category = GalleryCategory.find(values.gallery_category_id).name
@albs << {"_id"=>values.id,"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
i = i + 1
@output << @albs
end
# @albums = GalleryAlbum.find("5017a7babd98eb049900000a")
# @albums.update_attributes({:tag_ids =>["501ba786bd98eb0232000126"]})
render :json=>@albums.to_json
render :json=>@output.to_json
end
def upload_image

View File

@ -0,0 +1,228 @@
class Panel::Gallery::FrontEnd::OrbitGalleriesController < OrbitWidgetController
include AdminHelper
def index
@authenticated = false
@categorylist = GalleryCategory.all
@cid = params['cat']
@tags = GalleryTag.all
end
def new_category
names = params['category']
category = GalleryCategory.new
I18n.locale = :en
category.name = names['en']
I18n.locale = :zh_tw
category.name = names['zh_tw']
category.save!
render :json=>{"success"=>true,"id"=>category.id}.to_json
end
def categorylist
@categorylist = GalleryCategory.all
#render :layout => false
end
def gallery_category_delete
@category = GalleryCategory.find(params['id'])
@category.delete
render :json=>{"success"=>"true"}.to_json
end
def add_album
if is_manager? || is_admin?
@categorylist = GalleryCategory.all
elsif is_sub_manager?
@categorylist = GalleryCategory.authed_for_user(current_user,"new_album")
end
render :layout => false
end
def create_album
category = GalleryCategory.find(params['cid'])
albumnames = params["albumname"]
albumdescs = params["albumdesc"]
album = category.gallery_albums.new
I18n.locale = :en
album.name = albumnames["en"]
album.description = albumdescs["en"]
I18n.locale = :zh_tw
album.name = albumnames["zh_tw"]
album.description = albumdescs["zh_tw"]
album.save!
#x = category.gallery_albums.create({name: params['albumname'],description: params['albumdesc']})
render :json=>{"success"=>true,"id"=>album.id}.to_json
end
def get_albums
@categoryids = params["cid"]
@tags = params["tid"]
@albums = Array.new
if @categoryids == "all"
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << GalleryAlbum.where(tag_ids: tag)
end
else
@albums << GalleryAlbum.where(tag_ids: @tags)
end
else
@albums << GalleryAlbum.all
end
else
@categoryids.each do |id|
category = GalleryCategory.find(id)
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << category.gallery_albums.where(tag_ids: tag)
end
else
@albums << category.gallery_albums.where(tag_ids: @tags)
end
else
@albums << category.gallery_albums.all
end
end
end
i = 0
@albums.each do |album|
album.each do |values|
# if values.tag_ids.kind_of?(Array)
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
# end
values.tag_names = tags
values.save
end
i = i + 1
end
# @albums = GalleryAlbum.find("5017a7babd98eb049900000a")
# @albums.update_attributes({:tag_ids =>["501ba786bd98eb0232000126"]})
render :json=>@albums.to_json
end
def upload_image
albumid = params['aid'];
@album = GalleryAlbum.find(albumid)
@files = params['files']
a = Array.new
@files.each do |file|
@image = @album.gallery_images.new
@image.file = file
@image.save!
a << {"thumbnail_url"=>@image.file.thumb.url}
end
render :json=>a.to_json
end
def upload_panel
render :layout => false
end
def get_images
@album = GalleryAlbum.find(params["aid"])
render :json=>{"images" => @album.gallery_images.all, "tags" => @album.tag_ids}.to_json
end
def theater
picid = params["pic"]
@image = GalleryImage.find(picid)
@albumid = @image.gallery_album_id
album = GalleryAlbum.find(@albumid)
@images = album.gallery_images.all
render :layout=>false
end
def delete_album
aid = params['aid']
album = GalleryAlbum.find(aid)
album.delete
render :json =>{"success"=>true}.to_json
end
def edit_album
if is_manager? || is_admin? || is_sub_manager?
aid = params['aid']
album = GalleryAlbum.find(aid)
@images = album.gallery_images.all
@album_name = album.name_translations
@cover = album.cover
render :layout => false
end
end
def set_cover
aid = params['aid']
album = GalleryAlbum.find(aid)
image = GalleryImage.find(params[:imageid])
album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]})
render :json =>{"success"=>true}.to_json
end
def delete_images
images = params['images']
images.each do |image|
img = GalleryImage.find(image)
img.delete
end
if params['delete_cover'] == "true"
album = GalleryAlbum.find(params['aid'])
album.update_attributes(:cover=>"default")
end
render :json =>{"success"=>true}.to_json
end
def update_album
# data = params['data']
# album_name = params['name']
# aid = params['aid']
# data.each do |d|
# image = GalleryImage.find(d[1][:id])
# image.update_attributes(:description=>d[1][:text])
# end
# album = GalleryAlbum.find(aid)
# album.update_attributes(:name => album_name)
album_names = params[:albumnm]
data = params[:data]
aid =params[:aid]
debugger
data.each do |d|
image = GalleryImage.find(d[1][:id])
@site_valid_locales.each do |locale|
image.description_translations[locale] = d[1][:text][locale]
end
image.save!
end
album = GalleryAlbum.find(aid)
@site_valid_locales.each_with_index do |locale,i|
album.name_translations[locale] = album_names[i]
end
album.save!
render :json =>{"success"=>true}.to_json
end
def save_tags
case params[:tag]
when "album"
@object = GalleryAlbum.find(params[:id])
when "pic"
@object = GalleryImage.find(params[:id])
end
@object.update_attributes({:tag_ids => params[:tids]})
render :json => {"success"=> "true"}.to_json
end
end

View File

@ -27,7 +27,7 @@
<div class="rgphoto_edit <%= locale %>">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380">
<textarea name="gallery_album_gallery_images_attributes[<%= x %>][description_translations][<%= locale %>]" class="txtchange" for="<%= image.id %>"><%= image.description_translations[locale] %></textarea>
<textarea name="gallery_album_gallery_images_attributes[<%= x %>][description_translations][<%= locale %>]" class="txtchange" for="<%= image.id %>"><%= image.description_translations[locale] rescue nil %></textarea>
</div>
<div class="edit_fn">
<% if image.id.to_s == @cover %>

View File

@ -0,0 +1,34 @@
<div class="modal-window" id="categories">
<div class="modal-header">
<h3><%= t("gallery.add_album") %></h3>
</div>
<div class="modal-body add-album">
<select id="category_list">
<option value=""><%= t("gallery.select_category") %></option>
<% @categorylist.each do |category| %>
<option value='<%= category.id %>' ><%= category.name %></option>
<% end %>
</select>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab_content form-horizontal">
<% @site_valid_locales.each_with_index do |locale, i| %>
<% if i == 0 %>
<div class="<%= locale %> fade tab-pane in active">
<% else %>
<div class="<%= locale %> fade tab-pane" >
<% end %>
<p class="control-group"><label class="control-label"><%= t("gallery.album_name") %></label><input type="text" id="name_<%= locale %>" /></p>
<p class="control-group"><label class="control-label"><%= t("gallery.album_desc") %></label><input type="text" id="desc_<%= locale %>" /></p>
</div>
<% end %>
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" id="album_name_close_btn" onclick="return false;"><%= t("gallery.close") %></a>
<a href="#" class="btn btn-primary" id="album_name_save_btn" onclick="return false;"><%= t("gallery.save_changes") %></a>
</div>
</div>

View File

@ -0,0 +1,89 @@
<div id="tags" class="clear">
<% @categorylist.each do |category| %>
<div class="tag clear">
<div class="tagitem">
<i class="icon-folder-close"></i>
<% @site_valid_locales.each do |locale| %>
<span class="value" for="<%= locale %>"><%= category.name_translations[locale] %> </span>
<% end %>
</div>
<div class="action">
<a href="<%= category.id %>" class='delete' onclick='return false;'><%= t("gallery.delete") %></a>
<a href="<%= category.id %>" class='edit' onclick='return false;'><%= t("gallery.edit") %></a>
<%= show_gallery_category_permission_link(category) %>
</div>
</div>
<% end %>
</div>
<div class="form-actions form-fixed pagination-right">
<div style="margin:0;padding:0;display:inline">
<%= t("gallery.new_category")+"["+ t("gallery.english")+"]" %> : <input type="text" id="category_name_en" />
<%= t("gallery.new_category") +"["+ t("gallery.chinese")+"]" %> : <input type="text" id="category_name_zh_tw" />
<a href="#" class="btn btn-primary" id="category_save_btn" onclick="return false;"><%= t("gallery.save") %></a>
</div>
</div>
<script type="text/javascript">
var deleteCategory = function(a){
var cid = a.attr("href");
var parent = a.parent().parent();
$.post("gallery_category_delete",{id:cid},function(response){
if(response.success)
parent.hide("slide",function(){parent.remove();})
})
}
var editCategory = function(a){
var cid = a.attr("href");
var parent = a.parent().parent();
var parenthtml = parent.html();
var tempdom = $("<div class='tagitem'></div>");
parent.find("span.value").each(function(){
var locale = $(this).attr("for");
var lang = {
"en" : "English",
"zh_tw" : "Chinese"
}
tempdom.append("<label>"+lang[locale] + " :</label><input type='text' id='temp_name_"+locale+"' value='"+$(this).text()+"' />");
})
tempdom.append('<br /><a href="#" class="btn btn-primary" id="temp_save_btn" onclick="return false;"><%= I18n.t("gallery.save") %></a> <a href="#" class="btn btn-primary" id="temp_cancel_btn" onclick="return false;"><%= I18n.t("gallery.cancel") %></a>');
tempdom.find("a#temp_cancel_btn").click(function(){
parent.html(parenthtml);
parent.find("div.action a.delete").click(function(){
deleteCategory($(this));
})
parent.find(" div.action a.edit").click(function(){
editCategory($(this));
})
})
parent.html(tempdom);
}
$(document).ready(function(){
$("#tags div.action a.delete").click(function(){
deleteCategory($(this));
})
$("#tags div.action a.edit").click(function(){
editCategory($(this));
})
$("#category_save_btn").click(function(){
var lang = {
"en" : $("#category_name_en").val(),
"zh_tw" : $("#category_name_zh_tw").val()
};
$.post("gallery_category_save",{"category":lang},function(response){
if(response.success){
var $dom = $('<div class="tag clear hide"><div class="tagitem"><i class="icons-star"></i>'+lang.en+' '+lang.zh_tw+'</div> <div class="action"><a href="'+response.id+'" class="delete" onclick="return false;"><%= I18n.t("gallery.delete") %></a></div></div>');
$("div#tags").append($dom);
$dom.show('slide');
$dom.find("a.delete").click(function(){
deleteCategory($(this));
})
$("input[type=text]").val("");
}
})
})
})
</script>

View File

@ -0,0 +1,74 @@
<ul class="breadcrumb">
<li><span>Home</span><span class="divider">/</span></li>
<li><span><%= t('admin.orbit_gallery') %></span><span class="divider">/</span></li>
<li class="text-blue"><%= t('gallery.edit') %></li>
</ul>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<form id="edit_album" action="update_album" method="post">
<div class="tab_content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<% if i == 0 %>
<div class="<%= locale %> fade tab-pane in active">
<% else %>
<div class="<%= locale %> fade tab-pane" >
<% end %>
<div class="albumname_edit">
<label for=""><%= t("gallery.album_name") %></label>
<div class="inputui rginput rgih26 w380"><input type="text" name="gallery_album[name_translations][<%= locale %>]" value="<%= @album_name[locale] %>" class="txtchange" /></div>
</div>
<div class='description_loader'>
<% @images.each_with_index do |image,x| %>
<div class="rgphoto_edit <%= locale %>">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380">
<textarea name="gallery_album_gallery_images_attributes[<%= x %>][description_translations][<%= locale %>]" class="txtchange" for="<%= image.id %>"><%= image.description_translations[locale] %></textarea>
</div>
<div class="edit_fn">
<% if image.id.to_s == @cover %>
<a class="btn btn-primary rgbtsg bt-cover setcover active" onclick="return false;" title="<%= t("gallery.cover") %>" href="<%= image.id %>"><span class="icon-star icon-white"></span></a>
<% else %>
<a class="btn rgbtsg bt-cover" onclick="return false;" title="<%= t("gallery.set_cover") %>" href="<%= image.id %>"><span class="icon-star-empty"></span></a>
<% end %>
<a class="btn rgbtsg bt-tag" onclick="return false;" title="<%= t("gallery.photo_tag") %>" href="<%= image.id %>"><span class="icon-tags"></span></a>
<a class="btn rgbtsg bt-dels" onclick="return false;" title="<%= t("gallery.delete") %>" href="<%= image.id %>"><span class="icon-trash"></span></a>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
<input type="submit" value="Submit" />
</form>
<!-- <div class="tab-pane in active">
<div class="albumname_edit">
<label for="">Album Name:</label>
<div class="inputui rginput rgih26 w380"><span><input type="text" id='album_name_text' value="<%= @album_name %>" class="txtchange" /></span></div>
</div>
<div id='description_loader'>
<% @images.each do |image| %>
<div class="rgphoto_edit">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380">
<span>
<textarea name="description_box" class="txtchange" for="<%= image.id%>"><%= image.description %></textarea>
</span>
</div>
<div class="edit_fn">
<a class="rgui rgbt rgbtsg bt-dels" onclick="return false;" title="Delete" href="<%= image.id %>">Delete</a>
<% if image.id.to_s == @cover %>
<a class="rgui rgbt rgbtsg bt-cover setcover" onclick="return false;" title="Set Cover" href="<%= image.id %>">Set Cover</a>
<% else %>
<a class="rgui rgbt rgbtsg bt-cover" onclick="return false;" title="Set Cover" href="<%= image.id %>">Set Cover</a>
<% end %>
</div>
</div>
<% end %>
</div>
</div> -->

View File

@ -0,0 +1,166 @@
<%= stylesheet_link_tag "gallery" %>
<div id="filter" class="subnav">
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-categories" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t("gallery.category") %> <b class="web-symbol"></b></a>
</div>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t("gallery.tag") %> <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="filters">
<div class="accordion-body collapse" id="collapse-categories">
<div class="accordion-inner filter_btns cats" data-toggle="buttons-checkbox">
<% @categorylist.each do |category| %>
<a href="cat=<%= category.id %>" class="btn" onclick="return false;"><%= category.name %></a>
<% end %>
</div>
<div class="filter-clear">
<a href="" class="btn" onclick="return false;" for="cats"><i class="icons-brush-large"></i>清除</a>
</div>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<div class="accordion-inner filter_btns tags" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<a href="tag=<%= tag.id %>" class="btn" onclick="return false;"><%= tag[I18n.locale] %></a>
<% end %>
</div>
<div class="filter-clear">
<a href="" class="btn" onclick="return false;" for="tags"><i class="icons-brush-large" ></i>清除</a>
</div>
</div>
</div>
</div>
<!-- <table id="gallery_list" class="table main-list">
<thead>
<tr>
<th class="span1"></th>
<th class="span2"></th>
<th class="span2"></th>
<th></th>
</tr>
</thead>
<tbody id="tbody_gallery" class="sort-holder">
<tr>
<td class="span1"></td>
<td class="span2"></td>
<td class="span2"></td>
<td></td>
</tr>
</tbody>
</table> -->
<div id="orbit_gallery" class="rg">
<!-- <div class="rghead">
<div class="rgfn">
</div>
</div> -->
<div class="rgbody">
<div id="imgholder">
</div>
</div>
<!-- tag part -->
<% if @authenticated %>
<div id="tag_panel" class="my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<%
@locales = Array.new
@site_valid_locales.each do |locale|
@locales << locale
end
%>
<div class="viewport">
<div class="overview">
<ul class="tag_list" id="gallery_tag_list">
<% @tags.each do |tag| %>
<li data-content="<%= tag.id %>"><input id="tag_<%= tag.id %>" type="checkbox"><label for="tag_<%= tag.id %>"><%= tag[I18n.locale] %></label><span style="display:none;"><%= tag[@locales[1]] %> <%= tag[@locales[0]] %></span></li>
<% end %>
</ul>
</div>
</div>
<div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"><div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
</div>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "galleryAPI" %>
<%= javascript_include_tag "jquery.tinyscrollbar" %>
<% end %>
<script type="text/javascript">
var $tag_panel = $('#tag_panel');
orbit_bar_height = $('#orbit-bar').outerHeight();
action_panel_height = $('.form-actions').outerHeight();
window_height = $(window).height();
$tag_panel.height( window_height - orbit_bar_height - 90 );
$tag_panel.tinyscrollbar();
$(window).resize(function(){
$tag_panel.tinyscrollbar_update('relative');
$tag_panel.height( $(window).height() - orbit_bar_height - 90 );
});
</script>
<!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn">
<!-- <a href="" class="btn btn-primary pull-right"><i class="icon-plus icon-white"></i>新增</a> -->
</div>
</div>
</div>
<script type="text/javascript">
galleryAPI.prototype.loadFooterPanel = function(area,id,callbackFn){
var headarea = null;
if(area == "images"){
headarea = '<a class="bt-back btn btn-primary pull-left" title="<%= I18n.t("gallery.back_to_albums") %>" href="orbit_gallery"><i class="icon-arrow-left icon-white"></i><%= I18n.t("gallery.back_to_albums") %></a> ';
<% if @authenticated %>
headarea+='<a class="bt-add btn btn-primary pull-right" title="<%= I18n.t("gallery.add_images") %>" href="images" onclick="return false;"><i class="icon-plus icon-white"></i><%= I18n.t("gallery.add_images") %></a> ';
headarea+='<a class="bt-del btn btn-primary pull-right" title="<%= I18n.t("gallery.del_album") %>" href="delete" onclick="return false;"><i class="icon-trash icon-white"></i><%= I18n.t("gallery.del_album") %></a> ';
headarea+='<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="orbit_gallery?edit='+id+'" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>';
headarea+='<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.album_tag") %>" href="" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.album_tag") %></a>';
<% end %>
}else if(area == "albums"){
<% if @authenticated %>
headarea = '<a class="btn btn-primary pull-right" title="<%= I18n.t("gallery.add_album") %>" href="albums" onclick="return false;"><i class="icon-plus icon-white"></i><%= I18n.t("gallery.add_album") %></a>';
<% end %>
}else if (area == "theater"){
headarea = '<a href="" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a></div>';
headarea+= '<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>';
headarea+= '<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.photo_tag") %>" href="" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.photo_tag") %></a>';
}
if(typeof callbackFn == "function"){
callbackFn.call(this,headarea);
}
}
</script>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "galleryAPI" %>
<%= javascript_include_tag "rss" %>
<% end %>
<script type="text/javascript">
galleryAPI.prototype.locale = "<%= I18n.locale %>";
var gallery = new galleryAPI();
gallery.initialize();
</script>

View File

@ -0,0 +1,34 @@
<!-- <div class="rghead">
<div class="rgfn">
<a href="" class="rgui bt-back rgbt" title="Back" id='bakbtngallery'><span id='album_name_span'>Back to photos</span></a>
</div>
<div class="rgtitle">Gallery</div>
</div>
</div> -->
<div class="rslide" style="position:relative; width:100%;">
<div class="rslideinside"><div id="loading" style="display:none;"></div>
<div class="comp" id='main_pic' data-content='<%= @image.gallery_album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.url %>" alt="" /></a></div>
<div class="rslidenav">
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
<a href="" class="navN" title="下一張" onclick="return false;">Next</a>
</div>
</div>
<div class="slidelist">
<ul id='galleryimagelist' style="display:none;">
<% i=0 %>
<% @images.each do |image| %>
<li for="<%= i %>"><a href="orbit_gallery?theater=<%= image.id %>" class="list_element" data-content="<%= image.file.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" /></a></li>
<% i=i+1 %>
<% end %>
</ul>
</div>
<div class="slidectrl">
<a href="" class="togglescreen" title="切換全螢幕" onclick="return false;">Screen</a>
<a href="" class="togglelist" title="顯示照片清單" onclick="return false;">List</a>
<a href="" class="browserfullscreen" title="顯示照片清單" onclick="return false;">F</a>
<div class="slideinfo">
<!-- <b class="info"><%= @image.title %></b> -->
<span class="info"><%= @image.description %></span>
</div>
</div>
</div>

View File

@ -0,0 +1,108 @@
<html>
<head>
<%= csrf_meta_tag %>
<%= javascript_include_tag "jquery-latest" %>
<%= stylesheet_link_tag "jquery-ui" %>
<%= stylesheet_link_tag "jquery.fileupload-ui.css" %>
</head>
<body>
<div id='scroller_for_panel'>
<div id="fileupload">
<form action="upload_image" method="POST" enctype="multipart/form-data">
<div class="fileupload-buttonbar">
<label class="fileinput-button">
<span>Add files...</span>
<input type="file" name="files[]" multiple>
</label>
<input type="hidden" value="" name="aid" id="fileupload_aid" />
<button type="submit" class="start">Start upload</button>
<button type="reset" class="cancel">Cancel upload</button>
<!-- <button type="button" class="delete">Delete files</button>-->
</div>
</form>
<div class="fileupload-content">
<table class="files"></table>
<div class="fileupload-progressbar"></div>
</div>
</div>
<script id="template-upload" type="text/x-jquery-tmpl">
<tr class="template-upload{{if error}} ui-state-error{{/if}}">
<td class="preview"></td>
<td class="name">{{if name}}${name}{{else}}Untitled{{/if}}</td>
<td class="size">${sizef}</td>
{{if error}}
<td class="error" colspan="2">Error:
{{if error === 'maxFileSize'}}File is too big
{{else error === 'minFileSize'}}File is too small
{{else error === 'acceptFileTypes'}}Filetype not allowed
{{else error === 'maxNumberOfFiles'}}Max number of files exceeded
{{else}}${error}
{{/if}}
</td>
{{else}}
<td class="progress"><div></div></td>
<td class="start"><button>Start</button></td>
{{/if}}
<td class="cancel"><button>Cancel</button></td>
</tr>
</script>
<script id="template-download" type="text/x-jquery-tmpl">
<tr class="template-download{{if error}} ui-state-error{{/if}}">
{{if error}}
<td></td>
<td class="name">${name}</td>
<td class="size">${sizef}</td>
<td class="error" colspan="2">Error:
{{if error === 1}}File exceeds upload_max_filesize (php.ini directive)
{{else error === 2}}File exceeds MAX_FILE_SIZE (HTML form directive)
{{else error === 3}}File was only partially uploaded
{{else error === 4}}No File was uploaded
{{else error === 5}}Missing a temporary folder
{{else error === 6}}Failed to write file to disk
{{else error === 7}}File upload stopped by extension
{{else error === 'maxFileSize'}}File is too big
{{else error === 'minFileSize'}}File is too small
{{else error === 'acceptFileTypes'}}Filetype not allowed
{{else error === 'maxNumberOfFiles'}}Max number of files exceeded
{{else error === 'uploadedBytes'}}Uploaded bytes exceed file size
{{else error === 'emptyResult'}}Empty file upload result
{{else}}${error}
{{/if}}
</td>
{{else}}
<td class="preview">
{{if thumbnail_url}}
<a href="${url}" target="_blank"><img src="${thumbnail_url}"></a>
{{/if}}
</td>
<td class="name">
<a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>
</td>
<td class="size">${sizef}</td>
<td colspan="2"></td>
{{/if}}
</tr>
</script>
<script type="text/javascript">
$("input#fileupload_aid").val(parent.g.urlVars['album']);
</script>
</div>
<%= javascript_include_tag "jquery-ui.min" %>
<%= javascript_include_tag "jquery.tmpl.min" %>
<%= javascript_include_tag "jquery.iframe-transport" %>
<%= javascript_include_tag "jquery.fileupload" %>
<%= javascript_include_tag "jquery.fileupload-ui" %>
<%= javascript_include_tag "upload" %>
</body>
</html>
<!-- <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="../../js/gallery/jquery.iframe-transport.js"></script>
<script src="../../js/gallery/jquery.fileupload.js"></script>
<script src="../../js/gallery/jquery.fileupload-ui.js"></script>
<script src="../../js/gallery/upload.js"></script> -->

View File

@ -20,6 +20,10 @@ Rails.application.routes.draw do
match "update_album" => "orbit_galleries#update_album"
match "save_tags" => "orbit_galleries#save_tags"
resources :tags
end
namespace :front_end do
match "orbit_galleries" => "orbit_galleries#index"
match "get_albums" => "orbit_galleries#get_albums"
end
end
end