Initial COmmit...alr did some stuff lol
This commit is contained in:
10
js/ScrollTrigger.min.js
vendored
Normal file
10
js/ScrollTrigger.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
790
js/SmoothScroll.js
Normal file
790
js/SmoothScroll.js
Normal file
@@ -0,0 +1,790 @@
|
||||
//
|
||||
// SmoothScroll for websites v1.4.10 (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
|
||||
var tp = !allDeltasDivisableBy(120) && !allDeltasDivisableBy(100) && !dpiScaledWheelDelta;
|
||||
if (deltaY < 50) return true;
|
||||
return tp;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
})();
|
||||
33
js/SplitText.js
Normal file
33
js/SplitText.js
Normal file
File diff suppressed because one or more lines are too long
4494
js/bootstrap.js
vendored
Normal file
4494
js/bootstrap.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
js/bootstrap.js.map
Normal file
1
js/bootstrap.js.map
Normal file
File diff suppressed because one or more lines are too long
7
js/bootstrap.min.js
vendored
Normal file
7
js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
js/bootstrap.min.js.map
Normal file
1
js/bootstrap.min.js.map
Normal file
File diff suppressed because one or more lines are too long
333
js/function.js
Normal file
333
js/function.js
Normal file
@@ -0,0 +1,333 @@
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
var $window = $(window);
|
||||
var $body = $('body');
|
||||
|
||||
/* Preloader Effect */
|
||||
$window.on('load', function(){
|
||||
$(".preloader").fadeOut(600);
|
||||
});
|
||||
|
||||
/* Sticky Header */
|
||||
if($('.active-sticky-header').length){
|
||||
$window.on('resize', function(){
|
||||
setHeaderHeight();
|
||||
});
|
||||
|
||||
function setHeaderHeight(){
|
||||
$("header.main-header").css("height", $('header .header-sticky').outerHeight());
|
||||
}
|
||||
|
||||
$(window).on("scroll", function() {
|
||||
var fromTop = $(window).scrollTop();
|
||||
setHeaderHeight();
|
||||
var headerHeight = $('header .header-sticky').outerHeight()
|
||||
$("header .header-sticky").toggleClass("hide", (fromTop > headerHeight + 100));
|
||||
$("header .header-sticky").toggleClass("active", (fromTop > 600));
|
||||
});
|
||||
}
|
||||
|
||||
/* Slick Menu JS */
|
||||
$('#menu').slicknav({
|
||||
label : '',
|
||||
prependTo : '.responsive-menu'
|
||||
});
|
||||
|
||||
if($("a[href='#top']").length){
|
||||
$("a[href='#top']").click(function() {
|
||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/* Hero Slider Layout JS */
|
||||
const hero_slider_layout = new Swiper('.hero-slider-layout .swiper', {
|
||||
slidesPerView : 1,
|
||||
speed: 1000,
|
||||
spaceBetween: 0,
|
||||
loop: true,
|
||||
autoplay: {
|
||||
delay: 4000,
|
||||
},
|
||||
pagination: {
|
||||
el: '.hero-pagination',
|
||||
clickable: true,
|
||||
},
|
||||
});
|
||||
|
||||
/* Core Value Image Carousel JS */
|
||||
if ($('.core-value-slider').length) {
|
||||
const core_value_slider = new Swiper('.core-value-slider .swiper', {
|
||||
slidesPerView : 1,
|
||||
speed: 1000,
|
||||
spaceBetween: 10,
|
||||
loop: true,
|
||||
autoplay: {
|
||||
delay: 5000,
|
||||
},
|
||||
navigation: {
|
||||
nextEl: '.core-value-button-next',
|
||||
prevEl: '.core-value-button-prev',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/* Service Single Image Carousel JS */
|
||||
if ($('.service-single-slider').length) {
|
||||
const service_single_slider = new Swiper('.service-single-slider .swiper', {
|
||||
slidesPerView : 1,
|
||||
speed: 1000,
|
||||
spaceBetween: 10,
|
||||
loop: true,
|
||||
autoplay: {
|
||||
delay: 5000,
|
||||
},
|
||||
navigation: {
|
||||
nextEl: '.service-single-button-next',
|
||||
prevEl: '.service-single-button-prev',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/* Ministry Single Image Carousel JS */
|
||||
if ($('.ministry-single-slider').length) {
|
||||
const ministry_single_slider = new Swiper('.ministry-single-slider .swiper', {
|
||||
slidesPerView : 1,
|
||||
speed: 1000,
|
||||
spaceBetween: 10,
|
||||
loop: true,
|
||||
autoplay: {
|
||||
delay: 5000,
|
||||
},
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/* Skill Bar */
|
||||
if ($('.skills-progress-bar').length) {
|
||||
$('.skills-progress-bar').waypoint(function() {
|
||||
$('.skillbar').each(function() {
|
||||
$(this).find('.count-bar').animate({
|
||||
width:$(this).attr('data-percent')
|
||||
},2000);
|
||||
});
|
||||
},{
|
||||
offset: '50%'
|
||||
});
|
||||
}
|
||||
|
||||
/* Youtube Background Video JS */
|
||||
if ($('#herovideo').length) {
|
||||
var myPlayer = $("#herovideo").YTPlayer();
|
||||
}
|
||||
|
||||
/* Audio JS */
|
||||
const player = new Plyr('#player');
|
||||
|
||||
/* Init Counter */
|
||||
if ($('.counter').length) {
|
||||
$('.counter').counterUp({ delay: 6, time: 3000 });
|
||||
}
|
||||
|
||||
/* Image Reveal Animation */
|
||||
if ($('.reveal').length) {
|
||||
gsap.registerPlugin(ScrollTrigger);
|
||||
let revealContainers = document.querySelectorAll(".reveal");
|
||||
revealContainers.forEach((container) => {
|
||||
let image = container.querySelector("img");
|
||||
let tl = gsap.timeline({
|
||||
scrollTrigger: {
|
||||
trigger: container,
|
||||
toggleActions: "play none none none"
|
||||
}
|
||||
});
|
||||
tl.set(container, {
|
||||
autoAlpha: 1
|
||||
});
|
||||
tl.from(container, 1, {
|
||||
xPercent: -100,
|
||||
ease: Power2.out
|
||||
});
|
||||
tl.from(image, 1, {
|
||||
xPercent: 100,
|
||||
scale: 1,
|
||||
delay: -1,
|
||||
ease: Power2.out
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* Text Effect Animation */
|
||||
if ($('.text-anime-style-1').length) {
|
||||
let staggerAmount = 0.05,
|
||||
translateXValue = 0,
|
||||
delayValue = 0.5,
|
||||
animatedTextElements = document.querySelectorAll('.text-anime-style-1');
|
||||
|
||||
animatedTextElements.forEach((element) => {
|
||||
let animationSplitText = new SplitText(element, { type: "chars, words" });
|
||||
gsap.from(animationSplitText.words, {
|
||||
duration: 1,
|
||||
delay: delayValue,
|
||||
x: 20,
|
||||
autoAlpha: 0,
|
||||
stagger: staggerAmount,
|
||||
scrollTrigger: { trigger: element, start: "top 85%" },
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($('.text-anime-style-2').length) {
|
||||
let staggerAmount = 0.03,
|
||||
translateXValue = 20,
|
||||
delayValue = 0.1,
|
||||
easeType = "power2.out",
|
||||
animatedTextElements = document.querySelectorAll('.text-anime-style-2');
|
||||
|
||||
animatedTextElements.forEach((element) => {
|
||||
let animationSplitText = new SplitText(element, { type: "chars, words" });
|
||||
gsap.from(animationSplitText.chars, {
|
||||
duration: 1,
|
||||
delay: delayValue,
|
||||
x: translateXValue,
|
||||
autoAlpha: 0,
|
||||
stagger: staggerAmount,
|
||||
ease: easeType,
|
||||
scrollTrigger: { trigger: element, start: "top 85%"},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($('.text-anime-style-3').length) {
|
||||
let animatedTextElements = document.querySelectorAll('.text-anime-style-3');
|
||||
|
||||
animatedTextElements.forEach((element) => {
|
||||
//Reset if needed
|
||||
if (element.animation) {
|
||||
element.animation.progress(1).kill();
|
||||
element.split.revert();
|
||||
}
|
||||
|
||||
element.split = new SplitText(element, {
|
||||
type: "lines,words,chars",
|
||||
linesClass: "split-line",
|
||||
});
|
||||
gsap.set(element, { perspective: 400 });
|
||||
|
||||
gsap.set(element.split.chars, {
|
||||
opacity: 0,
|
||||
x: "50",
|
||||
});
|
||||
|
||||
element.animation = gsap.to(element.split.chars, {
|
||||
scrollTrigger: { trigger: element, start: "top 90%" },
|
||||
x: "0",
|
||||
y: "0",
|
||||
rotateX: "0",
|
||||
opacity: 1,
|
||||
duration: 1,
|
||||
ease: Back.easeOut,
|
||||
stagger: 0.02,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* Parallaxie js */
|
||||
var $parallaxie = $('.parallaxie');
|
||||
if($parallaxie.length && ($window.width() > 991))
|
||||
{
|
||||
if ($window.width() > 768) {
|
||||
$parallaxie.parallaxie({
|
||||
speed: 0.55,
|
||||
offset: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* Zoom Gallery screenshot */
|
||||
$('.gallery-items').magnificPopup({
|
||||
delegate: 'a',
|
||||
type: 'image',
|
||||
closeOnContentClick: false,
|
||||
closeBtnInside: false,
|
||||
mainClass: 'mfp-with-zoom',
|
||||
image: {
|
||||
verticalFit: true,
|
||||
},
|
||||
gallery: {
|
||||
enabled: true
|
||||
},
|
||||
zoom: {
|
||||
enabled: true,
|
||||
duration: 300, // don't foget to change the duration also in CSS
|
||||
opener: function(element) {
|
||||
return element.find('img');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Contact form validation */
|
||||
var $contactform = $("#contactForm");
|
||||
$contactform.validator({focus: false}).on("submit", function (event) {
|
||||
if (!event.isDefaultPrevented()) {
|
||||
event.preventDefault();
|
||||
submitForm();
|
||||
}
|
||||
});
|
||||
|
||||
function submitForm(){
|
||||
/* Initiate Variables With Form Content*/
|
||||
var fname = $("#fname").val();
|
||||
var lname = $("#lname").val();
|
||||
var email = $("#email").val();
|
||||
var phone = $("#phone").val();
|
||||
var message = $("#msg").val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "form-process.php",
|
||||
data: "fname=" + fname + "&lname=" + lname + "&email=" + email + "&phone=" + phone + "&message=" + message,
|
||||
success : function(text){
|
||||
if (text == "success"){
|
||||
formSuccess();
|
||||
} else {
|
||||
submitMSG(false,text);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function formSuccess(){
|
||||
$contactform[0].reset();
|
||||
submitMSG(true, "Message Sent Successfully!")
|
||||
}
|
||||
|
||||
function submitMSG(valid, msg){
|
||||
if(valid){
|
||||
var msgClasses = "h3 text-success";
|
||||
} else {
|
||||
var msgClasses = "h3 text-danger";
|
||||
}
|
||||
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
||||
}
|
||||
/* Contact form validation end */
|
||||
|
||||
/* Animated Wow Js */
|
||||
new WOW().init();
|
||||
|
||||
/* Popup Video */
|
||||
if ($('.popup-video').length) {
|
||||
$('.popup-video').magnificPopup({
|
||||
type: 'iframe',
|
||||
mainClass: 'mfp-fade',
|
||||
removalDelay: 160,
|
||||
preloader: false,
|
||||
fixedContentPos: true
|
||||
});
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
11
js/gsap.min.js
vendored
Normal file
11
js/gsap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
js/jquery-3.7.1.min.js
vendored
Normal file
2
js/jquery-3.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
js/jquery.counterup.min.js
vendored
Normal file
8
js/jquery.counterup.min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* jquery.counterup.js 1.0
|
||||
*
|
||||
* Copyright 2013, Benjamin Intal http://gambit.ph @bfintal
|
||||
* Released under the GPL v2 License
|
||||
*
|
||||
* Date: Nov 26, 2013
|
||||
*/!function(t){"use strict";t.fn.counterUp=function(e){var n=t.extend({time:400,delay:10},e);return this.each(function(){var e=t(this),u=n;e.waypoint({handler:function(){!function(){var t=[],n=u.time/u.delay,a=e.text(),r=/[0-9]+,[0-9]+/.test(a);a=a.replace(/,/g,"");/^[0-9]+$/.test(a);for(var o=/^[0-9]+\.[0-9]+$/.test(a),c=o?(a.split(".")[1]||[]).length:0,s=n;s>=1;s--){var i=parseInt(a/n*s);if(o&&(i=parseFloat(a/n*s).toFixed(c)),r)for(;/(\d+)(\d{3})/.test(i.toString());)i=i.toString().replace(/(\d+)(\d{3})/,"$1,$2");t.unshift(i)}e.data("counterup-nums",t),e.text("0");e.data("counterup-func",function(){e.text(e.data("counterup-nums").shift()),e.data("counterup-nums").length?setTimeout(e.data("counterup-func"),u.delay):(e.data("counterup-nums"),e.data("counterup-nums",null),e.data("counterup-func",null))}),setTimeout(e.data("counterup-func"),u.delay)}(),this.destroy()},offset:"100%"})})}}(jQuery);
|
||||
4
js/jquery.magnific-popup.min.js
vendored
Normal file
4
js/jquery.magnific-popup.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
9
js/jquery.mb.YTPlayer.min.js
vendored
Normal file
9
js/jquery.mb.YTPlayer.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
589
js/jquery.slicknav.js
Normal file
589
js/jquery.slicknav.js
Normal file
@@ -0,0 +1,589 @@
|
||||
/*!
|
||||
* SlickNav Responsive Mobile Menu v1.0.10
|
||||
* (c) 2016 Josh Cope
|
||||
* licensed under MIT
|
||||
*/
|
||||
;(function ($, document, window) {
|
||||
var
|
||||
// default settings object.
|
||||
defaults = {
|
||||
label: 'MENU',
|
||||
duplicate: true,
|
||||
duration: 200,
|
||||
easingOpen: 'swing',
|
||||
easingClose: 'swing',
|
||||
closedSymbol: '►',
|
||||
openedSymbol: '▼',
|
||||
prependTo: 'body',
|
||||
appendTo: '',
|
||||
parentTag: 'a',
|
||||
closeOnClick: false,
|
||||
allowParentLinks: false,
|
||||
nestedParentLinks: true,
|
||||
showChildren: false,
|
||||
removeIds: true,
|
||||
removeClasses: false,
|
||||
removeStyles: false,
|
||||
brand: '',
|
||||
animations: 'jquery',
|
||||
init: function () {},
|
||||
beforeOpen: function () {},
|
||||
beforeClose: function () {},
|
||||
afterOpen: function () {},
|
||||
afterClose: function () {}
|
||||
},
|
||||
mobileMenu = 'slicknav',
|
||||
prefix = 'slicknav';
|
||||
|
||||
Keyboard = {
|
||||
DOWN: 40,
|
||||
ENTER: 13,
|
||||
ESCAPE: 27,
|
||||
LEFT: 37,
|
||||
RIGHT: 39,
|
||||
SPACE: 32,
|
||||
TAB: 9,
|
||||
UP: 38,
|
||||
};
|
||||
|
||||
function Plugin(element, options) {
|
||||
this.element = element;
|
||||
|
||||
// jQuery has an extend method which merges the contents of two or
|
||||
// more objects, storing the result in the first object. The first object
|
||||
// is generally empty as we don't want to alter the default options for
|
||||
// future instances of the plugin
|
||||
this.settings = $.extend({}, defaults, options);
|
||||
|
||||
// Don't remove IDs by default if duplicate is false
|
||||
if (!this.settings.duplicate && !options.hasOwnProperty("removeIds")) {
|
||||
this.settings.removeIds = false;
|
||||
}
|
||||
|
||||
this._defaults = defaults;
|
||||
this._name = mobileMenu;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype.init = function () {
|
||||
var $this = this,
|
||||
menu = $(this.element),
|
||||
settings = this.settings,
|
||||
iconClass,
|
||||
menuBar;
|
||||
|
||||
// clone menu if needed
|
||||
if (settings.duplicate) {
|
||||
$this.mobileNav = menu.clone();
|
||||
} else {
|
||||
$this.mobileNav = menu;
|
||||
}
|
||||
|
||||
// remove IDs if set
|
||||
if (settings.removeIds) {
|
||||
$this.mobileNav.removeAttr('id');
|
||||
$this.mobileNav.find('*').each(function (i, e) {
|
||||
$(e).removeAttr('id');
|
||||
});
|
||||
}
|
||||
|
||||
// remove classes if set
|
||||
if (settings.removeClasses) {
|
||||
$this.mobileNav.removeAttr('class');
|
||||
$this.mobileNav.find('*').each(function (i, e) {
|
||||
$(e).removeAttr('class');
|
||||
});
|
||||
}
|
||||
|
||||
// remove styles if set
|
||||
if (settings.removeStyles) {
|
||||
$this.mobileNav.removeAttr('style');
|
||||
$this.mobileNav.find('*').each(function (i, e) {
|
||||
$(e).removeAttr('style');
|
||||
});
|
||||
}
|
||||
|
||||
// styling class for the button
|
||||
iconClass = prefix + '_icon';
|
||||
|
||||
if (settings.label === '') {
|
||||
iconClass += ' ' + prefix + '_no-text';
|
||||
}
|
||||
|
||||
if (settings.parentTag == 'a') {
|
||||
settings.parentTag = 'a href="#"';
|
||||
}
|
||||
|
||||
// create menu bar
|
||||
$this.mobileNav.attr('class', prefix + '_nav');
|
||||
menuBar = $('<div class="' + prefix + '_menu"></div>');
|
||||
if (settings.brand !== '') {
|
||||
var brand = $('<div class="' + prefix + '_brand">'+settings.brand+'</div>');
|
||||
$(menuBar).append(brand);
|
||||
}
|
||||
$this.btn = $(
|
||||
['<' + settings.parentTag + ' aria-haspopup="true" role="button" tabindex="0" class="' + prefix + '_btn ' + prefix + '_collapsed">',
|
||||
'<span class="' + prefix + '_menutxt">' + settings.label + '</span>',
|
||||
'<span class="' + iconClass + '">',
|
||||
'<span class="' + prefix + '_icon-bar"></span>',
|
||||
'<span class="' + prefix + '_icon-bar"></span>',
|
||||
'<span class="' + prefix + '_icon-bar"></span>',
|
||||
'</span>',
|
||||
'</' + settings.parentTag + '>'
|
||||
].join('')
|
||||
);
|
||||
$('.navbar-toggle').append($this.btn);
|
||||
if(settings.appendTo !== '') {
|
||||
$(settings.appendTo).append(menuBar);
|
||||
} else {
|
||||
$(settings.prependTo).prepend(menuBar);
|
||||
}
|
||||
menuBar.append($this.mobileNav);
|
||||
|
||||
// iterate over structure adding additional structure
|
||||
var items = $this.mobileNav.find('li');
|
||||
$(items).each(function () {
|
||||
var item = $(this),
|
||||
data = {};
|
||||
data.children = item.children('ul').attr('role', 'menu');
|
||||
item.data('menu', data);
|
||||
|
||||
// if a list item has a nested menu
|
||||
if (data.children.length > 0) {
|
||||
|
||||
// select all text before the child menu
|
||||
// check for anchors
|
||||
|
||||
var a = item.contents(),
|
||||
containsAnchor = false,
|
||||
nodes = [];
|
||||
|
||||
$(a).each(function () {
|
||||
if (!$(this).is('ul')) {
|
||||
nodes.push(this);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($(this).is("a")) {
|
||||
containsAnchor = true;
|
||||
}
|
||||
});
|
||||
|
||||
var wrapElement = $(
|
||||
'<' + settings.parentTag + ' role="menuitem" aria-haspopup="true" tabindex="-1" class="' + prefix + '_item"/>'
|
||||
);
|
||||
|
||||
// wrap item text with tag and add classes unless we are separating parent links
|
||||
if ((!settings.allowParentLinks || settings.nestedParentLinks) || !containsAnchor) {
|
||||
var $wrap = $(nodes).wrapAll(wrapElement).parent();
|
||||
$wrap.addClass(prefix+'_row');
|
||||
} else
|
||||
$(nodes).wrapAll('<span class="'+prefix+'_parent-link '+prefix+'_row"/>').parent();
|
||||
|
||||
if (!settings.showChildren) {
|
||||
item.addClass(prefix+'_collapsed');
|
||||
} else {
|
||||
item.addClass(prefix+'_open');
|
||||
}
|
||||
|
||||
item.addClass(prefix+'_parent');
|
||||
|
||||
// create parent arrow. wrap with link if parent links and separating
|
||||
var arrowElement = $('<span class="'+prefix+'_arrow">'+(settings.showChildren?settings.openedSymbol:settings.closedSymbol)+'</span>');
|
||||
|
||||
if (settings.allowParentLinks && !settings.nestedParentLinks && containsAnchor)
|
||||
arrowElement = arrowElement.wrap(wrapElement).parent();
|
||||
|
||||
//append arrow
|
||||
$(nodes).last().after(arrowElement);
|
||||
|
||||
|
||||
} else if ( item.children().length === 0) {
|
||||
item.addClass(prefix+'_txtnode');
|
||||
}
|
||||
|
||||
// accessibility for links
|
||||
item.children('a').attr('role', 'menuitem').click(function(event){
|
||||
//Ensure that it's not a parent
|
||||
if (settings.closeOnClick && !$(event.target).parent().closest('li').hasClass(prefix+'_parent')) {
|
||||
//Emulate menu close if set
|
||||
$($this.btn).click();
|
||||
}
|
||||
});
|
||||
|
||||
//also close on click if parent links are set
|
||||
if (settings.closeOnClick && settings.allowParentLinks) {
|
||||
item.children('a').children('a').click(function (event) {
|
||||
//Emulate menu close
|
||||
$($this.btn).click();
|
||||
});
|
||||
|
||||
item.find('.'+prefix+'_parent-link a:not(.'+prefix+'_item)').click(function(event){
|
||||
//Emulate menu close
|
||||
$($this.btn).click();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// structure is in place, now hide appropriate items
|
||||
$(items).each(function () {
|
||||
var data = $(this).data('menu');
|
||||
if (!settings.showChildren){
|
||||
$this._visibilityToggle(data.children, null, false, null, true);
|
||||
}
|
||||
});
|
||||
|
||||
// finally toggle entire menu
|
||||
$this._visibilityToggle($this.mobileNav, null, false, 'init', true);
|
||||
|
||||
// accessibility for menu button
|
||||
$this.mobileNav.attr('role','menu');
|
||||
|
||||
// outline prevention when using mouse
|
||||
$(document).mousedown(function(){
|
||||
$this._outlines(false);
|
||||
});
|
||||
|
||||
$(document).keyup(function(){
|
||||
$this._outlines(true);
|
||||
});
|
||||
|
||||
// menu button click
|
||||
$($this.btn).click(function (e) {
|
||||
e.preventDefault();
|
||||
$this._menuToggle();
|
||||
});
|
||||
|
||||
// click on menu parent
|
||||
$this.mobileNav.on('click', '.' + prefix + '_item', function (e) {
|
||||
e.preventDefault();
|
||||
$this._itemClick($(this));
|
||||
});
|
||||
|
||||
// check for keyboard events on menu button and menu parents
|
||||
$($this.btn).keydown(function (e) {
|
||||
var ev = e || event;
|
||||
|
||||
switch(ev.keyCode) {
|
||||
case Keyboard.ENTER:
|
||||
case Keyboard.SPACE:
|
||||
case Keyboard.DOWN:
|
||||
e.preventDefault();
|
||||
if (ev.keyCode !== Keyboard.DOWN || !$($this.btn).hasClass(prefix+'_open')){
|
||||
$this._menuToggle();
|
||||
}
|
||||
|
||||
$($this.btn).next().find('[role="menuitem"]').first().focus();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$this.mobileNav.on('keydown', '.'+prefix+'_item', function(e) {
|
||||
var ev = e || event;
|
||||
|
||||
switch(ev.keyCode) {
|
||||
case Keyboard.ENTER:
|
||||
e.preventDefault();
|
||||
$this._itemClick($(e.target));
|
||||
break;
|
||||
case Keyboard.RIGHT:
|
||||
e.preventDefault();
|
||||
if ($(e.target).parent().hasClass(prefix+'_collapsed')) {
|
||||
$this._itemClick($(e.target));
|
||||
}
|
||||
$(e.target).next().find('[role="menuitem"]').first().focus();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$this.mobileNav.on('keydown', '[role="menuitem"]', function(e) {
|
||||
var ev = e || event;
|
||||
|
||||
switch(ev.keyCode){
|
||||
case Keyboard.DOWN:
|
||||
e.preventDefault();
|
||||
var allItems = $(e.target).parent().parent().children().children('[role="menuitem"]:visible');
|
||||
var idx = allItems.index( e.target );
|
||||
var nextIdx = idx + 1;
|
||||
if (allItems.length <= nextIdx) {
|
||||
nextIdx = 0;
|
||||
}
|
||||
var next = allItems.eq( nextIdx );
|
||||
next.focus();
|
||||
break;
|
||||
case Keyboard.UP:
|
||||
e.preventDefault();
|
||||
var allItems = $(e.target).parent().parent().children().children('[role="menuitem"]:visible');
|
||||
var idx = allItems.index( e.target );
|
||||
var next = allItems.eq( idx - 1 );
|
||||
next.focus();
|
||||
break;
|
||||
case Keyboard.LEFT:
|
||||
e.preventDefault();
|
||||
if ($(e.target).parent().parent().parent().hasClass(prefix+'_open')) {
|
||||
var parent = $(e.target).parent().parent().prev();
|
||||
parent.focus();
|
||||
$this._itemClick(parent);
|
||||
} else if ($(e.target).parent().parent().hasClass(prefix+'_nav')){
|
||||
$this._menuToggle();
|
||||
$($this.btn).focus();
|
||||
}
|
||||
break;
|
||||
case Keyboard.ESCAPE:
|
||||
e.preventDefault();
|
||||
$this._menuToggle();
|
||||
$($this.btn).focus();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// allow links clickable within parent tags if set
|
||||
if (settings.allowParentLinks && settings.nestedParentLinks) {
|
||||
$('.'+prefix+'_item a').click(function(e){
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//toggle menu
|
||||
Plugin.prototype._menuToggle = function (el) {
|
||||
var $this = this;
|
||||
var btn = $this.btn;
|
||||
var mobileNav = $this.mobileNav;
|
||||
|
||||
if (btn.hasClass(prefix+'_collapsed')) {
|
||||
btn.removeClass(prefix+'_collapsed');
|
||||
btn.addClass(prefix+'_open');
|
||||
} else {
|
||||
btn.removeClass(prefix+'_open');
|
||||
btn.addClass(prefix+'_collapsed');
|
||||
}
|
||||
btn.addClass(prefix+'_animating');
|
||||
$this._visibilityToggle(mobileNav, btn.parent(), true, btn);
|
||||
};
|
||||
|
||||
// toggle clicked items
|
||||
Plugin.prototype._itemClick = function (el) {
|
||||
var $this = this;
|
||||
var settings = $this.settings;
|
||||
var data = el.data('menu');
|
||||
if (!data) {
|
||||
data = {};
|
||||
data.arrow = el.children('.'+prefix+'_arrow');
|
||||
data.ul = el.next('ul');
|
||||
data.parent = el.parent();
|
||||
//Separated parent link structure
|
||||
if (data.parent.hasClass(prefix+'_parent-link')) {
|
||||
data.parent = el.parent().parent();
|
||||
data.ul = el.parent().next('ul');
|
||||
}
|
||||
el.data('menu', data);
|
||||
}
|
||||
if (data.parent.hasClass(prefix+'_collapsed')) {
|
||||
data.arrow.html(settings.openedSymbol);
|
||||
data.parent.removeClass(prefix+'_collapsed');
|
||||
data.parent.addClass(prefix+'_open');
|
||||
data.parent.addClass(prefix+'_animating');
|
||||
$this._visibilityToggle(data.ul, data.parent, true, el);
|
||||
} else {
|
||||
data.arrow.html(settings.closedSymbol);
|
||||
data.parent.addClass(prefix+'_collapsed');
|
||||
data.parent.removeClass(prefix+'_open');
|
||||
data.parent.addClass(prefix+'_animating');
|
||||
$this._visibilityToggle(data.ul, data.parent, true, el);
|
||||
}
|
||||
};
|
||||
|
||||
// toggle actual visibility and accessibility tags
|
||||
Plugin.prototype._visibilityToggle = function(el, parent, animate, trigger, init) {
|
||||
var $this = this;
|
||||
var settings = $this.settings;
|
||||
var items = $this._getActionItems(el);
|
||||
var duration = 0;
|
||||
if (animate) {
|
||||
duration = settings.duration;
|
||||
}
|
||||
|
||||
function afterOpen(trigger, parent) {
|
||||
$(trigger).removeClass(prefix+'_animating');
|
||||
$(parent).removeClass(prefix+'_animating');
|
||||
|
||||
//Fire afterOpen callback
|
||||
if (!init) {
|
||||
settings.afterOpen(trigger);
|
||||
}
|
||||
}
|
||||
|
||||
function afterClose(trigger, parent) {
|
||||
el.attr('aria-hidden','true');
|
||||
items.attr('tabindex', '-1');
|
||||
$this._setVisAttr(el, true);
|
||||
el.hide(); //jQuery 1.7 bug fix
|
||||
|
||||
$(trigger).removeClass(prefix+'_animating');
|
||||
$(parent).removeClass(prefix+'_animating');
|
||||
|
||||
//Fire init or afterClose callback
|
||||
if (!init){
|
||||
settings.afterClose(trigger);
|
||||
} else if (trigger == 'init'){
|
||||
settings.init();
|
||||
}
|
||||
}
|
||||
|
||||
if (el.hasClass(prefix+'_hidden')) {
|
||||
el.removeClass(prefix+'_hidden');
|
||||
//Fire beforeOpen callback
|
||||
if (!init) {
|
||||
settings.beforeOpen(trigger);
|
||||
}
|
||||
if (settings.animations === 'jquery') {
|
||||
el.stop(true,true).slideDown(duration, settings.easingOpen, function(){
|
||||
afterOpen(trigger, parent);
|
||||
});
|
||||
} else if(settings.animations === 'velocity') {
|
||||
el.velocity("finish").velocity("slideDown", {
|
||||
duration: duration,
|
||||
easing: settings.easingOpen,
|
||||
complete: function() {
|
||||
afterOpen(trigger, parent);
|
||||
}
|
||||
});
|
||||
}
|
||||
el.attr('aria-hidden','false');
|
||||
items.attr('tabindex', '0');
|
||||
$this._setVisAttr(el, false);
|
||||
} else {
|
||||
el.addClass(prefix+'_hidden');
|
||||
|
||||
//Fire init or beforeClose callback
|
||||
if (!init){
|
||||
settings.beforeClose(trigger);
|
||||
}
|
||||
|
||||
if (settings.animations === 'jquery') {
|
||||
el.stop(true,true).slideUp(duration, this.settings.easingClose, function() {
|
||||
afterClose(trigger, parent)
|
||||
});
|
||||
} else if (settings.animations === 'velocity') {
|
||||
|
||||
el.velocity("finish").velocity("slideUp", {
|
||||
duration: duration,
|
||||
easing: settings.easingClose,
|
||||
complete: function() {
|
||||
afterClose(trigger, parent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// set attributes of element and children based on visibility
|
||||
Plugin.prototype._setVisAttr = function(el, hidden) {
|
||||
var $this = this;
|
||||
|
||||
// select all parents that aren't hidden
|
||||
var nonHidden = el.children('li').children('ul').not('.'+prefix+'_hidden');
|
||||
|
||||
// iterate over all items setting appropriate tags
|
||||
if (!hidden) {
|
||||
nonHidden.each(function(){
|
||||
var ul = $(this);
|
||||
ul.attr('aria-hidden','false');
|
||||
var items = $this._getActionItems(ul);
|
||||
items.attr('tabindex', '0');
|
||||
$this._setVisAttr(ul, hidden);
|
||||
});
|
||||
} else {
|
||||
nonHidden.each(function(){
|
||||
var ul = $(this);
|
||||
ul.attr('aria-hidden','true');
|
||||
var items = $this._getActionItems(ul);
|
||||
items.attr('tabindex', '-1');
|
||||
$this._setVisAttr(ul, hidden);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// get all 1st level items that are clickable
|
||||
Plugin.prototype._getActionItems = function(el) {
|
||||
var data = el.data("menu");
|
||||
if (!data) {
|
||||
data = {};
|
||||
var items = el.children('li');
|
||||
var anchors = items.find('a');
|
||||
data.links = anchors.add(items.find('.'+prefix+'_item'));
|
||||
el.data('menu', data);
|
||||
}
|
||||
return data.links;
|
||||
};
|
||||
|
||||
Plugin.prototype._outlines = function(state) {
|
||||
if (!state) {
|
||||
$('.'+prefix+'_item, .'+prefix+'_btn').css('outline','none');
|
||||
} else {
|
||||
$('.'+prefix+'_item, .'+prefix+'_btn').css('outline','');
|
||||
}
|
||||
};
|
||||
|
||||
Plugin.prototype.toggle = function(){
|
||||
var $this = this;
|
||||
$this._menuToggle();
|
||||
};
|
||||
|
||||
Plugin.prototype.open = function(){
|
||||
var $this = this;
|
||||
if ($this.btn.hasClass(prefix+'_collapsed')) {
|
||||
$this._menuToggle();
|
||||
}
|
||||
};
|
||||
|
||||
Plugin.prototype.close = function(){
|
||||
var $this = this;
|
||||
if ($this.btn.hasClass(prefix+'_open')) {
|
||||
$this._menuToggle();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn[mobileMenu] = function ( options ) {
|
||||
var args = arguments;
|
||||
|
||||
// Is the first parameter an object (options), or was omitted, instantiate a new instance
|
||||
if (options === undefined || typeof options === 'object') {
|
||||
return this.each(function () {
|
||||
|
||||
// Only allow the plugin to be instantiated once due to methods
|
||||
if (!$.data(this, 'plugin_' + mobileMenu)) {
|
||||
|
||||
// if it has no instance, create a new one, pass options to our plugin constructor,
|
||||
// and store the plugin instance in the elements jQuery data object.
|
||||
$.data(this, 'plugin_' + mobileMenu, new Plugin( this, options ));
|
||||
}
|
||||
});
|
||||
|
||||
// If is a string and doesn't start with an underscore or 'init' function, treat this as a call to a public method.
|
||||
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
||||
|
||||
// Cache the method call to make it possible to return a value
|
||||
var returns;
|
||||
|
||||
this.each(function () {
|
||||
var instance = $.data(this, 'plugin_' + mobileMenu);
|
||||
|
||||
// Tests that there's already a plugin-instance and checks that the requested public method exists
|
||||
if (instance instanceof Plugin && typeof instance[options] === 'function') {
|
||||
|
||||
// Call the method of our plugin instance, and pass it the supplied arguments.
|
||||
returns = instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) );
|
||||
}
|
||||
});
|
||||
|
||||
// If the earlier cached method gives a value back return the value, otherwise return this to preserve chainability.
|
||||
return returns !== undefined ? returns : this;
|
||||
}
|
||||
};
|
||||
}(jQuery, document, window));
|
||||
7
js/jquery.waypoints.min.js
vendored
Normal file
7
js/jquery.waypoints.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
127
js/magiccursor.js
Normal file
127
js/magiccursor.js
Normal file
@@ -0,0 +1,127 @@
|
||||
class Cursor {
|
||||
constructor(options) {
|
||||
this.options = $.extend(true, {
|
||||
container: "body",
|
||||
speed: 0.7,
|
||||
ease: "expo.out",
|
||||
visibleTimeout: 300
|
||||
}, options);
|
||||
this.body = $(this.options.container);
|
||||
this.el = $('<div class="cb-cursor"></div>');
|
||||
this.text = $('<div class="cb-cursor-text"></div>');
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
this.el.append(this.text);
|
||||
this.body.append(this.el);
|
||||
this.bind();
|
||||
this.move(-window.innerWidth, -window.innerHeight, 0);
|
||||
}
|
||||
|
||||
bind() {
|
||||
const self = this;
|
||||
|
||||
this.body.on('mouseleave', () => {
|
||||
self.hide();
|
||||
}).on('mouseenter', () => {
|
||||
self.show();
|
||||
}).on('mousemove', (e) => {
|
||||
this.pos = {
|
||||
x: this.stick ? this.stick.x - ((this.stick.x - e.clientX) * 0.15) : e.clientX,
|
||||
y: this.stick ? this.stick.y - ((this.stick.y - e.clientY) * 0.15) : e.clientY
|
||||
};
|
||||
this.update();
|
||||
}).on('mousedown', () => {
|
||||
self.setState('-active');
|
||||
}).on('mouseup', () => {
|
||||
self.removeState('-active');
|
||||
}).on('mouseenter', 'a,input,textarea,button', () => {
|
||||
self.setState('-pointer');
|
||||
}).on('mouseleave', 'a,input,textarea,button', () => {
|
||||
self.removeState('-pointer');
|
||||
}).on('mouseenter', 'iframe', () => {
|
||||
self.hide();
|
||||
}).on('mouseleave', 'iframe', () => {
|
||||
self.show();
|
||||
}).on('mouseenter', '[data-cursor]', function () {
|
||||
self.setState(this.dataset.cursor);
|
||||
}).on('mouseleave', '[data-cursor]', function () {
|
||||
self.removeState(this.dataset.cursor);
|
||||
}).on('mouseenter', '[data-cursor-text]', function () {
|
||||
self.setText(this.dataset.cursorText);
|
||||
}).on('mouseleave', '[data-cursor-text]', function () {
|
||||
self.removeText();
|
||||
}).on('mouseenter', '[data-cursor-stick]', function () {
|
||||
self.setStick(this.dataset.cursorStick);
|
||||
}).on('mouseleave', '[data-cursor-stick]', function () {
|
||||
self.removeStick();
|
||||
});
|
||||
}
|
||||
|
||||
setState(state) {
|
||||
this.el.addClass(state);
|
||||
}
|
||||
|
||||
removeState(state) {
|
||||
this.el.removeClass(state);
|
||||
}
|
||||
|
||||
toggleState(state) {
|
||||
this.el.toggleClass(state);
|
||||
}
|
||||
|
||||
setText(text) {
|
||||
this.text.html(text);
|
||||
this.el.addClass('-text');
|
||||
}
|
||||
|
||||
removeText() {
|
||||
this.el.removeClass('-text');
|
||||
}
|
||||
|
||||
setStick(el) {
|
||||
const target = $(el);
|
||||
const bound = target.get(0).getBoundingClientRect();
|
||||
this.stick = {
|
||||
y: bound.top + (target.height() / 2),
|
||||
x: bound.left + (target.width() / 2)
|
||||
};
|
||||
this.move(this.stick.x, this.stick.y, 5);
|
||||
}
|
||||
|
||||
removeStick() {
|
||||
this.stick = false;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.move();
|
||||
this.show();
|
||||
}
|
||||
|
||||
move(x, y, duration) {
|
||||
gsap.to(this.el, {
|
||||
x: x || this.pos.x,
|
||||
y: y || this.pos.y,
|
||||
force3D: true,
|
||||
overwrite: true,
|
||||
ease: this.options.ease,
|
||||
duration: this.visible ? (duration || this.options.speed) : 0
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
if (this.visible) return;
|
||||
clearInterval(this.visibleInt);
|
||||
this.el.addClass('-visible');
|
||||
this.visibleInt = setTimeout(() => this.visible = true);
|
||||
}
|
||||
|
||||
hide() {
|
||||
clearInterval(this.visibleInt);
|
||||
this.el.removeClass('-visible');
|
||||
this.visibleInt = setTimeout(() => this.visible = false, this.options.visibleTimeout);
|
||||
}
|
||||
}
|
||||
// Init cursor
|
||||
const cursor = new Cursor();
|
||||
55
js/parallaxie.js
Normal file
55
js/parallaxie.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/*! Copyright (c) 2016 THE ULTRASOFT (http://theultrasoft.com)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Project: Parallaxie
|
||||
* Version: 0.5
|
||||
*
|
||||
* Requires: jQuery 1.9+
|
||||
*/
|
||||
|
||||
(function( $ ){
|
||||
|
||||
$.fn.parallaxie = function( options ){
|
||||
|
||||
var options = $.extend({
|
||||
speed: 0.2,
|
||||
repeat: 'no-repeat',
|
||||
size: 'cover',
|
||||
pos_x: 'center',
|
||||
offset: 0,
|
||||
}, options );
|
||||
|
||||
this.each(function(){
|
||||
|
||||
var $el = $(this);
|
||||
var local_options = $el.data('parallaxie');
|
||||
if( typeof local_options != 'object' ) local_options = {};
|
||||
local_options = $.extend( {}, options, local_options );
|
||||
|
||||
var image_url = $el.data('image');
|
||||
if( typeof image_url == 'undefined' ){
|
||||
image_url = $el.css('background-image');
|
||||
if( !image_url ) return;
|
||||
|
||||
// APPLY DEFAULT CSS
|
||||
var pos_y = local_options.offset + ($el.offset().top - $(window).scrollTop()) * (1 - local_options.speed );
|
||||
$el.css({
|
||||
'background-image': image_url,
|
||||
'background-size': local_options.size,
|
||||
'background-repeat': local_options.repeat,
|
||||
'background-attachment': 'fixed',
|
||||
'background-position': local_options.pos_x + ' ' + pos_y + 'px',
|
||||
});
|
||||
|
||||
$(window).scroll( function(){
|
||||
//var pos_y = - ( $(window).scrollTop() - $el.offset().top ) * ( 1 + local_options.speed ) - ( $el.offset().top * local_options.speed );
|
||||
var pos_y = local_options.offset + ($el.offset().top - $(window).scrollTop()) * (1 - local_options.speed );
|
||||
$el.data( 'pos_y', pos_y );
|
||||
$el.css( 'background-position', local_options.pos_x + ' ' + pos_y + 'px' );
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
||||
}( jQuery ));
|
||||
1
js/plyr.js
Normal file
1
js/plyr.js
Normal file
File diff suppressed because one or more lines are too long
14
js/swiper-bundle.min.js
vendored
Normal file
14
js/swiper-bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
9
js/validator.min.js
vendored
Normal file
9
js/validator.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
513
js/wow.js
Normal file
513
js/wow.js
Normal file
@@ -0,0 +1,513 @@
|
||||
(function() {
|
||||
var MutationObserver, Util, WeakMap, getComputedStyle, getComputedStyleRX,
|
||||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
Util = (function() {
|
||||
function Util() {}
|
||||
|
||||
Util.prototype.extend = function(custom, defaults) {
|
||||
var key, value;
|
||||
for (key in defaults) {
|
||||
value = defaults[key];
|
||||
if (custom[key] == null) {
|
||||
custom[key] = value;
|
||||
}
|
||||
}
|
||||
return custom;
|
||||
};
|
||||
|
||||
Util.prototype.isMobile = function(agent) {
|
||||
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent);
|
||||
};
|
||||
|
||||
Util.prototype.createEvent = function(event, bubble, cancel, detail) {
|
||||
var customEvent;
|
||||
if (bubble == null) {
|
||||
bubble = false;
|
||||
}
|
||||
if (cancel == null) {
|
||||
cancel = false;
|
||||
}
|
||||
if (detail == null) {
|
||||
detail = null;
|
||||
}
|
||||
if (document.createEvent != null) {
|
||||
customEvent = document.createEvent('CustomEvent');
|
||||
customEvent.initCustomEvent(event, bubble, cancel, detail);
|
||||
} else if (document.createEventObject != null) {
|
||||
customEvent = document.createEventObject();
|
||||
customEvent.eventType = event;
|
||||
} else {
|
||||
customEvent.eventName = event;
|
||||
}
|
||||
return customEvent;
|
||||
};
|
||||
|
||||
Util.prototype.emitEvent = function(elem, event) {
|
||||
if (elem.dispatchEvent != null) {
|
||||
return elem.dispatchEvent(event);
|
||||
} else if (event in (elem != null)) {
|
||||
return elem[event]();
|
||||
} else if (("on" + event) in (elem != null)) {
|
||||
return elem["on" + event]();
|
||||
}
|
||||
};
|
||||
|
||||
Util.prototype.addEvent = function(elem, event, fn) {
|
||||
if (elem.addEventListener != null) {
|
||||
return elem.addEventListener(event, fn, false);
|
||||
} else if (elem.attachEvent != null) {
|
||||
return elem.attachEvent("on" + event, fn);
|
||||
} else {
|
||||
return elem[event] = fn;
|
||||
}
|
||||
};
|
||||
|
||||
Util.prototype.removeEvent = function(elem, event, fn) {
|
||||
if (elem.removeEventListener != null) {
|
||||
return elem.removeEventListener(event, fn, false);
|
||||
} else if (elem.detachEvent != null) {
|
||||
return elem.detachEvent("on" + event, fn);
|
||||
} else {
|
||||
return delete elem[event];
|
||||
}
|
||||
};
|
||||
|
||||
Util.prototype.innerHeight = function() {
|
||||
if ('innerHeight' in window) {
|
||||
return window.innerHeight;
|
||||
} else {
|
||||
return document.documentElement.clientHeight;
|
||||
}
|
||||
};
|
||||
|
||||
return Util;
|
||||
|
||||
})();
|
||||
|
||||
WeakMap = this.WeakMap || this.MozWeakMap || (WeakMap = (function() {
|
||||
function WeakMap() {
|
||||
this.keys = [];
|
||||
this.values = [];
|
||||
}
|
||||
|
||||
WeakMap.prototype.get = function(key) {
|
||||
var i, item, j, len, ref;
|
||||
ref = this.keys;
|
||||
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
||||
item = ref[i];
|
||||
if (item === key) {
|
||||
return this.values[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WeakMap.prototype.set = function(key, value) {
|
||||
var i, item, j, len, ref;
|
||||
ref = this.keys;
|
||||
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
||||
item = ref[i];
|
||||
if (item === key) {
|
||||
this.values[i] = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.keys.push(key);
|
||||
return this.values.push(value);
|
||||
};
|
||||
|
||||
return WeakMap;
|
||||
|
||||
})());
|
||||
|
||||
MutationObserver = this.MutationObserver || this.WebkitMutationObserver || this.MozMutationObserver || (MutationObserver = (function() {
|
||||
function MutationObserver() {
|
||||
if (typeof console !== "undefined" && console !== null) {
|
||||
console.warn('MutationObserver is not supported by your browser.');
|
||||
}
|
||||
if (typeof console !== "undefined" && console !== null) {
|
||||
console.warn('WOW.js cannot detect dom mutations, please call .sync() after loading new content.');
|
||||
}
|
||||
}
|
||||
|
||||
MutationObserver.notSupported = true;
|
||||
|
||||
MutationObserver.prototype.observe = function() {};
|
||||
|
||||
return MutationObserver;
|
||||
|
||||
})());
|
||||
|
||||
getComputedStyle = this.getComputedStyle || function(el, pseudo) {
|
||||
this.getPropertyValue = function(prop) {
|
||||
var ref;
|
||||
if (prop === 'float') {
|
||||
prop = 'styleFloat';
|
||||
}
|
||||
if (getComputedStyleRX.test(prop)) {
|
||||
prop.replace(getComputedStyleRX, function(_, _char) {
|
||||
return _char.toUpperCase();
|
||||
});
|
||||
}
|
||||
return ((ref = el.currentStyle) != null ? ref[prop] : void 0) || null;
|
||||
};
|
||||
return this;
|
||||
};
|
||||
|
||||
getComputedStyleRX = /(\-([a-z]){1})/g;
|
||||
|
||||
this.WOW = (function() {
|
||||
WOW.prototype.defaults = {
|
||||
boxClass: 'wow',
|
||||
animateClass: 'animated',
|
||||
offset: 0,
|
||||
mobile: true,
|
||||
live: true,
|
||||
callback: null,
|
||||
scrollContainer: null
|
||||
};
|
||||
|
||||
function WOW(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
this.scrollCallback = bind(this.scrollCallback, this);
|
||||
this.scrollHandler = bind(this.scrollHandler, this);
|
||||
this.resetAnimation = bind(this.resetAnimation, this);
|
||||
this.start = bind(this.start, this);
|
||||
this.scrolled = true;
|
||||
this.config = this.util().extend(options, this.defaults);
|
||||
if (options.scrollContainer != null) {
|
||||
this.config.scrollContainer = document.querySelector(options.scrollContainer);
|
||||
}
|
||||
this.animationNameCache = new WeakMap();
|
||||
this.wowEvent = this.util().createEvent(this.config.boxClass);
|
||||
}
|
||||
|
||||
WOW.prototype.init = function() {
|
||||
var ref;
|
||||
this.element = window.document.documentElement;
|
||||
if ((ref = document.readyState) === "interactive" || ref === "complete") {
|
||||
this.start();
|
||||
} else {
|
||||
this.util().addEvent(document, 'DOMContentLoaded', this.start);
|
||||
}
|
||||
return this.finished = [];
|
||||
};
|
||||
|
||||
WOW.prototype.start = function() {
|
||||
var box, j, len, ref;
|
||||
this.stopped = false;
|
||||
this.boxes = (function() {
|
||||
var j, len, ref, results;
|
||||
ref = this.element.querySelectorAll("." + this.config.boxClass);
|
||||
results = [];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
box = ref[j];
|
||||
results.push(box);
|
||||
}
|
||||
return results;
|
||||
}).call(this);
|
||||
this.all = (function() {
|
||||
var j, len, ref, results;
|
||||
ref = this.boxes;
|
||||
results = [];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
box = ref[j];
|
||||
results.push(box);
|
||||
}
|
||||
return results;
|
||||
}).call(this);
|
||||
if (this.boxes.length) {
|
||||
if (this.disabled()) {
|
||||
this.resetStyle();
|
||||
} else {
|
||||
ref = this.boxes;
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
box = ref[j];
|
||||
this.applyStyle(box, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.disabled()) {
|
||||
this.util().addEvent(this.config.scrollContainer || window, 'scroll', this.scrollHandler);
|
||||
this.util().addEvent(window, 'resize', this.scrollHandler);
|
||||
this.interval = setInterval(this.scrollCallback, 50);
|
||||
}
|
||||
if (this.config.live) {
|
||||
return new MutationObserver((function(_this) {
|
||||
return function(records) {
|
||||
var k, len1, node, record, results;
|
||||
results = [];
|
||||
for (k = 0, len1 = records.length; k < len1; k++) {
|
||||
record = records[k];
|
||||
results.push((function() {
|
||||
var l, len2, ref1, results1;
|
||||
ref1 = record.addedNodes || [];
|
||||
results1 = [];
|
||||
for (l = 0, len2 = ref1.length; l < len2; l++) {
|
||||
node = ref1[l];
|
||||
results1.push(this.doSync(node));
|
||||
}
|
||||
return results1;
|
||||
}).call(_this));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
})(this)).observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
WOW.prototype.stop = function() {
|
||||
this.stopped = true;
|
||||
this.util().removeEvent(this.config.scrollContainer || window, 'scroll', this.scrollHandler);
|
||||
this.util().removeEvent(window, 'resize', this.scrollHandler);
|
||||
if (this.interval != null) {
|
||||
return clearInterval(this.interval);
|
||||
}
|
||||
};
|
||||
|
||||
WOW.prototype.sync = function(element) {
|
||||
if (MutationObserver.notSupported) {
|
||||
return this.doSync(this.element);
|
||||
}
|
||||
};
|
||||
|
||||
WOW.prototype.doSync = function(element) {
|
||||
var box, j, len, ref, results;
|
||||
if (element == null) {
|
||||
element = this.element;
|
||||
}
|
||||
if (element.nodeType !== 1) {
|
||||
return;
|
||||
}
|
||||
element = element.parentNode || element;
|
||||
ref = element.querySelectorAll("." + this.config.boxClass);
|
||||
results = [];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
box = ref[j];
|
||||
if (indexOf.call(this.all, box) < 0) {
|
||||
this.boxes.push(box);
|
||||
this.all.push(box);
|
||||
if (this.stopped || this.disabled()) {
|
||||
this.resetStyle();
|
||||
} else {
|
||||
this.applyStyle(box, true);
|
||||
}
|
||||
results.push(this.scrolled = true);
|
||||
} else {
|
||||
results.push(void 0);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
WOW.prototype.show = function(box) {
|
||||
this.applyStyle(box);
|
||||
box.className = box.className + " " + this.config.animateClass;
|
||||
if (this.config.callback != null) {
|
||||
this.config.callback(box);
|
||||
}
|
||||
this.util().emitEvent(box, this.wowEvent);
|
||||
this.util().addEvent(box, 'animationend', this.resetAnimation);
|
||||
this.util().addEvent(box, 'oanimationend', this.resetAnimation);
|
||||
this.util().addEvent(box, 'webkitAnimationEnd', this.resetAnimation);
|
||||
this.util().addEvent(box, 'MSAnimationEnd', this.resetAnimation);
|
||||
return box;
|
||||
};
|
||||
|
||||
WOW.prototype.applyStyle = function(box, hidden) {
|
||||
var delay, duration, iteration;
|
||||
duration = box.getAttribute('data-wow-duration');
|
||||
delay = box.getAttribute('data-wow-delay');
|
||||
iteration = box.getAttribute('data-wow-iteration');
|
||||
return this.animate((function(_this) {
|
||||
return function() {
|
||||
return _this.customStyle(box, hidden, duration, delay, iteration);
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
||||
WOW.prototype.animate = (function() {
|
||||
if ('requestAnimationFrame' in window) {
|
||||
return function(callback) {
|
||||
return window.requestAnimationFrame(callback);
|
||||
};
|
||||
} else {
|
||||
return function(callback) {
|
||||
return callback();
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
WOW.prototype.resetStyle = function() {
|
||||
var box, j, len, ref, results;
|
||||
ref = this.boxes;
|
||||
results = [];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
box = ref[j];
|
||||
results.push(box.style.visibility = 'visible');
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
WOW.prototype.resetAnimation = function(event) {
|
||||
var target;
|
||||
if (event.type.toLowerCase().indexOf('animationend') >= 0) {
|
||||
target = event.target || event.srcElement;
|
||||
return target.className = target.className.replace(this.config.animateClass, '').trim();
|
||||
}
|
||||
};
|
||||
|
||||
WOW.prototype.customStyle = function(box, hidden, duration, delay, iteration) {
|
||||
if (hidden) {
|
||||
this.cacheAnimationName(box);
|
||||
}
|
||||
box.style.visibility = hidden ? 'hidden' : 'visible';
|
||||
if (duration) {
|
||||
this.vendorSet(box.style, {
|
||||
animationDuration: duration
|
||||
});
|
||||
}
|
||||
if (delay) {
|
||||
this.vendorSet(box.style, {
|
||||
animationDelay: delay
|
||||
});
|
||||
}
|
||||
if (iteration) {
|
||||
this.vendorSet(box.style, {
|
||||
animationIterationCount: iteration
|
||||
});
|
||||
}
|
||||
this.vendorSet(box.style, {
|
||||
animationName: hidden ? 'none' : this.cachedAnimationName(box)
|
||||
});
|
||||
return box;
|
||||
};
|
||||
|
||||
WOW.prototype.vendors = ["moz", "webkit"];
|
||||
|
||||
WOW.prototype.vendorSet = function(elem, properties) {
|
||||
var name, results, value, vendor;
|
||||
results = [];
|
||||
for (name in properties) {
|
||||
value = properties[name];
|
||||
elem["" + name] = value;
|
||||
results.push((function() {
|
||||
var j, len, ref, results1;
|
||||
ref = this.vendors;
|
||||
results1 = [];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
vendor = ref[j];
|
||||
results1.push(elem["" + vendor + (name.charAt(0).toUpperCase()) + (name.substr(1))] = value);
|
||||
}
|
||||
return results1;
|
||||
}).call(this));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
WOW.prototype.vendorCSS = function(elem, property) {
|
||||
var j, len, ref, result, style, vendor;
|
||||
style = getComputedStyle(elem);
|
||||
result = style.getPropertyCSSValue(property);
|
||||
ref = this.vendors;
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
vendor = ref[j];
|
||||
result = result || style.getPropertyCSSValue("-" + vendor + "-" + property);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
WOW.prototype.animationName = function(box) {
|
||||
var animationName, error;
|
||||
try {
|
||||
animationName = this.vendorCSS(box, 'animation-name').cssText;
|
||||
} catch (error) {
|
||||
animationName = getComputedStyle(box).getPropertyValue('animation-name');
|
||||
}
|
||||
if (animationName === 'none') {
|
||||
return '';
|
||||
} else {
|
||||
return animationName;
|
||||
}
|
||||
};
|
||||
|
||||
WOW.prototype.cacheAnimationName = function(box) {
|
||||
return this.animationNameCache.set(box, this.animationName(box));
|
||||
};
|
||||
|
||||
WOW.prototype.cachedAnimationName = function(box) {
|
||||
return this.animationNameCache.get(box);
|
||||
};
|
||||
|
||||
WOW.prototype.scrollHandler = function() {
|
||||
return this.scrolled = true;
|
||||
};
|
||||
|
||||
WOW.prototype.scrollCallback = function() {
|
||||
var box;
|
||||
if (this.scrolled) {
|
||||
this.scrolled = false;
|
||||
this.boxes = (function() {
|
||||
var j, len, ref, results;
|
||||
ref = this.boxes;
|
||||
results = [];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
box = ref[j];
|
||||
if (!(box)) {
|
||||
continue;
|
||||
}
|
||||
if (this.isVisible(box)) {
|
||||
this.show(box);
|
||||
continue;
|
||||
}
|
||||
results.push(box);
|
||||
}
|
||||
return results;
|
||||
}).call(this);
|
||||
if (!(this.boxes.length || this.config.live)) {
|
||||
return this.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WOW.prototype.offsetTop = function(element) {
|
||||
var top;
|
||||
while (element.offsetTop === void 0) {
|
||||
element = element.parentNode;
|
||||
}
|
||||
top = element.offsetTop;
|
||||
while (element = element.offsetParent) {
|
||||
top += element.offsetTop;
|
||||
}
|
||||
return top;
|
||||
};
|
||||
|
||||
WOW.prototype.isVisible = function(box) {
|
||||
var bottom, offset, top, viewBottom, viewTop;
|
||||
offset = box.getAttribute('data-wow-offset') || this.config.offset;
|
||||
viewTop = (this.config.scrollContainer && this.config.scrollContainer.scrollTop) || window.pageYOffset;
|
||||
viewBottom = viewTop + Math.min(this.element.clientHeight, this.util().innerHeight()) - offset;
|
||||
top = this.offsetTop(box);
|
||||
bottom = top + box.clientHeight;
|
||||
return top <= viewBottom && bottom >= viewTop;
|
||||
};
|
||||
|
||||
WOW.prototype.util = function() {
|
||||
return this._util != null ? this._util : this._util = new Util();
|
||||
};
|
||||
|
||||
WOW.prototype.disabled = function() {
|
||||
return !this.config.mobile && this.util().isMobile(navigator.userAgent);
|
||||
};
|
||||
|
||||
return WOW;
|
||||
|
||||
})();
|
||||
|
||||
}).call(this);
|
||||
Reference in New Issue
Block a user