This commit is contained in:
Luke Pulverenti 2017-01-27 18:07:14 -05:00
parent 82bcca376f
commit 8a6884abef
494 changed files with 256 additions and 120180 deletions

View file

@ -1,158 +1 @@
define([], function () {
'use strict';
function parentWithAttribute(elem, name, value) {
while ((value ? elem.getAttribute(name) !== value : !elem.getAttribute(name))) {
elem = elem.parentNode;
if (!elem || !elem.getAttribute) {
return null;
}
}
return elem;
}
function parentWithTag(elem, tagNames) {
// accept both string and array passed in
if (!Array.isArray(tagNames)) {
tagNames = [tagNames];
}
while (tagNames.indexOf(elem.tagName || '') === -1) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
function parentWithClass(elem, className) {
while (!elem.classList || !elem.classList.contains(className)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
var supportsCaptureOption = false;
try {
var opts = Object.defineProperty({}, 'capture', {
get: function () {
supportsCaptureOption = true;
}
});
window.addEventListener("test", null, opts);
} catch (e) { }
function addEventListenerWithOptions(target, type, handler, options) {
var optionsOrCapture = options;
if (!supportsCaptureOption) {
optionsOrCapture = options.capture;
}
target.addEventListener(type, handler, optionsOrCapture);
}
function removeEventListenerWithOptions(target, type, handler, options) {
var optionsOrCapture = options;
if (!supportsCaptureOption) {
optionsOrCapture = options.capture;
}
target.removeEventListener(type, handler, optionsOrCapture);
}
var windowSize;
var windowSizeEventsBound;
function clearWindowSize() {
windowSize = null;
}
function getWindowSize() {
if (!windowSize) {
windowSize = {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth
};
if (!windowSizeEventsBound) {
windowSizeEventsBound = true;
addEventListenerWithOptions(window, "orientationchange", clearWindowSize, { passive: true });
addEventListenerWithOptions(window, 'resize', clearWindowSize, { passive: true });
}
}
return windowSize;
}
var _animationEvent;
function whichAnimationEvent() {
if (_animationEvent) {
return _animationEvent;
}
var t,
el = document.createElement("div");
var animations = {
"animation": "animationend",
"OAnimation": "oAnimationEnd",
"MozAnimation": "animationend",
"WebkitAnimation": "webkitAnimationEnd"
};
for (t in animations) {
if (el.style[t] !== undefined) {
_animationEvent = animations[t];
return animations[t];
}
}
_animationEvent = 'animationend';
return _animationEvent;
}
var _transitionEvent;
function whichTransitionEvent() {
if (_transitionEvent) {
return _transitionEvent;
}
var t,
el = document.createElement("div");
var transitions = {
"transition": "transitionend",
"OTransition": "oTransitionEnd",
"MozTransition": "transitionend",
"WebkitTransition": "webkitTransitionEnd"
};
for (t in transitions) {
if (el.style[t] !== undefined) {
_transitionEvent = transitions[t];
return transitions[t];
}
}
_transitionEvent = 'transitionend';
return _transitionEvent;
}
return {
parentWithAttribute: parentWithAttribute,
parentWithClass: parentWithClass,
parentWithTag: parentWithTag,
addEventListener: addEventListenerWithOptions,
removeEventListener: removeEventListenerWithOptions,
getWindowSize: getWindowSize,
whichTransitionEvent: whichTransitionEvent,
whichAnimationEvent: whichAnimationEvent
};
});
define([],function(){"use strict";function parentWithAttribute(elem,name,value){for(;value?elem.getAttribute(name)!==value:!elem.getAttribute(name);)if(elem=elem.parentNode,!elem||!elem.getAttribute)return null;return elem}function parentWithTag(elem,tagNames){for(Array.isArray(tagNames)||(tagNames=[tagNames]);tagNames.indexOf(elem.tagName||"")===-1;)if(elem=elem.parentNode,!elem)return null;return elem}function parentWithClass(elem,className){for(;!elem.classList||!elem.classList.contains(className);)if(elem=elem.parentNode,!elem)return null;return elem}function addEventListenerWithOptions(target,type,handler,options){var optionsOrCapture=options;supportsCaptureOption||(optionsOrCapture=options.capture),target.addEventListener(type,handler,optionsOrCapture)}function removeEventListenerWithOptions(target,type,handler,options){var optionsOrCapture=options;supportsCaptureOption||(optionsOrCapture=options.capture),target.removeEventListener(type,handler,optionsOrCapture)}function clearWindowSize(){windowSize=null}function getWindowSize(){return windowSize||(windowSize={innerHeight:window.innerHeight,innerWidth:window.innerWidth},windowSizeEventsBound||(windowSizeEventsBound=!0,addEventListenerWithOptions(window,"orientationchange",clearWindowSize,{passive:!0}),addEventListenerWithOptions(window,"resize",clearWindowSize,{passive:!0}))),windowSize}function whichAnimationEvent(){if(_animationEvent)return _animationEvent;var t,el=document.createElement("div"),animations={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in animations)if(void 0!==el.style[t])return _animationEvent=animations[t],animations[t];return _animationEvent="animationend"}function whichTransitionEvent(){if(_transitionEvent)return _transitionEvent;var t,el=document.createElement("div"),transitions={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in transitions)if(void 0!==el.style[t])return _transitionEvent=transitions[t],transitions[t];return _transitionEvent="transitionend"}var supportsCaptureOption=!1;try{var opts=Object.defineProperty({},"capture",{get:function(){supportsCaptureOption=!0}});window.addEventListener("test",null,opts)}catch(e){}var windowSize,windowSizeEventsBound,_animationEvent,_transitionEvent;return{parentWithAttribute:parentWithAttribute,parentWithClass:parentWithClass,parentWithTag:parentWithTag,addEventListener:addEventListenerWithOptions,removeEventListener:removeEventListenerWithOptions,getWindowSize:getWindowSize,whichTransitionEvent:whichTransitionEvent,whichAnimationEvent:whichAnimationEvent}});