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/dist/arisu.js CHANGED
@@ -66,6 +66,7 @@ __webpack_require__.d(utils_namespaceObject, {
66
66
  HoverDir: () => (HoverDir),
67
67
  IAccordion: () => (IAccordion),
68
68
  IList: () => (IList),
69
+ ILoader: () => (ILoader),
69
70
  IPagination: () => (IPagination),
70
71
  ItemCount: () => (ItemCount),
71
72
  LineEffect: () => (LineEffect),
@@ -203,14 +204,14 @@ __webpack_require__.d(utils_namespaceObject, {
203
204
  if(b.isNull(变量)) {
204
205
  // 如果为空设置默认值
205
206
  b.setDefault(data.id, 0);
207
+ // 判断变量是否为对象
208
+ console.log(b.isObject(custom));
206
209
  // 获取两个数组中的相同值
207
210
  b.same([1,2], [7,9,4,2,5,6,1]) //[1, 2]
208
211
  // 获取两个数组中的不相同值
209
212
  b.different([1,2], [7,9,4,2,5,6,1]) //[7, 9, 4, 5, 6]
210
213
  // 判断字符串是否为html标签,如<li></li><div></div><img/>返回true
211
214
  console.log(b.isHtmlTag('<img />')); // true
212
- // 判断变量是否为对象
213
- console.log(b.isObject(custom));
214
215
  // 允许插件扩展plugin静态方法
215
216
  // 普通方法
216
217
  function test(p1, p2) { console.log(this, p1, p2) } //Base... 3 4
@@ -740,38 +741,74 @@ class Base {
740
741
  }
741
742
 
742
743
  // data属性绑定设置
744
+ // data( key, value ) {
745
+ // if ( key === undefined ) {
746
+ // throw new Error('读取的或设置的键值不能为空');
747
+ // }
748
+ //
749
+ // let cache,
750
+ // elem = this.elements[0],
751
+ // // 获取与元素关联的缓存对象
752
+ // id = Base.expando,
753
+ // isCache = id && Base.cache[ id ];
754
+ //
755
+ // if ( value !== undefined ) {
756
+ // // 如果尚未创建缓存对象,则创建它
757
+ // if ( !isCache ) {
758
+ // cache = {};
759
+ // // 生成唯一的缓存键
760
+ // elem[ Base.expando ] = cache[ Base.expando ] = id;
761
+ // // 将缓存对象存储在全局 Base.cache 中
762
+ // Base.cache[ id ] = isCache = cache;
763
+ // }
764
+ // // 存储数据到缓存对象中
765
+ // isCache[ Base.camelCase( key ) ] = value;
766
+ // return this;
767
+ // } else {
768
+ // // console.log(isCache)
769
+ // // console.log(elem)
770
+ // if (!isCache)
771
+ // return undefined;
772
+ // else
773
+ // return isCache[ Base.camelCase( key ) ] ? isCache[ Base.camelCase( key ) ] : Base.dataAttr( elem, Base.camelCase( key ) )
774
+ // }
775
+ // }
776
+
777
+ // 清除data属性绑定的值
778
+ // removeData( key ) {
779
+ // delete Base.cache[ Base.expando ][ key ];
780
+ // }
781
+
743
782
  data( key, value ) {
744
783
  if ( key === undefined ) {
745
784
  throw new Error('读取的或设置的键值不能为空');
746
785
  }
747
-
748
- let cache,
749
- elem = this.elements[0],
750
- // 获取与元素关联的缓存对象
751
- id = Base.expando,
752
- isCache = id && Base.cache[ id ];
753
-
786
+ let element = this.elements[0];
754
787
  if ( value !== undefined ) {
755
- // 如果尚未创建缓存对象,则创建它
756
- if ( !isCache ) {
757
- cache = {};
758
- // 生成唯一的缓存键
759
- elem[ Base.expando ] = cache[ Base.expando ] = id;
760
- // 将缓存对象存储在全局 Base.cache 中
761
- Base.cache[ id ] = isCache = cache;
788
+ // 获取与元素关联的数据映射,‌如果不存在则创建一个新的
789
+ let dataMap = Base.elementData.get( element );
790
+ if (!dataMap) {
791
+ dataMap = new Map(); // 使用Map来存储元素的数据
792
+ Base.elementData.set( element, dataMap );
762
793
  }
763
- // 存储数据到缓存对象中
764
- isCache[ Base.camelCase( key ) ] = value;
794
+
795
+ // 存储数据
796
+ dataMap.set( Base.camelCase( key ), value );
765
797
  return this;
766
798
  } else {
767
- if (!isCache) return undefined; else
768
- return isCache[ Base.camelCase( key ) ] ? isCache[ Base.camelCase( key ) ] : Base.dataAttr( elem, Base.camelCase( key ) )
799
+ const dataMap = Base.elementData.get(element);
800
+ // 如果数据映射存在且包含该key,‌则返回其值;‌否则返回undefined
801
+ return dataMap ? dataMap.get(Base.camelCase( key )) : Base.dataAttr( element, key );
769
802
  }
770
803
  }
771
804
 
772
805
  // 清除data属性绑定的值
773
806
  removeData( key ) {
774
- delete Base.cache[ Base.expando ][ key ];
807
+ let element = this.elements[0];
808
+ let dataMap = Base.elementData.get( element );
809
+ if (dataMap) {
810
+ dataMap.set( Base.camelCase( key ), undefined );
811
+ }
775
812
  }
776
813
 
777
814
  // attr 方法实现
@@ -1032,100 +1069,135 @@ class Base {
1032
1069
  // 标签消失高度变0的关闭动画,300MS刚刚好
1033
1070
  slideUp(duration, callback) {
1034
1071
  const options = b.extend({ duration: duration, callback: callback }, { duration: 300, callback: false })
1072
+ // return this.each((element) => {
1073
+ // const computedStyle = window.getComputedStyle(element),
1074
+ // height = element.offsetHeight;
1075
+ //
1076
+ // let paddingTop = computedStyle.getPropertyValue('padding-top'),
1077
+ // paddingBottom = computedStyle.getPropertyValue('padding-bottom'),
1078
+ // marginTop = computedStyle.getPropertyValue('margin-top'),
1079
+ // marginBottom = computedStyle.getPropertyValue('margin-bottom');
1080
+ // if (paddingTop && paddingTop.includes('px'))
1081
+ // paddingTop = paddingTop.replace(/px/g, '');
1082
+ // if (paddingBottom && paddingBottom.includes('px'))
1083
+ // paddingBottom = paddingBottom.replace(/px/g, '');
1084
+ // if (marginTop && marginTop.includes('px'))
1085
+ // marginTop = marginTop.replace(/px/g, '');
1086
+ // if (marginBottom && marginBottom.includes('px'))
1087
+ // marginBottom = marginBottom.replace(/px/g, '');
1088
+ //
1089
+ // // element.style.transition = 'height ' + options.duration + 'ms ease-in-out';
1090
+ // element.style.transition = 'none';
1091
+ // element.style.overflow = 'hidden'; // 隐藏超出元素的内容
1092
+ //
1093
+ // function step(startTime) {
1094
+ // const now = performance.now(),
1095
+ // timeElapsed = now - startTime,
1096
+ // newHeight = Math.max(0, height - (timeElapsed / options.duration) * height),// 计算当前应该设置的高度
1097
+ // newPaddingTop = Math.max(0, paddingTop - (timeElapsed / options.duration) * paddingTop),
1098
+ // newPaddingBottom = Math.max(0, paddingBottom - (timeElapsed / options.duration) * paddingBottom),
1099
+ // newMarginTop = Math.max(0, marginTop - (timeElapsed / options.duration) * marginTop),
1100
+ // newMarginBottom = Math.max(0, marginBottom - (timeElapsed / options.duration) * marginBottom);
1101
+ // element.style.height = newHeight + `px`;
1102
+ // element.style.paddingTop = newPaddingTop + `px`;
1103
+ // element.style.paddingBottom = newPaddingBottom + `px`;
1104
+ // element.style.marginTop = newMarginTop + `px`;
1105
+ // element.style.marginBottom = newMarginBottom + `px`;
1106
+ // // 如果还没到达目标高度,则继续下一帧
1107
+ // if (timeElapsed < options.duration) {
1108
+ // requestAnimationFrame(step.bind(null, startTime));
1109
+ // } else {
1110
+ // // 过渡完成后清除过渡效果,以便后续操作
1111
+ // element.style.transition = '';
1112
+ // element.style.height = '';
1113
+ // element.style.display = 'none';
1114
+ // options.callback && options.callback();
1115
+ // }
1116
+ // }
1117
+ // requestAnimationFrame(step);
1118
+ // });
1035
1119
  return this.each((element) => {
1036
- const computedStyle = window.getComputedStyle(element),
1037
- height = element.offsetHeight;
1038
-
1039
- let paddingTop = computedStyle.getPropertyValue('padding-top'),
1040
- paddingBottom = computedStyle.getPropertyValue('padding-bottom'),
1041
- marginTop = computedStyle.getPropertyValue('margin-top'),
1042
- marginBottom = computedStyle.getPropertyValue('margin-bottom');
1043
- if (paddingTop && paddingTop.includes('px'))
1044
- paddingTop = paddingTop.replace(/px/g, '');
1045
- if (paddingBottom && paddingBottom.includes('px'))
1046
- paddingBottom = paddingBottom.replace(/px/g, '');
1047
- if (marginTop && marginTop.includes('px'))
1048
- marginTop = marginTop.replace(/px/g, '');
1049
- if (marginBottom && marginBottom.includes('px'))
1050
- marginBottom = marginBottom.replace(/px/g, '');
1051
-
1052
- // element.style.transition = 'height ' + options.duration + 'ms ease-in-out';
1053
- element.style.transition = 'none';
1054
- element.style.overflow = 'hidden'; // 隐藏超出元素的内容
1055
-
1056
- function step(startTime) {
1057
- const now = performance.now(),
1058
- timeElapsed = now - startTime,
1059
- newHeight = Math.max(0, height - (timeElapsed / options.duration) * height),// 计算当前应该设置的高度
1060
- newPaddingTop = Math.max(0, paddingTop - (timeElapsed / options.duration) * paddingTop),
1061
- newPaddingBottom = Math.max(0, paddingBottom - (timeElapsed / options.duration) * paddingBottom),
1062
- newMarginTop = Math.max(0, marginTop - (timeElapsed / options.duration) * marginTop),
1063
- newMarginBottom = Math.max(0, marginBottom - (timeElapsed / options.duration) * marginBottom);
1064
- element.style.height = newHeight + `px`;
1065
- element.style.paddingTop = newPaddingTop + `px`;
1066
- element.style.paddingBottom = newPaddingBottom + `px`;
1067
- element.style.marginTop = newMarginTop + `px`;
1068
- element.style.marginBottom = newMarginBottom + `px`;
1069
- // 如果还没到达目标高度,则继续下一帧
1070
- if (timeElapsed < options.duration) {
1071
- requestAnimationFrame(step.bind(null, startTime));
1072
- } else {
1073
- // 过渡完成后清除过渡效果,以便后续操作
1074
- element.style.transition = '';
1075
- element.style.height = '';
1076
- element.style.display = 'none';
1077
- options.callback && options.callback();
1078
- }
1079
- }
1080
- requestAnimationFrame(step);
1120
+ element.style.height = element.scrollHeight + "px";
1121
+ element.style.overflow = 'hidden';
1122
+ element.style.transition = `height ${options.duration}ms ease-in-out`;
1123
+ setTimeout(() => {
1124
+ element.style.height = '0px';
1125
+ }, options.duration / 100);
1126
+ setTimeout(() => {
1127
+ element.style.display = 'none';
1128
+ element.style.overflow = '';
1129
+ element.style.transition = '';
1130
+ element.style.height = '';
1131
+ if (options.callback && typeof options.callback === 'function') options.callback(element);
1132
+ }, options.duration - options.duration / 100);
1081
1133
  });
1082
1134
  }
1083
1135
 
1084
1136
  // 标签显示高度变复原的打开动画
1085
1137
  slideDown(duration, callback) {
1086
1138
  const options = b.extend({ duration: duration, callback: callback }, { duration: 300, callback: false })
1139
+ // return this.each((element) => {
1140
+ // // 获取元素当前的高度和初始的 display 状态
1141
+ // let startHeight = element.offsetHeight,
1142
+ // display = element.style.display,
1143
+ // mainDuration = options.duration * 7 / 10,
1144
+ // pmDuration = options.duration * 3 / 10;
1145
+ // if (display === 'none') {
1146
+ // element.style.display = '';
1147
+ // startHeight = 0; // 如果元素是隐藏的,则从 0 开始
1148
+ // }
1149
+ //
1150
+ // let endHeight = element.scrollHeight, // 目标高度是元素的 scrollHeight
1151
+ // changeHeight = endHeight - startHeight,
1152
+ // startTime = null;
1153
+ //
1154
+ // // 动画函数
1155
+ // function step(timestamp) {
1156
+ // if (!startTime) startTime = timestamp;
1157
+ // let progress = timestamp - startTime;
1158
+ // if (progress > mainDuration) progress = mainDuration;
1159
+ // let newHeight = ease(progress, startHeight, changeHeight, mainDuration);
1160
+ // element.style.height = newHeight + 'px';
1161
+ //
1162
+ // if (progress < mainDuration) {
1163
+ // window.requestAnimationFrame(step);
1164
+ // } else {
1165
+ // element.style.transition = 'padding ' + pmDuration + 'ms ease, margin ' + pmDuration + 'ms ease';
1166
+ // // element.style.transition = 'all ' + pmDuration + 'ms ease';
1167
+ // element.style.margin = '';
1168
+ // element.style.padding = '';
1169
+ // element.style.height = '';
1170
+ // options.callback && options.callback();
1171
+ // }
1172
+ // }
1173
+ // // 线性缓动函数
1174
+ // function ease(t, b, c, d) {
1175
+ // t /= d / 2;
1176
+ // if (t < 1) return c / 2 * t * t + b;
1177
+ // t--;
1178
+ // return -c / 2 * (t * (t - 2) - 1) + b;
1179
+ // }
1180
+ // window.requestAnimationFrame(step);
1181
+ // });
1087
1182
  return this.each((element) => {
1088
1183
  // 获取元素当前的高度和初始的 display 状态
1089
1184
  let startHeight = element.offsetHeight,
1090
- display = element.style.display,
1091
- mainDuration = options.duration * 7 / 10,
1092
- pmDuration = options.duration * 3 / 10;
1185
+ display = element.style.display;
1093
1186
  if (display === 'none') {
1094
1187
  element.style.display = '';
1095
1188
  startHeight = 0; // 如果元素是隐藏的,则从 0 开始
1096
1189
  }
1097
-
1098
- let endHeight = element.scrollHeight, // 目标高度是元素的 scrollHeight
1099
- changeHeight = endHeight - startHeight,
1100
- startTime = null;
1101
-
1102
- // 动画函数
1103
- function step(timestamp) {
1104
- if (!startTime) startTime = timestamp;
1105
- let progress = timestamp - startTime;
1106
- if (progress > mainDuration) progress = mainDuration;
1107
- let newHeight = ease(progress, startHeight, changeHeight, mainDuration);
1108
- element.style.height = newHeight + 'px';
1109
-
1110
- if (progress < mainDuration) {
1111
- window.requestAnimationFrame(step);
1112
- } else {
1113
- element.style.transition = 'padding ' + pmDuration + 'ms ease, margin ' + pmDuration + 'ms ease';
1114
- // element.style.transition = 'all ' + pmDuration + 'ms ease';
1115
- element.style.margin = '';
1116
- element.style.padding = '';
1117
- element.style.height = '';
1118
- options.callback && options.callback();
1119
- }
1120
- }
1121
- // 线性缓动函数
1122
- function ease(t, b, c, d) {
1123
- t /= d / 2;
1124
- if (t < 1) return c / 2 * t * t + b;
1125
- t--;
1126
- return -c / 2 * (t * (t - 2) - 1) + b;
1127
- }
1128
- window.requestAnimationFrame(step);
1190
+ element.style.height = startHeight + "px";
1191
+ element.style.transition = `height ${options.duration}ms ease-in-out`;
1192
+ element.style.height = element.scrollHeight + "px";
1193
+ element.style.display = 'block';
1194
+ setTimeout(() => {
1195
+ element.style.overflow = '';
1196
+ element.style.transition = '';
1197
+ element.style.display = '';
1198
+ element.style.height = '';
1199
+ if (options.callback && typeof options.callback === 'function') options.callback(element);
1200
+ }, options.duration);
1129
1201
  });
1130
1202
  }
1131
1203
 
@@ -1174,6 +1246,7 @@ class Base {
1174
1246
  element.style.opacity = 0;
1175
1247
  setTimeout(() => {
1176
1248
  element.style.display = 'none';
1249
+ if (options.callback && typeof options.callback === 'function') options.callback(element);
1177
1250
  }, options.duration);
1178
1251
  });
1179
1252
  }
@@ -1198,8 +1271,8 @@ class Base {
1198
1271
  * 反选
1199
1272
  <pre>
1200
1273
  <a href="javascript:" id="be-reverse-check">反选</a>
1201
- <label><input type="checkbox" className="be-check" checked="checked"/>选项一</label>
1202
- <label><input type="checkbox" className="be-check"/>选项二</label>
1274
+ <label><input type="checkbox" class="be-check" checked="checked"/>选项一</label>
1275
+ <label><input type="checkbox" class="be-check"/>选项二</label>
1203
1276
 
1204
1277
  b('#be-reverse-check').checkReverse('.be-check')
1205
1278
  </pre>
@@ -1336,28 +1409,29 @@ class Base {
1336
1409
  }
1337
1410
  options = b.extend(options, {
1338
1411
  isFull: true,
1339
- loadingClass: '.do-preloader',
1340
- template: '<div class="do-preloader"><span class="do-pr-loader"><span class="do-pr-lr"></span></span></div>'
1412
+ loadingTarget: '#do-preloader',
1413
+ template: '<div id="do-preloader" class="do-preloader"><span class="do-pr-loader"><span class="do-pr-lr"></span></span></div>'
1341
1414
  });
1342
1415
 
1343
1416
  return this.each((element) => {
1344
1417
  if (isComplete) {
1345
1418
  b("> *", element).removeClass("be-blur-2");
1346
- b(options.loadingClass).addClass("oy-0");
1419
+ b(options.loadingTarget).addClass("oy-0");
1347
1420
  setTimeout(() => {
1348
1421
  b("> *", element).removeClass("be-ts");
1349
- b(options.loadingClass).remove();
1422
+ b(options.loadingTarget).remove();
1350
1423
  }, 300);
1351
1424
  } else {
1352
1425
  const myEle = b("> *", element);
1353
- myEle.addClass("be-ts")
1354
- setTimeout(() => {
1355
- myEle.addClass("be-blur-2");
1426
+ myEle.addClass("be-ts").addClass("be-blur-2");
1427
+ // setTimeout(() => { // 同时加入可能看不出效果
1428
+ // myEle.addClass("be-blur-2");
1356
1429
  b(element).prepend(options.template);
1357
- }, 30);
1358
- if (options.template) {
1359
- b(options.loadingClass).css('position', 'fixed').css('height', '100vh').css('width', '100vw')
1360
- }
1430
+ const myLoadingTarget = b(options.loadingTarget);
1431
+ if (myLoadingTarget.length) {
1432
+ b(options.loadingTarget).css('position', 'fixed').css('height', '100vh').css('width', '100vw')
1433
+ }
1434
+ // }, 100);
1361
1435
  }
1362
1436
  });
1363
1437
  }
@@ -1389,11 +1463,15 @@ class Base {
1389
1463
  return custom;
1390
1464
  }
1391
1465
 
1392
- // 字符串装换为驼峰格式
1466
+ // 字符串连字符-或者. 转为驼峰格式
1393
1467
  static camelCase = function(str) {
1394
- return str.replace(/-([a-z])/g, function(all, letter) {
1395
- return letter.toUpperCase();
1468
+ let transformed = str.replace(/-([a-z])/, function(match, p1) {
1469
+ return p1.toUpperCase();
1470
+ });
1471
+ transformed = transformed.replace(/\.([a-z])/, function(match, p1) {
1472
+ return p1.toUpperCase();
1396
1473
  });
1474
+ return transformed;
1397
1475
  }
1398
1476
 
1399
1477
  // 打印简写
@@ -1424,6 +1502,11 @@ class Base {
1424
1502
  return target;
1425
1503
  }
1426
1504
 
1505
+ // 判断变量是否为对象
1506
+ static isObject(item) {
1507
+ return (item) ? (item && typeof item === 'object' && !Array.isArray( item ) && true) : false;
1508
+ }
1509
+
1427
1510
  // 获取两个数组中的相同值,eg: b.same([1,2], [7,9,4,2,5,6,1]) //[1, 2]
1428
1511
  static same = function(arr1, arr2) {
1429
1512
  return arr1.filter(function(v) {
@@ -1444,11 +1527,6 @@ class Base {
1444
1527
  return regex.test(str);
1445
1528
  }
1446
1529
 
1447
- // 判断变量是否为对象
1448
- static isObject(item) {
1449
- return (item) ? (item && typeof item === 'object' && !Array.isArray( item ) && true) : false;
1450
- }
1451
-
1452
1530
  // 允许插件扩展
1453
1531
  static plugin(pluginName, pluginFunction) {
1454
1532
  // Base.fn[pluginName] = pluginFunction;
@@ -1893,6 +1971,7 @@ class Base {
1893
1971
  // 2.4 静态属性
1894
1972
  // 生成缓存随机名称
1895
1973
  static expando = "base" + ("" + Math.random()).replace(/\D/g, "");
1974
+ static elementData = new Map();
1896
1975
  static cache = { };
1897
1976
 
1898
1977
  static build(selector, context) {
@@ -2025,6 +2104,7 @@ Array.prototype.unique = function () {
2025
2104
  10. 弹框搜索面板:new u.PopoverSearch('#ipopover', {
2026
2105
  11. 文字切换动画特效:new u.Flash("#ce-flash", {
2027
2106
  12. 绘制点线背景动画:new u.LineEffect("#canvas-warp", {
2107
+ 13. JS、CSS页面引入,多次引入只保留一个:const iloader = new u.ILoader();
2028
2108
 
2029
2109
  * ======================================================================== */
2030
2110
  /**
@@ -2131,6 +2211,7 @@ class SubmitFlag {
2131
2211
 
2132
2212
  init(element) {
2133
2213
  let myElems = base(element),
2214
+ /** @type {SubmitFlag<>} **/
2134
2215
  data = myElems.data("be.submitflag");
2135
2216
  myElems.data("text", myElems.text()).click((e) => {
2136
2217
  data.request(e.currentTarget);
@@ -2556,13 +2637,18 @@ class BtnEf {
2556
2637
  * ======================================================================== */
2557
2638
  class AeLoader {
2558
2639
  constructor(selector, custom) {
2559
- this.selector = selector;
2560
- this.options = base.extend( custom, this.options )
2640
+ this.selector = '';
2641
+ if(base.isObject(selector)) {
2642
+ this.options = base.extend( selector, this.options );
2643
+ } else {
2644
+ if(selector) this.selector = selector;
2645
+ this.options = base.extend( custom, this.options )
2646
+ }
2561
2647
  base("[data-ae-load]").addClass("ae-load");
2562
2648
  }
2563
2649
 
2564
2650
  options = {
2565
- target: '',
2651
+ // target: '',
2566
2652
  //默认1秒,修改需要同时也需要修改CSS动画
2567
2653
  time: 1000
2568
2654
  }
@@ -2590,8 +2676,8 @@ class AeLoader {
2590
2676
 
2591
2677
  base("[data-ae-load]").addClass("ae-load");
2592
2678
  base(target + "[data-ae-load]").each(function(currentTarget) {
2593
- let minWidth = base(currentTarget).data("al-mw");
2594
- let minHeight = base(currentTarget).data("al-mh");
2679
+ const minWidth = base(currentTarget).data("al-mw"),
2680
+ minHeight = base(currentTarget).data("al-mh");
2595
2681
  if (minWidth) base(currentTarget).css("min-width", minWidth);
2596
2682
  if (minHeight) base(currentTarget).css("min-height", minHeight);
2597
2683
 
@@ -2625,7 +2711,7 @@ class AeLoader {
2625
2711
  * 2024年6月29日 10:28:55
2626
2712
  * ========================================================================
2627
2713
  * <pre>
2628
- <div class="be-paging-warp">
2714
+ <div id="be-pw" class="be-paging-warp">
2629
2715
  <p></p>
2630
2716
  <nav>
2631
2717
  <ul id="ipagination" class="be-paging"></ul>
@@ -2664,10 +2750,10 @@ class IPagination {
2664
2750
  }
2665
2751
  // containerId, totalItems, itemsPerPage, visiblePages = 5
2666
2752
  options = {
2667
- targetWarp: '.be-paging-warp',
2753
+ targetWarp: '#be-pw', //不同分页区分
2668
2754
  totalItems: 0, //总条数
2669
2755
  itemsPerPage: 0, //一页几条数据
2670
- visiblePages: 5, //显示多少可见页
2756
+ visiblePages: 5, //多少按钮页可见
2671
2757
  prev: '上一页', //or: <i class="bi bi-chevron-left"></i>
2672
2758
  next: '下一页', //or: <i class="bi bi-chevron-right"></i>
2673
2759
  first: '首页', //or: <i class="bi bi-chevron-double-left"></i>
@@ -2769,7 +2855,7 @@ class IPagination {
2769
2855
  </div>
2770
2856
  <div class="be-list-nofound">查询不到相应数据!</div>
2771
2857
  <div class="be-list-page">
2772
- <div class="be-paging-warp">
2858
+ <div id="ilist-ip-warp" class="be-paging-warp">
2773
2859
  <p></p>
2774
2860
  <nav>
2775
2861
  <ul id="ipagination" class="be-paging"></ul>
@@ -2946,6 +3032,7 @@ class IList {
2946
3032
  template: "#tp-list",
2947
3033
  headerMap: { }, //{ 'Content-Type': 'application/json'}
2948
3034
  cache: 'default',
3035
+ ipWarp: '#ilist-ip-warp',
2949
3036
  prev: '上一页', //or: <i class="bi bi-chevron-left"></i>
2950
3037
  next: '下一页', //or: <i class="bi bi-chevron-right"></i>
2951
3038
  first: '首页', //or: <i class="bi bi-chevron-double-left"></i>
@@ -2982,7 +3069,8 @@ class IList {
2982
3069
 
2983
3070
  // 数据查询
2984
3071
  getData(element, options, param) {
2985
- let target = this;
3072
+ let target = this,
3073
+ myElement = base(element);
2986
3074
  base(".be-list-data-body", element).html("");
2987
3075
  base(".be-list-loading", element).addClass("opacity-100");
2988
3076
  base(".be-list-nofound", element).removeClass("opacity-100");
@@ -3017,11 +3105,29 @@ class IList {
3017
3105
 
3018
3106
  if (data.total) {
3019
3107
  target.page(element, options, param, data.total);//翻页
3020
- //全选/全清
3108
+
3109
+ // 全选/全清
3021
3110
  base(".ilist-check-all").checkAll('.ilist-check');
3022
3111
 
3023
- if (base(element).data("be.ilist.event")) {
3024
- base(element).data("be.ilist.event", false);
3112
+ //点击列选择单列/点击列取消选择单列
3113
+ base( "table > tbody tr", element ).click( e => {
3114
+ let target = base( e.target );
3115
+ if (!(target.is( "input" ) || target.is( "i" ) || target.is( "a" ))) {
3116
+ base( ".ilist-check", e.currentTarget ).click();
3117
+ }
3118
+ } )
3119
+
3120
+ // 全选列/全清列
3121
+ // b( ".ilist-check-all", element ).change( e => {
3122
+ // let isChecked = b( e.currentTarget ).is( ":checked" );
3123
+ // if (isChecked)
3124
+ // b( ".ilist-check" ).addClass( "active" ).trigger("change");
3125
+ // else
3126
+ // b( ".ilist-check" ).removeClass( "active" ).trigger("change");
3127
+ // } );
3128
+
3129
+ if (myElement.data("be.ilist.event")) {
3130
+ myElement.data("be.ilist.event", false);
3025
3131
 
3026
3132
  //选择单列/取消选择单列
3027
3133
  base( ".ilist-check", element ).change( e => {
@@ -3032,27 +3138,14 @@ class IList {
3032
3138
  base(e.currentTarget).parents("tr").removeClass("active");
3033
3139
  } );
3034
3140
 
3035
- //全选列/全清列
3036
- base( ".ilist-check-all", element ).change( e => {
3037
- let isChecked = base( e.currentTarget ).is( ":checked" );
3038
- if (isChecked)
3039
- base( ".ilist-check" ).addClass( "active" ).trigger("change");
3040
- else
3041
- base( ".ilist-check" ).removeClass( "active" ).trigger("change");
3042
- } );
3043
-
3044
- //点击列选择单列/点击列取消选择单列
3045
- base( "table > tbody tr", element ).click( e => {
3046
- let target = base( e.target );
3047
- if (!(target.is( "input" ) || target.is( "i" ) || target.is( "a" ))) {
3048
- base( ".ilist-check", e.currentTarget ).click();
3049
- }
3050
- } )
3051
-
3052
3141
  //排序,<td data-sortname="a.title" data-is-sort="true"
3053
3142
  base( "table > thead tr td", element ).click( e => {
3054
3143
  const sortname = base( e.currentTarget ).data( "sortname" );
3055
3144
  if (sortname) {
3145
+ const reloadParam = myElement.data("be.ilist.param");
3146
+ if (reloadParam) {
3147
+ param = base.extend(reloadParam, param);
3148
+ }
3056
3149
  param.sortname = sortname;
3057
3150
  if (!base( e.currentTarget ).hasClass( "is-check" ) && param.sortname) {
3058
3151
  let sortorder = base( e.currentTarget ).attr( "data-sort-order" );
@@ -3073,7 +3166,7 @@ class IList {
3073
3166
  param.sortorder = "desc";
3074
3167
  }
3075
3168
 
3076
- base( element ).data( "be.ilist.flag", true );
3169
+ myElement.data("be.ilist.flag", true );
3077
3170
  param.page = "1";
3078
3171
  options.isInit = false;
3079
3172
  target.getData( element, options, param );
@@ -3101,8 +3194,9 @@ class IList {
3101
3194
  page(element, options, param, total) {
3102
3195
  let target = this,
3103
3196
  myElement = base(element);
3104
- if (myElement.data("be.ilist.flag")) {
3197
+ if (myElement.data("be.ilist.flag")) { //每次都重新生成一次分页
3105
3198
  new IPagination('#ipagination', {
3199
+ targetWarp: options.ipWarp,
3106
3200
  totalItems: total,
3107
3201
  itemsPerPage: options.rp,
3108
3202
  visiblePages: options.visiblePages,
@@ -3123,12 +3217,15 @@ class IList {
3123
3217
 
3124
3218
  // 设置参数重新搜索
3125
3219
  reload(param) {
3126
- let target = base(this),
3127
- data = target.data("be.ilist"),
3220
+ let myElement = base(this.selector),
3221
+ /** @type {IList<>} **/
3222
+ data = myElement.data("be.ilist"),
3128
3223
  newParam = base.extend(param,
3129
3224
  { page: 1, rp: data.options.rp, sortname: data.options.sortname, sortorder: data.options.sortorder });
3130
3225
  data.options.isInit = false;
3131
- target.data("be.ilist.flag", true);
3226
+ myElement.data("be.ilist.flag", true);
3227
+ myElement.data("be.ilist.param", newParam);
3228
+ base('table > thead tr td', myElement).attr('data-sort-order', '');
3132
3229
  data["getData"](data['selector'], data.options, newParam);
3133
3230
  }
3134
3231
  }
@@ -3585,7 +3682,6 @@ class PopoverSearch {
3585
3682
  // 获取参数
3586
3683
  getParam() {
3587
3684
  const params = {};
3588
- base.l(base(".popover-form-item"))
3589
3685
  base(".popover-form-item").each(function(e) {
3590
3686
  const myEle = base(e),
3591
3687
  name = myEle.attr("name"),
@@ -3933,38 +4029,52 @@ class LineEffect {
3933
4029
  // 监听事件,移动鼠标, 滚动, 改变屏幕大小
3934
4030
  addListeners(options, xy, canvas) {
3935
4031
  const target = this;
3936
- if(!('ontouchstart' in window)) {
3937
- window.addEventListener("mousemove", (e) => {
3938
- target.mouseMove(e, xy);
3939
- });
3940
- }
3941
- window.addEventListener("scroll", () => {
4032
+ const mousemove = (e) => {
4033
+ target.mouseMove(e, xy);
4034
+ };
4035
+ const scroll = () => {
3942
4036
  target.scrollCheck(options);
3943
- });
3944
- window.addEventListener("resize", () => {
4037
+ };
4038
+ const resize = () => {
3945
4039
  target.resize(options, canvas);
3946
- });
4040
+ };
4041
+
4042
+ if (document.getElementById(target.options.canvasId)) {
4043
+ if(!('ontouchstart' in window)) {
4044
+ window.addEventListener("mousemove", mousemove);
4045
+ }
4046
+ window.addEventListener("scroll", scroll);
4047
+ window.addEventListener("resize", resize);
4048
+ } else {
4049
+ if(!('ontouchstart' in window)) {
4050
+ window.removeEventListener("mousemove", mousemove);
4051
+ }
4052
+ window.removeEventListener("scroll", scroll);
4053
+ window.removeEventListener("resize", resize);
4054
+ }
3947
4055
  }
3948
4056
 
3949
4057
  mouseMove(e, xy) {
3950
- const canvas = document.getElementById(this.options.canvasId),
3951
- rect = canvas.getBoundingClientRect(),
3952
- scrollTop = window.pageYOffset || document.documentElement.scrollTop,
3953
- scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
3954
- offsetTop = rect.top + scrollTop,
3955
- offsetLeft = rect.left + scrollLeft;
3956
-
3957
- let posx = 0,
3958
- posy = 0;
3959
- if (e.pageX || e.pageY) {
3960
- posx = e.pageX;
3961
- posy = e.pageY;
3962
- } else if (e.clientX || e.clientY) {
3963
- posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
3964
- posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
4058
+ const canvas = document.getElementById(this.options.canvasId);
4059
+ if (canvas) {
4060
+ const rect = canvas.getBoundingClientRect(),
4061
+ scrollTop = window.pageYOffset || document.documentElement.scrollTop,
4062
+ scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
4063
+ offsetTop = rect.top + scrollTop,
4064
+ offsetLeft = rect.left + scrollLeft;
4065
+
4066
+ let posx = 0,
4067
+ posy = 0;
4068
+ if (e.pageX || e.pageY) {
4069
+ posx = e.pageX;
4070
+ posy = e.pageY;
4071
+ } else if (e.clientX || e.clientY) {
4072
+ posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
4073
+ posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
4074
+ }
4075
+ xy.x = posx - offsetLeft;
4076
+ xy.y = posy - offsetTop;
3965
4077
  }
3966
- xy.x = posx - offsetLeft;
3967
- xy.y = posy - offsetTop;
3968
4078
  }
3969
4079
 
3970
4080
  scrollCheck(options) {
@@ -3978,7 +4088,6 @@ class LineEffect {
3978
4088
  }
3979
4089
 
3980
4090
 
3981
-
3982
4091
  /* ========================================================================
3983
4092
  * 12. 鼠标上下左右划入监听实现对应动画
3984
4093
  * 2022年7月28日 10:50:06
@@ -4108,6 +4217,169 @@ class HoverDir {
4108
4217
  }
4109
4218
 
4110
4219
 
4220
+ /* ========================================================================
4221
+ * 13. JS、CSS页面引入,多次引入只保留一个
4222
+ * 2024年9月15日 09:19:37
4223
+ * ========================================================================
4224
+ * <pre>
4225
+ const iloader = new u.ILoader();
4226
+ Promise.all([
4227
+ iloader.loadStyle('https://arisu.cn/te/WEB/css/animate.v4.css'),
4228
+ iloader.loadScript('https://arisu.cn/te/WEB/js/handlebars-v4.0.5.js'),
4229
+ iloader.loadScript('https://arisu.cn/te/WEB/js/imagesloaded.pkgd.min.js'),
4230
+ ]).then(() => {
4231
+ console.log('All scripts、style loaded');
4232
+ }).catch(error => {
4233
+ console.error('Error loading scripts、style', error);
4234
+ });
4235
+ * </pre>
4236
+ * ======================================================================== */
4237
+ class ILoader {
4238
+ constructor(custom) {
4239
+ /** @type {Array<{script: HTMLElement, url: string, isLoaded: boolean}>} **/
4240
+ this.jsLoaded = [];
4241
+ this.cssLoaded = [];
4242
+ this.options = base.extend( custom, this.options );
4243
+ }
4244
+ options = {
4245
+ // 脚本加载失败,重新尝试次数和每次使用时间(毫秒)
4246
+ times: 20,
4247
+ time: 1000
4248
+ }
4249
+
4250
+ /** 定义一个加载并执行外部 JS 文件的函数
4251
+ const iloader = new u.ILoader();
4252
+ Promise.all([
4253
+ iloader.loadScript('https://arisu.cn/te/WEB/js/handlebars-v4.0.5.js'),
4254
+ iloader.loadScript('https://arisu.cn/te/WEB/js/imagesloaded.pkgd.min.js')
4255
+ ]).then(() => {
4256
+ console.log('All scripts loaded');
4257
+ }).catch(error => {
4258
+ console.error('Error loading scripts', error);
4259
+ });
4260
+ * @param url
4261
+ * @returns {Promise<unknown>}
4262
+ */
4263
+ loadScript(url) {
4264
+ const target = this;
4265
+
4266
+ return new Promise((resolve, reject) => {
4267
+ // 检查是否已经加载过该脚本
4268
+ const existingScript = target.jsLoaded.find(script => script.url === url);
4269
+ if (!existingScript) {
4270
+ // 页面上未引入
4271
+ let script = document.createElement('script'),
4272
+ isOnload = false,
4273
+ count = 0;
4274
+
4275
+ target.jsLoaded = [...target.jsLoaded, { script: script, url: url, isLoaded: false, count: 0 }];
4276
+
4277
+ script.src = url;
4278
+ // script.async = 'true';
4279
+ script.onload = () => {
4280
+ target.jsLoaded = target.jsLoaded.map(item =>
4281
+ item.url === url ? { ...item, isLoaded: true } : item
4282
+ );
4283
+ isOnload = true;
4284
+ resolve(script);
4285
+ };
4286
+ script.onerror = () => {
4287
+ target.jsLoaded = target.jsLoaded.filter(item => item.url !== url);
4288
+ reject(new Error('Script load error for ' + url));
4289
+ }
4290
+ document.body.append(script);
4291
+ const intervalId = setInterval(() => {
4292
+ if (isOnload) {
4293
+ // b.l('载入成功!: ', url)
4294
+ clearInterval(intervalId);
4295
+ return;
4296
+ } else {
4297
+ if (count > target.options.times) {
4298
+ // console.log('载入失败!: ', url)
4299
+ if (script.parentNode === document.body) document.body.removeChild(script);
4300
+ clearInterval(intervalId);
4301
+ return;
4302
+ }
4303
+ }
4304
+ count++;
4305
+ }, 100);
4306
+ } else {
4307
+ // 页面上已经引入,但是还未调用
4308
+ let count = 0, scriptItem;
4309
+ const intervalId = setInterval(() => {
4310
+ scriptItem = target.jsLoaded.find(item => item.url === url);
4311
+ base.l('尝试加载中: ', url, count)
4312
+ try {
4313
+ if (!scriptItem.isLoaded && count > target.options.times) {
4314
+ // b.l('删除了URL: ', scriptItem.url);
4315
+ target.jsLoaded = target.jsLoaded.filter(item => item.url !== url);
4316
+ if (scriptItem.script.parentNode === document.body) document.body.removeChild(scriptItem.script);
4317
+ clearInterval(intervalId);
4318
+ return;
4319
+ }
4320
+
4321
+ if (scriptItem.isLoaded) {
4322
+ // b.l('载入成功 ');
4323
+ clearInterval(intervalId);
4324
+ resolve();
4325
+ return;
4326
+ }
4327
+ count++;
4328
+ } catch(e) { console.error(e) }
4329
+ }, target.options.time);
4330
+ }
4331
+ })
4332
+ }
4333
+
4334
+ /** 定义一个加载并执行外部 JS 文件的函数
4335
+ Promise.all([
4336
+ loadScript('https://arisu.cn/te/WEB/css/buttons-plus.css'),
4337
+ loadStyle('https://arisu.cn/te/WEB/css/animate.v4.css')
4338
+ ]).then(() => {
4339
+ console.log('All scripts/style loaded');
4340
+ }).catch(error => {
4341
+ console.error('Error loading', error);
4342
+ });
4343
+ * @param href 样式地址
4344
+ * @returns {Promise<unknown>}
4345
+ */
4346
+ loadStyle(href) {
4347
+ const target = this;
4348
+ return new Promise((resolve, reject) => {
4349
+ // 检查是否已经加载了CSS文件
4350
+ const links = document.getElementsByTagName("link");
4351
+ for (let i = 0; i < links.length; i++) {
4352
+ if (links[i].getAttribute("href") === href) {
4353
+ resolve();
4354
+ return true;
4355
+ }
4356
+ }
4357
+
4358
+ let style = document.createElement('link');
4359
+ style.href = href;
4360
+ style.rel = 'stylesheet';
4361
+ style.type = 'text/css';
4362
+ style.onload = () => resolve(style);
4363
+ style.onerror = () => reject(new Error('Style load error for ' + href));
4364
+ document.head.append(style);
4365
+ target.cssLoaded.push(style);
4366
+ });
4367
+ }
4368
+
4369
+ // 删除所有引入脚本、样式
4370
+ destroy() {
4371
+ this.jsLoaded.forEach((item)=>{
4372
+ if (item.script && item.script.parentNode === document.body) document.body.removeChild(item.script);
4373
+ })
4374
+ this.cssLoaded.forEach((item)=>{
4375
+ if (item.parentNode === document.head) document.head.removeChild(item);
4376
+ })
4377
+ this.jsLoaded = [];
4378
+ this.cssLoaded = [];
4379
+ }
4380
+ }
4381
+
4382
+
4111
4383
 
4112
4384
 
4113
4385
  /* harmony default export */ const utils = (base);
@@ -4263,7 +4535,12 @@ function owl($target, options) {
4263
4535
  utils['owl'] = owl;
4264
4536
 
4265
4537
 
4266
- // 消息框参数设置
4538
+ /**
4539
+ * 消息框参数设置:messageInit('info', 1, 2)
4540
+ * @param type info / error / success
4541
+ * @param classes 消息位置(2:顶部 / 6:左下下) ,按顺时针显示
4542
+ * @param theme 样式(2:黑色), 1:flat、2:future、3:block、4:air、5:ice
4543
+ **/
4267
4544
  function messageInit(type, classes, theme) {
4268
4545
  // 弹框样式,需要导入对应CSS
4269
4546
  if (theme === 1) {
@@ -4677,6 +4954,7 @@ utils['niceScroll'] = niceScroll;
4677
4954
  function validationEngine($target, options) {
4678
4955
  options = utils.extend(options, {
4679
4956
  focusFirstField : false,
4957
+ validationEventTrigger: "click",
4680
4958
  promptPosition: "topRight"
4681
4959
  });
4682
4960
  $target.validationEngine(options);
@@ -4687,13 +4965,14 @@ utils['validationEngine'] = validationEngine;
4687
4965
  * 14. validationEngine表单验证,确认是否验证通过
4688
4966
  * @param $target jQuery选择器
4689
4967
  * @param command 字符串方法名
4968
+ * @param options 新参数
4690
4969
  <pre>
4691
4970
  const isSuccessed = b.validate($("#form-2"));
4692
4971
  </pre>
4693
4972
  **/
4694
- function validate($target, command) {
4695
- const options = utils.extend( { command: command }, { command: "validate" });
4696
- return $target.validationEngine(options.command);
4973
+ function validate($target, command, options) {
4974
+ const os = utils.extend( { command: command }, { command: "validate", options });
4975
+ return $target.validationEngine(os.command, os.options);
4697
4976
  }
4698
4977
  utils['validate'] = validate;
4699
4978