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