Commit for view only

This commit is contained in:
Harry Bomrah 2012-08-23 19:25:56 +08:00 committed by Christophe Vilayphiou
parent f4dde67344
commit f62eba182e
4 changed files with 48 additions and 25 deletions

View File

@ -245,8 +245,6 @@ var galleryAPI = function(){
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;
@ -254,10 +252,16 @@ var galleryAPI = function(){
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);
})
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);
})
}
// g.albumArea.find("#imgholder").append($addsign);
})
// g.albumArea.find("#imgholder").append($addsign);

View File

@ -1,8 +1,9 @@
class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
include AdminHelper
@authenticated = false
def index
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
@authenticated = false
end
@ -126,7 +127,26 @@ include AdminHelper
def get_images
@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
def theater

View File

@ -86,24 +86,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

@ -68,7 +68,6 @@
</div>
</div>
<!-- tag part -->
<% if @authenticated %>
<div id="tag_panel" class="my_scroll">
<div class="scrollbar">
<div class="track">
@ -86,16 +85,20 @@
<div class="viewport">
<div class="overview">
<ul class="tag_list" id="gallery_tag_list">
<% if @authenticated %>
<% @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 %>
<% 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>
<% 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>
<% end %>
<script type="text/javascript">
var $tag_panel = $('#tag_panel');
orbit_bar_height = $('#orbit-bar').outerHeight();
@ -125,11 +128,11 @@ 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> ';
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 %>
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 %>