fix locale
This commit is contained in:
BIN
dist/external/.DS_Store
vendored
BIN
dist/external/.DS_Store
vendored
Binary file not shown.
102
dist/external/deparam/deparam.esm.js
vendored
102
dist/external/deparam/deparam.esm.js
vendored
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* Created by alexey2baranov on 28.01.17.
|
||||
*/
|
||||
/*
|
||||
An extraction of the deparam method from Ben Alman's jQuery BBQ
|
||||
http://benalman.com/projects/jquery-bbq-plugin/
|
||||
*/
|
||||
|
||||
const coerce_types = {'true': !0, 'false': !1, 'null': null};
|
||||
|
||||
function deparam (params, coerce) {
|
||||
// console.log(params)
|
||||
const obj = {};
|
||||
|
||||
// Iterate over all name=value pairs.
|
||||
params.replace(/\+/g, ' ').split('&').forEach(function (v) {
|
||||
const param = v.split('=');
|
||||
|
||||
let
|
||||
key = decodeURIComponent(param[0]),
|
||||
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
||||
// into its component parts.
|
||||
keys = key.split(']['),
|
||||
keys_last = keys.length - 1;
|
||||
|
||||
// If the first keys part contains [ and the last ends with ], then []
|
||||
// are correctly balanced.
|
||||
if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) {
|
||||
// Remove the trailing ] from the last keys part.
|
||||
keys[keys_last] = keys[keys_last].replace(/\]$/, '');
|
||||
|
||||
// Split first keys part into two parts on the [ and add them back onto
|
||||
// the beginning of the keys array.
|
||||
keys = keys.shift().split('[').concat(keys);
|
||||
|
||||
keys_last = keys.length - 1;
|
||||
} else {
|
||||
// Basic 'foo' style key.
|
||||
keys_last = 0;
|
||||
}
|
||||
|
||||
// Are we dealing with a name=value pair, or just a name?
|
||||
if (param.length >= 2) {
|
||||
let val = decodeURIComponent(param.slice(1).join('='));
|
||||
|
||||
// Coerce values.
|
||||
if (coerce) {
|
||||
val = val && !isNaN(val) ? +val // number
|
||||
: val === 'undefined' ? undefined // undefined
|
||||
: coerce_types[val] !== undefined ? coerce_types[val] // true, false, null
|
||||
: val; // string
|
||||
}
|
||||
|
||||
if (keys_last) {
|
||||
let cur = obj;
|
||||
// Complex key, build deep object structure based on a few rules:
|
||||
// * The 'cur' pointer starts at the object top-level.
|
||||
// * [] = array push (n is set to array length), [n] = array if n is
|
||||
// numeric, otherwise object.
|
||||
// * If at the last keys part, set the value.
|
||||
// * For each keys part, if the current level is undefined create an
|
||||
// object or array based on the type of the next keys part.
|
||||
// * Move the 'cur' pointer to the next level.
|
||||
// * Rinse & repeat.
|
||||
for (let i = 0; i <= keys_last; i++) {
|
||||
key = keys[i] === '' ? cur.length : keys[i];
|
||||
cur = cur[key] = i < keys_last
|
||||
? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : [])
|
||||
: val;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Simple key, even simpler rules, since only scalars and shallow
|
||||
// arrays are allowed.
|
||||
|
||||
if (Array.isArray(obj[key])) {
|
||||
// val is already an array, so push on the next value.
|
||||
obj[key].push(val);
|
||||
|
||||
} else if (obj[key] !== undefined) {
|
||||
// val isn't an array, but since a second value has been specified,
|
||||
// convert val into an array.
|
||||
obj[key] = [obj[key], val];
|
||||
|
||||
} else {
|
||||
// val is a scalar.
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (key) {
|
||||
// No value was defined, so set something meaningful.
|
||||
obj[key] = coerce
|
||||
? undefined
|
||||
: '';
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
export default deparam;
|
||||
121
dist/external/dom-polyfill/dom-polyfill.js
vendored
121
dist/external/dom-polyfill/dom-polyfill.js
vendored
@@ -1,121 +0,0 @@
|
||||
// From https://github.com/inexorabletash/polyfill/blob/master/dom.js
|
||||
|
||||
/**
|
||||
* @module DOMPolyfill
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Node} o
|
||||
* @param {module:DOMPolyfill~ParentNode|module:DOMPolyfill~ChildNode} ps
|
||||
* @returns {void}
|
||||
*/
|
||||
function mixin (o, ps) {
|
||||
if (!o) return;
|
||||
Object.keys(ps).forEach((p) => {
|
||||
if ((p in o) || (p in o.prototype)) { return; }
|
||||
try {
|
||||
Object.defineProperty(
|
||||
o.prototype,
|
||||
p,
|
||||
Object.getOwnPropertyDescriptor(ps, p)
|
||||
);
|
||||
} catch (ex) {
|
||||
// Throws in IE8; just copy it
|
||||
o[p] = ps[p];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Node[]} nodes
|
||||
* @returns {Node}
|
||||
*/
|
||||
function convertNodesIntoANode (nodes) {
|
||||
nodes = nodes.map((node) => {
|
||||
const isNode = node && typeof node === 'object' && 'nodeType' in node;
|
||||
return isNode ? node : document.createTextNode(node);
|
||||
});
|
||||
if (nodes.length === 1) {
|
||||
return nodes[0];
|
||||
}
|
||||
const node = document.createDocumentFragment();
|
||||
nodes.forEach((n) => {
|
||||
// // eslint-disable-next-line unicorn/prefer-node-append
|
||||
node.appendChild(n);
|
||||
});
|
||||
return node;
|
||||
}
|
||||
|
||||
const ParentNode = {
|
||||
prepend (...nodes) {
|
||||
nodes = convertNodesIntoANode(nodes);
|
||||
this.insertBefore(nodes, this.firstChild);
|
||||
},
|
||||
append (...nodes) {
|
||||
nodes = convertNodesIntoANode(nodes);
|
||||
// // eslint-disable-next-line unicorn/prefer-node-append
|
||||
this.appendChild(nodes);
|
||||
}
|
||||
};
|
||||
|
||||
mixin(Document || HTMLDocument, ParentNode); // HTMLDocument for IE8
|
||||
mixin(DocumentFragment, ParentNode);
|
||||
mixin(Element, ParentNode);
|
||||
|
||||
// Mixin ChildNode
|
||||
// https://dom.spec.whatwg.org/#interface-childnode
|
||||
|
||||
const ChildNode = {
|
||||
before (...nodes) {
|
||||
const parent = this.parentNode;
|
||||
if (!parent) return;
|
||||
let viablePreviousSibling = this.previousSibling;
|
||||
while (nodes.includes(viablePreviousSibling)) {
|
||||
viablePreviousSibling = viablePreviousSibling.previousSibling;
|
||||
}
|
||||
const node = convertNodesIntoANode(nodes);
|
||||
parent.insertBefore(
|
||||
node,
|
||||
viablePreviousSibling
|
||||
? viablePreviousSibling.nextSibling
|
||||
: parent.firstChild
|
||||
);
|
||||
},
|
||||
after (...nodes) {
|
||||
const parent = this.parentNode;
|
||||
if (!parent) return;
|
||||
let viableNextSibling = this.nextSibling;
|
||||
while (nodes.includes(viableNextSibling)) {
|
||||
viableNextSibling = viableNextSibling.nextSibling;
|
||||
}
|
||||
const node = convertNodesIntoANode(nodes);
|
||||
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
|
||||
parent.insertBefore(node, viableNextSibling);
|
||||
},
|
||||
replaceWith (...nodes) {
|
||||
const parent = this.parentNode;
|
||||
if (!parent) return;
|
||||
let viableNextSibling = this.nextSibling;
|
||||
while (nodes.includes(viableNextSibling)) {
|
||||
viableNextSibling = viableNextSibling.nextSibling;
|
||||
}
|
||||
const node = convertNodesIntoANode(nodes);
|
||||
|
||||
if (this.parentNode === parent) {
|
||||
parent.replaceChild(node, this);
|
||||
} else {
|
||||
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
|
||||
parent.insertBefore(node, viableNextSibling);
|
||||
}
|
||||
},
|
||||
remove () {
|
||||
if (!this.parentNode) { return; }
|
||||
this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove
|
||||
}
|
||||
};
|
||||
|
||||
mixin(DocumentType, ChildNode);
|
||||
mixin(Element, ChildNode);
|
||||
mixin(CharacterData, ChildNode);
|
||||
1932
dist/external/jamilih/jml-es.js
vendored
1932
dist/external/jamilih/jml-es.js
vendored
File diff suppressed because it is too large
Load Diff
162
dist/external/load-stylesheets/index-es.js
vendored
162
dist/external/load-stylesheets/index-es.js
vendored
@@ -1,162 +0,0 @@
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
function loadStylesheets(stylesheets) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
beforeDefault = _ref.before,
|
||||
afterDefault = _ref.after,
|
||||
faviconDefault = _ref.favicon,
|
||||
canvasDefault = _ref.canvas,
|
||||
_ref$image = _ref.image,
|
||||
imageDefault = _ref$image === void 0 ? true : _ref$image,
|
||||
acceptErrors = _ref.acceptErrors;
|
||||
|
||||
stylesheets = Array.isArray(stylesheets) ? stylesheets : [stylesheets];
|
||||
|
||||
function setupLink(stylesheetURL) {
|
||||
var options = {};
|
||||
|
||||
if (Array.isArray(stylesheetURL)) {
|
||||
var _stylesheetURL = stylesheetURL;
|
||||
|
||||
var _stylesheetURL2 = _slicedToArray(_stylesheetURL, 2);
|
||||
|
||||
stylesheetURL = _stylesheetURL2[0];
|
||||
var _stylesheetURL2$ = _stylesheetURL2[1];
|
||||
options = _stylesheetURL2$ === void 0 ? {} : _stylesheetURL2$;
|
||||
}
|
||||
|
||||
var _options = options,
|
||||
_options$favicon = _options.favicon,
|
||||
favicon = _options$favicon === void 0 ? faviconDefault : _options$favicon;
|
||||
var _options2 = options,
|
||||
_options2$before = _options2.before,
|
||||
before = _options2$before === void 0 ? beforeDefault : _options2$before,
|
||||
_options2$after = _options2.after,
|
||||
after = _options2$after === void 0 ? afterDefault : _options2$after,
|
||||
_options2$canvas = _options2.canvas,
|
||||
canvas = _options2$canvas === void 0 ? canvasDefault : _options2$canvas,
|
||||
_options2$image = _options2.image,
|
||||
image = _options2$image === void 0 ? imageDefault : _options2$image;
|
||||
|
||||
function addLink() {
|
||||
if (before) {
|
||||
before.before(link);
|
||||
} else if (after) {
|
||||
after.after(link);
|
||||
} else {
|
||||
// eslint-disable-next-line unicorn/prefer-node-append
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
}
|
||||
|
||||
var link = document.createElement('link'); // eslint-disable-next-line promise/avoid-new
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var rej = reject;
|
||||
|
||||
if (acceptErrors) {
|
||||
rej = typeof acceptErrors === 'function' ? function (error) {
|
||||
acceptErrors({
|
||||
error: error,
|
||||
stylesheetURL: stylesheetURL,
|
||||
options: options,
|
||||
resolve: resolve,
|
||||
reject: reject
|
||||
});
|
||||
} : resolve;
|
||||
}
|
||||
|
||||
if (stylesheetURL.endsWith('.css')) {
|
||||
favicon = false;
|
||||
} else if (stylesheetURL.endsWith('.ico')) {
|
||||
favicon = true;
|
||||
}
|
||||
|
||||
if (favicon) {
|
||||
link.rel = 'shortcut icon';
|
||||
link.type = 'image/x-icon';
|
||||
|
||||
if (image === false) {
|
||||
link.href = stylesheetURL;
|
||||
addLink();
|
||||
resolve(link);
|
||||
return;
|
||||
}
|
||||
|
||||
var cnv = document.createElement('canvas');
|
||||
cnv.width = 16;
|
||||
cnv.height = 16;
|
||||
var context = cnv.getContext('2d');
|
||||
var img = document.createElement('img');
|
||||
img.addEventListener('error', function (error) {
|
||||
reject(error);
|
||||
});
|
||||
img.addEventListener('load', function () {
|
||||
context.drawImage(img, 0, 0);
|
||||
link.href = canvas ? cnv.toDataURL('image/x-icon') : stylesheetURL;
|
||||
addLink();
|
||||
resolve(link);
|
||||
});
|
||||
img.src = stylesheetURL;
|
||||
return;
|
||||
}
|
||||
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = stylesheetURL;
|
||||
addLink();
|
||||
link.addEventListener('error', function (error) {
|
||||
rej(error);
|
||||
});
|
||||
link.addEventListener('load', function () {
|
||||
resolve(link);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.all(stylesheets.map(function (stylesheetURL) {
|
||||
return setupLink(stylesheetURL);
|
||||
}));
|
||||
}
|
||||
|
||||
export default loadStylesheets;
|
||||
556
dist/external/qr-manipulation/dist/index-es.js
vendored
556
dist/external/qr-manipulation/dist/index-es.js
vendored
@@ -1,556 +0,0 @@
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function (obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
_typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _toConsumableArray(arr) {
|
||||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
||||
}
|
||||
|
||||
function _arrayWithoutHoles(arr) {
|
||||
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArray(iter) {
|
||||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) {
|
||||
if (!o) return;
|
||||
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
||||
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||||
if (n === "Object" && o.constructor) n = o.constructor.name;
|
||||
if (n === "Map" || n === "Set") return Array.from(o);
|
||||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
||||
}
|
||||
|
||||
function _arrayLikeToArray(arr, len) {
|
||||
if (len == null || len > arr.length) len = arr.length;
|
||||
|
||||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
||||
|
||||
return arr2;
|
||||
}
|
||||
|
||||
function _nonIterableSpread() {
|
||||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
|
||||
function convertToString(content, type) {
|
||||
switch (_typeof(content)) {
|
||||
case 'object':
|
||||
{
|
||||
if (!content) {
|
||||
throw new TypeError('Cannot supply `null`');
|
||||
}
|
||||
|
||||
switch (content.nodeType) {
|
||||
case 1:
|
||||
{
|
||||
// ELEMENT
|
||||
return content.outerHTML;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
// TEXT
|
||||
return content.nodeValue;
|
||||
}
|
||||
|
||||
case 11:
|
||||
{
|
||||
// DOCUMENT_FRAGMENT_NODE
|
||||
return _toConsumableArray(content.childNodes).reduce(function (s, node) {
|
||||
return s + convertToString(node, type);
|
||||
}, '');
|
||||
}
|
||||
|
||||
case undefined:
|
||||
// Array of nodes, QueryResult objects
|
||||
// if (Array.isArray(content)) {
|
||||
if (typeof content.reduce === 'function') {
|
||||
return content.reduce(function (s, node) {
|
||||
return s + convertToString(node, type);
|
||||
}, '');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new TypeError('Bad content for ' + type + '; type: ' + _typeof(content));
|
||||
}
|
||||
}
|
||||
|
||||
function convertToDOM(content, type, avoidClone) {
|
||||
switch (_typeof(content)) {
|
||||
case 'object':
|
||||
{
|
||||
if (!content) {
|
||||
throw new TypeError('Cannot supply `null`');
|
||||
}
|
||||
|
||||
if ([1, // ELEMENT
|
||||
3, // TEXT
|
||||
11 // Document fragment
|
||||
].includes(content.nodeType)) {
|
||||
return avoidClone ? content : content.cloneNode(true);
|
||||
}
|
||||
|
||||
if (typeof content.reduce !== 'function') {
|
||||
throw new TypeError('Unrecognized type of object for conversion to DOM');
|
||||
} // Array of nodes, QueryResult objects
|
||||
|
||||
|
||||
return avoidClone ? content : content.map(function (node) {
|
||||
if (!node || !node.cloneNode) {
|
||||
// Allows for arrays of HTML strings
|
||||
return convertToDOM(node, type, false);
|
||||
}
|
||||
|
||||
return node.cloneNode(true);
|
||||
});
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
var div = document.createElement('div'); // eslint-disable-next-line no-unsanitized/property
|
||||
|
||||
div.innerHTML = content;
|
||||
return div.firstElementChild || div.firstChild;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new TypeError('Bad content for ' + type + '; type: ' + _typeof(content));
|
||||
}
|
||||
}
|
||||
|
||||
function insert(type) {
|
||||
return function () {
|
||||
var _this = this;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var cbOrContent = args[0];
|
||||
|
||||
switch (_typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var ret = cbOrContent.call(_this, i, node.textContent);
|
||||
node[type](ret);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
this.forEach(function (node, i, arr) {
|
||||
node[type].apply(node, _toConsumableArray(args.flatMap(function (content) {
|
||||
return convertToDOM(content, type, i === arr.length - 1);
|
||||
})));
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
function insertText(type) {
|
||||
return function (cbOrContent) {
|
||||
var _this2 = this;
|
||||
|
||||
switch (_typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var ret = cbOrContent.call(_this2, i, node[type]);
|
||||
node[type] = convertToString(ret, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
this.forEach(function (node) {
|
||||
node[type] = convertToString(cbOrContent, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
var after = insert('after');
|
||||
var before = insert('before');
|
||||
var append = insert('append');
|
||||
var prepend = insert('prepend');
|
||||
var html = insertText('innerHTML');
|
||||
var text = insertText('textContent');
|
||||
/*
|
||||
// Todo:
|
||||
export const val = function (valueOrFunc) {
|
||||
|
||||
};
|
||||
*/
|
||||
// Given that these types require a selector engine and
|
||||
// in order to avoid the absence of optimization of `document.querySelectorAll`
|
||||
// for `:first-child` and different behavior in different contexts,
|
||||
// and to avoid making a mutual dependency with query-result,
|
||||
// exports of this type accept a QueryResult instance;
|
||||
// if selected without a second argument, we do default to
|
||||
// `document.querySelectorAll`, however.
|
||||
|
||||
var insertTo = function insertTo(method) {
|
||||
var $ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (sel) {
|
||||
return _toConsumableArray(document.querySelectorAll(sel));
|
||||
};
|
||||
var type = {
|
||||
appendTo: 'append',
|
||||
prependTo: 'prepend',
|
||||
insertAfter: 'after',
|
||||
insertBefore: 'before'
|
||||
}[method] || 'append';
|
||||
return function (target) {
|
||||
var toType = type + 'To';
|
||||
this.forEach(function (node, i, arr) {
|
||||
if (typeof target === 'string' && target.charAt(0) !== '<') {
|
||||
target = $(target);
|
||||
}
|
||||
|
||||
target = Array.isArray(target) ? target : [target];
|
||||
node[type].apply(node, _toConsumableArray(target.flatMap(function (content) {
|
||||
return convertToDOM(content, toType, i === arr.length - 1);
|
||||
})));
|
||||
});
|
||||
return this;
|
||||
};
|
||||
}; // Todo: optional `withDataAndEvents` and `deepWithDataAndEvents` arguments?
|
||||
|
||||
var clone = function clone() {
|
||||
return this.map(function (node) {
|
||||
// Still a QueryResult with such a map
|
||||
return node.cloneNode(true);
|
||||
});
|
||||
};
|
||||
var empty = function empty() {
|
||||
this.forEach(function (node) {
|
||||
node.textContent = '';
|
||||
});
|
||||
};
|
||||
var remove = function remove(selector) {
|
||||
if (selector) {
|
||||
this.forEach(function (node) {
|
||||
if (node.matches(selector)) {
|
||||
// Todo: Use query-result instead?
|
||||
node.remove();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.forEach(function (node) {
|
||||
node.remove();
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
/*
|
||||
// Todo:
|
||||
export const detach = function (selector) {
|
||||
// Should preserve attached data
|
||||
return remove(selector);
|
||||
};
|
||||
*/
|
||||
|
||||
var attr = function attr(attributeNameOrAtts, valueOrCb) {
|
||||
var _this3 = this;
|
||||
|
||||
if (valueOrCb === undefined) {
|
||||
switch (_typeof(attributeNameOrAtts)) {
|
||||
case 'string':
|
||||
{
|
||||
return this[0].hasAttribute(attributeNameOrAtts) ? this[0].getAttribute(attributeNameOrAtts) : undefined;
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (attributeNameOrAtts) {
|
||||
this.forEach(function (node, i) {
|
||||
Object.entries(attributeNameOrAtts).forEach(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
att = _ref2[0],
|
||||
val = _ref2[1];
|
||||
|
||||
node.setAttribute(att, val);
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
{
|
||||
throw new TypeError('Unexpected type for attribute name: ' + _typeof(attributeNameOrAtts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (_typeof(valueOrCb)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var ret = valueOrCb.call(_this3, i, node.getAttribute(valueOrCb));
|
||||
|
||||
if (ret === null) {
|
||||
node.removeAttribute(attributeNameOrAtts);
|
||||
} else {
|
||||
node.setAttribute(attributeNameOrAtts, ret);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
node.setAttribute(attributeNameOrAtts, valueOrCb);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (!valueOrCb) {
|
||||
// `null`
|
||||
return removeAttr.call(this, attributeNameOrAtts);
|
||||
}
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
{
|
||||
throw new TypeError('Unexpected type for attribute name: ' + _typeof(attributeNameOrAtts));
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
var removeAttr = function removeAttr(attributeName) {
|
||||
if (typeof attributeName !== 'string') {
|
||||
throw new TypeError('Unexpected type for attribute name: ' + _typeof(attributeName));
|
||||
}
|
||||
|
||||
this.forEach(function (node) {
|
||||
node.removeAttribute(attributeName);
|
||||
});
|
||||
};
|
||||
|
||||
function classAttManipulation(type) {
|
||||
return function (cbOrContent) {
|
||||
var _this4 = this;
|
||||
|
||||
switch (_typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var _node$classList;
|
||||
|
||||
var ret = cbOrContent.call(_this4, i, node.className);
|
||||
|
||||
(_node$classList = node.classList)[type].apply(_node$classList, _toConsumableArray(ret.split(' ')));
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (type === 'remove' && !cbOrContent) {
|
||||
this.forEach(function (node) {
|
||||
node.className = '';
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
this.forEach(function (node) {
|
||||
var _node$classList2;
|
||||
|
||||
(_node$classList2 = node.classList)[type].apply(_node$classList2, _toConsumableArray(cbOrContent.split(' ')));
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
var addClass = classAttManipulation('add');
|
||||
var removeClass = classAttManipulation('remove');
|
||||
var hasClass = function hasClass(className) {
|
||||
return this.some(function (node) {
|
||||
return node.classList.contains(className);
|
||||
});
|
||||
};
|
||||
var toggleClass = function toggleClass(classNameOrCb, state) {
|
||||
var _this5 = this;
|
||||
|
||||
switch (typeof cbOrContent === "undefined" ? "undefined" : _typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
if (typeof state === 'boolean') {
|
||||
this.forEach(function (node, i) {
|
||||
var _node$classList3;
|
||||
|
||||
var ret = classNameOrCb.call(_this5, i, node.className, state);
|
||||
|
||||
(_node$classList3 = node.classList).toggle.apply(_node$classList3, _toConsumableArray(ret.split(' ')).concat([state]));
|
||||
});
|
||||
} else {
|
||||
this.forEach(function (node, i) {
|
||||
var _node$classList4;
|
||||
|
||||
var ret = classNameOrCb.call(_this5, i, node.className, state);
|
||||
|
||||
(_node$classList4 = node.classList).toggle.apply(_node$classList4, _toConsumableArray(ret.split(' ')));
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
if (typeof state === 'boolean') {
|
||||
this.forEach(function (node) {
|
||||
var _node$classList5;
|
||||
|
||||
(_node$classList5 = node.classList).toggle.apply(_node$classList5, _toConsumableArray(classNameOrCb.split(' ')).concat([state]));
|
||||
});
|
||||
} else {
|
||||
this.forEach(function (node) {
|
||||
var _node$classList6;
|
||||
|
||||
(_node$classList6 = node.classList).toggle.apply(_node$classList6, _toConsumableArray(classNameOrCb.split(' ')));
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
var methods = {
|
||||
after: after,
|
||||
before: before,
|
||||
append: append,
|
||||
prepend: prepend,
|
||||
html: html,
|
||||
text: text,
|
||||
clone: clone,
|
||||
empty: empty,
|
||||
remove: remove,
|
||||
// detach
|
||||
attr: attr,
|
||||
removeAttr: removeAttr,
|
||||
addClass: addClass,
|
||||
hasClass: hasClass,
|
||||
removeClass: removeClass,
|
||||
toggleClass: toggleClass
|
||||
};
|
||||
|
||||
var manipulation = function manipulation($, jml) {
|
||||
['after', 'before', 'append', 'prepend', 'html', 'text', 'clone', 'empty', 'remove', // 'detach'
|
||||
'attr', 'removeAttr', 'addClass', 'hasClass', 'removeClass', 'toggleClass'].forEach(function (method) {
|
||||
$.extend(method, methods[method]);
|
||||
});
|
||||
['appendTo', 'prependTo', 'insertAfter', 'insertBefore'].forEach(function (method) {
|
||||
$.extend(method, insertTo(method, $));
|
||||
});
|
||||
|
||||
if (jml) {
|
||||
$.extend('jml', function () {
|
||||
var _this6 = this;
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
this.forEach(function (node) {
|
||||
while (node.hasChildNodes()) {
|
||||
node.firstChild.remove();
|
||||
}
|
||||
|
||||
var n = jml.apply(void 0, args);
|
||||
return append.call(_this6, n);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return $;
|
||||
};
|
||||
|
||||
export { addClass, after, append, attr, before, clone, empty, hasClass, html, insertTo, manipulation, prepend, remove, removeAttr, removeClass, text, toggleClass };
|
||||
124
dist/external/query-result/esm/index.js
vendored
124
dist/external/query-result/esm/index.js
vendored
@@ -1,124 +0,0 @@
|
||||
/**
|
||||
* ISC License
|
||||
*
|
||||
* Copyright (c) 2018, Andrea Giammarchi, @WebReflection
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
class QueryResult extends Array {}
|
||||
const {create, defineProperty} = Object;
|
||||
const AP = Array.prototype;
|
||||
const DOM_CONTENT_LOADED = 'DOMContentLoaded';
|
||||
const LOAD = 'load';
|
||||
const NO_TRANSPILER_ISSUES = (new QueryResult) instanceof QueryResult;
|
||||
const QRP = QueryResult.prototype;
|
||||
// fixes methods returning non QueryResult
|
||||
/* istanbul ignore if */
|
||||
if (!NO_TRANSPILER_ISSUES)
|
||||
Object.getOwnPropertyNames(AP).forEach(name => {
|
||||
const desc = Object.getOwnPropertyDescriptor(AP, name);
|
||||
if (typeof desc.value === 'function') {
|
||||
const fn = desc.value;
|
||||
desc.value = function () {
|
||||
const result = fn.apply(this, arguments);
|
||||
return result instanceof Array ? patch(result) : result;
|
||||
};
|
||||
}
|
||||
defineProperty(QRP, name, desc);
|
||||
});
|
||||
// fixes badly transpiled classes
|
||||
const patch = NO_TRANSPILER_ISSUES ?
|
||||
qr => qr :
|
||||
/* istanbul ignore next */
|
||||
qr => {
|
||||
const nqr = create(QRP);
|
||||
push.apply(nqr, slice(qr));
|
||||
return nqr;
|
||||
};
|
||||
const push = AP.push;
|
||||
const search = (list, el) => {
|
||||
const nodes = [];
|
||||
const length = list.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
const css = list[i].trim();
|
||||
if (css.slice(-6) === ':first') {
|
||||
const node = el.querySelector(css.slice(0, -6));
|
||||
if (node) push.call(nodes, node);
|
||||
} else
|
||||
push.apply(nodes, slice(el.querySelectorAll(css)));
|
||||
}
|
||||
return new QueryResult(...nodes);
|
||||
};
|
||||
const slice = NO_TRANSPILER_ISSUES ?
|
||||
patch :
|
||||
/* istanbul ignore next */
|
||||
all => {
|
||||
// do not use slice.call(...) due old IE gotcha
|
||||
const nodes = [];
|
||||
const length = all.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
nodes[i] = all[i];
|
||||
return nodes;
|
||||
}
|
||||
// use function to avoid usage of Symbol.hasInstance
|
||||
// (broken in older browsers anyway)
|
||||
const $ = function $(CSS, parent = document) {
|
||||
switch (typeof CSS) {
|
||||
case 'string': return patch(search(CSS.split(','), parent));
|
||||
case 'object':
|
||||
// needed to avoid iterator dance (breaks in older IEs)
|
||||
const nodes = [];
|
||||
const all = ('nodeType' in CSS || 'postMessage' in CSS) ? [CSS] : CSS;
|
||||
push.apply(nodes, slice(all));
|
||||
return patch(new QueryResult(...nodes));
|
||||
case 'function':
|
||||
const $parent = $(parent);
|
||||
const $window = $(parent.defaultView);
|
||||
const handler = {handleEvent(event) {
|
||||
$parent.off(DOM_CONTENT_LOADED, handler);
|
||||
$window.off(LOAD, handler);
|
||||
CSS(event);
|
||||
}};
|
||||
$parent.on(DOM_CONTENT_LOADED, handler);
|
||||
$window.on(LOAD, handler);
|
||||
const rs = parent.readyState;
|
||||
if (rs == 'complete' || (rs != 'loading' && !parent.documentElement.doScroll))
|
||||
setTimeout(() => $parent.dispatch(DOM_CONTENT_LOADED));
|
||||
return $;
|
||||
}
|
||||
};
|
||||
$.prototype = QRP;
|
||||
$.extend = (key, value) =>
|
||||
(defineProperty(QRP, key, {configurable: true, value}), $);
|
||||
// dropped usage of for-of to avoid broken iteration dance in older IEs
|
||||
$.extend('dispatch', function dispatch(type, init = {}) {
|
||||
const event = new CustomEvent(type, init);
|
||||
const length = this.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
this[i].dispatchEvent(event);
|
||||
return this;
|
||||
})
|
||||
.extend('off', function off(type, handler, options = false) {
|
||||
const length = this.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
this[i].removeEventListener(type, handler, options);
|
||||
return this;
|
||||
})
|
||||
.extend('on', function on(type, handler, options = false) {
|
||||
const length = this.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
this[i].addEventListener(type, handler, options);
|
||||
return this;
|
||||
});
|
||||
|
||||
export default $;
|
||||
580
dist/external/stackblur-canvas/dist/stackblur-es.js
vendored
580
dist/external/stackblur-canvas/dist/stackblur-es.js
vendored
@@ -1,580 +0,0 @@
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function (obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
_typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable no-bitwise, unicorn/prefer-query-selector */
|
||||
|
||||
/**
|
||||
* StackBlur - a fast almost Gaussian Blur For Canvas
|
||||
*
|
||||
* In case you find this class useful - especially in commercial projects -
|
||||
* I am not totally unhappy for a small donation to my PayPal account
|
||||
* mario@quasimondo.de
|
||||
*
|
||||
* Or support me on flattr:
|
||||
* {@link https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript}.
|
||||
*
|
||||
* @module StackBlur
|
||||
* @author Mario Klingemann
|
||||
* Contact: mario@quasimondo.com
|
||||
* Website: {@link http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html}
|
||||
* Twitter: @quasimondo
|
||||
*
|
||||
* @copyright (c) 2010 Mario Klingemann
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-len */
|
||||
var mulTable = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259];
|
||||
var shgTable = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24];
|
||||
/* eslint-enable max-len */
|
||||
|
||||
/**
|
||||
* @param {string|HTMLImageElement} img
|
||||
* @param {string|HTMLCanvasElement} canvas
|
||||
* @param {Float} radius
|
||||
* @param {boolean} blurAlphaChannel
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function processImage(img, canvas, radius, blurAlphaChannel) {
|
||||
if (typeof img === 'string') {
|
||||
img = document.getElementById(img);
|
||||
}
|
||||
|
||||
if (!img || !('naturalWidth' in img)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var w = img.naturalWidth;
|
||||
var h = img.naturalHeight;
|
||||
|
||||
if (typeof canvas === 'string') {
|
||||
canvas = document.getElementById(canvas);
|
||||
}
|
||||
|
||||
if (!canvas || !('getContext' in canvas)) {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
var context = canvas.getContext('2d');
|
||||
context.clearRect(0, 0, w, h);
|
||||
context.drawImage(img, 0, 0);
|
||||
|
||||
if (isNaN(radius) || radius < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (blurAlphaChannel) {
|
||||
processCanvasRGBA(canvas, 0, 0, w, h, radius);
|
||||
} else {
|
||||
processCanvasRGB(canvas, 0, 0, w, h, radius);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {string|HTMLCanvasElement} canvas
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @throws {Error|TypeError}
|
||||
* @returns {ImageData} See {@link https://html.spec.whatwg.org/multipage/canvas.html#imagedata}
|
||||
*/
|
||||
|
||||
|
||||
function getImageDataFromCanvas(canvas, topX, topY, width, height) {
|
||||
if (typeof canvas === 'string') {
|
||||
canvas = document.getElementById(canvas);
|
||||
}
|
||||
|
||||
if (!canvas || _typeof(canvas) !== 'object' || !('getContext' in canvas)) {
|
||||
throw new TypeError('Expecting canvas with `getContext` method ' + 'in processCanvasRGB(A) calls!');
|
||||
}
|
||||
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
try {
|
||||
return context.getImageData(topX, topY, width, height);
|
||||
} catch (e) {
|
||||
throw new Error('unable to access image data: ' + e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {HTMLCanvasElement} canvas
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function processCanvasRGBA(canvas, topX, topY, width, height, radius) {
|
||||
if (isNaN(radius) || radius < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
radius |= 0;
|
||||
var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);
|
||||
imageData = processImageDataRGBA(imageData, topX, topY, width, height, radius);
|
||||
canvas.getContext('2d').putImageData(imageData, topX, topY);
|
||||
}
|
||||
/**
|
||||
* @param {ImageData} imageData
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {ImageData}
|
||||
*/
|
||||
|
||||
|
||||
function processImageDataRGBA(imageData, topX, topY, width, height, radius) {
|
||||
var pixels = imageData.data;
|
||||
var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, aSum, rOutSum, gOutSum, bOutSum, aOutSum, rInSum, gInSum, bInSum, aInSum, pr, pg, pb, pa, rbs;
|
||||
var div = 2 * radius + 1; // const w4 = width << 2;
|
||||
|
||||
var widthMinus1 = width - 1;
|
||||
var heightMinus1 = height - 1;
|
||||
var radiusPlus1 = radius + 1;
|
||||
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
|
||||
var stackStart = new BlurStack();
|
||||
var stack = stackStart;
|
||||
var stackEnd;
|
||||
|
||||
for (i = 1; i < div; i++) {
|
||||
stack = stack.next = new BlurStack();
|
||||
|
||||
if (i === radiusPlus1) {
|
||||
stackEnd = stack;
|
||||
}
|
||||
}
|
||||
|
||||
stack.next = stackStart;
|
||||
var stackIn = null;
|
||||
var stackOut = null;
|
||||
yw = yi = 0;
|
||||
var mulSum = mulTable[radius];
|
||||
var shgSum = shgTable[radius];
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
rInSum = gInSum = bInSum = aInSum = rSum = gSum = bSum = aSum = 0;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
aOutSum = radiusPlus1 * (pa = pixels[yi + 3]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
aSum += sumFactor * pa;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack.a = pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
for (i = 1; i < radiusPlus1; i++) {
|
||||
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
||||
rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[p + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[p + 2]) * rbs;
|
||||
aSum += (stack.a = pa = pixels[p + 3]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
aInSum += pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
pixels[yi + 3] = pa = aSum * mulSum >> shgSum;
|
||||
|
||||
if (pa !== 0) {
|
||||
pa = 255 / pa;
|
||||
pixels[yi] = (rSum * mulSum >> shgSum) * pa;
|
||||
pixels[yi + 1] = (gSum * mulSum >> shgSum) * pa;
|
||||
pixels[yi + 2] = (bSum * mulSum >> shgSum) * pa;
|
||||
} else {
|
||||
pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
|
||||
}
|
||||
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
aSum -= aOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
aOutSum -= stackIn.a;
|
||||
p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;
|
||||
rInSum += stackIn.r = pixels[p];
|
||||
gInSum += stackIn.g = pixels[p + 1];
|
||||
bInSum += stackIn.b = pixels[p + 2];
|
||||
aInSum += stackIn.a = pixels[p + 3];
|
||||
rSum += rInSum;
|
||||
gSum += gInSum;
|
||||
bSum += bInSum;
|
||||
aSum += aInSum;
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
aOutSum += pa = stackOut.a;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
aInSum -= pa;
|
||||
stackOut = stackOut.next;
|
||||
yi += 4;
|
||||
}
|
||||
|
||||
yw += width;
|
||||
}
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
gInSum = bInSum = aInSum = rInSum = gSum = bSum = aSum = rSum = 0;
|
||||
yi = x << 2;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
aOutSum = radiusPlus1 * (pa = pixels[yi + 3]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
aSum += sumFactor * pa;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack.a = pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
yp = width;
|
||||
|
||||
for (i = 1; i <= radius; i++) {
|
||||
yi = yp + x << 2;
|
||||
rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[yi + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[yi + 2]) * rbs;
|
||||
aSum += (stack.a = pa = pixels[yi + 3]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
aInSum += pa;
|
||||
stack = stack.next;
|
||||
|
||||
if (i < heightMinus1) {
|
||||
yp += width;
|
||||
}
|
||||
}
|
||||
|
||||
yi = x;
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
p = yi << 2;
|
||||
pixels[p + 3] = pa = aSum * mulSum >> shgSum;
|
||||
|
||||
if (pa > 0) {
|
||||
pa = 255 / pa;
|
||||
pixels[p] = (rSum * mulSum >> shgSum) * pa;
|
||||
pixels[p + 1] = (gSum * mulSum >> shgSum) * pa;
|
||||
pixels[p + 2] = (bSum * mulSum >> shgSum) * pa;
|
||||
} else {
|
||||
pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
|
||||
}
|
||||
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
aSum -= aOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
aOutSum -= stackIn.a;
|
||||
p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;
|
||||
rSum += rInSum += stackIn.r = pixels[p];
|
||||
gSum += gInSum += stackIn.g = pixels[p + 1];
|
||||
bSum += bInSum += stackIn.b = pixels[p + 2];
|
||||
aSum += aInSum += stackIn.a = pixels[p + 3];
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
aOutSum += pa = stackOut.a;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
aInSum -= pa;
|
||||
stackOut = stackOut.next;
|
||||
yi += width;
|
||||
}
|
||||
}
|
||||
|
||||
return imageData;
|
||||
}
|
||||
/**
|
||||
* @param {HTMLCanvasElement} canvas
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function processCanvasRGB(canvas, topX, topY, width, height, radius) {
|
||||
if (isNaN(radius) || radius < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
radius |= 0;
|
||||
var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);
|
||||
imageData = processImageDataRGB(imageData, topX, topY, width, height, radius);
|
||||
canvas.getContext('2d').putImageData(imageData, topX, topY);
|
||||
}
|
||||
/**
|
||||
* @param {ImageData} imageData
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {ImageData}
|
||||
*/
|
||||
|
||||
|
||||
function processImageDataRGB(imageData, topX, topY, width, height, radius) {
|
||||
var pixels = imageData.data;
|
||||
var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, rOutSum, gOutSum, bOutSum, rInSum, gInSum, bInSum, pr, pg, pb, rbs;
|
||||
var div = 2 * radius + 1; // const w4 = width << 2;
|
||||
|
||||
var widthMinus1 = width - 1;
|
||||
var heightMinus1 = height - 1;
|
||||
var radiusPlus1 = radius + 1;
|
||||
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
|
||||
var stackStart = new BlurStack();
|
||||
var stack = stackStart;
|
||||
var stackEnd;
|
||||
|
||||
for (i = 1; i < div; i++) {
|
||||
stack = stack.next = new BlurStack();
|
||||
|
||||
if (i === radiusPlus1) {
|
||||
stackEnd = stack;
|
||||
}
|
||||
}
|
||||
|
||||
stack.next = stackStart;
|
||||
var stackIn = null;
|
||||
var stackOut = null;
|
||||
yw = yi = 0;
|
||||
var mulSum = mulTable[radius];
|
||||
var shgSum = shgTable[radius];
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
rInSum = gInSum = bInSum = rSum = gSum = bSum = 0;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
for (i = 1; i < radiusPlus1; i++) {
|
||||
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
||||
rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[p + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[p + 2]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
pixels[yi] = rSum * mulSum >> shgSum;
|
||||
pixels[yi + 1] = gSum * mulSum >> shgSum;
|
||||
pixels[yi + 2] = bSum * mulSum >> shgSum;
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;
|
||||
rInSum += stackIn.r = pixels[p];
|
||||
gInSum += stackIn.g = pixels[p + 1];
|
||||
bInSum += stackIn.b = pixels[p + 2];
|
||||
rSum += rInSum;
|
||||
gSum += gInSum;
|
||||
bSum += bInSum;
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
stackOut = stackOut.next;
|
||||
yi += 4;
|
||||
}
|
||||
|
||||
yw += width;
|
||||
}
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
gInSum = bInSum = rInSum = gSum = bSum = rSum = 0;
|
||||
yi = x << 2;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
yp = width;
|
||||
|
||||
for (i = 1; i <= radius; i++) {
|
||||
yi = yp + x << 2;
|
||||
rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[yi + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[yi + 2]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
stack = stack.next;
|
||||
|
||||
if (i < heightMinus1) {
|
||||
yp += width;
|
||||
}
|
||||
}
|
||||
|
||||
yi = x;
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
p = yi << 2;
|
||||
pixels[p] = rSum * mulSum >> shgSum;
|
||||
pixels[p + 1] = gSum * mulSum >> shgSum;
|
||||
pixels[p + 2] = bSum * mulSum >> shgSum;
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;
|
||||
rSum += rInSum += stackIn.r = pixels[p];
|
||||
gSum += gInSum += stackIn.g = pixels[p + 1];
|
||||
bSum += bInSum += stackIn.b = pixels[p + 2];
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
stackOut = stackOut.next;
|
||||
yi += width;
|
||||
}
|
||||
}
|
||||
|
||||
return imageData;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
var BlurStack =
|
||||
/**
|
||||
* Set properties.
|
||||
*/
|
||||
function BlurStack() {
|
||||
_classCallCheck(this, BlurStack);
|
||||
|
||||
this.r = 0;
|
||||
this.g = 0;
|
||||
this.b = 0;
|
||||
this.a = 0;
|
||||
this.next = null;
|
||||
};
|
||||
|
||||
export { BlurStack, processCanvasRGB as canvasRGB, processCanvasRGBA as canvasRGBA, processImage as image, processImageDataRGB as imageDataRGB, processImageDataRGBA as imageDataRGBA };
|
||||
Reference in New Issue
Block a user