Skip to content

Commit

Permalink
Added SEO & GA. Fixed Lazyload issue + minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeryeosgit committed Feb 19, 2020
1 parent c312549 commit 9747d9f
Show file tree
Hide file tree
Showing 4 changed files with 427 additions and 409 deletions.
269 changes: 134 additions & 135 deletions assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,183 +18,182 @@



(function( $ ){
(function ($) {


/* ----------------------------------------------------------- */
/* 1. FULL OVERLYAY MENU
/* ----------------------------------------------------------- */

$('.mu-menu-btn').on('click', function(event) {
event.preventDefault();
$('.mu-menu-full-overlay').addClass('mu-menu-full-overlay-show');
});
// when click colose btn
$('.mu-menu-close-btn').on('click', function(event) {
event.preventDefault();
$('.mu-menu-btn').on('click', function (event) {

event.preventDefault();

$('.mu-menu-full-overlay').addClass('mu-menu-full-overlay-show');

});

// when click colose btn

$('.mu-menu-close-btn').on('click', function (event) {

event.preventDefault();

$('.mu-menu-full-overlay').removeClass('mu-menu-full-overlay-show');

});

// when click menu item overlay disappear
});

// when click menu item overlay disappear

$('.mu-menu a').on('click', function (event) {

event.preventDefault();

$('.mu-menu-full-overlay').removeClass('mu-menu-full-overlay-show');

$('.mu-menu a').on('click', function(event) {

event.preventDefault();

$('.mu-menu-full-overlay').removeClass('mu-menu-full-overlay-show');

});
});

/* ----------------------------------------------------------- */
/* ----------------------------------------------------------- */
/* 2. MENU SMOOTH SCROLLING
/* ----------------------------------------------------------- */
/* ----------------------------------------------------------- */

//MENU SCROLLING WITH ACTIVE ITEM SELECTED

$(".mu-menu a").click(function(event){
event.preventDefault();
//calculate destination place
var dest=0;
if($(this.hash).offset().top > $(document).height()-$(window).height()){
dest=$(document).height()-$(window).height();
}else{
dest=$(this.hash).offset().top;
}
//go to destination
$('html,body').animate({scrollTop:dest}, 1000,'swing');
});

$(".mu-menu a").click(function (event) {
event.preventDefault();
//calculate destination place
var dest = 0;
if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
dest = $(document).height() - $(window).height();
} else {
dest = $(this.hash).offset().top;
}
//go to destination
$('html,body').animate({ scrollTop: dest }, 1000, 'swing');
});



/* ----------------------------------------------------------- */
/* 3. VIDEO POPUP
/* ----------------------------------------------------------- */

$('.mu-video-play-btn').on('click', function(event) {
event.preventDefault();
$('.mu-video-iframe-area').addClass('mu-video-iframe-display');
});
// when click the close btn

// disappear iframe window
$('.mu-video-close-btn').on('click', function(event) {
event.preventDefault();
$('.mu-video-play-btn').on('click', function (event) {

event.preventDefault();

$('.mu-video-iframe-area').addClass('mu-video-iframe-display');

});

// when click the close btn

// disappear iframe window

$('.mu-video-close-btn').on('click', function (event) {

event.preventDefault();

$('.mu-video-iframe-area').removeClass('mu-video-iframe-display');

});

// stop iframe if it is play while close the iframe window
});

// stop iframe if it is play while close the iframe window

$('.mu-video-close-btn').click(function(){
$('.mu-video-close-btn').click(function () {

$('.mu-video-iframe').attr('src', $('.mu-video-iframe').attr('src'));
$('.mu-video-iframe').attr('src', $('.mu-video-iframe').attr('src'));

});
});

// when click overlay area
// when click overlay area

$('.mu-video-iframe-area').on('click', function (event) {

event.preventDefault();

$('.mu-video-iframe-area').on('click', function(event) {

event.preventDefault();

$('.mu-video-iframe-area').removeClass('mu-video-iframe-display');

});

$('.mu-video-iframe-area, .mu-video-iframe').on('click', function(e){
e.stopPropagation();
});


$('.mu-video-iframe-area, .mu-video-iframe').on('click', function (e) {
e.stopPropagation();
});


/* ----------------------------------------------------------- */
/* 4. APPS SCREENSHOT SLIDEER ( SLICK SLIDER )
/* ----------------------------------------------------------- */

$('.mu-apps-screenshot-slider').slick({
slidesToShow: 4,
autoplay: true,
autoplaySpeed: 1000,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
arrows: false,
slidesToShow: 1
}
}
]
});

$('.mu-sponsor-logos-slider').slick({
slidesToShow: 4,
// autoplay: true,
autoplaySpeed: 100,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
arrows: false,
slidesToShow: 1
}
}
]
});
$('.mu-apps-screenshot-slider').slick({
slidesToShow: 4,
autoplay: true,
autoplaySpeed: 1000,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
arrows: false,
slidesToShow: 1
}
}
]
});

$('.mu-sponsor-logos-slider').slick({
slidesToShow: 4,
autoplay: true,
autoplaySpeed: 750,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
arrows: false,
slidesToShow: 1
}
}
]
});

/* ----------------------------------------------------------- */
/* 5. BOOTSTRAP ACCORDION
/* ----------------------------------------------------------- */
/* ----------------------------------------------------------- */

/* Start for accordion #1*/
$('#accordion .panel-collapse').on('shown.bs.collapse', function () {
/* Start for accordion #1*/
$('#accordion .panel-collapse').on('shown.bs.collapse', function () {
$(this).prev().find(".fa").removeClass("fa-plus").addClass("fa-minus");
});
//The reverse of the above on hidden event:
$('#accordion .panel-collapse').on('hidden.bs.collapse', function () {
});

//The reverse of the above on hidden event:

$('#accordion .panel-collapse').on('hidden.bs.collapse', function () {
$(this).prev().find(".fa").removeClass("fa-minus").addClass("fa-plus");
});
});





})( jQuery );


})(jQuery);






50 changes: 50 additions & 0 deletions assets/js/lazyload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
registerListener('load', setLazy);
registerListener('load', lazyLoad);
registerListener('scroll', lazyLoad);

const observer = new MutationObserver(lazyLoad);
var elementToObserve = document.querySelector(".mu-sponsor-logos-area");
observer.observe(elementToObserve, {attributes: true, subtree: true, childList: true});

var lazy = [];

function setLazy() {
lazy = document.getElementsByClassName('lazy');
console.log('Found ' + lazy.length + ' lazy images');
}

function lazyLoad() {
for (var i = 0; i < lazy.length; i++) {
if (isInViewport(lazy[i])) {
if (lazy[i].getAttribute('data-src')) {
lazy[i].src = lazy[i].getAttribute('data-src');
lazy[i].removeAttribute('data-src');
}
}
}

cleanLazy();
}

function cleanLazy() {
lazy = Array.prototype.filter.call(lazy, function (l) { return l.getAttribute('data-src'); });
}

function isInViewport(el) {
var rect = el.getBoundingClientRect();

return (
rect.bottom >= 0 &&
rect.right >= 0 &&
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.left <= (window.innerWidth || document.documentElement.clientWidth)
);
}

function registerListener(event, func) {
if (window.addEventListener) {
window.addEventListener(event, func)
} else {
window.attachEvent('on' + event, func)
}
}
Loading

0 comments on commit 9747d9f

Please sign in to comment.