This commit is contained in:
2019-09-25 15:05:50 +02:00
parent af7ca72760
commit 40af43681e
14 changed files with 3496 additions and 456 deletions
+147 -47
View File
@@ -1,59 +1,159 @@
var isTouch = window.DocumentTouch && document instanceof DocumentTouch;
function click_link() {
function scrollHeader() {
// Has scrolled class on header
var zvalue = $(document).scrollTop();
if ( zvalue > 75 )
$("#header").addClass("scrolled");
else
$("#header").removeClass("scrolled");
}
$link = $('#text_figli p > a');
function parallaxBackground() {
$('.parallax').css('background-positionY', ($(window).scrollTop() * 0.3) + 'px');
}
$link.click(function(e) {
e.preventDefault();
jQuery(document).ready(function($){
var $this = $(this);
$href = $this.attr("href");
url = $href.split("/");
page = url[1];
cat = url[2];
project_name = url[3];
scrollHeader();
if ($this.hasClass('open')) {
$this.removeClass('open');
$('#item_list.'+ cat).remove();
} else {
// Scroll Events
if (!isTouch){
$(document).scroll(function() {
scrollHeader();
parallaxBackground();
});
};
// Touch scroll
$(document).on({
'touchmove': function(e) {
scrollHeader(); // Replace this with your code.
$.ajax({
url : '/' + page + '/' + cat, // La ressource ciblée
type : 'GET', // Le type de la requête HTTP
dataType:'html',
success: function(data) {
$(data).find('#item_list').addClass(cat).insertAfter($this);
$this.addClass('open');
},
complete: function(data) {
console.log('cat', cat);
click_img(e, $this, $href, url, page, cat, project_name);
}
});
}
});
};
function click_list() {
var $link = $('.list-projets li > a');
$link.click(function(e) {
e.preventDefault();
var $this = $(this);
$href = $this.attr("href");
url = $href.split("/");
page = url[1];
cat = url[2];
project_name = url[3];
var $link_txt = $('#text_figli a#'+cat);
var $link_item = $('#item_list.'+cat);
var $link_card = $('.card > #'+project_name + ' a');
if ($link_txt.hasClass('open') && $link_card.parent().hasClass('open') ) {
console.log('anchor');
anchor($href);
}else if ($link_txt.hasClass('open')) {
$.ajax({
url : '/' + page + '/' + cat + '/' + project_name, // La ressource ciblée
type : 'GET', // Le type de la requête HTTP
dataType:'html',
success: function(data) {
$(data).find('#item').addClass(cat).insertAfter($link_card);
$link_card.parent().addClass('open');
},
});
} else {
$.ajax({
url : '/' + page + '/' + cat, // La ressource ciblée
type : 'GET', // Le type de la requête HTTP
dataType:'html',
success: function(data) {
$(data).find('#item_list').addClass(cat).insertAfter($link_txt);
$link_txt.addClass('open');
anchor($href);
$('.card a').click(function (e) {
e.preventDefault()
})
click_img(e, $this, $href, url, page, cat, project_name)
},
complete: function(data) {
console.log('cat', cat);
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);
$.ajax({
url : '/' + page + '/' + cat + '/' + project_name, // La ressource ciblée
type : 'GET', // Le type de la requête HTTP
dataType:'html',
success: function(data) {
$(data).find('#item').addClass(cat).insertAfter($link_card);
$link_card.parent().addClass('open');
},
});
}
}, 1500);
}
});
}
});
}
function click_img(e, $this, $href, url, page, cat, project_name) {
// $link_img = $('.card .card-image > a');
$('section.' + cat +' .card-image > a').click(function(e) {
var $this = $(this);
$href = $this.attr("href");
url = $href.split("/");
page = url[1];
cat = url[2];
project_name = url[3];
e.preventDefault();
if ($this.parent().hasClass('open')) {
$this.parent().removeClass('open');
$($this.parent().find('#item.'+ cat)).remove();
} else {
$.ajax({
url : '/' + page + '/' + cat + '/' + project_name, // La ressource ciblée
type : 'GET', // Le type de la requête HTTP
dataType:'html',
success: function(data) {
$(data).find('#item').addClass(cat).insertAfter($this);
$this.parent().addClass('open');
},
});
}
});
}
//Smooth scroll to start
$('#to-start').click(function(){
var start_y = $('#start').position().top;
var header_offset = 45;
window.scroll({ top: start_y - header_offset, left: 0, behavior: 'smooth' });
return false;
});
function anchor($href) {
//Smooth scroll to top
$('#to-top').click(function(){
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
return false;
});
var aTag = $("a[href='"+ $href +"']");
$('html,body').animate({scrollTop: aTag.offset().top},'slow');
// Responsive Menu
$('#toggle').click(function () {
$(this).toggleClass('active');
$('#overlay').toggleClass('open');
$('body').toggleClass('mobile-nav-open');
});
// Tree Menu
$(".tree").treemenu({delay:300});
}
$(document).ready(function($){
click_link();
click_list();
});