let user can set the amount of album limit for one page
This commit is contained in:
parent
3e0a8cff4d
commit
0dba57c48e
|
@ -170,7 +170,6 @@ function translate(ele,pretext,text,return_flag){
|
|||
alert('Your server has some problem, please try again later!')
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
var back = text.split('.')[1].split('_')
|
||||
var result = []
|
||||
|
@ -228,7 +227,28 @@ $(function() {
|
|||
};
|
||||
});
|
||||
$('#orbit_gallery').delegate('.icons-tag', clickEvent, function(){
|
||||
var tmp = $(this).parents('.rgalbum').eq(0)
|
||||
var now_this = $(this)
|
||||
if (tmp.find('.albumtag').eq(0).find('li.label').length == 0){
|
||||
var ele_id = tmp.attr('data-image-id')
|
||||
$.ajax({
|
||||
type : "post",
|
||||
url : "/admin/galleries/get_tag",
|
||||
dataType : "text",
|
||||
data:{ele_id: ele_id},
|
||||
global:false,
|
||||
success: function(data)
|
||||
{
|
||||
tmp.find('.albumtag').eq(0).html(data)
|
||||
now_this.parents('.gallery_info').nextAll('.albumtag').slideToggle(300);
|
||||
},
|
||||
error : function(data){
|
||||
alert('init process failed, please try again later.')
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$(this).parents('.gallery_info').nextAll('.albumtag').slideToggle(300);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
@ -246,7 +266,6 @@ $(function() {
|
|||
if(obj.description[$(this).attr("for")])
|
||||
$(this).val(obj.description[$(this).attr("for")]);
|
||||
})
|
||||
|
||||
}
|
||||
instance.find("input[type=hidden]").val(image_id);
|
||||
instance.find("form").bind("ajax:success",function(evt, data, status){
|
||||
|
@ -270,7 +289,6 @@ $(function() {
|
|||
checkboxes.each(function(){
|
||||
tag_ids.push($(this).val());
|
||||
})
|
||||
|
||||
$.post("/admin/galleries/image_tagging",{"image_ids":image_ids,"tag_ids":tag_ids},function(json){
|
||||
$.pageslide.close();
|
||||
photosData = json;
|
||||
|
@ -310,9 +328,6 @@ $(function() {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#imgholder").on(clickEvent, '.photo_cover', function(event) {
|
||||
var image_id = $(this).closest(".rgalbum").data("image-id"),
|
||||
album_id = $("#imgholder").data("gallery-id"),
|
||||
|
|
|
@ -46,6 +46,17 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
'back_end'
|
||||
end
|
||||
end
|
||||
def get_tag
|
||||
album = Album.find(params['ele_id']) rescue nil
|
||||
if !album.nil?
|
||||
text = album.tags.collect do |tag|
|
||||
"<li class=\"label\"> #{tag.name}</li>"
|
||||
end.join
|
||||
render :text => text
|
||||
else
|
||||
render :text => ''
|
||||
end
|
||||
end
|
||||
def rotate_images
|
||||
begin
|
||||
image_ids = params['image_ids'].split(',')
|
||||
|
@ -268,6 +279,12 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
albums2 = search_data(albums2,[:name])
|
||||
@fiter_albums = albums1.concat(albums2)
|
||||
end
|
||||
def update_album_setting
|
||||
AlbumSetting.first.update_attributes(limit: params['album_setting_limit'])
|
||||
redirect_to '/admin/galleries'
|
||||
end
|
||||
def setting
|
||||
end
|
||||
def index
|
||||
album_length = Album.all.count
|
||||
album_sort = Album.all.asc(:created_at)
|
||||
|
@ -279,13 +296,22 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
@url = request.original_fullpath
|
||||
if AlbumSetting.first.nil?
|
||||
AlbumSetting.create()
|
||||
elsif AlbumSetting.count > 1
|
||||
AlbumSetting.all.to_a[1..-1].each do |album_setting|
|
||||
album_setting.destroy
|
||||
end
|
||||
end
|
||||
@limit_count = AlbumSetting.first.limit.to_i
|
||||
@limit_count = album_length if @limit_count == 0
|
||||
if params['page_no'].nil?
|
||||
@show_script = true
|
||||
@albums = filter_album.take 50
|
||||
@albums = filter_album.take @limit_count
|
||||
else
|
||||
@show_script = false
|
||||
start = (params['page_no'].to_i - 1)*50
|
||||
@albums = filter_album[start...start+50]
|
||||
start = (params['page_no'].to_i - 1)*@limit_count
|
||||
@albums = filter_album[start...start+@limit_count]
|
||||
end
|
||||
if AlbumColor.count!=0
|
||||
if AlbumColor.all.desc('updated_at').first[:color] == 'transparent'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AlbumSetting
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
field :limit
|
||||
end
|
|
@ -19,9 +19,11 @@
|
|||
<li class="albumcateg"><%= (Category.find(album.category_id).title rescue album.category_id) %></li>
|
||||
</ul>
|
||||
<ul class="albumtag">
|
||||
<% album.tags.each do |tag| %>
|
||||
<% r = @tags.select { |k| k.id.to_s == tag.id.to_s } %>
|
||||
<li class="label"><%= r.map {|t| t.name}[0]%></li>
|
||||
<%end%>
|
||||
<!--
|
||||
<%# album.tags.each do |tag| %>
|
||||
<%# r = @tags.select { |k| k.id.to_s == tag.id.to_s } %>
|
||||
<li class="label"><%# r.map {|t| t.name}[0]%></li>
|
||||
<%# end%>
|
||||
-->
|
||||
</ul>
|
||||
</li>
|
|
@ -9,7 +9,7 @@
|
|||
<script type="text/javascript">
|
||||
var page_no = 2
|
||||
var catch_flag = true
|
||||
var max_page = <%= (@fiter_albums.length/50).ceil %>
|
||||
var max_page = <%= (@fiter_albums.length/@limit_count).ceil %>
|
||||
$('.bottomnav').ready(function(){
|
||||
function load_html_func(){
|
||||
$('#load_html').text("<%= t('gallery.wait_time') %>")
|
||||
|
@ -46,6 +46,18 @@
|
|||
<%= render_filter @filter_fields, "orbit_gallery" %>
|
||||
<div class="order-edit-notification">Albums re-ordering enabled.</div>
|
||||
<%= render 'recreate_thumb' %>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('form.update_album_setting_form').submit(function(){
|
||||
window.setTimeout(function(){alert('success')},500)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<%= form_tag '/admin/galleries/update_album_setting',remote: true,:class=>'update_album_setting_form' do %>
|
||||
<%= t('gallery.album_limit_for_one_page') %>:
|
||||
<%= text_field_tag :album_setting_limit, AlbumSetting.first.limit,:placeholder => t('gallery.blank_for_nil') %>
|
||||
<input type="submit" value="<%= t('submit') %>">
|
||||
<% end %>
|
||||
<div class="rgbody" style='float: left;'>
|
||||
<ul id="orbit_gallery" class="gallery clearfix" data-gallery-id="gallery"
|
||||
style='display: inline-flex;flex-wrap: wrap;'>
|
||||
|
@ -57,7 +69,7 @@
|
|||
<% 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 %>
|
||||
<% if @fiter_albums.length > @limit_count %>
|
||||
<button class="btn btn-small btn-info" id="load_html"><%= t('gallery.load_html') %></button>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('form.update_album_setting_form').submit(function(){
|
||||
window.setTimeout(function(){alert('success')},500)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<%= form_tag '/admin/galleries/update_album_setting',remote: true,:class=>'update_album_setting_form' do %>
|
||||
<%= t('gallery.album_limit_for_one_page') %>:
|
||||
<%= text_field_tag :album_setting_limit, AlbumSetting.first.limit,:placeholder => t('gallery.blank_for_nil') %>
|
||||
<input type="submit" value="<%= t('submit') %>">
|
||||
<% end %>
|
|
@ -1,6 +1,8 @@
|
|||
en:
|
||||
|
||||
gallery:
|
||||
album_limit_for_one_page: Amount of limit for album in one page
|
||||
blank_for_nil: blank present no limit
|
||||
load_html: Load next 50 data
|
||||
wait_time: please wait a minute
|
||||
show_desc: Show the album description
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
zh_tw:
|
||||
|
||||
gallery:
|
||||
album_limit_for_one_page: 一頁呈現的相簿數量
|
||||
blank_for_nil: 留白表示無限制
|
||||
load_html: 存取下50筆
|
||||
wait_time: 請稍等
|
||||
show_desc: 顯示相簿描述
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
get "/xhr/galleries/theater/:id" => "galleries#theater"
|
||||
namespace :admin do
|
||||
|
@ -24,6 +22,9 @@ Rails.application.routes.draw do
|
|||
get "galleries/upload_process" => "galleries#upload_process"
|
||||
post "galleries/start_upload_process" => "galleries#start_upload_process"
|
||||
post "galleries/init_upload" => "galleries#init_upload"
|
||||
post "galleries/get_tag" => "galleries#get_tag"
|
||||
post "galleries/update_album_setting" => "galleries#update_album_setting"
|
||||
get "galleries/setting" => "galleries#setting"
|
||||
resources :galleries do
|
||||
get "imgs" => "galleries#imgs"
|
||||
member do
|
||||
|
@ -34,10 +35,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
resources :images
|
||||
post "galleries/upload_image" => "galleries#upload_image"
|
||||
|
||||
|
||||
# match "image_tagging" => "album_images#image_tagging"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -46,6 +46,11 @@ module Gallery
|
|||
:active_for_action=>{'admin/galleries'=>'tags'},
|
||||
:active_for_tag => 'Gallery',
|
||||
:available_for => 'managers'
|
||||
context_link 'setting',
|
||||
:link_path=>"admin_galleries_setting_path" ,
|
||||
:priority=>5,
|
||||
:active_for_action=>{'admin/galleries'=>'setting'},
|
||||
:available_for => 'managers'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue