arisu.js 1.0.2 → 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 +7 -3
- package/dist/arisu.commonjs.min.js +1 -1
- package/dist/arisu.js +507 -190
- 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 +239 -123
- package/src/js/main.js +11 -4
- package/src/js/utils.js +256 -63
- package/webpack.config.js +15 -15
- 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
|
@@ -95,6 +95,8 @@
|
|
|
95
95
|
b('.myElement').slideDown(500, function() { console.log('动画完成'); });
|
|
96
96
|
// 标签打开关闭切换
|
|
97
97
|
b('.myElement').slideToggle(500, function() { console.log('动画完成'); });
|
|
98
|
+
// 元素透明度逐渐递减变0,最后display设置为none
|
|
99
|
+
b('#id').fadeOut(1000, ()=>{ b.l('透明度为0后消失') })
|
|
98
100
|
|
|
99
101
|
// 1.2 页面基础方法扩展
|
|
100
102
|
// 全选全清,<input type="checkbox" class="myCheckbox"><input type="checkbox" class="test">
|
|
@@ -122,14 +124,14 @@
|
|
|
122
124
|
if(b.isNull(变量)) {
|
|
123
125
|
// 如果为空设置默认值
|
|
124
126
|
b.setDefault(data.id, 0);
|
|
127
|
+
// 判断变量是否为对象
|
|
128
|
+
console.log(b.isObject(custom));
|
|
125
129
|
// 获取两个数组中的相同值
|
|
126
130
|
b.same([1,2], [7,9,4,2,5,6,1]) //[1, 2]
|
|
127
131
|
// 获取两个数组中的不相同值
|
|
128
132
|
b.different([1,2], [7,9,4,2,5,6,1]) //[7, 9, 4, 5, 6]
|
|
129
133
|
// 判断字符串是否为html标签,如<li></li><div></div><img/>返回true
|
|
130
134
|
console.log(b.isHtmlTag('<img />')); // true
|
|
131
|
-
// 判断变量是否为对象
|
|
132
|
-
console.log(b.isObject(custom));
|
|
133
135
|
// 允许插件扩展plugin静态方法
|
|
134
136
|
// 普通方法
|
|
135
137
|
function test(p1, p2) { console.log(this, p1, p2) } //Base... 3 4
|
|
@@ -659,38 +661,74 @@ class Base {
|
|
|
659
661
|
}
|
|
660
662
|
|
|
661
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
|
+
|
|
662
702
|
data( key, value ) {
|
|
663
703
|
if ( key === undefined ) {
|
|
664
704
|
throw new Error('读取的或设置的键值不能为空');
|
|
665
705
|
}
|
|
666
|
-
|
|
667
|
-
let cache,
|
|
668
|
-
elem = this.elements[0],
|
|
669
|
-
// 获取与元素关联的缓存对象
|
|
670
|
-
id = Base.expando,
|
|
671
|
-
isCache = id && Base.cache[ id ];
|
|
672
|
-
|
|
706
|
+
let element = this.elements[0];
|
|
673
707
|
if ( value !== undefined ) {
|
|
674
|
-
//
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
//
|
|
678
|
-
|
|
679
|
-
// 将缓存对象存储在全局 Base.cache 中
|
|
680
|
-
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 );
|
|
681
713
|
}
|
|
682
|
-
|
|
683
|
-
|
|
714
|
+
|
|
715
|
+
// 存储数据
|
|
716
|
+
dataMap.set( Base.camelCase( key ), value );
|
|
684
717
|
return this;
|
|
685
718
|
} else {
|
|
686
|
-
|
|
687
|
-
|
|
719
|
+
const dataMap = Base.elementData.get(element);
|
|
720
|
+
// 如果数据映射存在且包含该key,则返回其值;否则返回undefined
|
|
721
|
+
return dataMap ? dataMap.get(Base.camelCase( key )) : Base.dataAttr( element, key );
|
|
688
722
|
}
|
|
689
723
|
}
|
|
690
724
|
|
|
691
725
|
// 清除data属性绑定的值
|
|
692
726
|
removeData( key ) {
|
|
693
|
-
|
|
727
|
+
let element = this.elements[0];
|
|
728
|
+
let dataMap = Base.elementData.get( element );
|
|
729
|
+
if (dataMap) {
|
|
730
|
+
dataMap.set( Base.camelCase( key ), undefined );
|
|
731
|
+
}
|
|
694
732
|
}
|
|
695
733
|
|
|
696
734
|
// attr 方法实现
|
|
@@ -951,100 +989,135 @@ class Base {
|
|
|
951
989
|
// 标签消失高度变0的关闭动画,300MS刚刚好
|
|
952
990
|
slideUp(duration, callback) {
|
|
953
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
|
+
// });
|
|
954
1039
|
return this.each((element) => {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
if (marginBottom && marginBottom.includes('px'))
|
|
969
|
-
marginBottom = marginBottom.replace(/px/g, '');
|
|
970
|
-
|
|
971
|
-
// element.style.transition = 'height ' + options.duration + 'ms ease-in-out';
|
|
972
|
-
element.style.transition = 'none';
|
|
973
|
-
element.style.overflow = 'hidden'; // 隐藏超出元素的内容
|
|
974
|
-
|
|
975
|
-
function step(startTime) {
|
|
976
|
-
const now = performance.now(),
|
|
977
|
-
timeElapsed = now - startTime,
|
|
978
|
-
newHeight = Math.max(0, height - (timeElapsed / options.duration) * height),// 计算当前应该设置的高度
|
|
979
|
-
newPaddingTop = Math.max(0, paddingTop - (timeElapsed / options.duration) * paddingTop),
|
|
980
|
-
newPaddingBottom = Math.max(0, paddingBottom - (timeElapsed / options.duration) * paddingBottom),
|
|
981
|
-
newMarginTop = Math.max(0, marginTop - (timeElapsed / options.duration) * marginTop),
|
|
982
|
-
newMarginBottom = Math.max(0, marginBottom - (timeElapsed / options.duration) * marginBottom);
|
|
983
|
-
element.style.height = newHeight + `px`;
|
|
984
|
-
element.style.paddingTop = newPaddingTop + `px`;
|
|
985
|
-
element.style.paddingBottom = newPaddingBottom + `px`;
|
|
986
|
-
element.style.marginTop = newMarginTop + `px`;
|
|
987
|
-
element.style.marginBottom = newMarginBottom + `px`;
|
|
988
|
-
// 如果还没到达目标高度,则继续下一帧
|
|
989
|
-
if (timeElapsed < options.duration) {
|
|
990
|
-
requestAnimationFrame(step.bind(null, startTime));
|
|
991
|
-
} else {
|
|
992
|
-
// 过渡完成后清除过渡效果,以便后续操作
|
|
993
|
-
element.style.transition = '';
|
|
994
|
-
element.style.height = '';
|
|
995
|
-
element.style.display = 'none';
|
|
996
|
-
options.callback && options.callback();
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
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);
|
|
1000
1053
|
});
|
|
1001
1054
|
}
|
|
1002
1055
|
|
|
1003
1056
|
// 标签显示高度变复原的打开动画
|
|
1004
1057
|
slideDown(duration, callback) {
|
|
1005
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
|
+
// });
|
|
1006
1102
|
return this.each((element) => {
|
|
1007
1103
|
// 获取元素当前的高度和初始的 display 状态
|
|
1008
1104
|
let startHeight = element.offsetHeight,
|
|
1009
|
-
display = element.style.display
|
|
1010
|
-
mainDuration = options.duration * 7 / 10,
|
|
1011
|
-
pmDuration = options.duration * 3 / 10;
|
|
1105
|
+
display = element.style.display;
|
|
1012
1106
|
if (display === 'none') {
|
|
1013
1107
|
element.style.display = '';
|
|
1014
1108
|
startHeight = 0; // 如果元素是隐藏的,则从 0 开始
|
|
1015
1109
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
if (
|
|
1026
|
-
|
|
1027
|
-
element.style.height = newHeight + 'px';
|
|
1028
|
-
|
|
1029
|
-
if (progress < mainDuration) {
|
|
1030
|
-
window.requestAnimationFrame(step);
|
|
1031
|
-
} else {
|
|
1032
|
-
element.style.transition = 'padding ' + pmDuration + 'ms ease, margin ' + pmDuration + 'ms ease';
|
|
1033
|
-
// element.style.transition = 'all ' + pmDuration + 'ms ease';
|
|
1034
|
-
element.style.margin = '';
|
|
1035
|
-
element.style.padding = '';
|
|
1036
|
-
element.style.height = '';
|
|
1037
|
-
options.callback && options.callback();
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
// 线性缓动函数
|
|
1041
|
-
function ease(t, b, c, d) {
|
|
1042
|
-
t /= d / 2;
|
|
1043
|
-
if (t < 1) return c / 2 * t * t + b;
|
|
1044
|
-
t--;
|
|
1045
|
-
return -c / 2 * (t * (t - 2) - 1) + b;
|
|
1046
|
-
}
|
|
1047
|
-
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);
|
|
1048
1121
|
});
|
|
1049
1122
|
}
|
|
1050
1123
|
|
|
@@ -1065,6 +1138,39 @@ class Base {
|
|
|
1065
1138
|
}
|
|
1066
1139
|
}
|
|
1067
1140
|
|
|
1141
|
+
// 元素透明度逐渐递减变0,最后display设置为none
|
|
1142
|
+
fadeOut(duration, callback) {
|
|
1143
|
+
const options = b.extend({ duration: duration, callback: callback }, { duration: 300, callback: false })
|
|
1144
|
+
// let start = performance.now();
|
|
1145
|
+
// const step = (time, element) => {
|
|
1146
|
+
// let progress = (time - start) / options.duration;
|
|
1147
|
+
// if (progress >= 1) {
|
|
1148
|
+
// element.style.opacity = 0;
|
|
1149
|
+
// element.style.transition = 'none';
|
|
1150
|
+
// if (options.callback && typeof options.callback === 'function') options.callback();
|
|
1151
|
+
// return;
|
|
1152
|
+
// }
|
|
1153
|
+
// element.style.opacity = 1 - progress.toFixed(1);
|
|
1154
|
+
// window.requestAnimationFrame((time) => {
|
|
1155
|
+
// step(time, element)
|
|
1156
|
+
// });
|
|
1157
|
+
// };
|
|
1158
|
+
// return this.each((element) => {
|
|
1159
|
+
// element.style.transition = `opacity ${duration}ms ease-in-out`;
|
|
1160
|
+
// window.requestAnimationFrame((time) => {
|
|
1161
|
+
// step(time, element)
|
|
1162
|
+
// });
|
|
1163
|
+
// });
|
|
1164
|
+
return this.each((element) => {
|
|
1165
|
+
element.style.transition = `opacity ${options.duration}ms ease-in-out`;
|
|
1166
|
+
element.style.opacity = 0;
|
|
1167
|
+
setTimeout(() => {
|
|
1168
|
+
element.style.display = 'none';
|
|
1169
|
+
if (options.callback && typeof options.callback === 'function') options.callback(element);
|
|
1170
|
+
}, options.duration);
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1068
1174
|
// 1.2 页面常用方法扩展
|
|
1069
1175
|
|
|
1070
1176
|
// 全选全清
|
|
@@ -1085,8 +1191,8 @@ class Base {
|
|
|
1085
1191
|
* 反选
|
|
1086
1192
|
<pre>
|
|
1087
1193
|
<a href="javascript:" id="be-reverse-check">反选</a>
|
|
1088
|
-
<label><input type="checkbox"
|
|
1089
|
-
<label><input type="checkbox"
|
|
1194
|
+
<label><input type="checkbox" class="be-check" checked="checked"/>选项一</label>
|
|
1195
|
+
<label><input type="checkbox" class="be-check"/>选项二</label>
|
|
1090
1196
|
|
|
1091
1197
|
b('#be-reverse-check').checkReverse('.be-check')
|
|
1092
1198
|
</pre>
|
|
@@ -1184,8 +1290,8 @@ class Base {
|
|
|
1184
1290
|
/**
|
|
1185
1291
|
* 点击切换激活项(添加active class),已经激活则取消(删除active class)
|
|
1186
1292
|
<pre>
|
|
1187
|
-
<button type="button"
|
|
1188
|
-
<button type="button"
|
|
1293
|
+
<button type="button" class="my-btn btn btn-success">按钮1</button>
|
|
1294
|
+
<button type="button" class="my-btn btn btn-success">按钮2</button>
|
|
1189
1295
|
|
|
1190
1296
|
b(".my-btn").setActive();
|
|
1191
1297
|
</pre>
|
|
@@ -1204,7 +1310,7 @@ class Base {
|
|
|
1204
1310
|
}
|
|
1205
1311
|
|
|
1206
1312
|
/**
|
|
1207
|
-
* 全屏loading
|
|
1313
|
+
* 全屏loading
|
|
1208
1314
|
<pre>
|
|
1209
1315
|
import "istyle/src/css/loading/do-pr-loader.css";
|
|
1210
1316
|
b('#c').click(() => {
|
|
@@ -1223,24 +1329,29 @@ class Base {
|
|
|
1223
1329
|
}
|
|
1224
1330
|
options = b.extend(options, {
|
|
1225
1331
|
isFull: true,
|
|
1226
|
-
|
|
1227
|
-
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>'
|
|
1228
1334
|
});
|
|
1229
1335
|
|
|
1230
1336
|
return this.each((element) => {
|
|
1231
1337
|
if (isComplete) {
|
|
1232
1338
|
b("> *", element).removeClass("be-blur-2");
|
|
1233
|
-
b(options.
|
|
1339
|
+
b(options.loadingTarget).addClass("oy-0");
|
|
1234
1340
|
setTimeout(() => {
|
|
1235
1341
|
b("> *", element).removeClass("be-ts");
|
|
1236
|
-
b(options.
|
|
1342
|
+
b(options.loadingTarget).remove();
|
|
1237
1343
|
}, 300);
|
|
1238
1344
|
} else {
|
|
1239
|
-
b(element)
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1345
|
+
const myEle = b("> *", element);
|
|
1346
|
+
myEle.addClass("be-ts").addClass("be-blur-2");
|
|
1347
|
+
// setTimeout(() => { // 同时加入可能看不出效果
|
|
1348
|
+
// myEle.addClass("be-blur-2");
|
|
1349
|
+
b(element).prepend(options.template);
|
|
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);
|
|
1244
1355
|
}
|
|
1245
1356
|
});
|
|
1246
1357
|
}
|
|
@@ -1272,11 +1383,15 @@ class Base {
|
|
|
1272
1383
|
return custom;
|
|
1273
1384
|
}
|
|
1274
1385
|
|
|
1275
|
-
//
|
|
1386
|
+
// 字符串连字符-或者. 转为驼峰格式
|
|
1276
1387
|
static camelCase = function(str) {
|
|
1277
|
-
|
|
1278
|
-
return
|
|
1388
|
+
let transformed = str.replace(/-([a-z])/, function(match, p1) {
|
|
1389
|
+
return p1.toUpperCase();
|
|
1279
1390
|
});
|
|
1391
|
+
transformed = transformed.replace(/\.([a-z])/, function(match, p1) {
|
|
1392
|
+
return p1.toUpperCase();
|
|
1393
|
+
});
|
|
1394
|
+
return transformed;
|
|
1280
1395
|
}
|
|
1281
1396
|
|
|
1282
1397
|
// 打印简写
|
|
@@ -1307,6 +1422,11 @@ class Base {
|
|
|
1307
1422
|
return target;
|
|
1308
1423
|
}
|
|
1309
1424
|
|
|
1425
|
+
// 判断变量是否为对象
|
|
1426
|
+
static isObject(item) {
|
|
1427
|
+
return (item) ? (item && typeof item === 'object' && !Array.isArray( item ) && true) : false;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1310
1430
|
// 获取两个数组中的相同值,eg: b.same([1,2], [7,9,4,2,5,6,1]) //[1, 2]
|
|
1311
1431
|
static same = function(arr1, arr2) {
|
|
1312
1432
|
return arr1.filter(function(v) {
|
|
@@ -1327,11 +1447,6 @@ class Base {
|
|
|
1327
1447
|
return regex.test(str);
|
|
1328
1448
|
}
|
|
1329
1449
|
|
|
1330
|
-
// 判断变量是否为对象
|
|
1331
|
-
static isObject(item) {
|
|
1332
|
-
return (item) ? (item && typeof item === 'object' && !Array.isArray( item ) && true) : false;
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
1450
|
// 允许插件扩展
|
|
1336
1451
|
static plugin(pluginName, pluginFunction) {
|
|
1337
1452
|
// Base.fn[pluginName] = pluginFunction;
|
|
@@ -1776,6 +1891,7 @@ class Base {
|
|
|
1776
1891
|
// 2.4 静态属性
|
|
1777
1892
|
// 生成缓存随机名称
|
|
1778
1893
|
static expando = "base" + ("" + Math.random()).replace(/\D/g, "");
|
|
1894
|
+
static elementData = new Map();
|
|
1779
1895
|
static cache = { };
|
|
1780
1896
|
|
|
1781
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
|
|