arisu.js 1.0.3 → 1.0.4
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/README.md +6 -4
- package/dist/arisu.commonjs.min.js +1 -1
- package/dist/arisu.js +468 -189
- package/dist/arisu.min.js +1 -1
- package/dist/arisu.module.min.js +1 -1
- package/dist/arisu.window.min.js +1 -1
- package/package.json +1 -1
- package/src/js/base.js +200 -122
- package/src/js/main.js +11 -4
- package/src/js/utils.js +256 -63
- package/webpack.config.js +20 -20
- package/deprecated/arisu-1.2.js +0 -3307
- package/deprecated/arisu-1.3.js +0 -3718
- package/deprecated/arisu.min.js +0 -1
- package/deprecated/base-2.0.js +0 -948
- package/deprecated/early/base-1.2.js +0 -1090
- package/deprecated/export-method.js +0 -467
- package/deprecated/jquery.module.js +0 -299
- package/deprecated/jquery.template.js +0 -82
- package/deprecated/main-2.0.js +0 -278
- package/deprecated/single-vue.js +0 -47
- package/deprecated/single.js +0 -130
- package/deprecated/utils-1.2.js +0 -2774
package/src/js/base.js
CHANGED
|
@@ -124,14 +124,14 @@
|
|
|
124
124
|
if(b.isNull(变量)) {
|
|
125
125
|
// 如果为空设置默认值
|
|
126
126
|
b.setDefault(data.id, 0);
|
|
127
|
+
// 判断变量是否为对象
|
|
128
|
+
console.log(b.isObject(custom));
|
|
127
129
|
// 获取两个数组中的相同值
|
|
128
130
|
b.same([1,2], [7,9,4,2,5,6,1]) //[1, 2]
|
|
129
131
|
// 获取两个数组中的不相同值
|
|
130
132
|
b.different([1,2], [7,9,4,2,5,6,1]) //[7, 9, 4, 5, 6]
|
|
131
133
|
// 判断字符串是否为html标签,如<li></li><div></div><img/>返回true
|
|
132
134
|
console.log(b.isHtmlTag('<img />')); // true
|
|
133
|
-
// 判断变量是否为对象
|
|
134
|
-
console.log(b.isObject(custom));
|
|
135
135
|
// 允许插件扩展plugin静态方法
|
|
136
136
|
// 普通方法
|
|
137
137
|
function test(p1, p2) { console.log(this, p1, p2) } //Base... 3 4
|
|
@@ -661,38 +661,74 @@ class Base {
|
|
|
661
661
|
}
|
|
662
662
|
|
|
663
663
|
// data属性绑定设置
|
|
664
|
+
// data( key, value ) {
|
|
665
|
+
// if ( key === undefined ) {
|
|
666
|
+
// throw new Error('读取的或设置的键值不能为空');
|
|
667
|
+
// }
|
|
668
|
+
//
|
|
669
|
+
// let cache,
|
|
670
|
+
// elem = this.elements[0],
|
|
671
|
+
// // 获取与元素关联的缓存对象
|
|
672
|
+
// id = Base.expando,
|
|
673
|
+
// isCache = id && Base.cache[ id ];
|
|
674
|
+
//
|
|
675
|
+
// if ( value !== undefined ) {
|
|
676
|
+
// // 如果尚未创建缓存对象,则创建它
|
|
677
|
+
// if ( !isCache ) {
|
|
678
|
+
// cache = {};
|
|
679
|
+
// // 生成唯一的缓存键
|
|
680
|
+
// elem[ Base.expando ] = cache[ Base.expando ] = id;
|
|
681
|
+
// // 将缓存对象存储在全局 Base.cache 中
|
|
682
|
+
// Base.cache[ id ] = isCache = cache;
|
|
683
|
+
// }
|
|
684
|
+
// // 存储数据到缓存对象中
|
|
685
|
+
// isCache[ Base.camelCase( key ) ] = value;
|
|
686
|
+
// return this;
|
|
687
|
+
// } else {
|
|
688
|
+
// // console.log(isCache)
|
|
689
|
+
// // console.log(elem)
|
|
690
|
+
// if (!isCache)
|
|
691
|
+
// return undefined;
|
|
692
|
+
// else
|
|
693
|
+
// return isCache[ Base.camelCase( key ) ] ? isCache[ Base.camelCase( key ) ] : Base.dataAttr( elem, Base.camelCase( key ) )
|
|
694
|
+
// }
|
|
695
|
+
// }
|
|
696
|
+
|
|
697
|
+
// 清除data属性绑定的值
|
|
698
|
+
// removeData( key ) {
|
|
699
|
+
// delete Base.cache[ Base.expando ][ key ];
|
|
700
|
+
// }
|
|
701
|
+
|
|
664
702
|
data( key, value ) {
|
|
665
703
|
if ( key === undefined ) {
|
|
666
704
|
throw new Error('读取的或设置的键值不能为空');
|
|
667
705
|
}
|
|
668
|
-
|
|
669
|
-
let cache,
|
|
670
|
-
elem = this.elements[0],
|
|
671
|
-
// 获取与元素关联的缓存对象
|
|
672
|
-
id = Base.expando,
|
|
673
|
-
isCache = id && Base.cache[ id ];
|
|
674
|
-
|
|
706
|
+
let element = this.elements[0];
|
|
675
707
|
if ( value !== undefined ) {
|
|
676
|
-
//
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
//
|
|
680
|
-
|
|
681
|
-
// 将缓存对象存储在全局 Base.cache 中
|
|
682
|
-
Base.cache[ id ] = isCache = cache;
|
|
708
|
+
// 获取与元素关联的数据映射,如果不存在则创建一个新的
|
|
709
|
+
let dataMap = Base.elementData.get( element );
|
|
710
|
+
if (!dataMap) {
|
|
711
|
+
dataMap = new Map(); // 使用Map来存储元素的数据
|
|
712
|
+
Base.elementData.set( element, dataMap );
|
|
683
713
|
}
|
|
684
|
-
|
|
685
|
-
|
|
714
|
+
|
|
715
|
+
// 存储数据
|
|
716
|
+
dataMap.set( Base.camelCase( key ), value );
|
|
686
717
|
return this;
|
|
687
718
|
} else {
|
|
688
|
-
|
|
689
|
-
|
|
719
|
+
const dataMap = Base.elementData.get(element);
|
|
720
|
+
// 如果数据映射存在且包含该key,则返回其值;否则返回undefined
|
|
721
|
+
return dataMap ? dataMap.get(Base.camelCase( key )) : Base.dataAttr( element, key );
|
|
690
722
|
}
|
|
691
723
|
}
|
|
692
724
|
|
|
693
725
|
// 清除data属性绑定的值
|
|
694
726
|
removeData( key ) {
|
|
695
|
-
|
|
727
|
+
let element = this.elements[0];
|
|
728
|
+
let dataMap = Base.elementData.get( element );
|
|
729
|
+
if (dataMap) {
|
|
730
|
+
dataMap.set( Base.camelCase( key ), undefined );
|
|
731
|
+
}
|
|
696
732
|
}
|
|
697
733
|
|
|
698
734
|
// attr 方法实现
|
|
@@ -953,100 +989,135 @@ class Base {
|
|
|
953
989
|
// 标签消失高度变0的关闭动画,300MS刚刚好
|
|
954
990
|
slideUp(duration, callback) {
|
|
955
991
|
const options = b.extend({ duration: duration, callback: callback }, { duration: 300, callback: false })
|
|
992
|
+
// return this.each((element) => {
|
|
993
|
+
// const computedStyle = window.getComputedStyle(element),
|
|
994
|
+
// height = element.offsetHeight;
|
|
995
|
+
//
|
|
996
|
+
// let paddingTop = computedStyle.getPropertyValue('padding-top'),
|
|
997
|
+
// paddingBottom = computedStyle.getPropertyValue('padding-bottom'),
|
|
998
|
+
// marginTop = computedStyle.getPropertyValue('margin-top'),
|
|
999
|
+
// marginBottom = computedStyle.getPropertyValue('margin-bottom');
|
|
1000
|
+
// if (paddingTop && paddingTop.includes('px'))
|
|
1001
|
+
// paddingTop = paddingTop.replace(/px/g, '');
|
|
1002
|
+
// if (paddingBottom && paddingBottom.includes('px'))
|
|
1003
|
+
// paddingBottom = paddingBottom.replace(/px/g, '');
|
|
1004
|
+
// if (marginTop && marginTop.includes('px'))
|
|
1005
|
+
// marginTop = marginTop.replace(/px/g, '');
|
|
1006
|
+
// if (marginBottom && marginBottom.includes('px'))
|
|
1007
|
+
// marginBottom = marginBottom.replace(/px/g, '');
|
|
1008
|
+
//
|
|
1009
|
+
// // element.style.transition = 'height ' + options.duration + 'ms ease-in-out';
|
|
1010
|
+
// element.style.transition = 'none';
|
|
1011
|
+
// element.style.overflow = 'hidden'; // 隐藏超出元素的内容
|
|
1012
|
+
//
|
|
1013
|
+
// function step(startTime) {
|
|
1014
|
+
// const now = performance.now(),
|
|
1015
|
+
// timeElapsed = now - startTime,
|
|
1016
|
+
// newHeight = Math.max(0, height - (timeElapsed / options.duration) * height),// 计算当前应该设置的高度
|
|
1017
|
+
// newPaddingTop = Math.max(0, paddingTop - (timeElapsed / options.duration) * paddingTop),
|
|
1018
|
+
// newPaddingBottom = Math.max(0, paddingBottom - (timeElapsed / options.duration) * paddingBottom),
|
|
1019
|
+
// newMarginTop = Math.max(0, marginTop - (timeElapsed / options.duration) * marginTop),
|
|
1020
|
+
// newMarginBottom = Math.max(0, marginBottom - (timeElapsed / options.duration) * marginBottom);
|
|
1021
|
+
// element.style.height = newHeight + `px`;
|
|
1022
|
+
// element.style.paddingTop = newPaddingTop + `px`;
|
|
1023
|
+
// element.style.paddingBottom = newPaddingBottom + `px`;
|
|
1024
|
+
// element.style.marginTop = newMarginTop + `px`;
|
|
1025
|
+
// element.style.marginBottom = newMarginBottom + `px`;
|
|
1026
|
+
// // 如果还没到达目标高度,则继续下一帧
|
|
1027
|
+
// if (timeElapsed < options.duration) {
|
|
1028
|
+
// requestAnimationFrame(step.bind(null, startTime));
|
|
1029
|
+
// } else {
|
|
1030
|
+
// // 过渡完成后清除过渡效果,以便后续操作
|
|
1031
|
+
// element.style.transition = '';
|
|
1032
|
+
// element.style.height = '';
|
|
1033
|
+
// element.style.display = 'none';
|
|
1034
|
+
// options.callback && options.callback();
|
|
1035
|
+
// }
|
|
1036
|
+
// }
|
|
1037
|
+
// requestAnimationFrame(step);
|
|
1038
|
+
// });
|
|
956
1039
|
return this.each((element) => {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
if (marginBottom && marginBottom.includes('px'))
|
|
971
|
-
marginBottom = marginBottom.replace(/px/g, '');
|
|
972
|
-
|
|
973
|
-
// element.style.transition = 'height ' + options.duration + 'ms ease-in-out';
|
|
974
|
-
element.style.transition = 'none';
|
|
975
|
-
element.style.overflow = 'hidden'; // 隐藏超出元素的内容
|
|
976
|
-
|
|
977
|
-
function step(startTime) {
|
|
978
|
-
const now = performance.now(),
|
|
979
|
-
timeElapsed = now - startTime,
|
|
980
|
-
newHeight = Math.max(0, height - (timeElapsed / options.duration) * height),// 计算当前应该设置的高度
|
|
981
|
-
newPaddingTop = Math.max(0, paddingTop - (timeElapsed / options.duration) * paddingTop),
|
|
982
|
-
newPaddingBottom = Math.max(0, paddingBottom - (timeElapsed / options.duration) * paddingBottom),
|
|
983
|
-
newMarginTop = Math.max(0, marginTop - (timeElapsed / options.duration) * marginTop),
|
|
984
|
-
newMarginBottom = Math.max(0, marginBottom - (timeElapsed / options.duration) * marginBottom);
|
|
985
|
-
element.style.height = newHeight + `px`;
|
|
986
|
-
element.style.paddingTop = newPaddingTop + `px`;
|
|
987
|
-
element.style.paddingBottom = newPaddingBottom + `px`;
|
|
988
|
-
element.style.marginTop = newMarginTop + `px`;
|
|
989
|
-
element.style.marginBottom = newMarginBottom + `px`;
|
|
990
|
-
// 如果还没到达目标高度,则继续下一帧
|
|
991
|
-
if (timeElapsed < options.duration) {
|
|
992
|
-
requestAnimationFrame(step.bind(null, startTime));
|
|
993
|
-
} else {
|
|
994
|
-
// 过渡完成后清除过渡效果,以便后续操作
|
|
995
|
-
element.style.transition = '';
|
|
996
|
-
element.style.height = '';
|
|
997
|
-
element.style.display = 'none';
|
|
998
|
-
options.callback && options.callback();
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
requestAnimationFrame(step);
|
|
1040
|
+
element.style.height = element.scrollHeight + "px";
|
|
1041
|
+
element.style.overflow = 'hidden';
|
|
1042
|
+
element.style.transition = `height ${options.duration}ms ease-in-out`;
|
|
1043
|
+
setTimeout(() => {
|
|
1044
|
+
element.style.height = '0px';
|
|
1045
|
+
}, options.duration / 100);
|
|
1046
|
+
setTimeout(() => {
|
|
1047
|
+
element.style.display = 'none';
|
|
1048
|
+
element.style.overflow = '';
|
|
1049
|
+
element.style.transition = '';
|
|
1050
|
+
element.style.height = '';
|
|
1051
|
+
if (options.callback && typeof options.callback === 'function') options.callback(element);
|
|
1052
|
+
}, options.duration - options.duration / 100);
|
|
1002
1053
|
});
|
|
1003
1054
|
}
|
|
1004
1055
|
|
|
1005
1056
|
// 标签显示高度变复原的打开动画
|
|
1006
1057
|
slideDown(duration, callback) {
|
|
1007
1058
|
const options = b.extend({ duration: duration, callback: callback }, { duration: 300, callback: false })
|
|
1059
|
+
// return this.each((element) => {
|
|
1060
|
+
// // 获取元素当前的高度和初始的 display 状态
|
|
1061
|
+
// let startHeight = element.offsetHeight,
|
|
1062
|
+
// display = element.style.display,
|
|
1063
|
+
// mainDuration = options.duration * 7 / 10,
|
|
1064
|
+
// pmDuration = options.duration * 3 / 10;
|
|
1065
|
+
// if (display === 'none') {
|
|
1066
|
+
// element.style.display = '';
|
|
1067
|
+
// startHeight = 0; // 如果元素是隐藏的,则从 0 开始
|
|
1068
|
+
// }
|
|
1069
|
+
//
|
|
1070
|
+
// let endHeight = element.scrollHeight, // 目标高度是元素的 scrollHeight
|
|
1071
|
+
// changeHeight = endHeight - startHeight,
|
|
1072
|
+
// startTime = null;
|
|
1073
|
+
//
|
|
1074
|
+
// // 动画函数
|
|
1075
|
+
// function step(timestamp) {
|
|
1076
|
+
// if (!startTime) startTime = timestamp;
|
|
1077
|
+
// let progress = timestamp - startTime;
|
|
1078
|
+
// if (progress > mainDuration) progress = mainDuration;
|
|
1079
|
+
// let newHeight = ease(progress, startHeight, changeHeight, mainDuration);
|
|
1080
|
+
// element.style.height = newHeight + 'px';
|
|
1081
|
+
//
|
|
1082
|
+
// if (progress < mainDuration) {
|
|
1083
|
+
// window.requestAnimationFrame(step);
|
|
1084
|
+
// } else {
|
|
1085
|
+
// element.style.transition = 'padding ' + pmDuration + 'ms ease, margin ' + pmDuration + 'ms ease';
|
|
1086
|
+
// // element.style.transition = 'all ' + pmDuration + 'ms ease';
|
|
1087
|
+
// element.style.margin = '';
|
|
1088
|
+
// element.style.padding = '';
|
|
1089
|
+
// element.style.height = '';
|
|
1090
|
+
// options.callback && options.callback();
|
|
1091
|
+
// }
|
|
1092
|
+
// }
|
|
1093
|
+
// // 线性缓动函数
|
|
1094
|
+
// function ease(t, b, c, d) {
|
|
1095
|
+
// t /= d / 2;
|
|
1096
|
+
// if (t < 1) return c / 2 * t * t + b;
|
|
1097
|
+
// t--;
|
|
1098
|
+
// return -c / 2 * (t * (t - 2) - 1) + b;
|
|
1099
|
+
// }
|
|
1100
|
+
// window.requestAnimationFrame(step);
|
|
1101
|
+
// });
|
|
1008
1102
|
return this.each((element) => {
|
|
1009
1103
|
// 获取元素当前的高度和初始的 display 状态
|
|
1010
1104
|
let startHeight = element.offsetHeight,
|
|
1011
|
-
display = element.style.display
|
|
1012
|
-
mainDuration = options.duration * 7 / 10,
|
|
1013
|
-
pmDuration = options.duration * 3 / 10;
|
|
1105
|
+
display = element.style.display;
|
|
1014
1106
|
if (display === 'none') {
|
|
1015
1107
|
element.style.display = '';
|
|
1016
1108
|
startHeight = 0; // 如果元素是隐藏的,则从 0 开始
|
|
1017
1109
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
if (
|
|
1028
|
-
|
|
1029
|
-
element.style.height = newHeight + 'px';
|
|
1030
|
-
|
|
1031
|
-
if (progress < mainDuration) {
|
|
1032
|
-
window.requestAnimationFrame(step);
|
|
1033
|
-
} else {
|
|
1034
|
-
element.style.transition = 'padding ' + pmDuration + 'ms ease, margin ' + pmDuration + 'ms ease';
|
|
1035
|
-
// element.style.transition = 'all ' + pmDuration + 'ms ease';
|
|
1036
|
-
element.style.margin = '';
|
|
1037
|
-
element.style.padding = '';
|
|
1038
|
-
element.style.height = '';
|
|
1039
|
-
options.callback && options.callback();
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
// 线性缓动函数
|
|
1043
|
-
function ease(t, b, c, d) {
|
|
1044
|
-
t /= d / 2;
|
|
1045
|
-
if (t < 1) return c / 2 * t * t + b;
|
|
1046
|
-
t--;
|
|
1047
|
-
return -c / 2 * (t * (t - 2) - 1) + b;
|
|
1048
|
-
}
|
|
1049
|
-
window.requestAnimationFrame(step);
|
|
1110
|
+
element.style.height = startHeight + "px";
|
|
1111
|
+
element.style.transition = `height ${options.duration}ms ease-in-out`;
|
|
1112
|
+
element.style.height = element.scrollHeight + "px";
|
|
1113
|
+
element.style.display = 'block';
|
|
1114
|
+
setTimeout(() => {
|
|
1115
|
+
element.style.overflow = '';
|
|
1116
|
+
element.style.transition = '';
|
|
1117
|
+
element.style.display = '';
|
|
1118
|
+
element.style.height = '';
|
|
1119
|
+
if (options.callback && typeof options.callback === 'function') options.callback(element);
|
|
1120
|
+
}, options.duration);
|
|
1050
1121
|
});
|
|
1051
1122
|
}
|
|
1052
1123
|
|
|
@@ -1095,6 +1166,7 @@ class Base {
|
|
|
1095
1166
|
element.style.opacity = 0;
|
|
1096
1167
|
setTimeout(() => {
|
|
1097
1168
|
element.style.display = 'none';
|
|
1169
|
+
if (options.callback && typeof options.callback === 'function') options.callback(element);
|
|
1098
1170
|
}, options.duration);
|
|
1099
1171
|
});
|
|
1100
1172
|
}
|
|
@@ -1119,8 +1191,8 @@ class Base {
|
|
|
1119
1191
|
* 反选
|
|
1120
1192
|
<pre>
|
|
1121
1193
|
<a href="javascript:" id="be-reverse-check">反选</a>
|
|
1122
|
-
<label><input type="checkbox"
|
|
1123
|
-
<label><input type="checkbox"
|
|
1194
|
+
<label><input type="checkbox" class="be-check" checked="checked"/>选项一</label>
|
|
1195
|
+
<label><input type="checkbox" class="be-check"/>选项二</label>
|
|
1124
1196
|
|
|
1125
1197
|
b('#be-reverse-check').checkReverse('.be-check')
|
|
1126
1198
|
</pre>
|
|
@@ -1257,28 +1329,29 @@ class Base {
|
|
|
1257
1329
|
}
|
|
1258
1330
|
options = b.extend(options, {
|
|
1259
1331
|
isFull: true,
|
|
1260
|
-
|
|
1261
|
-
template: '<div class="do-preloader"><span class="do-pr-loader"><span class="do-pr-lr"></span></span></div>'
|
|
1332
|
+
loadingTarget: '#do-preloader',
|
|
1333
|
+
template: '<div id="do-preloader" class="do-preloader"><span class="do-pr-loader"><span class="do-pr-lr"></span></span></div>'
|
|
1262
1334
|
});
|
|
1263
1335
|
|
|
1264
1336
|
return this.each((element) => {
|
|
1265
1337
|
if (isComplete) {
|
|
1266
1338
|
b("> *", element).removeClass("be-blur-2");
|
|
1267
|
-
b(options.
|
|
1339
|
+
b(options.loadingTarget).addClass("oy-0");
|
|
1268
1340
|
setTimeout(() => {
|
|
1269
1341
|
b("> *", element).removeClass("be-ts");
|
|
1270
|
-
b(options.
|
|
1342
|
+
b(options.loadingTarget).remove();
|
|
1271
1343
|
}, 300);
|
|
1272
1344
|
} else {
|
|
1273
1345
|
const myEle = b("> *", element);
|
|
1274
|
-
myEle.addClass("be-ts")
|
|
1275
|
-
setTimeout(() => {
|
|
1276
|
-
|
|
1346
|
+
myEle.addClass("be-ts").addClass("be-blur-2");
|
|
1347
|
+
// setTimeout(() => { // 同时加入可能看不出效果
|
|
1348
|
+
// myEle.addClass("be-blur-2");
|
|
1277
1349
|
b(element).prepend(options.template);
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1350
|
+
const myLoadingTarget = b(options.loadingTarget);
|
|
1351
|
+
if (myLoadingTarget.length) {
|
|
1352
|
+
b(options.loadingTarget).css('position', 'fixed').css('height', '100vh').css('width', '100vw')
|
|
1353
|
+
}
|
|
1354
|
+
// }, 100);
|
|
1282
1355
|
}
|
|
1283
1356
|
});
|
|
1284
1357
|
}
|
|
@@ -1310,11 +1383,15 @@ class Base {
|
|
|
1310
1383
|
return custom;
|
|
1311
1384
|
}
|
|
1312
1385
|
|
|
1313
|
-
//
|
|
1386
|
+
// 字符串连字符-或者. 转为驼峰格式
|
|
1314
1387
|
static camelCase = function(str) {
|
|
1315
|
-
|
|
1316
|
-
return
|
|
1388
|
+
let transformed = str.replace(/-([a-z])/, function(match, p1) {
|
|
1389
|
+
return p1.toUpperCase();
|
|
1390
|
+
});
|
|
1391
|
+
transformed = transformed.replace(/\.([a-z])/, function(match, p1) {
|
|
1392
|
+
return p1.toUpperCase();
|
|
1317
1393
|
});
|
|
1394
|
+
return transformed;
|
|
1318
1395
|
}
|
|
1319
1396
|
|
|
1320
1397
|
// 打印简写
|
|
@@ -1345,6 +1422,11 @@ class Base {
|
|
|
1345
1422
|
return target;
|
|
1346
1423
|
}
|
|
1347
1424
|
|
|
1425
|
+
// 判断变量是否为对象
|
|
1426
|
+
static isObject(item) {
|
|
1427
|
+
return (item) ? (item && typeof item === 'object' && !Array.isArray( item ) && true) : false;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1348
1430
|
// 获取两个数组中的相同值,eg: b.same([1,2], [7,9,4,2,5,6,1]) //[1, 2]
|
|
1349
1431
|
static same = function(arr1, arr2) {
|
|
1350
1432
|
return arr1.filter(function(v) {
|
|
@@ -1365,11 +1447,6 @@ class Base {
|
|
|
1365
1447
|
return regex.test(str);
|
|
1366
1448
|
}
|
|
1367
1449
|
|
|
1368
|
-
// 判断变量是否为对象
|
|
1369
|
-
static isObject(item) {
|
|
1370
|
-
return (item) ? (item && typeof item === 'object' && !Array.isArray( item ) && true) : false;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
1450
|
// 允许插件扩展
|
|
1374
1451
|
static plugin(pluginName, pluginFunction) {
|
|
1375
1452
|
// Base.fn[pluginName] = pluginFunction;
|
|
@@ -1814,6 +1891,7 @@ class Base {
|
|
|
1814
1891
|
// 2.4 静态属性
|
|
1815
1892
|
// 生成缓存随机名称
|
|
1816
1893
|
static expando = "base" + ("" + Math.random()).replace(/\D/g, "");
|
|
1894
|
+
static elementData = new Map();
|
|
1817
1895
|
static cache = { };
|
|
1818
1896
|
|
|
1819
1897
|
static build(selector, context) {
|
package/src/js/main.js
CHANGED
|
@@ -148,7 +148,12 @@ function owl($target, options) {
|
|
|
148
148
|
b['owl'] = owl;
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
/**
|
|
152
|
+
* 消息框参数设置:messageInit('info', 1, 2)
|
|
153
|
+
* @param type info / error / success
|
|
154
|
+
* @param classes 消息位置(2:顶部 / 6:左下下) ,按顺时针显示
|
|
155
|
+
* @param theme 样式(2:黑色), 1:flat、2:future、3:block、4:air、5:ice
|
|
156
|
+
**/
|
|
152
157
|
function messageInit(type, classes, theme) {
|
|
153
158
|
// 弹框样式,需要导入对应CSS
|
|
154
159
|
if (theme === 1) {
|
|
@@ -562,6 +567,7 @@ b['niceScroll'] = niceScroll;
|
|
|
562
567
|
function validationEngine($target, options) {
|
|
563
568
|
options = b.extend(options, {
|
|
564
569
|
focusFirstField : false,
|
|
570
|
+
validationEventTrigger: "click",
|
|
565
571
|
promptPosition: "topRight"
|
|
566
572
|
});
|
|
567
573
|
$target.validationEngine(options);
|
|
@@ -572,13 +578,14 @@ b['validationEngine'] = validationEngine;
|
|
|
572
578
|
* 14. validationEngine表单验证,确认是否验证通过
|
|
573
579
|
* @param $target jQuery选择器
|
|
574
580
|
* @param command 字符串方法名
|
|
581
|
+
* @param options 新参数
|
|
575
582
|
<pre>
|
|
576
583
|
const isSuccessed = b.validate($("#form-2"));
|
|
577
584
|
</pre>
|
|
578
585
|
**/
|
|
579
|
-
function validate($target, command) {
|
|
580
|
-
const
|
|
581
|
-
return $target.validationEngine(
|
|
586
|
+
function validate($target, command, options) {
|
|
587
|
+
const os = b.extend( { command: command }, { command: "validate", options });
|
|
588
|
+
return $target.validationEngine(os.command, os.options);
|
|
582
589
|
}
|
|
583
590
|
b['validate'] = validate;
|
|
584
591
|
|