@pluginjs/i18n
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -1,526 +0,7 @@ | ||
import $ from 'jquery'; | ||
import { deepMerge, getValueByPath } from '@pluginjs/utils'; | ||
import template from '@pluginjs/template'; | ||
/* eslint no-undef: "off" */ | ||
/* Credit to http://featurejs.com MIT */ | ||
/** | ||
* Test if it's an old device that we want to filter out | ||
*/ | ||
/** | ||
* Function that takes a standard CSS property name as a parameter and | ||
* returns it's prefixed version valid for current browser it runs in | ||
*/ | ||
const pfx = function () { | ||
const prefixes = ['Webkit', 'Moz', 'O', 'ms']; | ||
const memory = {}; | ||
const style = document.createElement('dummy').style; | ||
return function (prop) { | ||
if (typeof memory[prop] === 'undefined') { | ||
const ucProp = prop.charAt(0).toUpperCase() + prop.substr(1); | ||
const props = `${prop} ${prefixes.join(`${ucProp} `)}${ucProp}`.split(' '); | ||
memory[prop] = null; | ||
for (const i in props) { | ||
if (style[props[i]] !== undefined) { | ||
memory[prop] = props[i]; | ||
break; | ||
} | ||
} | ||
} | ||
return memory[prop]; | ||
}; | ||
}(); | ||
const transitionEndEvent = () => { | ||
const eventNames = { | ||
transition: 'transitionend', | ||
OTransition: 'oTransitionEnd', | ||
MozTransition: 'transitionend', | ||
WebkitTransition: 'webkitTransitionEnd' | ||
}; | ||
const style = document.createElement('dummy').style; | ||
for (const i in eventNames) { | ||
if (eventNames.hasOwnProperty(i)) { | ||
if (style[i] !== undefined) { | ||
return eventNames[i]; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
/* Credit to https://github.com/jonschlinkert/get-value MIT */ | ||
function getValueByPath(obj, path) { | ||
if (Object(obj) !== obj || typeof path === 'undefined') { | ||
return obj; | ||
} | ||
if (path in obj) { | ||
return obj[path]; | ||
} | ||
const segs = path.split('.'); | ||
const length = segs.length; | ||
if (!length) { | ||
return undefined; | ||
} | ||
let i = -1; | ||
while (obj && ++i < length) { | ||
let key = segs[i]; | ||
while (key[key.length - 1] === '\\') { | ||
key = `${key.slice(0, -1)}.${segs[++i]}`; | ||
} | ||
obj = obj[key]; | ||
} | ||
return obj; | ||
} | ||
const asTransitionEnd = 'asTransitionEnd'; | ||
function triggerTransitionEnd(element) { | ||
$(element).trigger(transitionEndEvent()); | ||
} | ||
function setTransitionEndSupport() { | ||
$.fn.asTransitionEnd = function (duration) { | ||
let called = false; | ||
$(this).one(asTransitionEnd, () => { | ||
called = true; | ||
}); | ||
setTimeout(() => { | ||
if (!called) { | ||
triggerTransitionEnd(this); | ||
} | ||
}, duration); | ||
return this; | ||
}; | ||
const isTransitionEndEvent = transitionEndEvent(); | ||
if (isTransitionEndEvent) { | ||
// suport transition end | ||
$.event.special[asTransitionEnd] = { | ||
bindType: isTransitionEndEvent, | ||
delegateType: isTransitionEndEvent, | ||
handle(event) { | ||
if ($(event.target).is(this)) { | ||
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
} | ||
return undefined; | ||
} | ||
}; | ||
} | ||
} | ||
setTransitionEndSupport(); | ||
/* eslint no-undef: "off" */ | ||
/* Credit to http://featurejs.com MIT */ | ||
/** | ||
* Test if it's an old device that we want to filter out | ||
*/ | ||
/** | ||
* Function that takes a standard CSS property name as a parameter and | ||
* returns it's prefixed version valid for current browser it runs in | ||
*/ | ||
const pfx$1 = function () { | ||
const prefixes = ['Webkit', 'Moz', 'O', 'ms']; | ||
const memory = {}; | ||
const style = document.createElement('dummy').style; | ||
return function (prop) { | ||
if (typeof memory[prop] === 'undefined') { | ||
const ucProp = prop.charAt(0).toUpperCase() + prop.substr(1); | ||
const props = `${prop} ${prefixes.join(`${ucProp} `)}${ucProp}`.split(' '); | ||
memory[prop] = null; | ||
for (const i in props) { | ||
if (style[props[i]] !== undefined) { | ||
memory[prop] = props[i]; | ||
break; | ||
} | ||
} | ||
} | ||
return memory[prop]; | ||
}; | ||
}(); | ||
const transitionEndEvent$1 = () => { | ||
const eventNames = { | ||
transition: 'transitionend', | ||
OTransition: 'oTransitionEnd', | ||
MozTransition: 'transitionend', | ||
WebkitTransition: 'webkitTransitionEnd' | ||
}; | ||
const style = document.createElement('dummy').style; | ||
for (const i in eventNames) { | ||
if (eventNames.hasOwnProperty(i)) { | ||
if (style[i] !== undefined) { | ||
return eventNames[i]; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
var asyncGenerator$1 = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
/* Credit to https://github.com/jonschlinkert/get-value MIT */ | ||
function getValueByPath$1(obj, path) { | ||
if (Object(obj) !== obj || typeof path === 'undefined') { | ||
return obj; | ||
} | ||
if (path in obj) { | ||
return obj[path]; | ||
} | ||
const segs = path.split('.'); | ||
const length = segs.length; | ||
if (!length) { | ||
return undefined; | ||
} | ||
let i = -1; | ||
while (obj && ++i < length) { | ||
let key = segs[i]; | ||
while (key[key.length - 1] === '\\') { | ||
key = `${key.slice(0, -1)}.${segs[++i]}`; | ||
} | ||
obj = obj[key]; | ||
} | ||
return obj; | ||
} | ||
const asTransitionEnd$1 = 'asTransitionEnd'; | ||
function triggerTransitionEnd$1(element) { | ||
$(element).trigger(transitionEndEvent$1()); | ||
} | ||
function setTransitionEndSupport$1() { | ||
$.fn.asTransitionEnd = function (duration) { | ||
let called = false; | ||
$(this).one(asTransitionEnd$1, () => { | ||
called = true; | ||
}); | ||
setTimeout(() => { | ||
if (!called) { | ||
triggerTransitionEnd$1(this); | ||
} | ||
}, duration); | ||
return this; | ||
}; | ||
const isTransitionEndEvent = transitionEndEvent$1(); | ||
if (isTransitionEndEvent) { | ||
// suport transition end | ||
$.event.special[asTransitionEnd$1] = { | ||
bindType: isTransitionEndEvent, | ||
delegateType: isTransitionEndEvent, | ||
handle(event) { | ||
if ($(event.target).is(this)) { | ||
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
} | ||
return undefined; | ||
} | ||
}; | ||
} | ||
} | ||
setTransitionEndSupport$1(); | ||
/* Credit to https://github.com/Matt-Esch/string-template MIT */ | ||
const template = function () { | ||
const pattern = /\{\s*([.0-9a-zA-Z_]+)\s*\}/g; | ||
function render(string, ...args) { | ||
if (args.length === 1 && typeof args[0] === 'object') { | ||
args = args[0]; | ||
} | ||
if (!args || !args.hasOwnProperty) { | ||
args = {}; | ||
} | ||
return string.replace(pattern, (match, i, index) => { | ||
let result = null; | ||
if (string[index - 1] === '{' && string[index + match.length] === '}') { | ||
return i; | ||
} | ||
if (args.hasOwnProperty(i)) { | ||
result = args[i]; | ||
} else if (i.indexOf('.') !== -1) { | ||
result = getValueByPath$1(args, i); | ||
} | ||
if (result === null || result === undefined) { | ||
return ''; | ||
} | ||
return result; | ||
}); | ||
} | ||
return { | ||
render, | ||
compile(str) { | ||
return function (...args) { | ||
return render(str, ...args); | ||
}; | ||
}, | ||
parse(str) { | ||
const matches = str.match(pattern); | ||
if (matches === null) { | ||
return false; | ||
} | ||
const parsed = []; | ||
for (let i = 0; i < matches.length; i++) { | ||
if (!matches[i].match(/^\{\{.+\}\}$/g)) { | ||
parsed.push(matches[i].substring(1, matches[i].length - 1).trim()); | ||
} | ||
} | ||
return parsed; | ||
} | ||
}; | ||
}(); | ||
let I18N = class I18N { | ||
constructor(defaults, translations) { | ||
this.defaults = $.extend(true, {}, I18N.defaults, defaults); | ||
this.defaults = deepMerge({}, I18N.defaults, defaults); | ||
@@ -536,3 +17,3 @@ this.translations = translations ? translations : {}; | ||
if (this.translations[locale]) { | ||
$.extend(this.translations[locale], translation); | ||
Object.assign(this.translations[locale], translation); | ||
} else { | ||
@@ -553,3 +34,3 @@ this.translations[locale] = translation; | ||
const _options = $.extend({}, that.defaults, options); | ||
const _options = Object.assign({}, that.defaults, options); | ||
let _locale = _options.locale; | ||
@@ -556,0 +37,0 @@ |
562
dist/i18n.js
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) : | ||
(factory((global['@pluginjs/i18n'] = {}),global.jQuery)); | ||
}(this, (function (exports,$) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@pluginjs/utils'), require('@pluginjs/template')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@pluginjs/utils', '@pluginjs/template'], factory) : | ||
(factory((global['@pluginjs/i18n'] = {}),global['@pluginjs/utils'],global['@pluginjs/template'])); | ||
}(this, (function (exports,utils,template) { 'use strict'; | ||
$ = $ && $.hasOwnProperty('default') ? $['default'] : $; | ||
template = template && template.hasOwnProperty('default') ? template['default'] : template; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
var asyncGenerator$1 = function () { | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
@@ -160,534 +150,2 @@ this.value = value; | ||
/* eslint no-undef: "off" */ | ||
/* Credit to http://featurejs.com MIT */ | ||
/** | ||
* Test if it's an old device that we want to filter out | ||
*/ | ||
/** | ||
* Function that takes a standard CSS property name as a parameter and | ||
* returns it's prefixed version valid for current browser it runs in | ||
*/ | ||
var pfx = function () { | ||
var prefixes = ['Webkit', 'Moz', 'O', 'ms']; | ||
var memory = {}; | ||
var style = document.createElement('dummy').style; | ||
return function (prop) { | ||
if (typeof memory[prop] === 'undefined') { | ||
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1); | ||
var props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); | ||
memory[prop] = null; | ||
for (var i in props) { | ||
if (style[props[i]] !== undefined) { | ||
memory[prop] = props[i]; | ||
break; | ||
} | ||
} | ||
} | ||
return memory[prop]; | ||
}; | ||
}(); | ||
var transitionEndEvent = function transitionEndEvent() { | ||
var eventNames = { | ||
transition: 'transitionend', | ||
OTransition: 'oTransitionEnd', | ||
MozTransition: 'transitionend', | ||
WebkitTransition: 'webkitTransitionEnd' | ||
}; | ||
var style = document.createElement('dummy').style; | ||
for (var i in eventNames) { | ||
if (eventNames.hasOwnProperty(i)) { | ||
if (style[i] !== undefined) { | ||
return eventNames[i]; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function wrap(fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function _await(value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
/* Credit to https://github.com/jonschlinkert/get-value MIT */ | ||
function getValueByPath(obj, path) { | ||
if (Object(obj) !== obj || typeof path === 'undefined') { | ||
return obj; | ||
} | ||
if (path in obj) { | ||
return obj[path]; | ||
} | ||
var segs = path.split('.'); | ||
var length = segs.length; | ||
if (!length) { | ||
return undefined; | ||
} | ||
var i = -1; | ||
while (obj && ++i < length) { | ||
var key = segs[i]; | ||
while (key[key.length - 1] === '\\') { | ||
key = key.slice(0, -1) + '.' + segs[++i]; | ||
} | ||
obj = obj[key]; | ||
} | ||
return obj; | ||
} | ||
var asTransitionEnd = 'asTransitionEnd'; | ||
function triggerTransitionEnd(element) { | ||
$(element).trigger(transitionEndEvent()); | ||
} | ||
function setTransitionEndSupport() { | ||
$.fn.asTransitionEnd = function (duration) { | ||
var _this3 = this; | ||
var called = false; | ||
$(this).one(asTransitionEnd, function () { | ||
called = true; | ||
}); | ||
setTimeout(function () { | ||
if (!called) { | ||
triggerTransitionEnd(_this3); | ||
} | ||
}, duration); | ||
return this; | ||
}; | ||
var isTransitionEndEvent = transitionEndEvent(); | ||
if (isTransitionEndEvent) { | ||
// suport transition end | ||
$.event.special[asTransitionEnd] = { | ||
bindType: isTransitionEndEvent, | ||
delegateType: isTransitionEndEvent, | ||
handle: function handle(event) { | ||
if ($(event.target).is(this)) { | ||
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
} | ||
return undefined; | ||
} | ||
}; | ||
} | ||
} | ||
setTransitionEndSupport(); | ||
/* eslint no-undef: "off" */ | ||
/* Credit to http://featurejs.com MIT */ | ||
/** | ||
* Test if it's an old device that we want to filter out | ||
*/ | ||
/** | ||
* Function that takes a standard CSS property name as a parameter and | ||
* returns it's prefixed version valid for current browser it runs in | ||
*/ | ||
var pfx$1 = function () { | ||
var prefixes = ['Webkit', 'Moz', 'O', 'ms']; | ||
var memory = {}; | ||
var style = document.createElement('dummy').style; | ||
return function (prop) { | ||
if (typeof memory[prop] === 'undefined') { | ||
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1); | ||
var props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); | ||
memory[prop] = null; | ||
for (var i in props) { | ||
if (style[props[i]] !== undefined) { | ||
memory[prop] = props[i]; | ||
break; | ||
} | ||
} | ||
} | ||
return memory[prop]; | ||
}; | ||
}(); | ||
var transitionEndEvent$1 = function transitionEndEvent() { | ||
var eventNames = { | ||
transition: 'transitionend', | ||
OTransition: 'oTransitionEnd', | ||
MozTransition: 'transitionend', | ||
WebkitTransition: 'webkitTransitionEnd' | ||
}; | ||
var style = document.createElement('dummy').style; | ||
for (var i in eventNames) { | ||
if (eventNames.hasOwnProperty(i)) { | ||
if (style[i] !== undefined) { | ||
return eventNames[i]; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
var asyncGenerator$2 = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function wrap(fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function _await(value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
/* Credit to https://github.com/jonschlinkert/get-value MIT */ | ||
function getValueByPath$1(obj, path) { | ||
if (Object(obj) !== obj || typeof path === 'undefined') { | ||
return obj; | ||
} | ||
if (path in obj) { | ||
return obj[path]; | ||
} | ||
var segs = path.split('.'); | ||
var length = segs.length; | ||
if (!length) { | ||
return undefined; | ||
} | ||
var i = -1; | ||
while (obj && ++i < length) { | ||
var key = segs[i]; | ||
while (key[key.length - 1] === '\\') { | ||
key = key.slice(0, -1) + '.' + segs[++i]; | ||
} | ||
obj = obj[key]; | ||
} | ||
return obj; | ||
} | ||
var asTransitionEnd$1 = 'asTransitionEnd'; | ||
function triggerTransitionEnd$1(element) { | ||
$(element).trigger(transitionEndEvent$1()); | ||
} | ||
function setTransitionEndSupport$1() { | ||
$.fn.asTransitionEnd = function (duration) { | ||
var _this = this; | ||
var called = false; | ||
$(this).one(asTransitionEnd$1, function () { | ||
called = true; | ||
}); | ||
setTimeout(function () { | ||
if (!called) { | ||
triggerTransitionEnd$1(_this); | ||
} | ||
}, duration); | ||
return this; | ||
}; | ||
var isTransitionEndEvent = transitionEndEvent$1(); | ||
if (isTransitionEndEvent) { | ||
// suport transition end | ||
$.event.special[asTransitionEnd$1] = { | ||
bindType: isTransitionEndEvent, | ||
delegateType: isTransitionEndEvent, | ||
handle: function handle(event) { | ||
if ($(event.target).is(this)) { | ||
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
} | ||
return undefined; | ||
} | ||
}; | ||
} | ||
} | ||
setTransitionEndSupport$1(); | ||
/* Credit to https://github.com/Matt-Esch/string-template MIT */ | ||
var template = function () { | ||
var pattern = /\{\s*([.0-9a-zA-Z_]+)\s*\}/g; | ||
function render(string) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
if (args.length === 1 && _typeof(args[0]) === 'object') { | ||
args = args[0]; | ||
} | ||
if (!args || !args.hasOwnProperty) { | ||
args = {}; | ||
} | ||
return string.replace(pattern, function (match, i, index) { | ||
var result = null; | ||
if (string[index - 1] === '{' && string[index + match.length] === '}') { | ||
return i; | ||
} | ||
if (args.hasOwnProperty(i)) { | ||
result = args[i]; | ||
} else if (i.indexOf('.') !== -1) { | ||
result = getValueByPath$1(args, i); | ||
} | ||
if (result === null || result === undefined) { | ||
return ''; | ||
} | ||
return result; | ||
}); | ||
} | ||
return { | ||
render: render, | ||
compile: function compile(str) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return render.apply(undefined, [str].concat(args)); | ||
}; | ||
}, | ||
parse: function parse(str) { | ||
var matches = str.match(pattern); | ||
if (matches === null) { | ||
return false; | ||
} | ||
var parsed = []; | ||
for (var i = 0; i < matches.length; i++) { | ||
if (!matches[i].match(/^\{\{.+\}\}$/g)) { | ||
parsed.push(matches[i].substring(1, matches[i].length - 1).trim()); | ||
} | ||
} | ||
return parsed; | ||
} | ||
}; | ||
}(); | ||
var I18N = function () { | ||
@@ -697,3 +155,3 @@ function I18N(defaults$$1, translations) { | ||
this.defaults = $.extend(true, {}, I18N.defaults, defaults$$1); | ||
this.defaults = utils.deepMerge({}, I18N.defaults, defaults$$1); | ||
@@ -712,3 +170,3 @@ this.translations = translations ? translations : {}; | ||
if (this.translations[locale]) { | ||
$.extend(this.translations[locale], translation); | ||
Object.assign(this.translations[locale], translation); | ||
} else { | ||
@@ -733,3 +191,3 @@ this.translations[locale] = translation; | ||
var _options = $.extend({}, that.defaults, options); | ||
var _options = Object.assign({}, that.defaults, options); | ||
var _locale = _options.locale; | ||
@@ -739,3 +197,3 @@ | ||
var translation = that.getTranslation(locale); | ||
var message = getValueByPath(translation, key); | ||
var message = utils.getValueByPath(translation, key); | ||
@@ -742,0 +200,0 @@ return message; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jquery")):"function"==typeof define&&define.amd?define(["exports","jquery"],t):t(n["@pluginjs/i18n"]={},n.jQuery)}(this,function(n,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},r=(function(){function n(n){this.value=n}function t(t){function e(o,i){try{var a=t[o](i),u=a.value;u instanceof n?Promise.resolve(u.value).then(function(n){e("next",n)},function(n){e("throw",n)}):r(a.done?"return":"normal",a.value)}catch(n){r("throw",n)}}function r(n,t){switch(n){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?e(o.key,o.arg):i=null}var o,i;this._invoke=function(n,t){return new Promise(function(r,a){var u={key:n,arg:t,resolve:r,reject:a,next:null};i?i=i.next=u:(o=i=u,e(n,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(n){return this._invoke("next",n)},t.prototype.throw=function(n){return this._invoke("throw",n)},t.prototype.return=function(n){return this._invoke("return",n)}}(),function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}),o=function(){function n(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}}(),i=(function(){var n=["Webkit","Moz","O","ms"],t={},e=document.createElement("dummy").style}(),function(){var n={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},t=document.createElement("dummy").style;for(var e in n)if(n.hasOwnProperty(e)&&void 0!==t[e])return n[e];return!1}),a=(function(){function n(n){this.value=n}function t(t){function e(o,i){try{var a=t[o](i),u=a.value;u instanceof n?Promise.resolve(u.value).then(function(n){e("next",n)},function(n){e("throw",n)}):r(a.done?"return":"normal",a.value)}catch(n){r("throw",n)}}function r(n,t){switch(n){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?e(o.key,o.arg):i=null}var o,i;this._invoke=function(n,t){return new Promise(function(r,a){var u={key:n,arg:t,resolve:r,reject:a,next:null};i?i=i.next=u:(o=i=u,e(n,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(n){return this._invoke("next",n)},t.prototype.throw=function(n){return this._invoke("throw",n)},t.prototype.return=function(n){return this._invoke("return",n)}}(),"asTransitionEnd");!function(){t.fn.asTransitionEnd=function(n){var e=this,r=!1;return t(this).one(a,function(){r=!0}),setTimeout(function(){r||function(n){t(n).trigger(i())}(e)},n),this};var n=i();n&&(t.event.special[a]={bindType:n,delegateType:n,handle:function(n){if(t(n.target).is(this))return n.handleObj.handler.apply(this,arguments)}})}();!function(){var n=["Webkit","Moz","O","ms"],t={},e=document.createElement("dummy").style}();var u=function(){var n={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},t=document.createElement("dummy").style;for(var e in n)if(n.hasOwnProperty(e)&&void 0!==t[e])return n[e];return!1},s=(function(){function n(n){this.value=n}function t(t){function e(o,i){try{var a=t[o](i),u=a.value;u instanceof n?Promise.resolve(u.value).then(function(n){e("next",n)},function(n){e("throw",n)}):r(a.done?"return":"normal",a.value)}catch(n){r("throw",n)}}function r(n,t){switch(n){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?e(o.key,o.arg):i=null}var o,i;this._invoke=function(n,t){return new Promise(function(r,a){var u={key:n,arg:t,resolve:r,reject:a,next:null};i?i=i.next=u:(o=i=u,e(n,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(n){return this._invoke("next",n)},t.prototype.throw=function(n){return this._invoke("throw",n)},t.prototype.return=function(n){return this._invoke("return",n)}}(),"asTransitionEnd");!function(){t.fn.asTransitionEnd=function(n){var e=this,r=!1;return t(this).one(s,function(){r=!0}),setTimeout(function(){r||function(n){t(n).trigger(u())}(e)},n),this};var n=u();n&&(t.event.special[s]={bindType:n,delegateType:n,handle:function(n){if(t(n.target).is(this))return n.handleObj.handler.apply(this,arguments)}})}();var l=function(){function n(n){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return 1===o.length&&"object"===e(o[0])&&(o=o[0]),o&&o.hasOwnProperty||(o={}),n.replace(t,function(t,e,r){var i=null;return"{"===n[r-1]&&"}"===n[r+t.length]?e:(o.hasOwnProperty(e)?i=o[e]:-1!==e.indexOf(".")&&(i=function(n,t){if(Object(n)!==n||void 0===t)return n;if(t in n)return n[t];var e=t.split("."),r=e.length;if(r){for(var o=-1;n&&++o<r;){for(var i=e[o];"\\"===i[i.length-1];)i=i.slice(0,-1)+"."+e[++o];n=n[i]}return n}}(o,e)),null===i||void 0===i?"":i)})}var t=/\{\s*([.0-9a-zA-Z_]+)\s*\}/g;return{render:n,compile:function(t){return function(){for(var e=arguments.length,r=Array(e),o=0;o<e;o++)r[o]=arguments[o];return n.apply(void 0,[t].concat(r))}},parse:function(n){var e=n.match(t);if(null===e)return!1;for(var r=[],o=0;o<e.length;o++)e[o].match(/^\{\{.+\}\}$/g)||r.push(e[o].substring(1,e[o].length-1).trim());return r}}}(),c=function(){function n(e,o){r(this,n),this.defaults=t.extend(!0,{},n.defaults,e),this.translations=o||{}}return o(n,[{key:"hasTranslation",value:function(n){return n in this.translations}},{key:"addTranslation",value:function(n,e){this.translations[n]?t.extend(this.translations[n],e):this.translations[n]=e}},{key:"getTranslation",value:function(n){return this.translations[n]?this.translations[n]:{}}},{key:"instance",value:function(){function n(n,t){return function(n,t){if(Object(n)!==n||void 0===t)return n;if(t in n)return n[t];var e=t.split("."),r=e.length;if(r){for(var o=-1;n&&++o<r;){for(var i=e[o];"\\"===i[i.length-1];)i=i.slice(0,-1)+"."+e[++o];n=n[i]}return n}}(r.getTranslation(t),n)}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this,o=t.extend({},r.defaults,e),i=o.locale;return{translate:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i,u=n(t,a);if(void 0===u&&o.fallbacks){var s=a.split("-");if(s.length>1&&r.hasTranslation(s[0])&&(u=n(t,s[0])),void 0===u){u=n(t,!0!==o.fallbacks&&r.hasTranslation(o.fallbacks)?o.fallbacks:r.defaults.locale)}}if("[object Array]"===Object.prototype.toString.call(u)&&u.length>=2&&"string"==typeof e._number&&void 0!==e[e._number]){var c=parseInt(e[e._number],10);1===c?u=u[0]:c>1?u=u[1]:0===c&&u.length>=3&&(u=u[2])}if("string"==typeof u){var f=l.parse(u);if(!f)return u;for(var v=void 0,h=0;h<f.length;h++)void 0===e[v=f[h]]?e[v]=o.missingPlaceholder(v):null===e[v]&&(e[v]=o.nullPlaceholder(v));return l.render(u,e)}return Object(u)===u?u:'[missing "'+a+"."+t+'" translation]'},setLocale:function(n){i=n},getLocale:function(){return i}}}},{key:"setTranslations",value:function(n){this.translations=n}}]),n}();c.defaults={locale:"en",fallbacks:!0,nullPlaceholder:function(n){return"[missing {{"+n+"}} value]"},missingPlaceholder:function(n){return"[missing {{"+n+"}} value]"}},n.default=c,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@pluginjs/utils"),require("@pluginjs/template")):"function"==typeof define&&define.amd?define(["exports","@pluginjs/utils","@pluginjs/template"],n):n(t["@pluginjs/i18n"]={},t["@pluginjs/utils"],t["@pluginjs/template"])}(this,function(t,n,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;!function(){function t(t){this.value=t}function n(n){function e(i,a){try{var o=n[i](a),l=o.value;l instanceof t?Promise.resolve(l.value).then(function(t){e("next",t)},function(t){e("throw",t)}):r(o.done?"return":"normal",o.value)}catch(t){r("throw",t)}}function r(t,n){switch(t){case"return":i.resolve({value:n,done:!0});break;case"throw":i.reject(n);break;default:i.resolve({value:n,done:!1})}(i=i.next)?e(i.key,i.arg):a=null}var i,a;this._invoke=function(t,n){return new Promise(function(r,o){var l={key:t,arg:n,resolve:r,reject:o,next:null};a?a=a.next=l:(i=a=l,e(t,n))})},"function"!=typeof n.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(n.prototype[Symbol.asyncIterator]=function(){return this}),n.prototype.next=function(t){return this._invoke("next",t)},n.prototype.throw=function(t){return this._invoke("throw",t)},n.prototype.return=function(t){return this._invoke("return",t)}}();var r=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},i=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}(),a=function(){function t(e,i){r(this,t),this.defaults=n.deepMerge({},t.defaults,e),this.translations=i||{}}return i(t,[{key:"hasTranslation",value:function(t){return t in this.translations}},{key:"addTranslation",value:function(t,n){this.translations[t]?Object.assign(this.translations[t],n):this.translations[t]=n}},{key:"getTranslation",value:function(t){return this.translations[t]?this.translations[t]:{}}},{key:"instance",value:function(){function t(t,e){var r=i.getTranslation(e);return n.getValueByPath(r,t)}var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=this,a=Object.assign({},i.defaults,r),o=a.locale;return{translate:function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,s=t(n,l);if(void 0===s&&a.fallbacks){var u=l.split("-");if(u.length>1&&i.hasTranslation(u[0])&&(s=t(n,u[0])),void 0===s){s=t(n,!0!==a.fallbacks&&i.hasTranslation(a.fallbacks)?a.fallbacks:i.defaults.locale)}}if("[object Array]"===Object.prototype.toString.call(s)&&s.length>=2&&"string"==typeof r._number&&void 0!==r[r._number]){var c=parseInt(r[r._number],10);1===c?s=s[0]:c>1?s=s[1]:0===c&&s.length>=3&&(s=s[2])}if("string"==typeof s){var f=e.parse(s);if(!f)return s;for(var h=void 0,v=0;v<f.length;v++)void 0===r[h=f[v]]?r[h]=a.missingPlaceholder(h):null===r[h]&&(r[h]=a.nullPlaceholder(h));return e.render(s,r)}return Object(s)===s?s:'[missing "'+l+"."+n+'" translation]'},setLocale:function(t){o=t},getLocale:function(){return o}}}},{key:"setTranslations",value:function(t){this.translations=t}}]),t}();a.defaults={locale:"en",fallbacks:!0,nullPlaceholder:function(t){return"[missing {{"+t+"}} value]"},missingPlaceholder:function(t){return"[missing {{"+t+"}} value]"}},t.default=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) : | ||
(factory((global['@pluginjs/i18n'] = {}),global.jQuery)); | ||
}(this, (function (exports,$) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global['@pluginjs/i18n'] = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
$ = $ && $.hasOwnProperty('default') ? $['default'] : $; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
@@ -160,51 +158,79 @@ return typeof obj; | ||
/* eslint no-undef: "off" */ | ||
/* Credit to http://featurejs.com MIT */ | ||
/** | ||
* Test if it's an old device that we want to filter out | ||
*/ | ||
/** | ||
* Function that takes a standard CSS property name as a parameter and | ||
* returns it's prefixed version valid for current browser it runs in | ||
*/ | ||
var pfx = function () { | ||
var prefixes = ['Webkit', 'Moz', 'O', 'ms']; | ||
var memory = {}; | ||
var style = document.createElement('dummy').style; | ||
return function (prop) { | ||
if (typeof memory[prop] === 'undefined') { | ||
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1); | ||
var props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); | ||
memory[prop] = null; | ||
for (var i in props) { | ||
if (style[props[i]] !== undefined) { | ||
memory[prop] = props[i]; | ||
break; | ||
} | ||
var defineProperty = function (obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
}; | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return memory[prop]; | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
var transitionEndEvent = function transitionEndEvent() { | ||
var eventNames = { | ||
transition: 'transitionend', | ||
OTransition: 'oTransitionEnd', | ||
MozTransition: 'transitionend', | ||
WebkitTransition: 'webkitTransitionEnd' | ||
}; | ||
var style = document.createElement('dummy').style; | ||
for (var i in eventNames) { | ||
if (eventNames.hasOwnProperty(i)) { | ||
if (style[i] !== undefined) { | ||
return eventNames[i]; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
var asyncGenerator = function () { | ||
@@ -323,2 +349,92 @@ function AwaitValue(value) { | ||
var _extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
function nub(arr) { | ||
return Array.from(new Set(arr)); | ||
} | ||
function isPaintObject(data) { | ||
if ((typeof data === "undefined" ? "undefined" : _typeof(data)) !== 'object') { | ||
return false; | ||
} | ||
if (data === null) { | ||
return false; | ||
} | ||
if (data instanceof Set || data instanceof Map) { | ||
return false; | ||
} | ||
if (Array.isArray(data)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
function deepMergeTwo(x, y) { | ||
if (isPaintObject(y) && isPaintObject(x) || isPaintObject(x) && Array.isArray(y)) { | ||
return fromPairs(nub(Object.keys(x).concat(Object.keys(y))).map(function (key) { | ||
return [key, deepMergeTwo(x[key], y[key])]; | ||
})); | ||
} | ||
if (isPaintObject(y) && typeof x === 'function') { | ||
return Object.assign(function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return x.apply(this, args); | ||
}, y); | ||
} | ||
if (isPaintObject(y) && Array.isArray(x)) { | ||
return Object.assign([], x, y); | ||
} | ||
if (isPaintObject(x) && typeof y === 'function') { | ||
return Object.assign(function () { | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
return y.apply(this, args); | ||
}, x); | ||
} | ||
if (Array.isArray(y) && Array.isArray(x)) { | ||
// return x.concat(y) | ||
return nub(Object.keys(y).concat(Object.keys(x))).map(function (index) { | ||
return deepMergeTwo(x[index], y[index]); | ||
}); | ||
} | ||
if (typeof y === 'undefined') { | ||
return x; | ||
} | ||
return y; | ||
} | ||
function isObject(obj) { | ||
return Object(obj) === obj; | ||
} | ||
function deepMerge() { | ||
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
args[_key4] = arguments[_key4]; | ||
} | ||
return args.filter(isObject).reduce(deepMergeTwo); | ||
} | ||
/* Credit to https://github.com/jonschlinkert/get-value MIT */ | ||
@@ -344,3 +460,3 @@ function getValueByPath(obj, path) { | ||
while (key[key.length - 1] === '\\') { | ||
key = key.slice(0, -1) + '.' + segs[++i]; | ||
key = key.slice(0, -1) + "." + segs[++i]; | ||
} | ||
@@ -352,94 +468,12 @@ obj = obj[key]; | ||
var asTransitionEnd = 'asTransitionEnd'; | ||
function fromPairs(arr) { | ||
return arr.reduce(function (r, _ref10) { | ||
var _ref11 = slicedToArray(_ref10, 2), | ||
k = _ref11[0], | ||
v = _ref11[1]; | ||
function triggerTransitionEnd(element) { | ||
$(element).trigger(transitionEndEvent()); | ||
return _extends({}, r, defineProperty({}, k, v)); | ||
}, {}); | ||
} | ||
function setTransitionEndSupport() { | ||
$.fn.asTransitionEnd = function (duration) { | ||
var _this3 = this; | ||
var called = false; | ||
$(this).one(asTransitionEnd, function () { | ||
called = true; | ||
}); | ||
setTimeout(function () { | ||
if (!called) { | ||
triggerTransitionEnd(_this3); | ||
} | ||
}, duration); | ||
return this; | ||
}; | ||
var isTransitionEndEvent = transitionEndEvent(); | ||
if (isTransitionEndEvent) { | ||
// suport transition end | ||
$.event.special[asTransitionEnd] = { | ||
bindType: isTransitionEndEvent, | ||
delegateType: isTransitionEndEvent, | ||
handle: function handle(event) { | ||
if ($(event.target).is(this)) { | ||
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
} | ||
return undefined; | ||
} | ||
}; | ||
} | ||
} | ||
setTransitionEndSupport(); | ||
/* eslint no-undef: "off" */ | ||
/* Credit to http://featurejs.com MIT */ | ||
/** | ||
* Test if it's an old device that we want to filter out | ||
*/ | ||
/** | ||
* Function that takes a standard CSS property name as a parameter and | ||
* returns it's prefixed version valid for current browser it runs in | ||
*/ | ||
var pfx$1 = function () { | ||
var prefixes = ['Webkit', 'Moz', 'O', 'ms']; | ||
var memory = {}; | ||
var style = document.createElement('dummy').style; | ||
return function (prop) { | ||
if (typeof memory[prop] === 'undefined') { | ||
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1); | ||
var props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); | ||
memory[prop] = null; | ||
for (var i in props) { | ||
if (style[props[i]] !== undefined) { | ||
memory[prop] = props[i]; | ||
break; | ||
} | ||
} | ||
} | ||
return memory[prop]; | ||
}; | ||
}(); | ||
var transitionEndEvent$1 = function transitionEndEvent() { | ||
var eventNames = { | ||
transition: 'transitionend', | ||
OTransition: 'oTransitionEnd', | ||
MozTransition: 'transitionend', | ||
WebkitTransition: 'webkitTransitionEnd' | ||
}; | ||
var style = document.createElement('dummy').style; | ||
for (var i in eventNames) { | ||
if (eventNames.hasOwnProperty(i)) { | ||
if (style[i] !== undefined) { | ||
return eventNames[i]; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
var asyncGenerator$2 = function () { | ||
@@ -578,3 +612,3 @@ function AwaitValue(value) { | ||
while (key[key.length - 1] === '\\') { | ||
key = key.slice(0, -1) + '.' + segs[++i]; | ||
key = key.slice(0, -1) + "." + segs[++i]; | ||
} | ||
@@ -586,45 +620,2 @@ obj = obj[key]; | ||
var asTransitionEnd$1 = 'asTransitionEnd'; | ||
function triggerTransitionEnd$1(element) { | ||
$(element).trigger(transitionEndEvent$1()); | ||
} | ||
function setTransitionEndSupport$1() { | ||
$.fn.asTransitionEnd = function (duration) { | ||
var _this = this; | ||
var called = false; | ||
$(this).one(asTransitionEnd$1, function () { | ||
called = true; | ||
}); | ||
setTimeout(function () { | ||
if (!called) { | ||
triggerTransitionEnd$1(_this); | ||
} | ||
}, duration); | ||
return this; | ||
}; | ||
var isTransitionEndEvent = transitionEndEvent$1(); | ||
if (isTransitionEndEvent) { | ||
// suport transition end | ||
$.event.special[asTransitionEnd$1] = { | ||
bindType: isTransitionEndEvent, | ||
delegateType: isTransitionEndEvent, | ||
handle: function handle(event) { | ||
if ($(event.target).is(this)) { | ||
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
} | ||
return undefined; | ||
} | ||
}; | ||
} | ||
} | ||
setTransitionEndSupport$1(); | ||
/* Credit to https://github.com/Matt-Esch/string-template MIT */ | ||
@@ -702,3 +693,3 @@ var template = function () { | ||
this.defaults = $.extend(true, {}, I18N.defaults, defaults$$1); | ||
this.defaults = deepMerge({}, I18N.defaults, defaults$$1); | ||
@@ -717,3 +708,3 @@ this.translations = translations ? translations : {}; | ||
if (this.translations[locale]) { | ||
$.extend(this.translations[locale], translation); | ||
Object.assign(this.translations[locale], translation); | ||
} else { | ||
@@ -738,3 +729,3 @@ this.translations[locale] = translation; | ||
var _options = $.extend({}, that.defaults, options); | ||
var _options = Object.assign({}, that.defaults, options); | ||
var _locale = _options.locale; | ||
@@ -741,0 +732,0 @@ |
{ | ||
"name": "@pluginjs/i18n", | ||
"title": "Plugin", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "A workflow for modern frontend development.", | ||
@@ -35,4 +35,3 @@ "author": "Creation Studio Limited", | ||
"@pluginjs/template": "^0.2.6", | ||
"@pluginjs/utils": "^0.2.6", | ||
"jquery": "*" | ||
"@pluginjs/utils": "^0.2.6" | ||
}, | ||
@@ -42,3 +41,4 @@ "category": "core", | ||
"standalone": "dist/i18n.standalone.js", | ||
"module": "dist/i18n.esm.js" | ||
"module": "dist/i18n.esm.js", | ||
"dev-main": "src/main.js" | ||
} |
@@ -1,3 +0,3 @@ | ||
import { getValueByPath } from '@pluginjs/utils' | ||
import $ from 'jquery' | ||
import { getValueByPath, deepMerge } from '@pluginjs/utils' | ||
import template from '@pluginjs/template' | ||
@@ -7,3 +7,3 @@ | ||
constructor (defaults, translations) { | ||
this.defaults = $.extend(true, {}, I18N.defaults, defaults) | ||
this.defaults = deepMerge({}, I18N.defaults, defaults) | ||
@@ -19,3 +19,3 @@ this.translations = translations ? translations : {} | ||
if (this.translations[locale]) { | ||
$.extend(this.translations[locale], translation) | ||
Object.assign(this.translations[locale], translation) | ||
} else { | ||
@@ -36,3 +36,3 @@ this.translations[locale] = translation | ||
const _options = $.extend({}, that.defaults, options) | ||
const _options = Object.assign({}, that.defaults, options) | ||
let _locale = _options.locale | ||
@@ -39,0 +39,0 @@ |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
2
2
38557
1150
- Removedjquery@*
- Removedjquery@3.7.1(transitive)