Commit for view only

This commit is contained in:
Harry Bomrah 2012-08-23 19:25:56 +08:00
parent 861f521da3
commit 33bc430df5
4 changed files with 48 additions and 25 deletions

View File

@ -246,8 +246,6 @@ 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","");
// 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){ $.getJSON("get_images",{aid:id},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;
@ -255,10 +253,16 @@ var galleryAPI = function(){
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);
$.each(album.tags,function(i,tag){ if(typeof album.tag_names == "undefined"){
$.each(album.tags,function(i,tag){
g.tagList.find("li[data-content="+tag+"] input").attr("checked",true); 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);
})
}
// g.albumArea.find("#imgholder").append($addsign); // g.albumArea.find("#imgholder").append($addsign);
}) })
// g.albumArea.find("#imgholder").append($addsign); // g.albumArea.find("#imgholder").append($addsign);

View File

@ -1,8 +1,9 @@
class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
include AdminHelper include AdminHelper
@authenticated = false
def index def index
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 = false #turn this value to false for view only
else else
@authenticated = false @authenticated = false
end end
@ -126,7 +127,26 @@ include AdminHelper
def get_images def get_images
@album = GalleryAlbum.find(params["aid"]) @album = GalleryAlbum.find(params["aid"])
render :json=>{"images" => @album.gallery_images.all, "tags" => @album.tag_ids}.to_json @tag_names = Array.new
@images = @album.gallery_images.all
@output = Array.new
@images.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
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}
end
@authenticated = false
if @authenticated
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
else
@album.tag_ids.each do |tag|
@tag_names << GalleryTag.find(tag)[I18n.locale]
end
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
end
end end
def theater def theater

View File

@ -86,24 +86,20 @@ include AdminHelper
end end
end end
end end
i = 0 @output = Array.new
@albums.each do |album| @albums.each do |album|
@albs = Array.new
album.each do |values| album.each do |values|
# if values.tag_ids.kind_of?(Array)
tags = Array.new tags = Array.new
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
# end category = GalleryCategory.find(values.gallery_category_id).name
values.tag_names = tags @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}
values.save
end end
i = i + 1 @output << @albs
end end
# @albums = GalleryAlbum.find("5017a7babd98eb049900000a") render :json=>@output.to_json
# @albums.update_attributes({:tag_ids =>["501ba786bd98eb0232000126"]})
render :json=>@albums.to_json
end end
def upload_image def upload_image

View File

@ -68,7 +68,6 @@
</div> </div>
</div> </div>
<!-- tag part --> <!-- tag part -->
<% if @authenticated %>
<div id="tag_panel" class="my_scroll"> <div id="tag_panel" class="my_scroll">
<div class="scrollbar"> <div class="scrollbar">
<div class="track"> <div class="track">
@ -86,16 +85,20 @@
<div class="viewport"> <div class="viewport">
<div class="overview"> <div class="overview">
<ul class="tag_list" id="gallery_tag_list"> <ul class="tag_list" id="gallery_tag_list">
<% if @authenticated %>
<% @tags.each do |tag| %> <% @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> <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 %> <% end %>
<% end %>
</ul> </ul>
</div> </div>
</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> <% if @authenticated %>
<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>
<% end %>
</div> </div>
<% end %>
<script type="text/javascript"> <script type="text/javascript">
var $tag_panel = $('#tag_panel'); var $tag_panel = $('#tag_panel');
orbit_bar_height = $('#orbit-bar').outerHeight(); orbit_bar_height = $('#orbit-bar').outerHeight();
@ -125,11 +128,11 @@ galleryAPI.prototype.loadFooterPanel = function(area,id,callbackFn){
var headarea = null; var headarea = null;
if(area == "images"){ 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> '; 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> ';
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>';
<% if @authenticated %> <% 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-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-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-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 %> <% end %>
}else if(area == "albums"){ }else if(area == "albums"){
<% if @authenticated %> <% if @authenticated %>