2019-12-03 11:37:44 +00:00
|
|
|
(function ($) {
|
2019-12-16 15:48:13 +00:00
|
|
|
// Search
|
2020-03-24 04:51:01 +00:00
|
|
|
let $searchWrap = $('.search-form-wrap'),
|
2019-12-03 11:37:44 +00:00
|
|
|
isSearchAnim = false,
|
|
|
|
searchAnimDuration = 200;
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
const startSearchAnim = () => {
|
2019-12-03 11:37:44 +00:00
|
|
|
isSearchAnim = true;
|
|
|
|
};
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
const stopSearchAnim = (callback) => {
|
2019-12-03 11:37:44 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
isSearchAnim = false;
|
|
|
|
callback && callback();
|
|
|
|
}, searchAnimDuration);
|
|
|
|
};
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
$('.nav-item-search').click(() => {
|
2019-12-03 11:37:44 +00:00
|
|
|
if (isSearchAnim) return;
|
|
|
|
startSearchAnim();
|
|
|
|
$searchWrap.addClass('on');
|
|
|
|
stopSearchAnim(function () {
|
|
|
|
$('.local-search-input').focus();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
$(document).mouseup((e) => {
|
|
|
|
const _con = $('.local-search');
|
2019-12-03 11:37:44 +00:00
|
|
|
if (!_con.is(e.target) && _con.has(e.target).length === 0) {
|
|
|
|
$searchWrap.removeClass('on');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// Mobile Detect
|
|
|
|
const isMobile = {
|
2019-12-03 11:37:44 +00:00
|
|
|
Android: function () {
|
|
|
|
return navigator.userAgent.match(/Android/i);
|
|
|
|
},
|
|
|
|
BlackBerry: function () {
|
|
|
|
return navigator.userAgent.match(/BlackBerry/i);
|
|
|
|
},
|
|
|
|
iOS: function () {
|
|
|
|
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
|
|
|
},
|
|
|
|
Opera: function () {
|
|
|
|
return navigator.userAgent.match(/Opera Mini/i);
|
|
|
|
},
|
|
|
|
Windows: function () {
|
|
|
|
return navigator.userAgent.match(/IEMobile/i);
|
|
|
|
},
|
|
|
|
any: function () {
|
|
|
|
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Share
|
2020-03-16 03:24:54 +00:00
|
|
|
$('.share-outer').click(() => $('.share-wrap').fadeToggle())
|
2019-12-03 11:37:44 +00:00
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// Lazyload
|
2019-12-03 11:37:44 +00:00
|
|
|
$("img.lazy").lazyload({
|
2019-12-04 11:27:58 +00:00
|
|
|
effect: "fadeIn"
|
2019-12-03 11:37:44 +00:00
|
|
|
});
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// JustifiedGallery
|
2019-12-03 11:37:44 +00:00
|
|
|
$('#gallery').justifiedGallery({
|
2019-12-04 11:27:58 +00:00
|
|
|
rowHeight: 200,
|
|
|
|
margins: 5
|
2019-12-03 11:37:44 +00:00
|
|
|
});
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// ScrollDown
|
2019-12-03 11:37:44 +00:00
|
|
|
$(document).ready(function ($) {
|
2020-01-09 11:55:59 +00:00
|
|
|
$('.anchor').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('main').animate({ scrollTop: $('.cover').height() }, 'smooth');
|
2019-12-03 11:37:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// To Top
|
|
|
|
(() => {
|
2019-12-03 11:37:44 +00:00
|
|
|
// When to show the scroll link
|
|
|
|
// higher number = scroll link appears further down the page
|
2020-03-24 04:51:01 +00:00
|
|
|
const upperLimit = 1000;
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
// Our scroll link element
|
2020-03-24 04:51:01 +00:00
|
|
|
const scrollElem = $('#totop');
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
// Scroll to top speed
|
2020-03-24 04:51:01 +00:00
|
|
|
const scrollSpeed = 1600;
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
// Show and hide the scroll to top link based on scroll position
|
|
|
|
scrollElem.hide();
|
|
|
|
$('.content').scroll(function () {
|
2020-03-24 04:51:01 +00:00
|
|
|
const scrollTop = $('.content').scrollTop();
|
2019-12-04 11:27:58 +00:00
|
|
|
if (scrollTop > upperLimit) {
|
2020-03-23 15:04:50 +00:00
|
|
|
$(scrollElem).stop().fadeTo(200, .6); // fade back in
|
2019-12-04 11:27:58 +00:00
|
|
|
} else {
|
2020-03-23 15:04:50 +00:00
|
|
|
$(scrollElem).stop().fadeTo(200, 0); // fade out
|
2019-12-03 11:37:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Scroll to top animation on click
|
2019-12-04 11:27:58 +00:00
|
|
|
$(scrollElem).click(function () {
|
|
|
|
$('.content').animate({ scrollTop: 0 }, scrollSpeed); return false;
|
2019-12-03 11:37:44 +00:00
|
|
|
});
|
2020-03-24 04:51:01 +00:00
|
|
|
})();
|
2019-12-03 11:37:44 +00:00
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// Mobile Nav
|
|
|
|
const $content = $('.content'),
|
2020-01-23 06:13:24 +00:00
|
|
|
$sidebar = $('.sidebar');
|
2019-12-03 11:37:44 +00:00
|
|
|
|
|
|
|
$('.navbar-toggle').on('click', function () {
|
|
|
|
$content.toggleClass('on');
|
|
|
|
$sidebar.toggleClass('on');
|
|
|
|
});
|
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
$content.click(() => {
|
2019-12-03 11:37:44 +00:00
|
|
|
$content.removeClass('on');
|
|
|
|
$sidebar.removeClass('on');
|
|
|
|
});
|
|
|
|
|
2019-12-04 11:27:58 +00:00
|
|
|
if (window.matchMedia("(min-width: 768px)").matches) {
|
|
|
|
$content.addClass('on');
|
|
|
|
$sidebar.addClass('on');
|
|
|
|
}
|
2019-12-16 15:48:13 +00:00
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// Reward
|
|
|
|
$('#reward-btn').click(() => {
|
2020-02-06 15:14:35 +00:00
|
|
|
$('#reward').fadeIn(150)
|
|
|
|
$('#mask').fadeIn(150)
|
2019-12-16 15:48:13 +00:00
|
|
|
});
|
2020-03-24 04:51:01 +00:00
|
|
|
$('#reward .close, #mask').click(() => {
|
2019-12-16 15:48:13 +00:00
|
|
|
$('#mask').fadeOut(100)
|
|
|
|
$('#reward').fadeOut(100)
|
2019-12-05 15:31:52 +00:00
|
|
|
})
|
2020-03-23 15:04:50 +00:00
|
|
|
|
2020-03-24 04:51:01 +00:00
|
|
|
// DarkMode
|
|
|
|
if (sessionStorage.getItem('darkmode') == 1) {
|
2020-03-23 15:04:50 +00:00
|
|
|
$('body').addClass('darkmode')
|
|
|
|
$('#todark i').removeClass('ri-moon-line').addClass('ri-sun-line')
|
2020-03-24 04:51:01 +00:00
|
|
|
} else {
|
2020-03-23 15:04:50 +00:00
|
|
|
$('body').removeClass('darkmode')
|
|
|
|
$('#todark i').removeClass('ri-sun-line').addClass('ri-moon-line')
|
|
|
|
}
|
2020-03-24 04:51:01 +00:00
|
|
|
$('#todark').click(() => {
|
|
|
|
if (sessionStorage.getItem('darkmode') == 1) {
|
2020-03-23 15:04:50 +00:00
|
|
|
$('body').removeClass('darkmode')
|
|
|
|
$('#todark i').removeClass('ri-sun-line').addClass('ri-moon-line')
|
|
|
|
sessionStorage.removeItem('darkmode')
|
2020-03-24 04:51:01 +00:00
|
|
|
} else {
|
2020-03-23 15:04:50 +00:00
|
|
|
$('body').addClass('darkmode')
|
|
|
|
$('#todark i').removeClass('ri-moon-line').addClass('ri-sun-line')
|
2020-03-24 04:51:01 +00:00
|
|
|
sessionStorage.setItem('darkmode', 1)
|
2020-03-23 15:04:50 +00:00
|
|
|
}
|
|
|
|
})
|
2019-12-03 11:37:44 +00:00
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
|