ajaxbeta
This commit is contained in:
@@ -1,149 +0,0 @@
|
||||
var $link_txt = $('#text_figli p > a');
|
||||
var $link_list = $('.list-projets a');
|
||||
|
||||
function ajax_txt($href,$this, this_id) {
|
||||
var $link_txt = $('#text_figli > p');
|
||||
var idlink_txt = $link_txt.attr("id");
|
||||
var search_id =$link_txt.find('#' + this_id);
|
||||
|
||||
$.ajax({
|
||||
url : $href, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
success: function(data) {
|
||||
$(data).find('.card').addClass(this_id).insertAfter(search_id);
|
||||
|
||||
var $card = $('#text_figli .card .card-image > a');
|
||||
|
||||
$card.click(function(e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
var $href = $this.attr("href");
|
||||
var this_id = $this.parent('.card-image').attr("id");
|
||||
|
||||
if ($this.parent('.card-image').hasClass('views')) {
|
||||
$('#'+this_id+' #item').remove();
|
||||
$this.parent('.card-image').removeClass("views");
|
||||
}else{
|
||||
|
||||
$.ajax({
|
||||
url : $href, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
success: function(data) {
|
||||
$(data).find('#item').insertAfter($this);
|
||||
|
||||
$(window).on('resize', function(x){
|
||||
var x = $this.offset();
|
||||
var x = $this.offset();
|
||||
var Wwindow = $('#text_figli').width();
|
||||
var Wcard = $this.parents('.card').width();
|
||||
var xcard = $this.offset().left;
|
||||
var marginR = Wwindow - (Wcard + xcard);
|
||||
|
||||
console.log('x.left resize =',x.left);
|
||||
$this.parent('.card-image').find('#item').css('margin-left', -x.left+8);
|
||||
$this.parents('.card').css('margin-right', marginR);
|
||||
});
|
||||
|
||||
var x = $this.offset();
|
||||
var Wwindow = $('#text_figli').width();
|
||||
var Wcard = $this.parents('.card').width();
|
||||
var xcard = $this.offset().left;
|
||||
var marginR = Wwindow - (Wcard + xcard);
|
||||
// si la distance entre l'image précédente et la bord droit du text est supérieur ou égale
|
||||
// a un card
|
||||
// alors soustrai xcard a la marg calculer de this.
|
||||
// sinon tu ne change rien
|
||||
console.log('marginR', marginR);
|
||||
|
||||
// console.log('x.left',x.left);
|
||||
// console.log('marginR',marginR.right);
|
||||
$this.parent('.card-image').find('#item').css('margin-left', -x.left+8);
|
||||
$this.parents('.card').css('margin-right', marginR);
|
||||
}
|
||||
});
|
||||
$this.parent('.card-image').addClass('views');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ajax_liste($href,$this, this_id) {
|
||||
var $link_txt = $('#text_figli > p');
|
||||
var idlink_txt = $link_txt.attr("id");
|
||||
var search_id =$link_txt.find('#' + this_id);
|
||||
|
||||
console.log('$href',$href);
|
||||
var url = $href.split("/");
|
||||
var id = url[url.length - 2];
|
||||
var projetc_name = url[url.length - 1];
|
||||
console.log('projetc_name',projetc_name);
|
||||
|
||||
$.ajax({
|
||||
url : '/projets/' + id, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
success: function(data) {
|
||||
$(data).find('.card').addClass(this_id).insertAfter(search_id);
|
||||
},
|
||||
complete: function(){
|
||||
// Handle the complete event
|
||||
setTimeout( function(){
|
||||
$.ajax({
|
||||
url : '/projets/' + id + '/' + projetc_name, // La ressource ciblée
|
||||
type : 'GET', // Le type de la requête HTTP
|
||||
dataType:'html',
|
||||
success: function(data) {
|
||||
var $link_item = $('#text_figli > p > .card');
|
||||
var idlink_txt = $link_txt.attr("id");
|
||||
var search_id =$link_item.find('#' + projetc_name);
|
||||
console.log('search_id',id);
|
||||
$(data).find('#item').insertAfter(search_id);
|
||||
console.log('complete2');
|
||||
},
|
||||
})
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deploy() {
|
||||
$link_txt.click(function(e){
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
var $href = $this.attr("href");
|
||||
var this_id = $this.attr("id");
|
||||
|
||||
if ($this.hasClass('open')) {
|
||||
$('.card.'+this_id).remove();
|
||||
$this.removeClass("open");
|
||||
}else{
|
||||
ajax_txt($href, $this, this_id);
|
||||
$this.addClass('open');
|
||||
}
|
||||
});
|
||||
|
||||
$link_list.click(function(e){
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
var $href = $this.attr("href");
|
||||
var this_id = $this.attr("id");
|
||||
|
||||
if ($this.hasClass('open')) {
|
||||
$('.card.'+this_id).remove();
|
||||
$this.removeClass("open");
|
||||
}else{
|
||||
ajax_liste($href, $this, this_id);
|
||||
$this.addClass('open');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
deploy();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user