Skip to content

Instantly share code, notes, and snippets.

@vwochnik vwochnik/iframe.html
Last active Dec 20, 2016

Embed
What would you like to do?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example iframe</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 20px;
}
.footer {
padding-top: 40px;
padding-bottom: 40px;
margin-top: 40px;
border-top: 1px solid #eee;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
background-color: transparent;
}
.jumbotron .btn {
padding: 14px 24px;
font-size: 21px;
}
/* Customize the nav-justified links to be fill the entire space of the .navbar */
.nav-justified {
background-color: #eee;
border: 1px solid #ccc;
border-radius: 5px;
}
.nav-justified > li > a {
padding-top: 15px;
padding-bottom: 15px;
margin-bottom: 0;
font-weight: bold;
color: #777;
text-align: center;
background-color: #e5e5e5; /* Old browsers */
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e5e5e5));
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
background-image: linear-gradient(to bottom, #f5f5f5 0%,#e5e5e5 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background-repeat: repeat-x; /* Repeat the gradient */
border-bottom: 1px solid #d5d5d5;
}
.nav-justified > .active > a,
.nav-justified > .active > a:hover,
.nav-justified > .active > a:focus {
background-color: #ddd;
background-image: none;
-webkit-box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified > li:first-child > a {
border-radius: 5px 5px 0 0;
}
.nav-justified > li:last-child > a {
border-bottom: 0;
border-radius: 0 0 5px 5px;
}
@media (min-width: 768px) {
.nav-justified {
max-height: 52px;
}
.nav-justified > li > a {
border-right: 1px solid #d5d5d5;
border-left: 1px solid #fff;
}
.nav-justified > li:first-child > a {
border-left: 0;
border-radius: 5px 0 0 5px;
}
.nav-justified > li:last-child > a {
border-right: 0;
border-radius: 0 5px 5px 0;
}
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
.masthead,
.marketing,
.footer {
padding-right: 0;
padding-left: 0;
}
}
</style>
</head>
<body>
<div class="container">
<!-- The justified navigation menu is meant for single line per list item.
Multiple lines will require custom code not provided by Bootstrap. -->
<div class="masthead">
<h3 class="text-muted">Project name</h3>
<nav>
<ul class="nav nav-justified">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
<!-- Jumbotron -->
<div class="jumbotron">
<h1>Marketing stuff!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet.</p>
<p><a class="btn btn-lg btn-success" href="#" role="button">Get started today</a></p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="col-lg-4">
<h2>Safari bug warning!</h2>
<p class="text-danger">As of v9.1.2, Safari exhibits a bug in which resizing your browser horizontally causes rendering errors in the justified nav that are cleared upon refreshing.</p>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
</div>
<!-- Site footer -->
<footer class="footer">
<p>&copy; 2016 Company, Inc.</p>
</footer>
</div> <!-- /container -->
<script src="osc-ies.js"></script>
<script type="text/javascript">
var bridge = new ies.ChildBridge();
window.odoscopeInject = function(parent, before) {
var elem = document.createElement("div");
elem.innerHTML = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veritatis perspiciatis delectus ut saepe nam quidem numquam quasi itaque voluptatibus reprehenderit error, similique porro nobis iusto enim quam laborum repellendus, pariatur?";
parent.insertBefore(elem, before);
return elem;
};
setTimeout(function() {
bridge.initialize();
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>odoscope Injection Test</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 14px;
}
body {
margin: 0;
background: #efefff;
color: #334;
}
h1 {
text-align: center;
margin-bottom: 1rem;
}
.clear:after {
content: '';
display: table;
clear: both;
}
#wrapper {
max-width: 96rem;
margin: 2rem auto;
padding: 0 2rem;
}
.browser-mockup {
border-top: 2em solid rgba(230, 230, 230, 0.7);
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
position: relative;
border-radius: 3px 3px 0 0
}
.browser-mockup:before {
display: block;
position: absolute;
content: '';
top: -1.25em;
left: 1em;
width: 0.5em;
height: 0.5em;
border-radius: 50%;
background-color: #f44;
box-shadow: 0 0 0 2px #f44, 1.5em 0 0 2px #9b3, 3em 0 0 2px #fb5;
}
.browser-mockup:after {
display: block;
position: absolute;
content: '';
top: -1.6em;
left: 5.5em;
width: calc(100% - 6em);
height: 1.2em;
border-radius: 2px;
background-color: white;
}
.gap {
margin-bottom: 1rem;
}
.browser-mockup iframe {
display: block;
border: none;
width: 100%;
height: 40rem;
}
.wizard-btn {
font-size: 2rem;
line-height: 2rem;
width: 3.5rem;
height: 3.5rem;
padding: 0.75rem;
text-align: center;
margin-right: 0.5rem;
border: none;
border-radius: 50%;
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
background-color: rgba(230, 230, 230, 0.7);
color: #334;
}
.wizard-btn:hover {
background-color: rgba(220, 220, 240, 0.7);
}
.sel-text {
display: inline-block;
line-height: 3.5rem;
font-size: 1.5rem;
color: #393;
}
.log, .wizard {
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
border-radius: 3px 3px 0 0;
padding: 0.5rem;
overflow: auto;
}
.wizard {
background-color: rgba(230, 230, 230, 0.7);
height: 16rem;
}
.log {
background-color: rgba(230, 230, 230, 0.7);
height: 16rem;
}
.log .msg:not(:last-child) {
margin-bottom: 0.5rem;
}
.log .msg .date {
color: #f44;
}
</style>
<link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
</head>
<body>
<div id="wrapper">
<h1>odoscope Injection Test</h1>
<div class="browser-mockup gap" id="browser"></div>
<div class="clear gap">
<button id="prev" class="wizard-btn" style="float:left"><i class="ion ion-chevron-left"></i></button>
<button id="next" class="wizard-btn" style="float:right"><i class="ion ion-chevron-right"></i></button>
</div>
<div class="clear gap">
<div class="wizard" id="wizard" style="float:left;width:59%"></div>
<div class="log" id="log" style="float:right;width:39%"></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/taylorhakes/promise-polyfill/master/promise.min.js"></script>
<script src="osc-ies.js"></script>
<script src="wizard.js"></script>
</body>
</html>
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.ies = global.ies || {})));
}(this, (function (exports) { 'use strict';
var MAX_Z_INDEX = 2147483647;
var OSC_C_LIGHT = 'rgba(0,158,224,0.7)';
var OSC_C_WHITE = 'rgba(255,255,255,0.8)';
var OSC_C_DARK = 'rgba(0,158,224,0.9)';
var OSC_C_GRAY = 'rgba(60,89,101,0.8)';
var OSC_STRIPES = 'repeating-linear-gradient(45deg,rgba(0,158,224,0.7),rgba(0,158,224,0.7) 10px,rgba(0,158,224,0.8) 10px,rgba(0,158,224,0.8) 20px)';
var OSC_MODE_NONE = 0;
var OSC_MODE_SELECT = 1;
var OSC_MODE_INJECT = 2;
var OSC_POSITION_THIS = 0;
var OSC_POSITION_BEFORE = 1;
var OSC_POSITION_AFTER = 2;
/**
* Returns the Tag of the element
* @param { Object } element
* @return { String }
*/
function getID(el) {
return '#' + el.getAttribute('id');
}
/**
* Get class names for an element
*
* @pararm { Element } el
* @return { Array }
*/
function getClasses(el) {
var classNames = void 0;
try {
classNames = el.classList.toString().split(' ');
} catch (e) {
if (!el.hasAttribute('class')) {
return [];
}
var className = el.getAttribute('class');
// remove duplicate and leading/trailing whitespaces
className = className.trim().replace(/\s+/g, ' ');
// split into separate classnames
classNames = className.split(' ');
}
return classNames;
}
/**
* Returns the Class selectors of the element
* @param { Object } element
* @return { Array }
*/
function getClassSelectors(el) {
var classList = getClasses(el).filter(Boolean);
return classList.map(function (cl) {
return '.' + cl;
});
}
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
/**
* Returns the Attribute selectors of the element
* @param { DOM Element } element
* @param { Array } array of attributes to ignore
* @return { Array }
*/
function getAttributes(el) {
var attributesToIgnore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['id', 'class', 'length'];
var attributes = el.attributes;
var attrs = [].concat(toConsumableArray(attributes));
return attrs.reduce(function (sum, next) {
if (!(attributesToIgnore.indexOf(next.nodeName) > -1)) {
sum.push('[' + next.nodeName + '="' + next.value + '"]');
}
return sum;
}, []);
}
/**
* Determines if the passed el is a DOM element
*/
function isElement(el) {
var isElem = void 0;
if ((typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object') {
isElem = el instanceof HTMLElement;
} else {
isElem = !!el && (typeof el === 'undefined' ? 'undefined' : _typeof(el)) === 'object' && el.nodeType === 1 && typeof el.nodeName === 'string';
}
return isElem;
}
/**
* Returns the selectors based on the position of the element relative to its siblings
* @param { Object } element
* @return { Array }
*/
function getNthChild(element) {
var counter = 0;
var k = void 0;
var sibling = void 0;
var parentNode = element.parentNode;
if (Boolean(parentNode)) {
var childNodes = parentNode.childNodes;
var len = childNodes.length;
for (k = 0; k < len; k++) {
sibling = childNodes[k];
if (isElement(sibling)) {
counter++;
if (sibling === element) {
return ':nth-child(' + counter + ')';
}
}
}
}
return null;
}
/**
* Returns the Tag of the element
* @param { Object } element
* @return { String }
*/
function getTag(el) {
return el.tagName.toLowerCase();
}
/**
* Checks if the selector is unique
* @param { Object } element
* @param { String } selector
* @return { Array }
*/
function isUnique(el, selector) {
if (!Boolean(selector)) return false;
var elems = el.ownerDocument.querySelectorAll(selector);
return elems.length === 1 && elems[0] === el;
}
/**
* Returns all the element and all of its parents
* @param { DOM Element }
* @return { Array of DOM elements }
*/
function getParents(el) {
var parents = [];
var currentElement = el;
while (isElement(currentElement)) {
parents.push(currentElement);
currentElement = currentElement.parentNode;
}
return parents;
}
/**
* Expose `unique`
*/
/**
* Returns all the selectors of the elmenet
* @param { Object } element
* @return { Object }
*/
function getAllSelectors(el, selectors, attributesToIgnore) {
var funcs = {
'Tag': getTag,
'NthChild': getNthChild,
'Attributes': function Attributes(elem) {
return getAttributes(elem, attributesToIgnore);
},
'Class': getClassSelectors,
'ID': getID
};
return selectors.reduce(function (res, next) {
res[next] = funcs[next](el);
return res;
}, {});
}
/**
* Tests uniqueNess of the element inside its parent
* @param { Object } element
* @param { String } Selectors
* @return { Boolean }
*/
function testUniqueness(element, selector) {
var parentNode = element.parentNode;
var elements = parentNode.querySelectorAll(selector);
return elements.length === 1 && elements[0] === element;
}
/**
* Checks all the possible selectors of an element to find one unique and return it
* @param { Object } element
* @param { Array } items
* @param { String } tag
* @return { String }
*/
function getUniqueCombination(element, items, tag) {
var combinations = getCombinations(items);
var uniqCombinations = combinations.filter(testUniqueness.bind(this, element));
if (uniqCombinations.length) return uniqCombinations[0];
if (Boolean(tag)) {
var _combinations = items.map(function (item) {
return tag + item;
});
var _uniqCombinations = _combinations.filter(testUniqueness.bind(this, element));
if (_uniqCombinations.length) return _uniqCombinations[0];
}
return null;
}
/**
* Returns a uniqueSelector based on the passed options
* @param { DOM } element
* @param { Array } options
* @return { String }
*/
function getUniqueSelector(element, selectorTypes, attributesToIgnore) {
var foundSelector = void 0;
var elementSelectors = getAllSelectors(element, selectorTypes, attributesToIgnore);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = selectorTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var selectorType = _step.value;
var ID = elementSelectors.ID,
Tag = elementSelectors.Tag,
Classes = elementSelectors.Class,
Attributes = elementSelectors.Attributes,
NthChild = elementSelectors.NthChild;
switch (selectorType) {
case 'ID':
if (Boolean(ID) && testUniqueness(element, ID)) {
return ID;
}
break;
case 'Tag':
if (Boolean(Tag) && testUniqueness(element, Tag)) {
return Tag;
}
break;
case 'Class':
if (Boolean(Classes) && Classes.length) {
foundSelector = getUniqueCombination(element, Classes, Tag);
if (foundSelector) {
return foundSelector;
}
}
break;
case 'Attributes':
if (Boolean(Attributes) && Attributes.length) {
foundSelector = getUniqueCombination(element, Attributes, Tag);
if (foundSelector) {
return foundSelector;
}
}
break;
case 'NthChild':
if (Boolean(NthChild)) {
return NthChild;
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return '*';
}
/**
* Returns all the possible selector combinations
*/
function getCombinations(items) {
items = items ? items : [];
var result = [[]];
var i = void 0,
j = void 0,
k = void 0,
l = void 0,
ref = void 0,
ref1 = void 0;
for (i = k = 0, ref = items.length - 1; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
for (j = l = 0, ref1 = result.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
result.push(result[j].concat(items[i]));
}
}
result.shift();
result = result.sort(function (a, b) {
return a.length - b.length;
});
result = result.map(function (item) {
return item.join('');
});
return result;
}
/**
* Generate unique CSS selector for given DOM element
*
* @param {Element} el
* @return {String}
* @api private
*/
function unique(el) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$selectorType = options.selectorTypes,
selectorTypes = _options$selectorType === undefined ? ['ID', 'Class', 'Tag', 'NthChild'] : _options$selectorType,
_options$attributesTo = options.attributesToIgnore,
attributesToIgnore = _options$attributesTo === undefined ? ['id', 'class', 'length'] : _options$attributesTo;
var allSelectors = [];
var parents = getParents(el);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = parents[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var elem = _step2.value;
var selector = getUniqueSelector(elem, selectorTypes, attributesToIgnore);
if (Boolean(selector)) {
allSelectors.push(selector);
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
var selectors = [];
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = allSelectors[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var it = _step3.value;
selectors.unshift(it);
var _selector = selectors.join(' > ');
if (isUnique(el, _selector)) {
return _selector;
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return null;
}
function currentStyles(element) {
return element.currentStyle || window.getComputedStyle(element, null) || {};
}
function currentStyle(element, property) {
var style = currentStyles(element);
return style[property];
}
function outerHTML(element) {
if (element.outerHTML) {
return element.outerHTML;
}
var wrapper = document.createElement('div');
wrapper.appendChild(element.cloneNode(true));
return wrapper.innerHTML;
}
function withAncestors(element) {
var cursor = element,
result = [];
while (cursor) {
result.push(cursor);
cursor = cursor.parentElement;
}
return result;
}
function isAncestor(element1, element2) {
return element1 !== element2 && withAncestors(element2).includes(element1);
}
function elementLabel(element, withClasses) {
var result = element.tagName.toLowerCase();
if (element.id) {
result += "#" + element.id;
}
if (withClasses) {
element.className.split(' ').forEach(function (cls) {
if (cls.trim()) {
result += "." + cls.trim();
}
});
}
return result;
}
var HASH = '#'.charCodeAt(0);
var DOT = '.'.charCodeAt(0);
function createElement(query, ns) {
var tag;
var id;
var className;
var mode = 0;
var start = 0;
for (var i = 0; i <= query.length; i++) {
var char = query.charCodeAt(i);
if (char === HASH || char === DOT || !char) {
if (mode === 0) {
if (i === 0) {
tag = 'div';
} else if (!char) {
tag = query;
} else {
tag = query.substring(start, i);
}
} else {
var slice = query.substring(start, i);
if (mode === 1) {
id = slice;
} else if (className) {
className += ' ' + slice;
} else {
className = slice;
}
}
start = i + 1;
if (char === HASH) {
mode = 1;
} else {
mode = 2;
}
}
}
var element = ns ? document.createElementNS(ns, tag) : document.createElement(tag);
if (id) {
element.id = id;
}
if (className) {
element.className = className;
}
return element;
}
function text(content) {
return document.createTextNode(content);
}
function mount(parent, child, before) {
var parentEl = parent.el || parent;
var childEl = child.el || child;
if (childEl.__redom_list) {
childEl = childEl.el;
}
if (child === childEl && childEl.__redom_view) {
// try to look up the view if not provided
child = childEl.__redom_view;
}
if (child !== childEl) {
childEl.__redom_view = child;
}
if (child.isMounted) {
child.remount && child.remount();
} else {
child.mount && child.mount();
}
if (before) {
parentEl.insertBefore(childEl, before.el || before);
} else {
parentEl.appendChild(childEl);
}
if (child.isMounted) {
child.remounted && child.remounted();
} else {
child.isMounted = true;
child.mounted && child.mounted();
}
}
function unmount(parent, child) {
var parentEl = parent.el || parent;
var childEl = child.el || child;
if (child === childEl && childEl.__redom_view) {
// try to look up the view if not provided
child = childEl.__redom_view;
}
child.unmount && child.unmount();
parentEl.removeChild(childEl);
child.isMounted = false;
child.unmounted && child.unmounted();
}
var elcache = {};
function el(query) {
var arguments$1 = arguments;
var element;
if (typeof query === 'string') {
element = (elcache[query] || (elcache[query] = createElement(query))).cloneNode(false);
} else if (query && query.nodeType) {
element = query.cloneNode(false);
} else {
throw new Error('At least one argument required');
}
var empty = true;
for (var i = 1; i < arguments.length; i++) {
var arg = arguments$1[i];
if (!arg) {
continue;
}
// support middleware
if (typeof arg === 'function') {
arg(element);
} else if (typeof arg === 'string' || typeof arg === 'number') {
if (empty) {
empty = false;
element.textContent = arg;
} else {
element.appendChild(text(arg));
}
} else if (arg.nodeType || arg.el && arg.el.nodeType) {
empty = false;
mount(element, arg);
} else if (arg.length) {
empty = false;
for (var j = 0; j < arg.length; j++) {
mount(element, arg[j]);
}
} else if ((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object') {
for (var key in arg) {
var value = arg[key];
if (key === 'style') {
if (typeof value === 'string') {
element.setAttribute(key, value);
} else {
for (var cssKey in value) {
element.style[cssKey] = value[cssKey];
}
}
} else if (key in element || typeof value === 'function') {
element[key] = value;
} else {
element.setAttribute(key, value);
}
}
}
}
return element;
}
el.extend = function (query) {
var clone = elcache[query] || (elcache[query] = createElement(query));
return el.bind(this, clone);
};
function setChildren(parent, children) {
var parentEl = parent.el || parent;
var traverse = parentEl.firstChild;
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (!child) {
continue;
}
var childEl = child.el || child;
if (childEl === traverse) {
traverse = traverse.nextSibling;
continue;
}
mount(parent, child, traverse);
}
while (traverse) {
var next = traverse.nextSibling;
unmount(parent, traverse);
traverse = next;
}
}
function list(parent, View, key, initData) {
return new List(parent, View, key, initData);
}
function List(parent, View, key, initData) {
this.__redom_list = true;
this.View = View;
this.key = key;
this.initData = initData;
this.views = [];
this.el = typeof parent === 'string' ? el(parent) : parent;
if (key) {
this.lookup = {};
}
}
List.extend = function (parent, View, key, initData) {
return List.bind(List, parent, View, key, initData);
};
list.extend = List.extend;
List.prototype.update = function (data) {
if (data === void 0) data = [];
var View = this.View;
var key = this.key;
var functionKey = typeof key === 'function';
var initData = this.initData;
var newViews = new Array(data.length);
var oldViews = this.views;
var newLookup = key && {};
var oldLookup = key && this.lookup;
for (var i = 0; i < data.length; i++) {
var item = data[i];
var view = void 0;
if (key) {
var id = functionKey ? key(item) : item[key];
view = newViews[i] = oldLookup[id] || new View(initData, item, i, data);
newLookup[id] = view;
view.__id = id;
} else {
view = newViews[i] = oldViews[i] || new View(initData, item, i, data);
}
var el$$1 = view.el;
if (el$$1.__redom_list) {
el$$1 = el$$1.el;
}
el$$1.__redom_view = view;
view.update && view.update(item, i, data);
}
setChildren(this, newViews);
if (key) {
this.lookup = newLookup;
}
this.views = newViews;
};
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function unwrapExports (x) {
return x && x.__esModule ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var __moduleExports$1 = createCommonjsModule(function (module, exports) {
/**
* @ignore
* base event object for custom and dom event.
* @author yiminghe@gmail.com
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function returnFalse() {
return false;
}
function returnTrue() {
return true;
}
function EventBaseObject() {
this.timeStamp = Date.now();
this.target = undefined;
this.currentTarget = undefined;
}
EventBaseObject.prototype = {
isEventObject: 1,
constructor: EventBaseObject,
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
preventDefault: function preventDefault() {
this.isDefaultPrevented = returnTrue;
},
stopPropagation: function stopPropagation() {
this.isPropagationStopped = returnTrue;
},
stopImmediatePropagation: function stopImmediatePropagation() {
this.isImmediatePropagationStopped = returnTrue;
// fixed 1.2
// call stopPropagation implicitly
this.stopPropagation();
},
halt: function halt(immediate) {
if (immediate) {
this.stopImmediatePropagation();
} else {
this.stopPropagation();
}
this.preventDefault();
}
};
exports["default"] = EventBaseObject;
module.exports = exports["default"];
});
unwrapExports(__moduleExports$1);
/* eslint-disable no-unused-vars */
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (e) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
var __moduleExports$2 = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (Object.getOwnPropertySymbols) {
symbols = Object.getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
var __moduleExports = createCommonjsModule(function (module, exports) {
/**
* @ignore
* event object for dom
* @author yiminghe@gmail.com
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}
var _EventBaseObject = __moduleExports$1;
var _EventBaseObject2 = _interopRequireDefault(_EventBaseObject);
var _objectAssign = __moduleExports$2;
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var TRUE = true;
var FALSE = false;
var commonProps = ['altKey', 'bubbles', 'cancelable', 'ctrlKey', 'currentTarget', 'eventPhase', 'metaKey', 'shiftKey', 'target', 'timeStamp', 'view', 'type'];
function isNullOrUndefined(w) {
return w === null || w === undefined;
}
var eventNormalizers = [{
reg: /^key/,
props: ['char', 'charCode', 'key', 'keyCode', 'which'],
fix: function fix(event, nativeEvent) {
if (isNullOrUndefined(event.which)) {
event.which = !isNullOrUndefined(nativeEvent.charCode) ? nativeEvent.charCode : nativeEvent.keyCode;
}
// add metaKey to non-Mac browsers (use ctrl for PC 's and Meta for Macs)
if (event.metaKey === undefined) {
event.metaKey = event.ctrlKey;
}
}
}, {
reg: /^touch/,
props: ['touches', 'changedTouches', 'targetTouches']
}, {
reg: /^hashchange$/,
props: ['newURL', 'oldURL']
}, {
reg: /^gesturechange$/i,
props: ['rotation', 'scale']
}, {
reg: /^(mousewheel|DOMMouseScroll)$/,
props: [],
fix: function fix(event, nativeEvent) {
var deltaX = undefined;
var deltaY = undefined;
var delta = undefined;
var wheelDelta = nativeEvent.wheelDelta;
var axis = nativeEvent.axis;
var wheelDeltaY = nativeEvent.wheelDeltaY;
var wheelDeltaX = nativeEvent.wheelDeltaX;
var detail = nativeEvent.detail;
// ie/webkit
if (wheelDelta) {
delta = wheelDelta / 120;
}
// gecko
if (detail) {
// press control e.detail == 1 else e.detail == 3
delta = 0 - (detail % 3 === 0 ? detail / 3 : detail);
}
// Gecko
if (axis !== undefined) {
if (axis === event.HORIZONTAL_AXIS) {
deltaY = 0;
deltaX = 0 - delta;
} else if (axis === event.VERTICAL_AXIS) {
deltaX = 0;
deltaY = delta;
}
}
// Webkit
if (wheelDeltaY !== undefined) {
deltaY = wheelDeltaY / 120;
}
if (wheelDeltaX !== undefined) {
deltaX = -1 * wheelDeltaX / 120;
}
// 默认 deltaY (ie)
if (!deltaX && !deltaY) {
deltaY = delta;
}
if (deltaX !== undefined) {
/**
* deltaX of mousewheel event
* @property deltaX
* @member Event.DomEvent.Object
*/
event.deltaX = deltaX;
}
if (deltaY !== undefined) {
/**
* deltaY of mousewheel event
* @property deltaY
* @member Event.DomEvent.Object
*/
event.deltaY = deltaY;
}
if (delta !== undefined) {
/**
* delta of mousewheel event
* @property delta
* @member Event.DomEvent.Object
*/
event.delta = delta;
}
}
}, {
reg: /^mouse|contextmenu|click|mspointer|(^DOMMouseScroll$)/i,
props: ['buttons', 'clientX', 'clientY', 'button', 'offsetX', 'relatedTarget', 'which', 'fromElement', 'toElement', 'offsetY', 'pageX', 'pageY', 'screenX', 'screenY'],
fix: function fix(event, nativeEvent) {
var eventDoc = undefined;
var doc = undefined;
var body = undefined;
var target = event.target;
var button = nativeEvent.button;
// Calculate pageX/Y if missing and clientX/Y available
if (target && isNullOrUndefined(event.pageX) && !isNullOrUndefined(nativeEvent.clientX)) {
eventDoc = target.ownerDocument || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
event.pageX = nativeEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = nativeEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
}
// which for click: 1 === left; 2 === middle; 3 === right
// do not use button
if (!event.which && button !== undefined) {
if (button & 1) {
event.which = 1;
} else if (button & 2) {
event.which = 3;
} else if (button & 4) {
event.which = 2;
} else {
event.which = 0;
}
}
// add relatedTarget, if necessary
if (!event.relatedTarget && event.fromElement) {
event.relatedTarget = event.fromElement === target ? event.toElement : event.fromElement;
}
return event;
}
}];
function retTrue() {
return TRUE;
}
function retFalse() {
return FALSE;
}
function DomEventObject(nativeEvent) {
var type = nativeEvent.type;
var isNative = typeof nativeEvent.stopPropagation === 'function' || typeof nativeEvent.cancelBubble === 'boolean';
_EventBaseObject2['default'].call(this);
this.nativeEvent = nativeEvent;
// in case dom event has been mark as default prevented by lower dom node
var isDefaultPrevented = retFalse;
if ('defaultPrevented' in nativeEvent) {
isDefaultPrevented = nativeEvent.defaultPrevented ? retTrue : retFalse;
} else if ('getPreventDefault' in nativeEvent) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=691151
isDefaultPrevented = nativeEvent.getPreventDefault() ? retTrue : retFalse;
} else if ('returnValue' in nativeEvent) {
isDefaultPrevented = nativeEvent.returnValue === FALSE ? retTrue : retFalse;
}
this.isDefaultPrevented = isDefaultPrevented;
var fixFns = [];
var fixFn = undefined;
var l = undefined;
var prop = undefined;
var props = commonProps.concat();
eventNormalizers.forEach(function (normalizer) {
if (type.match(normalizer.reg)) {
props = props.concat(normalizer.props);
if (normalizer.fix) {
fixFns.push(normalizer.fix);
}
}
});
l = props.length;
// clone properties of the original event object
while (l) {
prop = props[--l];
this[prop] = nativeEvent[prop];
}
// fix target property, if necessary
if (!this.target && isNative) {
this.target = nativeEvent.srcElement || document; // srcElement might not be defined either
}
// check if target is a text node (safari)
if (this.target && this.target.nodeType === 3) {
this.target = this.target.parentNode;
}
l = fixFns.length;
while (l) {
fixFn = fixFns[--l];
fixFn(this, nativeEvent);
}
this.timeStamp = nativeEvent.timeStamp || Date.now();
}
var EventBaseObjectProto = _EventBaseObject2['default'].prototype;
(0, _objectAssign2['default'])(DomEventObject.prototype, EventBaseObjectProto, {
constructor: DomEventObject,
preventDefault: function preventDefault() {
var e = this.nativeEvent;
// if preventDefault exists run it on the original event
if (e.preventDefault) {
e.preventDefault();
} else {
// otherwise set the returnValue property of the original event to FALSE (IE)
e.returnValue = FALSE;
}
EventBaseObjectProto.preventDefault.call(this);
},
stopPropagation: function stopPropagation() {
var e = this.nativeEvent;
// if stopPropagation exists run it on the original event
if (e.stopPropagation) {
e.stopPropagation();
} else {
// otherwise set the cancelBubble property of the original event to TRUE (IE)
e.cancelBubble = TRUE;
}
EventBaseObjectProto.stopPropagation.call(this);
}
});
exports['default'] = DomEventObject;
module.exports = exports['default'];
});
unwrapExports(__moduleExports);
var index = createCommonjsModule(function (module, exports) {
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports['default'] = addEventListener;
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}
var _EventObject = __moduleExports;
var _EventObject2 = _interopRequireDefault(_EventObject);
function addEventListener(target, eventType, callback) {
function wrapCallback(e) {
var ne = new _EventObject2['default'](e);
callback.call(target, ne);
}
if (target.addEventListener) {
target.addEventListener(eventType, wrapCallback, false);
return {
remove: function remove() {
target.removeEventListener(eventType, wrapCallback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, wrapCallback);
return {
remove: function remove() {
target.detachEvent('on' + eventType, wrapCallback);
}
};
}
}
module.exports = exports['default'];
});
var addEventListener = unwrapExports(index);
var __moduleExports$4 = createCommonjsModule(function (module) {
// Generated by CoffeeScript 1.7.1
(function () {
var getNanoSeconds, hrtime, loadTime;
if (typeof performance !== "undefined" && performance !== null && performance.now) {
module.exports = function () {
return performance.now();
};
} else if (typeof process !== "undefined" && process !== null && process.hrtime) {
module.exports = function () {
return (getNanoSeconds() - loadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function getNanoSeconds() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
loadTime = getNanoSeconds();
} else if (Date.now) {
module.exports = function () {
return Date.now() - loadTime;
};
loadTime = Date.now();
} else {
module.exports = function () {
return new Date().getTime() - loadTime;
};
loadTime = new Date().getTime();
}
}).call(commonjsGlobal);
});
var now = __moduleExports$4;
var root = typeof window === 'undefined' ? commonjsGlobal : window;
var vendors = ['moz', 'webkit'];
var suffix = 'AnimationFrame';
var raf = root['request' + suffix];
var caf = root['cancel' + suffix] || root['cancelRequest' + suffix];
for (var i = 0; !raf && i < vendors.length; i++) {
raf = root[vendors[i] + 'Request' + suffix];
caf = root[vendors[i] + 'Cancel' + suffix] || root[vendors[i] + 'CancelRequest' + suffix];
}
// Some versions of FF have rAF but not cAF
if (!raf || !caf) {
var last = 0,
id = 0,
queue = [],
frameDuration = 1000 / 60;
raf = function raf(callback) {
if (queue.length === 0) {
var _now = now(),
next = Math.max(0, frameDuration - (_now - last));
last = next + _now;
setTimeout(function () {
var cp = queue.slice(0);
// Clear queue here to prevent
// callbacks from appending listeners
// to the current frame's queue
queue.length = 0;
for (var i = 0; i < cp.length; i++) {
if (!cp[i].cancelled) {
try {
cp[i].callback(last);
} catch (e) {
setTimeout(function () {
throw e;
}, 0);
}
}
}
}, Math.round(next));
}
queue.push({
handle: ++id,
callback: callback,
cancelled: false
});
return id;
};
caf = function caf(handle) {
for (var i = 0; i < queue.length; i++) {
if (queue[i].handle === handle) {
queue[i].cancelled = true;
}
}
};
}
var __moduleExports$3 = function index(fn) {
// Wrap in a new function to prevent
// `cancel` potentially being assigned
// to the native rAF function
return raf.call(root, fn);
};
var cancel = function cancel() {
caf.apply(root, arguments);
};
var polyfill = function polyfill() {
root.requestAnimationFrame = raf;
root.cancelAnimationFrame = caf;
};
__moduleExports$3.cancel = cancel;
__moduleExports$3.polyfill = polyfill;
var index$1 = createCommonjsModule(function (module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _raf = __moduleExports$3;
var _raf2 = _interopRequireDefault(_raf);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _toConsumableArray(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}return arr2;
} else {
return Array.from(arr);
}
}
var rafThrottle = function rafThrottle(callback) {
var requestId = void 0;
var later = function later(args) {
return function () {
requestId = null;
callback.apply(undefined, _toConsumableArray(args));
};
};
var throttled = function throttled() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (requestId == null) {
requestId = (0, _raf2.default)(later(args));
}
};
throttled.cancel = function () {
return _raf2.default.cancel(requestId);
};
return throttled;
};
exports.default = rafThrottle;
});
var throttle = unwrapExports(index$1);
var cssx = createCommonjsModule(function (module, exports) {
(function webpackUniversalModuleDefinition(root, factory) {
if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') module.exports = factory();else if (typeof define === 'function' && define.amd) define("cssx", [], factory);else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') exports["cssx"] = factory();else root["cssx"] = factory();
})(commonjsGlobal, function () {
return (/******/function (modules) {
// webpackBootstrap
/******/ // The module cache
/******/var installedModules = {};
/******/
/******/ // The require function
/******/function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/if (installedModules[moduleId])
/******/return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/var module = installedModules[moduleId] = {
/******/exports: {},
/******/id: moduleId,
/******/loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/__webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/__webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/__webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/return __webpack_require__(0);
/******/
}(
/************************************************************************/
/******/[
/* 0 */
/***/function (module, exports, __webpack_require__) {
var factory,
goGlobal,
stylesheets,
api,
randomId,
plugins = [];
__webpack_require__(1);
factory = __webpack_require__(5);
goGlobal = __webpack_require__(15);
randomId = __webpack_require__(16);
stylesheets = [];
function createStyleSheet(id) {
var s, i;
if (typeof id === 'undefined') {
id = randomId();
}
for (i = 0; i < stylesheets.length; i++) {
if (stylesheets[i].id() === id) {
return stylesheets[i];
}
}
s = factory.apply(factory, arguments);
stylesheets.push(s);
return s;
};
api = function api(id) {
return createStyleSheet(id, plugins);
};
api.domChanges = function (flag) {
factory.disableDOMChanges = !flag;
};
api.minify = function (flag) {
factory.minify = flag;
};
api.nextTick = function (flag) {
factory.useNextTick = flag;
};
api.getStylesheets = function () {
return stylesheets;
};
api.clear = function () {
var i;
for (i = 0; i < stylesheets.length; i++) {
stylesheets[i].clear();
}
stylesheets = [];
return api;
};
api.getCSS = function () {
var i,
css = '';
for (i = 0; i < stylesheets.length; i++) {
css += stylesheets[i].getCSS();
}
return css;
};
api.plugins = function (arr) {
plugins = plugins.concat(arr);
};
module.exports = api;
goGlobal(module.exports);
/***/
},
/* 1 */
/***/function (module, exports, __webpack_require__) {
__webpack_require__(2);
__webpack_require__(3);
__webpack_require__(4);
/***/
},
/* 2 */
/***/function (module, exports) {
if (!Array.prototype.filter) {
Array.prototype.filter = function (fun /*, thisArg*/) {
'use strict';
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== 'function') {
throw new TypeError();
}
var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++) {
if (i in t) {
var val = t[i];
// NOTE: Technically this should Object.defineProperty at
// the next index, as push can be affected by
// properties on Object.prototype and Array.prototype.
// But that method's new, and collisions should be
// rare, so use the more-compatible alternative.
if (fun.call(thisArg, val, i, t)) {
res.push(val);
}
}
}
return res;
};
}
/***/
},
/* 3 */
/***/function (module, exports) {
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}
/***/
},
/* 4 */
/***/function (module, exports) {
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.io/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function (callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling ToObject passing the |this|
// value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal
// method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== 'function') {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len)
// where Array is the standard built-in constructor with that name and
// len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while (k < len) {
var kValue, mappedValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal
// method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal
// method of O with argument Pk.
kValue = O[k];
// ii. Let mappedValue be the result of calling the Call internal
// method of callback with T as the this value and argument
// list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor
// { Value: mappedValue,
// Writable: true,
// Enumerable: true,
// Configurable: true },
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, k, {
// value: mappedValue,
// writable: true,
// enumerable: true,
// configurable: true
// });
// For best browser support, use the following:
A[k] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}
/***/
},
/* 5 */
/***/function (module, exports, __webpack_require__) {
var CSSRule = __webpack_require__(6);
var applyToDOM = __webpack_require__(8);
var nextTick = __webpack_require__(9);
var generate = __webpack_require__(13);
var isArray = __webpack_require__(7);
var ids = 0;
var getId = function getId() {
return 'x' + ++ids;
};
module.exports = function (id, plugins) {
var _id = id || getId();
var _api = {};
var _rules = [];
var _customProperties = {};
var _remove = null;
var _css = '';
var _scope = '';
var ruleExists = function ruleExists(rules, selector, parent) {
return rules.reduce(function (result, rule) {
if (result !== false) return result;
if (rule.selector === selector) {
if (parent) {
return rule.parent && parent.selector === rule.parent.selector ? rule : false;
}
return rule;
}
return false;
}, false);
};
var registerRule = function registerRule(rule, addAt) {
if (typeof addAt !== 'undefined') {
_rules.splice(addAt, 0, rule);
} else {
_rules.push(rule);
}
rule.index = _rules.length - 1;
};
var isNested = function isNested(obj) {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
return true;
} else if (isArray(obj)) {
return typeof obj[0] === 'string';
}
return false;
};
_api.id = function () {
return _id;
};
_api.add = _api.update = function (rawRules, parent, addAt, considerAsNew) {
var rule, prop, tmpRawRules, cssProps, props, nestedRules, selector, tmp;
var created = [];
if (typeof rawRules === 'string') {
tmp = {};
tmp[rawRules] = {};
rawRules = tmp;
}
if (typeof rawRules === 'function') {
rawRules = rawRules();
}
for (selector in rawRules) {
if (isArray(rawRules[selector])) {
rawRules[selector].forEach(function (r) {
tmp = {};
tmp[selector] = r;
_api.add(tmp, parent, undefined, true);
});
} else {
rule = ruleExists(_rules, selector, parent);
cssProps = {};
props = {};
nestedRules = [];
// new rule
if (considerAsNew || !rule) {
props = rawRules[selector];
for (prop in props) {
if (isNested(props[prop])) {
cssProps[prop] = props[prop];
} else {
tmpRawRules = {};
tmpRawRules[prop] = props[prop];
nestedRules.push(tmpRawRules);
}
}
rule = CSSRule(selector, this.resolveCustomProps(cssProps), _api);
if (!parent) {
registerRule(rule, addAt);
} else {
rule.parent = parent;
parent.registerNested(rule);
}
nestedRules.forEach(function (rawRulesNested) {
_api.add(rawRulesNested, rule);
});
// existing rule
} else {
rule.update(rawRules[selector]);
}
this.compile();
created.push(rule);
}
}
return created.length === 1 ? created[0] : created;
};
_api.rules = function () {
return _rules;
};
_api.compile = function () {
if (module.exports.useNextTick) {
nextTick(function () {
_api.compileImmediate();
}, _id);
return _api;
}
return _api.compileImmediate();
};
_api.compileImmediate = function () {
_css = generate(_rules, module.exports.minify, plugins, _scope);
if (!module.exports.disableDOMChanges) {
_remove = applyToDOM(_css, _id);
}
return _api;
};
_api.clear = function () {
_rules = [];
_css = '';
if (_remove !== null) {
_remove();
_remove = null;
}
return _api;
};
_api.destroy = function () {
return _api.clear();
};
_api.getCSS = function () {
this.compileImmediate();
return _css;
};
_api.define = function (prop, func) {
_customProperties[prop] = func;
};
_api.scope = function (scope) {
_scope = scope;
};
_api._getCustomProps = function () {
return _customProperties;
};
_api.resolveCustomProps = function (actual) {
var result = actual,
prop,
newProp,
value;
var custom = _customProperties;
for (prop in custom) {
if (typeof actual[prop] !== 'undefined') {
value = custom[prop](actual[prop]);
delete actual[prop];
for (newProp in value) {
actual[newProp] = value[newProp];
}
}
}
return result;
};
return _api;
};
module.exports.disableDOMChanges = false;
module.exports.minify = true;
module.exports.useNextTick = true;
/***/
},
/* 6 */
/***/function (module, exports, __webpack_require__) {
var isArray = __webpack_require__(7);
module.exports = function CSSRule(selector, props, stylesheet) {
var _api = {
selector: selector,
props: props,
stylesheet: stylesheet,
index: null,
nestedRules: null,
parent: null
};
_api.clone = function () {
var rule = CSSRule(this.selector, this.props, this.stylesheet);
rule.index = this.index;
rule.nestedRules = this.nestedRules;
rule.parent = this.parent;
return rule;
};
_api.descendant = _api.d = function (rawRules) {
var selector;
if (typeof rawRules === 'function') rawRules = rawRules();
for (selector in rawRules) {
rawRules[_api.selector + ' ' + selector] = rawRules[selector];
delete rawRules[selector];
}
return _api.stylesheet.add(rawRules, this.parent, this.index);
};
_api.nested = _api.n = function (rawRules) {
return _api.stylesheet.add(rawRules, this);
};
_api.update = function (props) {
var prop,
areThereNestedRules = this.nestedRules !== null;
if (typeof props === 'function') {
props = props();
}
props = this.stylesheet.resolveCustomProps(props);
for (prop in props) {
if (_typeof(props[prop]) !== 'object') {
this.props[prop] = props[prop];
} else if (areThereNestedRules) {
if (this.nestedRules[prop]) {
this.nestedRules[prop].update(props[prop]);
}
}
}
return this;
};
_api.registerNested = function (rule) {
var nestedRule;
if (this.nestedRules === null) this.nestedRules = {};
nestedRule = this.nestedRules[rule.selector];
if (nestedRule) {
if (isArray(nestedRule)) {
nestedRule.push(rule);
} else {
this.nestedRules[rule.selector] = [nestedRule, rule];
}
} else {
this.nestedRules[rule.selector] = rule;
}
return this;
};
return _api;
};
/***/
},
/* 7 */
/***/function (module, exports) {
module.exports = function (v) {
return Object.prototype.toString.call(v) === '[object Array]';
};
/***/
},
/* 8 */
/***/function (module, exports) {
var cache = {};
var qs = function qs(selector) {
return document.querySelector(selector);
};
var createNode = function createNode(type, attrs, content) {
var node = document.createElement(type),
i,
a;
for (i = 0; i < attrs.length; i++) {
a = attrs[i];
node.setAttribute(a.name, a.value);
}
node.innerHTML = content;
(qs('head') || qs('body')).appendChild(node);
return node;
};
var remove = function remove(id) {
return function () {
if (cache[id]) {
cache[id].el.parentNode.removeChild(cache[id].el);
delete cache[id];
}
};
};
module.exports = function (css, id) {
var el;
if (!cache[id]) {
el = createNode('style', [{ name: 'id', value: id }, { name: 'type', value: 'text/css' }], css);
cache[id] = { el: el, css: css, remove: remove(id) };
} else {
if (cache[id].css !== css) {
cache[id].css = css;
cache[id].el.innerHTML = css;
}
}
return cache[id].remove;
};
/***/
},
/* 9 */
/***/function (module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function (setImmediate) {
var cache = {};
__webpack_require__(12);
module.exports = function (work, id) {
if (!cache[id]) {
cache[id] = work;
setImmediate(function () {
delete cache[id];
work();
});
}
};
/* WEBPACK VAR INJECTION */
}).call(exports, __webpack_require__(10).setImmediate);
/***/
},
/* 10 */
/***/function (module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function (setImmediate, clearImmediate) {
var nextTick = __webpack_require__(11).nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;
var immediateIds = {};
var nextImmediateId = 0;
// DOM APIs, for completeness
exports.setTimeout = function () {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
};
exports.setInterval = function () {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
};
exports.clearTimeout = exports.clearInterval = function (timeout) {
timeout.close();
};
function Timeout(id, clearFn) {
this._id = id;
this._clearFn = clearFn;
}
Timeout.prototype.unref = Timeout.prototype.ref = function () {};
Timeout.prototype.close = function () {
this._clearFn.call(window, this._id);
};
// Does not start the time, just sets up the members needed.
exports.enroll = function (item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
};
exports.unenroll = function (item) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = -1;
};
exports._unrefActive = exports.active = function (item) {
clearTimeout(item._idleTimeoutId);
var msecs = item._idleTimeout;
if (msecs >= 0) {
item._idleTimeoutId = setTimeout(function onTimeout() {
if (item._onTimeout) item._onTimeout();
}, msecs);
}
};
// That's not how node.js implements it but the exposed api is the same.
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
var id = nextImmediateId++;
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
immediateIds[id] = true;
nextTick(function onNextTick() {
if (immediateIds[id]) {
// fn.call() is faster so we optimize for the common use-case
// @see http://jsperf.com/call-apply-segu
if (args) {
fn.apply(null, args);
} else {
fn.call(null);
}
// Prevent ids from leaking
exports.clearImmediate(id);
}
});
return id;
};
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
delete immediateIds[id];
};
/* WEBPACK VAR INJECTION */
}).call(exports, __webpack_require__(10).setImmediate, __webpack_require__(10).clearImmediate);
/***/
},
/* 11 */
/***/function (module, exports) {
// shim for using process in browser
var process = module.exports = {};
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = setTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
clearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
setTimeout(drainQueue, 0);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () {
return '/';
};
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function () {
return 0;
};
/***/
},
/* 12 */
/***/function (module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function (global, clearImmediate, process) {
(function (global, undefined) {
"use strict";
if (global.setImmediate) {
return;
}
var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};
var currentlyRunningATask = false;
var doc = global.document;
var setImmediate;
function addFromSetImmediateArguments(args) {
tasksByHandle[nextHandle] = partiallyApplied.apply(undefined, args);
return nextHandle++;
}
// This function accepts the same arguments as setImmediate, but
// returns a function that requires no arguments.
function partiallyApplied(handler) {
var args = [].slice.call(arguments, 1);
return function () {
if (typeof handler === "function") {
handler.apply(undefined, args);
} else {
new Function("" + handler)();
}
};
}
function runIfPresent(handle) {
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
// So if we're currently running a task, we'll need to delay this invocation.
if (currentlyRunningATask) {
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// "too much recursion" error.
setTimeout(partiallyApplied(runIfPresent, handle), 0);
} else {
var task = tasksByHandle[handle];
if (task) {
currentlyRunningATask = true;
try {
task();
} finally {
clearImmediate(handle);
currentlyRunningATask = false;
}
}
}
}
function clearImmediate(handle) {
delete tasksByHandle[handle];
}
function installNextTickImplementation() {
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
process.nextTick(partiallyApplied(runIfPresent, handle));
return handle;
};
}
function canUsePostMessage() {
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
// where `global.postMessage` means something completely different and can't be used for this purpose.
if (global.postMessage && !global.importScripts) {
var postMessageIsAsynchronous = true;
var oldOnMessage = global.onmessage;
global.onmessage = function () {
postMessageIsAsynchronous = false;
};
global.postMessage("", "*");
global.onmessage = oldOnMessage;
return postMessageIsAsynchronous;
}
}
function installPostMessageImplementation() {
// Installs an event handler on `global` for the `message` event: see
// * https://developer.mozilla.org/en/DOM/window.postMessage
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
var messagePrefix = "setImmediate$" + Math.random() + "$";
var onGlobalMessage = function onGlobalMessage(event) {
if (event.source === global && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) {
runIfPresent(+event.data.slice(messagePrefix.length));
}
};
if (global.addEventListener) {
global.addEventListener("message", onGlobalMessage, false);
} else {
global.attachEvent("onmessage", onGlobalMessage);
}
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
global.postMessage(messagePrefix + handle, "*");
return handle;
};
}
function installMessageChannelImplementation() {
var channel = new MessageChannel();
channel.port1.onmessage = function (event) {
var handle = event.data;
runIfPresent(handle);
};
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
channel.port2.postMessage(handle);
return handle;
};
}
function installReadyStateChangeImplementation() {
var html = doc.documentElement;
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
var script = doc.createElement("script");
script.onreadystatechange = function () {
runIfPresent(handle);
script.onreadystatechange = null;
html.removeChild(script);
script = null;
};
html.appendChild(script);
return handle;
};
}
function installSetTimeoutImplementation() {
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
setTimeout(partiallyApplied(runIfPresent, handle), 0);
return handle;
};
}
// If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
// Don't get fooled by e.g. browserify environments.
if ({}.toString.call(global.process) === "[object process]") {
// For Node.js before 0.9
installNextTickImplementation();
} else if (canUsePostMessage()) {
// For non-IE10 modern browsers
installPostMessageImplementation();
} else if (global.MessageChannel) {
// For web workers, where supported
installMessageChannelImplementation();
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
// For IE 6–8
installReadyStateChangeImplementation();
} else {
// For older browsers
installSetTimeoutImplementation();
}
attachTo.setImmediate = setImmediate;
attachTo.clearImmediate = clearImmediate;
})(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self);
/* WEBPACK VAR INJECTION */
}).call(exports, function () {
return this;
}(), __webpack_require__(10).clearImmediate, __webpack_require__(11));
/***/
},
/* 13 */
/***/function (module, exports, __webpack_require__) {
var isEmpty = __webpack_require__(14);
var isArray = __webpack_require__(7);
module.exports = function (topRules, minify, plugins, scope) {
var scopeTheSelector = function scopeTheSelector(selector) {
if (scope === '') return selector;
if (selector.indexOf(scope) === 0 || selector.indexOf('@') === 0) return selector;
return scope + ' ' + selector;
};
var applyPlugins = function applyPlugins(props) {
var n;
for (n = 0; n < plugins.length; n++) {
props = plugins[n](props);
}
return props;
};
var newLine = minify ? '' : '\n';
var interval = minify ? '' : ' ';
var tab = minify ? '' : ' ';
var process = function process(rules, indent) {
var css = '',
r,
prop,
props,
value;
var addLine = function addLine(line, noNewLine) {
css += line + (noNewLine ? '' : newLine);
};
var processRule = function processRule(rule) {
// console.log(rule);
if (!isEmpty(rule.props) || rule.nestedRules !== null) {
addLine(indent + scopeTheSelector(rule.selector) + interval + '{');
props = applyPlugins(rule.props);
for (prop in props) {
value = typeof props[prop] === 'function' ? props[prop]() : props[prop];
if (isArray(value)) {
value.forEach(function (v) {
addLine(indent + tab + prop + ':' + interval + v + ';');
});
} else {
addLine(indent + tab + prop + ':' + interval + value + ';');
}
}
if (rule.nestedRules) {
addLine(process(rule.nestedRules, indent + tab), true);
}
addLine(indent + '}');
}
};
indent = minify ? '' : indent;
if (isArray(rules)) {
rules.forEach(processRule);
} else {
for (r in rules) {
if (isArray(rules[r])) {
rules[r].forEach(processRule);
} else {
processRule(rules[r]);
}
}
};
return css;
};
return process(topRules, '');
};
/***/
},
/* 14 */
/***/function (module, exports) {
module.exports = function (obj) {
var prop;
for (prop in obj) {
if (obj.hasOwnProperty(prop)) {
return false;
}
}
return true;
};
/***/
},
/* 15 */
/***/function (module, exports) {
/* WEBPACK VAR INJECTION */(function (global) {
module.exports = function (api) {
if (typeof global !== 'undefined') {
global.cssx = api;
}
if (typeof window !== 'undefined') {
window.cssx = api;
}
};
/* WEBPACK VAR INJECTION */
}).call(exports, function () {
return this;
}());
/***/
},
/* 16 */
/***/function (module, exports) {
var ids = 0;
module.exports = function () {
return '_cssx' + ++ids;
};
module.exports.resetIDs = function () {
ids = 0;
};
/***/
}
/******/])
);
});
;
});
function makeInvisible(element) {
var oldVisibility = element.style.visibility,
oldTransition = element.style.transition;
element.style.transition = "none";
element.style.visibility = "hidden";
return function () {
element.style.visibility = oldVisibility;
/* force layout reflow to apply old visibility */
currentStyle(element, 'visibility');
element.style.transition = oldTransition;
};
}
function elementQualified(element) {
var styles = currentStyles(element);
return (/(block|flex|grid)$/.test(styles.display) && (!styles.transform || styles.transform === "none")
);
}
function fromPoint (x, y) {
var undo = [],
element,
last;
while ((element = document.elementFromPoint(x, y)) !== null && last !== element) {
if (withAncestors(element).every(elementQualified)) {
break;
}
undo.unshift(makeInvisible(element));
last = element;
}
undo.forEach(function (fn) {
return fn();
});
if (last === element || element === document.documentElement) {
return null;
}
return element;
}
function edgeDistance (element, x, y) {
var bounds = element.getBoundingClientRect();
return {
left: x - bounds.left,
top: y - bounds.top,
right: bounds.right - x,
bottom: bounds.bottom - y
};
}
function pointerEvents (point, select) {
var handlers = [];
var lastMousePos = void 0,
lastTouchPos = void 0,
lastTouchId = void 0;
function mouse(fn) {
return function (e) {
lastMousePos = [e.clientX, e.clientY];
fn.apply(undefined, toConsumableArray(lastMousePos));
};
}
function touch(fn, isStart) {
return function (e) {
var touch = void 0;
lastMousePos = null;
if (isStart) {
if (e.touches.length > 1) {
return;
}
touch = e.touches[0];
lastTouchId = touch.identifier;
} else {
for (var i = 0; i < e.changedTouches.length; ++i) {
if (e.changedTouches[i].identifier === lastTouchId) {
touch = e.changedTouches[i];
}
}
if (!touch) {
return;
}
}
lastTouchPos = [touch.clientX, touch.clientY];
fn.apply(undefined, toConsumableArray(lastTouchPos));
};
}
function click(e) {
if (lastMousePos) {
lastMousePos = [e.clientX, e.clientY];
select.apply(undefined, toConsumableArray(lastMousePos));
} else if (lastTouchPos) {
select.apply(undefined, toConsumableArray(lastTouchPos));
}
}
function pageScroll() {
if (lastMousePos) {
point.apply(undefined, toConsumableArray(lastMousePos));
}
}
var elem = document.documentElement;
handlers.push(addEventListener(elem, 'mousemove', mouse(point)));
handlers.push(addEventListener(elem, 'click', click));
handlers.push(addEventListener(elem, 'touchstart', touch(point, true)));
handlers.push(addEventListener(elem, 'touchmove', touch(point)));
handlers.push(addEventListener(elem, 'touchend', touch(point)));
handlers.push(addEventListener(elem, 'scroll', pageScroll));
return function () {
handlers.forEach(function (handler) {
handler.remove();
});
};
}
var __moduleExports$5 = createCommonjsModule(function (module) {
'use strict';
/* !
* type-detect
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
* MIT Licensed
*/
var getPrototypeOfExists = typeof Object.getPrototypeOf