Ruby update

This commit is contained in:
Harry Bomrah 2012-08-28 21:04:48 +08:00
parent 62abbf9417
commit a11d865dd1
9 changed files with 137 additions and 163 deletions

View File

@ -1,3 +1,4 @@
<%# encoding: utf-8 %>
$.extend($.expr[':'], { $.extend($.expr[':'], {
'containsi': function (elem, i, match, array) { 'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
@ -9,41 +10,9 @@ var galleryAPI = function(){
this.albumArea = $("#orbit_gallery"); this.albumArea = $("#orbit_gallery");
this.loadArea = null; this.loadArea = null;
this.tagList = $("ul#gallery_tag_list"); this.tagList = $("ul#gallery_tag_list");
// this.authenticated = false;
this.initialize = function(callbackFn){ this.initialize = function(callbackFn){
$(document).ready(function(){ $(document).ready(function(){
bindHandlers(); 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(){ var bindHandlers = function(){
$("#filter .filter_btns a").click(function(){ $("#filter .filter_btns a").click(function(){
@ -84,8 +53,8 @@ var galleryAPI = function(){
window.location = url; window.location = url;
}) })
} }
this.makeNewAlbum = function(){ this.makeNewAlbum = function(path){
$.get("albums/new",function(html){ $.get(path,function(html){
rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){ rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){
dom.find("#album_name_save_btn").click(function(){ dom.find("#album_name_save_btn").click(function(){
var options ={ var options ={
@ -127,7 +96,7 @@ var galleryAPI = function(){
} }
this.loadAlbums = function(id){ this.loadAlbums = function(id){
g.albumArea.find(".rghead .rgfn a").click(function(){g.makeNewAlbum()}); g.albumArea.find(".rghead .rgfn a").click(function(){g.makeNewAlbum($(this).attr("href"))});
g.albumArea.addClass('o_gallery'); g.albumArea.addClass('o_gallery');
g.albumArea.find("#imgholder").empty(); g.albumArea.find("#imgholder").empty();
if(id!="all"){ if(id!="all"){
@ -155,9 +124,9 @@ var galleryAPI = function(){
$.each(categories,function(x,category){ $.each(categories,function(x,category){
$.each(category,function(i,album){ $.each(category,function(i,album){
if(album.cover == "default") if(album.cover == "default")
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='albums/"+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>"); var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='"+album.show_path+"'><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 else
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='albums/"+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 $img = $("<div class='rgalbum'><a title='"+album.description+"' href='"+album.show_path+"'><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 = ""; var tag_string = "";
for(tag in album.tag_names){ for(tag in album.tag_names){
@ -167,7 +136,6 @@ var galleryAPI = function(){
g.albumArea.find("#imgholder").append($img); g.albumArea.find("#imgholder").append($img);
}) })
}) })
// g.albumArea.find("#imgholder").append($addsign);
}) })
} }
this.loadImages = function(id){ this.loadImages = function(id){
@ -205,7 +173,7 @@ var galleryAPI = function(){
} }
}) })
g.albumArea.find("#tag_panel .bt-save").click(function(){ g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(id,g.loadArea); g.saveTags(id,"album");
}) })
g.albumArea.find(".rghead .rgfn .bt-add").click(function(){ g.albumArea.find(".rghead .rgfn .bt-add").click(function(){
showUploadPanel(); showUploadPanel();
@ -235,10 +203,10 @@ var galleryAPI = function(){
g.albumArea.find("#imgholder").empty(); g.albumArea.find("#imgholder").empty();
$("#filter").remove(); $("#filter").remove();
g.albumArea.css("margin-top",""); g.albumArea.css("margin-top","");
$.getJSON(id+"/get_images",function(album){ $.getJSON(id+"/imgs",function(album){
$.each(album.images,function(i,image){ $.each(album.images,function(i,image){
var thumb = image.file.thumb.url; var thumb = image.file.thumb.url;
var $img = $("<div class='rgphoto'><a title='"+image.description+"' href='?theater="+image._id+"'><img src='"+thumb+"'/></a></div>"); var $img = $("<div class='rgphoto'><a title='"+image.description+"' href='"+image.theater_link+"'><img src='"+thumb+"'/></a></div>");
g.albumArea.find("#imgholder").append($img); g.albumArea.find("#imgholder").append($img);
}) })
g.tagList.find("input").attr("checked",false); g.tagList.find("input").attr("checked",false);
@ -252,11 +220,8 @@ var galleryAPI = function(){
g.tagList.append($li); g.tagList.append($li);
}) })
} }
// g.albumArea.find("#imgholder").append($addsign);
})
// g.albumArea.find("#imgholder").append($addsign);
// tag
})
} }
this.loadTheater = function(id){ this.loadTheater = function(id){
var imageArray; var imageArray;
@ -329,7 +294,7 @@ var galleryAPI = function(){
} }
}) })
g.albumArea.find("#tag_panel .bt-save").click(function(){ g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(imageArray[imagecount]._id,g.loadArea) g.saveTags(imageArray[imagecount]._id,"pic")
var tagids = new Array(); var tagids = new Array();
g.tagList.find("li input:checked").each(function(){ g.tagList.find("li input:checked").each(function(){
tagids.push($(this).parent().attr("data-content")); tagids.push($(this).parent().attr("data-content"));
@ -461,15 +426,15 @@ var galleryAPI = function(){
next = imagecount + 1; next = imagecount + 1;
prev = imagecount - 1; prev = imagecount - 1;
} }
$(".navN").attr({"href":"orbit_gallery?theater="+imageArray[next]._id,"data-content":imageArray[next].file.url}); $(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.url});
$(".navP").attr({"href":"orbit_gallery?theater="+imageArray[prev]._id,"data-content":imageArray[prev].file.url}); $(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.url});
}; };
if(imageArray.length > 1) if(imageArray.length > 1)
updateNavigation(); updateNavigation();
} }
var preparestage = function(albumid){ var preparestage = function(albumid){
$.getJSON("get_images",{aid:albumid},function(album){ $.getJSON("../albums/"+albumid+"/imgs",function(album){
imageArray = eval(album.images); imageArray = eval(album.images);
$.each(album.images,function(i,image){ $.each(album.images,function(i,image){
if(image._id == id) if(image._id == id)
@ -478,36 +443,28 @@ var galleryAPI = function(){
bindHandlers(); 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.albumArea.find(".bt-back").attr("href","album_images?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);
}); 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);
} }
this.editAlbum = function(id){ this.editAlbum = function(id){
var bindHandlers = function(){ var bindHandlers = function(){
$(".nav .nav-tabs a").click(function(){ $(".nav .nav-tabs a").click(function(){
$(".tab_content .tab-pane").hide(); $(".tab_content .tab-pane").hide();
}) })
$(".description_loader .edit_fn .bt-cover").click(function(){ $(".description_loader .edit_fn .bt-cover").click(function(){
$(".bt-cover").removeClass("setcover active btn-primary"); $(".bt-cover").removeClass("setcover active btn-primary");
$(".bt-cover span").removeClass("icon-white icon-star").addClass("icon-star-empty") $(".bt-cover span").removeClass("icon-white icon-star").addClass("icon-star-empty");
$(".bt-cover[for="+$(this).attr("for")+"]").addClass("setcover active btn-primary"); $(".bt-cover[for="+$(this).attr("for")+"]").addClass("setcover active btn-primary");
$(".bt-cover[for="+$(this).attr("for")+"]").find("span").removeClass("icon-star-empty").addClass("icon-white icon-star"); $(".bt-cover[for="+$(this).attr("for")+"]").find("span").removeClass("icon-star-empty").addClass("icon-white icon-star");
$.post("set_cover",{"imageid":$(this).attr("for")},function(){}) $.post("set_cover",{"imageid":$(this).attr("for")});
}) })
$(".description_loader .edit_fn .bt-dels").click(function(){ $(".description_loader .edit_fn .bt-dels").click(function(){
$(this) $(this)
@ -535,13 +492,23 @@ var galleryAPI = function(){
// }) // })
}) })
var current_element_for_tags = null;
$('.bt-tag').click(function(){ $('.bt-tag').click(function(){
var has_class = false;
if($(this).hasClass("active"))
has_class = true;
$('.bt-tag').removeClass("active");
$(this).toggleClass("active"); $(this).toggleClass("active");
var count = 0; var count = 0;
$('.bt-tag').each(function(){ $('.bt-tag').each(function(){
if($(this).hasClass("active")) if($(this).hasClass("active"))
count++; count++;
}) })
if(has_class){
$(this).removeClass("active");
count = 0;
}
var $tag_panel = $('#tag_panel'), var $tag_panel = $('#tag_panel'),
tag_panel_position = 0; tag_panel_position = 0;
if(count == 1) if(count == 1)
@ -558,6 +525,16 @@ var galleryAPI = function(){
.delay(200) .delay(200)
.animate({'margin-right':tag_panel_position+200},300); .animate({'margin-right':tag_panel_position+200},300);
current_element_for_tags = $(this).attr("href");
if(count == 1){
var no = $(this).parent().attr("no");
if(imageTagArray[no].id == current_element_for_tags){
g.tagList.find("input").attr("checked",false);
for(tag in imageTagArray[no].tags){
g.tagList.find("li[data-content="+imageTagArray[no].tags[tag]+"] input").attr("checked",true);
}
}
}
return false; return false;
}); });
g.albumArea.find("#tag_search_box").keyup(function(e){ g.albumArea.find("#tag_search_box").keyup(function(e){
@ -578,7 +555,7 @@ var galleryAPI = function(){
} }
}) })
g.albumArea.find("#tag_panel .bt-save").click(function(){ g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(imageArray[imagecount]._id,g.loadArea); g.saveTags(current_element_for_tags,"pic");
}) })
var tempval; var tempval;
$(".txtchange").focus(function(){ $(".txtchange").focus(function(){
@ -615,17 +592,15 @@ var galleryAPI = function(){
g.albumArea.find(".rghead .rgfn .bt-delete").hide(); g.albumArea.find(".rghead .rgfn .bt-delete").hide();
} }
}) })
// $.post("delete",{"images":images_to_delete,"delete_cover":delete_cover,"aid":id},function(response){
// if(response.success){
// }
// })
} }
}) })
} }
$("#filter").remove(); $("#filter").remove();
g.albumArea.addClass('o_album_edit'); g.albumArea.addClass('o_album_edit');
g.albumArea.css("margin-top",""); var imageTagArray = null;
$.getJSON("images_tags",function(data){
imageTagArray = eval(data);
})
bindHandlers(); bindHandlers();
} }
this.saveTags = function(id,tagsfor){ this.saveTags = function(id,tagsfor){
@ -633,15 +608,7 @@ var galleryAPI = function(){
g.tagList.find("li input:checked").each(function(){ g.tagList.find("li input:checked").each(function(){
tagids.push($(this).parent().attr("data-content")); tagids.push($(this).parent().attr("data-content"));
}) })
var tag = null; $.post("../save_tags",{"id":id,"tag":tagsfor,"tids":tagids})
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"; galleryAPI.prototype.locale = "en";

View File

@ -1,15 +1,21 @@
class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
include AdminHelper include AdminHelper
def theater def show
picid = params["pic"] if is_manager? || is_admin? || is_sub_manager?
@image = GalleryImage.find(picid) @authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@tags = GalleryTag.all
@image = GalleryImage.find(params[:id])
@albumid = @image.gallery_album_id @albumid = @image.gallery_album_id
album = GalleryAlbum.find(@albumid) @album = GalleryAlbum.find(@albumid)
@images = album.gallery_images.all @images = @album.gallery_images.all
render :layout=>false
end end
def destroy def destroy
images = params['images'] images = params['images']
images.each do |image| images.each do |image|
@ -57,15 +63,5 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
end 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 end

View File

@ -18,7 +18,7 @@ include AdminHelper
else else
@authenticated = false @authenticated = false
end end
@categorylist = GalleryCategory.all @album = GalleryAlbum.find(params[:id])
@tags = GalleryTag.all @tags = GalleryTag.all
end end
@ -43,7 +43,6 @@ include AdminHelper
album.name = albumnames["zh_tw"] album.name = albumnames["zh_tw"]
album.description = albumdescs["zh_tw"] album.description = albumdescs["zh_tw"]
album.save! album.save!
#x = category.gallery_albums.create({name: params['albumname'],description: params['albumdesc']})
render :json=>{"success"=>true,"id"=>album.id}.to_json render :json=>{"success"=>true,"id"=>album.id}.to_json
end end
@ -88,7 +87,7 @@ include AdminHelper
tags << GalleryTag.find(tag)[I18n.locale] tags << GalleryTag.find(tag)[I18n.locale]
end end
category = GalleryCategory.find(values.gallery_category_id).name 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} @albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"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 end
@output << @albs @output << @albs
end end
@ -118,7 +117,7 @@ include AdminHelper
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
end end
def get_images def imgs
@album = GalleryAlbum.find(params[:album_id]) @album = GalleryAlbum.find(params[:album_id])
@tag_names = Array.new @tag_names = Array.new
@images = @album.gallery_images.all @images = @album.gallery_images.all
@ -128,7 +127,7 @@ include AdminHelper
values.tag_ids.each do |tag| values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale] tags << GalleryTag.find(tag)[I18n.locale]
end end
@output << {"_id"=>values.id,"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags} @output << {"_id"=>values.id,"theater_link"=>panel_gallery_back_end_album_image_path(values),"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end end
if is_manager? || is_admin? || is_sub_manager? if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only @authenticated = true #turn this value to false for view only
@ -160,6 +159,15 @@ include AdminHelper
end end
render :json=>a.to_json render :json=>a.to_json
end end
def images_tags
album = GalleryAlbum.find(params[:album_id])
tags = Array.new
images = album.gallery_images.all
images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids}
end
render :json=>tags.to_json
end
end end

View File

@ -1,8 +1,18 @@
class Panel::Gallery::BackEnd::TagsController < Admin::TagsController class Panel::Gallery::BackEnd::TagsController < Admin::TagsController
def initialize def initialize
super super
@app_title = 'gallery' @app_title = 'gallery'
end 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 end

View File

@ -4,7 +4,30 @@
<div id="orbit_gallery" class="rg"> <div id="orbit_gallery" class="rg">
<div class="rgbody"> <div class="rgbody">
<div id="imgholder"> <div id="imgholder">
<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;">
<% @images.each_with_index do |image,i| %>
<li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" /></a></li>
<% 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">
<span class="info"><%= @image.description %></span>
</div>
</div>
</div>
</div> </div>
</div> </div>
<!-- tag part --> <!-- tag part -->
@ -59,19 +82,11 @@
<!-- tag end --> <!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead"> <div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn"> <div class="rgfn">
<% if params[:theater] %> <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>
<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> <% if @authenticated %>
<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> <a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="<%= edit_panel_gallery_back_end_album_path(@album) %>" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
<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>
<% else %>
<a class="bt-back btn btn-primary pull-left" title="<%= I18n.t("gallery.back_to_albums") %>" href="albums"><i class="icon-arrow-left icon-white"></i><%= I18n.t("gallery.back_to_albums") %></a>
<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>
<% if @authenticated %>
<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>
<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>
<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="../albums/<%= params[:id] %>/edit" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
<% end %>
<% end %> <% end %>
<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.photo_tag") %>" href="#tags" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.photo_tag") %></a>
</div> </div>
</div> </div>
</div> </div>
@ -84,8 +99,8 @@
galleryAPI.prototype.locale = "<%= I18n.locale %>"; galleryAPI.prototype.locale = "<%= I18n.locale %>";
var gallery = new galleryAPI(); var gallery = new galleryAPI();
gallery.initialize(); gallery.initialize();
gallery.loadArea = "images"; gallery.loadArea = "theater";
gallery.loadImages("<%= params[:id] %>"); gallery.loadTheater("<%= params[:id] %>");
</script> </script>

View File

@ -13,7 +13,7 @@
<% end %> <% end %>
</ul> </ul>
<!-- <form id="edit_album" action="update_album" method="post"> --> <!-- <form id="edit_album" action="update_album" method="post"> -->
<%= form_for @album, :url => panel_gallery_back_end_albums_path(@album), :html => {:class => 'clear'} do |f| %> <%= form_for @album, :url => panel_gallery_back_end_album_path(@album), :html => {:class => 'clear'} do |f| %>
<div class="tab_content"> <div class="tab_content">
<% @site_valid_locales.each_with_index do |locale, i| %> <% @site_valid_locales.each_with_index do |locale, i| %>
<% if i == 0 %> <% if i == 0 %>
@ -30,16 +30,18 @@
<div class='description_loader'> <div class='description_loader'>
<% @images.each_with_index do |image,x| %> <% @images.each_with_index do |image,x| %>
<div class="rgphoto_edit <%= locale %>" data-content="<%= image.id %>"> <div class="rgphoto_edit <%= locale %>" data-content="<%= image.id %>">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a> <!-- <a href="<%= panel_gallery_back_end_album_images_path(image) %>"> -->
<%= link_to panel_gallery_back_end_album_image_path(image) do %>
<img src="<%= image.file.thumb.url %>" />
<% end %>
<div class="inputui rginput rgih98 w380"> <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] rescue nil %></textarea> -->
<%= f.fields_for :gallery_images do |j| %> <%= f.fields_for :gallery_images do |j| %>
<%= j.fields_for :description_translations do |desc| %> <%= j.fields_for :description_translations do |desc| %>
<%= desc.text_area locale, :value => (image.description_translations[locale] rescue nil ), :class => "txtchange" %> <%= desc.text_area locale, :value => (image.description_translations[locale] rescue nil ), :class => "txtchange" %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<div class="edit_fn"> <div class="edit_fn" no="<%= x %>">
<% if image.id.to_s == @cover %> <% if image.id.to_s == @cover %>
<a class="btn btn-primary rgbtsg bt-cover setcover active" onclick="return false;" title="<%= t("gallery.cover") %>" href="set_cover" for="<%= image.id %>"><span class="icon-star icon-white"></span></a> <a class="btn btn-primary rgbtsg bt-cover setcover active" onclick="return false;" title="<%= t("gallery.cover") %>" href="set_cover" for="<%= image.id %>"><span class="icon-star icon-white"></span></a>
<% else %> <% else %>
@ -55,7 +57,7 @@
<% end %> <% end %>
<div class="form-actions form-fixed pagination-right rghead"> <div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn"> <div class="rgfn">
<a href="../<%= params[: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> <a href="<%= panel_gallery_back_end_album_path(@album) %>" 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>
<a class="bt-del bt-delete btn btn-primary pull-right" onclick="return false;" style="display:none;" title="<%= I18n.t("gallery.delete_selected") %>" href="<%= panel_gallery_back_end_album_images_path %>"><i class="icon-trash icon-white"></i><%= I18n.t("gallery.delete_selected") %></a> <a class="bt-del bt-delete btn btn-primary pull-right" onclick="return false;" style="display:none;" title="<%= I18n.t("gallery.delete_selected") %>" href="<%= panel_gallery_back_end_album_images_path %>"><i class="icon-trash icon-white"></i><%= I18n.t("gallery.delete_selected") %></a>
<input type="submit" class="bt-save icon-ok btn btn-primary pull-right" style="display:none;" value="Save" /><i class="icon-ok icon-white"></i> <input type="submit" class="bt-save icon-ok btn btn-primary pull-right" style="display:none;" value="Save" /><i class="icon-ok icon-white"></i>
</div> </div>

View File

@ -97,7 +97,7 @@
<div class="form-actions form-fixed pagination-right rghead"> <div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn"> <div class="rgfn">
<% if @authenticated %> <% if @authenticated %>
<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> <a class="btn btn-primary pull-right" title="<%= I18n.t("gallery.add_album") %>" href="<%= new_panel_gallery_back_end_album_path %>" onclick="return false;"><i class="icon-plus icon-white"></i><%= I18n.t("gallery.add_album") %></a>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@ -58,20 +58,14 @@
</script> </script>
<!-- tag end --> <!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead"> <div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn"> <div class="rgfn">
<% if params[:theater] %> <a class="bt-back btn btn-primary pull-left" title="<%= I18n.t("gallery.back_to_albums") %>" href="<%= panel_gallery_back_end_albums_path %>"><i class="icon-arrow-left icon-white"></i><%= I18n.t("gallery.back_to_albums") %></a>
<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>
<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>
<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>
<% else %>
<a class="bt-back btn btn-primary pull-left" title="<%= I18n.t("gallery.back_to_albums") %>" href="../albums"><i class="icon-arrow-left icon-white"></i><%= I18n.t("gallery.back_to_albums") %></a>
<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> <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>
<% if @authenticated %> <% if @authenticated %>
<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> <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>
<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> <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>
<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="<%= params[:id] %>/edit" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a> <a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="<%= edit_panel_gallery_back_end_album_path(@album) %>" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
<% end %> <% end %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,37 +2,19 @@ Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :gallery do namespace :gallery do
namespace :back_end do namespace :back_end do
# match "orbit_gallery" => "orbit_galleries#index"
# match "add_album" => "orbit_galleries#add"
# match "create_album" => "orbit_galleries#create_album"
match "get_albums" => "albums#get_albums" match "get_albums" => "albums#get_albums"
match "upload_image" => "albums#upload_image" match "upload_image" => "albums#upload_image"
match "get_images" => "album_images#get_images" match "save_tags" => "tags#save_tags"
match "theater" => "album_images#theater"
# match "delete_album" => "orbit_galleries#delete"
# match "edit_album" => "orbit_galleries#edit"
#match "set_cover" => "albums#set_cover"
# match "delete_images" => "orbit_galleries#delete_images"
# # match "update_album" => "orbit_galleries#update_album"
match "save_tags" => "album_images#save_tags"
# match "categories" => "orbit_gallery_categories#index" resources :albums do
# match "gallery_category_delete" => "orbit_gallery_categories#delete"
# match "gallery_category_save" => "orbit_gallery_categories#new"
resources :albums do
match "set_cover" => "albums#set_cover" match "set_cover" => "albums#set_cover"
match "get_images" => "albums#get_images" match "imgs" => "albums#imgs"
match "upload_panel" => "albums#upload_panel" match "upload_panel" => "albums#upload_panel"
match "images_tags" => "albums#images_tags"
end
resources :album_images do
# match "delete" => "album_images#destroy"
end end
resources :album_images
resources :gallery_categories resources :gallery_categories
resources :tags resources :tags
end end
namespace :front_end do namespace :front_end do