This commit is contained in:
KhaiNguyen
2020-02-13 10:39:37 +07:00
commit 59401cb805
12867 changed files with 4646216 additions and 0 deletions

View File

@@ -0,0 +1,788 @@
//
// SmoothScroll for websites v1.4.9 (Balazs Galambosi)
// http://www.smoothscroll.net/
//
// Licensed under the terms of the MIT license.
//
// You may use it in your theme if you credit me.
// It is also free to use on any individual website.
//
// Exception:
// The only restriction is to not publish any
// extension for browsers or native application
// without getting a written permission first.
//
(function () {
// Scroll Variables (tweakable)
var defaultOptions = {
// Scrolling Core
frameRate : 150, // [Hz]
animationTime : 400, // [ms]
stepSize : 100, // [px]
// Pulse (less tweakable)
// ratio of "tail" to "acceleration"
pulseAlgorithm : true,
pulseScale : 4,
pulseNormalize : 1,
// Acceleration
accelerationDelta : 50, // 50
accelerationMax : 3, // 3
// Keyboard Settings
keyboardSupport : true, // option
arrowScroll : 50, // [px]
// Other
fixedBackground : true,
excluded : ''
};
var options = defaultOptions;
// Other Variables
var isExcluded = false;
var isFrame = false;
var direction = { x: 0, y: 0 };
var initDone = false;
var root = document.documentElement;
var activeElement;
var observer;
var refreshSize;
var deltaBuffer = [];
var deltaBufferTimer;
var isMac = /^Mac/.test(navigator.platform);
var key = { left: 37, up: 38, right: 39, down: 40, spacebar: 32,
pageup: 33, pagedown: 34, end: 35, home: 36 };
var arrowKeys = { 37: 1, 38: 1, 39: 1, 40: 1 };
/***********************************************
* INITIALIZE
***********************************************/
/**
* Tests if smooth scrolling is allowed. Shuts down everything if not.
*/
function initTest() {
if (options.keyboardSupport) {
addEvent('keydown', keydown);
}
}
/**
* Sets up scrolls array, determines if frames are involved.
*/
function init() {
if (initDone || !document.body) return;
initDone = true;
var body = document.body;
var html = document.documentElement;
var windowHeight = window.innerHeight;
var scrollHeight = body.scrollHeight;
// check compat mode for root element
root = (document.compatMode.indexOf('CSS') >= 0) ? html : body;
activeElement = body;
initTest();
// Checks if this script is running in a frame
if (top != self) {
isFrame = true;
}
/**
* Safari 10 fixed it, Chrome fixed it in v45:
* This fixes a bug where the areas left and right to
* the content does not trigger the onmousewheel event
* on some pages. e.g.: html, body { height: 100% }
*/
else if (isOldSafari &&
scrollHeight > windowHeight &&
(body.offsetHeight <= windowHeight ||
html.offsetHeight <= windowHeight)) {
var fullPageElem = document.createElement('div');
fullPageElem.style.cssText = 'position:absolute; z-index:-10000; ' +
'top:0; left:0; right:0; height:' +
root.scrollHeight + 'px';
document.body.appendChild(fullPageElem);
// DOM changed (throttled) to fix height
var pendingRefresh;
refreshSize = function () {
if (pendingRefresh) return; // could also be: clearTimeout(pendingRefresh);
pendingRefresh = setTimeout(function () {
if (isExcluded) return; // could be running after cleanup
fullPageElem.style.height = '0';
fullPageElem.style.height = root.scrollHeight + 'px';
pendingRefresh = null;
}, 500); // act rarely to stay fast
};
setTimeout(refreshSize, 10);
addEvent('resize', refreshSize);
// TODO: attributeFilter?
var config = {
attributes: true,
childList: true,
characterData: false
// subtree: true
};
observer = new MutationObserver(refreshSize);
observer.observe(body, config);
if (root.offsetHeight <= windowHeight) {
var clearfix = document.createElement('div');
clearfix.style.clear = 'both';
body.appendChild(clearfix);
}
}
// disable fixed background
if (!options.fixedBackground && !isExcluded) {
body.style.backgroundAttachment = 'scroll';
html.style.backgroundAttachment = 'scroll';
}
}
/**
* Removes event listeners and other traces left on the page.
*/
function cleanup() {
observer && observer.disconnect();
removeEvent(wheelEvent, wheel);
removeEvent('mousedown', mousedown);
removeEvent('keydown', keydown);
removeEvent('resize', refreshSize);
removeEvent('load', init);
}
/************************************************
* SCROLLING
************************************************/
var que = [];
var pending = false;
var lastScroll = Date.now();
/**
* Pushes scroll actions to the scrolling queue.
*/
function scrollArray(elem, left, top) {
directionCheck(left, top);
if (options.accelerationMax != 1) {
var now = Date.now();
var elapsed = now - lastScroll;
if (elapsed < options.accelerationDelta) {
var factor = (1 + (50 / elapsed)) / 2;
if (factor > 1) {
factor = Math.min(factor, options.accelerationMax);
left *= factor;
top *= factor;
}
}
lastScroll = Date.now();
}
// push a scroll command
que.push({
x: left,
y: top,
lastX: (left < 0) ? 0.99 : -0.99,
lastY: (top < 0) ? 0.99 : -0.99,
start: Date.now()
});
// don't act if there's a pending queue
if (pending) {
return;
}
var scrollRoot = getScrollRoot();
var isWindowScroll = (elem === scrollRoot || elem === document.body);
// if we haven't already fixed the behavior,
// and it needs fixing for this sesh
if (elem.$scrollBehavior == null && isScrollBehaviorSmooth(elem)) {
elem.$scrollBehavior = elem.style.scrollBehavior;
elem.style.scrollBehavior = 'auto';
}
var step = function (time) {
var now = Date.now();
var scrollX = 0;
var scrollY = 0;
for (var i = 0; i < que.length; i++) {
var item = que[i];
var elapsed = now - item.start;
var finished = (elapsed >= options.animationTime);
// scroll position: [0, 1]
var position = (finished) ? 1 : elapsed / options.animationTime;
// easing [optional]
if (options.pulseAlgorithm) {
position = pulse(position);
}
// only need the difference
var x = (item.x * position - item.lastX) >> 0;
var y = (item.y * position - item.lastY) >> 0;
// add this to the total scrolling
scrollX += x;
scrollY += y;
// update last values
item.lastX += x;
item.lastY += y;
// delete and step back if it's over
if (finished) {
que.splice(i, 1); i--;
}
}
// scroll left and top
if (isWindowScroll) {
window.scrollBy(scrollX, scrollY);
}
else {
if (scrollX) elem.scrollLeft += scrollX;
if (scrollY) elem.scrollTop += scrollY;
}
// clean up if there's nothing left to do
if (!left && !top) {
que = [];
}
if (que.length) {
requestFrame(step, elem, (1000 / options.frameRate + 1));
} else {
pending = false;
// restore default behavior at the end of scrolling sesh
if (elem.$scrollBehavior != null) {
elem.style.scrollBehavior = elem.$scrollBehavior;
elem.$scrollBehavior = null;
}
}
};
// start a new queue of actions
requestFrame(step, elem, 0);
pending = true;
}
/***********************************************
* EVENTS
***********************************************/
/**
* Mouse wheel handler.
* @param {Object} event
*/
function wheel(event) {
if (!initDone) {
init();
}
var target = event.target;
// leave early if default action is prevented
// or it's a zooming event with CTRL
if (event.defaultPrevented || event.ctrlKey) {
return true;
}
// leave embedded content alone (flash & pdf)
if (isNodeName(activeElement, 'embed') ||
(isNodeName(target, 'embed') && /\.pdf/i.test(target.src)) ||
isNodeName(activeElement, 'object') ||
target.shadowRoot) {
return true;
}
var deltaX = -event.wheelDeltaX || event.deltaX || 0;
var deltaY = -event.wheelDeltaY || event.deltaY || 0;
if (isMac) {
if (event.wheelDeltaX && isDivisible(event.wheelDeltaX, 120)) {
deltaX = -120 * (event.wheelDeltaX / Math.abs(event.wheelDeltaX));
}
if (event.wheelDeltaY && isDivisible(event.wheelDeltaY, 120)) {
deltaY = -120 * (event.wheelDeltaY / Math.abs(event.wheelDeltaY));
}
}
// use wheelDelta if deltaX/Y is not available
if (!deltaX && !deltaY) {
deltaY = -event.wheelDelta || 0;
}
// line based scrolling (Firefox mostly)
if (event.deltaMode === 1) {
deltaX *= 40;
deltaY *= 40;
}
var overflowing = overflowingAncestor(target);
// nothing to do if there's no element that's scrollable
if (!overflowing) {
// except Chrome iframes seem to eat wheel events, which we need to
// propagate up, if the iframe has nothing overflowing to scroll
if (isFrame && isChrome) {
// change target to iframe element itself for the parent frame
Object.defineProperty(event, "target", {value: window.frameElement});
return parent.wheel(event);
}
return true;
}
// check if it's a touchpad scroll that should be ignored
if (isTouchpad(deltaY)) {
return true;
}
// scale by step size
// delta is 120 most of the time
// synaptics seems to send 1 sometimes
if (Math.abs(deltaX) > 1.2) {
deltaX *= options.stepSize / 120;
}
if (Math.abs(deltaY) > 1.2) {
deltaY *= options.stepSize / 120;
}
scrollArray(overflowing, deltaX, deltaY);
event.preventDefault();
scheduleClearCache();
}
/**
* Keydown event handler.
* @param {Object} event
*/
function keydown(event) {
var target = event.target;
var modifier = event.ctrlKey || event.altKey || event.metaKey ||
(event.shiftKey && event.keyCode !== key.spacebar);
// our own tracked active element could've been removed from the DOM
if (!document.body.contains(activeElement)) {
activeElement = document.activeElement;
}
// do nothing if user is editing text
// or using a modifier key (except shift)
// or in a dropdown
// or inside interactive elements
var inputNodeNames = /^(textarea|select|embed|object)$/i;
var buttonTypes = /^(button|submit|radio|checkbox|file|color|image)$/i;
if ( event.defaultPrevented ||
inputNodeNames.test(target.nodeName) ||
isNodeName(target, 'input') && !buttonTypes.test(target.type) ||
isNodeName(activeElement, 'video') ||
isInsideYoutubeVideo(event) ||
target.isContentEditable ||
modifier ) {
return true;
}
// [spacebar] should trigger button press, leave it alone
if ((isNodeName(target, 'button') ||
isNodeName(target, 'input') && buttonTypes.test(target.type)) &&
event.keyCode === key.spacebar) {
return true;
}
// [arrwow keys] on radio buttons should be left alone
if (isNodeName(target, 'input') && target.type == 'radio' &&
arrowKeys[event.keyCode]) {
return true;
}
var shift, x = 0, y = 0;
var overflowing = overflowingAncestor(activeElement);
if (!overflowing) {
// Chrome iframes seem to eat key events, which we need to
// propagate up, if the iframe has nothing overflowing to scroll
return (isFrame && isChrome) ? parent.keydown(event) : true;
}
var clientHeight = overflowing.clientHeight;
if (overflowing == document.body) {
clientHeight = window.innerHeight;
}
switch (event.keyCode) {
case key.up:
y = -options.arrowScroll;
break;
case key.down:
y = options.arrowScroll;
break;
case key.spacebar: // (+ shift)
shift = event.shiftKey ? 1 : -1;
y = -shift * clientHeight * 0.9;
break;
case key.pageup:
y = -clientHeight * 0.9;
break;
case key.pagedown:
y = clientHeight * 0.9;
break;
case key.home:
if (overflowing == document.body && document.scrollingElement)
overflowing = document.scrollingElement;
y = -overflowing.scrollTop;
break;
case key.end:
var scroll = overflowing.scrollHeight - overflowing.scrollTop;
var scrollRemaining = scroll - clientHeight;
y = (scrollRemaining > 0) ? scrollRemaining + 10 : 0;
break;
case key.left:
x = -options.arrowScroll;
break;
case key.right:
x = options.arrowScroll;
break;
default:
return true; // a key we don't care about
}
scrollArray(overflowing, x, y);
event.preventDefault();
scheduleClearCache();
}
/**
* Mousedown event only for updating activeElement
*/
function mousedown(event) {
activeElement = event.target;
}
/***********************************************
* OVERFLOW
***********************************************/
var uniqueID = (function () {
var i = 0;
return function (el) {
return el.uniqueID || (el.uniqueID = i++);
};
})();
var cacheX = {}; // cleared out after a scrolling session
var cacheY = {}; // cleared out after a scrolling session
var clearCacheTimer;
var smoothBehaviorForElement = {};
//setInterval(function () { cache = {}; }, 10 * 1000);
function scheduleClearCache() {
clearTimeout(clearCacheTimer);
clearCacheTimer = setInterval(function () {
cacheX = cacheY = smoothBehaviorForElement = {};
}, 1*1000);
}
function setCache(elems, overflowing, x) {
var cache = x ? cacheX : cacheY;
for (var i = elems.length; i--;)
cache[uniqueID(elems[i])] = overflowing;
return overflowing;
}
function getCache(el, x) {
return (x ? cacheX : cacheY)[uniqueID(el)];
}
// (body) (root)
// | hidden | visible | scroll | auto |
// hidden | no | no | YES | YES |
// visible | no | YES | YES | YES |
// scroll | no | YES | YES | YES |
// auto | no | YES | YES | YES |
function overflowingAncestor(el) {
var elems = [];
var body = document.body;
var rootScrollHeight = root.scrollHeight;
do {
var cached = getCache(el, false);
if (cached) {
return setCache(elems, cached);
}
elems.push(el);
if (rootScrollHeight === el.scrollHeight) {
var topOverflowsNotHidden = overflowNotHidden(root) && overflowNotHidden(body);
var isOverflowCSS = topOverflowsNotHidden || overflowAutoOrScroll(root);
if (isFrame && isContentOverflowing(root) ||
!isFrame && isOverflowCSS) {
return setCache(elems, getScrollRoot());
}
} else if (isContentOverflowing(el) && overflowAutoOrScroll(el)) {
return setCache(elems, el);
}
} while ((el = el.parentElement));
}
function isContentOverflowing(el) {
return (el.clientHeight + 10 < el.scrollHeight);
}
// typically for <body> and <html>
function overflowNotHidden(el) {
var overflow = getComputedStyle(el, '').getPropertyValue('overflow-y');
return (overflow !== 'hidden');
}
// for all other elements
function overflowAutoOrScroll(el) {
var overflow = getComputedStyle(el, '').getPropertyValue('overflow-y');
return (overflow === 'scroll' || overflow === 'auto');
}
// for all other elements
function isScrollBehaviorSmooth(el) {
var id = uniqueID(el);
if (smoothBehaviorForElement[id] == null) {
var scrollBehavior = getComputedStyle(el, '')['scroll-behavior'];
smoothBehaviorForElement[id] = ('smooth' == scrollBehavior);
}
return smoothBehaviorForElement[id];
}
/***********************************************
* HELPERS
***********************************************/
function addEvent(type, fn, arg) {
window.addEventListener(type, fn, arg || false);
}
function removeEvent(type, fn, arg) {
window.removeEventListener(type, fn, arg || false);
}
function isNodeName(el, tag) {
return el && (el.nodeName||'').toLowerCase() === tag.toLowerCase();
}
function directionCheck(x, y) {
x = (x > 0) ? 1 : -1;
y = (y > 0) ? 1 : -1;
if (direction.x !== x || direction.y !== y) {
direction.x = x;
direction.y = y;
que = [];
lastScroll = 0;
}
}
if (window.localStorage && localStorage.SS_deltaBuffer) {
try { // #46 Safari throws in private browsing for localStorage
deltaBuffer = localStorage.SS_deltaBuffer.split(',');
} catch (e) { }
}
function isTouchpad(deltaY) {
if (!deltaY) return;
if (!deltaBuffer.length) {
deltaBuffer = [deltaY, deltaY, deltaY];
}
deltaY = Math.abs(deltaY);
deltaBuffer.push(deltaY);
deltaBuffer.shift();
clearTimeout(deltaBufferTimer);
deltaBufferTimer = setTimeout(function () {
try { // #46 Safari throws in private browsing for localStorage
localStorage.SS_deltaBuffer = deltaBuffer.join(',');
} catch (e) { }
}, 1000);
var dpiScaledWheelDelta = deltaY > 120 && allDeltasDivisableBy(deltaY); // win64
return !allDeltasDivisableBy(120) && !allDeltasDivisableBy(100) && !dpiScaledWheelDelta;
}
function isDivisible(n, divisor) {
return (Math.floor(n / divisor) == n / divisor);
}
function allDeltasDivisableBy(divisor) {
return (isDivisible(deltaBuffer[0], divisor) &&
isDivisible(deltaBuffer[1], divisor) &&
isDivisible(deltaBuffer[2], divisor));
}
function isInsideYoutubeVideo(event) {
var elem = event.target;
var isControl = false;
if (document.URL.indexOf ('www.youtube.com/watch') != -1) {
do {
isControl = (elem.classList &&
elem.classList.contains('html5-video-controls'));
if (isControl) break;
} while ((elem = elem.parentNode));
}
return isControl;
}
var requestFrame = (function () {
return (window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function (callback, element, delay) {
window.setTimeout(callback, delay || (1000/60));
});
})();
var MutationObserver = (window.MutationObserver ||
window.WebKitMutationObserver ||
window.MozMutationObserver);
var getScrollRoot = (function() {
var SCROLL_ROOT = document.scrollingElement;
return function() {
if (!SCROLL_ROOT) {
var dummy = document.createElement('div');
dummy.style.cssText = 'height:10000px;width:1px;';
document.body.appendChild(dummy);
var bodyScrollTop = document.body.scrollTop;
var docElScrollTop = document.documentElement.scrollTop;
window.scrollBy(0, 3);
if (document.body.scrollTop != bodyScrollTop)
(SCROLL_ROOT = document.body);
else
(SCROLL_ROOT = document.documentElement);
window.scrollBy(0, -3);
document.body.removeChild(dummy);
}
return SCROLL_ROOT;
};
})();
/***********************************************
* PULSE (by Michael Herf)
***********************************************/
/**
* Viscous fluid with a pulse for part and decay for the rest.
* - Applies a fixed force over an interval (a damped acceleration), and
* - Lets the exponential bleed away the velocity over a longer interval
* - Michael Herf, http://stereopsis.com/stopping/
*/
function pulse_(x) {
var val, start, expx;
// test
x = x * options.pulseScale;
if (x < 1) { // acceleartion
val = x - (1 - Math.exp(-x));
} else { // tail
// the previous animation ended here:
start = Math.exp(-1);
// simple viscous drag
x -= 1;
expx = 1 - Math.exp(-x);
val = start + (expx * (1 - start));
}
return val * options.pulseNormalize;
}
function pulse(x) {
if (x >= 1) return 1;
if (x <= 0) return 0;
if (options.pulseNormalize == 1) {
options.pulseNormalize /= pulse_(1);
}
return pulse_(x);
}
/***********************************************
* FIRST RUN
***********************************************/
var userAgent = window.navigator.userAgent;
var isEdge = /Edge/.test(userAgent); // thank you MS
var isChrome = /chrome/i.test(userAgent) && !isEdge;
var isSafari = /safari/i.test(userAgent) && !isEdge;
var isMobile = /mobile/i.test(userAgent);
var isIEWin7 = /Windows NT 6.1/i.test(userAgent) && /rv:11/i.test(userAgent);
var isOldSafari = isSafari && (/Version\/8/i.test(userAgent) || /Version\/9/i.test(userAgent));
var isEnabledForBrowser = (isChrome || isSafari || isIEWin7) && !isMobile;
var supportsPassive = false;
try {
window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
get: function () {
supportsPassive = true;
}
}));
} catch(e) {}
var wheelOpt = supportsPassive ? { passive: false } : false;
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';
if (wheelEvent && isEnabledForBrowser) {
addEvent(wheelEvent, wheel, wheelOpt);
addEvent('mousedown', mousedown);
addEvent('load', init);
}
/***********************************************
* PUBLIC INTERFACE
***********************************************/
function SmoothScroll(optionsToSet) {
for (var key in optionsToSet)
if (defaultOptions.hasOwnProperty(key))
options[key] = optionsToSet[key];
}
SmoothScroll.destroy = cleanup;
if (window.SmoothScrollOptions) // async API
SmoothScroll(window.SmoothScrollOptions);
if (typeof define === 'function' && define.amd)
define(function() {
return SmoothScroll;
});
else if ('object' == typeof exports)
module.exports = SmoothScroll;
else
window.SmoothScroll = SmoothScroll;
})();

View File

@@ -0,0 +1,9 @@
jQuery(document).ready(function($) {
"use strict";
$( "a:contains('import-demo-full-custom')" ).parent().remove();
$("#import-content").change(function() {
var id = $(this).children(":selected").attr("id");
$('#import-link-value').val(id);
});
$("#vc_settings-templatera #submit_btn").attr('value', 'Import ekko Templates');
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,645 @@
// ------------------------------------------------------------------------
// Check if element is in ViewPort
// ------------------------------------------------------------------------
(function($) {
"use strict";
$.belowthefold = function(element, settings) {
var fold = $(window).height() + $(window).scrollTop();
return fold <= $(element).offset().top - settings.threshold;
};
$.abovethetop = function(element, settings) {
var top = $(window).scrollTop();
return top >= $(element).offset().top + $(element).height() - settings.threshold;
};
$.rightofscreen = function(element, settings) {
var fold = $(window).width() + $(window).scrollLeft();
return fold <= $(element).offset().left - settings.threshold;
};
$.leftofscreen = function(element, settings) {
var left = $(window).scrollLeft();
return left >= $(element).offset().left + $(element).width() - settings.threshold;
};
$.inviewport = function(element, settings) {
return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
};
$.extend($.expr[':'], {
"below-the-fold": function(a, i, m) {
return $.belowthefold(a, {
threshold: 0
});
},
"above-the-top": function(a, i, m) {
return $.abovethetop(a, {
threshold: 0
});
},
"left-of-screen": function(a, i, m) {
return $.leftofscreen(a, {
threshold: 0
});
},
"right-of-screen": function(a, i, m) {
return $.rightofscreen(a, {
threshold: 0
});
},
"in-viewport": function(a, i, m) {
return $.inviewport(a, {
threshold: 0
});
}
});
// ------------------------------------------------------------------------
// Preload Effect
// ------------------------------------------------------------------------
$(window).load(function() {
"use strict";
$('body').removeClass('fade-in');
});
window.addEventListener("beforeunload", function () {
$("body a[href]").click(function(){
var $anchor = $(this);
// Don't fade for links that open in new window
if ( $anchor.attr('target') && $anchor.attr('target').indexOf('_blank') >=0 ) {
return;
}
// Don't fade for email
if ( $anchor.attr('href').indexOf('mailto:') >=0 ) {
return;
}
// Don't fade for telephone links
if ( $anchor.attr('href').indexOf('tel:') >=0 ) {
return;
}
// Don't fade for links to anchor tags
if ( $anchor.attr('href').indexOf('#') >=0 ) {
return;
}
// Fade out
document.body.classList.add("fade-out");
});
});
$(document).ready(function() {
"use strict";
$(".wpb_wrapper:empty").parent().addClass('hide-on-mobile');
$('.parallax-overlay').each(function() {
var size = $(this).attr('data-vc-kd-parallax');
var height = $(this).closest('.kd_vc_parallax').innerHeight();
$(this).css('height', size * height + 'px');
});
if ($('.entry-header .breadcrumbs').length > 0) {
var str = $(".entry-header .breadcrumbs").html();
$(".entry-header .breadcrumbs").html(str.replace(/&gt;/g, '<span class="fa fa-angle-right"></span>'));
}
// ------------------------------------------------------------------------
// 3rd level menu off screen
// ------------------------------------------------------------------------
$(".navbar-nav .dropdown").on("mouseover", function () {
var dropdown = $(this).find('.dropdown-menu');
var off = dropdown.offset();
var l = off.left;
var w = dropdown.width();
var docW = $(window).width();
var isEntirelyVisible = (l + w < docW);
if (!isEntirelyVisible) {
console.log(l + w - docW);
dropdown.addClass('align-menu-right');
}
});
$(window).on('resize', function(){
$(".dropdown-menu").removeClass('align-menu-right');
});
// ------------------------------------------------------------------------
// Mega menu effects
// ------------------------------------------------------------------------
if ($('.transparent-navigation').length > 0) {
$( ".navbar-nav .mega-menu" ).hover(
function () {
$('body').removeClass( "transparent-navigation" );
},
function () {
$('body').addClass( "transparent-navigation" );
}
);
}
$( ".navbar-nav .mega-menu" ).hover(
function () {
$('.navbar-nav').addClass( "no-transition" );
},
function () {
$('.navbar-nav').removeClass( "no-transition" );
}
);
if ($('#single-page').length > 0) {
$('body').addClass('single-post');
}
// ------------------------------------------------------------------------
// Side panel
// ------------------------------------------------------------------------
var $html_wrapper = $('html'),
scrollDisabled = false,
scrollTop;
function scrollDisable() {
if (scrollDisabled) {
return;
}
scrollTop = $(window).scrollTop();
$html_wrapper.addClass('scrollLock')
.css({
top: -1 * scrollTop
});
scrollDisabled = true;
}
function scrollEnable() {
if (!scrollDisabled) {
return;
}
$html_wrapper.removeClass('scrollLock');
$(window).scrollTop(scrollTop);
scrollDisabled = false;
}
if ($(".panel-trigger-btn").length) {
$(".panel-trigger-btn").click(function() {
scrollDisable();
$(".kd-side-panel, .panel-screen-overlay").addClass("active");
$(".navbar.navbar-default.fixed-menu").addClass("panel-enabled");
});
$(".kd-side-panel .panel-close").click(function() {
scrollEnable();
$(".kd-side-panel, .panel-screen-overlay").removeClass("active");
$(".navbar.navbar-default.fixed-menu").removeClass("panel-enabled");
});
$('.panel-screen-overlay').on("click", function(){
$(".kd-side-panel .panel-close").trigger("click");
});
}
// ------------------------------------------------------------------------
// Live Preview Customizer
// ------------------------------------------------------------------------
$("#customizer .switcher, .demo-switcher ").click(function() {
$("#customizer").toggleClass('active');
});
// ------------------------------------------------------------------------
// Topbar search
// ------------------------------------------------------------------------
$(".topbar-search .toggle-search").click(function() {
$(".topbar-search .topbar-search-container").toggleClass('active');
$(this).toggleClass('fa-times');
});
function draw() {
requestAnimationFrame(draw);
scrollEvent();
}
draw();
// ------------------------------------------------------------------------
// Fixed Footer
// ------------------------------------------------------------------------
if ($("#footer.fixed").length) {
var footerHeight = $("#footer.fixed").height();
$("#wrapper").css("margin-bottom", footerHeight);
}
// ------------------------------------------------------------------------
// Custom Search Field
// ------------------------------------------------------------------------
$("#s").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for=" + eId + "]")).length == 1) {
$(elem).attr("placeholder", 'Search');
$(label).remove();
}
});
$(".search-submit, .blog_widget #bbp_search_submit").val('');
$(".woocommerce-product-search input[type='submit']").val('');
// ------------------------------------------------------------------------
// Contact Form Buttons
// ------------------------------------------------------------------------
$(document).on("click", ".section .wpcf7-not-valid-tip,.section .wpcf7-mail-sent-ok, .blog-header-form .wpcf7-not-valid-tip, .blog-header-form .wpcf7-mail-sent-ok, .subscribe-form header .wpcf7-response-output, .modal-content-inner .wpcf7-not-valid-tip, .kd-side-panel .wpcf7-not-valid-tip", function() {
$(this).fadeOut();
});
// ------------------------------------------------------------------------
// Reset reCaptcha for modal window
// ------------------------------------------------------------------------
if ($('.wpcf7-recaptcha').length > 0) {
$(document).on("click", ".modal-menu-item", function() {
grecaptcha.reset();
});
}
// ------------------------------------------------------------------------
// Blog video cover
// ------------------------------------------------------------------------
$('.background-video-image').each(function() {
var imgSrc = $(this).children('img').attr('src');
$(this).css('background', 'url("' + imgSrc + '")').css('background-position', 'initial');
});
$('.video-cover').each(function(){
var videoCover = $(this);
if(videoCover.find('iframe').length){
videoCover.find('iframe').attr('data-src', videoCover.find('iframe').attr('src'));
videoCover.find('iframe').attr('src','');
}
});
$('.video-cover .play-video').on("click", function(){
var playIcon = $(this);
var videoCover = playIcon.closest('.video-cover');
if(videoCover.find('video').length){
var video = videoCover.find('video').get(0);
videoCover.addClass('show-video');
video.play();
return false;
} else if(videoCover.find('iframe').length){
var iframe = videoCover.find('iframe');
var videoSrc = iframe.attr('data-src');
var videoSrcAuto = videoSrc.replace('?feature=oembed', '?autoplay=1');
iframe.attr('src', videoSrcAuto);
videoCover.addClass('show-video');
return false;
}
});
// ------------------------------------------------------------------------
// Main Menu One Page Links
// ------------------------------------------------------------------------
$( "<span class='mobile-dropdown'></span>" ).appendTo( $( ".navbar-nav .menu-item-has-children" ) );
$(".navbar-nav .menu-item-has-children .mobile-dropdown").click(function() {
$(this).closest(".menu-item-has-children").toggleClass('mobile-visible');
});
// ------------------------------------------------------------------------
// Bbpress Breadcrumbs
// ------------------------------------------------------------------------
if ($('.bbp-breadcrumb').length > 0) {
$( '.bbp-breadcrumb' ).appendTo( $(".bbpress-breadcrumbs"));
}
// ------------------------------------------------------------------------
// Main Smooth Scroll and Scroll Spy
// ------------------------------------------------------------------------
$('.navbar-collapse ul li a, .navbar-collapse .modal-menu-item.scroll-section').click(function() {
$('.navbar-toggle:visible').click();
});
$(function() {
$('.navbar-nav .one-page-link a, .footer_widget .menu li a, .scroll-section a, .btn-smooth-scroll, .modal-menu-item.scroll-section, .demo-button').bind('click', function(event) {
if ($("body").hasClass("home")) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 90
}, 1500, 'easeInOutExpo');
event.preventDefault();
}
});
});
$(function() {
$('.portfolio-demo-button').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 250
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
$('body').scrollspy({
offset: 100,
target: '.navbar-fixed-top'
});
// ------------------------------------------------------------------------
// WPGlobus compatibility - NavWalker conflict
// ------------------------------------------------------------------------
if ($('.wpglobus-selector-link').length > 0) {
$('.wpglobus-selector-link .dropdown-menu').addClass('sub-menu');
}
// ------------------------------------------------------------------------
// Back to top button
// ------------------------------------------------------------------------
$(window).bind("scroll", function() {
if ($(window).scrollTop() > $(window).height()) {
$('.back-to-top').addClass('active');
}
if ($(window).scrollTop() < $(window).height()) {
$('.back-to-top').removeClass('active');
}
});
$('.back-to-top').click(function(event) {
event.preventDefault();
$('html, body').animate({
scrollTop: 0
}, 500);
return false;
});
});
// ------------------------------------------------------------------------
// Blog image carousel
// ------------------------------------------------------------------------
if (jQuery().owlCarousel) {
jQuery('.post .entry-gallery .gallery').addClass('post-gallery-carousel');
jQuery('.single-post .gallery').addClass('post-gallery-carousel');
}
if ($(".post .entry-gallery .post-gallery-carousel").length || $(".single-post .post-gallery-carousel").length) {
$(".post .entry-gallery .post-gallery-carousel, .single-post .post-gallery-carousel").owlCarousel({
stageClass: "owl-wrapper",
stageOuterClass: "owl-wrapper-outer",
loadedClass: "owl-carousel",
items: 1,
dots: true,
dotsSpeed: 500,
dotsEach: true,
});
}
// ------------------------------------------------------------------------
// Portfolio & Blog related posts slider
// ------------------------------------------------------------------------
if ($(".related-content.owlslider-related-posts").length) {
$(".related-content.owlslider-related-posts").owlCarousel({
stageClass: "owl-wrapper",
stageOuterClass: "owl-wrapper-outer",
loadedClass: "owl-carousel",
responsive:{
0:{
items: 1,
nav: false,
dots: true,
},
767:{
items: 3,
nav: false,
dots: true,
},
960:{
nav: true,
navSpeed: 500,
dots: false,
}
},
nav: true,
navSpeed: 500,
dots: false,
rewind: true,
loop: true,
});
}
// ------------------------------------------------------------------------
// Portfolio photoSwipe init
// ------------------------------------------------------------------------
var PhotoSwipe = window.PhotoSwipe,
PhotoSwipeUI_Default = window.PhotoSwipeUI_Default;
$('body').on('click', 'a[data-size]', function(e) {
if (!PhotoSwipe || !PhotoSwipeUI_Default) {
return;
}
e.preventDefault();
openPhotoSwipe(this);
});
var parseThumbnailElements = function(gallery, el) {
var elements = $(gallery).find('a[data-size]').has('img'),
galleryItems = [],
index;
elements.each(function(i) {
var $el = $(this),
size = $el.data('size').split('x'),
caption;
if ($el.next().is('.wp-caption-text')) {
// image with caption
caption = $el.next().text();
} else if ($el.parent().next().is('.wp-caption-text')) {
// gallery icon with caption
caption = $el.parent().next().text();
} else {
caption = $el.attr('title');
}
galleryItems.push({
src: $el.attr('href'),
w: parseInt(size[0], 10),
h: parseInt(size[1], 10),
title: caption,
msrc: $el.find('img').attr('src'),
el: $el
});
if (el === $el.get(0)) {
index = i;
}
});
return [galleryItems, parseInt(index, 10)];
};
var openPhotoSwipe = function(element, disableAnimation) {
var pswpElement = $('.pswp').get(0),
galleryElement = $(element).parents('.gallery, .hentry, .main, body').first(),
gallery,
options,
items, index;
items = parseThumbnailElements(galleryElement, element);
index = items[1];
items = items[0];
options = {
index: index,
getThumbBoundsFn: function(index) {
var image = items[index].el.find('img'),
offset = image.offset();
return {
x: offset.left,
y: offset.top,
w: image.width()
};
},
showHideOpacity: true,
history: false
};
if (disableAnimation) {
options.showAnimationDuration = 0;
}
// Pass data to PhotoSwipe and initialize it
gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
};
// ------------------------------------------------------------------------
// Classie Script
// ------------------------------------------------------------------------
(function(window) {
function classReg(className) {
return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}
var hasClass, addClass, removeClass;
if ('classList' in document.documentElement) {
hasClass = function(elem, c) {
return elem.classList.contains(c);
};
addClass = function(elem, c) {
elem.classList.add(c);
};
removeClass = function(elem, c) {
elem.classList.remove(c);
};
} else {
hasClass = function(elem, c) {
return classReg(c).test(elem.className);
};
addClass = function(elem, c) {
if (!hasClass(elem, c)) {
elem.className = elem.className + ' ' + c;
}
};
removeClass = function(elem, c) {
elem.className = elem.className.replace(classReg(c), ' ');
};
}
function toggleClass(elem, c) {
var fn = hasClass(elem, c) ? removeClass : addClass;
fn(elem, c);
}
var classie = {
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
toggleClass: toggleClass,
has: hasClass,
add: addClass,
remove: removeClass,
toggle: toggleClass
};
if (typeof define === 'function' && define.amd) {
define(classie);
} else {
window.classie = classie;
}
})(window);
// ------------------------------------------------------------------------
// Animated Header
// ------------------------------------------------------------------------
var cbpAnimatedHeader = (function() {
var docElem = document.documentElement,
header = document.querySelector('.navbar-default'),
didScroll = false,
changeHeaderOn = 50;
function init() {
window.addEventListener('scroll', function(event) {
if (!didScroll) {
didScroll = true;
setTimeout(scrollPage, 100);
}
}, false);
window.addEventListener('load', function(event) {
if (!didScroll) {
didScroll = true;
setTimeout(scrollPage, 100);
}
}, false);
}
function scrollPage() {
var sy = scrollY();
if (sy >= changeHeaderOn) {
classie.add(header, 'navbar-shrink');
$(".topbar-search-container").removeClass('active');
$(".topbar-search .toggle-search").removeClass('fa-times');
} else {
if (!$(".panel-screen-overlay.active").length) {
classie.remove(header, 'navbar-shrink');
}
}
didScroll = false;
}
function scrollY() {
return window.pageYOffset || docElem.scrollTop;
}
if (!$(header).hasClass("fixed-menu")) {
init();
}
})();
})(jQuery);
function scrollEvent() {
if (!is_touch_device()) {
viewportTop = jQuery(window).scrollTop();
if (jQuery(window).width())
jQuery('.parallax-overlay').each(function() {
elementOffset = jQuery(this).offset().top;
var size = jQuery(this).attr('data-vc-kd-parallax');
distance = (elementOffset - viewportTop) * ( 1 - size );
jQuery(this).css('transform', 'translate3d(0, ' + distance + 'px,0)');
});
jQuery('.kd-parallax-image .vc_figure img').each(function() {
elementOffset = jQuery(this).offset().top;
distance = (elementOffset - viewportTop) * -0.5;
jQuery(this).css('transform', 'translateY(' + distance + 'px)');
});
}
}
function is_touch_device() {
return 'ontouchstart' in window || 'onmsgesturechange' in window;
}

View File

@@ -0,0 +1,33 @@
(function($){
"use strict";
function get_cart(){
if(window.wc_add_to_cart_params!=undefined){
$.post({
url: wc_add_to_cart_params.ajax_url,
dataType: 'JSON',
data: {action: 'woomenucart_ajax', nonce: keydesign_menucart_ajax.nonce},
success: function(data, textStatus, XMLHttpRequest){
$('.keydesign-cart-dropdown').html(data.cart);
if(data.articles < 1) { $('.keydesign-cart-dropdown').html('<li><span class="empty-cart">Your cart is currently empty</span></li>'); }
if(data!='') {
if($('.keydesign-cart .badge, .mobile-shopping-cart .badge').length){
if(data.articles>0){
$('.keydesign-cart .badge, .mobile-shopping-cart .badge').html(data.articles);
$('.keydesign-cart .badge, .mobile-shopping-cart .badge').show();
} else {
$('.keydesign-cart .badge, .mobile-shopping-cart .badge').hide();
}
} else $('.keydesign-cart .cart-icon-container').append('<span class="badge">'+data.articles+'</span>');
}
}
});
}
}
$(document).ready(function(){
$('body').bind("added_to_cart",get_cart);
$('body').bind("wc_fragments_refreshed",get_cart);
});
})(jQuery);