Merge branch 'master' into 'master'
fix timeout error for too many album See merge request !14
This commit is contained in:
commit
f3b5133af3
|
@ -111,6 +111,14 @@ $(function () {
|
|||
});
|
||||
}
|
||||
});
|
||||
Array.prototype.uniq = function(){
|
||||
var attr = this
|
||||
attr = $.grep(attr, function(v, k){
|
||||
return $.inArray(v ,attr) === k;
|
||||
});
|
||||
return attr;
|
||||
}
|
||||
|
||||
function batch_crop(){
|
||||
var check_li = $('#imgholder').find("input[type='checkbox']:checked").parents('li');
|
||||
var image_ids =[];
|
||||
|
@ -372,11 +380,13 @@ $(function() {
|
|||
$container.sortable("enable");
|
||||
$(".order-edit-notification").slideDown();
|
||||
images_order = $container.sortable( "toArray", { attribute: "data-image-id" });
|
||||
images_order = images_order.uniq();
|
||||
$container.data("order-edit","1");
|
||||
translate(el,'','gallery.save_order',false)
|
||||
}else{
|
||||
var temp = $container.sortable( "toArray", { attribute: "data-image-id" }),
|
||||
type = $container.attr("id");
|
||||
temp = temp.uniq()
|
||||
if(images_order.toString() != temp.toString()){
|
||||
$.ajax({
|
||||
url : "/admin/galleries/order",
|
||||
|
|
|
@ -4,6 +4,7 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
before_filter :setup_vars
|
||||
before_action :authenticate_user, :except => "imgs"
|
||||
before_action :log_user_action
|
||||
layout :compute_layout
|
||||
find_tag = Tag.all.select{|value| value.name==I18n.t('gallery.not_show_desc')}
|
||||
if find_tag.length==0
|
||||
module_app_id = ModuleApp.where(:key=>"gallery").first[:_id]
|
||||
|
@ -38,7 +39,13 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def compute_layout
|
||||
if action_name== 'index' && !params['page_no'].nil?
|
||||
false
|
||||
else
|
||||
'back_end'
|
||||
end
|
||||
end
|
||||
def rotate_images
|
||||
begin
|
||||
image_ids = params['image_ids'].split(',')
|
||||
|
@ -250,21 +257,36 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
finish = AlbumVariable.first.finish rescue false
|
||||
render :json => {'percent' => progress_percent, 'filename' => progress_filename, 'finish' => finish }.to_json
|
||||
end
|
||||
def index
|
||||
Album.each do |album|
|
||||
if album.album_colors.first.nil?
|
||||
album.album_colors.create('color' => 'transparent')
|
||||
end
|
||||
end
|
||||
def filter_album
|
||||
@tags = @module_app.tags
|
||||
categories = @module_app.categories.enabled
|
||||
@filter_fields = filter_fields(categories, @tags)
|
||||
@filter_fields.delete(:status)
|
||||
@albums = Album.where(:order => -1).desc(:created_at).with_categories(filters("category")).with_tags(filters("tag"))
|
||||
@albums = search_data(@albums,[:name])
|
||||
albums = Album.where(:order.gt => -1).asc(:order).with_categories(filters("category")).with_tags(filters("tag"))
|
||||
albums = search_data(albums,[:name])
|
||||
@albums = @albums.concat(albums)
|
||||
albums1 = Album.where(:order => -1).desc(:created_at).with_categories(filters("category")).with_tags(filters("tag"))
|
||||
albums1 = search_data(albums1,[:name])
|
||||
albums2 = Album.where(:order.gt => -1).asc(:order).with_categories(filters("category")).with_tags(filters("tag"))
|
||||
albums2 = search_data(albums2,[:name])
|
||||
@fiter_albums = albums1.concat(albums2)
|
||||
end
|
||||
def index
|
||||
album_length = Album.all.count
|
||||
album_sort = Album.all.asc(:created_at)
|
||||
if album_sort.first.album_colors.first.nil?
|
||||
album_sort.each_with_index do |album|
|
||||
if album.album_colors.first.nil?
|
||||
album.album_colors.create('color' => 'transparent')
|
||||
end
|
||||
end
|
||||
end
|
||||
@url = request.original_fullpath
|
||||
if params['page_no'].nil?
|
||||
@show_script = true
|
||||
@albums = filter_album.take 50
|
||||
else
|
||||
@show_script = false
|
||||
start = (params['page_no'].to_i - 1)*50
|
||||
@albums = filter_album[start...start+50]
|
||||
end
|
||||
if AlbumColor.count!=0
|
||||
if AlbumColor.all.desc('updated_at').first[:color] == 'transparent'
|
||||
@color_save = ''
|
||||
|
|
|
@ -1,31 +1,67 @@
|
|||
<%= stylesheet_link_tag "gallery" %>
|
||||
<%= stylesheet_link_tag "lib/tags-groups" %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<% if @show_script %>
|
||||
<%= stylesheet_link_tag "gallery" %>
|
||||
<%= stylesheet_link_tag "lib/tags-groups" %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/jquery-ui-1.10.0.custom.min" %>
|
||||
<%= javascript_include_tag "jquery.masonry.min.js" %>
|
||||
<%= javascript_include_tag "jquery.lite.image.resize.js" %>
|
||||
<%= javascript_include_tag "gallery" %>
|
||||
<% end %>
|
||||
<%= render_filter @filter_fields, "orbit_gallery" %>
|
||||
<div class="order-edit-notification">Albums re-ordering enabled.</div>
|
||||
<%= render 'recreate_thumb' %>
|
||||
<div class="rgbody" style='float: left;'>
|
||||
<script type="text/javascript">
|
||||
var page_no = 2
|
||||
var catch_flag = true
|
||||
var max_page = <%= (@fiter_albums.length/50).ceil %>
|
||||
$('.bottomnav').ready(function(){
|
||||
function load_html_func(){
|
||||
$('#load_html').text("<%= t('gallery.wait_time') %>")
|
||||
if (catch_flag){
|
||||
catch_flag = true;
|
||||
$.ajax({
|
||||
type : "get",
|
||||
url : "<%= @url %>",
|
||||
dataType : "text",
|
||||
data:{page_no: page_no},
|
||||
global:false,
|
||||
success: function(data)
|
||||
{
|
||||
$('#orbit_gallery').append(data)
|
||||
page_no++
|
||||
catch_flag = true
|
||||
if (max_page < page_no){
|
||||
$('#load_html').hide()
|
||||
}
|
||||
$('#load_html').text("<%= t('gallery.load_html') %>")
|
||||
},
|
||||
error : function(data){
|
||||
catch_flag = true
|
||||
alert('please try again later.')
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
$('#load_html').click(load_html_func)
|
||||
})
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<%= render_filter @filter_fields, "orbit_gallery" %>
|
||||
<div class="order-edit-notification">Albums re-ordering enabled.</div>
|
||||
<%= render 'recreate_thumb' %>
|
||||
<div class="rgbody" style='float: left;'>
|
||||
<ul id="orbit_gallery" class="gallery clearfix" data-gallery-id="gallery"
|
||||
style='display: inline-flex;flex-wrap: wrap;'>
|
||||
<%= render :partial => "album", :collection => @albums %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="bottomnav clearfix">
|
||||
</div>
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<% if can_edit_or_delete?(nil) %>
|
||||
<a href="#" class="btn btn-small btn-info order-btn-class" id="edit-order-btn"><%= t('gallery.edit_order') %></a>
|
||||
<% end %>
|
||||
<% if @fiter_albums.length > 50 %>
|
||||
<button class="btn btn-small btn-info" id="load_html"><%= t('gallery.load_html') %></button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render :partial => "album", :collection => @albums %>
|
||||
<% end %>
|
|
@ -1 +1,2 @@
|
|||
<%= render_view %>
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
en:
|
||||
|
||||
gallery:
|
||||
load_html: Load next 50 data
|
||||
wait_time: please wait a minute
|
||||
show_desc: Show the album description
|
||||
not_show_desc: Don't show the album description
|
||||
show_original_image: Show the original picture
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
zh_tw:
|
||||
|
||||
gallery:
|
||||
load_html: 存取下50筆
|
||||
wait_time: 請稍等
|
||||
show_desc: 顯示相簿描述
|
||||
not_show_desc: 不顯示相簿描述
|
||||
show_original_image: 顯示原始圖片
|
||||
|
|
Loading…
Reference in New Issue