|
|
|
@ -284,8 +284,7 @@
|
|
|
|
|
barElement = document.querySelector(bars[key]); |
|
|
|
|
if (activeObj[key]) { |
|
|
|
|
swapContent(activeObj[key], barElement); |
|
|
|
|
} |
|
|
|
|
else if (barElement) { |
|
|
|
|
} else if (barElement) { |
|
|
|
|
barElement.parentNode.removeChild(barElement); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -294,8 +293,7 @@
|
|
|
|
|
swapContent( |
|
|
|
|
(activeObj.contents || activeDom).cloneNode(true), |
|
|
|
|
document.querySelector('.content'), |
|
|
|
|
transition |
|
|
|
|
); |
|
|
|
|
transition); |
|
|
|
|
|
|
|
|
|
PUSH.id = id; |
|
|
|
|
|
|
|
|
@ -344,7 +342,9 @@
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (options.timeout) { |
|
|
|
|
options._timeout = setTimeout(function () { xhr.abort('timeout'); }, options.timeout); |
|
|
|
|
options._timeout = setTimeout(function () { |
|
|
|
|
xhr.abort('timeout'); |
|
|
|
|
}, options.timeout); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
xhr.send(); |
|
|
|
@ -398,11 +398,13 @@
|
|
|
|
|
|
|
|
|
|
var swapContent = function (swap, container, transition, complete) { |
|
|
|
|
"use strict"; |
|
|
|
|
|
|
|
|
|
function fadeContainerEnd() { |
|
|
|
|
container.removeEventListener('webkitTransitionEnd', fadeContainerEnd); |
|
|
|
|
swap.classList.add('in'); |
|
|
|
|
swap.addEventListener('webkitTransitionEnd', fadeSwapEnd); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function fadeSwapEnd() { |
|
|
|
|
swap.removeEventListener('webkitTransitionEnd', fadeSwapEnd); |
|
|
|
|
container.parentNode.removeChild(container); |
|
|
|
@ -410,6 +412,7 @@
|
|
|
|
|
swap.classList.remove('in'); |
|
|
|
|
complete && complete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function slideEnd() { |
|
|
|
|
swap.removeEventListener('webkitTransitionEnd', slideEnd); |
|
|
|
|
swap.classList.remove('slide'); |
|
|
|
@ -465,7 +468,9 @@
|
|
|
|
|
|
|
|
|
|
var triggerStateChange = function () { |
|
|
|
|
var e = new CustomEvent('push', { |
|
|
|
|
detail: { state: getCached(PUSH.id) }, |
|
|
|
|
detail: { |
|
|
|
|
state: getCached(PUSH.id) |
|
|
|
|
}, |
|
|
|
|
bubbles: true, |
|
|
|
|
cancelable: true |
|
|
|
|
}); |
|
|
|
@ -476,7 +481,9 @@
|
|
|
|
|
var findTarget = function (target) { |
|
|
|
|
var i, toggles = document.querySelectorAll('a'); |
|
|
|
|
for (; target && target !== document; target = target.parentNode) { |
|
|
|
|
for (i = toggles.length; i--;) { if (toggles[i] === target) return target; } |
|
|
|
|
for (i = toggles.length; i--;) { |
|
|
|
|
if (toggles[i] === target) return target; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -486,7 +493,9 @@
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var parseURL = function (url) { |
|
|
|
|
var a = document.createElement('a'); a.href = url; return a; |
|
|
|
|
var a = document.createElement('a'); |
|
|
|
|
a.href = url; |
|
|
|
|
return a; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var extendWithDom = function (obj, fragment, dom) { |
|
|
|
@ -546,10 +555,16 @@
|
|
|
|
|
// Attach PUSH event handlers
|
|
|
|
|
// ==========================
|
|
|
|
|
|
|
|
|
|
window.addEventListener('touchstart', function () { isScrolling = false; }); |
|
|
|
|
window.addEventListener('touchmove', function () { isScrolling = true; }) |
|
|
|
|
window.addEventListener('touchstart', function () { |
|
|
|
|
isScrolling = false; |
|
|
|
|
}); |
|
|
|
|
window.addEventListener('touchmove', function () { |
|
|
|
|
isScrolling = true; |
|
|
|
|
}) |
|
|
|
|
window.addEventListener('touchend', touchend); |
|
|
|
|
window.addEventListener('click', function (e) { if (getTarget(e)) e.preventDefault(); }); |
|
|
|
|
window.addEventListener('click', function (e) { |
|
|
|
|
if (getTarget(e)) e.preventDefault(); |
|
|
|
|
}); |
|
|
|
|
window.addEventListener('popstate', popstate); |
|
|
|
|
|
|
|
|
|
}(); |
|
|
|
@ -564,7 +579,9 @@
|
|
|
|
|
var getTarget = function (target) { |
|
|
|
|
var i, popovers = document.querySelectorAll('.segmented-controller li a'); |
|
|
|
|
for (; target && target !== document; target = target.parentNode) { |
|
|
|
|
for (i = popovers.length; i--;) { if (popovers[i] === target) return target; } |
|
|
|
|
for (i = popovers.length; i--;) { |
|
|
|
|
if (popovers[i] === target) return target; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -609,8 +626,11 @@
|
|
|
|
|
targetBody.classList.add(className); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.addEventListener('click', function (e) { if (getTarget(e.target)) e.preventDefault(); }); |
|
|
|
|
}();/* ---------------------------------- |
|
|
|
|
window.addEventListener('click', function (e) { |
|
|
|
|
if (getTarget(e.target)) e.preventDefault(); |
|
|
|
|
}); |
|
|
|
|
}(); |
|
|
|
|
/* ---------------------------------- |
|
|
|
|
* SLIDER v1.0.0 |
|
|
|
|
* Licensed under The MIT License |
|
|
|
|
* Adapted from Brad Birdsall's swipe |
|
|
|
@ -636,7 +656,9 @@
|
|
|
|
|
var getSlider = function (target) { |
|
|
|
|
var i, sliders = document.querySelectorAll('.slider ul'); |
|
|
|
|
for (; target && target !== document; target = target.parentNode) { |
|
|
|
|
for (i = sliders.length; i--;) { if (sliders[i] === target) return target; } |
|
|
|
|
for (i = sliders.length; i--;) { |
|
|
|
|
if (sliders[i] === target) return target; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -702,8 +724,7 @@
|
|
|
|
|
if (!slider || isScrolling) return; |
|
|
|
|
|
|
|
|
|
setSlideNumber( |
|
|
|
|
(+new Date) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0 |
|
|
|
|
); |
|
|
|
|
(+new Date) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0); |
|
|
|
|
|
|
|
|
|
offsetX = slideNumber * sliderWidth; |
|
|
|
|
|
|
|
|
@ -711,7 +732,9 @@
|
|
|
|
|
slider.style.webkitTransform = 'translate3d(' + offsetX + 'px,0,0)'; |
|
|
|
|
|
|
|
|
|
e = new CustomEvent('slide', { |
|
|
|
|
detail: { slideNumber: Math.abs(slideNumber) }, |
|
|
|
|
detail: { |
|
|
|
|
slideNumber: Math.abs(slideNumber) |
|
|
|
|
}, |
|
|
|
|
bubbles: true, |
|
|
|
|
cancelable: true |
|
|
|
|
}); |
|
|
|
@ -731,7 +754,7 @@
|
|
|
|
|
* ---------------------------------- */ |
|
|
|
|
|
|
|
|
|
!function () { |
|
|
|
|
|
|
|
|
|
"use strict"; |
|
|
|
|
var start = {}, |
|
|
|
|
touchMove = false, |
|
|
|
|
distanceX = false, |
|
|
|
@ -740,7 +763,9 @@
|
|
|
|
|
var findToggle = function (target) { |
|
|
|
|
var i, toggles = document.querySelectorAll('.toggle'); |
|
|
|
|
for (; target && target !== document; target = target.parentNode) { |
|
|
|
|
for (i = toggles.length; i--;) { if (toggles[i] === target) return target; } |
|
|
|
|
for (i = toggles.length; i--;) { |
|
|
|
|
if (toggles[i] === target) return target; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -758,7 +783,10 @@
|
|
|
|
|
handleWidth = handle.offsetWidth, |
|
|
|
|
offset = toggle.classList.contains('active') ? (toggleWidth - handleWidth) : 0; |
|
|
|
|
|
|
|
|
|
start = { pageX : e.touches[0].pageX - offset, pageY : e.touches[0].pageY }; |
|
|
|
|
start = { |
|
|
|
|
pageX: e.touches[0].pageX - offset, |
|
|
|
|
pageY: e.touches[0].pageY |
|
|
|
|
}; |
|
|
|
|
touchMove = false; |
|
|
|
|
|
|
|
|
|
// todo: probably should be moved to the css
|
|
|
|
@ -817,7 +845,9 @@
|
|
|
|
|
toggle.classList[slideOn ? 'add' : 'remove']('active'); |
|
|
|
|
|
|
|
|
|
e = new CustomEvent('toggle', { |
|
|
|
|
detail: { isActive: slideOn }, |
|
|
|
|
detail: { |
|
|
|
|
isActive: slideOn |
|
|
|
|
}, |
|
|
|
|
bubbles: true, |
|
|
|
|
cancelable: true |
|
|
|
|
}); |
|
|
|
|