"use strict";
/* --- Anita Config --- */
const anita_config = {
/* --- Header and Main Menu --- */
// Main Menu config for quick and same result for all pages.
// Use 'Label' : 'url' for menu items and 'Label' : { ... } for Submenus. Don't forget about commas after each item.
main_menu: {
'About us': '../sub01/menu01.php?topmenu=01',
'Portfolio':
'../sub03/menu01.php?topmenu=03',
'Contact Us': '../sub01/menu02.php?topmenu=01'
},
// Option to stick the header to the top of the page
sticky_header: true,
// Menu items appear delay in milliseconds
fs_menu_delay: 100,
/* --- Social Links --- */
socials: {
'instagram' : {
'url': 'https://www.instagram.com/wizdesign.lab/',
'label': 'Instagram.'
},
'youtube' : {
'url': 'https://www.youtube.com/@user-py3wb7jg2v/featured',
'label': 'Youtube.'
},
},
/* --- Content Features --- */
// Page background Spotlight Effect
spotlight: true,
// Back to Top Button
back2top: true,
// Interractive Cursor
int_cursor: true,
/* --- Protection Options --- */
// Right Click Protection
disable_right_click: true,
// Protect Images from Drag
image_drag_protection: false,
/* --- Localization --- */
l10n: {
// Footer Copyright string
copyright: ' ',
// The message that appears when visitors try to open context menu
rcp_message: 'Thank you for visiting our site.',
// The Button Label for Context Menu blocker
rcp_button: 'Close',
// Back to Top Label
b2t_label: 'Back to Top'
}
}
/* --- Activate Preloader --- */
jQuery('body').append('
')
.append('
' + _self.options.l10n.b2t_label + '')
.on('click', function(e) {
e.preventDefault();
jQuery('html, body').stop().animate( { scrollTop: 0 }, 500 );
});
}
// Spotlight
if ( _self.options.spotlight ) {
_self.$el.body.append('
');
}
// Events
_self.$el.win.on('load', function() {
_self.layout();
}).on('resize', function() {
_self.layout();
}).on('scroll', function() {
if ( _self.$el.win.scrollTop() > 40 ) {
_self.$el.header.addClass('is-scrolled');
} else {
_self.$el.header.removeClass('is-scrolled');
}
if ( _self.scrollLocked ) {
window.scrollTo({
top: _self.scrollLockPoint
});
} else {
// Check Back 2 Top State
if (_self.$el.b2t) {
if ( _self.$el.win.scrollTop() > window.innerHeight ) {
_self.$el.b2t.parent().addClass('is-visible');
} else {
_self.$el.b2t.parent().removeClass('is-visible');
}
if ( _self.$el.win.scrollTop() >= _self.maxScroll ) {
_self.$el.b2t.parent().addClass('is-fixed');
} else {
_self.$el.b2t.parent().removeClass('is-fixed');
}
}
}
});
// Keyboard Events
jQuery(document).on('keyup', function(e) {
if (e.keyCode == 27) {
if ( _self.$el.body.hasClass('anita-show-menu') ) {
_self.scrollLocked = false;
_self.$el.body.removeClass('anita-show-menu');
}
if ( _self.$el.body.hasClass('anita-rcp-message-show') ) {
_self.$el.body.removeClass('anita-rcp-message-show');
}
}
});
}
contentOrigin() {
if ( this.$el.main.children('.anita-container').length ) {
this.$el.main.children('.anita-container').css('transform-origin', '50% ' + (window.scrollY + 0.5 * window.innerHeight) + 'px');
}
}
generateID() {
return '_' + Math.random().toString(36).substr(2, 9);
}
inView( this_el ) {
let rect = this_el.getBoundingClientRect()
return (
( rect.height > 0 || rect.width > 0) &&
rect.bottom >= 0 &&
rect.right >= 0 &&
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.left <= (window.innerWidth || document.documentElement.clientWidth)
)
}
// Anita Init
init() {
let _self = this;
// Max Scroll for Back to Top
this.maxScroll = this.$el.body.height() - this.$el.footer.height() - this.$el.win.height();
if (this.$el.b2t) {
if (this.$el.win.scrollTop() >= this.maxScroll ) {
this.$el.b2t.parent().addClass('is-fixed');
}
if ( this.$el.win.scrollTop() > window.innerHeight ) {
this.$el.b2t.parent().addClass('is-visible');
} else {
this.$el.b2t.parent().removeClass('is-visible');
}
}
// Right Click Protection
if ( _self.options.disable_right_click ) {
// Append DOM
_self.$el.body.append('\
');
// Disable Context Menu
jQuery(document).on('contextmenu', function (e) {
e.preventDefault();
if ( jQuery('.anita-rcp-message').length ) {
_self.$el.body.addClass('anita-rcp-message-show');
}
});
if ( jQuery('.anita-rcp-message').length ) {
jQuery('.anita-rcp-message').on('click', '.anita-rcpm-overlay, .anita-rcpm-box', function(e) {
e.preventDefault();
_self.$el.body.removeClass('anita-rcp-message-show');
});
}
}
// Image Drag Protection
if ( _self.options.image_drag_protection ) {
jQuery(document).on('mousedown', 'a', function (e) {
if ( jQuery(this).attr('href').indexOf('.png') || jQuery(this).attr('href').indexOf('.gif') || jQuery(this).attr('href').indexOf('.jpg') ) {
e.preventDefault();
}
});
jQuery(document).on('mousedown', 'img', function (e) {
e.preventDefault();
});
}
// Header Options
if ( _self.options.sticky_header ) {
_self.$el.header.addClass('is-sticky');
}
// Set Retina Logo
if ( jQuery('.anita-logo.is-retina').length ) {
jQuery('.anita-logo.is-retina').each(function() {
let $this = jQuery(this);
$this.css({
'width' : $this.children('img').attr('width') ? (0.5 * $this.children('img').attr('width')) : _self.options.logo_size.w,
'height' : $this.children('img').attr('height') ? (0.5 * $this.children('img').attr('height')) : _self.options.logo_size.h,
})
});
}
// Main Menu Setup
let anita_fullscreen_menu = function() {
// Menu Numbers
let count = 1;
_self.$el.nav.children('ul.main-menu').children('li').each(function() {
jQuery(this).addClass('is-hidden').children('a').prepend('
'+ ( count < 10 ? '0' + count : count) +'.');
count++;
});
// Sub-Menu Accordion
if ( _self.$el.nav.find('.menu-item-has-children').length ) {
_self.$el.nav.find('.menu-item-has-children').children('ul.sub-menu').slideUp(1);
_self.$el.nav.on('click', '.menu-item-has-children > a', function(e) {
e.preventDefault();
jQuery(this).parent().toggleClass('is-open').children('ul.sub-menu').slideToggle(300);
});
}
_self.$el.nav.show_menu = function() {
// Show Menu Items Function
let items_length = _self.$el.nav.children('ul.main-menu').children('li').length - 1;
_self.$el.body.addClass('anita-show-menu');
_self.scrollLockPoint = _self.$el.win.scrollTop();
_self.scrollLocked = true;
_self.$el.nav.children('ul.main-menu').children('li').each(function(i) {
let $this = jQuery(this);
setTimeout(function() {
$this.removeClass('is-hidden');
if ( i == items_length ) {
_self.$el.body.removeClass('is-locked');
}
}, i * _self.options.fs_menu_delay, $this);
});
}
_self.$el.nav.hide_menu = function() {
// Hide Menu Items Function
let items_length = _self.$el.nav.children('ul.main-menu').children('li').length - 1;
_self.scrollLocked = false;
_self.$el.body.removeClass('is-locked');
_self.$el.body.removeClass('anita-show-menu');
_self.$el.nav.children('ul.main-menu').children('li').addClass('is-hidden');
}
// Menu Open/Close Event
jQuery('.anita-menu-toggler').on('click', function() {
_self.$el.body.addClass('is-locked');
_self.contentOrigin();
if (! _self.$el.body.hasClass('anita-show-menu') ) {
_self.$el.nav.show_menu();
} else {
// Hide Items
_self.$el.nav.hide_menu();
}
});
jQuery('.anita-menu-overlay').on('click', function() {
_self.scrollLocked = false;
_self.$el.body.removeClass('anita-show-menu');
});
}
let anita_mobile_menu = function() {
// Create Mobile Menu
_self.$el.mobileMenu = jQuery('').appendTo(_self.$el.body);
_self.$el.mobileMenu.append(_self.$el.nav.clone());
_self.$el.mobileMenuNav = _self.$el.mobileMenu.children('nav');
_self.$el.mobileMenuNav.removeClass('anita-simple-nav');
_self.$el.mobileMenu.append('');
// Items Counter
_self.$el.mobileMenuNav.children('ul.main-menu').children('li').each(function(i) {
i++;
jQuery(this).addClass('is-hidden').children('a').prepend('
'+ ( i < 10 ? '0' + i : i) +'.');
});
// Sub-Menu Accordion
if ( _self.$el.mobileMenuNav.find('.menu-item-has-children').length ) {
_self.$el.mobileMenuNav.find('.menu-item-has-children').children('ul.sub-menu').slideUp(1);
_self.$el.mobileMenuNav.on('click', '.menu-item-has-children > a', function(e) {
e.preventDefault();
jQuery(this).parent().toggleClass('is-open').children('ul.sub-menu').slideToggle(300);
});
}
// Show Hide Menu
_self.$el.mobileMenuNav.show_menu = function() {
// Show Menu Items Function
let items_length = _self.$el.nav.children('ul.main-menu').children('li').length - 1;
_self.$el.body.addClass('anita-show-menu');
_self.scrollLockPoint = _self.$el.win.scrollTop();
_self.scrollLocked = true;
_self.$el.mobileMenuNav.children('ul.main-menu').children('li').each(function(i) {
let $this = jQuery(this);
setTimeout(function() {
$this.removeClass('is-hidden');
if ( i == items_length ) {
_self.$el.body.removeClass('is-locked');
}
}, i * _self.options.fs_menu_delay, $this);
});
}
_self.$el.mobileMenuNav.hide_menu = function() {
// Hide Menu Items Function
let items_length = _self.$el.nav.children('ul.main-menu').children('li').length - 1;
_self.scrollLocked = false;
_self.$el.body.removeClass('is-locked');
_self.$el.body.removeClass('anita-show-menu');
_self.$el.mobileMenuNav.children('ul.main-menu').children('li').addClass('is-hidden');
}
// Mobile Menu Button
_self.$el.header.find('.anita-menu-wrapper').append('');
_self.$el.header.on('click', '.anita-mobile-menu-toggler', function() {
if (! _self.$el.body.hasClass('anita-show-menu') ) {
_self.$el.mobileMenuNav.show_menu();
} else {
// Hide Items
_self.$el.mobileMenuNav.hide_menu();
}
});
}
// Create JS Menu
let anita_js_menu = function() {
if ( _self.options.main_menu !== null ) {
let current_page = window.location.pathname.split("/").pop();
if (current_page == '') {
current_page = 'index';
}
let $main_menu = jQuery('
');
let get_item = function(label, link) {
if ( link.indexOf(current_page) > -1 ) {
return jQuery('');
} else {
return jQuery('
'+ label +'');
}
}
let get_submenu = function(label, obj, $parent) {
let $li = jQuery('').appendTo($parent);
$li.append('
' + label + '');
let $submenu = jQuery('').appendTo($li);
for ( const [label, link] of Object.entries(obj) ) {
if (typeof link === 'object') {
get_submenu(label, link, $submenu);
} else {
$submenu.append(get_item(label, link));
}
}
}
for ( const [label, link] of Object.entries(_self.options.main_menu) ) {
if (typeof link === 'object') {
get_submenu(label, link, $main_menu);
} else {
$main_menu.append(get_item(label, link));
}
}
// Set Current Menu Item
if ( $main_menu.find('.current-menu-item').length ) {
$main_menu.find('.current-menu-item').each(function() {
jQuery(this).parents('li').addClass('current-menu-parent');
});
}
return $main_menu;
} else {
console.warn('No menu config found.');
}
}
// Create JS Menu
if ( _self.$el.nav.hasClass('anita-js-menu') ) {
_self.$el.nav.append( anita_js_menu() );
}
// Setup Fullscreen Menu
if ( ! _self.$el.nav.hasClass('anita-simple-nav') ) {
anita_fullscreen_menu();
} else {
// Create Mobile Menu
anita_mobile_menu();
}
// Social Links
if ( jQuery('.anita-js-socials').length && _self.options.socials ) {
jQuery('.anita-js-socials').each(function() {
let $socials = jQuery('
').appendTo(this);
for ( const [classname, item] of Object.entries(_self.options.socials) ) {
$socials.append('
' + (item.label ? item.label : '') + '');
}
});
}
// Copyright
if ( jQuery('.anita-js-copyright').length ) {
jQuery('.anita-js-copyright').each(function() {
jQuery(this).html(_self.options.l10n.copyright);
});
}
// PhotoSwipe Lightbox
if ( jQuery('.anita-lightbox-link').length ) {
if ( typeof PhotoSwipe !== 'function' ) {
jQuery.getScript('../inc/intro_js/photoswipe.js').done(function() {
if ( _self.pswp ) {
_self.pswp.isReady = true;
}
});
}
this.pswp = {
isReady: typeof PhotoSwipe == 'function' ? true : false,
getMaxHeight : function() {
let maxHeight = _self.$el.win.height();
if ( jQuery('.pswp__caption').length ) {
maxHeight = maxHeight - jQuery('.pswp__caption').height();
}
if ( jQuery('.pswp__top-bar').length ) {
let $top_bar = jQuery('.pswp__top-bar'),
top_bar_height = $top_bar.height() + parseInt($top_bar.css('padding-top'), 10) + parseInt($top_bar.css('padding-bottom'), 10);
if ( jQuery('.pswp__caption').length ) {
maxHeight = maxHeight - top_bar_height;
} else {
maxHeight = maxHeight - top_bar_height*2;
}
}
return maxHeight;
},
// Resize Video
resizeVideo : function() {
let result = {};
if ( window.innerWidth/16 > this.getMaxHeight()/9 ) {
result.w = this.getMaxHeight() * 1.7778 * 0.8;
result.h = this.getMaxHeight() * 0.8;
} else {
result.w = window.innerWidth * 0.8;
result.h = window.innerWidth * 0.5625 * 0.8;
}
return result;
},
gallery : Array(),
dom : jQuery('\
\
').appendTo( _self.$el.body )
};
_self.$el.body.on('click', '.pswp__scroll-wrap', function(e) {
if ( _self.pswp.lightbox ) {
_self.pswp.lightbox.close();
}
});
_self.$el.body.on('click', '.anita-pswp-image-wrap', function(e) {
e.preventDefault();
e.stopPropagation();
});
_self.$el.body.on('click', '.pswp__scroll-wrap button, .pswp__scroll-wrap a, .pswp__scroll-wrap img', function(e) {
e.preventDefault();
e.stopPropagation();
});
jQuery(document).on('click', '.anita-lightbox-link', function(e) {
e.preventDefault();
if (typeof PhotoSwipe == 'function') {
let $this = jQuery(this),
this_index = parseInt($this.attr('data-count'), 10),
this_gallery = $this.attr('data-gallery') ? $this.attr('data-gallery') : 'default',
this_options = {
index: this_index,
history: false,
bgOpacity: 0.9,
showHideOpacity: true,
getThumbBoundsFn: function(index) {
var pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
rect = $this[0].getBoundingClientRect();
return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
},
};
_self.pswp.lightbox = new PhotoSwipe( _self.$el.body.find('.pswp')[0], PhotoSwipeUI_Default, _self.pswp.gallery[this_gallery], this_options );
_self.pswp.lightbox.init();
// Init video (if is video slide)
if ($this.attr('data-type') !== 'image') {
let $this_video = jQuery(_self.pswp.lightbox.container).find('[data-src="'+ $this.attr('href') +'"]');
$this_video.addClass('is-inview').width(_self.pswp.resizeVideo().w).height(_self.pswp.resizeVideo().h);
if ( 'video' == $this.attr('data-type') ) {
if ( $this_video.children('video').length ) {
$this_video.children('video').attr('autoplay', true);
}
} else {
if ( $this_video.children('iframe').length ) {
$this_video.children('iframe').attr('src', $this_video.attr('data-player-src')+'?controls=1&loop=0&autoplay=1&muted=1');
}
}
}
// Check for videos in view
_self.pswp.lightbox.listen('resize', function() {
if ( jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').length ) {
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').width(_self.pswp.resizeVideo().w).height(_self.pswp.resizeVideo().h);
}
if ( jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').length ) {
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').width(_self.pswp.resizeVideo().w).height(_self.pswp.resizeVideo().h);
}
});
_self.pswp.lightbox.listen('beforeChange', function() {
// Self-hosted Video
if ( jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').length ) {
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').width(_self.pswp.resizeVideo().w).height(_self.pswp.resizeVideo().h);
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').each(function() {
if ( _self.inView( this ) ) {
jQuery(this).addClass('is-inview');
if ( jQuery(this).children('video').length ) {
jQuery(this).children('video')[0].play();
}
} else {
jQuery(this).removeClass('is-inview');
if ( jQuery(this).children('video').length ) {
jQuery(this).children('video')[0].pause();
}
}
});
}
// Embedded Video
if ( jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').length ) {
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').width(_self.pswp.resizeVideo().w).height(_self.pswp.resizeVideo().h);
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').each(function() {
let $this_video = jQuery(this);
if ( _self.inView( this ) ) {
$this_video.addClass('is-inview');
$this_video.children('iframe').attr('src', $this_video.attr('data-player-src')+'?controls=1&loop=0&autoplay=1&muted=1');
} else {
$this_video.removeClass('is-inview');
$this_video.children('iframe').attr( 'src', jQuery(this).attr('data-src') + '?controls=1&loop=0' );
}
});
}
});
_self.pswp.lightbox.listen('close', function() {
// Close ligthbox
if ( jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').length ) {
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--iframe').each(function() {
if ( jQuery(this).children('iframe').length ) {
jQuery(this).children('iframe').attr( 'src', jQuery(this).attr('data-src') + '?controls=1&loop=0' );
}
});
}
});
_self.pswp.lightbox.listen('unbindEvents', function() {
// Unbind Events after close
});
_self.pswp.lightbox.listen('destroy', function() {
// Destroy after unbind close
if ( jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').length ) {
jQuery(_self.pswp.lightbox.container).find('.anita-pswp-media--video').each(function() {
if ( jQuery(this).children('video').length ) {
jQuery(this).children('video')[0].pause();
}
});
}
});
} else {
console.warn('PhotoSwipe not loaded');
}
});
}
// Interractive Cursor
if ( _self.options.int_cursor ) {
this.cursor = {
$el: jQuery('
').appendTo( _self.$el.body ),
position: {
x: window.innerWidth * 0.5,
y: window.innerHeight * 0.5,
lerpX: window.innerWidth * 0.5,
lerpY: window.innerHeight * 0.5,
},
isActive: false,
isFixed: false,
isTouch: false,
timer: new Anita_Clock,
prevTime: 0,
init: function() {
let _cursor = this;
// Append UI
this.$el.append('
');
this.$el.append('