716 lines
25 KiB
JavaScript
716 lines
25 KiB
JavaScript
/**
|
|
* 2012 - 2020 HiPresta
|
|
*
|
|
* MODULE Gallery
|
|
*
|
|
* @author HiPresta <support@hipresta.com>
|
|
* @copyright HiPresta 2020
|
|
* @license Addons PrestaShop license limitation
|
|
* @link https://hipresta.com
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* Don't use this module on several shops. The license provided by PrestaShop Addons
|
|
* for all its modules is valid only once for a single shop.
|
|
*/
|
|
|
|
$.fn.position_sort = function(name) {
|
|
var sortable_item = [];
|
|
var sortable = $(this);
|
|
|
|
sortable.each(function(i) {
|
|
$('li', this).each(function(e) {
|
|
var data_id = $(this).attr('data-id-image');
|
|
sortable_item.push(name+'['+e+'][id_item] ='+data_id);
|
|
});
|
|
});
|
|
return sortable_item.join('&');
|
|
}
|
|
|
|
// initSortableMenuItems('.sortable', 'menu_item', 'sortable_change_position');
|
|
function initSortableItems(){
|
|
$('.sortable').sortable({
|
|
stop: function(event, ui) {
|
|
var position = $('.sortable').position_sort('gallery_item')+"&id_parent="+$(this).attr('data-id-parent')+"&action=sortable_change_position&secure_key="+gallery_secure_key+"&psv="+psv;
|
|
$.post(gallery_admin_controller_dir+"&ajax=1", position);
|
|
}
|
|
}).disableSelection();
|
|
}
|
|
|
|
function HiInitGalleriesSort() {
|
|
if ($('#table-higallery').length) {
|
|
var $galleriesTable = $('#table-higallery');
|
|
} else {
|
|
var $galleriesTable = $('.table.higallery');
|
|
}
|
|
$galleriesTable.find('tbody').sortable({
|
|
handle: '.icon-move',
|
|
stop: function(event, ui) {
|
|
var sorted_items = [];
|
|
$galleriesTable.find('tbody tr').each(function(e) {
|
|
var id_gallery = parseInt($(this).find('td:eq(1)').text());
|
|
sorted_items.push('sortedGalleries['+e+']=' + id_gallery);
|
|
});
|
|
|
|
var params = sorted_items.join('&');
|
|
params += '&ajax=1&secure_key=' + gallery_secure_key + '&action=sortGalleries'
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
async: true,
|
|
data: params,
|
|
success: function(response){
|
|
if (response.error != '') {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function update_helper_list(action){
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir+"&ajax=1",
|
|
data: {
|
|
action : action,
|
|
secure_key : gallery_secure_key,
|
|
psv: psv,
|
|
},
|
|
success: function(response){
|
|
$("#form-higallery").replaceWith(response.content);
|
|
|
|
HiInitGalleriesSort();
|
|
}
|
|
});
|
|
};
|
|
|
|
function show_gallery_form(th, action, action_type, id){
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir,
|
|
data: {
|
|
ajax : true,
|
|
action : action,
|
|
action_type : action_type,
|
|
id : id,
|
|
secure_key : gallery_secure_key,
|
|
psv: psv,
|
|
},
|
|
beforeSend: function(){
|
|
if (th.hasClass("edit")){
|
|
th.find('i').removeClass('icon-pencil').addClass('icon-refresh icon-spin');
|
|
} else {
|
|
th.find('i').removeClass('process-icon-new').addClass('process-icon-refresh icon-spin');
|
|
}
|
|
},
|
|
success: function(response){
|
|
if (th.hasClass("edit")){
|
|
th.find('i').removeClass('icon-refresh icon-spin').addClass('icon-pencil');
|
|
} else {
|
|
th.find('i').removeClass('process-icon-refresh icon-spin').addClass('process-icon-new');
|
|
}
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
$("#modal_form .content").html(response.content);
|
|
$('#modal_form').modal('show');
|
|
if ($('[name=position]').val() != 'gallery_page' && $('[name=position]').val() != 'single_gallery_page') {
|
|
$('.gallery_page_content').hide();
|
|
} else {
|
|
$('.gallery_page_content').show();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
function save_gallery_form(form, action, helper_action){
|
|
$('.tagify').each(function(){
|
|
var input_id = $(this).attr('id');
|
|
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
|
});
|
|
var formdata = new FormData($(form)[0])
|
|
formdata.append("action", action);
|
|
formdata.append("secure_key", gallery_secure_key);
|
|
formdata.append("psv", psv);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir+"&ajax=1",
|
|
data: formdata,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function(){
|
|
form.find('i.process-icon-save').removeClass('process-icon-save').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
form.find('i.process-icon-refresh').removeClass('process-icon-refresh icon-spin').addClass('process-icon-save');
|
|
if (response.error) {
|
|
showErrorMessage(response.errors.error);
|
|
} else {
|
|
showSuccessMessage('Successful Save');
|
|
$('#modal_form').modal('hide');
|
|
update_helper_list(helper_action);
|
|
}
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
function delete_list_item(th, action, id){
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir+"&ajax=1",
|
|
data: {
|
|
action : action,
|
|
id : id,
|
|
secure_key : gallery_secure_key,
|
|
psv: psv,
|
|
},
|
|
success: function(response){
|
|
showSuccessMessage('Successful delete');
|
|
th.closest('tr').remove();
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
HiInitGalleriesSort();
|
|
|
|
$('.fake_desc').closest('form').hide();
|
|
$(document).on('click', '[name=submit_gallery_cancel]', function(){
|
|
$('#modal_form').modal('hide');
|
|
return false;
|
|
});
|
|
$(document).on('change', '[name=position]', function(){
|
|
if ($(this).val() != 'gallery_page' && $(this).val() != 'single_gallery_page') {
|
|
$('.gallery_page_content').hide();
|
|
} else {
|
|
$('.gallery_page_content').show();
|
|
}
|
|
return false;
|
|
});
|
|
$(document).on('click', '#desc-higallery-new', function(e){
|
|
e.preventDefault();
|
|
show_gallery_form($(this), 'show_gallery_add_form', 'add', null);
|
|
});
|
|
|
|
$(document).on('click', '.higallery .edit', function(e){
|
|
e.preventDefault();
|
|
var id = $(this).attr("href").match(/id_gallery=([0-9]+)/)[1];
|
|
show_gallery_form($(this), 'show_gallery_update_form', 'update', id);
|
|
});
|
|
|
|
$(document).on('submit', '#modal_form form.gallery_form', function(e){
|
|
e.preventDefault();
|
|
save_gallery_form($(this), 'save_gallery', 'update_helper_list');
|
|
});
|
|
|
|
$(document).on('click', '.higallery .delete', function(e){
|
|
e.preventDefault();
|
|
var id = $(this).attr("href").match(/id_gallery=([0-9]+)/)[1];
|
|
delete_list_item($(this), 'delete_gallery_list_item', id)
|
|
});
|
|
|
|
|
|
$(document).on('click', '.higallery .status', function(e){
|
|
e.preventDefault();
|
|
var th = $(this);
|
|
$.ajax({
|
|
type: "POST",
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : "update_status",
|
|
id : $(this).attr('data-id'),
|
|
status : $(this).attr('data-status'),
|
|
secure_key : gallery_secure_key,
|
|
},
|
|
beforeSend: function(){
|
|
if (th.hasClass('btn-success')){
|
|
th.find('i').removeClass('icon-check').addClass('icon-refresh icon-spin');
|
|
} else {
|
|
th.find('i').removeClass('icon-remove').addClass('icon-refresh icon-spin');
|
|
}
|
|
},
|
|
success: function(response){
|
|
if (th.hasClass('btn-success')){
|
|
th.find('i').removeClass('icon-refresh icon-spin').addClass('icon-check');
|
|
} else {
|
|
th.find('i').removeClass('icon-refresh icon-spin').addClass('icon-remove');
|
|
}
|
|
$("#form-higallery").replaceWith(response.content);
|
|
|
|
HiInitGalleriesSort();
|
|
}
|
|
});
|
|
})
|
|
|
|
/*Show Gallery image add form*/
|
|
$(document).on('click', '.higallery .gallery_manage_image', function(e){
|
|
e.preventDefault();
|
|
var th = $(this);
|
|
$.ajax({
|
|
type: "POST",
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : "gallery_manage_image",
|
|
id_gallery : $(this).attr('data-id-gallery'),
|
|
secure_key : gallery_secure_key,
|
|
},
|
|
beforeSend: function(){
|
|
th.find('i').removeClass('icon-image').addClass('icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
th.find('i').removeClass('icon-refresh icon-spin').addClass('icon-image');
|
|
$('#form-higallery').replaceWith(response.content);
|
|
// $("#modal_form .content").html(response.content);
|
|
initSortableItems();
|
|
// $('#modal_form').modal('show');
|
|
}
|
|
});
|
|
});
|
|
|
|
$(document).on('click', '.back-to-upload-image', function(e){
|
|
var $this = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax: true,
|
|
action: 'gallery_manage_image',
|
|
id_gallery: $('.gallery-image-container').attr('data-id-gallery'),
|
|
secure_key : gallery_secure_key
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i').removeClass('process-icon-back').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response) {
|
|
$('.gallery-image-container').remove();
|
|
$('.gallery-social-accounts-container').replaceWith(response.content);
|
|
initSortableItems();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(document).on('click', '[name="submit_gallery_cancel"]', function(e) {
|
|
e.preventDefault();
|
|
|
|
var $this = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data: {
|
|
ajax: true,
|
|
action : 'update_helper_list',
|
|
secure_key : gallery_secure_key,
|
|
psv: psv
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i').removeClass('process-icon-cancel').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
$this.find('i').removeClass('process-icon-refresh icon-spin').addClass('process-icon-cancel');
|
|
|
|
$('.gallery-image-container').remove();
|
|
$('.gallery_image_form').replaceWith(response.content);
|
|
|
|
HiInitGalleriesSort();
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
}
|
|
});
|
|
});
|
|
|
|
/*Save gallery image*/
|
|
$(document).on('submit', 'form.gallery_image_form', function(e){
|
|
e.preventDefault();
|
|
var form = $(this);
|
|
var formdata = new FormData($(form)[0])
|
|
formdata.append("action", 'add_gallery_image');
|
|
formdata.append("secure_key", gallery_secure_key);
|
|
formdata.append("psv", psv);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir+"&ajax=1",
|
|
data: formdata,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function(){
|
|
form.find('i.process-icon-save').removeClass('process-icon-save').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
form.find('i.process-icon-refresh').removeClass('process-icon-refresh icon-spin').addClass('process-icon-save');
|
|
if (response.error) {
|
|
showErrorMessage(error);
|
|
} else {
|
|
showSuccessMessage('Successful Save');
|
|
$('.gallery_image_form').remove();
|
|
$('.gallery-image-container').replaceWith(response.content);
|
|
initSortableItems();
|
|
}
|
|
}
|
|
});
|
|
return false;
|
|
});
|
|
/*Show gallery image update form*/
|
|
$(document).on('click', '.edit-gallery-image', function(e){
|
|
e.preventDefault();
|
|
var th = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : "show_update_gallery_image",
|
|
id_image : $(this).closest('li').attr('data-id-image'),
|
|
id_gallery : $(this).closest('ul').attr('data-id-parent'),
|
|
secure_key : gallery_secure_key,
|
|
},
|
|
beforeSend: function(){
|
|
th.find('i.icon-edit').removeClass('icon-edit').addClass('icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
th.find('i.icon-refresh').removeClass('icon-refresh icon-spin').addClass('icon-edit');
|
|
$(".gallery_image_form").replaceWith(response.content);
|
|
initSortableItems();
|
|
}
|
|
});
|
|
return false;
|
|
});
|
|
/*Delete gallery image */
|
|
$(document).on('click', '.delete-gallery-image', function(e){
|
|
e.preventDefault();
|
|
var th = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: "JSON",
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : "delete_gallery_image",
|
|
id_image : $(this).closest('li').attr('data-id-image'),
|
|
id_gallery : $(this).closest('ul').attr('data-id-parent'),
|
|
secure_key : gallery_secure_key,
|
|
},
|
|
beforeSend: function(){
|
|
th.find('i.icon-trash').removeClass('icon-trash').addClass('icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage('Deleted with success');
|
|
$('.gallery-image-container').replaceWith(response.content);
|
|
initSortableItems();
|
|
}
|
|
}
|
|
});
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '#desc-higallerysocialnetwork-new', function() {
|
|
var $this = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : "displaySocialAccountForm",
|
|
secure_key : gallery_secure_key
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i.process-icon-new').removeClass('process-icon-new').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response) {
|
|
$this.find('i.process-icon-refresh').removeClass('process-icon-refresh icon-spin').addClass('process-icon-new');
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
$('#modal_form .content').html(response.content);
|
|
$('#modal_form').modal('show');
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '[name="submit_cancel_social_account"]', function(){
|
|
$('#modal_form').modal('hide');
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', 'button[name="submit_social_network_form"]', function(e){
|
|
e.preventDefault();
|
|
var $this = $(this);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action: 'displaySelectedSocialForm',
|
|
social_network: $('#social_network').val(),
|
|
secure_key: gallery_secure_key
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i').removeClass('process-icon-save').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
$this.find('i').removeClass('process-icon-refresh icon-spin').addClass('process-icon-save');
|
|
$('#modal_form .content').html(response.content);
|
|
}
|
|
});
|
|
});
|
|
|
|
$(document).on('click', 'button[name="submit_instagram_save"]', function(e){
|
|
e.preventDefault();
|
|
var $this = $(this);
|
|
var form = $this.closest('form');
|
|
var formdata = new FormData($(form)[0])
|
|
formdata.append('action', 'saveSocialAccount');
|
|
formdata.append('secure_key', gallery_secure_key);
|
|
formdata.append('ajax', true);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
url: gallery_admin_controller_dir,
|
|
data: formdata,
|
|
contentType: false,
|
|
processData: false,
|
|
beforeSend: function(){
|
|
$this.find('i').removeClass('process-icon-save').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response){
|
|
$this.find('i').removeClass('process-icon-refresh icon-spin').addClass('process-icon-save');
|
|
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
$('#modal_form').modal('hide');
|
|
$('#form-higallerysocialnetwork').replaceWith(response.content);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$(document).on('click', '.higallerysocialnetwork .edit', function(e) {
|
|
var $this = $(this);
|
|
var id_social_account = $(this).attr('href').match(/id_higallerysocialnetwork=([0-9]+)/)[1];
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : 'displaySocialAccountEditForm',
|
|
id_social_account: id_social_account,
|
|
secure_key : gallery_secure_key
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i.icon-pencil').removeClass('icon-pencil').addClass('icon-refresh icon-spin');
|
|
},
|
|
success: function(response) {
|
|
$this.find('i.icon-refresh').removeClass('icon-refresh icon-spin').addClass('icon-pencil');
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
$('#modal_form .content').html(response.content);
|
|
$('#modal_form').modal('show');
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '.higallerysocialnetwork .delete', function(e){
|
|
var $this = $(this);
|
|
var id_social_account = $(this).attr('href').match(/id_higallerysocialnetwork=([0-9]+)/)[1];
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : 'deleteSocialAccount',
|
|
id_social_account: id_social_account,
|
|
secure_key : gallery_secure_key
|
|
},
|
|
success: function(response) {
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
$('#form-higallerysocialnetwork').replaceWith(response.content);
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '#social_import, .back-to-select-social-accounts', function(e) {
|
|
var $this = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax : true,
|
|
action : 'selectSocialAccount',
|
|
secure_key : gallery_secure_key
|
|
},
|
|
beforeSend: function(){
|
|
// .back-to-select-social-accounts
|
|
$this.find('i.process-icon-back').removeClass('process-icon-back').addClass('process-icon-refresh icon-spin');
|
|
// #social_import
|
|
$this.find('i.icon-instagram').removeClass('icon-instagram').addClass('icon-refresh icon-spin');
|
|
},
|
|
success: function(response) {
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
$('.gallery_image_form, .gallery-social-account-images-container').replaceWith(response.content);
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '.load-social-images', function(e) {
|
|
var id_social_account = $(this).attr('data-social-id');
|
|
var $this = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax: true,
|
|
action: 'loadSocialImages',
|
|
secure_key: gallery_secure_key,
|
|
id_social_account: id_social_account
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i.icon-instagram').removeClass('icon-instagram').addClass('icon-refresh icon-spin');
|
|
},
|
|
success: function(response) {
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
$('.gallery-social-accounts-container').replaceWith(response.content);
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '.social-account-image-item img', function(){
|
|
$(this).parent().find('input[type="checkbox"]').click();
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '.import-social-images', function(e) {
|
|
var $this = $(this);
|
|
var selected_images = new Array();
|
|
$("input:checkbox[name=social_account_image]:checked").each(function() {
|
|
selected_images.push($(this).val());
|
|
});
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax: true,
|
|
action: 'importSocialImages',
|
|
secure_key: gallery_secure_key,
|
|
id_gallery: $('.gallery-image-container').attr('data-id-gallery'),
|
|
images: selected_images
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i.process-icon-import').removeClass('process-icon-import').addClass('process-icon-refresh icon-spin');
|
|
},
|
|
success: function(response) {
|
|
$this.find('i.process-icon-refresh').removeClass('process-icon-refresh').removeClass('icon-spin').addClass('process-icon-import');
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
|
|
$("input:checkbox[name=social_account_image]:checked").parent().remove();
|
|
|
|
$('.gallery-image-container').replaceWith(response.content);
|
|
|
|
initSortableItems();
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$(document).on('click', '.load-more-ig-images', function() {
|
|
var $this = $(this);
|
|
$.ajax({
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
url: gallery_admin_controller_dir,
|
|
data:{
|
|
ajax: true,
|
|
action: 'loadMoreImagesIG',
|
|
secure_key: gallery_secure_key,
|
|
next: $(this).attr('href')
|
|
},
|
|
beforeSend: function(){
|
|
$this.find('i.icon-refresh').addClass('icon-spin');
|
|
},
|
|
success: function(response) {
|
|
$this.find('i.icon-refresh').removeClass('icon-spin');
|
|
|
|
if (response.error) {
|
|
showErrorMessage(response.error);
|
|
} else {
|
|
showSuccessMessage(response.message);
|
|
|
|
if (response.ig_next_page) {
|
|
$('.load-more-ig-images').attr('href', response.ig_next_page);
|
|
} else {
|
|
$('.load-more-ig-images').remove();
|
|
}
|
|
|
|
$('.load-more-images-container').append(response.content);
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
});
|