first commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { $, addClass, removeClass, hasClass, toggleClass, attr, removeAttr, transform, transition, on, off, trigger, transitionEnd, outerWidth, outerHeight, styles, offset, css, each, html, text, is, index, eq, append, prepend, next, nextAll, prev, prevAll, parent, parents, closest, find, children, filter, remove } from 'dom7';
|
||||
var Methods = {
|
||||
addClass: addClass,
|
||||
removeClass: removeClass,
|
||||
hasClass: hasClass,
|
||||
toggleClass: toggleClass,
|
||||
attr: attr,
|
||||
removeAttr: removeAttr,
|
||||
transform: transform,
|
||||
transition: transition,
|
||||
on: on,
|
||||
off: off,
|
||||
trigger: trigger,
|
||||
transitionEnd: transitionEnd,
|
||||
outerWidth: outerWidth,
|
||||
outerHeight: outerHeight,
|
||||
styles: styles,
|
||||
offset: offset,
|
||||
css: css,
|
||||
each: each,
|
||||
html: html,
|
||||
text: text,
|
||||
is: is,
|
||||
index: index,
|
||||
eq: eq,
|
||||
append: append,
|
||||
prepend: prepend,
|
||||
next: next,
|
||||
nextAll: nextAll,
|
||||
prev: prev,
|
||||
prevAll: prevAll,
|
||||
parent: parent,
|
||||
parents: parents,
|
||||
closest: closest,
|
||||
find: find,
|
||||
children: children,
|
||||
filter: filter,
|
||||
remove: remove
|
||||
};
|
||||
Object.keys(Methods).forEach(function (methodName) {
|
||||
Object.defineProperty($.fn, methodName, {
|
||||
value: Methods[methodName],
|
||||
writable: true
|
||||
});
|
||||
});
|
||||
export default $;
|
||||
@@ -0,0 +1,27 @@
|
||||
import { getWindow } from 'ssr-window';
|
||||
var browser;
|
||||
|
||||
function calcBrowser() {
|
||||
var window = getWindow();
|
||||
|
||||
function isSafari() {
|
||||
var ua = window.navigator.userAgent.toLowerCase();
|
||||
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
|
||||
}
|
||||
|
||||
return {
|
||||
isEdge: !!window.navigator.userAgent.match(/Edge/g),
|
||||
isSafari: isSafari(),
|
||||
isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
|
||||
};
|
||||
}
|
||||
|
||||
function getBrowser() {
|
||||
if (!browser) {
|
||||
browser = calcBrowser();
|
||||
}
|
||||
|
||||
return browser;
|
||||
}
|
||||
|
||||
export { getBrowser };
|
||||
@@ -0,0 +1,62 @@
|
||||
import { getWindow } from 'ssr-window';
|
||||
import { getSupport } from './get-support';
|
||||
var device;
|
||||
|
||||
function calcDevice(_temp) {
|
||||
var _ref = _temp === void 0 ? {} : _temp,
|
||||
userAgent = _ref.userAgent;
|
||||
|
||||
var support = getSupport();
|
||||
var window = getWindow();
|
||||
var platform = window.navigator.platform;
|
||||
var ua = userAgent || window.navigator.userAgent;
|
||||
var device = {
|
||||
ios: false,
|
||||
android: false
|
||||
};
|
||||
var screenWidth = window.screen.width;
|
||||
var screenHeight = window.screen.height;
|
||||
var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
|
||||
|
||||
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
||||
var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
|
||||
var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
|
||||
var windows = platform === 'Win32';
|
||||
var macos = platform === 'MacIntel'; // iPadOs 13 fix
|
||||
|
||||
var iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
|
||||
|
||||
if (!ipad && macos && support.touch && iPadScreens.indexOf(screenWidth + "x" + screenHeight) >= 0) {
|
||||
ipad = ua.match(/(Version)\/([\d.]+)/);
|
||||
if (!ipad) ipad = [0, 1, '13_0_0'];
|
||||
macos = false;
|
||||
} // Android
|
||||
|
||||
|
||||
if (android && !windows) {
|
||||
device.os = 'android';
|
||||
device.android = true;
|
||||
}
|
||||
|
||||
if (ipad || iphone || ipod) {
|
||||
device.os = 'ios';
|
||||
device.ios = true;
|
||||
} // Export object
|
||||
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
function getDevice(overrides) {
|
||||
if (overrides === void 0) {
|
||||
overrides = {};
|
||||
}
|
||||
|
||||
if (!device) {
|
||||
device = calcDevice(overrides);
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
export { getDevice };
|
||||
@@ -0,0 +1,43 @@
|
||||
import { getWindow, getDocument } from 'ssr-window';
|
||||
var support;
|
||||
|
||||
function calcSupport() {
|
||||
var window = getWindow();
|
||||
var document = getDocument();
|
||||
return {
|
||||
touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
|
||||
pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0,
|
||||
observer: function checkObserver() {
|
||||
return 'MutationObserver' in window || 'WebkitMutationObserver' in window;
|
||||
}(),
|
||||
passiveListener: function checkPassiveListener() {
|
||||
var supportsPassive = false;
|
||||
|
||||
try {
|
||||
var opts = Object.defineProperty({}, 'passive', {
|
||||
// eslint-disable-next-line
|
||||
get: function get() {
|
||||
supportsPassive = true;
|
||||
}
|
||||
});
|
||||
window.addEventListener('testPassiveListener', null, opts);
|
||||
} catch (e) {// No support
|
||||
}
|
||||
|
||||
return supportsPassive;
|
||||
}(),
|
||||
gestures: function checkGestures() {
|
||||
return 'ongesturestart' in window;
|
||||
}()
|
||||
};
|
||||
}
|
||||
|
||||
function getSupport() {
|
||||
if (!support) {
|
||||
support = calcSupport();
|
||||
}
|
||||
|
||||
return support;
|
||||
}
|
||||
|
||||
export { getSupport };
|
||||
@@ -0,0 +1,189 @@
|
||||
import { getDocument, getWindow } from 'ssr-window';
|
||||
|
||||
function deleteProps(obj) {
|
||||
var object = obj;
|
||||
Object.keys(object).forEach(function (key) {
|
||||
try {
|
||||
object[key] = null;
|
||||
} catch (e) {// no getter for object
|
||||
}
|
||||
|
||||
try {
|
||||
delete object[key];
|
||||
} catch (e) {// something got wrong
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function nextTick(callback, delay) {
|
||||
if (delay === void 0) {
|
||||
delay = 0;
|
||||
}
|
||||
|
||||
return setTimeout(callback, delay);
|
||||
}
|
||||
|
||||
function now() {
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
function getComputedStyle(el) {
|
||||
var window = getWindow();
|
||||
var style;
|
||||
|
||||
if (window.getComputedStyle) {
|
||||
style = window.getComputedStyle(el, null);
|
||||
}
|
||||
|
||||
if (!style && el.currentStyle) {
|
||||
style = el.currentStyle;
|
||||
}
|
||||
|
||||
if (!style) {
|
||||
style = el.style;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
function getTranslate(el, axis) {
|
||||
if (axis === void 0) {
|
||||
axis = 'x';
|
||||
}
|
||||
|
||||
var window = getWindow();
|
||||
var matrix;
|
||||
var curTransform;
|
||||
var transformMatrix;
|
||||
var curStyle = getComputedStyle(el, null);
|
||||
|
||||
if (window.WebKitCSSMatrix) {
|
||||
curTransform = curStyle.transform || curStyle.webkitTransform;
|
||||
|
||||
if (curTransform.split(',').length > 6) {
|
||||
curTransform = curTransform.split(', ').map(function (a) {
|
||||
return a.replace(',', '.');
|
||||
}).join(', ');
|
||||
} // Some old versions of Webkit choke when 'none' is passed; pass
|
||||
// empty string instead in this case
|
||||
|
||||
|
||||
transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
||||
} else {
|
||||
transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
||||
matrix = transformMatrix.toString().split(',');
|
||||
}
|
||||
|
||||
if (axis === 'x') {
|
||||
// Latest Chrome and webkits Fix
|
||||
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix
|
||||
else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers
|
||||
else curTransform = parseFloat(matrix[4]);
|
||||
}
|
||||
|
||||
if (axis === 'y') {
|
||||
// Latest Chrome and webkits Fix
|
||||
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix
|
||||
else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers
|
||||
else curTransform = parseFloat(matrix[5]);
|
||||
}
|
||||
|
||||
return curTransform || 0;
|
||||
}
|
||||
|
||||
function isObject(o) {
|
||||
return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
||||
}
|
||||
|
||||
function isNode(node) {
|
||||
// eslint-disable-next-line
|
||||
if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
|
||||
return node instanceof HTMLElement;
|
||||
}
|
||||
|
||||
return node && (node.nodeType === 1 || node.nodeType === 11);
|
||||
}
|
||||
|
||||
function extend() {
|
||||
var to = Object(arguments.length <= 0 ? undefined : arguments[0]);
|
||||
var noExtend = ['__proto__', 'constructor', 'prototype'];
|
||||
|
||||
for (var i = 1; i < arguments.length; i += 1) {
|
||||
var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
||||
|
||||
if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
|
||||
var keysArray = Object.keys(Object(nextSource)).filter(function (key) {
|
||||
return noExtend.indexOf(key) < 0;
|
||||
});
|
||||
|
||||
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])) {
|
||||
if (nextSource[nextKey].__swiper__) {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
} else {
|
||||
extend(to[nextKey], nextSource[nextKey]);
|
||||
}
|
||||
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
|
||||
to[nextKey] = {};
|
||||
|
||||
if (nextSource[nextKey].__swiper__) {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
} else {
|
||||
extend(to[nextKey], nextSource[nextKey]);
|
||||
}
|
||||
} else {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
function bindModuleMethods(instance, obj) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
if (isObject(obj[key])) {
|
||||
Object.keys(obj[key]).forEach(function (subKey) {
|
||||
if (typeof obj[key][subKey] === 'function') {
|
||||
obj[key][subKey] = obj[key][subKey].bind(instance);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
instance[key] = obj[key];
|
||||
});
|
||||
}
|
||||
|
||||
function classesToSelector(classes) {
|
||||
if (classes === void 0) {
|
||||
classes = '';
|
||||
}
|
||||
|
||||
return "." + classes.trim().replace(/([\.:!\/])/g, '\\$1') // eslint-disable-line
|
||||
.replace(/ /g, '.');
|
||||
}
|
||||
|
||||
function createElementIfNotDefined($container, params, createElements, checkProps) {
|
||||
var document = getDocument();
|
||||
|
||||
if (createElements) {
|
||||
Object.keys(checkProps).forEach(function (key) {
|
||||
if (!params[key] && params.auto === true) {
|
||||
var element = document.createElement('div');
|
||||
element.className = checkProps[key];
|
||||
$container.append(element);
|
||||
params[key] = element;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export { deleteProps, nextTick, now, getTranslate, isObject, extend, bindModuleMethods, getComputedStyle, classesToSelector, createElementIfNotDefined };
|
||||
Reference in New Issue
Block a user