loader ajax
This commit is contained in:
@@ -4,6 +4,7 @@ function click_link() {
|
||||
|
||||
$link.click(function(e) {
|
||||
e.preventDefault();
|
||||
var $loader = $(this).find('.loader');
|
||||
|
||||
var $this = $(this);
|
||||
$href = $this.attr("href");
|
||||
@@ -15,8 +16,8 @@ function click_link() {
|
||||
if ($this.hasClass('open')) {
|
||||
$this.removeClass('open');
|
||||
$('#item_list.'+ cat).remove();
|
||||
} else {
|
||||
|
||||
} else {
|
||||
$loader.css('display','inline-block');
|
||||
$.ajax({
|
||||
url : '/' + page + '/' + cat, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
@@ -24,13 +25,14 @@ function click_link() {
|
||||
success: function(data) {
|
||||
$(data).find('#item_list').addClass(cat).insertAfter($this);
|
||||
$this.addClass('open');
|
||||
|
||||
},
|
||||
lazy();
|
||||
},
|
||||
complete: function(data) {
|
||||
console.log('cat', cat);
|
||||
lazyload();
|
||||
$loader.hide();
|
||||
click_img(e, $this, $href, url, page, cat, project_name);
|
||||
}
|
||||
closeAjax();
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -62,18 +64,17 @@ function click_list() {
|
||||
url : '/' + page + '/' + cat + '/' + project_name, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
// async: false,
|
||||
success: function(data) {
|
||||
$('#item_list.'+cat+' .card-image.open #item').remove();
|
||||
$('#item_list.'+cat+' .card-image').removeClass('open');
|
||||
$(data).find('#item').addClass(cat).insertAfter($link_card);
|
||||
|
||||
$link_card.parent().addClass('open');
|
||||
|
||||
lazy();
|
||||
},
|
||||
complete: function(data) {
|
||||
lazyload();
|
||||
// animate();
|
||||
marg_item(project_name);
|
||||
closeAjax();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -83,11 +84,11 @@ function click_list() {
|
||||
url : '/' + page + '/' + cat, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
// async: false,
|
||||
success: function(data) {
|
||||
|
||||
$(data).find('#item_list').addClass(cat).insertAfter($link_txt);
|
||||
$link_txt.addClass('open');
|
||||
|
||||
lazy();
|
||||
anchor($href);
|
||||
|
||||
$('.card a').click(function (e) {
|
||||
@@ -98,14 +99,11 @@ function click_list() {
|
||||
},
|
||||
complete: function(data) {
|
||||
console.log('cat', cat);
|
||||
lazyload();
|
||||
|
||||
var $link_card = $('.card > #'+project_name + ' a');
|
||||
|
||||
setTimeout( function(){
|
||||
console.log('project_name', project_name);
|
||||
console.log('$link_card', $link_card);
|
||||
|
||||
if ($link_card.hasClass('open')) {
|
||||
}else {
|
||||
anchor($href);
|
||||
@@ -116,15 +114,16 @@ function click_list() {
|
||||
success: function(data) {
|
||||
$(data).find('#item').addClass(cat).insertAfter($link_card);
|
||||
$link_card.parent().addClass('open');
|
||||
lazy();
|
||||
},
|
||||
complete: function(data) {
|
||||
// animate();
|
||||
lazyload();
|
||||
marg_item(project_name);
|
||||
closeAjax();
|
||||
|
||||
},
|
||||
});
|
||||
}
|
||||
}, 900);
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -140,16 +139,22 @@ function click_img(e, $this, $href, url, page, cat, project_name) {
|
||||
cat = url[2];
|
||||
project_name = url[3];
|
||||
|
||||
var $loader = $(this).parents('.card').find('.loader');
|
||||
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if ($this.parent().hasClass('open')) {
|
||||
$this.parent().removeClass('open');
|
||||
$($this.parent().find('#item.'+ cat)).remove();
|
||||
} else {
|
||||
$loader.css('display','inline-block');
|
||||
$.ajax({
|
||||
url : '/' + page + '/' + cat + '/' + project_name, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
// async: false,
|
||||
success: function(data) {
|
||||
$('#item_list.'+cat+' .card-image.open #item').remove();
|
||||
$('#item_list.'+cat+' .card-image').removeClass('open');
|
||||
@@ -157,9 +162,14 @@ function click_img(e, $this, $href, url, page, cat, project_name) {
|
||||
$this.parent().addClass('open');
|
||||
marg_item(project_name);
|
||||
anchor($href);
|
||||
lazy();
|
||||
},
|
||||
complete:function() {
|
||||
lazyload();
|
||||
// var $projet = $("#text_figli .card #item");
|
||||
// var hamburger = "<div id='icone_list'><button class='hamburger hamburger--slider is-active' type='button'><span class='hamburger-box'><span class='hamburger-inner'></span></span></button></div>"
|
||||
// $projet.prepend(hamburger);
|
||||
closeAjax();
|
||||
$loader.hide();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -236,22 +246,62 @@ function mouseHover() {
|
||||
|
||||
};
|
||||
|
||||
function lazyload() {
|
||||
$('.lazy').Lazy({
|
||||
// your configuration goes here
|
||||
// scrollDirection: 'vertical',
|
||||
effect: "fadeIn",
|
||||
effectTime: 900,
|
||||
threshold: 0
|
||||
// visibleOnly: true,
|
||||
// onError: function(element) {
|
||||
// console.log('error loading ' + element.data('src'));
|
||||
// }
|
||||
function lazy() {
|
||||
$('img.lazy').Lazy({
|
||||
effect: "fadeIn",
|
||||
effectTime: 500,
|
||||
threshold: 0
|
||||
});
|
||||
}
|
||||
|
||||
function redirection() {
|
||||
var url = document.location.href;
|
||||
console.log(url);
|
||||
if (url != 'https://figureslibres.kevintessier.net/') {
|
||||
document.location.href="https://figureslibres.kevintessier.net/"
|
||||
}
|
||||
}
|
||||
|
||||
function animate_burger() {
|
||||
var forEach=function(t,o,r){if("[object Object]"===Object.prototype.toString.call(t))for(var c in t)Object.prototype.hasOwnProperty.call(t,c)&&o.call(r,t[c],c,t);else for(var e=0,l=t.length;l>e;e++)o.call(r,t[e],e,t)};
|
||||
var hamburgers = document.querySelectorAll(".hamburger");
|
||||
var $hamburger = $('button.hamburger');
|
||||
|
||||
if (hamburgers.length > 0) {
|
||||
forEach(hamburgers, function(hamburger) {
|
||||
hamburger.addEventListener("click", function() {
|
||||
this.classList.toggle("is-active");
|
||||
}, false);
|
||||
});
|
||||
}
|
||||
|
||||
$hamburger.click(function() {
|
||||
$('.sidebar-right').toggleClass("is-active");
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function closeAjax() {
|
||||
var $button = $('#item #icone_list');
|
||||
|
||||
$button.click(function() {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
}
|
||||
|
||||
function croix() {
|
||||
var $link = $("#text_figli p > a");
|
||||
var hamburger = "<div id='icone_list'><button class='hamburger hamburger--slider is-active' type='button'><span class='hamburger-box'><span class='hamburger-inner'></span></span></button></div>"
|
||||
var loader = "<div class='loader'></div>"
|
||||
$link.append(hamburger);
|
||||
$link.append(loader);
|
||||
}
|
||||
|
||||
$(document).ready(function($){
|
||||
// redirection();
|
||||
click_link();
|
||||
click_list();
|
||||
mouseHover();
|
||||
animate_burger();
|
||||
croix();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user