@bbn/bbn 1.0.436 → 1.0.438
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/_.js +7 -11
- package/dist/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/date.d.ts +26 -0
- package/dist/date.js +190 -0
- package/dist/db.js +107 -124
- package/dist/fn/ajax/_addLoader.js +6 -6
- package/dist/fn/ajax/_deleteLoader.js +11 -13
- package/dist/fn/ajax/abort.js +1 -1
- package/dist/fn/ajax/abortURL.js +1 -1
- package/dist/fn/ajax/ajax.js +25 -30
- package/dist/fn/ajax/callback.js +10 -14
- package/dist/fn/ajax/download.js +7 -9
- package/dist/fn/ajax/downloadContent.js +5 -6
- package/dist/fn/ajax/getLoader.js +1 -1
- package/dist/fn/ajax/getRequestId.js +2 -2
- package/dist/fn/ajax/link.js +9 -13
- package/dist/fn/ajax/post.js +3 -7
- package/dist/fn/ajax/postOut.js +2 -4
- package/dist/fn/ajax/setNavigationVars.js +5 -7
- package/dist/fn/ajax/stream.js +21 -22
- package/dist/fn/ajax/treatAjaxArguments.js +3 -3
- package/dist/fn/ajax/upload.js +6 -9
- package/dist/fn/browser/copy.js +9 -12
- package/dist/fn/browser/error.js +2 -2
- package/dist/fn/browser/executeSlowly.js +11 -55
- package/dist/fn/browser/getBrowserName.js +1 -1
- package/dist/fn/browser/getBrowserVersion.js +1 -1
- package/dist/fn/browser/getCookie.js +5 -5
- package/dist/fn/browser/getDeviceType.js +1 -1
- package/dist/fn/browser/getEventData.js +30 -30
- package/dist/fn/browser/happy.js +1 -5
- package/dist/fn/browser/info.js +1 -5
- package/dist/fn/browser/isActiveInterface.js +2 -3
- package/dist/fn/browser/isFocused.js +1 -2
- package/dist/fn/browser/log.js +8 -12
- package/dist/fn/browser/replaceSelection.js +5 -5
- package/dist/fn/browser/selectElementText.js +4 -5
- package/dist/fn/browser/setCookie.js +3 -3
- package/dist/fn/browser/warning.js +2 -2
- package/dist/fn/browser/yieldToBrowser.js +7 -43
- package/dist/fn/convert/arrayBuffer2String.js +1 -1
- package/dist/fn/convert/canvasToImage.js +1 -1
- package/dist/fn/convert/colorToHex.js +1 -1
- package/dist/fn/convert/fromXml.js +7 -13
- package/dist/fn/convert/hex2rgb.js +1 -1
- package/dist/fn/convert/imageToCanvas.js +1 -1
- package/dist/fn/convert/imgToBase64.js +2 -3
- package/dist/fn/convert/toCSV.js +7 -10
- package/dist/fn/datetime/calendar.js +4 -5
- package/dist/fn/datetime/date.js +1 -1
- package/dist/fn/datetime/dateSQL.js +1 -1
- package/dist/fn/datetime/daysInMonth.js +1 -1
- package/dist/fn/datetime/fdate.js +2 -3
- package/dist/fn/datetime/fdatetime.js +2 -3
- package/dist/fn/datetime/ftime.js +1 -1
- package/dist/fn/datetime/getChrono.js +2 -3
- package/dist/fn/datetime/getDay.js +3 -3
- package/dist/fn/datetime/startChrono.js +1 -1
- package/dist/fn/datetime/stopChrono.js +2 -2
- package/dist/fn/datetime/timestamp.js +2 -3
- package/dist/fn/default/defaultAjaxAbortFunction.js +1 -2
- package/dist/fn/default/defaultAjaxErrorFunction.js +1 -3
- package/dist/fn/default/defaultAlertFunction.js +1 -2
- package/dist/fn/default/defaultConfirmFunction.js +2 -3
- package/dist/fn/default/defaultEndLoadingFunction.js +1 -3
- package/dist/fn/default/defaultPostLinkFunction.js +1 -2
- package/dist/fn/default/defaultPreLinkFunction.js +1 -3
- package/dist/fn/form/addInputs.js +10 -12
- package/dist/fn/form/fieldValue.js +1 -1
- package/dist/fn/form/formdata.js +24 -24
- package/dist/fn/form/objectToFormData.js +5 -8
- package/dist/fn/form/submit.js +4 -4
- package/dist/fn/html/adjustHeight.js +1 -1
- package/dist/fn/html/adjustSize.js +5 -5
- package/dist/fn/html/adjustWidth.js +1 -1
- package/dist/fn/html/getAllTags.js +1 -1
- package/dist/fn/html/getAncestors.js +2 -3
- package/dist/fn/html/getAttributes.js +2 -2
- package/dist/fn/html/getHTMLOfSelection.js +4 -4
- package/dist/fn/html/getHtml.js +2 -3
- package/dist/fn/html/getIndex.js +3 -4
- package/dist/fn/html/getPath.js +12 -17
- package/dist/fn/html/html2text.js +1 -1
- package/dist/fn/html/isInViewport.js +4 -5
- package/dist/fn/html/isInside.js +5 -5
- package/dist/fn/html/makeReactive.js +22 -26
- package/dist/fn/init.js +18 -18
- package/dist/fn/loop/each.js +2 -2
- package/dist/fn/loop/fori.js +3 -5
- package/dist/fn/loop/forir.js +3 -5
- package/dist/fn/loop/iterate.js +3 -6
- package/dist/fn/loop/riterate.js +1 -2
- package/dist/fn/misc/analyzeFunction.js +36 -36
- package/dist/fn/misc/money.js +4 -4
- package/dist/fn/misc/translate.js +2 -2
- package/dist/fn/object/_compareValues.js +2 -3
- package/dist/fn/object/_filter.js +7 -10
- package/dist/fn/object/arrayFromProp.js +2 -2
- package/dist/fn/object/checkProps.js +1 -2
- package/dist/fn/object/checkPropsDetails.js +8 -9
- package/dist/fn/object/checkPropsOrDie.js +2 -3
- package/dist/fn/object/circularReplacer.js +2 -2
- package/dist/fn/object/clone.js +2 -2
- package/dist/fn/object/compareConditions.js +6 -6
- package/dist/fn/object/count.js +1 -3
- package/dist/fn/object/createObject.js +3 -16
- package/dist/fn/object/deepPath.js +6 -7
- package/dist/fn/object/diffObj.js +11 -13
- package/dist/fn/object/extend.js +10 -14
- package/dist/fn/object/extendOut.js +4 -9
- package/dist/fn/object/filter.js +6 -12
- package/dist/fn/object/filterToConditions.js +6 -7
- package/dist/fn/object/findAll.js +4 -5
- package/dist/fn/object/getField.js +2 -8
- package/dist/fn/object/getFieldValues.js +2 -2
- package/dist/fn/object/getProperty.js +5 -9
- package/dist/fn/object/getRow.js +2 -7
- package/dist/fn/object/getSortingMoves.js +28 -28
- package/dist/fn/object/isWritable.js +1 -1
- package/dist/fn/object/map.js +2 -3
- package/dist/fn/object/move.js +1 -1
- package/dist/fn/object/multiorder.js +5 -6
- package/dist/fn/object/mutateArray.js +8 -9
- package/dist/fn/object/mutateObject.js +3 -3
- package/dist/fn/object/order.js +1 -2
- package/dist/fn/object/removeEmpty.js +2 -2
- package/dist/fn/object/removePrivateProp.js +2 -3
- package/dist/fn/object/search.js +13 -17
- package/dist/fn/object/setProp.js +1 -3
- package/dist/fn/object/setProperty.js +8 -8
- package/dist/fn/object/shortenObj.js +3 -4
- package/dist/fn/object/shuffle.js +2 -3
- package/dist/fn/object/sum.js +3 -3
- package/dist/fn/object/unique.js +1 -1
- package/dist/fn/phone/fphone.js +22 -22
- package/dist/fn/string/baseName.js +3 -3
- package/dist/fn/string/correctCase.js +1 -1
- package/dist/fn/string/crc32.js +7 -7
- package/dist/fn/string/data2Html.js +4 -5
- package/dist/fn/string/dirName.js +1 -1
- package/dist/fn/string/escapeUrl.js +6 -6
- package/dist/fn/string/fileExt.js +1 -1
- package/dist/fn/string/firstVarElement.js +2 -2
- package/dist/fn/string/format.js +4 -4
- package/dist/fn/string/formatBytes.js +2 -3
- package/dist/fn/string/hash.js +4 -8
- package/dist/fn/string/randomString.js +5 -5
- package/dist/fn/string/replaceAll.js +1 -2
- package/dist/fn/string/sanitize.js +6 -7
- package/dist/fn/string/simpleHash.js +2 -2
- package/dist/fn/string/simpleHash1.js +3 -3
- package/dist/fn/string/simpleHash2.js +3 -3
- package/dist/fn/string/treatForHash.js +6 -10
- package/dist/fn/string/trim.js +1 -2
- package/dist/fn/string/uniqString.js +7 -14
- package/dist/fn/style/addColors.js +14 -14
- package/dist/fn/style/addStyle.js +1 -1
- package/dist/fn/style/animateCss.js +1 -1
- package/dist/fn/style/center.js +1 -1
- package/dist/fn/style/cssExists.js +5 -5
- package/dist/fn/style/getCssVar.js +1 -1
- package/dist/fn/style/getScrollBarSize.js +5 -5
- package/dist/fn/style/lightenDarkenHex.js +2 -2
- package/dist/fn/style/outerHeight.js +2 -2
- package/dist/fn/style/outerWidth.js +2 -2
- package/dist/fn/style/resize.js +14 -14
- package/dist/fn/type/checkType.js +5 -9
- package/dist/fn/type/isArray.js +2 -7
- package/dist/fn/type/isBlob.js +2 -7
- package/dist/fn/type/isBoolean.js +2 -7
- package/dist/fn/type/isCanvas.js +2 -7
- package/dist/fn/type/isColor.js +2 -7
- package/dist/fn/type/isComment.js +2 -7
- package/dist/fn/type/isCp.js +3 -8
- package/dist/fn/type/isDataURL.js +2 -7
- package/dist/fn/type/isDate.js +2 -7
- package/dist/fn/type/isDimension.js +2 -7
- package/dist/fn/type/isDom.js +2 -7
- package/dist/fn/type/isEmail.js +3 -8
- package/dist/fn/type/isEvent.js +2 -7
- package/dist/fn/type/isFunction.js +2 -7
- package/dist/fn/type/isHostname.js +2 -7
- package/dist/fn/type/isIP.js +2 -7
- package/dist/fn/type/isInt.js +2 -7
- package/dist/fn/type/isIterable.js +2 -7
- package/dist/fn/type/isNotObject.js +2 -7
- package/dist/fn/type/isNull.js +2 -7
- package/dist/fn/type/isNumber.js +2 -7
- package/dist/fn/type/isObject.js +2 -7
- package/dist/fn/type/isPercent.js +2 -7
- package/dist/fn/type/isPrimitive.js +2 -7
- package/dist/fn/type/isPromise.js +2 -7
- package/dist/fn/type/isPropSize.js +2 -2
- package/dist/fn/type/isSQLDate.js +2 -7
- package/dist/fn/type/isSame.js +12 -12
- package/dist/fn/type/isString.js +2 -7
- package/dist/fn/type/isSymbol.js +2 -7
- package/dist/fn/type/isURL.js +2 -7
- package/dist/fn/type/isUid.js +2 -7
- package/dist/fn/type/isValidDimension.js +2 -2
- package/dist/fn/type/isValidName.js +2 -7
- package/dist/fn/type/isVue.js +4 -11
- package/dist/fn.js +247 -247
- package/dist/index.js +9 -7
- package/package.json +1 -1
package/dist/fn/html/isInside.js
CHANGED
|
@@ -2,17 +2,17 @@ import getAncestors from './getAncestors.js';
|
|
|
2
2
|
import isString from '../type/isString.js';
|
|
3
3
|
import each from '../loop/each.js';
|
|
4
4
|
export default function isInside(ele, ancestor) {
|
|
5
|
-
|
|
5
|
+
let ancestors = getAncestors(ele);
|
|
6
6
|
if (ancestors.length) {
|
|
7
7
|
if (isString(ancestor)) {
|
|
8
|
-
|
|
9
|
-
each(ancestors,
|
|
8
|
+
let ok = false;
|
|
9
|
+
each(ancestors, (a) => {
|
|
10
10
|
if (a.matches && a.matches(ancestor)) {
|
|
11
|
-
|
|
11
|
+
ok = true;
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
return
|
|
15
|
+
return ok;
|
|
16
16
|
}
|
|
17
17
|
if (ancestor instanceof HTMLElement) {
|
|
18
18
|
return ancestors.indexOf(ancestor) > -1;
|
|
@@ -7,8 +7,8 @@ import warning from '../browser/warning.js';
|
|
|
7
7
|
import isFunction from '../type/isFunction.js';
|
|
8
8
|
import isSame from '../type/isSame.js';
|
|
9
9
|
export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const parentString = (parent === null || parent === void 0 ? void 0 : parent.$cid) || '';
|
|
11
|
+
const prefix = '__bbn_' + (parentString ? parentString + '_' : '');
|
|
12
12
|
if (obj && typeof obj === 'object' && [undefined, Object, Array].includes(obj.constructor)) {
|
|
13
13
|
if (obj.__bbnIsProxy && obj.__bbnParent === parent) {
|
|
14
14
|
return obj;
|
|
@@ -24,23 +24,19 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
|
24
24
|
enumerable: false,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
get
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const handler = {
|
|
28
|
+
get(target, key) {
|
|
29
|
+
const realValue = Reflect.get(target, key);
|
|
30
|
+
const realTarget = target.__bbnRoot || target;
|
|
31
31
|
if (isSymbol(key)) {
|
|
32
32
|
return Reflect.get(realTarget, key);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const propName = parentProp ? parentProp + '.' + key : key;
|
|
35
|
+
const hiddenKey = prefix + (isNumber(key) ? key.toString() : key);
|
|
36
36
|
if (['fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'].includes(key) &&
|
|
37
37
|
isArray(target)) {
|
|
38
|
-
return function () {
|
|
39
|
-
|
|
40
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
41
|
-
args[_i] = arguments[_i];
|
|
42
|
-
}
|
|
43
|
-
var res = realTarget[key].apply(realTarget, args);
|
|
38
|
+
return function (...args) {
|
|
39
|
+
let res = realTarget[key](...args);
|
|
44
40
|
warning('DOING ARRAY STUFF');
|
|
45
41
|
log(target.__bbnParent);
|
|
46
42
|
onSet(target, 'length', parent);
|
|
@@ -51,7 +47,7 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
|
51
47
|
return realValue;
|
|
52
48
|
}
|
|
53
49
|
if (key === '__bbnRoot') {
|
|
54
|
-
|
|
50
|
+
let root = obj;
|
|
55
51
|
while (root && (root === null || root === void 0 ? void 0 : root.__bbnTarget)) {
|
|
56
52
|
root = root.__bbnTarget;
|
|
57
53
|
}
|
|
@@ -99,12 +95,12 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
|
99
95
|
}
|
|
100
96
|
return realValue;
|
|
101
97
|
},
|
|
102
|
-
set
|
|
98
|
+
set(target, key, value) {
|
|
103
99
|
if (isSymbol(key)) {
|
|
104
100
|
return Reflect.get(target, key, value);
|
|
105
101
|
}
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
const realTarget = target.__bbnRoot || target;
|
|
103
|
+
const propName = parentProp ? parentProp + '.' + key : key;
|
|
108
104
|
if (isSymbol(key)) {
|
|
109
105
|
return Reflect.get(target, key);
|
|
110
106
|
}
|
|
@@ -124,7 +120,7 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
|
124
120
|
if (value &&
|
|
125
121
|
typeof value === 'object' &&
|
|
126
122
|
[undefined, Object, Array].includes(value.constructor)) {
|
|
127
|
-
|
|
123
|
+
const hiddenKey = prefix + (isNumber(key) ? key.toString() : key);
|
|
128
124
|
Reflect.defineProperty(realTarget, hiddenKey, {
|
|
129
125
|
value: makeReactive(value, onSet, parent, propName),
|
|
130
126
|
writable: true,
|
|
@@ -151,14 +147,14 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
|
151
147
|
}
|
|
152
148
|
return true;
|
|
153
149
|
},
|
|
154
|
-
defineProperty
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
defineProperty(target, key, description) {
|
|
151
|
+
const realTarget = target;
|
|
152
|
+
const propName = parentProp ? parentProp + '.' + key : key;
|
|
157
153
|
if (key === '__bbnWatchers' || isSymbol(key) || key.indexOf('__bbn_') === 0) {
|
|
158
154
|
Reflect.defineProperty(realTarget, key, description);
|
|
159
155
|
}
|
|
160
156
|
else {
|
|
161
|
-
|
|
157
|
+
const hiddenKey = prefix + (isNumber(key) ? key.toString() : key);
|
|
162
158
|
Reflect.defineProperty(realTarget, hiddenKey, {
|
|
163
159
|
value: makeReactive(description.value, onSet, parent, propName),
|
|
164
160
|
writable: true,
|
|
@@ -169,13 +165,13 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
|
|
|
169
165
|
onSet(target, key, parent);
|
|
170
166
|
return true;
|
|
171
167
|
},
|
|
172
|
-
deleteProperty
|
|
173
|
-
|
|
168
|
+
deleteProperty(target, key) {
|
|
169
|
+
const realTarget = target;
|
|
174
170
|
if (key.indexOf('__bbn_') === 0) {
|
|
175
171
|
Reflect.deleteProperty(realTarget, key);
|
|
176
172
|
}
|
|
177
173
|
else {
|
|
178
|
-
|
|
174
|
+
const hiddenKey = prefix + (isNumber(key) ? key.toString() : key);
|
|
179
175
|
Reflect.deleteProperty(realTarget, hiddenKey);
|
|
180
176
|
Reflect.deleteProperty(target, key);
|
|
181
177
|
}
|
package/dist/fn/init.js
CHANGED
|
@@ -24,7 +24,7 @@ import timestamp from './datetime/timestamp.js';
|
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
26
|
export default function init(cfg, force) {
|
|
27
|
-
|
|
27
|
+
let parts;
|
|
28
28
|
if (!bbn.env.isInit) {
|
|
29
29
|
bbn.env.root =
|
|
30
30
|
document.baseURI.length > 0 ? document.baseURI : bbn.env.host;
|
|
@@ -66,7 +66,7 @@ export default function init(cfg, force) {
|
|
|
66
66
|
"weekOfYear",
|
|
67
67
|
"weekYear",
|
|
68
68
|
"weekday",
|
|
69
|
-
],
|
|
69
|
+
], (plugin) => {
|
|
70
70
|
if (window["dayjs_plugin_" + plugin]) {
|
|
71
71
|
dayjs.extend(window["dayjs_plugin_" + plugin]);
|
|
72
72
|
}
|
|
@@ -79,7 +79,7 @@ export default function init(cfg, force) {
|
|
|
79
79
|
bbn.env.path = substr(bbn.env.url, bbn.env.root.length);
|
|
80
80
|
parts = bbn.env.path.split("/");
|
|
81
81
|
//$.each(parts, function(i, v){
|
|
82
|
-
each(parts,
|
|
82
|
+
each(parts, (v, i) => {
|
|
83
83
|
v = decodeURI(v.trim());
|
|
84
84
|
if (v !== "") {
|
|
85
85
|
bbn.env.params.push(v);
|
|
@@ -89,11 +89,11 @@ export default function init(cfg, force) {
|
|
|
89
89
|
addColors(bbn.var.colors);
|
|
90
90
|
}
|
|
91
91
|
if (bbn.env.lang && undefined !== dayjs) {
|
|
92
|
-
import('dayjs/locale/' + bbn.env.lang + '.js').then(
|
|
92
|
+
import('dayjs/locale/' + bbn.env.lang + '.js').then(() => {
|
|
93
93
|
dayjs.locale(bbn.env.lang);
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
document.addEventListener("visibilitychange",
|
|
96
|
+
document.addEventListener("visibilitychange", () => {
|
|
97
97
|
if (document.hidden && bbn.env.isFocused) {
|
|
98
98
|
bbn.env.isFocused = false;
|
|
99
99
|
}
|
|
@@ -101,21 +101,21 @@ export default function init(cfg, force) {
|
|
|
101
101
|
bbn.env.isFocused = true;
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
-
document.addEventListener("focusin",
|
|
104
|
+
document.addEventListener("focusin", (e) => {
|
|
105
105
|
if (e.target instanceof HTMLElement &&
|
|
106
106
|
!e.target.classList.contains("bbn-no")) {
|
|
107
107
|
bbn.env.focused = e.target;
|
|
108
108
|
}
|
|
109
109
|
bbn.env.last_focus = timestamp();
|
|
110
110
|
});
|
|
111
|
-
document.addEventListener("click",
|
|
111
|
+
document.addEventListener("click", (e) => {
|
|
112
112
|
bbn.env.last_focus = timestamp();
|
|
113
113
|
if (bbn.env.nav !== "ajax") {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
let target = e.target;
|
|
117
117
|
if (target instanceof HTMLElement && target.tagName !== "A") {
|
|
118
|
-
|
|
118
|
+
let p = target;
|
|
119
119
|
while (p && p.tagName !== "A") {
|
|
120
120
|
if (p.tagName === "BODY") {
|
|
121
121
|
break;
|
|
@@ -139,18 +139,18 @@ export default function init(cfg, force) {
|
|
|
139
139
|
return false;
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
-
each(document.querySelectorAll("form:not(.bbn-no), form:not(.bbn-form)"),
|
|
143
|
-
ele.addEventListener("submit",
|
|
142
|
+
each(document.querySelectorAll("form:not(.bbn-no), form:not(.bbn-form)"), (ele) => {
|
|
143
|
+
ele.addEventListener("submit", (e) => {
|
|
144
144
|
submit(ele, e);
|
|
145
145
|
});
|
|
146
146
|
});
|
|
147
|
-
window.addEventListener("hashchange",
|
|
147
|
+
window.addEventListener("hashchange", () => {
|
|
148
148
|
bbn.env.hashChanged = new Date().getTime();
|
|
149
149
|
}, false);
|
|
150
|
-
window.addEventListener("resize",
|
|
150
|
+
window.addEventListener("resize", () => {
|
|
151
151
|
resize();
|
|
152
152
|
});
|
|
153
|
-
window.addEventListener("orientationchange",
|
|
153
|
+
window.addEventListener("orientationchange", () => {
|
|
154
154
|
resize();
|
|
155
155
|
});
|
|
156
156
|
resize();
|
|
@@ -162,11 +162,11 @@ export default function init(cfg, force) {
|
|
|
162
162
|
}
|
|
163
163
|
if (window.history) {
|
|
164
164
|
window.onpopstate = function (e) {
|
|
165
|
-
|
|
165
|
+
let h = window.history;
|
|
166
166
|
if (!bbn.env.historyDisabled && h) {
|
|
167
167
|
//e.preventDefault();
|
|
168
168
|
if (bbn.fn.defaultHistoryFunction(h.state)) {
|
|
169
|
-
|
|
169
|
+
let state = h.state;
|
|
170
170
|
if (state) {
|
|
171
171
|
//link(substr(state.url, bbn.env.root.length), $.extend({title: state.title}, state.data));
|
|
172
172
|
link(state.url, extend({ title: state.title || bbn.env.siteTitle }, state.data || {}));
|
|
@@ -178,10 +178,10 @@ export default function init(cfg, force) {
|
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
-
window.addEventListener('online',
|
|
181
|
+
window.addEventListener('online', () => {
|
|
182
182
|
bbn.env.online = true;
|
|
183
183
|
});
|
|
184
|
-
window.addEventListener('offline',
|
|
184
|
+
window.addEventListener('offline', () => {
|
|
185
185
|
bbn.env.online = false;
|
|
186
186
|
});
|
|
187
187
|
bbn.env.isInit = true;
|
package/dist/fn/loop/each.js
CHANGED
|
@@ -34,7 +34,7 @@ import iterate from './iterate.js';
|
|
|
34
34
|
*/
|
|
35
35
|
export default function each(arr, fn) {
|
|
36
36
|
if (isNumber(arr) && arr > 0) {
|
|
37
|
-
for (
|
|
37
|
+
for (let i = 0; i < arr; i++) {
|
|
38
38
|
if (fn(i, i) === false) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
@@ -42,7 +42,7 @@ export default function each(arr, fn) {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
if (isIterable(arr)) {
|
|
45
|
-
for (
|
|
45
|
+
for (let i = 0; i < arr.length; i++) {
|
|
46
46
|
if (fn(arr[i], i) === false) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
package/dist/fn/loop/fori.js
CHANGED
|
@@ -34,18 +34,16 @@ import isNumber from '../type/isNumber.js';
|
|
|
34
34
|
* @param {Number} min The index at which the loop will start
|
|
35
35
|
* @returns {undefined}
|
|
36
36
|
*/
|
|
37
|
-
export default function fori(arr, fn, max, min) {
|
|
38
|
-
if (max === void 0) { max = arr.length - 1; }
|
|
39
|
-
if (min === void 0) { min = 0; }
|
|
37
|
+
export default function fori(arr, fn, max = arr.length - 1, min = 0) {
|
|
40
38
|
if (isArray(arr)) {
|
|
41
|
-
|
|
39
|
+
let realMax = arr.length - 1;
|
|
42
40
|
if (!isNumber(max) || !(0 < max && max <= realMax)) {
|
|
43
41
|
max = realMax;
|
|
44
42
|
}
|
|
45
43
|
if (!isNumber(min) || !(0 <= min && min < realMax) || min > max) {
|
|
46
44
|
min = 0;
|
|
47
45
|
}
|
|
48
|
-
for (
|
|
46
|
+
for (let i = min; i <= max; i++) {
|
|
49
47
|
if (fn(arr[i], i) === false) {
|
|
50
48
|
return;
|
|
51
49
|
}
|
package/dist/fn/loop/forir.js
CHANGED
|
@@ -34,18 +34,16 @@ import isNumber from '../type/isNumber.js';
|
|
|
34
34
|
* @param {Number} min The index at which the loop will start
|
|
35
35
|
* @returns {undefined}
|
|
36
36
|
*/
|
|
37
|
-
export default function forir(arr, fn, max, min) {
|
|
38
|
-
if (max === void 0) { max = arr.length - 1; }
|
|
39
|
-
if (min === void 0) { min = 0; }
|
|
37
|
+
export default function forir(arr, fn, max = arr.length - 1, min = 0) {
|
|
40
38
|
if (isArray(arr)) {
|
|
41
|
-
|
|
39
|
+
let realMax = arr.length - 1;
|
|
42
40
|
if (!isNumber(max) || !(0 < max && max <= realMax)) {
|
|
43
41
|
max = realMax;
|
|
44
42
|
}
|
|
45
43
|
if (!isNumber(min) || !(0 <= min && min < realMax) || min > max) {
|
|
46
44
|
min = 0;
|
|
47
45
|
}
|
|
48
|
-
for (
|
|
46
|
+
for (let i = max; i >= min; i--) {
|
|
49
47
|
if (fn(arr[i], i) === false) {
|
|
50
48
|
return;
|
|
51
49
|
}
|
package/dist/fn/loop/iterate.js
CHANGED
|
@@ -19,16 +19,13 @@ import removePrivateProp from '../object/removePrivateProp.js';
|
|
|
19
19
|
* @param {Boolean} reverse If set to true the order of the keys will be reversed
|
|
20
20
|
* @returns {Object}
|
|
21
21
|
*/
|
|
22
|
-
export default function iterate(obj, fn, noPrivate, reverse) {
|
|
23
|
-
if (noPrivate === void 0) { noPrivate = false; }
|
|
24
|
-
if (reverse === void 0) { reverse = false; }
|
|
22
|
+
export default function iterate(obj, fn, noPrivate = false, reverse = false) {
|
|
25
23
|
if (obj !== null && typeof obj === "object") {
|
|
26
|
-
|
|
24
|
+
let iter = Object.keys(noPrivate ? removePrivateProp(obj) : obj);
|
|
27
25
|
if (reverse) {
|
|
28
26
|
iter.reverse();
|
|
29
27
|
}
|
|
30
|
-
for (
|
|
31
|
-
var prop = iter_1[_i];
|
|
28
|
+
for (let prop of iter) {
|
|
32
29
|
if (fn(obj[prop], prop) === false) {
|
|
33
30
|
break;
|
|
34
31
|
}
|
package/dist/fn/loop/riterate.js
CHANGED
|
@@ -18,8 +18,7 @@ import iterate from './iterate.js';
|
|
|
18
18
|
* @param {Boolean} noPrivate If set to true the _private_ properties won't be included
|
|
19
19
|
* @returns {Object}
|
|
20
20
|
*/
|
|
21
|
-
export default function riterate(obj, fn, noPrivate) {
|
|
22
|
-
if (noPrivate === void 0) { noPrivate = false; }
|
|
21
|
+
export default function riterate(obj, fn, noPrivate = false) {
|
|
23
22
|
return iterate(obj, fn, noPrivate, true);
|
|
24
23
|
}
|
|
25
24
|
;
|
|
@@ -8,30 +8,30 @@ import md5 from "../string/md5.js";
|
|
|
8
8
|
* @throws {Error} When unexpected syntax is encountered while parsing.
|
|
9
9
|
*/
|
|
10
10
|
export default function analyzeFunction(fn) {
|
|
11
|
-
|
|
11
|
+
const all = typeof fn === "function" ? fn.toString() : fn;
|
|
12
12
|
if (typeof all !== "string") {
|
|
13
13
|
throw Error("Unexpected type " + typeof fn + " while parsing function");
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
for (
|
|
15
|
+
let exp = "";
|
|
16
|
+
let isArrow = false;
|
|
17
|
+
let isAsync = false;
|
|
18
|
+
let hasFunction = false;
|
|
19
|
+
let name = "";
|
|
20
|
+
let parOpened = 0;
|
|
21
|
+
let parClosed = 0;
|
|
22
|
+
let args = [];
|
|
23
|
+
let currentArg = {};
|
|
24
|
+
let body;
|
|
25
|
+
let currentQuote = "";
|
|
26
|
+
let escapable = ['"', "'", "`"];
|
|
27
|
+
let isEscaped = false;
|
|
28
|
+
let settingDefault = false;
|
|
29
|
+
let isComment = false;
|
|
30
|
+
let isCommentLine = false;
|
|
31
|
+
let isDestructuring = false;
|
|
32
|
+
let isBinary = false;
|
|
33
|
+
let returnType = "";
|
|
34
|
+
for (let i = 0; i < all.length; i++) {
|
|
35
35
|
// Handle string literals
|
|
36
36
|
if (!isComment && all[i] === "/" && all[i + 1] === "*") {
|
|
37
37
|
isComment = true;
|
|
@@ -70,7 +70,7 @@ export default function analyzeFunction(fn) {
|
|
|
70
70
|
}
|
|
71
71
|
else if (exp.trim() !== "async") {
|
|
72
72
|
name = exp.trim();
|
|
73
|
-
|
|
73
|
+
let tmp = name.match(/^([a-zA-Z0-9_]+)<[a-zA-Z0-9_]+>$/);
|
|
74
74
|
if (tmp) {
|
|
75
75
|
name = tmp[1];
|
|
76
76
|
}
|
|
@@ -99,7 +99,7 @@ export default function analyzeFunction(fn) {
|
|
|
99
99
|
exp += all[i];
|
|
100
100
|
}
|
|
101
101
|
else if (parOpened && parOpened === parClosed && all[i] === ":") {
|
|
102
|
-
|
|
102
|
+
const matches = all.substring(i + 1).trim().match(/^\s*([a-zA-Z0-9_]+)\s*\{/);
|
|
103
103
|
if (!matches) {
|
|
104
104
|
throw Error("Unexpected ':' while parsing function");
|
|
105
105
|
}
|
|
@@ -206,21 +206,21 @@ export default function analyzeFunction(fn) {
|
|
|
206
206
|
if (body.substr(0, 25).indexOf('[native code]') > -1) {
|
|
207
207
|
isBinary = true;
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
.map(
|
|
209
|
+
const argString = args
|
|
210
|
+
.map((arg) => arg.name + (arg.default ? " = " + arg.default : ""))
|
|
211
211
|
.join(", ");
|
|
212
|
-
|
|
212
|
+
const hash = md5(body + (name ? "-" + name : "") + (argString ? "-" + argString : ""));
|
|
213
213
|
return {
|
|
214
|
-
body
|
|
215
|
-
args
|
|
216
|
-
argString
|
|
217
|
-
isArrow
|
|
218
|
-
hasFunction
|
|
219
|
-
name
|
|
220
|
-
isAsync
|
|
221
|
-
isBinary
|
|
222
|
-
hash
|
|
223
|
-
returnType
|
|
214
|
+
body,
|
|
215
|
+
args,
|
|
216
|
+
argString,
|
|
217
|
+
isArrow,
|
|
218
|
+
hasFunction,
|
|
219
|
+
name,
|
|
220
|
+
isAsync,
|
|
221
|
+
isBinary,
|
|
222
|
+
hash,
|
|
223
|
+
returnType
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
;
|
package/dist/fn/misc/money.js
CHANGED
|
@@ -82,7 +82,7 @@ export default function money(val, kilo, currency, novalue, decimal, thousands,
|
|
|
82
82
|
precision = kilo ? 3 : 0;
|
|
83
83
|
}
|
|
84
84
|
if ((val === 0) && (typeof precision === 'number') && (precision > 0)) {
|
|
85
|
-
|
|
85
|
+
let res = val.toFixed(precision).replace('.', decimal);
|
|
86
86
|
if (currency) {
|
|
87
87
|
res += ' ' + (kilo ? 'K' + currency : currency);
|
|
88
88
|
}
|
|
@@ -106,9 +106,9 @@ export default function money(val, kilo, currency, novalue, decimal, thousands,
|
|
|
106
106
|
currency = 'K' + currency;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
let v = val.toFixed(precision);
|
|
110
|
+
let decimalPosition = 0;
|
|
111
|
+
let decimalIdx = 10000;
|
|
112
112
|
if (v) {
|
|
113
113
|
decimalIdx = v.indexOf('.');
|
|
114
114
|
if (decimalIdx <= 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import iterate from '../loop/iterate.js';
|
|
2
2
|
export default function translate(o, namespace) {
|
|
3
|
-
|
|
4
|
-
iterate(o,
|
|
3
|
+
let lng = namespace ? bbn.lng[namespace.indexOf('_') === 0 ? namespace : '_' + namespace] : bbn.lng;
|
|
4
|
+
iterate(o, (v, k) => {
|
|
5
5
|
lng[k] = v;
|
|
6
6
|
});
|
|
7
7
|
}
|
|
@@ -40,9 +40,8 @@ import isDate from '../type/isDate.js';
|
|
|
40
40
|
* @param {String} [dir=asc] Direction of comparison (desc or asc by default)
|
|
41
41
|
* @returns {Number} Always either -1, 1, or 0
|
|
42
42
|
*/
|
|
43
|
-
export default function _compareValues(a, b, prop, dir) {
|
|
44
|
-
|
|
45
|
-
var va = getProperty(a, prop), vb = getProperty(b, prop), ta = (typeof va).toLowerCase(), tb = (typeof vb).toLowerCase();
|
|
43
|
+
export default function _compareValues(a, b, prop, dir = "asc") {
|
|
44
|
+
let va = getProperty(a, prop), vb = getProperty(b, prop), ta = (typeof va).toLowerCase(), tb = (typeof vb).toLowerCase();
|
|
46
45
|
if (dir !== "asc" && isString(dir) && dir.toLowerCase() === "desc") {
|
|
47
46
|
dir = "desc";
|
|
48
47
|
}
|
|
@@ -47,10 +47,7 @@ import compareConditions from './compareConditions.js';
|
|
|
47
47
|
* @param {String} operator The operator to use for comparison with the value as used in bbn.fn.compare
|
|
48
48
|
* @returns {Array} A new filtered array
|
|
49
49
|
*/
|
|
50
|
-
export default function _filter(arr, prop, val, operator, limit) {
|
|
51
|
-
if (val === void 0) { val = null; }
|
|
52
|
-
if (operator === void 0) { operator = '='; }
|
|
53
|
-
if (limit === void 0) { limit = 0; }
|
|
50
|
+
export default function _filter(arr, prop, val = null, operator = '=', limit = 0) {
|
|
54
51
|
if (!isArray(arr)) {
|
|
55
52
|
try {
|
|
56
53
|
arr = Array.from(arr);
|
|
@@ -60,9 +57,9 @@ export default function _filter(arr, prop, val, operator, limit) {
|
|
|
60
57
|
throw new Error('Error in filter: The first argument must be an array');
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
let cfg = {};
|
|
61
|
+
const res = [];
|
|
62
|
+
const isFn = typeof (prop) === 'function';
|
|
66
63
|
if (!prop || !arr.length) {
|
|
67
64
|
return arr;
|
|
68
65
|
}
|
|
@@ -76,14 +73,14 @@ export default function _filter(arr, prop, val, operator, limit) {
|
|
|
76
73
|
else if (!isFn) {
|
|
77
74
|
throw new Error('Search function error: The prop argument should be a string or an object');
|
|
78
75
|
}
|
|
79
|
-
|
|
76
|
+
let fn;
|
|
80
77
|
if (typeof (prop) === 'function') {
|
|
81
78
|
fn = prop;
|
|
82
79
|
}
|
|
83
80
|
else {
|
|
84
|
-
fn =
|
|
81
|
+
fn = (a, i) => compareConditions(a, cfg);
|
|
85
82
|
}
|
|
86
|
-
for (
|
|
83
|
+
for (let i = 0; i < arr.length; i++) {
|
|
87
84
|
bbn.env._enumerated.push(true);
|
|
88
85
|
if (fn(arr[i], i)) {
|
|
89
86
|
bbn.env._enumerated.pop();
|
|
@@ -32,8 +32,8 @@ import getProperty from './getProperty.js';
|
|
|
32
32
|
* @returns {Array} The new array
|
|
33
33
|
*/
|
|
34
34
|
export default function arrayFromProp(arr, prop) {
|
|
35
|
-
|
|
36
|
-
each(arr,
|
|
35
|
+
let r = [];
|
|
36
|
+
each(arr, (a, i) => {
|
|
37
37
|
r.push(getProperty(a, prop));
|
|
38
38
|
});
|
|
39
39
|
return r;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import checkPropsDetails from './checkPropsDetails.js';
|
|
2
|
-
export default function checkProps(obj, props, checkEmpty) {
|
|
3
|
-
if (checkEmpty === void 0) { checkEmpty = false; }
|
|
2
|
+
export default function checkProps(obj, props, checkEmpty = false) {
|
|
4
3
|
return checkPropsDetails(obj, props, checkEmpty).result;
|
|
5
4
|
}
|
|
6
5
|
;
|
|
@@ -2,9 +2,8 @@ import isArray from '../type/isArray.js';
|
|
|
2
2
|
import isObject from '../type/isObject.js';
|
|
3
3
|
import each from '../loop/each.js';
|
|
4
4
|
import substr from '../string/substr.js';
|
|
5
|
-
export default function checkPropsDetails(obj, props, checkEmpty) {
|
|
6
|
-
|
|
7
|
-
var res = {
|
|
5
|
+
export default function checkPropsDetails(obj, props, checkEmpty = false) {
|
|
6
|
+
let res = {
|
|
8
7
|
error: false,
|
|
9
8
|
result: true,
|
|
10
9
|
};
|
|
@@ -18,23 +17,23 @@ export default function checkPropsDetails(obj, props, checkEmpty) {
|
|
|
18
17
|
res.error = bbn._("checkProps must receive an object as obj argument");
|
|
19
18
|
}
|
|
20
19
|
if (!res.error) {
|
|
21
|
-
|
|
22
|
-
each(props,
|
|
20
|
+
let check;
|
|
21
|
+
each(props, (varName) => {
|
|
23
22
|
varName = varName.trim().split(":");
|
|
24
|
-
|
|
23
|
+
let type = varName[1] || false;
|
|
25
24
|
varName = varName[0];
|
|
26
25
|
if (obj[varName] === undefined) {
|
|
27
26
|
res.error = varName + " " + bbn._("is not defined");
|
|
28
27
|
}
|
|
29
28
|
else if (type) {
|
|
30
|
-
|
|
29
|
+
check =
|
|
31
30
|
"is" +
|
|
32
31
|
substr(type, 0, 1).toUpperCase() +
|
|
33
32
|
substr(type, 1).toLowerCase();
|
|
34
|
-
if (bbn.fn[
|
|
33
|
+
if (bbn.fn[check] === undefined) {
|
|
35
34
|
res.error = type + " " + bbn._("is not a valid type");
|
|
36
35
|
}
|
|
37
|
-
else if (!bbn.fn[
|
|
36
|
+
else if (!bbn.fn[check](obj[varName])) {
|
|
38
37
|
res.error = varName + " " + bbn._("is not a") + " " + type;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import checkPropsDetails from './checkPropsDetails.js';
|
|
2
|
-
export default function checkPropsOrDie(obj, props, checkEmpty) {
|
|
3
|
-
|
|
4
|
-
var res = checkPropsDetails(obj, props, checkEmpty);
|
|
2
|
+
export default function checkPropsOrDie(obj, props, checkEmpty = false) {
|
|
3
|
+
let res = checkPropsDetails(obj, props, checkEmpty);
|
|
5
4
|
if (res.error) {
|
|
6
5
|
throw new Error(res.error);
|
|
7
6
|
}
|
|
@@ -6,8 +6,8 @@ import isCp from '../type/isCp.js';
|
|
|
6
6
|
* @returns Function
|
|
7
7
|
*/
|
|
8
8
|
export default function circularReplacer() {
|
|
9
|
-
|
|
10
|
-
return
|
|
9
|
+
const visited = new WeakSet();
|
|
10
|
+
return (key, value) => {
|
|
11
11
|
if (typeof value === "object" && value !== null) {
|
|
12
12
|
if (visited.has(value)) {
|
|
13
13
|
return;
|
package/dist/fn/object/clone.js
CHANGED
|
@@ -20,12 +20,12 @@ import extend from './extend.js';
|
|
|
20
20
|
*/
|
|
21
21
|
export default function clone(obj) {
|
|
22
22
|
if (isArray(obj)) {
|
|
23
|
-
return obj.slice().map(
|
|
23
|
+
return obj.slice().map((a) => {
|
|
24
24
|
return typeof a === "object" ? clone(a) : a;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
if (isObject(obj)) {
|
|
28
|
-
|
|
28
|
+
const o = Object.create(Object.getPrototypeOf(obj));
|
|
29
29
|
return extend(true, o, obj);
|
|
30
30
|
}
|
|
31
31
|
return obj;
|