@bbn/bbn 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +32 -32
- package/dist/bundle.js +1215 -418
- package/dist/fn/_addLoader.js +21 -1
- package/dist/fn/abort.js +12 -3
- package/dist/fn/addColors.js +11 -3
- package/dist/fn/addInputs.js +9 -2
- package/dist/fn/addStyle.js +7 -3
- package/dist/fn/adjustSize.js +19 -6
- package/dist/fn/ajax.js +16 -5
- package/dist/fn/analyzeFunction.js +10 -1
- package/dist/fn/animateCss.js +8 -2
- package/dist/fn/arrayBuffer2String.js +3 -1
- package/dist/fn/arrayFromProp.js +7 -1
- package/dist/fn/autoExtend.js +2 -0
- package/dist/fn/br2nl.js +3 -1
- package/dist/fn/calendar.js +8 -1
- package/dist/fn/callback.js +4 -2
- package/dist/fn/camelToCss.js +7 -1
- package/dist/fn/canvasToImage.js +5 -1
- package/dist/fn/center.js +12 -1
- package/dist/fn/checkProps.js +3 -1
- package/dist/fn/checkPropsDetails.js +4 -1
- package/dist/fn/clone.js +3 -1
- package/dist/fn/colorToHex.js +5 -1
- package/dist/fn/compare.js +28 -15
- package/dist/fn/compareConditions.js +1 -0
- package/dist/fn/copy.js +8 -2
- package/dist/fn/correctCase.js +3 -1
- package/dist/fn/count.js +3 -1
- package/dist/fn/crc32.js +1 -1
- package/dist/fn/cssExists.js +2 -0
- package/dist/fn/dateSQL.js +6 -3
- package/dist/fn/deepPath.js +9 -7
- package/dist/fn/defaultAjaxAbortFunction.js +3 -1
- package/dist/fn/defaultAjaxErrorFunction.d.ts +1 -1
- package/dist/fn/defaultAjaxErrorFunction.js +15 -2
- package/dist/fn/defaultAlertFunction.d.ts +1 -1
- package/dist/fn/defaultAlertFunction.js +5 -1
- package/dist/fn/defaultEndLoadingFunction.d.ts +1 -1
- package/dist/fn/defaultEndLoadingFunction.js +19 -1
- package/dist/fn/defaultErrorFunction.js +3 -1
- package/dist/fn/defaultHistoryFunction.js +3 -1
- package/dist/fn/defaultLinkFunction.js +3 -1
- package/dist/fn/defaultPostLinkFunction.js +3 -1
- package/dist/fn/defaultPreLinkFunction.d.ts +1 -1
- package/dist/fn/defaultPreLinkFunction.js +11 -1
- package/dist/fn/defaultResizeFunction.js +3 -1
- package/dist/fn/defaultStartLoadingFunction.d.ts +1 -1
- package/dist/fn/defaultStartLoadingFunction.js +14 -1
- package/dist/fn/deleteProp.js +5 -1
- package/dist/fn/diffObj.js +20 -5
- package/dist/fn/download.js +4 -1
- package/dist/fn/downloadContent.js +12 -1
- package/dist/fn/eraseCookie.js +3 -1
- package/dist/fn/error.js +5 -1
- package/dist/fn/escapeRegExp.js +3 -1
- package/dist/fn/escapeUrl.js +3 -1
- package/dist/fn/extend.js +6 -1
- package/dist/fn/fdate.js +1 -0
- package/dist/fn/fdatetime.js +10 -1
- package/dist/fn/filter.js +10 -6
- package/dist/fn/filterToConditions.js +8 -2
- package/dist/fn/findAll.js +5 -3
- package/dist/fn/format.js +5 -1
- package/dist/fn/formatDate.js +3 -1
- package/dist/fn/formdata.js +7 -2
- package/dist/fn/ftime.js +3 -1
- package/dist/fn/getAllTags.js +3 -1
- package/dist/fn/getAttributes.js +3 -1
- package/dist/fn/getBrowserName.js +20 -10
- package/dist/fn/getBrowserVersion.js +21 -10
- package/dist/fn/getEventData.js +26 -6
- package/dist/fn/getField.js +1 -2
- package/dist/fn/getPath.js +14 -3
- package/dist/fn/getProp.js +5 -1
- package/dist/fn/getRequestId.js +5 -3
- package/dist/fn/getScrollBarSize.js +4 -1
- package/dist/fn/getText.js +3 -1
- package/dist/fn/happy.js +8 -1
- package/dist/fn/hash.js +2 -1
- package/dist/fn/hex2rgb.js +8 -1
- package/dist/fn/history.js +3 -1
- package/dist/fn/html2text.js +6 -1
- package/dist/fn/imageToCanvas.js +7 -1
- package/dist/fn/imgToBase64.js +4 -1
- package/dist/fn/info.js +9 -1
- package/dist/fn/init.js +72 -14
- package/dist/fn/isArray.d.ts +1 -1
- package/dist/fn/isArray.js +3 -3
- package/dist/fn/isBlob.d.ts +1 -1
- package/dist/fn/isBlob.js +3 -3
- package/dist/fn/isBoolean.d.ts +1 -1
- package/dist/fn/isBoolean.js +3 -3
- package/dist/fn/isCanvas.d.ts +1 -1
- package/dist/fn/isCanvas.js +3 -3
- package/dist/fn/isComment.d.ts +1 -1
- package/dist/fn/isComment.js +3 -3
- package/dist/fn/isCp.d.ts +1 -1
- package/dist/fn/isCp.js +3 -3
- package/dist/fn/isDate.d.ts +1 -1
- package/dist/fn/isDate.js +3 -3
- package/dist/fn/isDesktopDevice.js +3 -1
- package/dist/fn/isDom.d.ts +1 -1
- package/dist/fn/isDom.js +3 -3
- package/dist/fn/isEvent.d.ts +1 -1
- package/dist/fn/isEvent.js +3 -3
- package/dist/fn/isFocused.js +3 -1
- package/dist/fn/isFunction.d.ts +1 -1
- package/dist/fn/isFunction.js +3 -3
- package/dist/fn/isHostname.d.ts +1 -1
- package/dist/fn/isHostname.js +10 -5
- package/dist/fn/isIP.d.ts +1 -1
- package/dist/fn/isIP.js +10 -3
- package/dist/fn/isInside.js +6 -4
- package/dist/fn/isInt.d.ts +1 -1
- package/dist/fn/isInt.js +3 -3
- package/dist/fn/isIterable.js +3 -1
- package/dist/fn/isMobile.js +3 -1
- package/dist/fn/isMobileDevice.js +3 -1
- package/dist/fn/isNull.d.ts +1 -1
- package/dist/fn/isNull.js +3 -3
- package/dist/fn/isNumber.d.ts +1 -1
- package/dist/fn/isNumber.js +3 -3
- package/dist/fn/isObject.d.ts +1 -1
- package/dist/fn/isObject.js +3 -3
- package/dist/fn/isPercent.d.ts +1 -1
- package/dist/fn/isPercent.js +3 -3
- package/dist/fn/isPrimitive.d.ts +1 -1
- package/dist/fn/isPrimitive.js +3 -3
- package/dist/fn/isPromise.d.ts +1 -1
- package/dist/fn/isPromise.js +3 -3
- package/dist/fn/isPropSize.js +10 -4
- package/dist/fn/isSQLDate.d.ts +1 -1
- package/dist/fn/isSQLDate.js +5 -4
- package/dist/fn/isSame.js +7 -4
- package/dist/fn/isString.d.ts +1 -1
- package/dist/fn/isString.js +3 -3
- package/dist/fn/isSymbol.d.ts +1 -1
- package/dist/fn/isSymbol.js +3 -3
- package/dist/fn/isTabletDevice.js +3 -1
- package/dist/fn/isURL.d.ts +1 -1
- package/dist/fn/isURL.js +10 -1
- package/dist/fn/isValidDimension.js +3 -1
- package/dist/fn/isValidName.d.ts +1 -1
- package/dist/fn/isValidName.js +3 -3
- package/dist/fn/isValue.d.ts +1 -1
- package/dist/fn/isValue.js +3 -3
- package/dist/fn/isVue.d.ts +1 -1
- package/dist/fn/isVue.js +5 -5
- package/dist/fn/iterate.js +5 -3
- package/dist/fn/link.js +24 -3
- package/dist/fn/makeReactive.js +47 -11
- package/dist/fn/md5.js +12 -3
- package/dist/fn/money.js +26 -0
- package/dist/fn/nl2br.js +3 -1
- package/dist/fn/objectToFormData.js +8 -4
- package/dist/fn/order.js +3 -1
- package/dist/fn/percent.js +3 -1
- package/dist/fn/pickValue.js +5 -3
- package/dist/fn/post.js +8 -3
- package/dist/fn/printf.js +8 -1
- package/dist/fn/randomInt.js +3 -1
- package/dist/fn/randomString.js +9 -2
- package/dist/fn/removeExtraSpaces.js +3 -1
- package/dist/fn/repeat.js +7 -1
- package/dist/fn/replaceSelection.js +6 -0
- package/dist/fn/riterate.js +3 -1
- package/dist/fn/roundDecimal.js +3 -1
- package/dist/fn/search.js +17 -2
- package/dist/fn/selector.js +3 -1
- package/dist/fn/setNavigationVars.js +20 -2
- package/dist/fn/setProp.js +9 -1
- package/dist/fn/shorten.js +1 -1
- package/dist/fn/shuffle.js +6 -1
- package/dist/fn/simpleHash.js +5 -1
- package/dist/fn/simpleHash1.js +1 -1
- package/dist/fn/simpleHash2.js +1 -1
- package/dist/fn/startChrono.js +5 -3
- package/dist/fn/stat.js +4 -2
- package/dist/fn/stopChrono.js +7 -5
- package/dist/fn/string2ArrayBuffer.js +1 -1
- package/dist/fn/submit.js +12 -1
- package/dist/fn/sum.js +11 -3
- package/dist/fn/timestamp.js +4 -1
- package/dist/fn/toggleFullScreen.js +3 -1
- package/dist/fn/translate.js +6 -1
- package/dist/fn/treatAjaxArguments.js +8 -0
- package/dist/fn/uniqString.d.ts +1 -1
- package/dist/fn/uniqString.js +14 -11
- package/dist/fn/unique.js +5 -1
- package/dist/fn/upload.js +20 -9
- package/dist/fn/warning.js +10 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/fn/repeat.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { iterate } from './iterate';
|
|
2
|
-
const repeat = function (st, num) {
|
|
2
|
+
const repeat = function (st, num) {
|
|
3
|
+
let res = '';
|
|
4
|
+
iterate(num, () => {
|
|
5
|
+
res += st;
|
|
6
|
+
});
|
|
7
|
+
return res;
|
|
8
|
+
};
|
|
3
9
|
export { repeat };
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
const replaceSelection = function (html, selectInserted) {
|
|
2
2
|
let sel, range, fragment;
|
|
3
3
|
sel = window.getSelection();
|
|
4
|
+
// Test that the Selection object contains at least one Range
|
|
4
5
|
if (sel.getRangeAt && sel.rangeCount) {
|
|
6
|
+
// Get the first Range (only Firefox supports more than one)
|
|
5
7
|
range = window.getSelection().getRangeAt(0);
|
|
6
8
|
range.deleteContents();
|
|
9
|
+
// Create a DocumentFragment to insert and populate it with HTML
|
|
10
|
+
// Need to test for the existence of range.createContextualFragment
|
|
11
|
+
// because it's non-standard and IE 9 does not support it
|
|
7
12
|
if (range.createContextualFragment) {
|
|
8
13
|
fragment = range.createContextualFragment(html);
|
|
9
14
|
}
|
|
10
15
|
else {
|
|
16
|
+
// In IE 9 we need to use innerHTML of a temporary element
|
|
11
17
|
const div = document.createElement("div");
|
|
12
18
|
let child;
|
|
13
19
|
div.innerHTML = html;
|
package/dist/fn/riterate.js
CHANGED
package/dist/fn/roundDecimal.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
const roundDecimal = function (value, decimals) {
|
|
1
|
+
const roundDecimal = function (value, decimals) {
|
|
2
|
+
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
|
|
3
|
+
};
|
|
2
4
|
export { roundDecimal };
|
package/dist/fn/search.js
CHANGED
|
@@ -15,11 +15,26 @@ const search = function (arr, prop, val, operator, startFrom) {
|
|
|
15
15
|
let filter = {};
|
|
16
16
|
let isFunction = false;
|
|
17
17
|
if (isString(prop)) {
|
|
18
|
-
filter.conditions = [{
|
|
18
|
+
filter.conditions = [{
|
|
19
|
+
field: prop,
|
|
20
|
+
value: val,
|
|
21
|
+
operator: operator || '='
|
|
22
|
+
}];
|
|
19
23
|
}
|
|
20
24
|
else if (!prop) {
|
|
21
25
|
isFunction = true;
|
|
22
|
-
filter = a => {
|
|
26
|
+
filter = a => {
|
|
27
|
+
return compareConditions({ value: a }, filterToConditions({
|
|
28
|
+
logic: 'AND',
|
|
29
|
+
conditions: [
|
|
30
|
+
{
|
|
31
|
+
field: 'value',
|
|
32
|
+
operator: operator || '=',
|
|
33
|
+
value: val
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
23
38
|
}
|
|
24
39
|
else {
|
|
25
40
|
startFrom = operator;
|
package/dist/fn/selector.js
CHANGED
|
@@ -3,14 +3,28 @@ import { filter } from './filter';
|
|
|
3
3
|
import { extend } from './extend';
|
|
4
4
|
import { html2text } from './html2text';
|
|
5
5
|
const setNavigationVars = function (url, title, data, repl) {
|
|
6
|
+
// Current path becomes old path
|
|
6
7
|
bbn.env.old_path = bbn.env.path;
|
|
8
|
+
// URL includes the domain
|
|
7
9
|
bbn.env.url = ['https:/', 'http://'].includes(substr(url, 0, 7)) ? url : bbn.env.root + url;
|
|
10
|
+
// Path does not
|
|
8
11
|
bbn.env.path = substr(bbn.env.url, bbn.env.root.length);
|
|
9
|
-
|
|
12
|
+
// Params will include each part of the URL
|
|
13
|
+
bbn.env.params = filter(bbn.env.path.split("/"), (v) => {
|
|
14
|
+
return v !== '';
|
|
15
|
+
});
|
|
16
|
+
// Managing history
|
|
10
17
|
let h = window.history;
|
|
11
18
|
if (h) {
|
|
19
|
+
// Current state
|
|
12
20
|
let state = h.state;
|
|
13
|
-
|
|
21
|
+
// Future state
|
|
22
|
+
let obj = {
|
|
23
|
+
url: bbn.env.path,
|
|
24
|
+
old_path: bbn.env.old_path || null,
|
|
25
|
+
data: data || {}
|
|
26
|
+
};
|
|
27
|
+
// If same URL we replace
|
|
14
28
|
if (state && (state.url === bbn.env.path)) {
|
|
15
29
|
if (state.data) {
|
|
16
30
|
extend(obj.data, state.data);
|
|
@@ -20,16 +34,20 @@ const setNavigationVars = function (url, title, data, repl) {
|
|
|
20
34
|
}
|
|
21
35
|
repl = 1;
|
|
22
36
|
}
|
|
37
|
+
// If no title the global title
|
|
23
38
|
if (!title) {
|
|
24
39
|
title = bbn.env.siteTitle;
|
|
25
40
|
}
|
|
41
|
+
// Otherwise we add the global title at the end
|
|
26
42
|
else {
|
|
27
43
|
title = html2text(title);
|
|
28
44
|
}
|
|
45
|
+
// Replacing state
|
|
29
46
|
if (repl) {
|
|
30
47
|
obj.reload = 1;
|
|
31
48
|
h.replaceState(obj, title, bbn.env.url);
|
|
32
49
|
}
|
|
50
|
+
// Adding state
|
|
33
51
|
else {
|
|
34
52
|
h.pushState(obj, title, bbn.env.url);
|
|
35
53
|
}
|
package/dist/fn/setProp.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
const setProp = function (obj, prop, value, writable = true, configurable = true) {
|
|
1
|
+
const setProp = function (obj, prop, value, writable = true, configurable = true) {
|
|
2
|
+
checkType(prop, "string", bbn._("The prop must be a string in setProp"));
|
|
3
|
+
checkType(obj, "object", bbn._("The obj must be an object in setProp"));
|
|
4
|
+
Object.defineProperty(obj, prop, {
|
|
5
|
+
value: value,
|
|
6
|
+
writable: writable,
|
|
7
|
+
configurable: configurable
|
|
8
|
+
});
|
|
9
|
+
};
|
|
2
10
|
export { setProp };
|
package/dist/fn/shorten.js
CHANGED
package/dist/fn/shuffle.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
const shuffle = function (array) {
|
|
2
2
|
let currentIndex = array.length, randomIndex;
|
|
3
|
+
// While there remain elements to shuffle.
|
|
3
4
|
while (currentIndex != 0) {
|
|
5
|
+
// Pick a remaining element.
|
|
4
6
|
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
5
7
|
currentIndex--;
|
|
6
|
-
|
|
8
|
+
// And swap it with the current element.
|
|
9
|
+
[array[currentIndex], array[randomIndex]] = [
|
|
10
|
+
array[randomIndex], array[currentIndex]
|
|
11
|
+
];
|
|
7
12
|
}
|
|
8
13
|
return array;
|
|
9
14
|
};
|
package/dist/fn/simpleHash.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { simpleHash1 } from './simpleHash1';
|
|
2
2
|
import { simpleHash2 } from './simpleHash2';
|
|
3
|
-
const simpleHash = function (str) {
|
|
3
|
+
const simpleHash = function (str) {
|
|
4
|
+
const part1 = simpleHash1(str).toString(16).padStart(8, '0');
|
|
5
|
+
const part2 = simpleHash2(str).toString(16).padStart(8, '0');
|
|
6
|
+
return part1 + part2;
|
|
7
|
+
};
|
|
4
8
|
export { simpleHash };
|
package/dist/fn/simpleHash1.js
CHANGED
package/dist/fn/simpleHash2.js
CHANGED
package/dist/fn/startChrono.js
CHANGED
|
@@ -3,9 +3,11 @@ const startChrono = function (name) {
|
|
|
3
3
|
let now = (new Date()).getTime();
|
|
4
4
|
let h1 = 3600 * 1000;
|
|
5
5
|
if (_private.length) {
|
|
6
|
-
each(_private, (t, n) => {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
each(_private, (t, n) => {
|
|
7
|
+
if (now - t > h1) {
|
|
8
|
+
delete _private[n];
|
|
9
|
+
}
|
|
10
|
+
});
|
|
9
11
|
now = (new Date()).getTime();
|
|
10
12
|
}
|
|
11
13
|
_private[name] = now;
|
package/dist/fn/stat.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getPath } from './getPath';
|
|
|
2
2
|
const stat = function (returnStat) {
|
|
3
3
|
return;
|
|
4
4
|
if (bbn.env.logging) {
|
|
5
|
-
var logs = bbn.
|
|
5
|
+
var logs = bbn.var.loggers;
|
|
6
6
|
for (var i = 0; i < arguments.length; i++) {
|
|
7
7
|
var a = arguments[i], type = typeof (a);
|
|
8
8
|
if ((type === 'boolean') || (type === 'undefined')) {
|
|
@@ -16,7 +16,9 @@ const stat = function (returnStat) {
|
|
|
16
16
|
a = a.toString();
|
|
17
17
|
}
|
|
18
18
|
if (!logs[a]) {
|
|
19
|
-
logs[a] = {
|
|
19
|
+
logs[a] = {
|
|
20
|
+
_num: 0,
|
|
21
|
+
};
|
|
20
22
|
}
|
|
21
23
|
logs[a]._num++;
|
|
22
24
|
logs = logs[a];
|
package/dist/fn/stopChrono.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const stopChrono = function (name) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const stopChrono = function (name) {
|
|
2
|
+
if (_private[name]) {
|
|
3
|
+
let now = (new Date()).getTime();
|
|
4
|
+
let diff = now - _private[name];
|
|
5
|
+
return diff;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
6
8
|
export { stopChrono };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const string2ArrayBuffer = function (str) {
|
|
2
|
-
var buf = new ArrayBuffer(str.length * 2);
|
|
2
|
+
var buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
|
|
3
3
|
var bufView = new Uint16Array(buf);
|
|
4
4
|
for (var i = 0, strLen = str.length; i < strLen; i++) {
|
|
5
5
|
bufView[i] = str.charCodeAt(i);
|
package/dist/fn/submit.js
CHANGED
|
@@ -7,17 +7,28 @@ const submit = function (form, e, fn) {
|
|
|
7
7
|
if (url === '') {
|
|
8
8
|
url = '.';
|
|
9
9
|
}
|
|
10
|
+
//if ( (typeof(url) === 'string') && (url.indexOf("http") !== 0 || url.indexOf(window.document.location.hostname) !== -1) && !form.is("[target]") ){
|
|
10
11
|
if ((typeof (url) === 'string') && (url.indexOf("http") !== 0 || url.indexOf(window.document.location.hostname) !== -1) && !form.getAttribute("target")) {
|
|
11
12
|
if (e) {
|
|
12
13
|
e.preventDefault();
|
|
13
14
|
}
|
|
14
15
|
data = formdata(form);
|
|
15
16
|
if (data) {
|
|
17
|
+
//$form.attr("action", null);
|
|
16
18
|
form.setAttribute('action', null);
|
|
19
|
+
//$form.data("bbnSubmit", 1);
|
|
17
20
|
form.dataset.bbnSubmit = 1;
|
|
21
|
+
//var script = $form.data("script");
|
|
18
22
|
let script = form.dataset.script;
|
|
19
23
|
if (isFunction(script)) {
|
|
20
|
-
form.
|
|
24
|
+
/*$form.data("script", function(d){
|
|
25
|
+
$form.attr("action", url);
|
|
26
|
+
script(d);
|
|
27
|
+
})*/
|
|
28
|
+
form.dataset.script = d => {
|
|
29
|
+
form.setAttribute("action", url);
|
|
30
|
+
script(d);
|
|
31
|
+
};
|
|
21
32
|
}
|
|
22
33
|
if (!fn) {
|
|
23
34
|
fn = form.getAttribute("data-script");
|
package/dist/fn/sum.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { each } from './each';
|
|
2
2
|
import { filter } from './filter';
|
|
3
|
-
const sum = function (arr, numberProp, prop, val, operator) {
|
|
4
|
-
r
|
|
5
|
-
|
|
3
|
+
const sum = function (arr, numberProp, prop, val, operator) {
|
|
4
|
+
let r = 0;
|
|
5
|
+
let isFunction = isFunction(numberProp);
|
|
6
|
+
each(filter(arr, prop, val, operator), (a) => {
|
|
7
|
+
let tmp = isFunction ? numberProp(a) : a[numberProp];
|
|
8
|
+
if (tmp) {
|
|
9
|
+
r += (parseFloat(tmp) || 0);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return r;
|
|
13
|
+
};
|
|
6
14
|
export { sum };
|
package/dist/fn/timestamp.js
CHANGED
package/dist/fn/translate.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { iterate } from './iterate';
|
|
2
|
-
const translate = function (o, namespace) {
|
|
2
|
+
const translate = function (o, namespace) {
|
|
3
|
+
let lng = namespace ? bbn.lng[namespace.indexOf('_') === 0 ? namespace : '_' + namespace] : bbn.lng;
|
|
4
|
+
iterate(o, (v, k) => {
|
|
5
|
+
lng[k] = v;
|
|
6
|
+
});
|
|
7
|
+
};
|
|
3
8
|
export { translate };
|
|
@@ -10,6 +10,7 @@ const treatAjaxArguments = function (args) {
|
|
|
10
10
|
for (i = 0; i < args.length; i++) {
|
|
11
11
|
t = typeof (args[i]);
|
|
12
12
|
t = t.toLowerCase();
|
|
13
|
+
/* Callbacks */
|
|
13
14
|
if (isFunction(args[i])) {
|
|
14
15
|
if (cfg.errorFn && !cfg.abortFn) {
|
|
15
16
|
cfg.abortFn = args[i];
|
|
@@ -21,14 +22,17 @@ const treatAjaxArguments = function (args) {
|
|
|
21
22
|
cfg.successFn = args[i];
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
/* Force */
|
|
24
26
|
else if ((args[i] === 1) || (args[i] === true)) {
|
|
25
27
|
cfg.force = true;
|
|
26
28
|
}
|
|
27
29
|
else if (t === 'string') {
|
|
28
30
|
if (!cfg.url) {
|
|
31
|
+
/* Hash */
|
|
29
32
|
if (args[i].indexOf('#') === 0 || args[i].indexOf(bbn.env.root + '#') === 0) {
|
|
30
33
|
cfg.url = substr(args[i], bbn.env.root.length);
|
|
31
34
|
}
|
|
35
|
+
/* Link */
|
|
32
36
|
else {
|
|
33
37
|
cfg.url = args[i];
|
|
34
38
|
if (cfg.url.indexOf(bbn.env.root) === 0) {
|
|
@@ -36,17 +40,21 @@ const treatAjaxArguments = function (args) {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
}
|
|
43
|
+
/* Ajax datatype */
|
|
39
44
|
else {
|
|
40
45
|
cfg.datatype = args[i];
|
|
41
46
|
}
|
|
42
47
|
}
|
|
48
|
+
/* Event */
|
|
43
49
|
else if (args[i] && (t === 'object')) {
|
|
44
50
|
if (args[i] instanceof Event) {
|
|
45
51
|
cfg.e = args[i];
|
|
46
52
|
}
|
|
53
|
+
/* HTML Element */
|
|
47
54
|
else if (!cfg.ele && (args[i].nodeType === 1)) {
|
|
48
55
|
cfg.ele = args[i];
|
|
49
56
|
}
|
|
57
|
+
/* An object to post */
|
|
50
58
|
else if (t.toLowerCase() === 'object') {
|
|
51
59
|
cfg.obj = args[i];
|
|
52
60
|
}
|
package/dist/fn/uniqString.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const uniqString: () => string;
|
|
1
|
+
declare const uniqString: (...args: any[]) => string;
|
|
2
2
|
export { uniqString };
|
package/dist/fn/uniqString.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import { isArray } from './isArray';
|
|
2
2
|
import { each } from './each';
|
|
3
3
|
import { md5 } from './md5';
|
|
4
|
-
const uniqString = function () {
|
|
4
|
+
const uniqString = function (...args) {
|
|
5
5
|
var st = '';
|
|
6
|
-
for (var i = 0; i <
|
|
7
|
-
if (!
|
|
6
|
+
for (var i = 0; i < args.length; i++) {
|
|
7
|
+
if (!args[i]) {
|
|
8
8
|
st += '__bbn_empty__';
|
|
9
9
|
}
|
|
10
|
-
else if (typeof (
|
|
11
|
-
if (isArray(
|
|
12
|
-
st += JSON.stringify(
|
|
10
|
+
else if (typeof (args[i]) === 'object') {
|
|
11
|
+
if (isArray(args[i])) {
|
|
12
|
+
st += JSON.stringify(args[i]);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
+
// An object with the same properties, even in different order, should produce the same answer
|
|
15
16
|
let tmp = {};
|
|
16
|
-
let ks = Object.keys(
|
|
17
|
-
each(ks, k => {
|
|
17
|
+
let ks = Object.keys(args[i]).sort();
|
|
18
|
+
each(ks, k => {
|
|
19
|
+
tmp[k] = args[i][k];
|
|
20
|
+
});
|
|
18
21
|
st += JSON.stringify(tmp);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
else if (typeof (
|
|
22
|
-
st +=
|
|
24
|
+
else if (typeof (args[i]) !== 'string') {
|
|
25
|
+
st += args[i].toString();
|
|
23
26
|
}
|
|
24
27
|
else {
|
|
25
|
-
st +=
|
|
28
|
+
st += args[i];
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
return md5(st);
|
package/dist/fn/unique.js
CHANGED
package/dist/fn/upload.js
CHANGED
|
@@ -2,24 +2,35 @@ import { objectToFormData } from './objectToFormData';
|
|
|
2
2
|
import { log } from './log';
|
|
3
3
|
const upload = function (url, file, success, failure, progress) {
|
|
4
4
|
let fn = () => {
|
|
5
|
-
return axios.post(url || bbn.env.path, objectToFormData(file), {
|
|
5
|
+
return axios.post(url || bbn.env.path, objectToFormData(file), {
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'multipart/form-data'
|
|
8
|
+
},
|
|
9
|
+
onUploadProgress(progressEvent) {
|
|
6
10
|
if (progress) {
|
|
7
11
|
let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
8
12
|
progress(percentCompleted, progressEvent.loaded, progressEvent.total);
|
|
9
13
|
}
|
|
10
|
-
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
11
16
|
};
|
|
12
17
|
if (!success && !failure) {
|
|
13
18
|
return fn();
|
|
14
19
|
}
|
|
15
20
|
else {
|
|
16
|
-
return fn()
|
|
17
|
-
|
|
18
|
-
success
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
return fn()
|
|
22
|
+
.then(res => {
|
|
23
|
+
if (success) {
|
|
24
|
+
log("SUCCESS", res);
|
|
25
|
+
success(res);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
.catch(err => {
|
|
29
|
+
if (failure) {
|
|
30
|
+
log("ERROR", err);
|
|
31
|
+
failure(err);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
23
34
|
}
|
|
24
35
|
};
|
|
25
36
|
export { upload };
|
package/dist/fn/warning.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { log } from './log';
|
|
2
|
-
const warning = function (message) {
|
|
2
|
+
const warning = function (message) {
|
|
3
|
+
const args = ["BBN: " + message];
|
|
4
|
+
args.unshift({
|
|
5
|
+
_bbn_console_mode: "warn",
|
|
6
|
+
_bbn_console_level: 2,
|
|
7
|
+
_bbn_console_style: "color: #E64141; background: #F7E195; font-size: 14px"
|
|
8
|
+
});
|
|
9
|
+
log.apply(this, args);
|
|
10
|
+
return this;
|
|
11
|
+
};
|
|
3
12
|
export { warning };
|
package/dist/index.js
CHANGED
|
@@ -227,7 +227,7 @@ import { uniqString } from './fn/uniqString';
|
|
|
227
227
|
import { unique } from './fn/unique';
|
|
228
228
|
import { upload } from './fn/upload';
|
|
229
229
|
import { warning } from './fn/warning';
|
|
230
|
-
|
|
230
|
+
const fn = {
|
|
231
231
|
_addLoader,
|
|
232
232
|
_compareValues,
|
|
233
233
|
_deleteLoader,
|