changed the frontend loading to more rails specific. and also fixed the filter reload in thumbnali and summary view of members

This commit is contained in:
Harry Bomrah 2013-11-07 14:13:55 +08:00 committed by saurabhbhatia
parent 4e706fab0c
commit 4353b481c7
8 changed files with 33 additions and 129 deletions

View File

@ -25,12 +25,12 @@
<ul class="nav nav-pills filter-nav pull-right">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
<a href="#collapse-role" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
</div>
</li>
</ul>
<div class="filter-group accordion-group">
<div class="accordion-body collapse" id="collapse-status">
<div class="accordion-body collapse" id="collapse-role">
<%= render :partial => "filter"%>

View File

@ -25,12 +25,12 @@
<ul class="nav nav-pills filter-nav pull-right">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
<a href="#collapse-role" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
</div>
</li>
</ul>
<div class="filter-group accordion-group">
<div class="accordion-body collapse" id="collapse-status">
<div class="accordion-body collapse" id="collapse-role">
<%= render :partial => "filter"%>

View File

@ -32,52 +32,8 @@ var galleryAPI = function(){
}
}
$(document).ready(function(){
//bindHandlers();
})
var bindHandlers = function(){
}
}
}
this.loadAlbums = function(cids){
g.albumArea.find(".rghead .rgfn a").click(function(){g.makeNewAlbum($(this).attr("href"))});
g.albumArea.addClass('o_gallery');
g.albumArea.find("#imgholder").empty();
$.getJSON("/panel/gallery/front_end/get_albums",{"cid":cids,"inner":true},function(categories){
$.each(categories,function(x,category){
$.each(category,function(i,album){
album.description = (album.description?album.description:"<%= I18n.t('gallery.no_description') %>")
if(album.cover == "default")
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='"+album.show_path+"'><img src='../../../assets/gallery/default.jpg'/></a><span class='albumname'><a title='"+album.description+"' href='?album="+album._id+"'>"+album.name+"</a></span><span class='categoryname'><i class='icon-folder-close'></i> "+album.category_name+"</span><span class='tagnames'></span></div>");
else
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='"+album.show_path+"'><img src='"+album.cover_path+"'/></a><span class='albumname'><a title='"+album.description+"' href='?album="+album._id+"'>"+album.name+"</a></span><span class='categoryname'><i class='icon-folder-close'></i> "+album.category_name+"</span><span class='tagnames'></span></div>");
var tag_string = "";
for(tag in album.tag_names){
if(tag == album.tag_names.length-1)
tag_string+= '<span class="tags">' + album.tag_names[tag] + '</span>';
else
tag_string+= '<span class="tags">' + album.tag_names[tag] + ', </span>';
}
$img.find(".tagnames").html(tag_string);
g.albumArea.find("#imgholder").append($img);
})
})
})
}
this.loadImages = function(id){
g.albumArea.addClass('o_album');
g.albumArea.find("#imgholder").empty();
$.getJSON("panel/gallery/front_end/albums/"+id+"/imgs",{inner:true},function(album){
$.each(album.images,function(i,image){
var thumb = image.file.thumb.url;
image.description = (image.description?image.description:"<%= I18n.t('gallery.no_description') %>")
var $img = $("<div class='rgphoto'><a title='"+image.description+"' href='"+image.theater_link+"'><img src='"+thumb+"'/></a></div>");
g.albumArea.find("#imgholder").append($img);
})
})
}
this.loadTheater = function(id){
var imageArray;
var imagecount = 0;

View File

@ -1,31 +1,11 @@
class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
def index
@categories = params[:category_id]
@albums = GalleryAlbum.where(:category_id.in => params[:category_id])
end
def show
@album = GalleryAlbum.find(params[:id])
@tags = Tag.find(@album.tagged_ids).map{|t| t.name}
end
def get_albums
@categoryids = params["cid"]
@albums = Array.new
@albums << GalleryAlbum.where(:category_id.in => @categoryids)
@output = Array.new
@albums.each do |album|
@albs = Array.new
album.each do |values|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
category = Category.find(values.category_id).title
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
@output << @albs
end
render :json=>@output.to_json
@images = @album.gallery_images
end
def imgs

View File

@ -0,0 +1,14 @@
<div class='rgalbum'>
<a title='<%= album.name %>' href='<%= panel_gallery_front_end_album_path(album) %>'>
<% if album.cover == "default" %>
<%= image_tag "gallery/default.jpg" %>
<% else %>
<img src="<%= album.cover_path %>">
<% end %>
</a>
<span class='albumname'>
<a title='<%= album.description %>' href='<%= panel_gallery_front_end_album_path(album) %>'><%= album.name %></a>
</span>
<span class='categoryname'><i class='icon-folder-close'></i><%= Category.find(album.category_id).title %></span>
<span class='tagnames'></span>
</div>

View File

@ -0,0 +1,5 @@
<div class='rgphoto'>
<a title='<%= image.description %>' href='<%= theater_panel_gallery_front_end_album_path(image) %>'>
<img src='<%= image.file.thumb.url %>'/>
</a>
</div>

View File

@ -1,35 +1,14 @@
<%= stylesheet_link_tag "gallery_frontend" %>
<%#= stylesheet_link_tag "gallery" %>
<div id="orbit_gallery" class="rg">
<div class="rgbody">
<div id="imgholder">
<% @albums.each do |album| %>
<%= render :partial => "album", :object => album %>
<% end %>
</div>
</div>
<div class="rghead">
<div class="rgfn">
</div>
</div>
</div>
<script type="text/javascript">
</script>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "galleryAPI_frontend" %>
<%#= javascript_include_tag "jquery.tinyscrollbar" %>
<%= javascript_include_tag "rss" %>
<% end %>
<script type="text/javascript">
galleryAPI.prototype.locale = "<%= I18n.locale %>";
var gallery = new galleryAPI();
var categories = <%= @categories.to_json.html_safe %>;
gallery.initialize();
gallery.loadArea = "albums";
gallery.loadAlbums(categories);
</script>

View File

@ -1,42 +1,12 @@
<%= stylesheet_link_tag "gallery_frontend" %>
<div id="orbit_gallery" class="rg">
<div class="rgbody">
<div id="imgholder">
<% @images.each do |image| %>
<%= render :partial => "image", :object => image %>
<% end %>
</div>
</div>
<!-- tag part -->
<!-- add "album_tags" or "photo_tags" class to .taglist -->
<div class="taglist">
<h3 class="taglist_title"><%= t('gallery.album_tag') %></h3>
<ul>
<% @tags.each do |tag|%>
<li><%= tag %></li>
<% end %>
</ul>
</div>
<!-- tag end -->
<!-- -->
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "galleryAPI_frontend" %>
<%#= javascript_include_tag "jquery.tinyscrollbar" %>
<%= javascript_include_tag "rss" %>
<% end %>
<script type="text/javascript">
galleryAPI.prototype.locale = "<%= I18n.locale %>";
var gallery = new galleryAPI();
gallery.initialize();
gallery.loadArea = "images";
gallery.loadImages("<%= params[:id] %>");
</script>