2018-10-16 16:28:42 +00:00
|
|
|
let initSubHeaderOffsetTop = 500;
|
|
|
|
|
|
|
|
let parallaxActive = true;
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
initSubHeaderOffsetTop = $('#profile-sub-header').offset().top;
|
|
|
|
|
|
|
|
$('section[data-type="background"]').each(function () {
|
|
|
|
// console.log(parallaxActive);
|
|
|
|
var $bgobj = $(this);
|
|
|
|
$bgobj.css('height', parseFloat($('#profile-sub-header').css('top')) - $(window).scrollTop() - 60);
|
|
|
|
$(window).scroll(function () {
|
|
|
|
if (parallaxActive) {
|
|
|
|
let translateY = $('#profile-sub-header').css('transform');
|
|
|
|
if (translateY !== 'none') {
|
|
|
|
translateY = matrixToArray(translateY);
|
|
|
|
translateY = parseFloat(translateY[translateY.length - 1]);
|
|
|
|
} else {
|
|
|
|
translateY = 0;
|
|
|
|
}
|
|
|
|
$bgobj.css('height', 500 + translateY - $(window).scrollTop() - 60);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('section[data-type="foreground"]').each(function () {
|
|
|
|
var $bgobj = $(this);
|
|
|
|
|
|
|
|
$(window).scroll(function () {
|
|
|
|
if (parallaxActive) {
|
|
|
|
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));
|
|
|
|
var coords = '50% ' + yPos + 'px';
|
|
|
|
$bgobj.css({backgroundPosition: coords});
|
|
|
|
$bgobj.css('transform', 'translate3d(0,' + yPos + 'px, 0)')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function matrixToArray(str) {
|
|
|
|
return str.split('(')[1].split(')')[0].split(',');
|
|
|
|
}
|
|
|
|
|
|
|
|
$(window).scroll(function () {
|
|
|
|
const scrollTrigger = $('#scroll-trigger');
|
|
|
|
if ($(this).scrollTop() + 75 > scrollTrigger.offset().top) {
|
|
|
|
parallaxActive = false;
|
|
|
|
$('#profile-sub-header').addClass('fixedTop').css('transform', 'translate3d(0,0,0)');
|
2018-10-27 10:08:54 +00:00
|
|
|
$('#profile-content').css('transform', 'translate3d(0, ' + $('#profile-sub-header').height() + 'px, 0)');
|
2018-10-16 16:28:42 +00:00
|
|
|
} else {
|
|
|
|
parallaxActive = true;
|
|
|
|
$('#profile-sub-header').removeClass('fixedTop');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const subButton = $('.subscribe-button');
|
|
|
|
const subbedClass = 'subbed';
|
|
|
|
|
|
|
|
subButton.on('click', function (e) {
|
|
|
|
sendFollowerRequest();
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
function toggleSubbed(isSubbed) {
|
|
|
|
let count = subButton.attr('data-count');
|
|
|
|
|
|
|
|
if (isSubbed) {
|
|
|
|
subButton.removeClass(subbedClass);
|
|
|
|
count--;
|
|
|
|
} else {
|
|
|
|
subButton.addClass(subbedClass);
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
subButton.attr('data-count', count);
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendFollowerRequest() {
|
|
|
|
$.ajax({
|
2018-10-17 11:56:22 +00:00
|
|
|
url: "/user/switchFollowing",
|
2018-10-16 16:28:42 +00:00
|
|
|
method: "POST",
|
|
|
|
success: function (data) {
|
|
|
|
console.log(data);
|
|
|
|
switch (data.code) {
|
|
|
|
case 0:
|
|
|
|
$('#mustBeLoggedInModal').modal('show');
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$('#cantFollowYourself').modal('show');
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
toggleSubbed(true);
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
toggleSubbed(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: console.log
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(".vertical-tab-menu>.list-group>a").click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$(this).siblings('a.active').removeClass("active");
|
|
|
|
$(this).addClass("active");
|
|
|
|
var index = $(this).index();
|
|
|
|
$(".vertical-tabs>.vertical-tab-content").removeClass("active");
|
|
|
|
$(".vertical-tabs>.vertical-tab-content").eq(index).addClass("active");
|
|
|
|
});
|
|
|
|
});
|