Comparing version 1.7.2 to 2.0.0
# Change Log | ||
## Dom7 v2.0.0 - Released on September 11, 2017 | ||
* Removed XHR (Ajax) functionality | ||
* Removed `$.` utilities, including `$.parseUrlQuery`, `$.isArray`, `$.each`, `$.unique`, `$.serializeObject`, `$.dataset`, `$.extend` | ||
## Dom7 v1.7.2 - Released on September 7, 2017 | ||
@@ -4,0 +8,0 @@ * Fixed issue when calling `.show()` always set `display: block` not repsecting actual display property |
822
dist/dom7.js
/** | ||
* Dom7 1.7.2 | ||
* Dom7 2.0.0 | ||
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API | ||
@@ -12,3 +12,3 @@ * http://framework7.io/docs/dom.html | ||
* | ||
* Released on: September 7, 2017 | ||
* Released on: September 11, 2017 | ||
*/ | ||
@@ -103,54 +103,2 @@ (function (global, factory) { | ||
function parseUrlQuery(url) { | ||
var query = {}; | ||
var urlToParse = url || window.location.href; | ||
var i; | ||
var params; | ||
var param; | ||
var length; | ||
if (typeof urlToParse === 'string' && urlToParse.length) { | ||
urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : ''; | ||
params = urlToParse.split('&').filter(function (paramsPart) { return paramsPart !== ''; }); | ||
length = params.length; | ||
for (i = 0; i < length; i += 1) { | ||
param = params[i].replace(/#\S+/g, '').split('='); | ||
query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || ''; | ||
} | ||
} | ||
return query; | ||
} | ||
function isArray(arr) { | ||
return Array.isArray(arr); | ||
} | ||
function each(obj, callback) { | ||
// Check it's iterable | ||
// TODO: Should probably raise a value error here | ||
if (typeof obj !== 'object') { return; } | ||
// Don't bother continuing without a callback | ||
if (!callback) { return; } | ||
if (Array.isArray(obj) || obj instanceof Dom7) { | ||
// Array | ||
for (var i = 0; i < obj.length; i += 1) { | ||
// If callback returns false | ||
if (callback(i, obj[i]) === false) { | ||
// Break out of the loop | ||
return; | ||
} | ||
} | ||
} else { | ||
// Object | ||
for (var prop in obj) { | ||
// Check the propertie belongs to the object | ||
// not it's prototype | ||
if (obj.hasOwnProperty(prop)) { | ||
// If the callback returns false | ||
if (callback(prop, obj[prop]) === false) { | ||
// Break out of the loop; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
function unique(arr) { | ||
@@ -163,59 +111,6 @@ var uniqueArray = []; | ||
} | ||
function serializeObject(obj, parents) { | ||
if ( parents === void 0 ) parents = []; | ||
if (typeof obj === 'string') { return obj; } | ||
var resultArray = []; | ||
var separator = '&'; | ||
var newParents; | ||
function varName(name) { | ||
if (parents.length > 0) { | ||
var parentParts = ''; | ||
for (var j = 0; j < parents.length; j += 1) { | ||
if (j === 0) { parentParts += parents[j]; } | ||
else { parentParts += "[" + (encodeURIComponent(parents[j])) + "]"; } | ||
} | ||
return (parentParts + "[" + (encodeURIComponent(name)) + "]"); | ||
} | ||
return encodeURIComponent(name); | ||
} | ||
function varValue(value) { | ||
return encodeURIComponent(value); | ||
} | ||
Object.keys(obj).forEach(function (prop) { | ||
var toPush; | ||
if (Array.isArray(obj[prop])) { | ||
toPush = []; | ||
for (var i = 0; i < obj[prop].length; i += 1) { | ||
if (!Array.isArray(obj[prop][i]) && typeof obj[prop][i] === 'object') { | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
newParents.push(String(i)); | ||
toPush.push(serializeObject(obj[prop][i], newParents)); | ||
} else { | ||
toPush.push(((varName(prop)) + "[]=" + (varValue(obj[prop][i])))); | ||
} | ||
} | ||
if (toPush.length > 0) { resultArray.push(toPush.join(separator)); } | ||
} else if (obj[prop] === null || obj[prop] === '') { | ||
resultArray.push(((varName(prop)) + "=")); | ||
} else if (typeof obj[prop] === 'object') { | ||
// Object, convert to named array | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
toPush = serializeObject(obj[prop], newParents); | ||
if (toPush !== '') { resultArray.push(toPush); } | ||
} else if (typeof obj[prop] !== 'undefined' && obj[prop] !== '') { | ||
// Should be string or plain value | ||
resultArray.push(((varName(prop)) + "=" + (varValue(obj[prop])))); | ||
} else if (obj[prop] === '') { resultArray.push(varName(prop)); } | ||
}); | ||
return resultArray.join(separator); | ||
} | ||
function toCamelCase(string) { | ||
return string.toLowerCase().replace(/-(.)/g, function (match, group1) { return group1.toUpperCase(); }); | ||
} | ||
function dataset(el) { | ||
return $$1(el).dataset(); | ||
} | ||
function requestAnimationFrame(callback) { | ||
@@ -231,48 +126,3 @@ if (window.requestAnimationFrame) { return window.requestAnimationFrame(callback); } | ||
} | ||
function isObject(o) { | ||
return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; | ||
} | ||
function extend() { | ||
var args = [], len$1 = arguments.length; | ||
while ( len$1-- ) args[ len$1 ] = arguments[ len$1 ]; | ||
var to = Object(args[0]); | ||
for (var i = 1; i < args.length; i += 1) { | ||
var nextSource = args[i]; | ||
if (nextSource !== undefined && nextSource !== null) { | ||
var keysArray = Object.keys(Object(nextSource)); | ||
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { | ||
var nextKey = keysArray[nextIndex]; | ||
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); | ||
if (desc !== undefined && desc.enumerable) { | ||
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
to[nextKey] = {}; | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
} | ||
var Utils = { | ||
__utils: true, | ||
parseUrlQuery: parseUrlQuery, | ||
parseQuery: parseUrlQuery, | ||
isArray: isArray, | ||
each: each, | ||
unique: unique, | ||
serializeObject: serializeObject, | ||
param: serializeObject, | ||
toCamelCase: toCamelCase, | ||
dataset: dataset, | ||
requestAnimationFrame: requestAnimationFrame, | ||
cancelAnimationFrame: cancelAnimationFrame, | ||
extend: extend, | ||
}; | ||
var Methods = { | ||
@@ -416,9 +266,9 @@ // Classes and attributes | ||
}, | ||
dataset: function dataset$$1() { | ||
dataset: function dataset() { | ||
var el = this[0]; | ||
if (!el) { return undefined; } | ||
var dataset$$1 = {}; | ||
var dataset = {}; | ||
if (el.dataset) { | ||
for (var dataKey in el.dataset) { | ||
dataset$$1[dataKey] = el.dataset[dataKey]; | ||
dataset[dataKey] = el.dataset[dataKey]; | ||
} | ||
@@ -429,12 +279,12 @@ } else { | ||
if (attr.name.indexOf('data-') >= 0) { | ||
dataset$$1[toCamelCase(attr.name.split('data-')[1])] = attr.value; | ||
dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value; | ||
} | ||
} | ||
} | ||
for (var key in dataset$$1) { | ||
if (dataset$$1[key] === 'false') { dataset$$1[key] = false; } | ||
else if (dataset$$1[key] === 'true') { dataset$$1[key] = true; } | ||
else if (parseFloat(dataset$$1[key]) === dataset$$1[key] * 1) { dataset$$1[key] *= 1; } | ||
for (var key in dataset) { | ||
if (dataset[key] === 'false') { dataset[key] = false; } | ||
else if (dataset[key] === 'true') { dataset[key] = true; } | ||
else if (parseFloat(dataset[key]) === dataset[key] * 1) { dataset[key] *= 1; } | ||
} | ||
return dataset$$1; | ||
return dataset; | ||
}, | ||
@@ -801,3 +651,3 @@ val: function val(value) { | ||
// Iterate over the collection passing elements to `callback` | ||
each: function each$$1(callback) { | ||
each: function each(callback) { | ||
var this$1 = this; | ||
@@ -1351,519 +1201,193 @@ | ||
function animate(initialProps, initialParams) { | ||
var els = this; | ||
var a = { | ||
props: $$1.extend({}, initialProps), | ||
params: $$1.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
var Animate = { | ||
animate: function animate(initialProps, initialParams) { | ||
var els = this; | ||
var a = { | ||
props: $$1.extend({}, initialProps), | ||
params: $$1.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
easingProgress: function easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop: function stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each(function (index, el) { | ||
var element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done: function done(complete) { | ||
a.animating = false; | ||
a.elements.each(function (index, el) { | ||
var element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) { complete(els); } | ||
if (a.que.length > 0) { | ||
var que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate: function animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
var elements = []; | ||
easingProgress: function easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop: function stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each(function (index, el) { | ||
var element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done: function done(complete) { | ||
a.animating = false; | ||
a.elements.each(function (index, el) { | ||
var element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) { complete(els); } | ||
if (a.que.length > 0) { | ||
var que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate: function animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
var elements = []; | ||
// Define & Cache Initials & Units | ||
a.elements.each(function (index, el) { | ||
var initialFullValue; | ||
var initialValue; | ||
var unit; | ||
var finalValue; | ||
var finalFullValue; | ||
// Define & Cache Initials & Units | ||
a.elements.each(function (index, el) { | ||
var initialFullValue; | ||
var initialValue; | ||
var unit; | ||
var finalValue; | ||
var finalFullValue; | ||
if (!el.dom7AnimateInstance) { a.elements[index].dom7AnimateInstance = a; } | ||
if (!el.dom7AnimateInstance) { a.elements[index].dom7AnimateInstance = a; } | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach(function (prop) { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue: initialFullValue, | ||
initialValue: initialValue, | ||
unit: unit, | ||
finalValue: finalValue, | ||
finalFullValue: finalFullValue, | ||
currentValue: initialValue, | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach(function (prop) { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue: initialFullValue, | ||
initialValue: initialValue, | ||
unit: unit, | ||
finalValue: finalValue, | ||
finalFullValue: finalFullValue, | ||
currentValue: initialValue, | ||
}; | ||
}); | ||
}); | ||
}); | ||
var startTime = null; | ||
var time; | ||
var elementsDone = 0; | ||
var propsDone = 0; | ||
var done; | ||
var began = false; | ||
var startTime = null; | ||
var time; | ||
var elementsDone = 0; | ||
var propsDone = 0; | ||
var done; | ||
var began = false; | ||
a.animating = true; | ||
a.animating = true; | ||
function render() { | ||
time = new Date().getTime(); | ||
var progress; | ||
var easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) { params.begin(els); } | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
function render() { | ||
time = new Date().getTime(); | ||
var progress; | ||
var easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) { params.begin(els); } | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
elements.forEach(function (element) { | ||
var el = element; | ||
if (done || el.done) { return; } | ||
Object.keys(props).forEach(function (prop) { | ||
elements.forEach(function (element) { | ||
var el = element; | ||
if (done || el.done) { return; } | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
var ref = el[prop]; | ||
var initialValue = ref.initialValue; | ||
var finalValue = ref.finalValue; | ||
var unit = ref.unit; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
var currentValue = el[prop].currentValue; | ||
Object.keys(props).forEach(function (prop) { | ||
if (done || el.done) { return; } | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
var ref = el[prop]; | ||
var initialValue = ref.initialValue; | ||
var finalValue = ref.finalValue; | ||
var unit = ref.unit; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
var currentValue = el[prop].currentValue; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
} | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
} | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
el.container.style[prop] = currentValue + unit; | ||
el.container.style[prop] = currentValue + unit; | ||
}); | ||
}); | ||
}); | ||
if (done) { return; } | ||
// Then call | ||
if (done) { return; } | ||
// Then call | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
return a; | ||
}, | ||
}; | ||
return a; | ||
}, | ||
}; | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
var animateInstance; | ||
for (var i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else { a.elements[i].dom7AnimateInstance = a; } | ||
} | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
return els; | ||
} | ||
function stop() { | ||
var els = this; | ||
for (var i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
} | ||
} | ||
var Animate = { | ||
animate: animate, | ||
stop: stop, | ||
}; | ||
// Global Ajax Setup | ||
var globalAjaxOptions = {}; | ||
function ajaxSetup(options) { | ||
if (options.type && !options.method) { options.method = options.type; } | ||
each(options, function (optionName, optionValue) { | ||
globalAjaxOptions[optionName] = optionValue; | ||
}); | ||
} | ||
// JSONP Requests | ||
var jsonpRequests = 0; | ||
// Ajax | ||
function ajax(options) { | ||
var defaults = { | ||
method: 'GET', | ||
data: false, | ||
async: true, | ||
cache: true, | ||
user: '', | ||
password: '', | ||
headers: {}, | ||
xhrFields: {}, | ||
statusCode: {}, | ||
processData: true, | ||
dataType: 'text', | ||
contentType: 'application/x-www-form-urlencoded', | ||
timeout: 0, | ||
}; | ||
var callbacks = ['beforeSend', 'error', 'complete', 'success', 'statusCode']; | ||
// For jQuery guys | ||
if (options.type) { options.method = options.type; } | ||
// Global options | ||
var globals = globalAjaxOptions; | ||
// Merge global and defaults | ||
each(globals, function (globalOptionName, globalOptionValue) { | ||
if (callbacks.indexOf(globalOptionName) < 0) { defaults[globalOptionName] = globalOptionValue; } | ||
}); | ||
// Function to run XHR callbacks and events | ||
function fireAjaxCallback(eventName, eventData, callbackName) { | ||
var a = arguments; | ||
if (eventName) { $$1(document).trigger(eventName, eventData); } | ||
if (callbackName) { | ||
// Global callback | ||
if (callbackName in globals) { globals[callbackName](a[3], a[4], a[5], a[6]); } | ||
// Options callback | ||
if (options[callbackName]) { options[callbackName](a[3], a[4], a[5], a[6]); } | ||
var animateInstance; | ||
for (var i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else { a.elements[i].dom7AnimateInstance = a; } | ||
} | ||
} | ||
// Merge options and defaults | ||
each(defaults, function (prop, defaultValue) { | ||
if (!(prop in options)) { options[prop] = defaultValue; } | ||
}); | ||
// Default URL | ||
if (!options.url) { | ||
options.url = window.location.toString(); | ||
} | ||
// Parameters Prefix | ||
var paramsPrefix = options.url.indexOf('?') >= 0 ? '&' : '?'; | ||
// UC method | ||
var method = options.method.toUpperCase(); | ||
// Data to modify GET URL | ||
if ((method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') && options.data) { | ||
var stringData; | ||
if (typeof options.data === 'string') { | ||
// Should be key=value string | ||
if (options.data.indexOf('?') >= 0) { stringData = options.data.split('?')[1]; } | ||
else { stringData = options.data; } | ||
} else { | ||
// Should be key=value object | ||
stringData = serializeObject(options.data); | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (stringData.length) { | ||
options.url += paramsPrefix + stringData; | ||
if (paramsPrefix === '?') { paramsPrefix = '&'; } | ||
} | ||
} | ||
// JSONP | ||
if (options.dataType === 'json' && options.url.indexOf('callback=') >= 0) { | ||
var callbackName = "f7jsonp_" + (Date.now() + ((jsonpRequests += 1))); | ||
var abortTimeout; | ||
var callbackSplit = options.url.split('callback='); | ||
var requestUrl = (callbackSplit[0]) + "callback=" + callbackName; | ||
if (callbackSplit[1].indexOf('&') >= 0) { | ||
var addVars = callbackSplit[1].split('&').filter(function (el) { return el.indexOf('=') > 0; }).join('&'); | ||
if (addVars.length > 0) { requestUrl += "&" + addVars; } | ||
} | ||
// Create script | ||
var script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.onerror = function onerror() { | ||
clearTimeout(abortTimeout); | ||
fireAjaxCallback(undefined, undefined, 'error', null, 'scripterror'); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { scripterror: true }, 'complete', null, 'scripterror'); | ||
}; | ||
script.src = requestUrl; | ||
// Handler | ||
window[callbackName] = function jsonpCallback(data) { | ||
clearTimeout(abortTimeout); | ||
fireAjaxCallback(undefined, undefined, 'success', data); | ||
script.parentNode.removeChild(script); | ||
script = null; | ||
delete window[callbackName]; | ||
}; | ||
document.querySelector('head').appendChild(script); | ||
if (options.timeout > 0) { | ||
abortTimeout = setTimeout(function () { | ||
script.parentNode.removeChild(script); | ||
script = null; | ||
fireAjaxCallback(undefined, undefined, 'error', null, 'timeout'); | ||
}, options.timeout); | ||
} | ||
return; | ||
} | ||
// Cache for GET/HEAD requests | ||
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') { | ||
if (options.cache === false) { | ||
options.url += paramsPrefix + "_nocache" + (Date.now()); | ||
} | ||
} | ||
// Create XHR | ||
var xhr = new XMLHttpRequest(); | ||
// Save Request URL | ||
xhr.requestUrl = options.url; | ||
xhr.requestParameters = options; | ||
// Open XHR | ||
xhr.open(method, options.url, options.async, options.user, options.password); | ||
// Create POST Data | ||
var postData = null; | ||
if ((method === 'POST' || method === 'PUT' || method === 'PATCH') && options.data) { | ||
if (options.processData) { | ||
var postDataInstances = [ArrayBuffer, Blob, Document, FormData]; | ||
// Post Data | ||
if (postDataInstances.indexOf(options.data.constructor) >= 0) { | ||
postData = options.data; | ||
} else { | ||
// POST Headers | ||
var boundary = "---------------------------" + (Date.now().toString(16)); | ||
if (options.contentType === 'multipart/form-data') { | ||
xhr.setRequestHeader('Content-Type', ("multipart/form-data; boundary=" + boundary)); | ||
} else { | ||
xhr.setRequestHeader('Content-Type', options.contentType); | ||
} | ||
postData = ''; | ||
var data = serializeObject(options.data); | ||
if (options.contentType === 'multipart/form-data') { | ||
data = data.split('&'); | ||
var newData = []; | ||
for (var i = 0; i < data.length; i += 1) { | ||
newData.push(("Content-Disposition: form-data; name=\"" + (data[i].split('=')[0]) + "\"\r\n\r\n" + (data[i].split('=')[1]) + "\r\n")); | ||
} | ||
postData = "--" + boundary + "\r\n" + (newData.join(("--" + boundary + "\r\n"))) + "--" + boundary + "--\r\n"; | ||
} else { | ||
postData = data; | ||
} | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
postData = options.data; | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
} | ||
// Additional headers | ||
if (options.headers) { | ||
each(options.headers, function (headerName, headerCallback) { | ||
xhr.setRequestHeader(headerName, headerCallback); | ||
}); | ||
} | ||
return els; | ||
}, | ||
// Check for crossDomain | ||
if (typeof options.crossDomain === 'undefined') { | ||
options.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(options.url) && RegExp.$2 !== window.location.host; | ||
} | ||
if (!options.crossDomain) { | ||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
} | ||
if (options.xhrFields) { | ||
each(options.xhrFields, function (fieldName, fieldValue) { | ||
xhr[fieldName] = fieldValue; | ||
}); | ||
} | ||
var xhrTimeout; | ||
// Handle XHR | ||
xhr.onload = function onload() { | ||
if (xhrTimeout) { clearTimeout(xhrTimeout); } | ||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) { | ||
var responseData; | ||
if (options.dataType === 'json') { | ||
try { | ||
responseData = JSON.parse(xhr.responseText); | ||
fireAjaxCallback('ajaxSuccess ajax:success', { xhr: xhr }, 'success', responseData, xhr.status, xhr); | ||
} catch (err) { | ||
fireAjaxCallback('ajaxError ajax:error', { xhr: xhr, parseerror: true }, 'error', xhr, 'parseerror'); | ||
} | ||
} else { | ||
responseData = xhr.responseType === 'text' || xhr.responseType === '' ? xhr.responseText : xhr.response; | ||
fireAjaxCallback('ajaxSuccess ajax:success', { xhr: xhr }, 'success', responseData, xhr.status, xhr); | ||
stop: function stop() { | ||
var els = this; | ||
for (var i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
} | ||
} else { | ||
fireAjaxCallback('ajaxError ajax:error', { xhr: xhr }, 'error', xhr, xhr.status); | ||
} | ||
if (options.statusCode) { | ||
if (globals.statusCode && globals.statusCode[xhr.status]) { globals.statusCode[xhr.status](xhr); } | ||
if (options.statusCode[xhr.status]) { options.statusCode[xhr.status](xhr); } | ||
} | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr: xhr }, 'complete', xhr, xhr.status); | ||
}; | ||
xhr.onerror = function onerror() { | ||
if (xhrTimeout) { clearTimeout(xhrTimeout); } | ||
fireAjaxCallback('ajaxError ajax:error', { xhr: xhr }, 'error', xhr, xhr.status); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr: xhr, error: true }, 'complete', xhr, 'error'); | ||
}; | ||
// Ajax start callback | ||
fireAjaxCallback('ajaxStart ajax:start', { xhr: xhr }, 'start', xhr); | ||
fireAjaxCallback(undefined, undefined, 'beforeSend', xhr); | ||
// Timeout | ||
if (options.timeout > 0) { | ||
xhr.onabort = function onabort() { | ||
if (xhrTimeout) { clearTimeout(xhrTimeout); } | ||
}; | ||
xhrTimeout = setTimeout(function () { | ||
xhr.abort(); | ||
fireAjaxCallback('ajaxError ajax:error', { xhr: xhr, timeout: true }, 'error', xhr, 'timeout'); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr: xhr, timeout: true }, 'complete', xhr, 'timeout'); | ||
}, options.timeout); | ||
} | ||
// Send XHR | ||
xhr.send(postData); | ||
// Return XHR object | ||
return xhr; | ||
} | ||
function ajaxShortcut(method) { | ||
var args = [], len = arguments.length - 1; | ||
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; | ||
var url; | ||
var data; | ||
var success; | ||
var error; | ||
var dataType; | ||
if (typeof args[1] === 'function') { | ||
var assign; | ||
(assign = args, url = assign[0], success = assign[1], error = assign[2], dataType = assign[3]); | ||
} else { | ||
var assign$1; | ||
(assign$1 = args, url = assign$1[0], data = assign$1[1], success = assign$1[2], error = assign$1[3], dataType = assign$1[4]); | ||
} | ||
[success, error].forEach(function (callback) { | ||
if (typeof callback === 'string') { | ||
dataType = callback; | ||
if (callback === success) { success = undefined; } | ||
else { error = undefined; } | ||
} | ||
}); | ||
dataType = dataType || (method === 'getJSON' ? 'json' : undefined); | ||
return ajax({ | ||
url: url, | ||
method: method === 'post' ? 'POST' : 'GET', | ||
data: data, | ||
success: success, | ||
error: error, | ||
dataType: dataType, | ||
}); | ||
} | ||
function get() { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
args.unshift('get'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
function post() { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
args.unshift('post'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
function getJSON() { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
args.unshift('getJSON'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
var Ajax = { | ||
__utils: true, | ||
ajaxSetup: ajaxSetup, | ||
ajax: ajax, | ||
get: get, | ||
post: post, | ||
getJSON: getJSON, | ||
}, | ||
}; | ||
// Utils & Helpers | ||
$$1.use(Utils, Methods, Scroll, Animate, Ajax); | ||
// Install methods | ||
$$1.use(Methods, Scroll, Animate); | ||
@@ -1870,0 +1394,0 @@ return $$1; |
/** | ||
* Dom7 1.7.2 | ||
* Dom7 2.0.0 | ||
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API | ||
@@ -12,4 +12,4 @@ * http://framework7.io/docs/dom.html | ||
* | ||
* Released on: September 7, 2017 | ||
*/!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Dom7=e()}(this,function(){"use strict";function t(t,e){var n=[],r=0;if(t&&!e&&t instanceof x)return t;if(t)if("string"==typeof t){var i,o,s=t.trim();if(s.indexOf("<")>=0&&s.indexOf(">")>=0){var a="div";for(0===s.indexOf("<li")&&(a="ul"),0===s.indexOf("<tr")&&(a="tbody"),0!==s.indexOf("<td")&&0!==s.indexOf("<th")||(a="tr"),0===s.indexOf("<tbody")&&(a="table"),0===s.indexOf("<option")&&(a="select"),o=document.createElement(a),o.innerHTML=s,r=0;r<o.childNodes.length;r+=1)n.push(o.childNodes[r])}else for(i=e||"#"!==t[0]||t.match(/[ .<>:~]/)?(e||document).querySelectorAll(t.trim()):[document.getElementById(t.trim().split("#")[1])],r=0;r<i.length;r+=1)i[r]&&n.push(i[r])}else if(t.nodeType||t===window||t===document)n.push(t);else if(t.length>0&&t[0].nodeType)for(r=0;r<t.length;r+=1)n.push(t[r]);return new x(n)}function e(t){var e,n,r,i,o={},s=t||window.location.href;if("string"==typeof s&&s.length)for(s=s.indexOf("?")>-1?s.replace(/\S*\?/,""):"",n=s.split("&").filter(function(t){return""!==t}),i=n.length,e=0;e<i;e+=1)r=n[e].replace(/#\S+/g,"").split("="),o[decodeURIComponent(r[0])]=void 0===r[1]?void 0:decodeURIComponent(r[1])||"";return o}function n(t){return Array.isArray(t)}function r(t,e){if("object"==typeof t&&e)if(Array.isArray(t)||t instanceof x){for(var n=0;n<t.length;n+=1)if(!1===e(n,t[n]))return}else for(var r in t)if(t.hasOwnProperty(r)&&!1===e(r,t[r]))return}function i(t){for(var e=[],n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}function o(t,e){function n(t){if(e.length>0){for(var n="",r=0;r<e.length;r+=1)n+=0===r?e[r]:"["+encodeURIComponent(e[r])+"]";return n+"["+encodeURIComponent(t)+"]"}return encodeURIComponent(t)}function r(t){return encodeURIComponent(t)}if(void 0===e&&(e=[]),"string"==typeof t)return t;var i,s=[];return Object.keys(t).forEach(function(a){var l;if(Array.isArray(t[a])){l=[];for(var u=0;u<t[a].length;u+=1)Array.isArray(t[a][u])||"object"!=typeof t[a][u]?l.push(n(a)+"[]="+r(t[a][u])):(i=e.slice(),i.push(a),i.push(String(u)),l.push(o(t[a][u],i)));l.length>0&&s.push(l.join("&"))}else null===t[a]||""===t[a]?s.push(n(a)+"="):"object"==typeof t[a]?(i=e.slice(),i.push(a),""!==(l=o(t[a],i))&&s.push(l)):void 0!==t[a]&&""!==t[a]?s.push(n(a)+"="+r(t[a])):""===t[a]&&s.push(n(a))}),s.join("&")}function s(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function a(e){return t(e).dataset()}function l(t){return window.requestAnimationFrame?window.requestAnimationFrame(t):window.webkitRequestAnimationFrame?window.webkitRequestAnimationFrame(t):window.setTimeout(t,1e3/60)}function u(t){return window.cancelAnimationFrame?window.cancelAnimationFrame(t):window.webkitCancelAnimationFrame?window.webkitCancelAnimationFrame(t):window.clearTimeout(t)}function f(t){return"object"==typeof t&&null!==t&&t.constructor&&t.constructor===Object}function h(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var n=Object(t[0]),r=1;r<t.length;r+=1){var i=t[r];if(void 0!==i&&null!==i)for(var o=Object.keys(Object(i)),s=0,a=o.length;s<a;s+=1){var l=o[s],u=Object.getOwnPropertyDescriptor(i,l);void 0!==u&&u.enumerable&&(f(n[l])&&f(i[l])?h(n[l],i[l]):!f(n[l])&&f(i[l])?(n[l]={},h(n[l],i[l])):n[l]=i[l])}}return n}function c(e,n){var r=this,i={props:t.extend({},e),params:t.extend({duration:300,easing:"swing"},n),elements:r,animating:!1,que:[],easingProgress:function(t,e){return"swing"===t?.5-Math.cos(e*Math.PI)/2:"function"==typeof t?t(e):e},stop:function(){i.frameId&&u(i.frameId),i.animating=!1,i.elements.each(function(t,e){delete e.dom7AnimateInstance}),i.que=[]},done:function(t){if(i.animating=!1,i.elements.each(function(t,e){delete e.dom7AnimateInstance}),t&&t(r),i.que.length>0){var e=i.que.shift();i.animate(e[0],e[1])}},animate:function(t,e){function n(){s=(new Date).getTime();var d,p;c||(c=!0,e.begin&&e.begin(r)),null===u&&(u=s),e.progress&&e.progress(r,Math.max(Math.min((s-u)/e.duration,1),0),u+e.duration-s<0?0:u+e.duration-s,u),o.forEach(function(n){var r=n;a||r.done||Object.keys(t).forEach(function(n){if(!a&&!r.done){d=Math.max(Math.min((s-u)/e.duration,1),0),p=i.easingProgress(e.easing,d);var l=r[n],c=l.initialValue,v=l.finalValue,m=l.unit;r[n].currentValue=c+p*(v-c);var g=r[n].currentValue;if((v>c&&g>=v||v<c&&g<=v)&&(r.container.style[n]=v+m,h+=1,h===Object.keys(t).length&&(r.done=!0,f+=1),f===o.length&&(a=!0)),a)return void i.done(e.complete);r.container.style[n]=g+m}})}),a||(i.frameId=l(n))}if(i.animating)return i.que.push([t,e]),i;var o=[];i.elements.each(function(e,n){var r,s,a,l,u;n.dom7AnimateInstance||(i.elements[e].dom7AnimateInstance=i),o[e]={container:n},Object.keys(t).forEach(function(i){r=window.getComputedStyle(n,null).getPropertyValue(i).replace(",","."),s=parseFloat(r),a=r.replace(s,""),l=parseFloat(t[i]),u=t[i]+a,o[e][i]={initialFullValue:r,initialValue:s,unit:a,finalValue:l,finalFullValue:u,currentValue:s}})});var s,a,u=null,f=0,h=0,c=!1;return i.animating=!0,i.frameId=l(n),i}};if(0===i.elements.length)return r;for(var o,s=0;s<i.elements.length;s+=1)i.elements[s].dom7AnimateInstance?o=i.elements[s].dom7AnimateInstance:i.elements[s].dom7AnimateInstance=i;return o||(o=i),"stop"===e?o.stop():o.animate(i.props,i.params),r}function d(){for(var t=this,e=0;e<t.length;e+=1)t[e].dom7AnimateInstance&&t[e].dom7AnimateInstance.stop()}function p(t){t.type&&!t.method&&(t.method=t.type),r(t,function(t,e){A[t]=e})}function v(e){function n(n,r,i){var o=arguments;n&&t(document).trigger(n,r),i&&(i in a&&a[i](o[3],o[4],o[5],o[6]),e[i]&&e[i](o[3],o[4],o[5],o[6]))}var i={method:"GET",data:!1,async:!0,cache:!0,user:"",password:"",headers:{},xhrFields:{},statusCode:{},processData:!0,dataType:"text",contentType:"application/x-www-form-urlencoded",timeout:0},s=["beforeSend","error","complete","success","statusCode"];e.type&&(e.method=e.type);var a=A;r(a,function(t,e){s.indexOf(t)<0&&(i[t]=e)}),r(i,function(t,n){t in e||(e[t]=n)}),e.url||(e.url=window.location.toString());var l=e.url.indexOf("?")>=0?"&":"?",u=e.method.toUpperCase();if(("GET"===u||"HEAD"===u||"OPTIONS"===u||"DELETE"===u)&&e.data){var f;f="string"==typeof e.data?e.data.indexOf("?")>=0?e.data.split("?")[1]:e.data:o(e.data),f.length&&(e.url+=l+f,"?"===l&&(l="&"))}if("json"===e.dataType&&e.url.indexOf("callback=")>=0){var h,c="f7jsonp_"+(Date.now()+(O+=1)),d=e.url.split("callback="),p=d[0]+"callback="+c;if(d[1].indexOf("&")>=0){var v=d[1].split("&").filter(function(t){return t.indexOf("=")>0}).join("&");v.length>0&&(p+="&"+v)}var m=document.createElement("script");return m.type="text/javascript",m.onerror=function(){clearTimeout(h),n(void 0,void 0,"error",null,"scripterror"),n("ajaxComplete ajax:complete",{scripterror:!0},"complete",null,"scripterror")},m.src=p,window[c]=function(t){clearTimeout(h),n(void 0,void 0,"success",t),m.parentNode.removeChild(m),m=null,delete window[c]},document.querySelector("head").appendChild(m),void(e.timeout>0&&(h=setTimeout(function(){m.parentNode.removeChild(m),m=null,n(void 0,void 0,"error",null,"timeout")},e.timeout)))}"GET"!==u&&"HEAD"!==u&&"OPTIONS"!==u&&"DELETE"!==u||!1===e.cache&&(e.url+=l+"_nocache"+Date.now());var g=new XMLHttpRequest;g.requestUrl=e.url,g.requestParameters=e,g.open(u,e.url,e.async,e.user,e.password);var y=null;if(("POST"===u||"PUT"===u||"PATCH"===u)&&e.data)if(e.processData){var w=[ArrayBuffer,Blob,Document,FormData];if(w.indexOf(e.data.constructor)>=0)y=e.data;else{var x="---------------------------"+Date.now().toString(16);"multipart/form-data"===e.contentType?g.setRequestHeader("Content-Type","multipart/form-data; boundary="+x):g.setRequestHeader("Content-Type",e.contentType),y="";var b=o(e.data);if("multipart/form-data"===e.contentType){b=b.split("&");for(var E=[],T=0;T<b.length;T+=1)E.push('Content-Disposition: form-data; name="'+b[T].split("=")[0]+'"\r\n\r\n'+b[T].split("=")[1]+"\r\n");y="--"+x+"\r\n"+E.join("--"+x+"\r\n")+"--"+x+"--\r\n"}else y=b}}else y=e.data;e.headers&&r(e.headers,function(t,e){g.setRequestHeader(t,e)}),void 0===e.crossDomain&&(e.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(e.url)&&RegExp.$2!==window.location.host),e.crossDomain||g.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.xhrFields&&r(e.xhrFields,function(t,e){g[t]=e});var L;return g.onload=function(){if(L&&clearTimeout(L),g.status>=200&&g.status<300||0===g.status){var t;if("json"===e.dataType)try{t=JSON.parse(g.responseText),n("ajaxSuccess ajax:success",{xhr:g},"success",t,g.status,g)}catch(t){n("ajaxError ajax:error",{xhr:g,parseerror:!0},"error",g,"parseerror")}else t="text"===g.responseType||""===g.responseType?g.responseText:g.response,n("ajaxSuccess ajax:success",{xhr:g},"success",t,g.status,g)}else n("ajaxError ajax:error",{xhr:g},"error",g,g.status);e.statusCode&&(a.statusCode&&a.statusCode[g.status]&&a.statusCode[g.status](g),e.statusCode[g.status]&&e.statusCode[g.status](g)),n("ajaxComplete ajax:complete",{xhr:g},"complete",g,g.status)},g.onerror=function(){L&&clearTimeout(L),n("ajaxError ajax:error",{xhr:g},"error",g,g.status),n("ajaxComplete ajax:complete",{xhr:g,error:!0},"complete",g,"error")},n("ajaxStart ajax:start",{xhr:g},"start",g),n(void 0,void 0,"beforeSend",g),e.timeout>0&&(g.onabort=function(){L&&clearTimeout(L)},L=setTimeout(function(){g.abort(),n("ajaxError ajax:error",{xhr:g,timeout:!0},"error",g,"timeout"),n("ajaxComplete ajax:complete",{xhr:g,timeout:!0},"complete",g,"timeout")},e.timeout)),g.send(y),g}function m(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r,i,o,s,a;if("function"==typeof e[1]){var l;l=e,r=l[0],o=l[1],s=l[2],a=l[3]}else{var u;u=e,r=u[0],i=u[1],o=u[2],s=u[3],a=u[4]}return[o,s].forEach(function(t){"string"==typeof t&&(a=t,t===o?o=void 0:s=void 0)}),a=a||("getJSON"===t?"json":void 0),v({url:r,method:"post"===t?"POST":"GET",data:i,success:o,error:s,dataType:a})}function g(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.unshift("get"),m.apply(this,t)}function y(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.unshift("post"),m.apply(this,t)}function w(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.unshift("getJSON"),m.apply(this,t)}var x=function(t){for(var e=this,n=0;n<t.length;n+=1)e[n]=t[n];return e.length=t.length,this};t.fn=x.prototype,t.Class=x,t.use=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];e.forEach(function(e){var n="__utils"in e;Object.keys(e).forEach(function(r){"__utils"!==r&&(n?t[r]=e[r]:t.fn[r]=e[r])})})};for(var b={__utils:!0,parseUrlQuery:e,parseQuery:e,isArray:n,each:r,unique:i,serializeObject:o,param:o,toCamelCase:s,dataset:a,requestAnimationFrame:l,cancelAnimationFrame:u,extend:h},E=({addClass:function(t){var e=this;if(void 0===t)return this;for(var n=t.split(" "),r=0;r<n.length;r+=1)for(var i=0;i<this.length;i+=1)void 0!==e[i].classList&&e[i].classList.add(n[r]);return this},removeClass:function(t){for(var e=this,n=t.split(" "),r=0;r<n.length;r+=1)for(var i=0;i<this.length;i+=1)void 0!==e[i].classList&&e[i].classList.remove(n[r]);return this},hasClass:function(t){return!!this[0]&&this[0].classList.contains(t)},toggleClass:function(t){for(var e=this,n=t.split(" "),r=0;r<n.length;r+=1)for(var i=0;i<this.length;i+=1)void 0!==e[i].classList&&e[i].classList.toggle(n[r]);return this},attr:function(t,e){var n=arguments,r=this;if(1!==arguments.length||"string"!=typeof t){for(var i=0;i<this.length;i+=1)if(2===n.length)r[i].setAttribute(t,e);else for(var o in t)r[i][o]=t[o],r[i].setAttribute(o,t[o]);return this}if(this[0])return this[0].getAttribute(t)},removeAttr:function(t){for(var e=this,n=0;n<this.length;n+=1)e[n].removeAttribute(t);return this},prop:function(t,e){var n=arguments,r=this;if(1!==arguments.length||"string"!=typeof t){for(var i=0;i<this.length;i+=1)if(2===n.length)r[i][t]=e;else for(var o in t)r[i][o]=t[o];return this}if(this[0])return this[0][t]},data:function(t,e){var n,r=this;if(void 0!==e){for(var i=0;i<this.length;i+=1)n=r[i],n.dom7ElementDataStorage||(n.dom7ElementDataStorage={}),n.dom7ElementDataStorage[t]=e;return this}if(n=this[0]){if(n.dom7ElementDataStorage&&t in n.dom7ElementDataStorage)return n.dom7ElementDataStorage[t];var o=n.getAttribute("data-"+t);if(o)return o}else;},removeData:function(t){for(var e=this,n=0;n<this.length;n+=1){var r=e[n];r.dom7ElementDataStorage&&r.dom7ElementDataStorage[t]&&(r.dom7ElementDataStorage[t]=null,delete r.dom7ElementDataStorage[t])}},dataset:function(){var t=this[0];if(t){var e={};if(t.dataset)for(var n in t.dataset)e[n]=t.dataset[n];else for(var r=0;r<t.attributes.length;r+=1){var i=t.attributes[r];i.name.indexOf("data-")>=0&&(e[s(i.name.split("data-")[1])]=i.value)}for(var o in e)"false"===e[o]?e[o]=!1:"true"===e[o]?e[o]=!0:parseFloat(e[o])===1*e[o]&&(e[o]*=1);return e}},val:function(t){var e=this;{if(void 0!==t){for(var n=0;n<this.length;n+=1)e[n].value=t;return this}if(this[0]){if(this[0].multiple&&"select"===this[0].nodeName.toLowerCase()){for(var r=[],i=0;i<this[0].selectedOptions.length;i+=1)r.push(e[0].selectedOptions[i].value);return r}return this[0].value}}},transform:function(t){for(var e=this,n=0;n<this.length;n+=1){var r=e[n].style;r.webkitTransform=t,r.transform=t}return this},transition:function(t){var e=this;"string"!=typeof t&&(t+="ms");for(var n=0;n<this.length;n+=1){var r=e[n].style;r.webkitTransitionDuration=t,r.transitionDuration=t}return this},on:function(){function e(e){var n=e.target;if(n){var r=e.target.dom7EventData||[];if(r.unshift(e),t(n).is(s))a.apply(n,r);else for(var i=t(n).parents(),o=0;o<i.length;o+=1)t(i[o]).is(s)&&a.apply(i[o],r)}}function n(t){var e=t&&t.target?t.target.dom7EventData||[]:[];e.unshift(t),a.apply(this,e)}for(var r=this,i=[],o=arguments.length;o--;)i[o]=arguments[o];var s,a,l=i[0],u=!1;"function"==typeof i[1]?(s=!1,a=i[1],u=i[2]):(s=i[1],a=i[2],u=i[3]);for(var f,h=l.split(" "),c=0;c<this.length;c+=1){var d=r[c];if(s)for(f=0;f<h.length;f+=1)d.dom7LiveListeners||(d.dom7LiveListeners=[]),d.dom7LiveListeners.push({type:l,listener:a,proxyListener:e}),d.addEventListener(h[f],e,u);else for(f=0;f<h.length;f+=1)d.dom7Listeners||(d.dom7Listeners=[]),d.dom7Listeners.push({type:l,listener:a,proxyListener:n}),d.addEventListener(h[f],n,u)}return this},off:function(){for(var t=this,e=[],n=arguments.length;n--;)e[n]=arguments[n];var r,i,o=e[0],s=!1;"function"==typeof e[1]?(r=!1,i=e[1],s=e[2]):(r=e[1],i=e[2],s=e[3]);for(var a=o.split(" "),l=0;l<a.length;l+=1)for(var u=0;u<this.length;u+=1){var f=t[u];if(r){if(f.dom7LiveListeners)for(var h=0;h<f.dom7LiveListeners.length;h+=1)i?f.dom7LiveListeners[h].listener===i&&f.removeEventListener(a[l],f.dom7LiveListeners[h].proxyListener,s):f.dom7LiveListeners[h].type===a[l]&&f.removeEventListener(a[l],f.dom7LiveListeners[h].proxyListener,s)}else if(f.dom7Listeners)for(var c=0;c<f.dom7Listeners.length;c+=1)i?f.dom7Listeners[c].listener===i&&f.removeEventListener(a[l],f.dom7Listeners[c].proxyListener,s):f.dom7Listeners[c].type===a[l]&&f.removeEventListener(a[l],f.dom7Listeners[c].proxyListener,s)}return this},once:function(t,e,n,r){function i(s){var a=s.target.dom7EventData||[];n.apply(this,a),o.off(t,e,i,r)}var o=this;return"function"==typeof e&&(n=arguments[1],r=arguments[2],e=!1),o.on(t,e,i,r)},trigger:function(){for(var t=this,e=[],n=arguments.length;n--;)e[n]=arguments[n];for(var r=e[0].split(" "),i=e[1],o=0;o<r.length;o+=1)for(var s=0;s<this.length;s+=1){var a=void 0;try{a=new window.CustomEvent(r[o],{detail:i,bubbles:!0,cancelable:!0})}catch(t){a=document.createEvent("Event"),a.initEvent(r[o],!0,!0),a.detail=i}t[s].dom7EventData=e.filter(function(t,e){return e>0}),t[s].dispatchEvent(a),t[s].dom7EventData=[],delete t[s].dom7EventData}return this},transitionEnd:function(t){function e(o){if(o.target===this)for(t.call(this,o),n=0;n<r.length;n+=1)i.off(r[n],e)}var n,r=["webkitTransitionEnd","transitionend"],i=this;if(t)for(n=0;n<r.length;n+=1)i.on(r[n],e);return this},animationEnd:function(t){function e(o){if(o.target===this)for(t.call(this,o),n=0;n<r.length;n+=1)i.off(r[n],e)}var n,r=["webkitAnimationEnd","animationend"],i=this;if(t)for(n=0;n<r.length;n+=1)i.on(r[n],e);return this},width:function(){return this[0]===window?window.innerWidth:this.length>0?parseFloat(this.css("width")):null},outerWidth:function(t){if(this.length>0){if(t){var e=this.styles();return this[0].offsetWidth+parseFloat(e.getPropertyValue("margin-right"))+parseFloat(e.getPropertyValue("margin-left"))}return this[0].offsetWidth}return null},height:function(){return this[0]===window?window.innerHeight:this.length>0?parseFloat(this.css("height")):null},outerHeight:function(t){if(this.length>0){if(t){var e=this.styles();return this[0].offsetHeight+parseFloat(e.getPropertyValue("margin-top"))+parseFloat(e.getPropertyValue("margin-bottom"))}return this[0].offsetHeight}return null},offset:function(){if(this.length>0){var t=this[0],e=t.getBoundingClientRect(),n=document.body,r=t.clientTop||n.clientTop||0,i=t.clientLeft||n.clientLeft||0,o=t===window?window.scrollY:t.scrollTop,s=t===window?window.scrollX:t.scrollLeft;return{top:e.top+o-r,left:e.left+s-i}}return null},hide:function(){for(var t=this,e=0;e<this.length;e+=1)t[e].style.display="none";return this},show:function(){for(var t=this,e=0;e<this.length;e+=1){var n=t[e];"none"===n.style.display&&(n.style.display=""),"none"===window.getComputedStyle(n,null).getPropertyValue("display")&&(n.style.display="block")}return this},styles:function(){return this[0]?window.getComputedStyle(this[0],null):{}},css:function(t,e){var n,r=this;if(1===arguments.length){if("string"!=typeof t){for(n=0;n<this.length;n+=1)for(var i in t)r[n].style[i]=t[i];return this}if(this[0])return window.getComputedStyle(this[0],null).getPropertyValue(t)}if(2===arguments.length&&"string"==typeof t){for(n=0;n<this.length;n+=1)r[n].style[t]=e;return this}return this},toArray:function(){for(var t=this,e=[],n=0;n<this.length;n+=1)e.push(t[n]);return e},each:function(t){var e=this;if(!t)return this;for(var n=0;n<this.length;n+=1)if(!1===t.call(e[n],n,e[n]))return e;return this},forEach:function(t){var e=this;if(!t)return this;for(var n=0;n<this.length;n+=1)if(!1===t.call(e[n],e[n],n))return e;return this},filter:function(t){for(var e=[],n=this,r=0;r<n.length;r+=1)t.call(n[r],r,n[r])&&e.push(n[r]);return new x(e)},map:function(t){for(var e=[],n=this,r=0;r<n.length;r+=1)e.push(t.call(n[r],r,n[r]));return new x(e)},html:function(t){var e=this;if(void 0===t)return this[0]?this[0].innerHTML:void 0;for(var n=0;n<this.length;n+=1)e[n].innerHTML=t;return this},text:function(t){var e=this;if(void 0===t)return this[0]?this[0].textContent.trim():null;for(var n=0;n<this.length;n+=1)e[n].textContent=t;return this},is:function(e){var n,r,i=this[0];if(!i||void 0===e)return!1;if("string"==typeof e){if(i.matches)return i.matches(e);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(e);if(i.msMatchesSelector)return i.msMatchesSelector(e);for(n=t(e),r=0;r<n.length;r+=1)if(n[r]===i)return!0;return!1}if(e===document)return i===document;if(e===window)return i===window;if(e.nodeType||e instanceof x){for(n=e.nodeType?[e]:e,r=0;r<n.length;r+=1)if(n[r]===i)return!0;return!1}return!1},indexOf:function(t){for(var e=this,n=0;n<this.length;n+=1)if(e[n]===t)return n},index:function(){var t,e=this[0];if(e){for(t=0;null!==(e=e.previousSibling);)1===e.nodeType&&(t+=1);return t}},eq:function(t){if(void 0===t)return this;var e,n=this.length;return t>n-1?new x([]):t<0?(e=n+t,new x(e<0?[]:[this[e]])):new x([this[t]])},append:function(){for(var t=this,e=[],n=arguments.length;n--;)e[n]=arguments[n];for(var r,i=0;i<e.length;i+=1){r=e[i];for(var o=0;o<this.length;o+=1)if("string"==typeof r){var s=document.createElement("div");for(s.innerHTML=r;s.firstChild;)t[o].appendChild(s.firstChild)}else if(r instanceof x)for(var a=0;a<r.length;a+=1)t[o].appendChild(r[a]);else t[o].appendChild(r)}return this},appendTo:function(e){return t(e).append(this),this},prepend:function(t){var e,n,r=this;for(e=0;e<this.length;e+=1)if("string"==typeof t){var i=document.createElement("div");for(i.innerHTML=t,n=i.childNodes.length-1;n>=0;n-=1)r[e].insertBefore(i.childNodes[n],r[e].childNodes[0])}else if(t instanceof x)for(n=0;n<t.length;n+=1)r[e].insertBefore(t[n],r[e].childNodes[0]);else r[e].insertBefore(t,r[e].childNodes[0]);return this},prependTo:function(e){return t(e).prepend(this),this},insertBefore:function(e){for(var n=this,r=t(e),i=0;i<this.length;i+=1)if(1===r.length)r[0].parentNode.insertBefore(n[i],r[0]);else if(r.length>1)for(var o=0;o<r.length;o+=1)r[o].parentNode.insertBefore(n[i].cloneNode(!0),r[o])},insertAfter:function(e){for(var n=this,r=t(e),i=0;i<this.length;i+=1)if(1===r.length)r[0].parentNode.insertBefore(n[i],r[0].nextSibling);else if(r.length>1)for(var o=0;o<r.length;o+=1)r[o].parentNode.insertBefore(n[i].cloneNode(!0),r[o].nextSibling)},next:function(e){return new x(this.length>0?e?this[0].nextElementSibling&&t(this[0].nextElementSibling).is(e)?[this[0].nextElementSibling]:[]:this[0].nextElementSibling?[this[0].nextElementSibling]:[]:[])},nextAll:function(e){var n=[],r=this[0];if(!r)return new x([]);for(;r.nextElementSibling;){var i=r.nextElementSibling;e?t(i).is(e)&&n.push(i):n.push(i),r=i}return new x(n)},prev:function(e){if(this.length>0){var n=this[0];return new x(e?n.previousElementSibling&&t(n.previousElementSibling).is(e)?[n.previousElementSibling]:[]:n.previousElementSibling?[n.previousElementSibling]:[])}return new x([])},prevAll:function(e){var n=[],r=this[0];if(!r)return new x([]);for(;r.previousElementSibling;){var i=r.previousElementSibling;e?t(i).is(e)&&n.push(i):n.push(i),r=i}return new x(n)},siblings:function(t){return this.nextAll(t).add(this.prevAll(t))},parent:function(e){for(var n=this,r=[],o=0;o<this.length;o+=1)null!==n[o].parentNode&&(e?t(n[o].parentNode).is(e)&&r.push(n[o].parentNode):r.push(n[o].parentNode));return t(i(r))},parents:function(e){for(var n=this,r=[],o=0;o<this.length;o+=1)for(var s=n[o].parentNode;s;)e?t(s).is(e)&&r.push(s):r.push(s),s=s.parentNode;return t(i(r))},closest:function(t){var e=this;return void 0===t?new x([]):(e.is(t)||(e=e.parents(t).eq(0)),e)},find:function(t){for(var e=this,n=[],r=0;r<this.length;r+=1)for(var i=e[r].querySelectorAll(t),o=0;o<i.length;o+=1)n.push(i[o]);return new x(n)},children:function(e){for(var n=this,r=[],o=0;o<this.length;o+=1)for(var s=n[o].childNodes,a=0;a<s.length;a+=1)e?1===s[a].nodeType&&t(s[a]).is(e)&&r.push(s[a]):1===s[a].nodeType&&r.push(s[a]);return new x(i(r))},remove:function(){for(var t=this,e=0;e<this.length;e+=1)t[e].parentNode&&t[e].parentNode.removeChild(t[e]);return this},detach:function(){return this.remove()},add:function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r,i,o=this;for(r=0;r<e.length;r+=1){var s=t(e[r]);for(i=0;i<s.length;i+=1)o[o.length]=s[i],o.length+=1}return o},empty:function(){for(var t=this,e=0;e<this.length;e+=1){var n=t[e];if(1===n.nodeType){for(var r=0;r<n.childNodes.length;r+=1)n.childNodes[r].parentNode&&n.childNodes[r].parentNode.removeChild(n.childNodes[r]);n.textContent=""}}return this}}),T="click blur focus focusin focusout keyup keydown keypress submit change mousedown mousemove mouseup mouseenter mouseleave mouseout mouseover touchstart touchend touchmove resize scroll".split(" "),L="resize scroll".split(" "),S=0;S<T.length;S+=1)!function(e){E[e]=function(n,r,i){var o=this;if(void 0===n){for(var s=0;s<this.length;s+=1)L.indexOf(e)<0&&(e in o[s]?o[s][e]():t(o[s]).trigger(e));return this}return this.on(e,n,r,i)}}(T[S]);var C={scrollTo:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],r=t[1],i=t[2],o=t[3],s=t[4];if(4===t.length&&"function"==typeof o){s=o;var a;a=t,n=a[0],r=a[1],i=a[2],s=a[3],o=a[4]}return void 0===o&&(o="swing"),this.each(function(){function t(n){void 0===n&&(n=(new Date).getTime()),null===y&&(y=n);var r,u=Math.max(Math.min((n-y)/i,1),0),f="linear"===o?u:.5-Math.cos(u*Math.PI)/2;if(m&&(d=e+f*(h-e)),g&&(p=a+f*(c-a)),m&&h>e&&d>=h&&(v.scrollTop=h,r=!0),m&&h<e&&d<=h&&(v.scrollTop=h,r=!0),g&&c>a&&p>=c&&(v.scrollLeft=c,r=!0),g&&c<a&&p<=c&&(v.scrollLeft=c,r=!0),r)return void(s&&s());m&&(v.scrollTop=d),g&&(v.scrollLeft=p),l(t)}var e,a,u,f,h,c,d,p,v=this,m=r>0||0===r,g=n>0||0===n;if(void 0===o&&(o="swing"),m&&(e=v.scrollTop,i||(v.scrollTop=r)),g&&(a=v.scrollLeft,i||(v.scrollLeft=n)),i){m&&(u=v.scrollHeight-v.offsetHeight,h=Math.max(Math.min(r,u),0)),g&&(f=v.scrollWidth-v.offsetWidth,c=Math.max(Math.min(n,f),0));var y=null;m&&h===e&&(m=!1),g&&c===a&&(g=!1),l(t)}})},scrollTop:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],r=t[1],i=t[2],o=t[3];if(3===t.length&&"function"==typeof i){var s;s=t,n=s[0],r=s[1],o=s[2],i=s[3]}var a=this;return void 0===n?a.length>0?a[0].scrollTop:null:a.scrollTo(void 0,n,r,i,o)},scrollLeft:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],r=t[1],i=t[2],o=t[3];if(3===t.length&&"function"==typeof i){var s;s=t,n=s[0],r=s[1],o=s[2],i=s[3]}var a=this;return void 0===n?a.length>0?a[0].scrollLeft:null:a.scrollTo(n,void 0,r,i,o)}},j={animate:c,stop:d},A={},O=0,D={__utils:!0,ajaxSetup:p,ajax:v,get:g,post:y,getJSON:w};return t.use(b,E,C,j,D),t}); | ||
* Released on: September 11, 2017 | ||
*/!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Dom7=e()}(this,function(){"use strict";function t(t,e){var n=[],i=0;if(t&&!e&&t instanceof o)return t;if(t)if("string"==typeof t){var r,s,a=t.trim();if(a.indexOf("<")>=0&&a.indexOf(">")>=0){var l="div";for(0===a.indexOf("<li")&&(l="ul"),0===a.indexOf("<tr")&&(l="tbody"),0!==a.indexOf("<td")&&0!==a.indexOf("<th")||(l="tr"),0===a.indexOf("<tbody")&&(l="table"),0===a.indexOf("<option")&&(l="select"),s=document.createElement(l),s.innerHTML=a,i=0;i<s.childNodes.length;i+=1)n.push(s.childNodes[i])}else for(r=e||"#"!==t[0]||t.match(/[ .<>:~]/)?(e||document).querySelectorAll(t.trim()):[document.getElementById(t.trim().split("#")[1])],i=0;i<r.length;i+=1)r[i]&&n.push(r[i])}else if(t.nodeType||t===window||t===document)n.push(t);else if(t.length>0&&t[0].nodeType)for(i=0;i<t.length;i+=1)n.push(t[i]);return new o(n)}function e(t){for(var e=[],n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}function n(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(t){return window.requestAnimationFrame?window.requestAnimationFrame(t):window.webkitRequestAnimationFrame?window.webkitRequestAnimationFrame(t):window.setTimeout(t,1e3/60)}function r(t){return window.cancelAnimationFrame?window.cancelAnimationFrame(t):window.webkitCancelAnimationFrame?window.webkitCancelAnimationFrame(t):window.clearTimeout(t)}var o=function(t){for(var e=this,n=0;n<t.length;n+=1)e[n]=t[n];return e.length=t.length,this};t.fn=o.prototype,t.Class=o,t.use=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];e.forEach(function(e){var n="__utils"in e;Object.keys(e).forEach(function(i){"__utils"!==i&&(n?t[i]=e[i]:t.fn[i]=e[i])})})};for(var s=({addClass:function(t){var e=this;if(void 0===t)return this;for(var n=t.split(" "),i=0;i<n.length;i+=1)for(var r=0;r<this.length;r+=1)void 0!==e[r].classList&&e[r].classList.add(n[i]);return this},removeClass:function(t){for(var e=this,n=t.split(" "),i=0;i<n.length;i+=1)for(var r=0;r<this.length;r+=1)void 0!==e[r].classList&&e[r].classList.remove(n[i]);return this},hasClass:function(t){return!!this[0]&&this[0].classList.contains(t)},toggleClass:function(t){for(var e=this,n=t.split(" "),i=0;i<n.length;i+=1)for(var r=0;r<this.length;r+=1)void 0!==e[r].classList&&e[r].classList.toggle(n[i]);return this},attr:function(t,e){var n=arguments,i=this;if(1!==arguments.length||"string"!=typeof t){for(var r=0;r<this.length;r+=1)if(2===n.length)i[r].setAttribute(t,e);else for(var o in t)i[r][o]=t[o],i[r].setAttribute(o,t[o]);return this}if(this[0])return this[0].getAttribute(t)},removeAttr:function(t){for(var e=this,n=0;n<this.length;n+=1)e[n].removeAttribute(t);return this},prop:function(t,e){var n=arguments,i=this;if(1!==arguments.length||"string"!=typeof t){for(var r=0;r<this.length;r+=1)if(2===n.length)i[r][t]=e;else for(var o in t)i[r][o]=t[o];return this}if(this[0])return this[0][t]},data:function(t,e){var n,i=this;if(void 0!==e){for(var r=0;r<this.length;r+=1)n=i[r],n.dom7ElementDataStorage||(n.dom7ElementDataStorage={}),n.dom7ElementDataStorage[t]=e;return this}if(n=this[0]){if(n.dom7ElementDataStorage&&t in n.dom7ElementDataStorage)return n.dom7ElementDataStorage[t];var o=n.getAttribute("data-"+t);if(o)return o}else;},removeData:function(t){for(var e=this,n=0;n<this.length;n+=1){var i=e[n];i.dom7ElementDataStorage&&i.dom7ElementDataStorage[t]&&(i.dom7ElementDataStorage[t]=null,delete i.dom7ElementDataStorage[t])}},dataset:function(){var t=this[0];if(t){var e={};if(t.dataset)for(var i in t.dataset)e[i]=t.dataset[i];else for(var r=0;r<t.attributes.length;r+=1){var o=t.attributes[r];o.name.indexOf("data-")>=0&&(e[n(o.name.split("data-")[1])]=o.value)}for(var s in e)"false"===e[s]?e[s]=!1:"true"===e[s]?e[s]=!0:parseFloat(e[s])===1*e[s]&&(e[s]*=1);return e}},val:function(t){var e=this;{if(void 0!==t){for(var n=0;n<this.length;n+=1)e[n].value=t;return this}if(this[0]){if(this[0].multiple&&"select"===this[0].nodeName.toLowerCase()){for(var i=[],r=0;r<this[0].selectedOptions.length;r+=1)i.push(e[0].selectedOptions[r].value);return i}return this[0].value}}},transform:function(t){for(var e=this,n=0;n<this.length;n+=1){var i=e[n].style;i.webkitTransform=t,i.transform=t}return this},transition:function(t){var e=this;"string"!=typeof t&&(t+="ms");for(var n=0;n<this.length;n+=1){var i=e[n].style;i.webkitTransitionDuration=t,i.transitionDuration=t}return this},on:function(){function e(e){var n=e.target;if(n){var i=e.target.dom7EventData||[];if(i.unshift(e),t(n).is(s))a.apply(n,i);else for(var r=t(n).parents(),o=0;o<r.length;o+=1)t(r[o]).is(s)&&a.apply(r[o],i)}}function n(t){var e=t&&t.target?t.target.dom7EventData||[]:[];e.unshift(t),a.apply(this,e)}for(var i=this,r=[],o=arguments.length;o--;)r[o]=arguments[o];var s,a,l=r[0],h=!1;"function"==typeof r[1]?(s=!1,a=r[1],h=r[2]):(s=r[1],a=r[2],h=r[3]);for(var f,u=l.split(" "),d=0;d<this.length;d+=1){var c=i[d];if(s)for(f=0;f<u.length;f+=1)c.dom7LiveListeners||(c.dom7LiveListeners=[]),c.dom7LiveListeners.push({type:l,listener:a,proxyListener:e}),c.addEventListener(u[f],e,h);else for(f=0;f<u.length;f+=1)c.dom7Listeners||(c.dom7Listeners=[]),c.dom7Listeners.push({type:l,listener:a,proxyListener:n}),c.addEventListener(u[f],n,h)}return this},off:function(){for(var t=this,e=[],n=arguments.length;n--;)e[n]=arguments[n];var i,r,o=e[0],s=!1;"function"==typeof e[1]?(i=!1,r=e[1],s=e[2]):(i=e[1],r=e[2],s=e[3]);for(var a=o.split(" "),l=0;l<a.length;l+=1)for(var h=0;h<this.length;h+=1){var f=t[h];if(i){if(f.dom7LiveListeners)for(var u=0;u<f.dom7LiveListeners.length;u+=1)r?f.dom7LiveListeners[u].listener===r&&f.removeEventListener(a[l],f.dom7LiveListeners[u].proxyListener,s):f.dom7LiveListeners[u].type===a[l]&&f.removeEventListener(a[l],f.dom7LiveListeners[u].proxyListener,s)}else if(f.dom7Listeners)for(var d=0;d<f.dom7Listeners.length;d+=1)r?f.dom7Listeners[d].listener===r&&f.removeEventListener(a[l],f.dom7Listeners[d].proxyListener,s):f.dom7Listeners[d].type===a[l]&&f.removeEventListener(a[l],f.dom7Listeners[d].proxyListener,s)}return this},once:function(t,e,n,i){function r(s){var a=s.target.dom7EventData||[];n.apply(this,a),o.off(t,e,r,i)}var o=this;return"function"==typeof e&&(n=arguments[1],i=arguments[2],e=!1),o.on(t,e,r,i)},trigger:function(){for(var t=this,e=[],n=arguments.length;n--;)e[n]=arguments[n];for(var i=e[0].split(" "),r=e[1],o=0;o<i.length;o+=1)for(var s=0;s<this.length;s+=1){var a=void 0;try{a=new window.CustomEvent(i[o],{detail:r,bubbles:!0,cancelable:!0})}catch(t){a=document.createEvent("Event"),a.initEvent(i[o],!0,!0),a.detail=r}t[s].dom7EventData=e.filter(function(t,e){return e>0}),t[s].dispatchEvent(a),t[s].dom7EventData=[],delete t[s].dom7EventData}return this},transitionEnd:function(t){function e(o){if(o.target===this)for(t.call(this,o),n=0;n<i.length;n+=1)r.off(i[n],e)}var n,i=["webkitTransitionEnd","transitionend"],r=this;if(t)for(n=0;n<i.length;n+=1)r.on(i[n],e);return this},animationEnd:function(t){function e(o){if(o.target===this)for(t.call(this,o),n=0;n<i.length;n+=1)r.off(i[n],e)}var n,i=["webkitAnimationEnd","animationend"],r=this;if(t)for(n=0;n<i.length;n+=1)r.on(i[n],e);return this},width:function(){return this[0]===window?window.innerWidth:this.length>0?parseFloat(this.css("width")):null},outerWidth:function(t){if(this.length>0){if(t){var e=this.styles();return this[0].offsetWidth+parseFloat(e.getPropertyValue("margin-right"))+parseFloat(e.getPropertyValue("margin-left"))}return this[0].offsetWidth}return null},height:function(){return this[0]===window?window.innerHeight:this.length>0?parseFloat(this.css("height")):null},outerHeight:function(t){if(this.length>0){if(t){var e=this.styles();return this[0].offsetHeight+parseFloat(e.getPropertyValue("margin-top"))+parseFloat(e.getPropertyValue("margin-bottom"))}return this[0].offsetHeight}return null},offset:function(){if(this.length>0){var t=this[0],e=t.getBoundingClientRect(),n=document.body,i=t.clientTop||n.clientTop||0,r=t.clientLeft||n.clientLeft||0,o=t===window?window.scrollY:t.scrollTop,s=t===window?window.scrollX:t.scrollLeft;return{top:e.top+o-i,left:e.left+s-r}}return null},hide:function(){for(var t=this,e=0;e<this.length;e+=1)t[e].style.display="none";return this},show:function(){for(var t=this,e=0;e<this.length;e+=1){var n=t[e];"none"===n.style.display&&(n.style.display=""),"none"===window.getComputedStyle(n,null).getPropertyValue("display")&&(n.style.display="block")}return this},styles:function(){return this[0]?window.getComputedStyle(this[0],null):{}},css:function(t,e){var n,i=this;if(1===arguments.length){if("string"!=typeof t){for(n=0;n<this.length;n+=1)for(var r in t)i[n].style[r]=t[r];return this}if(this[0])return window.getComputedStyle(this[0],null).getPropertyValue(t)}if(2===arguments.length&&"string"==typeof t){for(n=0;n<this.length;n+=1)i[n].style[t]=e;return this}return this},toArray:function(){for(var t=this,e=[],n=0;n<this.length;n+=1)e.push(t[n]);return e},each:function(t){var e=this;if(!t)return this;for(var n=0;n<this.length;n+=1)if(!1===t.call(e[n],n,e[n]))return e;return this},forEach:function(t){var e=this;if(!t)return this;for(var n=0;n<this.length;n+=1)if(!1===t.call(e[n],e[n],n))return e;return this},filter:function(t){for(var e=[],n=this,i=0;i<n.length;i+=1)t.call(n[i],i,n[i])&&e.push(n[i]);return new o(e)},map:function(t){for(var e=[],n=this,i=0;i<n.length;i+=1)e.push(t.call(n[i],i,n[i]));return new o(e)},html:function(t){var e=this;if(void 0===t)return this[0]?this[0].innerHTML:void 0;for(var n=0;n<this.length;n+=1)e[n].innerHTML=t;return this},text:function(t){var e=this;if(void 0===t)return this[0]?this[0].textContent.trim():null;for(var n=0;n<this.length;n+=1)e[n].textContent=t;return this},is:function(e){var n,i,r=this[0];if(!r||void 0===e)return!1;if("string"==typeof e){if(r.matches)return r.matches(e);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(e);if(r.msMatchesSelector)return r.msMatchesSelector(e);for(n=t(e),i=0;i<n.length;i+=1)if(n[i]===r)return!0;return!1}if(e===document)return r===document;if(e===window)return r===window;if(e.nodeType||e instanceof o){for(n=e.nodeType?[e]:e,i=0;i<n.length;i+=1)if(n[i]===r)return!0;return!1}return!1},indexOf:function(t){for(var e=this,n=0;n<this.length;n+=1)if(e[n]===t)return n},index:function(){var t,e=this[0];if(e){for(t=0;null!==(e=e.previousSibling);)1===e.nodeType&&(t+=1);return t}},eq:function(t){if(void 0===t)return this;var e,n=this.length;return t>n-1?new o([]):t<0?(e=n+t,new o(e<0?[]:[this[e]])):new o([this[t]])},append:function(){for(var t=this,e=[],n=arguments.length;n--;)e[n]=arguments[n];for(var i,r=0;r<e.length;r+=1){i=e[r];for(var s=0;s<this.length;s+=1)if("string"==typeof i){var a=document.createElement("div");for(a.innerHTML=i;a.firstChild;)t[s].appendChild(a.firstChild)}else if(i instanceof o)for(var l=0;l<i.length;l+=1)t[s].appendChild(i[l]);else t[s].appendChild(i)}return this},appendTo:function(e){return t(e).append(this),this},prepend:function(t){var e,n,i=this;for(e=0;e<this.length;e+=1)if("string"==typeof t){var r=document.createElement("div");for(r.innerHTML=t,n=r.childNodes.length-1;n>=0;n-=1)i[e].insertBefore(r.childNodes[n],i[e].childNodes[0])}else if(t instanceof o)for(n=0;n<t.length;n+=1)i[e].insertBefore(t[n],i[e].childNodes[0]);else i[e].insertBefore(t,i[e].childNodes[0]);return this},prependTo:function(e){return t(e).prepend(this),this},insertBefore:function(e){for(var n=this,i=t(e),r=0;r<this.length;r+=1)if(1===i.length)i[0].parentNode.insertBefore(n[r],i[0]);else if(i.length>1)for(var o=0;o<i.length;o+=1)i[o].parentNode.insertBefore(n[r].cloneNode(!0),i[o])},insertAfter:function(e){for(var n=this,i=t(e),r=0;r<this.length;r+=1)if(1===i.length)i[0].parentNode.insertBefore(n[r],i[0].nextSibling);else if(i.length>1)for(var o=0;o<i.length;o+=1)i[o].parentNode.insertBefore(n[r].cloneNode(!0),i[o].nextSibling)},next:function(e){return new o(this.length>0?e?this[0].nextElementSibling&&t(this[0].nextElementSibling).is(e)?[this[0].nextElementSibling]:[]:this[0].nextElementSibling?[this[0].nextElementSibling]:[]:[])},nextAll:function(e){var n=[],i=this[0];if(!i)return new o([]);for(;i.nextElementSibling;){var r=i.nextElementSibling;e?t(r).is(e)&&n.push(r):n.push(r),i=r}return new o(n)},prev:function(e){if(this.length>0){var n=this[0];return new o(e?n.previousElementSibling&&t(n.previousElementSibling).is(e)?[n.previousElementSibling]:[]:n.previousElementSibling?[n.previousElementSibling]:[])}return new o([])},prevAll:function(e){var n=[],i=this[0];if(!i)return new o([]);for(;i.previousElementSibling;){var r=i.previousElementSibling;e?t(r).is(e)&&n.push(r):n.push(r),i=r}return new o(n)},siblings:function(t){return this.nextAll(t).add(this.prevAll(t))},parent:function(n){for(var i=this,r=[],o=0;o<this.length;o+=1)null!==i[o].parentNode&&(n?t(i[o].parentNode).is(n)&&r.push(i[o].parentNode):r.push(i[o].parentNode));return t(e(r))},parents:function(n){for(var i=this,r=[],o=0;o<this.length;o+=1)for(var s=i[o].parentNode;s;)n?t(s).is(n)&&r.push(s):r.push(s),s=s.parentNode;return t(e(r))},closest:function(t){var e=this;return void 0===t?new o([]):(e.is(t)||(e=e.parents(t).eq(0)),e)},find:function(t){for(var e=this,n=[],i=0;i<this.length;i+=1)for(var r=e[i].querySelectorAll(t),s=0;s<r.length;s+=1)n.push(r[s]);return new o(n)},children:function(n){for(var i=this,r=[],s=0;s<this.length;s+=1)for(var a=i[s].childNodes,l=0;l<a.length;l+=1)n?1===a[l].nodeType&&t(a[l]).is(n)&&r.push(a[l]):1===a[l].nodeType&&r.push(a[l]);return new o(e(r))},remove:function(){for(var t=this,e=0;e<this.length;e+=1)t[e].parentNode&&t[e].parentNode.removeChild(t[e]);return this},detach:function(){return this.remove()},add:function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var i,r,o=this;for(i=0;i<e.length;i+=1){var s=t(e[i]);for(r=0;r<s.length;r+=1)o[o.length]=s[r],o.length+=1}return o},empty:function(){for(var t=this,e=0;e<this.length;e+=1){var n=t[e];if(1===n.nodeType){for(var i=0;i<n.childNodes.length;i+=1)n.childNodes[i].parentNode&&n.childNodes[i].parentNode.removeChild(n.childNodes[i]);n.textContent=""}}return this}}),a="click blur focus focusin focusout keyup keydown keypress submit change mousedown mousemove mouseup mouseenter mouseleave mouseout mouseover touchstart touchend touchmove resize scroll".split(" "),l="resize scroll".split(" "),h=0;h<a.length;h+=1)!function(e){s[e]=function(n,i,r){var o=this;if(void 0===n){for(var s=0;s<this.length;s+=1)l.indexOf(e)<0&&(e in o[s]?o[s][e]():t(o[s]).trigger(e));return this}return this.on(e,n,i,r)}}(a[h]);var f={scrollTo:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4];if(4===t.length&&"function"==typeof s){a=s;var l;l=t,n=l[0],r=l[1],o=l[2],a=l[3],s=l[4]}return void 0===s&&(s="swing"),this.each(function(){function t(n){void 0===n&&(n=(new Date).getTime()),null===w&&(w=n);var r,h=Math.max(Math.min((n-w)/o,1),0),f="linear"===s?h:.5-Math.cos(h*Math.PI)/2;if(m&&(c=e+f*(u-e)),p&&(v=l+f*(d-l)),m&&u>e&&c>=u&&(g.scrollTop=u,r=!0),m&&u<e&&c<=u&&(g.scrollTop=u,r=!0),p&&d>l&&v>=d&&(g.scrollLeft=d,r=!0),p&&d<l&&v<=d&&(g.scrollLeft=d,r=!0),r)return void(a&&a());m&&(g.scrollTop=c),p&&(g.scrollLeft=v),i(t)}var e,l,h,f,u,d,c,v,g=this,m=r>0||0===r,p=n>0||0===n;if(void 0===s&&(s="swing"),m&&(e=g.scrollTop,o||(g.scrollTop=r)),p&&(l=g.scrollLeft,o||(g.scrollLeft=n)),o){m&&(h=g.scrollHeight-g.offsetHeight,u=Math.max(Math.min(r,h),0)),p&&(f=g.scrollWidth-g.offsetWidth,d=Math.max(Math.min(n,f),0));var w=null;m&&u===e&&(m=!1),p&&d===l&&(p=!1),i(t)}})},scrollTop:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],i=t[1],r=t[2],o=t[3];if(3===t.length&&"function"==typeof r){var s;s=t,n=s[0],i=s[1],o=s[2],r=s[3]}var a=this;return void 0===n?a.length>0?a[0].scrollTop:null:a.scrollTo(void 0,n,i,r,o)},scrollLeft:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],i=t[1],r=t[2],o=t[3];if(3===t.length&&"function"==typeof r){var s;s=t,n=s[0],i=s[1],o=s[2],r=s[3]}var a=this;return void 0===n?a.length>0?a[0].scrollLeft:null:a.scrollTo(n,void 0,i,r,o)}},u={animate:function(e,n){var o=this,s={props:t.extend({},e),params:t.extend({duration:300,easing:"swing"},n),elements:o,animating:!1,que:[],easingProgress:function(t,e){return"swing"===t?.5-Math.cos(e*Math.PI)/2:"function"==typeof t?t(e):e},stop:function(){s.frameId&&r(s.frameId),s.animating=!1,s.elements.each(function(t,e){delete e.dom7AnimateInstance}),s.que=[]},done:function(t){if(s.animating=!1,s.elements.each(function(t,e){delete e.dom7AnimateInstance}),t&&t(o),s.que.length>0){var e=s.que.shift();s.animate(e[0],e[1])}},animate:function(t,e){function n(){a=(new Date).getTime();var c,v;d||(d=!0,e.begin&&e.begin(o)),null===h&&(h=a),e.progress&&e.progress(o,Math.max(Math.min((a-h)/e.duration,1),0),h+e.duration-a<0?0:h+e.duration-a,h),r.forEach(function(n){var i=n;l||i.done||Object.keys(t).forEach(function(n){if(!l&&!i.done){c=Math.max(Math.min((a-h)/e.duration,1),0),v=s.easingProgress(e.easing,c);var o=i[n],d=o.initialValue,g=o.finalValue,m=o.unit;i[n].currentValue=d+v*(g-d);var p=i[n].currentValue;if((g>d&&p>=g||g<d&&p<=g)&&(i.container.style[n]=g+m,u+=1,u===Object.keys(t).length&&(i.done=!0,f+=1),f===r.length&&(l=!0)),l)return void s.done(e.complete);i.container.style[n]=p+m}})}),l||(s.frameId=i(n))}if(s.animating)return s.que.push([t,e]),s;var r=[];s.elements.each(function(e,n){var i,o,a,l,h;n.dom7AnimateInstance||(s.elements[e].dom7AnimateInstance=s),r[e]={container:n},Object.keys(t).forEach(function(s){i=window.getComputedStyle(n,null).getPropertyValue(s).replace(",","."),o=parseFloat(i),a=i.replace(o,""),l=parseFloat(t[s]),h=t[s]+a,r[e][s]={initialFullValue:i,initialValue:o,unit:a,finalValue:l,finalFullValue:h,currentValue:o}})});var a,l,h=null,f=0,u=0,d=!1;return s.animating=!0,s.frameId=i(n),s}};if(0===s.elements.length)return o;for(var a,l=0;l<s.elements.length;l+=1)s.elements[l].dom7AnimateInstance?a=s.elements[l].dom7AnimateInstance:s.elements[l].dom7AnimateInstance=s;return a||(a=s),"stop"===e?a.stop():a.animate(s.props,s.params),o},stop:function(){for(var t=this,e=0;e<t.length;e+=1)t[e].dom7AnimateInstance&&t[e].dom7AnimateInstance.stop()}};return t.use(s,f,u),t}); | ||
//# sourceMappingURL=dom7.min.js.map |
/** | ||
* Dom7 1.7.2 | ||
* Dom7 2.0.0 | ||
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API | ||
@@ -12,3 +12,3 @@ * http://framework7.io/docs/dom.html | ||
* | ||
* Released on: September 7, 2017 | ||
* Released on: September 11, 2017 | ||
*/ | ||
@@ -96,54 +96,2 @@ class Dom7 { | ||
function parseUrlQuery(url) { | ||
const query = {}; | ||
let urlToParse = url || window.location.href; | ||
let i; | ||
let params; | ||
let param; | ||
let length; | ||
if (typeof urlToParse === 'string' && urlToParse.length) { | ||
urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : ''; | ||
params = urlToParse.split('&').filter(paramsPart => paramsPart !== ''); | ||
length = params.length; | ||
for (i = 0; i < length; i += 1) { | ||
param = params[i].replace(/#\S+/g, '').split('='); | ||
query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || ''; | ||
} | ||
} | ||
return query; | ||
} | ||
function isArray(arr) { | ||
return Array.isArray(arr); | ||
} | ||
function each(obj, callback) { | ||
// Check it's iterable | ||
// TODO: Should probably raise a value error here | ||
if (typeof obj !== 'object') return; | ||
// Don't bother continuing without a callback | ||
if (!callback) return; | ||
if (Array.isArray(obj) || obj instanceof Dom7) { | ||
// Array | ||
for (let i = 0; i < obj.length; i += 1) { | ||
// If callback returns false | ||
if (callback(i, obj[i]) === false) { | ||
// Break out of the loop | ||
return; | ||
} | ||
} | ||
} else { | ||
// Object | ||
for (let prop in obj) { | ||
// Check the propertie belongs to the object | ||
// not it's prototype | ||
if (obj.hasOwnProperty(prop)) { | ||
// If the callback returns false | ||
if (callback(prop, obj[prop]) === false) { | ||
// Break out of the loop; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
function unique(arr) { | ||
@@ -156,57 +104,6 @@ const uniqueArray = []; | ||
} | ||
function serializeObject(obj, parents = []) { | ||
if (typeof obj === 'string') return obj; | ||
const resultArray = []; | ||
const separator = '&'; | ||
let newParents; | ||
function varName(name) { | ||
if (parents.length > 0) { | ||
let parentParts = ''; | ||
for (let j = 0; j < parents.length; j += 1) { | ||
if (j === 0) parentParts += parents[j]; | ||
else parentParts += `[${encodeURIComponent(parents[j])}]`; | ||
} | ||
return `${parentParts}[${encodeURIComponent(name)}]`; | ||
} | ||
return encodeURIComponent(name); | ||
} | ||
function varValue(value) { | ||
return encodeURIComponent(value); | ||
} | ||
Object.keys(obj).forEach((prop) => { | ||
let toPush; | ||
if (Array.isArray(obj[prop])) { | ||
toPush = []; | ||
for (let i = 0; i < obj[prop].length; i += 1) { | ||
if (!Array.isArray(obj[prop][i]) && typeof obj[prop][i] === 'object') { | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
newParents.push(String(i)); | ||
toPush.push(serializeObject(obj[prop][i], newParents)); | ||
} else { | ||
toPush.push(`${varName(prop)}[]=${varValue(obj[prop][i])}`); | ||
} | ||
} | ||
if (toPush.length > 0) resultArray.push(toPush.join(separator)); | ||
} else if (obj[prop] === null || obj[prop] === '') { | ||
resultArray.push(`${varName(prop)}=`); | ||
} else if (typeof obj[prop] === 'object') { | ||
// Object, convert to named array | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
toPush = serializeObject(obj[prop], newParents); | ||
if (toPush !== '') resultArray.push(toPush); | ||
} else if (typeof obj[prop] !== 'undefined' && obj[prop] !== '') { | ||
// Should be string or plain value | ||
resultArray.push(`${varName(prop)}=${varValue(obj[prop])}`); | ||
} else if (obj[prop] === '') resultArray.push(varName(prop)); | ||
}); | ||
return resultArray.join(separator); | ||
} | ||
function toCamelCase(string) { | ||
return string.toLowerCase().replace(/-(.)/g, (match, group1) => group1.toUpperCase()); | ||
} | ||
function dataset(el) { | ||
return $(el).dataset(); | ||
} | ||
function requestAnimationFrame(callback) { | ||
@@ -222,44 +119,2 @@ if (window.requestAnimationFrame) return window.requestAnimationFrame(callback); | ||
} | ||
function isObject(o) { | ||
return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; | ||
} | ||
function extend(...args) { | ||
const to = Object(args[0]); | ||
for (let i = 1; i < args.length; i += 1) { | ||
const nextSource = args[i]; | ||
if (nextSource !== undefined && nextSource !== null) { | ||
const keysArray = Object.keys(Object(nextSource)); | ||
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { | ||
const nextKey = keysArray[nextIndex]; | ||
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); | ||
if (desc !== undefined && desc.enumerable) { | ||
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
to[nextKey] = {}; | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
} | ||
const Utils = { | ||
__utils: true, | ||
parseUrlQuery, | ||
parseQuery: parseUrlQuery, | ||
isArray, | ||
each, | ||
unique, | ||
serializeObject, | ||
param: serializeObject, | ||
toCamelCase, | ||
dataset, | ||
requestAnimationFrame, | ||
cancelAnimationFrame, | ||
extend, | ||
}; | ||
@@ -389,6 +244,6 @@ const Methods = { | ||
if (!el) return undefined; | ||
const dataset$$1 = {}; | ||
const dataset = {}; | ||
if (el.dataset) { | ||
for (const dataKey in el.dataset) { | ||
dataset$$1[dataKey] = el.dataset[dataKey]; | ||
dataset[dataKey] = el.dataset[dataKey]; | ||
} | ||
@@ -399,12 +254,12 @@ } else { | ||
if (attr.name.indexOf('data-') >= 0) { | ||
dataset$$1[toCamelCase(attr.name.split('data-')[1])] = attr.value; | ||
dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value; | ||
} | ||
} | ||
} | ||
for (const key in dataset$$1) { | ||
if (dataset$$1[key] === 'false') dataset$$1[key] = false; | ||
else if (dataset$$1[key] === 'true') dataset$$1[key] = true; | ||
else if (parseFloat(dataset$$1[key]) === dataset$$1[key] * 1) dataset$$1[key] *= 1; | ||
for (const key in dataset) { | ||
if (dataset[key] === 'false') dataset[key] = false; | ||
else if (dataset[key] === 'true') dataset[key] = true; | ||
else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1; | ||
} | ||
return dataset$$1; | ||
return dataset; | ||
}, | ||
@@ -1233,500 +1088,188 @@ val(value) { | ||
function animate(initialProps, initialParams) { | ||
const els = this; | ||
const a = { | ||
props: $.extend({}, initialProps), | ||
params: $.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
const Animate = { | ||
animate(initialProps, initialParams) { | ||
const els = this; | ||
const a = { | ||
props: $.extend({}, initialProps), | ||
params: $.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done(complete) { | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) complete(els); | ||
if (a.que.length > 0) { | ||
const que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
const elements = []; | ||
easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done(complete) { | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) complete(els); | ||
if (a.que.length > 0) { | ||
const que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
const elements = []; | ||
// Define & Cache Initials & Units | ||
a.elements.each((index, el) => { | ||
let initialFullValue; | ||
let initialValue; | ||
let unit; | ||
let finalValue; | ||
let finalFullValue; | ||
// Define & Cache Initials & Units | ||
a.elements.each((index, el) => { | ||
let initialFullValue; | ||
let initialValue; | ||
let unit; | ||
let finalValue; | ||
let finalFullValue; | ||
if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a; | ||
if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a; | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach((prop) => { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue, | ||
initialValue, | ||
unit, | ||
finalValue, | ||
finalFullValue, | ||
currentValue: initialValue, | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach((prop) => { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue, | ||
initialValue, | ||
unit, | ||
finalValue, | ||
finalFullValue, | ||
currentValue: initialValue, | ||
}; | ||
}); | ||
}); | ||
}); | ||
let startTime = null; | ||
let time; | ||
let elementsDone = 0; | ||
let propsDone = 0; | ||
let done; | ||
let began = false; | ||
let startTime = null; | ||
let time; | ||
let elementsDone = 0; | ||
let propsDone = 0; | ||
let done; | ||
let began = false; | ||
a.animating = true; | ||
a.animating = true; | ||
function render() { | ||
time = new Date().getTime(); | ||
let progress; | ||
let easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) params.begin(els); | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
function render() { | ||
time = new Date().getTime(); | ||
let progress; | ||
let easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) params.begin(els); | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
elements.forEach((element) => { | ||
const el = element; | ||
if (done || el.done) return; | ||
Object.keys(props).forEach((prop) => { | ||
elements.forEach((element) => { | ||
const el = element; | ||
if (done || el.done) return; | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
const { initialValue, finalValue, unit } = el[prop]; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
const currentValue = el[prop].currentValue; | ||
Object.keys(props).forEach((prop) => { | ||
if (done || el.done) return; | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
const { initialValue, finalValue, unit } = el[prop]; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
const currentValue = el[prop].currentValue; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
} | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
} | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
el.container.style[prop] = currentValue + unit; | ||
el.container.style[prop] = currentValue + unit; | ||
}); | ||
}); | ||
}); | ||
if (done) return; | ||
// Then call | ||
if (done) return; | ||
// Then call | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
return a; | ||
}, | ||
}; | ||
return a; | ||
}, | ||
}; | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
let animateInstance; | ||
for (let i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else a.elements[i].dom7AnimateInstance = a; | ||
} | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
return els; | ||
} | ||
function stop() { | ||
const els = this; | ||
for (let i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
} | ||
} | ||
const Animate = { | ||
animate, | ||
stop, | ||
}; | ||
// Global Ajax Setup | ||
const globalAjaxOptions = {}; | ||
function ajaxSetup(options) { | ||
if (options.type && !options.method) options.method = options.type; | ||
each(options, (optionName, optionValue) => { | ||
globalAjaxOptions[optionName] = optionValue; | ||
}); | ||
} | ||
// JSONP Requests | ||
let jsonpRequests = 0; | ||
// Ajax | ||
function ajax(options) { | ||
const defaults = { | ||
method: 'GET', | ||
data: false, | ||
async: true, | ||
cache: true, | ||
user: '', | ||
password: '', | ||
headers: {}, | ||
xhrFields: {}, | ||
statusCode: {}, | ||
processData: true, | ||
dataType: 'text', | ||
contentType: 'application/x-www-form-urlencoded', | ||
timeout: 0, | ||
}; | ||
const callbacks = ['beforeSend', 'error', 'complete', 'success', 'statusCode']; | ||
// For jQuery guys | ||
if (options.type) options.method = options.type; | ||
// Global options | ||
const globals = globalAjaxOptions; | ||
// Merge global and defaults | ||
each(globals, (globalOptionName, globalOptionValue) => { | ||
if (callbacks.indexOf(globalOptionName) < 0) defaults[globalOptionName] = globalOptionValue; | ||
}); | ||
// Function to run XHR callbacks and events | ||
function fireAjaxCallback(eventName, eventData, callbackName) { | ||
const a = arguments; | ||
if (eventName) $(document).trigger(eventName, eventData); | ||
if (callbackName) { | ||
// Global callback | ||
if (callbackName in globals) globals[callbackName](a[3], a[4], a[5], a[6]); | ||
// Options callback | ||
if (options[callbackName]) options[callbackName](a[3], a[4], a[5], a[6]); | ||
let animateInstance; | ||
for (let i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else a.elements[i].dom7AnimateInstance = a; | ||
} | ||
} | ||
// Merge options and defaults | ||
each(defaults, (prop, defaultValue) => { | ||
if (!(prop in options)) options[prop] = defaultValue; | ||
}); | ||
// Default URL | ||
if (!options.url) { | ||
options.url = window.location.toString(); | ||
} | ||
// Parameters Prefix | ||
let paramsPrefix = options.url.indexOf('?') >= 0 ? '&' : '?'; | ||
// UC method | ||
const method = options.method.toUpperCase(); | ||
// Data to modify GET URL | ||
if ((method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') && options.data) { | ||
let stringData; | ||
if (typeof options.data === 'string') { | ||
// Should be key=value string | ||
if (options.data.indexOf('?') >= 0) stringData = options.data.split('?')[1]; | ||
else stringData = options.data; | ||
} else { | ||
// Should be key=value object | ||
stringData = serializeObject(options.data); | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (stringData.length) { | ||
options.url += paramsPrefix + stringData; | ||
if (paramsPrefix === '?') paramsPrefix = '&'; | ||
} | ||
} | ||
// JSONP | ||
if (options.dataType === 'json' && options.url.indexOf('callback=') >= 0) { | ||
const callbackName = `f7jsonp_${Date.now() + ((jsonpRequests += 1))}`; | ||
let abortTimeout; | ||
const callbackSplit = options.url.split('callback='); | ||
let requestUrl = `${callbackSplit[0]}callback=${callbackName}`; | ||
if (callbackSplit[1].indexOf('&') >= 0) { | ||
const addVars = callbackSplit[1].split('&').filter((el) => el.indexOf('=') > 0).join('&'); | ||
if (addVars.length > 0) requestUrl += `&${addVars}`; | ||
} | ||
// Create script | ||
let script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.onerror = function onerror() { | ||
clearTimeout(abortTimeout); | ||
fireAjaxCallback(undefined, undefined, 'error', null, 'scripterror'); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { scripterror: true }, 'complete', null, 'scripterror'); | ||
}; | ||
script.src = requestUrl; | ||
// Handler | ||
window[callbackName] = function jsonpCallback(data) { | ||
clearTimeout(abortTimeout); | ||
fireAjaxCallback(undefined, undefined, 'success', data); | ||
script.parentNode.removeChild(script); | ||
script = null; | ||
delete window[callbackName]; | ||
}; | ||
document.querySelector('head').appendChild(script); | ||
if (options.timeout > 0) { | ||
abortTimeout = setTimeout(() => { | ||
script.parentNode.removeChild(script); | ||
script = null; | ||
fireAjaxCallback(undefined, undefined, 'error', null, 'timeout'); | ||
}, options.timeout); | ||
} | ||
return; | ||
} | ||
// Cache for GET/HEAD requests | ||
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') { | ||
if (options.cache === false) { | ||
options.url += `${paramsPrefix}_nocache${Date.now()}`; | ||
} | ||
} | ||
// Create XHR | ||
const xhr = new XMLHttpRequest(); | ||
// Save Request URL | ||
xhr.requestUrl = options.url; | ||
xhr.requestParameters = options; | ||
// Open XHR | ||
xhr.open(method, options.url, options.async, options.user, options.password); | ||
// Create POST Data | ||
let postData = null; | ||
if ((method === 'POST' || method === 'PUT' || method === 'PATCH') && options.data) { | ||
if (options.processData) { | ||
const postDataInstances = [ArrayBuffer, Blob, Document, FormData]; | ||
// Post Data | ||
if (postDataInstances.indexOf(options.data.constructor) >= 0) { | ||
postData = options.data; | ||
} else { | ||
// POST Headers | ||
let boundary = `---------------------------${Date.now().toString(16)}`; | ||
if (options.contentType === 'multipart/form-data') { | ||
xhr.setRequestHeader('Content-Type', `multipart/form-data; boundary=${boundary}`); | ||
} else { | ||
xhr.setRequestHeader('Content-Type', options.contentType); | ||
} | ||
postData = ''; | ||
let data = serializeObject(options.data); | ||
if (options.contentType === 'multipart/form-data') { | ||
data = data.split('&'); | ||
const newData = []; | ||
for (let i = 0; i < data.length; i += 1) { | ||
newData.push(`Content-Disposition: form-data; name="${data[i].split('=')[0]}"\r\n\r\n${data[i].split('=')[1]}\r\n`); | ||
} | ||
postData = `--${boundary}\r\n${newData.join(`--${boundary}\r\n`)}--${boundary}--\r\n`; | ||
} else { | ||
postData = data; | ||
} | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
postData = options.data; | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
} | ||
// Additional headers | ||
if (options.headers) { | ||
each(options.headers, (headerName, headerCallback) => { | ||
xhr.setRequestHeader(headerName, headerCallback); | ||
}); | ||
} | ||
return els; | ||
}, | ||
// Check for crossDomain | ||
if (typeof options.crossDomain === 'undefined') { | ||
options.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(options.url) && RegExp.$2 !== window.location.host; | ||
} | ||
if (!options.crossDomain) { | ||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
} | ||
if (options.xhrFields) { | ||
each(options.xhrFields, (fieldName, fieldValue) => { | ||
xhr[fieldName] = fieldValue; | ||
}); | ||
} | ||
let xhrTimeout; | ||
// Handle XHR | ||
xhr.onload = function onload() { | ||
if (xhrTimeout) clearTimeout(xhrTimeout); | ||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) { | ||
let responseData; | ||
if (options.dataType === 'json') { | ||
try { | ||
responseData = JSON.parse(xhr.responseText); | ||
fireAjaxCallback('ajaxSuccess ajax:success', { xhr }, 'success', responseData, xhr.status, xhr); | ||
} catch (err) { | ||
fireAjaxCallback('ajaxError ajax:error', { xhr, parseerror: true }, 'error', xhr, 'parseerror'); | ||
} | ||
} else { | ||
responseData = xhr.responseType === 'text' || xhr.responseType === '' ? xhr.responseText : xhr.response; | ||
fireAjaxCallback('ajaxSuccess ajax:success', { xhr }, 'success', responseData, xhr.status, xhr); | ||
stop() { | ||
const els = this; | ||
for (let i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
} | ||
} else { | ||
fireAjaxCallback('ajaxError ajax:error', { xhr }, 'error', xhr, xhr.status); | ||
} | ||
if (options.statusCode) { | ||
if (globals.statusCode && globals.statusCode[xhr.status]) globals.statusCode[xhr.status](xhr); | ||
if (options.statusCode[xhr.status]) options.statusCode[xhr.status](xhr); | ||
} | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr }, 'complete', xhr, xhr.status); | ||
}; | ||
xhr.onerror = function onerror() { | ||
if (xhrTimeout) clearTimeout(xhrTimeout); | ||
fireAjaxCallback('ajaxError ajax:error', { xhr }, 'error', xhr, xhr.status); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr, error: true }, 'complete', xhr, 'error'); | ||
}; | ||
// Ajax start callback | ||
fireAjaxCallback('ajaxStart ajax:start', { xhr }, 'start', xhr); | ||
fireAjaxCallback(undefined, undefined, 'beforeSend', xhr); | ||
// Timeout | ||
if (options.timeout > 0) { | ||
xhr.onabort = function onabort() { | ||
if (xhrTimeout) clearTimeout(xhrTimeout); | ||
}; | ||
xhrTimeout = setTimeout(() => { | ||
xhr.abort(); | ||
fireAjaxCallback('ajaxError ajax:error', { xhr, timeout: true }, 'error', xhr, 'timeout'); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr, timeout: true }, 'complete', xhr, 'timeout'); | ||
}, options.timeout); | ||
} | ||
// Send XHR | ||
xhr.send(postData); | ||
// Return XHR object | ||
return xhr; | ||
} | ||
function ajaxShortcut(method, ...args) { | ||
let url; | ||
let data; | ||
let success; | ||
let error; | ||
let dataType; | ||
if (typeof args[1] === 'function') { | ||
[url, success, error, dataType] = args; | ||
} else { | ||
[url, data, success, error, dataType] = args; | ||
} | ||
[success, error].forEach((callback) => { | ||
if (typeof callback === 'string') { | ||
dataType = callback; | ||
if (callback === success) success = undefined; | ||
else error = undefined; | ||
} | ||
}); | ||
dataType = dataType || (method === 'getJSON' ? 'json' : undefined); | ||
return ajax({ | ||
url, | ||
method: method === 'post' ? 'POST' : 'GET', | ||
data, | ||
success, | ||
error, | ||
dataType, | ||
}); | ||
} | ||
function get(...args) { | ||
args.unshift('get'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
function post(...args) { | ||
args.unshift('post'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
function getJSON(...args) { | ||
args.unshift('getJSON'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
const Ajax = { | ||
__utils: true, | ||
ajaxSetup, | ||
ajax, | ||
get, | ||
post, | ||
getJSON, | ||
}, | ||
}; | ||
export { $, Utils, Methods, Scroll, Animate, Ajax }; | ||
export { $, Methods, Scroll, Animate }; |
/** | ||
* Dom7 1.7.2 | ||
* Dom7 2.0.0 | ||
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API | ||
@@ -12,3 +12,3 @@ * http://framework7.io/docs/dom.html | ||
* | ||
* Released on: September 7, 2017 | ||
* Released on: September 11, 2017 | ||
*/ | ||
@@ -96,54 +96,2 @@ class Dom7 { | ||
function parseUrlQuery(url) { | ||
const query = {}; | ||
let urlToParse = url || window.location.href; | ||
let i; | ||
let params; | ||
let param; | ||
let length; | ||
if (typeof urlToParse === 'string' && urlToParse.length) { | ||
urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : ''; | ||
params = urlToParse.split('&').filter(paramsPart => paramsPart !== ''); | ||
length = params.length; | ||
for (i = 0; i < length; i += 1) { | ||
param = params[i].replace(/#\S+/g, '').split('='); | ||
query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || ''; | ||
} | ||
} | ||
return query; | ||
} | ||
function isArray(arr) { | ||
return Array.isArray(arr); | ||
} | ||
function each(obj, callback) { | ||
// Check it's iterable | ||
// TODO: Should probably raise a value error here | ||
if (typeof obj !== 'object') return; | ||
// Don't bother continuing without a callback | ||
if (!callback) return; | ||
if (Array.isArray(obj) || obj instanceof Dom7) { | ||
// Array | ||
for (let i = 0; i < obj.length; i += 1) { | ||
// If callback returns false | ||
if (callback(i, obj[i]) === false) { | ||
// Break out of the loop | ||
return; | ||
} | ||
} | ||
} else { | ||
// Object | ||
for (let prop in obj) { | ||
// Check the propertie belongs to the object | ||
// not it's prototype | ||
if (obj.hasOwnProperty(prop)) { | ||
// If the callback returns false | ||
if (callback(prop, obj[prop]) === false) { | ||
// Break out of the loop; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
function unique(arr) { | ||
@@ -156,57 +104,6 @@ const uniqueArray = []; | ||
} | ||
function serializeObject(obj, parents = []) { | ||
if (typeof obj === 'string') return obj; | ||
const resultArray = []; | ||
const separator = '&'; | ||
let newParents; | ||
function varName(name) { | ||
if (parents.length > 0) { | ||
let parentParts = ''; | ||
for (let j = 0; j < parents.length; j += 1) { | ||
if (j === 0) parentParts += parents[j]; | ||
else parentParts += `[${encodeURIComponent(parents[j])}]`; | ||
} | ||
return `${parentParts}[${encodeURIComponent(name)}]`; | ||
} | ||
return encodeURIComponent(name); | ||
} | ||
function varValue(value) { | ||
return encodeURIComponent(value); | ||
} | ||
Object.keys(obj).forEach((prop) => { | ||
let toPush; | ||
if (Array.isArray(obj[prop])) { | ||
toPush = []; | ||
for (let i = 0; i < obj[prop].length; i += 1) { | ||
if (!Array.isArray(obj[prop][i]) && typeof obj[prop][i] === 'object') { | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
newParents.push(String(i)); | ||
toPush.push(serializeObject(obj[prop][i], newParents)); | ||
} else { | ||
toPush.push(`${varName(prop)}[]=${varValue(obj[prop][i])}`); | ||
} | ||
} | ||
if (toPush.length > 0) resultArray.push(toPush.join(separator)); | ||
} else if (obj[prop] === null || obj[prop] === '') { | ||
resultArray.push(`${varName(prop)}=`); | ||
} else if (typeof obj[prop] === 'object') { | ||
// Object, convert to named array | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
toPush = serializeObject(obj[prop], newParents); | ||
if (toPush !== '') resultArray.push(toPush); | ||
} else if (typeof obj[prop] !== 'undefined' && obj[prop] !== '') { | ||
// Should be string or plain value | ||
resultArray.push(`${varName(prop)}=${varValue(obj[prop])}`); | ||
} else if (obj[prop] === '') resultArray.push(varName(prop)); | ||
}); | ||
return resultArray.join(separator); | ||
} | ||
function toCamelCase(string) { | ||
return string.toLowerCase().replace(/-(.)/g, (match, group1) => group1.toUpperCase()); | ||
} | ||
function dataset(el) { | ||
return $$1(el).dataset(); | ||
} | ||
function requestAnimationFrame(callback) { | ||
@@ -222,44 +119,2 @@ if (window.requestAnimationFrame) return window.requestAnimationFrame(callback); | ||
} | ||
function isObject(o) { | ||
return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; | ||
} | ||
function extend(...args) { | ||
const to = Object(args[0]); | ||
for (let i = 1; i < args.length; i += 1) { | ||
const nextSource = args[i]; | ||
if (nextSource !== undefined && nextSource !== null) { | ||
const keysArray = Object.keys(Object(nextSource)); | ||
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { | ||
const nextKey = keysArray[nextIndex]; | ||
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); | ||
if (desc !== undefined && desc.enumerable) { | ||
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
to[nextKey] = {}; | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
} | ||
const Utils = { | ||
__utils: true, | ||
parseUrlQuery, | ||
parseQuery: parseUrlQuery, | ||
isArray, | ||
each, | ||
unique, | ||
serializeObject, | ||
param: serializeObject, | ||
toCamelCase, | ||
dataset, | ||
requestAnimationFrame, | ||
cancelAnimationFrame, | ||
extend, | ||
}; | ||
@@ -389,6 +244,6 @@ const Methods = { | ||
if (!el) return undefined; | ||
const dataset$$1 = {}; | ||
const dataset = {}; | ||
if (el.dataset) { | ||
for (const dataKey in el.dataset) { | ||
dataset$$1[dataKey] = el.dataset[dataKey]; | ||
dataset[dataKey] = el.dataset[dataKey]; | ||
} | ||
@@ -399,12 +254,12 @@ } else { | ||
if (attr.name.indexOf('data-') >= 0) { | ||
dataset$$1[toCamelCase(attr.name.split('data-')[1])] = attr.value; | ||
dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value; | ||
} | ||
} | ||
} | ||
for (const key in dataset$$1) { | ||
if (dataset$$1[key] === 'false') dataset$$1[key] = false; | ||
else if (dataset$$1[key] === 'true') dataset$$1[key] = true; | ||
else if (parseFloat(dataset$$1[key]) === dataset$$1[key] * 1) dataset$$1[key] *= 1; | ||
for (const key in dataset) { | ||
if (dataset[key] === 'false') dataset[key] = false; | ||
else if (dataset[key] === 'true') dataset[key] = true; | ||
else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1; | ||
} | ||
return dataset$$1; | ||
return dataset; | ||
}, | ||
@@ -1233,503 +1088,191 @@ val(value) { | ||
function animate(initialProps, initialParams) { | ||
const els = this; | ||
const a = { | ||
props: $$1.extend({}, initialProps), | ||
params: $$1.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
const Animate = { | ||
animate(initialProps, initialParams) { | ||
const els = this; | ||
const a = { | ||
props: $$1.extend({}, initialProps), | ||
params: $$1.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done(complete) { | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) complete(els); | ||
if (a.que.length > 0) { | ||
const que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
const elements = []; | ||
easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done(complete) { | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) complete(els); | ||
if (a.que.length > 0) { | ||
const que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
const elements = []; | ||
// Define & Cache Initials & Units | ||
a.elements.each((index, el) => { | ||
let initialFullValue; | ||
let initialValue; | ||
let unit; | ||
let finalValue; | ||
let finalFullValue; | ||
// Define & Cache Initials & Units | ||
a.elements.each((index, el) => { | ||
let initialFullValue; | ||
let initialValue; | ||
let unit; | ||
let finalValue; | ||
let finalFullValue; | ||
if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a; | ||
if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a; | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach((prop) => { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue, | ||
initialValue, | ||
unit, | ||
finalValue, | ||
finalFullValue, | ||
currentValue: initialValue, | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach((prop) => { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue, | ||
initialValue, | ||
unit, | ||
finalValue, | ||
finalFullValue, | ||
currentValue: initialValue, | ||
}; | ||
}); | ||
}); | ||
}); | ||
let startTime = null; | ||
let time; | ||
let elementsDone = 0; | ||
let propsDone = 0; | ||
let done; | ||
let began = false; | ||
let startTime = null; | ||
let time; | ||
let elementsDone = 0; | ||
let propsDone = 0; | ||
let done; | ||
let began = false; | ||
a.animating = true; | ||
a.animating = true; | ||
function render() { | ||
time = new Date().getTime(); | ||
let progress; | ||
let easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) params.begin(els); | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
function render() { | ||
time = new Date().getTime(); | ||
let progress; | ||
let easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) params.begin(els); | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
elements.forEach((element) => { | ||
const el = element; | ||
if (done || el.done) return; | ||
Object.keys(props).forEach((prop) => { | ||
elements.forEach((element) => { | ||
const el = element; | ||
if (done || el.done) return; | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
const { initialValue, finalValue, unit } = el[prop]; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
const currentValue = el[prop].currentValue; | ||
Object.keys(props).forEach((prop) => { | ||
if (done || el.done) return; | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
const { initialValue, finalValue, unit } = el[prop]; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
const currentValue = el[prop].currentValue; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
} | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
} | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
el.container.style[prop] = currentValue + unit; | ||
el.container.style[prop] = currentValue + unit; | ||
}); | ||
}); | ||
}); | ||
if (done) return; | ||
// Then call | ||
if (done) return; | ||
// Then call | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
return a; | ||
}, | ||
}; | ||
return a; | ||
}, | ||
}; | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
let animateInstance; | ||
for (let i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else a.elements[i].dom7AnimateInstance = a; | ||
} | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
return els; | ||
} | ||
function stop() { | ||
const els = this; | ||
for (let i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
} | ||
} | ||
const Animate = { | ||
animate, | ||
stop, | ||
}; | ||
// Global Ajax Setup | ||
const globalAjaxOptions = {}; | ||
function ajaxSetup(options) { | ||
if (options.type && !options.method) options.method = options.type; | ||
each(options, (optionName, optionValue) => { | ||
globalAjaxOptions[optionName] = optionValue; | ||
}); | ||
} | ||
// JSONP Requests | ||
let jsonpRequests = 0; | ||
// Ajax | ||
function ajax(options) { | ||
const defaults = { | ||
method: 'GET', | ||
data: false, | ||
async: true, | ||
cache: true, | ||
user: '', | ||
password: '', | ||
headers: {}, | ||
xhrFields: {}, | ||
statusCode: {}, | ||
processData: true, | ||
dataType: 'text', | ||
contentType: 'application/x-www-form-urlencoded', | ||
timeout: 0, | ||
}; | ||
const callbacks = ['beforeSend', 'error', 'complete', 'success', 'statusCode']; | ||
// For jQuery guys | ||
if (options.type) options.method = options.type; | ||
// Global options | ||
const globals = globalAjaxOptions; | ||
// Merge global and defaults | ||
each(globals, (globalOptionName, globalOptionValue) => { | ||
if (callbacks.indexOf(globalOptionName) < 0) defaults[globalOptionName] = globalOptionValue; | ||
}); | ||
// Function to run XHR callbacks and events | ||
function fireAjaxCallback(eventName, eventData, callbackName) { | ||
const a = arguments; | ||
if (eventName) $$1(document).trigger(eventName, eventData); | ||
if (callbackName) { | ||
// Global callback | ||
if (callbackName in globals) globals[callbackName](a[3], a[4], a[5], a[6]); | ||
// Options callback | ||
if (options[callbackName]) options[callbackName](a[3], a[4], a[5], a[6]); | ||
let animateInstance; | ||
for (let i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else a.elements[i].dom7AnimateInstance = a; | ||
} | ||
} | ||
// Merge options and defaults | ||
each(defaults, (prop, defaultValue) => { | ||
if (!(prop in options)) options[prop] = defaultValue; | ||
}); | ||
// Default URL | ||
if (!options.url) { | ||
options.url = window.location.toString(); | ||
} | ||
// Parameters Prefix | ||
let paramsPrefix = options.url.indexOf('?') >= 0 ? '&' : '?'; | ||
// UC method | ||
const method = options.method.toUpperCase(); | ||
// Data to modify GET URL | ||
if ((method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') && options.data) { | ||
let stringData; | ||
if (typeof options.data === 'string') { | ||
// Should be key=value string | ||
if (options.data.indexOf('?') >= 0) stringData = options.data.split('?')[1]; | ||
else stringData = options.data; | ||
} else { | ||
// Should be key=value object | ||
stringData = serializeObject(options.data); | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (stringData.length) { | ||
options.url += paramsPrefix + stringData; | ||
if (paramsPrefix === '?') paramsPrefix = '&'; | ||
} | ||
} | ||
// JSONP | ||
if (options.dataType === 'json' && options.url.indexOf('callback=') >= 0) { | ||
const callbackName = `f7jsonp_${Date.now() + ((jsonpRequests += 1))}`; | ||
let abortTimeout; | ||
const callbackSplit = options.url.split('callback='); | ||
let requestUrl = `${callbackSplit[0]}callback=${callbackName}`; | ||
if (callbackSplit[1].indexOf('&') >= 0) { | ||
const addVars = callbackSplit[1].split('&').filter((el) => el.indexOf('=') > 0).join('&'); | ||
if (addVars.length > 0) requestUrl += `&${addVars}`; | ||
} | ||
// Create script | ||
let script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.onerror = function onerror() { | ||
clearTimeout(abortTimeout); | ||
fireAjaxCallback(undefined, undefined, 'error', null, 'scripterror'); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { scripterror: true }, 'complete', null, 'scripterror'); | ||
}; | ||
script.src = requestUrl; | ||
// Handler | ||
window[callbackName] = function jsonpCallback(data) { | ||
clearTimeout(abortTimeout); | ||
fireAjaxCallback(undefined, undefined, 'success', data); | ||
script.parentNode.removeChild(script); | ||
script = null; | ||
delete window[callbackName]; | ||
}; | ||
document.querySelector('head').appendChild(script); | ||
if (options.timeout > 0) { | ||
abortTimeout = setTimeout(() => { | ||
script.parentNode.removeChild(script); | ||
script = null; | ||
fireAjaxCallback(undefined, undefined, 'error', null, 'timeout'); | ||
}, options.timeout); | ||
} | ||
return; | ||
} | ||
// Cache for GET/HEAD requests | ||
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') { | ||
if (options.cache === false) { | ||
options.url += `${paramsPrefix}_nocache${Date.now()}`; | ||
} | ||
} | ||
// Create XHR | ||
const xhr = new XMLHttpRequest(); | ||
// Save Request URL | ||
xhr.requestUrl = options.url; | ||
xhr.requestParameters = options; | ||
// Open XHR | ||
xhr.open(method, options.url, options.async, options.user, options.password); | ||
// Create POST Data | ||
let postData = null; | ||
if ((method === 'POST' || method === 'PUT' || method === 'PATCH') && options.data) { | ||
if (options.processData) { | ||
const postDataInstances = [ArrayBuffer, Blob, Document, FormData]; | ||
// Post Data | ||
if (postDataInstances.indexOf(options.data.constructor) >= 0) { | ||
postData = options.data; | ||
} else { | ||
// POST Headers | ||
let boundary = `---------------------------${Date.now().toString(16)}`; | ||
if (options.contentType === 'multipart/form-data') { | ||
xhr.setRequestHeader('Content-Type', `multipart/form-data; boundary=${boundary}`); | ||
} else { | ||
xhr.setRequestHeader('Content-Type', options.contentType); | ||
} | ||
postData = ''; | ||
let data = serializeObject(options.data); | ||
if (options.contentType === 'multipart/form-data') { | ||
data = data.split('&'); | ||
const newData = []; | ||
for (let i = 0; i < data.length; i += 1) { | ||
newData.push(`Content-Disposition: form-data; name="${data[i].split('=')[0]}"\r\n\r\n${data[i].split('=')[1]}\r\n`); | ||
} | ||
postData = `--${boundary}\r\n${newData.join(`--${boundary}\r\n`)}--${boundary}--\r\n`; | ||
} else { | ||
postData = data; | ||
} | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
postData = options.data; | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
} | ||
// Additional headers | ||
if (options.headers) { | ||
each(options.headers, (headerName, headerCallback) => { | ||
xhr.setRequestHeader(headerName, headerCallback); | ||
}); | ||
} | ||
return els; | ||
}, | ||
// Check for crossDomain | ||
if (typeof options.crossDomain === 'undefined') { | ||
options.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(options.url) && RegExp.$2 !== window.location.host; | ||
} | ||
if (!options.crossDomain) { | ||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
} | ||
if (options.xhrFields) { | ||
each(options.xhrFields, (fieldName, fieldValue) => { | ||
xhr[fieldName] = fieldValue; | ||
}); | ||
} | ||
let xhrTimeout; | ||
// Handle XHR | ||
xhr.onload = function onload() { | ||
if (xhrTimeout) clearTimeout(xhrTimeout); | ||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) { | ||
let responseData; | ||
if (options.dataType === 'json') { | ||
try { | ||
responseData = JSON.parse(xhr.responseText); | ||
fireAjaxCallback('ajaxSuccess ajax:success', { xhr }, 'success', responseData, xhr.status, xhr); | ||
} catch (err) { | ||
fireAjaxCallback('ajaxError ajax:error', { xhr, parseerror: true }, 'error', xhr, 'parseerror'); | ||
} | ||
} else { | ||
responseData = xhr.responseType === 'text' || xhr.responseType === '' ? xhr.responseText : xhr.response; | ||
fireAjaxCallback('ajaxSuccess ajax:success', { xhr }, 'success', responseData, xhr.status, xhr); | ||
stop() { | ||
const els = this; | ||
for (let i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
} | ||
} else { | ||
fireAjaxCallback('ajaxError ajax:error', { xhr }, 'error', xhr, xhr.status); | ||
} | ||
if (options.statusCode) { | ||
if (globals.statusCode && globals.statusCode[xhr.status]) globals.statusCode[xhr.status](xhr); | ||
if (options.statusCode[xhr.status]) options.statusCode[xhr.status](xhr); | ||
} | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr }, 'complete', xhr, xhr.status); | ||
}; | ||
xhr.onerror = function onerror() { | ||
if (xhrTimeout) clearTimeout(xhrTimeout); | ||
fireAjaxCallback('ajaxError ajax:error', { xhr }, 'error', xhr, xhr.status); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr, error: true }, 'complete', xhr, 'error'); | ||
}; | ||
// Ajax start callback | ||
fireAjaxCallback('ajaxStart ajax:start', { xhr }, 'start', xhr); | ||
fireAjaxCallback(undefined, undefined, 'beforeSend', xhr); | ||
// Timeout | ||
if (options.timeout > 0) { | ||
xhr.onabort = function onabort() { | ||
if (xhrTimeout) clearTimeout(xhrTimeout); | ||
}; | ||
xhrTimeout = setTimeout(() => { | ||
xhr.abort(); | ||
fireAjaxCallback('ajaxError ajax:error', { xhr, timeout: true }, 'error', xhr, 'timeout'); | ||
fireAjaxCallback('ajaxComplete ajax:complete', { xhr, timeout: true }, 'complete', xhr, 'timeout'); | ||
}, options.timeout); | ||
} | ||
// Send XHR | ||
xhr.send(postData); | ||
// Return XHR object | ||
return xhr; | ||
} | ||
function ajaxShortcut(method, ...args) { | ||
let url; | ||
let data; | ||
let success; | ||
let error; | ||
let dataType; | ||
if (typeof args[1] === 'function') { | ||
[url, success, error, dataType] = args; | ||
} else { | ||
[url, data, success, error, dataType] = args; | ||
} | ||
[success, error].forEach((callback) => { | ||
if (typeof callback === 'string') { | ||
dataType = callback; | ||
if (callback === success) success = undefined; | ||
else error = undefined; | ||
} | ||
}); | ||
dataType = dataType || (method === 'getJSON' ? 'json' : undefined); | ||
return ajax({ | ||
url, | ||
method: method === 'post' ? 'POST' : 'GET', | ||
data, | ||
success, | ||
error, | ||
dataType, | ||
}); | ||
} | ||
function get(...args) { | ||
args.unshift('get'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
function post(...args) { | ||
args.unshift('post'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
function getJSON(...args) { | ||
args.unshift('getJSON'); | ||
return ajaxShortcut.apply(this, args); | ||
} | ||
const Ajax = { | ||
__utils: true, | ||
ajaxSetup, | ||
ajax, | ||
get, | ||
post, | ||
getJSON, | ||
}, | ||
}; | ||
// Utils & Helpers | ||
$$1.use(Utils, Methods, Scroll, Animate, Ajax); | ||
// Install methods | ||
$$1.use(Methods, Scroll, Animate); | ||
export default $$1; |
{ | ||
"name": "dom7", | ||
"version": "1.7.2", | ||
"version": "2.0.0", | ||
"description": "Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API", | ||
@@ -5,0 +5,0 @@ "main": "dist/dom7.js", |
import $ from './$'; | ||
import { requestAnimationFrame, cancelAnimationFrame } from './utils'; | ||
function animate(initialProps, initialParams) { | ||
const els = this; | ||
const a = { | ||
props: $.extend({}, initialProps), | ||
params: $.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
const Animate = { | ||
animate(initialProps, initialParams) { | ||
const els = this; | ||
const a = { | ||
props: $.extend({}, initialProps), | ||
params: $.extend({ | ||
duration: 300, | ||
easing: 'swing', // or 'linear' | ||
/* Callbacks | ||
begin(elements) | ||
complete(elements) | ||
progress(elements, complete, remaining, start, tweenValue) | ||
*/ | ||
}, initialParams), | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
elements: els, | ||
animating: false, | ||
que: [], | ||
easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done(complete) { | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) complete(els); | ||
if (a.que.length > 0) { | ||
const que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
const elements = []; | ||
easingProgress(easing, progress) { | ||
if (easing === 'swing') { | ||
return 0.5 - (Math.cos(progress * Math.PI) / 2); | ||
} | ||
if (typeof easing === 'function') { | ||
return easing(progress); | ||
} | ||
return progress; | ||
}, | ||
stop() { | ||
if (a.frameId) { | ||
cancelAnimationFrame(a.frameId); | ||
} | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
a.que = []; | ||
}, | ||
done(complete) { | ||
a.animating = false; | ||
a.elements.each((index, el) => { | ||
const element = el; | ||
delete element.dom7AnimateInstance; | ||
}); | ||
if (complete) complete(els); | ||
if (a.que.length > 0) { | ||
const que = a.que.shift(); | ||
a.animate(que[0], que[1]); | ||
} | ||
}, | ||
animate(props, params) { | ||
if (a.animating) { | ||
a.que.push([props, params]); | ||
return a; | ||
} | ||
const elements = []; | ||
// Define & Cache Initials & Units | ||
a.elements.each((index, el) => { | ||
let initialFullValue; | ||
let initialValue; | ||
let unit; | ||
let finalValue; | ||
let finalFullValue; | ||
// Define & Cache Initials & Units | ||
a.elements.each((index, el) => { | ||
let initialFullValue; | ||
let initialValue; | ||
let unit; | ||
let finalValue; | ||
let finalFullValue; | ||
if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a; | ||
if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a; | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach((prop) => { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue, | ||
initialValue, | ||
unit, | ||
finalValue, | ||
finalFullValue, | ||
currentValue: initialValue, | ||
elements[index] = { | ||
container: el, | ||
}; | ||
Object.keys(props).forEach((prop) => { | ||
initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); | ||
initialValue = parseFloat(initialFullValue); | ||
unit = initialFullValue.replace(initialValue, ''); | ||
finalValue = parseFloat(props[prop]); | ||
finalFullValue = props[prop] + unit; | ||
elements[index][prop] = { | ||
initialFullValue, | ||
initialValue, | ||
unit, | ||
finalValue, | ||
finalFullValue, | ||
currentValue: initialValue, | ||
}; | ||
}); | ||
}); | ||
}); | ||
let startTime = null; | ||
let time; | ||
let elementsDone = 0; | ||
let propsDone = 0; | ||
let done; | ||
let began = false; | ||
let startTime = null; | ||
let time; | ||
let elementsDone = 0; | ||
let propsDone = 0; | ||
let done; | ||
let began = false; | ||
a.animating = true; | ||
a.animating = true; | ||
function render() { | ||
time = new Date().getTime(); | ||
let progress; | ||
let easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) params.begin(els); | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
function render() { | ||
time = new Date().getTime(); | ||
let progress; | ||
let easeProgress; | ||
// let el; | ||
if (!began) { | ||
began = true; | ||
if (params.begin) params.begin(els); | ||
} | ||
if (startTime === null) { | ||
startTime = time; | ||
} | ||
if (params.progress) { | ||
params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime); | ||
} | ||
elements.forEach((element) => { | ||
const el = element; | ||
if (done || el.done) return; | ||
Object.keys(props).forEach((prop) => { | ||
elements.forEach((element) => { | ||
const el = element; | ||
if (done || el.done) return; | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
const { initialValue, finalValue, unit } = el[prop]; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
const currentValue = el[prop].currentValue; | ||
Object.keys(props).forEach((prop) => { | ||
if (done || el.done) return; | ||
progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); | ||
easeProgress = a.easingProgress(params.easing, progress); | ||
const { initialValue, finalValue, unit } = el[prop]; | ||
el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue)); | ||
const currentValue = el[prop].currentValue; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
if ( | ||
(finalValue > initialValue && currentValue >= finalValue) || | ||
(finalValue < initialValue && currentValue <= finalValue)) { | ||
el.container.style[prop] = finalValue + unit; | ||
propsDone += 1; | ||
if (propsDone === Object.keys(props).length) { | ||
el.done = true; | ||
elementsDone += 1; | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
} | ||
} | ||
if (elementsDone === elements.length) { | ||
done = true; | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
} | ||
if (done) { | ||
a.done(params.complete); | ||
return; | ||
} | ||
el.container.style[prop] = currentValue + unit; | ||
el.container.style[prop] = currentValue + unit; | ||
}); | ||
}); | ||
}); | ||
if (done) return; | ||
// Then call | ||
if (done) return; | ||
// Then call | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
} | ||
a.frameId = requestAnimationFrame(render); | ||
return a; | ||
}, | ||
}; | ||
return a; | ||
}, | ||
}; | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
if (a.elements.length === 0) { | ||
return els; | ||
} | ||
let animateInstance; | ||
for (let i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else a.elements[i].dom7AnimateInstance = a; | ||
} | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
let animateInstance; | ||
for (let i = 0; i < a.elements.length; i += 1) { | ||
if (a.elements[i].dom7AnimateInstance) { | ||
animateInstance = a.elements[i].dom7AnimateInstance; | ||
} else a.elements[i].dom7AnimateInstance = a; | ||
} | ||
if (!animateInstance) { | ||
animateInstance = a; | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
if (initialProps === 'stop') { | ||
animateInstance.stop(); | ||
} else { | ||
animateInstance.animate(a.props, a.params); | ||
} | ||
return els; | ||
} | ||
return els; | ||
}, | ||
function stop() { | ||
const els = this; | ||
for (let i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
stop() { | ||
const els = this; | ||
for (let i = 0; i < els.length; i += 1) { | ||
if (els[i].dom7AnimateInstance) { | ||
els[i].dom7AnimateInstance.stop(); | ||
} | ||
} | ||
} | ||
} | ||
const Animate = { | ||
animate, | ||
stop, | ||
}, | ||
}; | ||
export { animate, stop }; | ||
export default Animate; |
import $ from './$'; | ||
import Utils from './utils'; | ||
import Methods from './methods'; | ||
import Scroll from './scroll'; | ||
import Animate from './animate'; | ||
import Ajax from './ajax'; | ||
// Utils & Helpers | ||
$.use(Utils, Methods, Scroll, Animate, Ajax); | ||
// Install methods | ||
$.use(Methods, Scroll, Animate); | ||
// Export | ||
export default $; |
import $ from './$'; | ||
import Utils from './utils'; | ||
import Methods from './methods'; | ||
import Scroll from './scroll'; | ||
import Animate from './animate'; | ||
import Ajax from './ajax'; | ||
// Export | ||
export { $, Utils, Methods, Scroll, Animate, Ajax }; | ||
export { $, Methods, Scroll, Animate }; |
157
src/utils.js
@@ -1,56 +0,1 @@ | ||
import Dom7 from './dom7-class'; | ||
import $ from './$'; | ||
function parseUrlQuery(url) { | ||
const query = {}; | ||
let urlToParse = url || window.location.href; | ||
let i; | ||
let params; | ||
let param; | ||
let length; | ||
if (typeof urlToParse === 'string' && urlToParse.length) { | ||
urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : ''; | ||
params = urlToParse.split('&').filter(paramsPart => paramsPart !== ''); | ||
length = params.length; | ||
for (i = 0; i < length; i += 1) { | ||
param = params[i].replace(/#\S+/g, '').split('='); | ||
query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || ''; | ||
} | ||
} | ||
return query; | ||
} | ||
function isArray(arr) { | ||
return Array.isArray(arr); | ||
} | ||
function each(obj, callback) { | ||
// Check it's iterable | ||
// TODO: Should probably raise a value error here | ||
if (typeof obj !== 'object') return; | ||
// Don't bother continuing without a callback | ||
if (!callback) return; | ||
if (Array.isArray(obj) || obj instanceof Dom7) { | ||
// Array | ||
for (let i = 0; i < obj.length; i += 1) { | ||
// If callback returns false | ||
if (callback(i, obj[i]) === false) { | ||
// Break out of the loop | ||
return; | ||
} | ||
} | ||
} else { | ||
// Object | ||
for (let prop in obj) { | ||
// Check the propertie belongs to the object | ||
// not it's prototype | ||
if (obj.hasOwnProperty(prop)) { | ||
// If the callback returns false | ||
if (callback(prop, obj[prop]) === false) { | ||
// Break out of the loop; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
function unique(arr) { | ||
@@ -63,57 +8,6 @@ const uniqueArray = []; | ||
} | ||
function serializeObject(obj, parents = []) { | ||
if (typeof obj === 'string') return obj; | ||
const resultArray = []; | ||
const separator = '&'; | ||
let newParents; | ||
function varName(name) { | ||
if (parents.length > 0) { | ||
let parentParts = ''; | ||
for (let j = 0; j < parents.length; j += 1) { | ||
if (j === 0) parentParts += parents[j]; | ||
else parentParts += `[${encodeURIComponent(parents[j])}]`; | ||
} | ||
return `${parentParts}[${encodeURIComponent(name)}]`; | ||
} | ||
return encodeURIComponent(name); | ||
} | ||
function varValue(value) { | ||
return encodeURIComponent(value); | ||
} | ||
Object.keys(obj).forEach((prop) => { | ||
let toPush; | ||
if (Array.isArray(obj[prop])) { | ||
toPush = []; | ||
for (let i = 0; i < obj[prop].length; i += 1) { | ||
if (!Array.isArray(obj[prop][i]) && typeof obj[prop][i] === 'object') { | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
newParents.push(String(i)); | ||
toPush.push(serializeObject(obj[prop][i], newParents)); | ||
} else { | ||
toPush.push(`${varName(prop)}[]=${varValue(obj[prop][i])}`); | ||
} | ||
} | ||
if (toPush.length > 0) resultArray.push(toPush.join(separator)); | ||
} else if (obj[prop] === null || obj[prop] === '') { | ||
resultArray.push(`${varName(prop)}=`); | ||
} else if (typeof obj[prop] === 'object') { | ||
// Object, convert to named array | ||
newParents = parents.slice(); | ||
newParents.push(prop); | ||
toPush = serializeObject(obj[prop], newParents); | ||
if (toPush !== '') resultArray.push(toPush); | ||
} else if (typeof obj[prop] !== 'undefined' && obj[prop] !== '') { | ||
// Should be string or plain value | ||
resultArray.push(`${varName(prop)}=${varValue(obj[prop])}`); | ||
} else if (obj[prop] === '') resultArray.push(varName(prop)); | ||
}); | ||
return resultArray.join(separator); | ||
} | ||
function toCamelCase(string) { | ||
return string.toLowerCase().replace(/-(.)/g, (match, group1) => group1.toUpperCase()); | ||
} | ||
function dataset(el) { | ||
return $(el).dataset(); | ||
} | ||
function requestAnimationFrame(callback) { | ||
@@ -129,57 +23,8 @@ if (window.requestAnimationFrame) return window.requestAnimationFrame(callback); | ||
} | ||
function isObject(o) { | ||
return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; | ||
} | ||
function extend(...args) { | ||
const to = Object(args[0]); | ||
for (let i = 1; i < args.length; i += 1) { | ||
const nextSource = args[i]; | ||
if (nextSource !== undefined && nextSource !== null) { | ||
const keysArray = Object.keys(Object(nextSource)); | ||
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { | ||
const nextKey = keysArray[nextIndex]; | ||
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); | ||
if (desc !== undefined && desc.enumerable) { | ||
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { | ||
to[nextKey] = {}; | ||
extend(to[nextKey], nextSource[nextKey]); | ||
} else { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
} | ||
const Utils = { | ||
__utils: true, | ||
parseUrlQuery, | ||
parseQuery: parseUrlQuery, | ||
isArray, | ||
each, | ||
unique, | ||
serializeObject, | ||
param: serializeObject, | ||
toCamelCase, | ||
dataset, | ||
requestAnimationFrame, | ||
cancelAnimationFrame, | ||
extend, | ||
}; | ||
export { | ||
parseUrlQuery, | ||
isArray, | ||
each, | ||
unique, | ||
serializeObject, | ||
toCamelCase, | ||
dataset, | ||
requestAnimationFrame, | ||
cancelAnimationFrame, | ||
extend, | ||
}; | ||
export default Utils; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252926
21
5219