let user can set the amount of album limit for one page

This commit is contained in:
chiu 2020-03-17 17:25:08 +08:00
parent 3e0a8cff4d
commit 0dba57c48e
10 changed files with 604 additions and 525 deletions

View File

@ -1,495 +1,510 @@
function rotate(){
$("#crop_div").dialog("open");
$("#crop_div").dialog("open");
}
function change_degree(degree_change){
var degree_org = parseInt($('#show_degree').text())
degree_org+=degree_change
if (degree_org==360 || degree_org==-360){
degree_org = 0
}
$('#show_degree').text(degree_org)
var degree_org = parseInt($('#show_degree').text())
degree_org+=degree_change
if (degree_org==360 || degree_org==-360){
degree_org = 0
}
$('#show_degree').text(degree_org)
}
function init_upload(temp_length){
var value = $("input[name='all_upload_length']")
if (value.val()==''){
value.val(temp_length)
$.ajax({
type : "post",
url : "/admin/galleries/init_upload",
dataType : "json",
data:{all_length: value.val()},
async: false,
global:false,
success: function()
{
},
error : function(data){
alert('init upload process failed, please try again later.')
}
});
if (value.val()=='1'){
value.val('')
}
}
var value = $("input[name='all_upload_length']")
if (value.val()==''){
value.val(temp_length)
$.ajax({
type : "post",
url : "/admin/galleries/init_upload",
dataType : "json",
data:{all_length: value.val()},
async: false,
global:false,
success: function()
{
},
error : function(data){
alert('init upload process failed, please try again later.')
}
});
if (value.val()=='1'){
value.val('')
}
}
}
function form_submit() {
var temp_length = $('#file-list').find('li.template-upload').length
init_upload(temp_length)
var length_upload
var count_upload
var send_start
if (temp_length>1){
$( 'form#fileupload' ).ajaxSuccess(function() {
if (typeof length_upload == "undefined"){
count_upload = 1
length_upload = $('#file-list').find('li.template-upload').length
}
else{
count_upload ++
}
if (count_upload === length_upload){
send_start = undefined
$.ajax({
url : "/admin/galleries/start_upload_process",
dataType : "json",
type : "post",
error: function(){
alert('init upload process failed, please try again later.')
},
success: function(){
window.location.href = '/admin/galleries/upload_process'
}
})
$.ajax({
url : "/admin/galleries/start_upload_process",
dataType : "json",
type : "post",
error: function(){
alert('init upload process failed, please try again later.')
},
success: function(){
window.location.href = '/admin/galleries/upload_process'
}
})
}
});
}
var temp_length = $('#file-list').find('li.template-upload').length
init_upload(temp_length)
var length_upload
var count_upload
var send_start
if (temp_length>1){
$( 'form#fileupload' ).ajaxSuccess(function() {
if (typeof length_upload == "undefined"){
count_upload = 1
length_upload = $('#file-list').find('li.template-upload').length
}
else{
count_upload ++
}
if (count_upload === length_upload){
send_start = undefined
$.ajax({
url : "/admin/galleries/start_upload_process",
dataType : "json",
type : "post",
error: function(){
alert('init upload process failed, please try again later.')
},
success: function(){
window.location.href = '/admin/galleries/upload_process'
}
})
$.ajax({
url : "/admin/galleries/start_upload_process",
dataType : "json",
type : "post",
error: function(){
alert('init upload process failed, please try again later.')
},
success: function(){
window.location.href = '/admin/galleries/upload_process'
}
})
}
});
}
}
function form_only_one_submit() {
var temp_length = 1
init_upload(temp_length)
init_upload(temp_length)
}
!function ($) {
$.fn.checkListLength = function (param){
_defaultSettings = {
onlyOne: null,
};
_set = $.extend(_defaultSettings, param);
$this = this;
$li = this.children('li');
$dropzone = $('#dropzone');
if(($li.length - _set.onlyOne) === 0) {
$('#dropzone').fadeIn(300);
} else {
$('#dropzone').fadeOut(300);
}
$('#file-list').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
};
$.fn.checkListLength = function (param){
_defaultSettings = {
onlyOne: null,
};
_set = $.extend(_defaultSettings, param);
$this = this;
$li = this.children('li');
$dropzone = $('#dropzone');
if(($li.length - _set.onlyOne) === 0) {
$('#dropzone').fadeIn(300);
} else {
$('#dropzone').fadeOut(300);
}
$('#file-list').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
};
}(window.jQuery);
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
if($('#fileupload').length){
$('#fileupload').fileupload({
//maxFileSize: 5000000,=
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
dropZone: $('#dropzone'),
headers:{
'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content")
}
});
}
'use strict';
// Initialize the jQuery File Upload widget:
if($('#fileupload').length){
$('#fileupload').fileupload({
//maxFileSize: 5000000,=
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
dropZone: $('#dropzone'),
headers:{
'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content")
}
});
}
});
Array.prototype.uniq = function(){
var attr = this
attr = $.grep(attr, function(v, k){
return $.inArray(v ,attr) === k;
});
return attr;
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 =[];
if (check_li.length>0){
check_li.each(function(){
image_ids.push($(this).data('image-id'));
});
if (navigator.onLine) {
window.location.href = '/admin/galleries/batch_crop?image_ids=' + image_ids.join(',')
} else {
alert('Please connect the network and try again later!')
}
}else{
alert('Please select at least one')
var check_li = $('#imgholder').find("input[type='checkbox']:checked").parents('li');
var image_ids =[];
if (check_li.length>0){
check_li.each(function(){
image_ids.push($(this).data('image-id'));
});
if (navigator.onLine) {
window.location.href = '/admin/galleries/batch_crop?image_ids=' + image_ids.join(',')
} else {
alert('Please connect the network and try again later!')
}
}else{
alert('Please select at least one')
}
}
function select_all() {
$('#imgholder').find("input[type='checkbox']:not(:checked)").trigger('click')
$('#imgholder').find("input[type='checkbox']:not(:checked)").trigger('click')
}
function translate(ele,pretext,text,return_flag){
var return_value
if (navigator.onLine) {
$.ajax({
url : "/admin/galleries/translate",
dataType : "json",
type : "post",
async: false,
data:{text:text},
success:function(data){
if (return_flag){
return_value = data.translate
}
else{
ele.html(pretext + data.translate)
}
},
error:function(){
var back = text.split('.')[1].split('_')
var result = []
for (i=0;i<back.length;i++){
result.push(back[i].charAt(0).toUpperCase() + back[i].slice(1))
}
if (return_flag){
return_value = result.join(' ')
}
else{
ele.html(pretext + result.join(' '))
}
alert('Your server has some problem, please try again later!')
}
})
} else {
var return_value
if (navigator.onLine) {
$.ajax({
url : "/admin/galleries/translate",
dataType : "json",
type : "post",
async: false,
data:{text:text},
success:function(data){
if (return_flag){
return_value = data.translate
}
else{
ele.html(pretext + data.translate)
}
},
error:function(){
var back = text.split('.')[1].split('_')
var result = []
for (i=0;i<back.length;i++){
result.push(back[i].charAt(0).toUpperCase() + back[i].slice(1))
}
if (return_flag){
return_value = result.join(' ')
}
else{
ele.html(pretext + result.join(' '))
}
alert('Please connect the network and try again later!')
return_value = result.join(' ')
}
else{
ele.html(pretext + result.join(' '))
}
alert('Your server has some problem, please try again later!')
}
})
} else {
var back = text.split('.')[1].split('_')
var result = []
for (i=0;i<back.length;i++){
result.push(back[i].charAt(0).toUpperCase() + back[i].slice(1))
}
if (return_flag){
return return_value
return_value = result.join(' ')
}
else{
ele.html(pretext + result.join(' '))
}
alert('Please connect the network and try again later!')
}
if (return_flag){
return return_value
}
}
$(function() {
var $container = $('.gallery'),
$containerData = $container.data();
$container.data("order-edit","0");
$container.sortable({
disabled: true
});
$container.imagesLoaded(function(){
var $albumname = $('.albumname'),
$img = $('.rgalbum img');
$('.rgalbum > a').rsImg();
if($containerData.galleryId == 'gallery') {
// $container.masonry({
// itemSelector : '.rgalbum',
// isAnimated: true,
// });
$albumname.each(function(i) {
var $albumblock = $(this).closest('a').height(),
$H = $(this).outerHeight(true);
if($H > $albumblock) {
$(this).css({
'bottom': "auto",
'top': 0,
});
$(this).hover(function() {
$(this).stop(true, true).delay(500).animate({
'top': '-='+($H-$albumblock),
},($H-$albumblock)*10)
},function() {
$(this).stop(true, true);
$(this).css({
'bottom': "auto",
'top': 0,
});
});
};
});
$('#orbit_gallery').delegate('.icons-tag', clickEvent, function(){
$(this).parents('.gallery_info').nextAll('.albumtag').slideToggle(300);
});
};
});
var $container = $('.gallery'),
$containerData = $container.data();
$container.data("order-edit","0");
$container.sortable({
disabled: true
});
$container.imagesLoaded(function(){
var $albumname = $('.albumname'),
$img = $('.rgalbum img');
$('.rgalbum > a').rsImg();
if($containerData.galleryId == 'gallery') {
// $container.masonry({
// itemSelector : '.rgalbum',
// isAnimated: true,
// });
$albumname.each(function(i) {
var $albumblock = $(this).closest('a').height(),
$H = $(this).outerHeight(true);
if($H > $albumblock) {
$(this).css({
'bottom': "auto",
'top': 0,
});
$(this).hover(function() {
$(this).stop(true, true).delay(500).animate({
'top': '-='+($H-$albumblock),
},($H-$albumblock)*10)
},function() {
$(this).stop(true, true);
$(this).css({
'bottom': "auto",
'top': 0,
});
});
};
});
$('#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);
}
});
};
});
var bindEvent = function(instance,elem){
var $e = elem,
image_id = $e.closest(".rgalbum").data("image-id");
obj = photosData.galleries.filter(function(a) {
return a.id == image_id;
})[0];
switch($e.attr("for")){
case "description":
if(obj.description){
instance.find("textarea").each(function(){
if(obj.description[$(this).attr("for")])
$(this).val(obj.description[$(this).attr("for")]);
})
var bindEvent = function(instance,elem){
var $e = elem,
image_id = $e.closest(".rgalbum").data("image-id");
obj = photosData.galleries.filter(function(a) {
return a.id == image_id;
})[0];
switch($e.attr("for")){
case "description":
if(obj.description){
instance.find("textarea").each(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){
$.pageslide.close();
photosData = data;
})
break;
case "tags":
instance.find('.tags-groups').cardCheck({
item: '.card'
});
for(i = 0; i < obj.tags.length; i++){
instance.find("input[value="+obj.tags[i]+"]").parent().addClass('active');
instance.find("input[value="+obj.tags[i]+"]").prop("checked","checked");
}
instance.find("form").submit(function(event) {
var checkboxes = $(this).find("input[type=checkbox]:checked"),
tag_ids = [],
image_ids =[image_id];
}
instance.find("input[type=hidden]").val(image_id);
instance.find("form").bind("ajax:success",function(evt, data, status){
$.pageslide.close();
photosData = data;
})
break;
case "tags":
instance.find('.tags-groups').cardCheck({
item: '.card'
});
for(i = 0; i < obj.tags.length; i++){
instance.find("input[value="+obj.tags[i]+"]").parent().addClass('active');
instance.find("input[value="+obj.tags[i]+"]").prop("checked","checked");
}
instance.find("form").submit(function(event) {
var checkboxes = $(this).find("input[type=checkbox]:checked"),
tag_ids = [],
image_ids =[image_id];
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;
})
return false;
});
break;
case "batch":
instance.find('.tags-groups').cardCheck({
item: '.card'
});
instance.find("form").submit(function(event) {
var checkboxes = $(this).find("input[type=checkbox]:checked"),
tag_ids = [],
image_ids =[],
images = $("#imgholder .rgalbum.active");
checkboxes.each(function(){
tag_ids.push($(this).val());
})
images.each(function(){
image_ids.push($(this).data("image-id"));
})
$.post("/admin/galleries/image_tagging",{"image_ids":image_ids,"tag_ids":tag_ids},function(json){
$.pageslide.close();
photosData = json;
})
return false;
});
break;
}
}
checkboxes.each(function(){
tag_ids.push($(this).val());
})
if($("#imgholder").length){
$('.open').pageslide({
loadComplete: function(instance,elem) {
bindEvent(instance,elem);
}
})
}
$("#imgholder").on(clickEvent, '.photo_cover', function(event) {
var image_id = $(this).closest(".rgalbum").data("image-id"),
album_id = $("#imgholder").data("gallery-id"),
set_cover = true;
if($(this).children().hasClass("icons-star-2")){
$(".icons-star").removeClass("icons-star").addClass('icons-star-2');
$(this).children().removeClass("icons-star-2").addClass("icons-star");
}else{
$(this).children().removeClass("icons-star").addClass("icons-star-2");
set_cover = false;
}
$.post("/admin/galleries/set_cover",{"album_id":album_id,"image_id":image_id,"set_cover":set_cover});
$.post("/admin/galleries/image_tagging",{"image_ids":image_ids,"tag_ids":tag_ids},function(json){
$.pageslide.close();
photosData = json;
})
return false;
});
break;
case "batch":
instance.find('.tags-groups').cardCheck({
item: '.card'
});
instance.find("form").submit(function(event) {
var checkboxes = $(this).find("input[type=checkbox]:checked"),
tag_ids = [],
image_ids =[],
images = $("#imgholder .rgalbum.active");
checkboxes.each(function(){
tag_ids.push($(this).val());
})
images.each(function(){
image_ids.push($(this).data("image-id"));
})
$.post("/admin/galleries/image_tagging",{"image_ids":image_ids,"tag_ids":tag_ids},function(json){
$.pageslide.close();
photosData = json;
})
return false;
});
break;
}
}
});
if($("#imgholder").length){
$('.open').pageslide({
loadComplete: function(instance,elem) {
bindEvent(instance,elem);
}
})
}
$("#delete_selected_photos_btn").click(function(){
var photos_to_delete = [],
delete_cover = false,
$photos = $(".rgalbum.active"),
album_id = $("#imgholder").data("gallery-id");
$('.modal-body .spinning').fadeIn('fast');
$('.modal-body .text-warning').hide(0);
$photos.each(function(){
photos_to_delete.push($(this).data('image-id'));
if ($(this).find(".icons-star").length) {
delete_cover = true;
};
});
$.ajax({
url : "/admin/galleries/delete_photos",
type : "POST",
data : {"images":photos_to_delete,"delete_cover":delete_cover,"album_id":album_id},
success : function(){
$photos.slideUp(300,function() {
$(this).remove();
});
$('#dialog').modal('hide');
$('.modal-body .spinning').hide();
$('.modal-body .text-warning').show();
$('.deletephoto, .deselect, .addtags').addClass('hide')
}
});
})
$("#imgholder").on(clickEvent, '.photo_cover', function(event) {
var image_id = $(this).closest(".rgalbum").data("image-id"),
album_id = $("#imgholder").data("gallery-id"),
set_cover = true;
if($(this).children().hasClass("icons-star-2")){
$(".icons-star").removeClass("icons-star").addClass('icons-star-2');
$(this).children().removeClass("icons-star-2").addClass("icons-star");
}else{
$(this).children().removeClass("icons-star").addClass("icons-star-2");
set_cover = false;
}
$.post("/admin/galleries/set_cover",{"album_id":album_id,"image_id":image_id,"set_cover":set_cover});
});
$("#delete_selected_photos_btn").click(function(){
var photos_to_delete = [],
delete_cover = false,
$photos = $(".rgalbum.active"),
album_id = $("#imgholder").data("gallery-id");
$('.modal-body .spinning').fadeIn('fast');
$('.modal-body .text-warning').hide(0);
$photos.each(function(){
photos_to_delete.push($(this).data('image-id'));
if ($(this).find(".icons-star").length) {
delete_cover = true;
};
});
$.ajax({
url : "/admin/galleries/delete_photos",
type : "POST",
data : {"images":photos_to_delete,"delete_cover":delete_cover,"album_id":album_id},
success : function(){
$photos.slideUp(300,function() {
$(this).remove();
});
$('#dialog').modal('hide');
$('.modal-body .spinning').hide();
$('.modal-body .text-warning').show();
$('.deletephoto, .deselect, .addtags').addClass('hide')
}
});
})
$('#imgholder').on(clickEvent, '.checkbox', function() {
$(this).prop('checked') ? $(this).closest('.rgalbum').addClass('active') : $(this).closest('.rgalbum').removeClass('active');
var checkLength = $("#imgholder .rgalbum.active");
checkLength.length ? $('.deletephoto, .deselect, .addtags, .crop').removeClass('hide') : $('.deletephoto, .deselect, .addtags, .crop').addClass('hide');
});
$('.deselect').on(clickEvent, function(event) {
$('.rgalbum').removeClass('active');
$('.checkbox').prop('checked', false)
$('.deletephoto, .deselect, .addtags').addClass('hide')
event.preventDefault();
});
$('.phtot-action').delegate('li', clickEvent, function(event) {
$('.checkbox').prop('checked', false)
$('.rgalbum').removeClass('active');
$('.deletephoto, .deselect, .addtags').removeClass('hide')
});
var images_order = [];
$("#edit-order-btn").on("click",function(){
var el = $(this);
if($container.data("order-edit") == "0"){
$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",
data : {"imageids" : temp, "type" : type},
type : "post",
dataType : "json"
})
}
$(".order-edit-notification").slideUp();
$container.sortable("disable");
$container.data("order-edit","0");
translate(el,'','gallery.edit_order',false)
}
return false;
})
$('#imgholder').on(clickEvent, '.checkbox', function() {
$(this).prop('checked') ? $(this).closest('.rgalbum').addClass('active') : $(this).closest('.rgalbum').removeClass('active');
var checkLength = $("#imgholder .rgalbum.active");
checkLength.length ? $('.deletephoto, .deselect, .addtags, .crop').removeClass('hide') : $('.deletephoto, .deselect, .addtags, .crop').addClass('hide');
});
$('.deselect').on(clickEvent, function(event) {
$('.rgalbum').removeClass('active');
$('.checkbox').prop('checked', false)
$('.deletephoto, .deselect, .addtags').addClass('hide')
event.preventDefault();
});
$('.phtot-action').delegate('li', clickEvent, function(event) {
$('.checkbox').prop('checked', false)
$('.rgalbum').removeClass('active');
$('.deletephoto, .deselect, .addtags').removeClass('hide')
});
var images_order = [];
$("#edit-order-btn").on("click",function(){
var el = $(this);
if($container.data("order-edit") == "0"){
$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",
data : {"imageids" : temp, "type" : type},
type : "post",
dataType : "json"
})
}
$(".order-edit-notification").slideUp();
$container.sortable("disable");
$container.data("order-edit","0");
translate(el,'','gallery.edit_order',false)
}
return false;
})
//
var last_image_id = null;
$('.add-imgs').on({
click: function() {
$('#fileupload').slideToggle(300, function() {
if(!$(this).is(':hidden')) {
translate($('.add-imgs'),'<i class="icons-cross-2"></i> ','gallery.close_panel',false)
$('.rgbody').stop(true, false).animate({'padding-bottom': 280}, 300);
$("#edit-order-btn").hide();
$.ajax({
url : "/admin/galleries/last_image_id",
data : {"albumid" : $("#fileupload_aid").val()},
dataType : "json",
type : "get"
}).done(function(d){
last_image_id = d.last_image_id;
})
} else {
translate($('.add-imgs'),'<i class="icons-plus"></i> ','gallery.add_image',false)
$('.files').empty()
$('#file-list').checkListLength();
$('.rgbody').stop(true, false).animate({'padding-bottom': 0}, 300);
$("#edit-order-btn").show();
fetchNewImages();
};
});
return false;
}
});
var fetchNewImages = function(){
var albumid = $("#fileupload_aid").val();
$('.add-imgs').on({
click: function() {
$('#fileupload').slideToggle(300, function() {
if(!$(this).is(':hidden')) {
translate($('.add-imgs'),'<i class="icons-cross-2"></i> ','gallery.close_panel',false)
$('.rgbody').stop(true, false).animate({'padding-bottom': 280}, 300);
$("#edit-order-btn").hide();
$.ajax({
url : "/admin/galleries/last_image_id",
data : {"albumid" : $("#fileupload_aid").val()},
dataType : "json",
type : "get"
}).done(function(d){
last_image_id = d.last_image_id;
})
} else {
translate($('.add-imgs'),'<i class="icons-plus"></i> ','gallery.add_image',false)
$('.files').empty()
$('#file-list').checkListLength();
$('.rgbody').stop(true, false).animate({'padding-bottom': 0}, 300);
$("#edit-order-btn").show();
fetchNewImages();
};
});
return false;
}
});
var fetchNewImages = function(){
var albumid = $("#fileupload_aid").val();
$.getJSON('/admin/galleries/get_photoData_json?id='+albumid, function(json, textStatus) {
photosData = json;
});
$.getJSON('/admin/galleries/get_photoData_json?id='+albumid, function(json, textStatus) {
photosData = json;
});
$.ajax({
url : "/admin/galleries/new_images",
data : {"last_image_id" : last_image_id, "album_id" : albumid},
success : function(data){
var $e = $(data);
$imgs = $e.find("img");
$("#imgholder").prepend($e);
$os = $e.find("a.open");
$os.pageslide({
loadComplete: function(instance,elem) {
bindEvent(instance,elem);
}
});
}
})
$.ajax({
url : "/admin/galleries/new_images",
data : {"last_image_id" : last_image_id, "album_id" : albumid},
success : function(data){
var $e = $(data);
$imgs = $e.find("img");
$("#imgholder").prepend($e);
$os = $e.find("a.open");
$os.pageslide({
loadComplete: function(instance,elem) {
bindEvent(instance,elem);
}
});
}
})
}
var buttons_option={}
var op_fn1 = function() {
var check_img = $('#imgholder').find("input[type='checkbox']:checked").parents('li').find('img');
check_img.each(function(){
}
var buttons_option={}
var op_fn1 = function() {
var check_img = $('#imgholder').find("input[type='checkbox']:checked").parents('li').find('img');
check_img.each(function(){
check_img.css('transform','rotate('+$('#show_degree').text()+'deg)');
});
}
var op_fn2 = function() {
var confirm_msg = translate('','','gallery.confirm_msg',true)
if ( confirm (confirm_msg) ){
var check_li = $('#imgholder').find("input[type='checkbox']:checked").parents('li');
var image_ids =[];
check_li.each(function(){
image_ids.push($(this).data('image-id'));
});
if (navigator.onLine) {
window.location.href = '/admin/galleries/rotate_images?image_ids=' + image_ids.join(',') +'&rotate_angle=' + $('#show_degree').text()
} else {
alert('Please connect the network and try again later!')
}
console.log(image_ids)
$(this).dialog("close");
}
}
var op_fn2 = function() {
var confirm_msg = translate('','','gallery.confirm_msg',true)
if ( confirm (confirm_msg) ){
var check_li = $('#imgholder').find("input[type='checkbox']:checked").parents('li');
var image_ids =[];
check_li.each(function(){
image_ids.push($(this).data('image-id'));
});
if (navigator.onLine) {
window.location.href = '/admin/galleries/rotate_images?image_ids=' + image_ids.join(',') +'&rotate_angle=' + $('#show_degree').text()
} else {
alert('Please connect the network and try again later!')
}
console.log(image_ids)
$(this).dialog("close");
}
}
var op_fn3 = function() { $(this).dialog("close"); }
var op1 = translate('','','gallery.review',true)
var op2 = translate('','','gallery.rotate',true)
var op3 = translate('','','gallery.close_panel',true)
buttons_option[op1] = op_fn1
buttons_option[op2] = op_fn2
buttons_option[op3] = op_fn3
$("#crop_div").dialog({
}
var op_fn3 = function() { $(this).dialog("close"); }
var op1 = translate('','','gallery.review',true)
var op2 = translate('','','gallery.rotate',true)
var op3 = translate('','','gallery.close_panel',true)
buttons_option[op1] = op_fn1
buttons_option[op2] = op_fn2
buttons_option[op3] = op_fn3
$("#crop_div").dialog({
autoOpen: false,
show: "blind",
hide: "explode",

View File

@ -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'

View File

@ -0,0 +1,5 @@
class AlbumSetting
include Mongoid::Document
include Mongoid::Timestamps
field :limit
end

View File

@ -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>

View File

@ -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>

View File

@ -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 %>

View File

@ -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

View File

@ -1,6 +1,8 @@
zh_tw:
gallery:
album_limit_for_one_page: 一頁呈現的相簿數量
blank_for_nil: 留白表示無限制
load_html: 存取下50筆
wait_time: 請稍等
show_desc: 顯示相簿描述

View File

@ -1,43 +1,41 @@
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
get "galleries/get_photoData_json" => "galleries#get_photoData_json"
get "galleries/recreate_image" => "galleries#recreate_image"
get "galleries/crop_process" => "images#crop_process"
post "galleries/recreate_image/recreate_progress" => "galleries#recreate_progress"
get "galleries/recreate_image/finish_recreate" => "galleries#finish_recreate"
get "galleries/batch_crop" => "images#batch_crop"
get "galleries/new_images" => "galleries#new_images"
get "galleries/last_image_id" => "galleries#last_image_id"
post "galleries/set_cover" => "galleries#set_cover"
post "galleries/delete_photos" => "images#delete_photos"
post "galleries/update_image" => "images#update_image"
post "galleries/image_tagging" => "images#image_tagging"
post "galleries/order" => "images#changeorder"
post "galleries/translate" => "galleries#call_translate"
post "galleries/save_crop" => "galleries#save_crop"
get "galleries/rotate_images" => "galleries#rotate_images"
get "galleries/upload_process" => "galleries#upload_process"
post "galleries/start_upload_process" => "galleries#start_upload_process"
post "galleries/init_upload" => "galleries#init_upload"
resources :galleries do
get "imgs" => "galleries#imgs"
member do
get "import"
get "excel_format"
post "importimages"
end
get "/xhr/galleries/theater/:id" => "galleries#theater"
namespace :admin do
get "galleries/get_photoData_json" => "galleries#get_photoData_json"
get "galleries/recreate_image" => "galleries#recreate_image"
get "galleries/crop_process" => "images#crop_process"
post "galleries/recreate_image/recreate_progress" => "galleries#recreate_progress"
get "galleries/recreate_image/finish_recreate" => "galleries#finish_recreate"
get "galleries/batch_crop" => "images#batch_crop"
get "galleries/new_images" => "galleries#new_images"
get "galleries/last_image_id" => "galleries#last_image_id"
post "galleries/set_cover" => "galleries#set_cover"
post "galleries/delete_photos" => "images#delete_photos"
post "galleries/update_image" => "images#update_image"
post "galleries/image_tagging" => "images#image_tagging"
post "galleries/order" => "images#changeorder"
post "galleries/translate" => "galleries#call_translate"
post "galleries/save_crop" => "galleries#save_crop"
get "galleries/rotate_images" => "galleries#rotate_images"
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
get "import"
get "excel_format"
post "importimages"
end
resources :images
post "galleries/upload_image" => "galleries#upload_image"
# match "image_tagging" => "album_images#image_tagging"
end
end
end
resources :images
post "galleries/upload_image" => "galleries#upload_image"
# match "image_tagging" => "album_images#image_tagging"
end
end
end

View File

@ -1,9 +1,9 @@
module Gallery
class Engine < ::Rails::Engine
initializer "gallery" do
OrbitApp.registration "Gallery", :type => "ModuleApp" do
module_label "gallery.gallery"
base_url File.expand_path File.dirname(__FILE__)
initializer "gallery" do
OrbitApp.registration "Gallery", :type => "ModuleApp" do
module_label "gallery.gallery"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget"]
# widget_settings []
widget_settings [{"data_count"=>10}]
@ -13,41 +13,46 @@ module Gallery
authorizable
frontend_enabled
data_count 1..30
side_bar do
head_label_i18n 'gallery.gallery', icon_class: "icons-pictures"
available_for "users"
active_for_controllers (['admin/galleries','admin/images'])
head_link_path "admin_galleries_path"
side_bar do
head_label_i18n 'gallery.gallery', icon_class: "icons-pictures"
available_for "users"
active_for_controllers (['admin/galleries','admin/images'])
head_link_path "admin_galleries_path"
context_link 'gallery.all',
:link_path=>"admin_galleries_path" ,
:priority=>1,
:active_for_action=>{'admin/galleries'=>"index"},
:available_for => 'users'
context_link 'gallery.all',
:link_path=>"admin_galleries_path" ,
:priority=>1,
:active_for_action=>{'admin/galleries'=>"index"},
:available_for => 'users'
context_link 'gallery.new',
:link_path=>"new_admin_gallery_path" ,
:priority=>2,
:active_for_action=>{'admin/galleries'=>"new"},
:available_for => 'sub_managers'
context_link 'gallery.new',
:link_path=>"new_admin_gallery_path" ,
:priority=>2,
:active_for_action=>{'admin/galleries'=>"new"},
:available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
:priority=>3,
:active_for_action=>{'admin/galleries'=>'categories'},
:active_for_category => 'Gallery',
:available_for => 'managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
:priority=>3,
:active_for_action=>{'admin/galleries'=>'categories'},
:active_for_category => 'Gallery',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
:priority=>4,
:active_for_action=>{'admin/galleries'=>'tags'},
:active_for_tag => 'Gallery',
:available_for => 'managers'
end
end
end
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
:priority=>4,
: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
end
end