arisu.js 1.0.4 → 2.0.1-alpha.1
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 +3 -1
- package/dist/arisu.commonjs.js +1 -0
- package/dist/arisu.esm.js +1 -0
- package/dist/arisu.umd.js +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/js/base.d.ts +152 -0
- package/dist/types/js/base.d.ts.map +1 -0
- package/dist/types/js/utils/GoTop.d.ts +9 -0
- package/dist/types/js/utils/GoTop.d.ts.map +1 -0
- package/dist/types/js/utils/IAccordion.d.ts +17 -0
- package/dist/types/js/utils/IAccordion.d.ts.map +1 -0
- package/package.json +23 -6
- package/dist/arisu.commonjs.min.js +0 -1
- package/dist/arisu.js +0 -4985
- package/dist/arisu.min.js +0 -1
- package/dist/arisu.module.min.js +0 -1
- package/dist/arisu.window.min.js +0 -1
- package/src/js/base.js +0 -2000
- package/src/js/main.js +0 -594
- package/src/js/utils.js +0 -2304
- package/webpack.config.js +0 -137
package/src/js/utils.js
DELETED
|
@@ -1,2304 +0,0 @@
|
|
|
1
|
-
import b from './base'
|
|
2
|
-
|
|
3
|
-
/* ========================================================================
|
|
4
|
-
* 常用JS插件组件
|
|
5
|
-
* 2024年6月7日 15:50:36
|
|
6
|
-
* ========================================================================
|
|
7
|
-
//使用范例
|
|
8
|
-
import b, * as u from 'ilib/utils'
|
|
9
|
-
let sf = new u.SubmitFlag(".e2")
|
|
10
|
-
or
|
|
11
|
-
import b, { SubmitFlag } from 'ilib/utils'
|
|
12
|
-
let sf = new SubmitFlag(".e2")
|
|
13
|
-
|
|
14
|
-
1. SubmitFlag防用户多次点击:new u.SubmitFlag(".e2")
|
|
15
|
-
2. 底部按钮快速移动到顶部:new u.GoTop({
|
|
16
|
-
3. 数字增加减少,购物数量控制:new u.ItemCount({
|
|
17
|
-
4. niceSelect自定义下拉框:new u.NiceSelect('#ns2')
|
|
18
|
-
5. 按钮动画:new u.BtnEf(".bn-btn-5")
|
|
19
|
-
6. 局部loading动画:new u.AeLoader()...
|
|
20
|
-
7. 分页:new u.IPagination({ target: '#ipagination'...
|
|
21
|
-
8. 列表查询分页封装插件:const ilist = new u.IList({ target: '#test-list' ..
|
|
22
|
-
9. 手风琴导航菜单:new u.IAccordion({ speed: 300, showCount: true });
|
|
23
|
-
10. 弹框搜索面板:new u.PopoverSearch('#ipopover', {
|
|
24
|
-
11. 文字切换动画特效:new u.Flash("#ce-flash", {
|
|
25
|
-
12. 绘制点线背景动画:new u.LineEffect("#canvas-warp", {
|
|
26
|
-
13. JS、CSS页面引入,多次引入只保留一个:const iloader = new u.ILoader();
|
|
27
|
-
|
|
28
|
-
* ======================================================================== */
|
|
29
|
-
/**
|
|
30
|
-
* 自定义组件初始化参数
|
|
31
|
-
* @param iclass 自定义组件
|
|
32
|
-
* @param selector 选择器
|
|
33
|
-
* @param custom 自定义参数
|
|
34
|
-
* @param callback 回调方法
|
|
35
|
-
*/
|
|
36
|
-
const defaultConstructor = (iclass, selector, custom, callback) => {
|
|
37
|
-
// if (typeof custom === 'string') {
|
|
38
|
-
// iclass.elements = document.querySelectorAll( custom );
|
|
39
|
-
// iclass.options = b.extend( { target: custom }, iclass.options )
|
|
40
|
-
// iclass.selector = custom;
|
|
41
|
-
// } else {
|
|
42
|
-
// if (typeof custom.target === 'string') {
|
|
43
|
-
// iclass.elements = document.querySelectorAll( custom.target );
|
|
44
|
-
// } else
|
|
45
|
-
// if (custom.target instanceof NodeList || custom.target instanceof HTMLElement) {
|
|
46
|
-
// iclass.elements = [ custom.target ];
|
|
47
|
-
// } else {
|
|
48
|
-
// iclass.elements = document.querySelectorAll( iclass.options.target );
|
|
49
|
-
// }
|
|
50
|
-
// }
|
|
51
|
-
if (typeof selector === 'string') {
|
|
52
|
-
iclass.elements = document.querySelectorAll( selector );
|
|
53
|
-
} else if (selector instanceof NodeList || selector instanceof HTMLElement) {
|
|
54
|
-
iclass.elements = [ selector ];
|
|
55
|
-
} else {
|
|
56
|
-
iclass.elements = document.querySelectorAll( selector );
|
|
57
|
-
}
|
|
58
|
-
iclass.options = b.extend( custom, iclass.options )
|
|
59
|
-
callback(iclass);
|
|
60
|
-
|
|
61
|
-
// if (iclass.elements.length !== 1) {
|
|
62
|
-
// throw new Error('未正确设置生效标签,请确保传入"#id"或唯一的".class"');
|
|
63
|
-
// }
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
//普通方法
|
|
68
|
-
// function test(p1, p2) {
|
|
69
|
-
// console.log(this, p1, p2)
|
|
70
|
-
// }
|
|
71
|
-
// b['test'] = test;
|
|
72
|
-
// // 插件
|
|
73
|
-
// +function(b) {
|
|
74
|
-
// function myPlugin(options) {
|
|
75
|
-
// b.l(options);
|
|
76
|
-
// this.each((index, element) => {
|
|
77
|
-
// b.l(index);
|
|
78
|
-
// b.l(element);
|
|
79
|
-
// });
|
|
80
|
-
// return this;
|
|
81
|
-
// }
|
|
82
|
-
// b.plugin('myPlugin', myPlugin);
|
|
83
|
-
// 废弃直接使用:
|
|
84
|
-
// b['plugin'] = plugin;
|
|
85
|
-
// }(Base);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// 自定义组件
|
|
91
|
-
|
|
92
|
-
/* ========================================================================
|
|
93
|
-
* 1. 提交后台过程中让按钮不可用,防止用户多次点击
|
|
94
|
-
* 2016年6月26日10:08:11
|
|
95
|
-
* ========================================================================
|
|
96
|
-
* <pre>
|
|
97
|
-
<button href="#" class="e2 btn btn-danger">发送请求a</button>
|
|
98
|
-
<button href="#" class="e2 btn btn-danger">发送请求b</button>
|
|
99
|
-
<button id="stopSF" href="#" class="btn btn-danger">停止发送请求</button>
|
|
100
|
-
|
|
101
|
-
// let sf = new u.SubmitFlag(".e2")
|
|
102
|
-
// 或者
|
|
103
|
-
let sf = new u.SubmitFlag(".e2", {
|
|
104
|
-
text: "数据请求中..",
|
|
105
|
-
useText: true
|
|
106
|
-
})
|
|
107
|
-
b("#stopSF").click(() => {
|
|
108
|
-
sf.complete();
|
|
109
|
-
})
|
|
110
|
-
* </pre>
|
|
111
|
-
* ======================================================================== */
|
|
112
|
-
export class SubmitFlag {
|
|
113
|
-
constructor(selector, custom) {
|
|
114
|
-
this.selector = selector;
|
|
115
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
116
|
-
target.elements.forEach((element) => {
|
|
117
|
-
let myElems = b(element);
|
|
118
|
-
if (!myElems.data("be.submitflag"))
|
|
119
|
-
myElems.data("be.submitflag", target);
|
|
120
|
-
|
|
121
|
-
target.init(element);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
options = {
|
|
127
|
-
text: "处理中..",
|
|
128
|
-
useText: true
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
init(element) {
|
|
132
|
-
let myElems = b(element),
|
|
133
|
-
/** @type {SubmitFlag<>} **/
|
|
134
|
-
data = myElems.data("be.submitflag");
|
|
135
|
-
myElems.data("text", myElems.text()).click((e) => {
|
|
136
|
-
data.request(e.currentTarget);
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
request(element) {
|
|
141
|
-
let myElems = b(element);
|
|
142
|
-
myElems.addClass("submit-flag-request").data("text", myElems.text()).attr("disabled", "disabled");
|
|
143
|
-
myElems.text(this.options.text);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
complete(element) {
|
|
147
|
-
let myElems = (element) ? b(element) : b(this.selector);
|
|
148
|
-
myElems.removeClass("submit-flag-request").removeAttr("disabled");
|
|
149
|
-
if (myElems.data("text") && this.options.useText)
|
|
150
|
-
myElems.text(myElems.data("text"));
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
destroy() {
|
|
154
|
-
b(this.selector).removeData("be.submitflag");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* ========================================================================
|
|
159
|
-
* 2. 底部按钮快速移动到顶部,按钮出现/消失需要用到animate.css v4,缓动需要样式html { scroll-behavior: smooth; }
|
|
160
|
-
* 2018年7月3日11:55:06
|
|
161
|
-
* ========================================================================
|
|
162
|
-
* <pre>
|
|
163
|
-
<a class="ce-gotop" href="javascript:">
|
|
164
|
-
<i class="bi bi-chevron-up"></i>
|
|
165
|
-
</a>
|
|
166
|
-
|
|
167
|
-
import 'istyle/src/css/case/ce-gotop.css';
|
|
168
|
-
new u.GoTop(".ce-gotop", {
|
|
169
|
-
position: {
|
|
170
|
-
bottom: "15px",
|
|
171
|
-
right: "15px"
|
|
172
|
-
},
|
|
173
|
-
showEffect: " animate__zoomIn ",
|
|
174
|
-
hideEffect: " animate__zoomOut ",
|
|
175
|
-
type: "fixed",
|
|
176
|
-
offsetTop: "400"
|
|
177
|
-
});
|
|
178
|
-
* </pre>
|
|
179
|
-
* ======================================================================== */
|
|
180
|
-
export class GoTop {
|
|
181
|
-
constructor(selector, custom) {
|
|
182
|
-
this.selector = selector;
|
|
183
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
184
|
-
target.elements.forEach((element) => {
|
|
185
|
-
let myElems = b(element);
|
|
186
|
-
if (!myElems.data("be.gotop"))
|
|
187
|
-
myElems.data("be.gotop", target);
|
|
188
|
-
|
|
189
|
-
target.init(element);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
options = {
|
|
195
|
-
position: {
|
|
196
|
-
bottom: "15px",
|
|
197
|
-
right: "15px"
|
|
198
|
-
},
|
|
199
|
-
showEffect: " animate__zoomIn ",
|
|
200
|
-
hideEffect: " animate__zoomOut ",
|
|
201
|
-
type: "fixed",
|
|
202
|
-
offsetTop: "400"
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
init(element) {
|
|
206
|
-
let t = this,
|
|
207
|
-
myElem = b(element),
|
|
208
|
-
type = t.options.type,
|
|
209
|
-
showEffect = t.options.showEffect,
|
|
210
|
-
position = t.options.position,
|
|
211
|
-
offsetTop = t.options.offsetTop,
|
|
212
|
-
hideEffect = t.options.hideEffect;
|
|
213
|
-
|
|
214
|
-
myElem.addClass("animate__animated").css({
|
|
215
|
-
"display": "inline-block",
|
|
216
|
-
"position": type,
|
|
217
|
-
"opacity": 0
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
if (type === "fixed" || type === "absolute") {
|
|
221
|
-
myElem.css(position);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
myElem.on("click", (e) => {
|
|
225
|
-
e.preventDefault();
|
|
226
|
-
scrollTo(0, 0);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
if (!offsetTop && !myElem.hasClass("animated-running")) {
|
|
230
|
-
if (myElem.offset().top <= b(window).height()) {
|
|
231
|
-
myElem.addClass("animated-running " + showEffect).css({
|
|
232
|
-
"opacity": ""
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
b(window).on("scroll", function () {
|
|
238
|
-
if (offsetTop) {
|
|
239
|
-
if (b(window).scrollTop() >= offsetTop && !myElem.hasClass("animated-running")) {
|
|
240
|
-
myElem.addClass("animated-running " + showEffect).css({
|
|
241
|
-
"opacity": ""
|
|
242
|
-
});
|
|
243
|
-
myElem.removeClass(hideEffect);
|
|
244
|
-
} else if (b(window).scrollTop() <= offsetTop && myElem.hasClass("animated-running")) {
|
|
245
|
-
myElem.removeClass("animated-running " + showEffect).css({
|
|
246
|
-
"opacity": 0
|
|
247
|
-
});
|
|
248
|
-
myElem.addClass(hideEffect);
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
251
|
-
let thisOffsetTop = myElem.offset().top;
|
|
252
|
-
|
|
253
|
-
if (!myElem.hasClass("animated-running")) {
|
|
254
|
-
if (b(window).scrollTop() >= thisOffsetTop - b(window).height()) {
|
|
255
|
-
myElem.addClass("animated-running " + showEffect).css({
|
|
256
|
-
"opacity": ""
|
|
257
|
-
});
|
|
258
|
-
myElem.removeClass(hideEffect);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
b(window).trigger("scroll");
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/* ========================================================================
|
|
269
|
-
* 3. 数字增加减少,购物数量控制
|
|
270
|
-
* 2018年1月20日22:14:46
|
|
271
|
-
* ========================================================================
|
|
272
|
-
* <pre>
|
|
273
|
-
<div class="fm-count fmc1">
|
|
274
|
-
<input class="form-control fm-result" type="text" value="1" readonly="">
|
|
275
|
-
<div class="fm-btns">
|
|
276
|
-
<i class="fm-plus bi bi-chevron-up"></i>
|
|
277
|
-
<i class="fm-minus bi bi-chevron-down"></i>
|
|
278
|
-
</div>
|
|
279
|
-
</div>
|
|
280
|
-
|
|
281
|
-
import 'istyle/src/css/form/fm-count.css';
|
|
282
|
-
new u.ItemCount(".fmc1", {
|
|
283
|
-
num: 1
|
|
284
|
-
})
|
|
285
|
-
* </pre>
|
|
286
|
-
* ======================================================================== */
|
|
287
|
-
export class ItemCount {
|
|
288
|
-
constructor(selector, custom) {
|
|
289
|
-
this.selector = selector;
|
|
290
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
291
|
-
this.value = 0;
|
|
292
|
-
target.elements.forEach((element) => {
|
|
293
|
-
let myElems = b(element);
|
|
294
|
-
if (!myElems.data("be.itemcount"))
|
|
295
|
-
myElems.data("be.itemcount", target);
|
|
296
|
-
|
|
297
|
-
target.init(element);
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
options = {
|
|
303
|
-
num: 1
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
init(element) {
|
|
307
|
-
let t = this,
|
|
308
|
-
myElem = b(element),
|
|
309
|
-
options = this.options,
|
|
310
|
-
myPlus = myElem.find(".fm-plus"),
|
|
311
|
-
myMinus = myElem.find(".fm-minus"),
|
|
312
|
-
myResult = myElem.find(".fm-result"),
|
|
313
|
-
resultVal = parseInt(myResult.val());
|
|
314
|
-
|
|
315
|
-
myPlus.on("click", function (e) {
|
|
316
|
-
e.preventDefault();
|
|
317
|
-
resultVal += options.num;
|
|
318
|
-
myResult.val(resultVal);
|
|
319
|
-
t.value = resultVal;
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
myMinus.on("click", function (e) {
|
|
323
|
-
e.preventDefault();
|
|
324
|
-
if (resultVal - options.num >= 0) {
|
|
325
|
-
resultVal -= options.num;
|
|
326
|
-
myResult.val(resultVal);
|
|
327
|
-
t.value = resultVal;
|
|
328
|
-
} else {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
getValue() {
|
|
335
|
-
return this.value;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/* ========================================================================
|
|
340
|
-
* 4. niceSelect下拉框
|
|
341
|
-
* 2022年8月14日 21:41:21
|
|
342
|
-
* ========================================================================
|
|
343
|
-
* <pre>
|
|
344
|
-
<div style="height: 5rem;">
|
|
345
|
-
<select id="ns2" class="ns-select mx-auto">
|
|
346
|
-
<option value="1">All Category</option>
|
|
347
|
-
<option value="2">HTML Template</option>
|
|
348
|
-
<option value="3">WP Theme</option>
|
|
349
|
-
<option value="4">Graphic Design</option>
|
|
350
|
-
</select>
|
|
351
|
-
</div>
|
|
352
|
-
<button id="nsBtn" href="#" class="btn btn-danger">获取下拉框值</button>
|
|
353
|
-
|
|
354
|
-
import 'istyle/src/css/case/ce-nice-select.css';
|
|
355
|
-
let ns = new u.NiceSelect('#ns2');
|
|
356
|
-
b("#nsBtn").click(() => {
|
|
357
|
-
b.l(ns.getValue())//选中下拉框value的值
|
|
358
|
-
b.l(ns.getText()) //选中下拉框文本
|
|
359
|
-
})
|
|
360
|
-
* </pre>
|
|
361
|
-
* ======================================================================== */
|
|
362
|
-
export class NiceSelect {
|
|
363
|
-
constructor(selector, custom) {
|
|
364
|
-
this.selector = selector;
|
|
365
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
366
|
-
this.selector = target.selector;
|
|
367
|
-
target.elements.forEach((element) => {
|
|
368
|
-
let myElems = b(element);
|
|
369
|
-
if (!myElems.data("be.niceselect"))
|
|
370
|
-
myElems.data("be.niceselect", target);
|
|
371
|
-
|
|
372
|
-
target.init(element);
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
options = {}
|
|
378
|
-
|
|
379
|
-
create(element) {
|
|
380
|
-
let t = this,
|
|
381
|
-
mySelect = b(element),
|
|
382
|
-
myDropdown = mySelect.after('<div></div>').next()
|
|
383
|
-
.addClass('ce-nice-select')
|
|
384
|
-
.addClass(mySelect.attr('class') || '')
|
|
385
|
-
.addClass(mySelect.attr('disabled') ? 'disabled' : '')
|
|
386
|
-
.attr('tabindex', mySelect.attr('disabled') ? null : '0')
|
|
387
|
-
.html('<span class="current"></span><ul class="list"></ul>');
|
|
388
|
-
|
|
389
|
-
let myOptions = mySelect.find('option');
|
|
390
|
-
let mySelected = b(element.options[element.selectedIndex]);
|
|
391
|
-
|
|
392
|
-
t.text = mySelected.data('display') || mySelected.text();
|
|
393
|
-
myDropdown.find('.current').html(t.text);
|
|
394
|
-
|
|
395
|
-
myOptions.each(function(element) {
|
|
396
|
-
let myOption = b(element),
|
|
397
|
-
display = myOption.data('display'),
|
|
398
|
-
isDisplay = (display !== null && display !== undefined ? display : ""),
|
|
399
|
-
isSelect = mySelected.text() === myOption.text() ? 'selected' : '';
|
|
400
|
-
myDropdown.find('ul').append("<li data-value=\"" + myOption.val() + "\" data-display=\"" + isDisplay +
|
|
401
|
-
"\" class=\"option " + isSelect + "\">" + myOption.text() + "</li>");
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
init(element) {
|
|
406
|
-
let t = this,
|
|
407
|
-
mySelector = b(t.selector),
|
|
408
|
-
myElement = b(element);
|
|
409
|
-
myElement.hide();
|
|
410
|
-
t.create(element);
|
|
411
|
-
let myNS = mySelector.next();
|
|
412
|
-
myNS.on('click', function() {
|
|
413
|
-
let myDropdown = myElement.next();
|
|
414
|
-
myDropdown.toggleClass('open');
|
|
415
|
-
if (myDropdown.hasClass('open')) {
|
|
416
|
-
myDropdown.find('.option');
|
|
417
|
-
myDropdown.find('.focus').removeClass('focus');
|
|
418
|
-
myDropdown.find('.selected').addClass('focus');
|
|
419
|
-
} else {
|
|
420
|
-
myDropdown.focus();
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
b('.option', myNS).on('click', function(e) {
|
|
425
|
-
let myOption = b(e.currentTarget);
|
|
426
|
-
let myDropdown = myNS;
|
|
427
|
-
myDropdown.find('.selected').removeClass('selected');
|
|
428
|
-
myOption.addClass('selected');
|
|
429
|
-
|
|
430
|
-
t.text = myOption.data('display') || myOption.text();
|
|
431
|
-
myDropdown.find('.current').text(t.text);
|
|
432
|
-
t.value = myOption.data('value');
|
|
433
|
-
myDropdown.prev('select').val(t.value).trigger('change');
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
return this;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
getText() {
|
|
440
|
-
return this.text;
|
|
441
|
-
}
|
|
442
|
-
getValue() {
|
|
443
|
-
return this.value;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
/* ========================================================================
|
|
449
|
-
* 5. 按钮动画
|
|
450
|
-
* 2023年8月30日 10:41:03
|
|
451
|
-
* ========================================================================
|
|
452
|
-
* <pre>
|
|
453
|
-
<a href="#" class="bn-btn-5">
|
|
454
|
-
<span>了解更多</span>
|
|
455
|
-
</a>
|
|
456
|
-
|
|
457
|
-
import 'istyle/src/css/button/bn-btn-5.css';
|
|
458
|
-
new u.BtnEf(".bn-btn-5");
|
|
459
|
-
* </pre>
|
|
460
|
-
* ======================================================================== */
|
|
461
|
-
export class BtnEf {
|
|
462
|
-
constructor(selector, custom) {
|
|
463
|
-
this.selector = selector;
|
|
464
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
465
|
-
this.value = 0;
|
|
466
|
-
target.elements.forEach((element) => {
|
|
467
|
-
let myElems = b(element);
|
|
468
|
-
if (!myElems.data("be.btnef"))
|
|
469
|
-
myElems.data("be.btnef", target);
|
|
470
|
-
|
|
471
|
-
target.init(element);
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
options = {};
|
|
477
|
-
|
|
478
|
-
init(element) {
|
|
479
|
-
b(element).append('<b></b>');
|
|
480
|
-
b(element).on('mouseenter', function (e) {
|
|
481
|
-
let parentOffset = b(this).offset(),
|
|
482
|
-
relX = e.pageX - parentOffset.left,
|
|
483
|
-
relY = e.pageY - parentOffset.top;
|
|
484
|
-
b(this).find('b').css({
|
|
485
|
-
'top': relY + 'px',
|
|
486
|
-
'left': relX + 'px'
|
|
487
|
-
});
|
|
488
|
-
}).on('mouseout', function (e) {
|
|
489
|
-
let parentOffset = b(this).offset(),
|
|
490
|
-
relX = e.pageX - parentOffset.left,
|
|
491
|
-
relY = e.pageY - parentOffset.top;
|
|
492
|
-
b(this).find('b').css({
|
|
493
|
-
'top': relY + 'px',
|
|
494
|
-
'left': relX + 'px'
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
// b("." + b(element).attr('class') + "[href='#']").click(function (e) {
|
|
498
|
-
// e.preventDefault()
|
|
499
|
-
// });
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
/* ========================================================================
|
|
505
|
-
* 6. 局部loading动画
|
|
506
|
-
* 2023年8月5日 10:55:51
|
|
507
|
-
* ========================================================================
|
|
508
|
-
* <pre>
|
|
509
|
-
<div class="do-load-warp mx-auto" style="text-align: left; width: 620px;">
|
|
510
|
-
<p class="mb-3 ae-test-target" data-ae-load>
|
|
511
|
-
在线客服正在为您服务
|
|
512
|
-
</p>
|
|
513
|
-
<h2 class="mb-3 ae-test-target" data-ae-load>
|
|
514
|
-
欢迎!我们能为您提供什么帮助?
|
|
515
|
-
</h2>
|
|
516
|
-
<div class="mb-5 " data-ae-load>
|
|
517
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="img-fluid mx-auto d-block"/>
|
|
518
|
-
</div>
|
|
519
|
-
</div>
|
|
520
|
-
|
|
521
|
-
<a id="ae-load-loading" class="btn btn-primary" href="#">显示loading动画</a>
|
|
522
|
-
<a id="ae-load-done" class="btn btn-primary" href="#">loading动画完成,显示数据</a>
|
|
523
|
-
<a id="ae-load-start" class="btn btn-primary" href="#">不需要加载数据,完整的loading动画</a>// let al = new u.AeLoader();//建议使用这个,在根据情况指定触发
|
|
524
|
-
|
|
525
|
-
import 'istyle/src/css/loading/ae-load.css';
|
|
526
|
-
// let al = new u.AeLoader();//建议使用这个,在根据情况指定触发
|
|
527
|
-
let al = new u.AeLoader('.ae-test-target', {
|
|
528
|
-
time: 1000 //默认1秒,修改需要同时也需要修改CSS动画
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
// 不需要加载数据,完整的loading动画
|
|
532
|
-
b("#ae-load-start").click(function(e) {
|
|
533
|
-
e.preventDefault();
|
|
534
|
-
//全部触发
|
|
535
|
-
al.start();
|
|
536
|
-
// 指定触发,如果初始化有指定则不需要
|
|
537
|
-
// al.start(".ae-test-target");
|
|
538
|
-
});
|
|
539
|
-
// 显示loading动画
|
|
540
|
-
b("#ae-load-loading").click(function(e) {
|
|
541
|
-
e.preventDefault();
|
|
542
|
-
//全部触发
|
|
543
|
-
al.loading();
|
|
544
|
-
// 指定触发,如果初始化有指定则不需要
|
|
545
|
-
// al.loading(".ae-test-target");
|
|
546
|
-
});
|
|
547
|
-
// loading动画完成,显示数据
|
|
548
|
-
b("#ae-load-done").click(function(e) {
|
|
549
|
-
e.preventDefault();
|
|
550
|
-
//全部触发
|
|
551
|
-
al.done();
|
|
552
|
-
// 指定触发,如果初始化有指定则不需要
|
|
553
|
-
// al.done(".ae-test-target");
|
|
554
|
-
});
|
|
555
|
-
* </pre>
|
|
556
|
-
* ======================================================================== */
|
|
557
|
-
export class AeLoader {
|
|
558
|
-
constructor(selector, custom) {
|
|
559
|
-
this.selector = '';
|
|
560
|
-
if(b.isObject(selector)) {
|
|
561
|
-
this.options = b.extend( selector, this.options );
|
|
562
|
-
} else {
|
|
563
|
-
if(selector) this.selector = selector;
|
|
564
|
-
this.options = b.extend( custom, this.options )
|
|
565
|
-
}
|
|
566
|
-
b("[data-ae-load]").addClass("ae-load");
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
options = {
|
|
570
|
-
// target: '',
|
|
571
|
-
//默认1秒,修改需要同时也需要修改CSS动画
|
|
572
|
-
time: 1000
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
//不需要加载数据,完整的loading动画
|
|
576
|
-
start(target) {
|
|
577
|
-
target = target ? target : this.selector;
|
|
578
|
-
// b(target + "[data-ae-load]").addClass("ae-load");
|
|
579
|
-
// b(target + "[data-ae-load]").removeClass("ae-tt-complete ae-tt-done ae-tt-loading");
|
|
580
|
-
// setTimeout(function() {
|
|
581
|
-
// b(target + "[data-ae-load]").addClass("ae-tt-complete");
|
|
582
|
-
// setTimeout(function() {b(target + "[data-ae-load]").removeClass("ae-load ae-tt-complete");}, 1000);
|
|
583
|
-
// }, 100);
|
|
584
|
-
b(target + "[data-ae-load]").addClass("ae-load")
|
|
585
|
-
.removeClass("ae-tt-complete ae-tt-done ae-tt-loading")
|
|
586
|
-
.addClass("ae-tt-complete");
|
|
587
|
-
setTimeout(function() {
|
|
588
|
-
b(target + "[data-ae-load]").removeClass("ae-load ae-tt-complete");
|
|
589
|
-
}, this.options.time);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
//显示loading动画
|
|
593
|
-
loading(target) {
|
|
594
|
-
target = target ? target : this.selector;
|
|
595
|
-
|
|
596
|
-
b("[data-ae-load]").addClass("ae-load");
|
|
597
|
-
b(target + "[data-ae-load]").each(function(currentTarget) {
|
|
598
|
-
const minWidth = b(currentTarget).data("al-mw"),
|
|
599
|
-
minHeight = b(currentTarget).data("al-mh");
|
|
600
|
-
if (minWidth) b(currentTarget).css("min-width", minWidth);
|
|
601
|
-
if (minHeight) b(currentTarget).css("min-height", minHeight);
|
|
602
|
-
|
|
603
|
-
// b(currentTarget).removeClass("ae-tt-complete ae-tt-done ae-tt-loading");
|
|
604
|
-
// setTimeout(function() {
|
|
605
|
-
// b(currentTarget).addClass("ae-tt-loading");
|
|
606
|
-
// }, 1);
|
|
607
|
-
b(currentTarget).removeClass("ae-tt-complete ae-tt-done ae-tt-loading").addClass("ae-tt-loading");
|
|
608
|
-
})
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
//loading动画完成,显示数据
|
|
612
|
-
done(target) {
|
|
613
|
-
target = target ? target : this.selector;
|
|
614
|
-
// b(target + "[data-ae-load]").removeClass("ae-tt-done");
|
|
615
|
-
// setTimeout(function() {
|
|
616
|
-
// b(target + "[data-ae-load]").addClass("ae-tt-done");
|
|
617
|
-
// setTimeout(function() {b(target + "[data-ae-load]").removeClass("ae-load ae-tt-loading ae-tt-done");}, 1000);
|
|
618
|
-
// }, 1);
|
|
619
|
-
b(target + "[data-ae-load]").removeClass("ae-tt-done").addClass("ae-tt-done");
|
|
620
|
-
setTimeout(function() {
|
|
621
|
-
b(target + "[data-ae-load]").removeClass("ae-load ae-tt-loading ae-tt-done");
|
|
622
|
-
}, this.options.time);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
/* ========================================================================
|
|
629
|
-
* 7. 分页
|
|
630
|
-
* 2024年6月29日 10:28:55
|
|
631
|
-
* ========================================================================
|
|
632
|
-
* <pre>
|
|
633
|
-
<div id="be-pw" class="be-paging-warp">
|
|
634
|
-
<p></p>
|
|
635
|
-
<nav>
|
|
636
|
-
<ul id="ipagination" class="be-paging"></ul>
|
|
637
|
-
</nav>
|
|
638
|
-
</div>
|
|
639
|
-
|
|
640
|
-
new u.IPagination('#ipagination', {
|
|
641
|
-
totalItems: 100,
|
|
642
|
-
itemsPerPage: 10,
|
|
643
|
-
visiblePages: 5,
|
|
644
|
-
// prev: '<i class="bi bi-chevron-left"></i>',
|
|
645
|
-
// next: '<i class="bi bi-chevron-right"></i>',
|
|
646
|
-
// first: '<i class="bi bi-chevron-double-left"></i>',
|
|
647
|
-
// last: '<i class="bi bi-chevron-double-right"></i>',
|
|
648
|
-
onButtonClick: (page) => {
|
|
649
|
-
console.log('当前页为:', page);
|
|
650
|
-
}
|
|
651
|
-
})
|
|
652
|
-
* </pre>
|
|
653
|
-
* ======================================================================== */
|
|
654
|
-
export class IPagination {
|
|
655
|
-
constructor(selector, custom) {
|
|
656
|
-
this.selector = selector;
|
|
657
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
658
|
-
let t = this;
|
|
659
|
-
target.elements.forEach( ( element ) => {
|
|
660
|
-
let myElems = b( element );
|
|
661
|
-
if (!myElems.data( "be.ipagination" ))
|
|
662
|
-
myElems.data( "be.ipagination", target );
|
|
663
|
-
|
|
664
|
-
t.currentPage = 1;
|
|
665
|
-
t.totalPages = Math.ceil(t.options.totalItems / t.options.itemsPerPage);
|
|
666
|
-
target.init( );
|
|
667
|
-
} )
|
|
668
|
-
} );
|
|
669
|
-
}
|
|
670
|
-
// containerId, totalItems, itemsPerPage, visiblePages = 5
|
|
671
|
-
options = {
|
|
672
|
-
targetWarp: '#be-pw', //不同分页区分
|
|
673
|
-
totalItems: 0, //总条数
|
|
674
|
-
itemsPerPage: 0, //一页几条数据
|
|
675
|
-
visiblePages: 5, //多少按钮页可见
|
|
676
|
-
prev: '上一页', //or: <i class="bi bi-chevron-left"></i>
|
|
677
|
-
next: '下一页', //or: <i class="bi bi-chevron-right"></i>
|
|
678
|
-
first: '首页', //or: <i class="bi bi-chevron-double-left"></i>
|
|
679
|
-
last: '尾页', //or: <i class="bi bi-chevron-double-right"></i>
|
|
680
|
-
onButtonClick: function (currentPage) {}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
init() {
|
|
684
|
-
let target = this,
|
|
685
|
-
options = target.options;
|
|
686
|
-
|
|
687
|
-
b(this.selector).html('');
|
|
688
|
-
|
|
689
|
-
// 添加上一页和首页按钮
|
|
690
|
-
this.addPageButton(options.first, 1, () => this.goToPage(1));
|
|
691
|
-
this.addPageButton(options.prev, this.currentPage - 1, () => this.goToPrevPage());
|
|
692
|
-
|
|
693
|
-
// 根据当前页码计算要显示的页码范围
|
|
694
|
-
let startPage = Math.max(1, this.currentPage - Math.floor(options.visiblePages / 2)),
|
|
695
|
-
endPage = Math.min(this.totalPages, startPage + options.visiblePages - 1);
|
|
696
|
-
|
|
697
|
-
// 如果范围小于可见页数,则调整开始页码以显示更多前面的页码
|
|
698
|
-
if (endPage - startPage < options.visiblePages - 1) {
|
|
699
|
-
startPage = Math.max(1, endPage - options.visiblePages + 1);
|
|
700
|
-
}
|
|
701
|
-
// 显示页码按钮
|
|
702
|
-
for (let i = startPage; i <= endPage; i++) {
|
|
703
|
-
this.addPageButton(i, i, () => this.goToPage(i));
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
// 添加下一页和尾页按钮
|
|
707
|
-
this.addPageButton(options.next, this.currentPage + 1, () => this.goToNextPage());
|
|
708
|
-
this.addPageButton(options.last, this.totalPages, () => this.goToPage(this.totalPages));
|
|
709
|
-
const start = options.itemsPerPage * (target.currentPage - 1) + 1,
|
|
710
|
-
end = (start < options.totalItems - options.itemsPerPage ) ? ( start + options.itemsPerPage - 1 ) : ( start + options.totalItems % options.itemsPerPage - 1 );
|
|
711
|
-
b('p', options.targetWarp).html('显示 ' + start + ' 至 ' + end + ' 条,共有 ' + options.totalItems + ' 条');
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
addPageButton(text, page, onClick) {
|
|
715
|
-
const li = document.createElement('li');
|
|
716
|
-
li.classList.add('page-item');
|
|
717
|
-
if ( typeof text === 'number' && Number.isFinite(text) || !isNaN(Number(text)) && Number.isFinite(Number(text)) ) {
|
|
718
|
-
li.classList.add('pi-t2');
|
|
719
|
-
} else {
|
|
720
|
-
li.classList.add('pi-t1');
|
|
721
|
-
}
|
|
722
|
-
const button = document.createElement('button');
|
|
723
|
-
li.append(button);
|
|
724
|
-
button.innerHTML = text;
|
|
725
|
-
button.onclick = onClick;
|
|
726
|
-
if (page === this.currentPage || page === 0 || page === this.totalPages + 1) {
|
|
727
|
-
li.classList.add('active');
|
|
728
|
-
li.classList.add('disabled');
|
|
729
|
-
// button.disabled = true;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
b(this.selector).append(li);
|
|
733
|
-
}
|
|
734
|
-
goToPrevPage() {
|
|
735
|
-
if (this.currentPage > 1) {
|
|
736
|
-
this.currentPage--;
|
|
737
|
-
this.init();
|
|
738
|
-
this.options.onButtonClick(this.currentPage);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
goToNextPage() {
|
|
742
|
-
if (this.currentPage < this.totalPages) {
|
|
743
|
-
this.currentPage++;
|
|
744
|
-
this.init();
|
|
745
|
-
this.options.onButtonClick(this.currentPage);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
goToPage(page) {
|
|
749
|
-
if (page >= 1 && page <= this.totalPages) {
|
|
750
|
-
this.currentPage = page;
|
|
751
|
-
this.init();
|
|
752
|
-
this.options.onButtonClick(this.currentPage);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/* ========================================================================
|
|
758
|
-
* 8. 列表查询分页封装插件
|
|
759
|
-
* 列表查询分页封装插件,opacity-* 为css透明度
|
|
760
|
-
* 2016年7月27日15:02:29
|
|
761
|
-
* ========================================================================
|
|
762
|
-
* <pre>
|
|
763
|
-
// 1. 基础模板
|
|
764
|
-
<script type="text/template" id="tp-list">
|
|
765
|
-
<div class="be-list-data"></div>
|
|
766
|
-
<div class="be-list-loading">
|
|
767
|
-
<div class="do-preloader-3">
|
|
768
|
-
<div class="do-p3">
|
|
769
|
-
<div class="do-p3-inner do-p3-i1"></div>
|
|
770
|
-
<div class="do-p3-inner do-p3-i2"></div>
|
|
771
|
-
<div class="do-p3-inner do-p3-i3"></div>
|
|
772
|
-
</div>
|
|
773
|
-
</div>
|
|
774
|
-
</div>
|
|
775
|
-
<div class="be-list-nofound">查询不到相应数据!</div>
|
|
776
|
-
<div class="be-list-page">
|
|
777
|
-
<div id="ilist-ip-warp" class="be-paging-warp">
|
|
778
|
-
<p></p>
|
|
779
|
-
<nav>
|
|
780
|
-
<ul id="ipagination" class="be-paging"></ul>
|
|
781
|
-
</nav>
|
|
782
|
-
</div>
|
|
783
|
-
</div>
|
|
784
|
-
</script>
|
|
785
|
-
// 2. 数据列表模型,如新闻
|
|
786
|
-
<script type="text/template" id="tp-data-news">
|
|
787
|
-
{{#if isInit true}}
|
|
788
|
-
<table class="be-table">
|
|
789
|
-
<thead>
|
|
790
|
-
<tr>
|
|
791
|
-
<td class="xs-show be-te-check is-check">
|
|
792
|
-
<input type="checkbox" class="ilist-check-all" data-flag="1" data-url={{url}} />
|
|
793
|
-
</td>
|
|
794
|
-
<td class="xs-hid">时间</td>
|
|
795
|
-
<td class="xs-show" data-sortname="a.title" data-is-sort="true">标题</td>
|
|
796
|
-
<td>类型</td>
|
|
797
|
-
<td>作者</td>
|
|
798
|
-
<td class="be-list-events">操作</td>
|
|
799
|
-
</tr>
|
|
800
|
-
</thead>
|
|
801
|
-
<tbody class="be-list-data-body">
|
|
802
|
-
{{/if}}
|
|
803
|
-
{{#each items}}
|
|
804
|
-
<tr>
|
|
805
|
-
<td class="xs-show be-te-check">
|
|
806
|
-
<input type="checkbox" class="ilist-check" data-flag="1" data-id="{{id}}" data-url={{url}}/>
|
|
807
|
-
</td>
|
|
808
|
-
<td class="xs-hid">{{createDate}}</td>
|
|
809
|
-
<td class="xs-show">{{title}}</td>
|
|
810
|
-
<td>{{sort}}</td>
|
|
811
|
-
<td>{{author}}</td>
|
|
812
|
-
<td class="be-list-events">
|
|
813
|
-
<a href="link/{{id}}" class="be-detail"><i class="bi bi-search"></i></a>
|
|
814
|
-
<a href="link/{{id}}" class="be-edit"><i class="bi bi-pencil-square"></i></a>
|
|
815
|
-
<a data-id={{id}} data-url={{url}} href="#" class="be-delete"><i class="bi bi-trash3"></i></a>
|
|
816
|
-
</td>
|
|
817
|
-
</tr>
|
|
818
|
-
{{/each}}
|
|
819
|
-
{{#if isInit true}}
|
|
820
|
-
</tbody>
|
|
821
|
-
</table>
|
|
822
|
-
{{/if}}
|
|
823
|
-
</script>
|
|
824
|
-
// 3. HTML代码查询参数范例,根据情况修改查询参数及列表.be-list ID
|
|
825
|
-
<div class="be-list-warp">
|
|
826
|
-
<div class="be-list-filter">
|
|
827
|
-
<div class="be-lf-btns">
|
|
828
|
-
<div class="be-lb-left">
|
|
829
|
-
<a href="javascript:" class="mn-button me-2"><i class="bi bi-plus-square"></i>新增</a>
|
|
830
|
-
<a href="javascript:" class="mn-button me-2"><i class="bi bi-trash3"></i>删除</a>
|
|
831
|
-
</div>
|
|
832
|
-
<div class="be-lb-right">
|
|
833
|
-
<a id="be-search" href="javascript:" class="mn-button me-2">
|
|
834
|
-
<i class="bi bi-search"></i>搜索
|
|
835
|
-
</a>
|
|
836
|
-
<button class="mn-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#searchMore"
|
|
837
|
-
aria-expanded="false" aria-controls="searchMore">
|
|
838
|
-
<i class="bi bi-chevron-double-down"></i>
|
|
839
|
-
</button>
|
|
840
|
-
</div>
|
|
841
|
-
</div>
|
|
842
|
-
<!-- 隐藏的查询条件 -->
|
|
843
|
-
<div class="be-lf-params">
|
|
844
|
-
<div class="collapse" id="searchMore">
|
|
845
|
-
<div class="be-lf-ps">
|
|
846
|
-
<label>
|
|
847
|
-
<span>类型:</span>
|
|
848
|
-
<select value="0">
|
|
849
|
-
<option value="0" selected="selected">所有</option>
|
|
850
|
-
<option value="1">实事</option>
|
|
851
|
-
<option value="2">娱乐</option>
|
|
852
|
-
<option value="3">军事</option>
|
|
853
|
-
</select>
|
|
854
|
-
</label>
|
|
855
|
-
<label>
|
|
856
|
-
<span>标题:</span>
|
|
857
|
-
<input id="be-input-2" type="text" placeholder="标题"/>
|
|
858
|
-
</label>
|
|
859
|
-
<label>
|
|
860
|
-
<span>时间:</span>
|
|
861
|
-
<input type="date" />
|
|
862
|
-
</label>
|
|
863
|
-
</div>
|
|
864
|
-
</div>
|
|
865
|
-
</div>
|
|
866
|
-
</div>
|
|
867
|
-
<div id="test-list" class="be-list"></div>
|
|
868
|
-
</div>
|
|
869
|
-
|
|
870
|
-
// JS操作
|
|
871
|
-
import '../css/bootstrap-icons.css'
|
|
872
|
-
import 'istyle/src/css/base/be-table.css'
|
|
873
|
-
import 'istyle/src/css/base/be-paging.css'
|
|
874
|
-
import 'istyle/src/css/button/mn-button.css'
|
|
875
|
-
import 'istyle/src/css/loading/do-preloader-3.css'
|
|
876
|
-
import Handlebars from 'glib/handlebars'
|
|
877
|
-
import { Tooltip } from 'glib/bootstrap';
|
|
878
|
-
|
|
879
|
-
const ilist = new u.IList('#test-list', {
|
|
880
|
-
url: "./springmvc/news/findNews.action",
|
|
881
|
-
param: {},
|
|
882
|
-
method: "get",
|
|
883
|
-
sortname: "a.id",
|
|
884
|
-
rp: 10,
|
|
885
|
-
visiblePages: 5,
|
|
886
|
-
handlebars: Handlebars,
|
|
887
|
-
headerMap: { 'token': 'abc123' },
|
|
888
|
-
onSuccess: function(data) {
|
|
889
|
-
b.handlebars(Handlebars);
|
|
890
|
-
const tplEl = b("#tp-data-news");
|
|
891
|
-
const html = Handlebars.compile(tplEl.html())({
|
|
892
|
-
items: data.rows,
|
|
893
|
-
isInit: data.isInit
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
if (data.isInit)
|
|
897
|
-
b(".be-list-data", "#test-list").html(html);
|
|
898
|
-
else
|
|
899
|
-
b(".be-list-data-body", "#test-list").html(html);
|
|
900
|
-
|
|
901
|
-
b.tip(Tooltip);
|
|
902
|
-
// 测试获取列ID
|
|
903
|
-
// b(".ip").click(function() {
|
|
904
|
-
// alert("该列数据id为" + b(this).data("id"));
|
|
905
|
-
// })
|
|
906
|
-
},
|
|
907
|
-
onError: (e) => {
|
|
908
|
-
console.error(e);
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
|
|
912
|
-
b('#be-search').click(() => {
|
|
913
|
-
ilist.reload({
|
|
914
|
-
'title': b('#be-input-2').val()
|
|
915
|
-
})
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
* </pre>
|
|
919
|
-
* ======================================================================== */
|
|
920
|
-
export class IList {
|
|
921
|
-
|
|
922
|
-
constructor(selector, custom) {
|
|
923
|
-
this.selector = selector;
|
|
924
|
-
defaultConstructor( this, selector, custom, ( target ) => {
|
|
925
|
-
target.elements.forEach( ( element ) => {
|
|
926
|
-
let myElems = b( element );
|
|
927
|
-
if (!myElems.data( "be.ilist" ))
|
|
928
|
-
myElems.data( "be.ilist", target );
|
|
929
|
-
|
|
930
|
-
if (typeof Handlebars !== 'undefined' && custom.handlebars === null) custom.handlebars = Handlebars;
|
|
931
|
-
target.init( element, custom );
|
|
932
|
-
} );
|
|
933
|
-
} );
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
options = {
|
|
937
|
-
rp: "10",
|
|
938
|
-
visiblePages: 7,
|
|
939
|
-
sortname: "id",
|
|
940
|
-
sortorder: "desc",
|
|
941
|
-
method: "post",
|
|
942
|
-
dataType: "json",
|
|
943
|
-
// async: true,
|
|
944
|
-
// jsonp: null,
|
|
945
|
-
// jsonpCallback: null,
|
|
946
|
-
param: {},
|
|
947
|
-
handlebars: null,//必须的模板生成工具
|
|
948
|
-
url: "",
|
|
949
|
-
loadColor: "#0a0a0a",//必须是16进制,不能缩写
|
|
950
|
-
lang: "cn",
|
|
951
|
-
template: "#tp-list",
|
|
952
|
-
headerMap: { }, //{ 'Content-Type': 'application/json'}
|
|
953
|
-
cache: 'default',
|
|
954
|
-
ipWarp: '#ilist-ip-warp',
|
|
955
|
-
prev: '上一页', //or: <i class="bi bi-chevron-left"></i>
|
|
956
|
-
next: '下一页', //or: <i class="bi bi-chevron-right"></i>
|
|
957
|
-
first: '首页', //or: <i class="bi bi-chevron-double-left"></i>
|
|
958
|
-
last: '尾页', //or: <i class="bi bi-chevron-double-right"></i>
|
|
959
|
-
onSuccess: false,
|
|
960
|
-
onError: false
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
init(element, options) {
|
|
964
|
-
let target = this,
|
|
965
|
-
myElement = b(element),
|
|
966
|
-
html = myElement.data("be.ilist.html");
|
|
967
|
-
if (options === undefined)
|
|
968
|
-
options = target.options
|
|
969
|
-
myElement.data("be.ilist.flag", true);
|
|
970
|
-
|
|
971
|
-
if (html) {
|
|
972
|
-
// myElement.html(html);
|
|
973
|
-
b(".be-list-data-body", element).html("");
|
|
974
|
-
} else {
|
|
975
|
-
const tplEl = b(options.template),
|
|
976
|
-
html = options.handlebars.compile(tplEl.html())({});
|
|
977
|
-
myElement.html(html);
|
|
978
|
-
myElement.data("be.ilist.html", html);
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
let param = b.extend(
|
|
982
|
-
{ page: 1, rp: options.rp, sortname: options.sortname, sortorder: options.sortorder },
|
|
983
|
-
options.param );
|
|
984
|
-
options.isInit = true;// 是否为初始化列表,表头只在初始化生成
|
|
985
|
-
b(element).data("be.ilist.event", true);
|
|
986
|
-
target.getData(element, options, param);
|
|
987
|
-
};
|
|
988
|
-
|
|
989
|
-
// 数据查询
|
|
990
|
-
getData(element, options, param) {
|
|
991
|
-
let target = this,
|
|
992
|
-
myElement = b(element);
|
|
993
|
-
b(".be-list-data-body", element).html("");
|
|
994
|
-
b(".be-list-loading", element).addClass("opacity-100");
|
|
995
|
-
b(".be-list-nofound", element).removeClass("opacity-100");
|
|
996
|
-
b(".be-list-page", element).removeClass("opacity-100");
|
|
997
|
-
|
|
998
|
-
b.ajax({
|
|
999
|
-
method: options.method,
|
|
1000
|
-
url: options.url,
|
|
1001
|
-
headerMap: options.headerMap,
|
|
1002
|
-
// beforeSend: function(request) {
|
|
1003
|
-
// for (let key in options.headerMap) {
|
|
1004
|
-
// if (options.headerMap.hasOwnProperty(key)) {
|
|
1005
|
-
// request.setRequestHeader(key, options.headerMap[key]);
|
|
1006
|
-
// }
|
|
1007
|
-
// }
|
|
1008
|
-
// },
|
|
1009
|
-
data: param,
|
|
1010
|
-
cache: options.cache,
|
|
1011
|
-
// jsonp: options.jsonp,
|
|
1012
|
-
// jsonpCallback: options.jsonp,
|
|
1013
|
-
async: options.async,
|
|
1014
|
-
dataType: options.dataType,
|
|
1015
|
-
success: function (data) {
|
|
1016
|
-
// b(".be-list-loading", element).css("display", "none");
|
|
1017
|
-
b(".be-list-loading", element).removeClass("opacity-100").addClass("opacity-0");
|
|
1018
|
-
b(".be-list-data", element).removeClass("opacity-0");
|
|
1019
|
-
b(".be-list-data-body", element).css("display", "table-row-group");
|
|
1020
|
-
|
|
1021
|
-
data.isInit = options.isInit;
|
|
1022
|
-
if (options.onSuccess)
|
|
1023
|
-
options.onSuccess(data);
|
|
1024
|
-
|
|
1025
|
-
if (data.total) {
|
|
1026
|
-
target.page(element, options, param, data.total);//翻页
|
|
1027
|
-
|
|
1028
|
-
// 全选/全清
|
|
1029
|
-
b(".ilist-check-all").checkAll('.ilist-check');
|
|
1030
|
-
|
|
1031
|
-
//点击列选择单列/点击列取消选择单列
|
|
1032
|
-
b( "table > tbody tr", element ).click( e => {
|
|
1033
|
-
let target = b( e.target );
|
|
1034
|
-
if (!(target.is( "input" ) || target.is( "i" ) || target.is( "a" ))) {
|
|
1035
|
-
b( ".ilist-check", e.currentTarget ).click();
|
|
1036
|
-
}
|
|
1037
|
-
} )
|
|
1038
|
-
|
|
1039
|
-
// 全选列/全清列
|
|
1040
|
-
// b( ".ilist-check-all", element ).change( e => {
|
|
1041
|
-
// let isChecked = b( e.currentTarget ).is( ":checked" );
|
|
1042
|
-
// if (isChecked)
|
|
1043
|
-
// b( ".ilist-check" ).addClass( "active" ).trigger("change");
|
|
1044
|
-
// else
|
|
1045
|
-
// b( ".ilist-check" ).removeClass( "active" ).trigger("change");
|
|
1046
|
-
// } );
|
|
1047
|
-
|
|
1048
|
-
if (myElement.data("be.ilist.event")) {
|
|
1049
|
-
myElement.data("be.ilist.event", false);
|
|
1050
|
-
|
|
1051
|
-
//选择单列/取消选择单列
|
|
1052
|
-
b( ".ilist-check", element ).change( e => {
|
|
1053
|
-
let isChecked = b( e.currentTarget ).is( ":checked" );
|
|
1054
|
-
if (isChecked)
|
|
1055
|
-
b(e.currentTarget).parents("tr").addClass("active");
|
|
1056
|
-
else
|
|
1057
|
-
b(e.currentTarget).parents("tr").removeClass("active");
|
|
1058
|
-
} );
|
|
1059
|
-
|
|
1060
|
-
//排序,<td data-sortname="a.title" data-is-sort="true"
|
|
1061
|
-
b( "table > thead tr td", element ).click( e => {
|
|
1062
|
-
const sortname = b( e.currentTarget ).data( "sortname" );
|
|
1063
|
-
if (sortname) {
|
|
1064
|
-
const reloadParam = myElement.data("be.ilist.param");
|
|
1065
|
-
if (reloadParam) {
|
|
1066
|
-
param = b.extend(reloadParam, param);
|
|
1067
|
-
}
|
|
1068
|
-
param.sortname = sortname;
|
|
1069
|
-
if (!b( e.currentTarget ).hasClass( "is-check" ) && param.sortname) {
|
|
1070
|
-
let sortorder = b( e.currentTarget ).attr( "data-sort-order" );
|
|
1071
|
-
|
|
1072
|
-
b( "table > thead tr td", element ).removeAttr( "data-sort-order" );
|
|
1073
|
-
|
|
1074
|
-
if (sortorder) {
|
|
1075
|
-
if (sortorder === "desc") {
|
|
1076
|
-
b( e.currentTarget ).attr( "data-sort-order", "asc" );
|
|
1077
|
-
sortorder = "asc";
|
|
1078
|
-
} else {
|
|
1079
|
-
b( e.currentTarget ).attr( "data-sort-order", "desc" );
|
|
1080
|
-
sortorder = "desc";
|
|
1081
|
-
}
|
|
1082
|
-
param.sortorder = sortorder;
|
|
1083
|
-
} else {
|
|
1084
|
-
b( e.currentTarget ).attr( "data-sort-order", "desc" );
|
|
1085
|
-
param.sortorder = "desc";
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
myElement.data("be.ilist.flag", true );
|
|
1089
|
-
param.page = "1";
|
|
1090
|
-
options.isInit = false;
|
|
1091
|
-
target.getData( element, options, param );
|
|
1092
|
-
} else {
|
|
1093
|
-
b( e.currentTarget ).css( "cursor", "auto ! important" );
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
} );
|
|
1097
|
-
}
|
|
1098
|
-
b(".be-list-page", element).addClass("opacity-100");//b(".be-list-page", element).css("visibility", "visible");
|
|
1099
|
-
} else {
|
|
1100
|
-
b(".be-list-nofound", element).addClass("opacity-100");//b(".be-list-nofound", element).css("display", "block");
|
|
1101
|
-
b(".be-list-page", element).removeClass("opacity-100");
|
|
1102
|
-
}
|
|
1103
|
-
},
|
|
1104
|
-
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
1105
|
-
try {
|
|
1106
|
-
if (options.onError) options.onError(XMLHttpRequest, textStatus, errorThrown);
|
|
1107
|
-
} catch (e) {}
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// 分页查询
|
|
1113
|
-
page(element, options, param, total) {
|
|
1114
|
-
let target = this,
|
|
1115
|
-
myElement = b(element);
|
|
1116
|
-
if (myElement.data("be.ilist.flag")) { //每次都重新生成一次分页
|
|
1117
|
-
new IPagination('#ipagination', {
|
|
1118
|
-
targetWarp: options.ipWarp,
|
|
1119
|
-
totalItems: total,
|
|
1120
|
-
itemsPerPage: options.rp,
|
|
1121
|
-
visiblePages: options.visiblePages,
|
|
1122
|
-
prev: options.prev,
|
|
1123
|
-
next: options.next,
|
|
1124
|
-
first: options.first,
|
|
1125
|
-
last: options.last,
|
|
1126
|
-
onButtonClick: ( page ) => {
|
|
1127
|
-
document.querySelector('.ilist-check-all').checked = false;
|
|
1128
|
-
param.page = page;
|
|
1129
|
-
options.isInit = false;
|
|
1130
|
-
target.getData( element, options, param );
|
|
1131
|
-
}
|
|
1132
|
-
} )
|
|
1133
|
-
}
|
|
1134
|
-
myElement.data("be.ilist.flag", false);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
// 设置参数重新搜索
|
|
1138
|
-
reload(param) {
|
|
1139
|
-
let myElement = b(this.selector),
|
|
1140
|
-
/** @type {IList<>} **/
|
|
1141
|
-
data = myElement.data("be.ilist"),
|
|
1142
|
-
newParam = b.extend(param,
|
|
1143
|
-
{ page: 1, rp: data.options.rp, sortname: data.options.sortname, sortorder: data.options.sortorder });
|
|
1144
|
-
data.options.isInit = false;
|
|
1145
|
-
myElement.data("be.ilist.flag", true);
|
|
1146
|
-
myElement.data("be.ilist.param", newParam);
|
|
1147
|
-
b('table > thead tr td', myElement).attr('data-sort-order', '');
|
|
1148
|
-
data["getData"](data['selector'], data.options, newParam);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
/* ========================================================================
|
|
1154
|
-
* 9. 手风琴导航菜单
|
|
1155
|
-
* 右侧导航菜单
|
|
1156
|
-
* 2024年7月18日 10:17:08
|
|
1157
|
-
* ========================================================================
|
|
1158
|
-
* <pre>
|
|
1159
|
-
<button id="iaccordion-btn" class="ce-accordion-btn"><i class="bi bi-layout-text-sidebar-reverse"></i></button>
|
|
1160
|
-
<ul class="ce-accordion" id="iaccordion">
|
|
1161
|
-
<li class="sub-menu"><a href="javascript:"><i class="bi bi-sunset"></i><span>主页</span></a></li>
|
|
1162
|
-
<li class="sub-menu"><a href="#"><i class="bi bi-twitch"></i><span>数据</span></a>
|
|
1163
|
-
<ul class="sub">
|
|
1164
|
-
<li class="sub-menu"><a href="javascript:"><span>人员管理</span></a></li>
|
|
1165
|
-
<li class="sub-menu"><a href="javascript:"><span>日志</span></a></li>
|
|
1166
|
-
<li class="sub-menu"><a href="javascript:"><span>新闻管理</span></a></li>
|
|
1167
|
-
<li class="sub-menu"><a href="javascript:"><span>签到</span></a></li>
|
|
1168
|
-
</ul>
|
|
1169
|
-
</li>
|
|
1170
|
-
<li class="sub-menu"><a href="#"><i class="bi bi-twitter"></i><span>权限</span></a>
|
|
1171
|
-
<ul class="sub">
|
|
1172
|
-
<li class="sub-menu"><a href="javascript:"><span>新闻平台权限</span></a></li>
|
|
1173
|
-
<li class="sub-menu"><a href="javascript:"><span>商城权限</span></a>
|
|
1174
|
-
<ul class="sub">
|
|
1175
|
-
<li class="sub-menu"><a href="javascript:"><span>商城查询权限</span></a></li>
|
|
1176
|
-
</ul>
|
|
1177
|
-
</li>
|
|
1178
|
-
</ul>
|
|
1179
|
-
</li>
|
|
1180
|
-
</ul>
|
|
1181
|
-
|
|
1182
|
-
import 'istyle/src/css/accordion/ce-accordion.css'
|
|
1183
|
-
new u.IAccordion('#iaccordion', { speed: 300, showCount: true });
|
|
1184
|
-
b("#iaccordion-btn").click((e) => {
|
|
1185
|
-
b('#iaccordion').toggleClass("ce-accordion-small")
|
|
1186
|
-
b(e.currentTarget).toggleClass("ce-ab-small")
|
|
1187
|
-
})
|
|
1188
|
-
* </pre>
|
|
1189
|
-
* ======================================================================== */
|
|
1190
|
-
export class IAccordion {
|
|
1191
|
-
constructor(selector, custom) {
|
|
1192
|
-
this.selector = selector;
|
|
1193
|
-
defaultConstructor(this, selector, custom, (target) => {
|
|
1194
|
-
target.elements.forEach( ( element ) => {
|
|
1195
|
-
let myElems = b( element );
|
|
1196
|
-
if (!myElems.data( "be.iaccordion" ))
|
|
1197
|
-
myElems.data( "be.iaccordion", target );
|
|
1198
|
-
|
|
1199
|
-
target.init( element, custom );
|
|
1200
|
-
} );
|
|
1201
|
-
} );
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
options = {
|
|
1205
|
-
classParent: 'ia-parent', // 包含ul的父级菜单
|
|
1206
|
-
classActive : 'active', // 当前激活菜单
|
|
1207
|
-
classArrow: 'ia-icon', // 菜单右侧展开缩小图标: - and +
|
|
1208
|
-
classCount: 'ia-count',
|
|
1209
|
-
autoExpand: false,
|
|
1210
|
-
classExpand : 'ia-current-parent',
|
|
1211
|
-
autoClose: true, // 打开菜单时是否关闭其他承担
|
|
1212
|
-
speed: 300,
|
|
1213
|
-
saveState : true, // 下次打开是否使用当前的菜单
|
|
1214
|
-
disableLink : true, // 需要展开子项的不触发浏览链接
|
|
1215
|
-
showCount: false, // 显示一样多少菜单
|
|
1216
|
-
cookie: 'ia-cookie',
|
|
1217
|
-
smallClass: 'ce-accordion-small'
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
init(element, options) {
|
|
1221
|
-
const target = this,
|
|
1222
|
-
myLinks = b( 'li > a', element ),
|
|
1223
|
-
mySub = b( 'li > ul', element );
|
|
1224
|
-
|
|
1225
|
-
options = b.extend( options, target.options );
|
|
1226
|
-
const classActive = options.classActive;
|
|
1227
|
-
|
|
1228
|
-
this.setUpAccordion(element, myLinks, mySub, options);
|
|
1229
|
-
if (options.saveState === true) {
|
|
1230
|
-
target.checkCookie( options.cookie, element, classActive );
|
|
1231
|
-
}
|
|
1232
|
-
if (options.autoExpand === true) {
|
|
1233
|
-
b( 'li.' + options.classExpand + ' > a' ).addClass( classActive );
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
myLinks.click( function ( e ) {
|
|
1237
|
-
const myTarget = b( e.currentTarget ),
|
|
1238
|
-
myActiveLi = myTarget.parent(),
|
|
1239
|
-
isSmall = target.isSmall( e, element, options.smallClass);
|
|
1240
|
-
// 需要展开子项的不触发浏览链接
|
|
1241
|
-
if (options.disableLink === true) {
|
|
1242
|
-
if (myTarget.siblings( 'ul' ).length > 0) {
|
|
1243
|
-
e.preventDefault();
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
// 关闭其他展开的菜单
|
|
1248
|
-
if (options.autoClose === true) {
|
|
1249
|
-
target.autoCloseAccordion( element, myTarget, isSmall, options )
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
if (b( '> ul', myActiveLi ).length === 0) {
|
|
1253
|
-
b( '> a', myActiveLi ).addClass( classActive );
|
|
1254
|
-
} else if (b( '> ul', myActiveLi ).css( 'display' ) !== 'none') {
|
|
1255
|
-
// 已经打开的则关闭
|
|
1256
|
-
target.slideUp( b( 'ul', myActiveLi ), isSmall, options )
|
|
1257
|
-
b( 'a', myActiveLi ).removeClass( classActive );
|
|
1258
|
-
} else {
|
|
1259
|
-
if (b( e.currentTarget ).siblings( 'ul' ).css( 'display' ) === 'none') {
|
|
1260
|
-
target.slideDown(b( e.currentTarget ).siblings( 'ul' ).css("overflow", "hidden"), isSmall, options)
|
|
1261
|
-
} else {
|
|
1262
|
-
target.slideUp( b( e.currentTarget ).siblings( 'ul' ), isSmall, options )
|
|
1263
|
-
}
|
|
1264
|
-
b( '> a', myActiveLi ).addClass( classActive );
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
// 设置cookie
|
|
1268
|
-
if (options.saveState === true) {
|
|
1269
|
-
target.createCookie( options.cookie, element, classActive );
|
|
1270
|
-
}
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
setUpAccordion(target, myLinks, mySub, options) {
|
|
1275
|
-
const classArrowHtml = '<span class="' + options.classArrow + '"></span>',
|
|
1276
|
-
classParentLi = options.classParent + '-li';
|
|
1277
|
-
mySub.show();
|
|
1278
|
-
b( 'li', target ).each(e => {
|
|
1279
|
-
if (b( '> ul', e ).length > 0) {
|
|
1280
|
-
b( e ).addClass( classParentLi );
|
|
1281
|
-
b( '> a', e ).addClass( options.classParent ).append( classArrowHtml );
|
|
1282
|
-
}
|
|
1283
|
-
});
|
|
1284
|
-
mySub.hide();
|
|
1285
|
-
// 显示数量
|
|
1286
|
-
if (options.showCount === true) {
|
|
1287
|
-
b( 'ul', target ).each((ele) => {
|
|
1288
|
-
b( '> a', b(ele).parent() ).append( ' <span class="' + options.classCount + '">(' + ele.children.length + ')</span>' );
|
|
1289
|
-
})
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
// 关闭其它标签
|
|
1294
|
-
autoCloseAccordion( element, target, isSmall, options ) {
|
|
1295
|
-
const t = this;
|
|
1296
|
-
b( 'ul', element ).each((ele) => {
|
|
1297
|
-
let isParent = false;
|
|
1298
|
-
target.parents("ul").each((parentEle) => {
|
|
1299
|
-
if (parentEle === ele)
|
|
1300
|
-
isParent = true;
|
|
1301
|
-
});
|
|
1302
|
-
if (!isParent && target.siblings( 'ul' ).elements[0] !== ele && ele.style.display !== 'none') {
|
|
1303
|
-
t.slideUp( b(ele), isSmall, options )
|
|
1304
|
-
}
|
|
1305
|
-
})
|
|
1306
|
-
// 重置激活菜单
|
|
1307
|
-
b( 'a', element ).removeClass( options.classActive );
|
|
1308
|
-
target.parents("li").each((ele) => {
|
|
1309
|
-
b( '> a', ele).addClass( options.classActive );
|
|
1310
|
-
})
|
|
1311
|
-
// target.addClass( options.classActive );
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
// 检索cookie值
|
|
1315
|
-
checkCookie(cookieId, target, classActive) {
|
|
1316
|
-
const t = this,
|
|
1317
|
-
cookieVal = b.getCookie(cookieId);
|
|
1318
|
-
if( cookieVal !== null && cookieVal !== "" ) {
|
|
1319
|
-
const activeArray = cookieVal.split(',');
|
|
1320
|
-
t.setActiveMenu( target, activeArray, 0, classActive )
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
// 通过cookie设置之前的存档
|
|
1325
|
-
setActiveMenu(target, activeArray, index, classActive) {
|
|
1326
|
-
const myCookieLi = b('li:eq(' + activeArray[index] + ')', target),
|
|
1327
|
-
myA = b('> a', myCookieLi ),
|
|
1328
|
-
myUl = myA.siblings('ul');
|
|
1329
|
-
myA.addClass( classActive );
|
|
1330
|
-
myUl.css('display', '');
|
|
1331
|
-
|
|
1332
|
-
if (activeArray.length > index + 1) {
|
|
1333
|
-
this.setActiveMenu(myUl, activeArray, ++index, classActive);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
// 创建cookie
|
|
1338
|
-
createCookie(cookieId, target, classActive){
|
|
1339
|
-
let activeIndex = [];
|
|
1340
|
-
// 激活菜单列表
|
|
1341
|
-
b('li a.' + classActive, target).each((e) => {
|
|
1342
|
-
const myArrayItem = b(e).parent('li'),
|
|
1343
|
-
// itemIndex = b('li', target).index(myArrayItem);
|
|
1344
|
-
itemIndex = myArrayItem.index();
|
|
1345
|
-
activeIndex.push(itemIndex);
|
|
1346
|
-
});
|
|
1347
|
-
b.setCookie(cookieId, activeIndex);
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
// 是否为在缩小模式下的下拉按钮
|
|
1351
|
-
isSmall(e, element, smallClass) {
|
|
1352
|
-
if (b(element).hasClass(smallClass) && b(e.currentTarget).siblings('ul').length !== 0) {
|
|
1353
|
-
e.preventDefault();
|
|
1354
|
-
return true;
|
|
1355
|
-
} else {
|
|
1356
|
-
return false;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
// 菜单列显示
|
|
1361
|
-
slideDown(myElement, isSmall, options) {
|
|
1362
|
-
if (!isSmall)
|
|
1363
|
-
myElement.slideDown(options.speed)
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
// 菜单列隐藏
|
|
1367
|
-
slideUp(myElement, isSmall, options) {
|
|
1368
|
-
if (!isSmall)
|
|
1369
|
-
myElement.slideUp(options.speed)
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
/* ========================================================================
|
|
1374
|
-
* 10. 弹框搜索面板
|
|
1375
|
-
* 2016年5月22日19:01:48
|
|
1376
|
-
* ========================================================================
|
|
1377
|
-
* <pre>
|
|
1378
|
-
<script type="text/template" id="tp-popover-items">
|
|
1379
|
-
{{#each items}}
|
|
1380
|
-
<div class="popover-content-item row">
|
|
1381
|
-
{{#if type 'text'}}
|
|
1382
|
-
<div class="col-sm-3 text-right">
|
|
1383
|
-
<label class="label-control">{{desc}}:</label>
|
|
1384
|
-
</div>
|
|
1385
|
-
<div class="col-sm-8 no-padding-left">
|
|
1386
|
-
<input name="{{name}}" class="form-control popover-form-item" placeholder="{{desc}}" value="{{value}}"/>
|
|
1387
|
-
</div>
|
|
1388
|
-
{{/if}}
|
|
1389
|
-
{{#if type 'date'}}
|
|
1390
|
-
<div class="col-sm-3 text-right">
|
|
1391
|
-
<label class="label-control">{{desc}}:</label>
|
|
1392
|
-
</div>
|
|
1393
|
-
<div class="col-sm-8 no-padding-left be-rel">
|
|
1394
|
-
<input id="airDatepicker" name="{{name}}" class="form-control popover-form-item popover-form-date" placeholder="{{desc}}" value="{{value}}"/>
|
|
1395
|
-
</div>
|
|
1396
|
-
{{/if}}
|
|
1397
|
-
{{#if type 'select'}}
|
|
1398
|
-
<div class="col-sm-3 text-right">
|
|
1399
|
-
<label class="label-control">{{desc}}:</label>
|
|
1400
|
-
</div>
|
|
1401
|
-
<div class="col-sm-8 no-padding-left">
|
|
1402
|
-
<select name="{{name}}" class="form-select popover-form-item">
|
|
1403
|
-
{{#each options}}
|
|
1404
|
-
<option value="{{name}}" {{#if selected true}}selected="selected"{{/if}}>{{value}}</option>
|
|
1405
|
-
{{/each}}
|
|
1406
|
-
</select>
|
|
1407
|
-
</div>
|
|
1408
|
-
{{/if}}
|
|
1409
|
-
</div>
|
|
1410
|
-
{{/each}}
|
|
1411
|
-
</script>
|
|
1412
|
-
|
|
1413
|
-
<script type="text/template" id="tp-popover">
|
|
1414
|
-
<div class="popover tooltip ce-popover" role="tooltip">
|
|
1415
|
-
<h3 class="popover-title">详细搜索</h3>
|
|
1416
|
-
<div class="popover-content">
|
|
1417
|
-
<div class="popover-content-items"></div>
|
|
1418
|
-
</div>
|
|
1419
|
-
<div class="popover-footer">
|
|
1420
|
-
<a class="ce-popover-ok"><i class="bi bi-search"></i>搜索</a>
|
|
1421
|
-
<a class="ce-popover-cancel"><i class="bi bi-x-square"></i>关闭</a>
|
|
1422
|
-
<a class="ce-popover-clear"><i class="bi bi-trash3"></i>清除</a>
|
|
1423
|
-
</div>
|
|
1424
|
-
</div>
|
|
1425
|
-
</script>
|
|
1426
|
-
|
|
1427
|
-
<a id="ipopover" tabindex="0" class="btn btn-sm btn-danger">弹出搜索框</a>
|
|
1428
|
-
|
|
1429
|
-
// JS调用
|
|
1430
|
-
<script src="/js/bootstrap.bundle.js"></script>
|
|
1431
|
-
<script src="/js/handlebars.min.js"></script>
|
|
1432
|
-
<script>
|
|
1433
|
-
Handlebars.registerHelper("if", function(v1, v2, options) {
|
|
1434
|
-
return (v1 === v2) ? options.fn(this) : options.inverse(this);
|
|
1435
|
-
});
|
|
1436
|
-
</script>
|
|
1437
|
-
or
|
|
1438
|
-
import "istyle/src/css/base/init.css";
|
|
1439
|
-
import "istyle/src/css/case/ce-popover.css";
|
|
1440
|
-
import Handlebars from 'glib/handlebars'
|
|
1441
|
-
import * as bootstrap from 'glib/bootstrap';
|
|
1442
|
-
|
|
1443
|
-
b.handlebars(Handlebars);
|
|
1444
|
-
import AirDatepicker from 'glib/air-datepicker'
|
|
1445
|
-
import localeZh from 'glib/air-datepicker/locale/zh';
|
|
1446
|
-
import 'glib/air-datepicker/air-datepicker.css'
|
|
1447
|
-
import 'istyle/src/css/form/fm-datepicker.css'
|
|
1448
|
-
|
|
1449
|
-
new u.PopoverSearch('#ipopover', {
|
|
1450
|
-
handlebars: Handlebars,
|
|
1451
|
-
airDatepicker: AirDatepicker,
|
|
1452
|
-
localeZh: localeZh,
|
|
1453
|
-
bootstrap: bootstrap,
|
|
1454
|
-
items: [
|
|
1455
|
-
{name: "name", desc: "姓名", type: "text", value: ""},
|
|
1456
|
-
{name: "time", desc: "开始时间", type: "date", value: ""},
|
|
1457
|
-
{name: "select", desc: "选项", type: "select",
|
|
1458
|
-
options: [
|
|
1459
|
-
{name: "", value: "所有", selected: false},//如果默认查询所有,name设置为""
|
|
1460
|
-
{name: "o1", value: "选项1", selected: false},
|
|
1461
|
-
{name: "o2", value: "选项2", selected: true}
|
|
1462
|
-
]
|
|
1463
|
-
}
|
|
1464
|
-
],
|
|
1465
|
-
onSerach: function(e) {
|
|
1466
|
-
// $("#ipopover").click();
|
|
1467
|
-
console.log(e.param);//参数及参数值对象,{name: "arisu", time: "2016-07-16 17:02:59", select: "o2"}
|
|
1468
|
-
}
|
|
1469
|
-
});
|
|
1470
|
-
* </pre>
|
|
1471
|
-
* ======================================================================== */
|
|
1472
|
-
export class PopoverSearch {
|
|
1473
|
-
constructor( selector, custom ) {
|
|
1474
|
-
this.selector = selector;
|
|
1475
|
-
defaultConstructor( this, selector, custom, ( target ) => {
|
|
1476
|
-
target.elements.forEach( ( element ) => {
|
|
1477
|
-
let myElems = b( element );
|
|
1478
|
-
if (!myElems.data( "be.popoversearch" ))
|
|
1479
|
-
myElems.data( "be.popoversearch", target );
|
|
1480
|
-
|
|
1481
|
-
if (typeof Handlebars !== 'undefined' && custom.handlebars === null) custom.handlebars = Handlebars;
|
|
1482
|
-
if (typeof bootstrap !== 'undefined' && custom.bootstrap === null) custom.bootstrap = bootstrap;
|
|
1483
|
-
if (typeof AirDatepicker !== 'undefined' && custom.airDatepicker === null) custom.airDatepicker = AirDatepicker;
|
|
1484
|
-
if (typeof localeZh !== 'undefined' && custom.localeZh === null) custom.localeZh = localeZh;
|
|
1485
|
-
target.init( element, custom );
|
|
1486
|
-
} );
|
|
1487
|
-
} );
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
options = {
|
|
1491
|
-
handlebars: null, //模板生成工具
|
|
1492
|
-
bootstrap: null, //bootstrap Popover
|
|
1493
|
-
airDatepicker: null,//日期控件
|
|
1494
|
-
localeZh: null, //日期控件中文支持
|
|
1495
|
-
template: "#tp-popover",
|
|
1496
|
-
templateItems: "#tp-popover-items",
|
|
1497
|
-
html: true,
|
|
1498
|
-
title: "详细搜索",
|
|
1499
|
-
trigger: "click",
|
|
1500
|
-
toggle: "popover",
|
|
1501
|
-
placement: "auto",
|
|
1502
|
-
onSerach: false,
|
|
1503
|
-
items: [], //搜索框json数据
|
|
1504
|
-
// startView: 2,
|
|
1505
|
-
// minView: 2,
|
|
1506
|
-
timepicker: true, //是否显示时分秒
|
|
1507
|
-
format: "yyyy-MM-dd hh:mm:ss"
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
init(element, options) {
|
|
1511
|
-
let target = this;
|
|
1512
|
-
target.itemsValue = []; // 搜索框值
|
|
1513
|
-
// var $element = $(element);
|
|
1514
|
-
// var target = this;
|
|
1515
|
-
|
|
1516
|
-
const template = options.handlebars.compile(b(options.template).html())({});
|
|
1517
|
-
|
|
1518
|
-
const popr = new options.bootstrap.Popover(element, {
|
|
1519
|
-
html: options.html,
|
|
1520
|
-
title: options.title,
|
|
1521
|
-
trigger: options.trigger,
|
|
1522
|
-
toggle: options.toggle,
|
|
1523
|
-
placement: options.placement,
|
|
1524
|
-
template: template,
|
|
1525
|
-
animation: true,
|
|
1526
|
-
param: null
|
|
1527
|
-
});
|
|
1528
|
-
|
|
1529
|
-
element.addEventListener('inserted.bs.popover', () => {
|
|
1530
|
-
target.addItem(options);
|
|
1531
|
-
})
|
|
1532
|
-
|
|
1533
|
-
element.addEventListener('shown.bs.popover', () => {
|
|
1534
|
-
target.search(target, options);
|
|
1535
|
-
target.close(popr);
|
|
1536
|
-
target.clear();
|
|
1537
|
-
})
|
|
1538
|
-
|
|
1539
|
-
element.addEventListener('hide.bs.popover', () => {
|
|
1540
|
-
target.itemsHtml = b(".popover-content-items").html();
|
|
1541
|
-
target.itemsValue = [];
|
|
1542
|
-
b(".popover-form-item").each((e) => {
|
|
1543
|
-
target.itemsValue.push(b(e).val());
|
|
1544
|
-
})
|
|
1545
|
-
})
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
// 添加搜索框
|
|
1549
|
-
addItem(options) {
|
|
1550
|
-
const target = this;
|
|
1551
|
-
if (target.itemsHtml) {
|
|
1552
|
-
b(".ce-popover > .popover-content .popover-content-items").html(target.itemsHtml);
|
|
1553
|
-
} else {
|
|
1554
|
-
const html = options.handlebars.compile(b(options.templateItems).html())({
|
|
1555
|
-
items: options.items
|
|
1556
|
-
});
|
|
1557
|
-
b(".ce-popover > .popover-content .popover-content-items").html(html);
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
b('.popover-form-item').each((e, i) => {
|
|
1561
|
-
const myEle = b(e);
|
|
1562
|
-
myEle.val(target.itemsValue[i])
|
|
1563
|
-
if (myEle.hasClass('popover-form-date')) {
|
|
1564
|
-
try {
|
|
1565
|
-
new options.airDatepicker( ".ce-popover input[name='" + myEle.attr('name') + "']", {
|
|
1566
|
-
classes: 'fm-datepicker',
|
|
1567
|
-
autoClose: true,
|
|
1568
|
-
inline: false,
|
|
1569
|
-
timepicker: options.timepicker,
|
|
1570
|
-
buttons: ['today', 'clear'],
|
|
1571
|
-
locale: options.localeZh,
|
|
1572
|
-
dateFormat( date ) {
|
|
1573
|
-
return date.format( options.format )
|
|
1574
|
-
}
|
|
1575
|
-
} )
|
|
1576
|
-
} catch (e) {
|
|
1577
|
-
b(".ce-popover input[name='" + myEle.attr('name') + "']").attr('type', 'date');
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
})
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
// 关闭
|
|
1584
|
-
close(popr) {
|
|
1585
|
-
// b.l(element)
|
|
1586
|
-
// b.l(b(".ce-popover-cancel", element))
|
|
1587
|
-
b(".ce-popover-cancel", '.ce-popover').off("click").on("click", () => {
|
|
1588
|
-
popr.hide();
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
// 清空条件
|
|
1593
|
-
clear() {
|
|
1594
|
-
b(".ce-popover-clear", ".ce-popover").off("click").on("click", () => {
|
|
1595
|
-
b('.popover-form-item', '.ce-popover').each((e) => {
|
|
1596
|
-
b(e).val("");
|
|
1597
|
-
})
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
// 获取参数
|
|
1602
|
-
getParam() {
|
|
1603
|
-
const params = {};
|
|
1604
|
-
b(".popover-form-item").each(function(e) {
|
|
1605
|
-
const myEle = b(e),
|
|
1606
|
-
name = myEle.attr("name"),
|
|
1607
|
-
val = myEle.val();
|
|
1608
|
-
if (val) params[name] = val;
|
|
1609
|
-
})
|
|
1610
|
-
return params;
|
|
1611
|
-
};
|
|
1612
|
-
|
|
1613
|
-
// 调用参数中的搜索方法
|
|
1614
|
-
search(target, options) {
|
|
1615
|
-
b(".ce-popover-ok", ".ce-popover").off("click").on("click", () => {
|
|
1616
|
-
if (options.onSerach) options.onSerach({param: target.getParam()});
|
|
1617
|
-
})
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
/* ========================================================================
|
|
1623
|
-
* 11. 文字切换动画特效
|
|
1624
|
-
* 2023年7月5日 12:58:24
|
|
1625
|
-
* ========================================================================
|
|
1626
|
-
* <pre>
|
|
1627
|
-
<div id="ce-flash" class="ce-txt">
|
|
1628
|
-
<span>
|
|
1629
|
-
<b class="is-visible">尖端设计.</b>
|
|
1630
|
-
<b>编码流畅严谨.</b>
|
|
1631
|
-
<b>完美构图.</b>
|
|
1632
|
-
</span>
|
|
1633
|
-
</div>
|
|
1634
|
-
|
|
1635
|
-
import "istyle/src/css/case/ce-txt.css";
|
|
1636
|
-
new u.Flash("#ce-flash", {
|
|
1637
|
-
animationDelay: 3000,
|
|
1638
|
-
lettersDelay: 50
|
|
1639
|
-
})
|
|
1640
|
-
* </pre>
|
|
1641
|
-
* ======================================================================== */
|
|
1642
|
-
export class Flash {
|
|
1643
|
-
constructor( selector, custom ) {
|
|
1644
|
-
this.selector = selector;
|
|
1645
|
-
defaultConstructor( this, selector, custom, ( target ) => {
|
|
1646
|
-
target.elements.forEach( ( element ) => {
|
|
1647
|
-
let myElems = b( element );
|
|
1648
|
-
if (!myElems.data( "be.flash" ))
|
|
1649
|
-
myElems.data( "be.flash", target );
|
|
1650
|
-
|
|
1651
|
-
target.init( element, custom );
|
|
1652
|
-
} );
|
|
1653
|
-
} );
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
options = {
|
|
1657
|
-
//动画间隔时间5秒
|
|
1658
|
-
animationDelay: 5000,
|
|
1659
|
-
//letters: 每个字特效的时间间隔
|
|
1660
|
-
lettersDelay: 50,
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
init(element, options) {
|
|
1664
|
-
const target = this;
|
|
1665
|
-
if (options.type === 1) {
|
|
1666
|
-
b(element).addClass("letters");
|
|
1667
|
-
}
|
|
1668
|
-
target.singleLetters(element);
|
|
1669
|
-
//初始化动画
|
|
1670
|
-
target.animateHeadline(element, options);
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
// 文本加入HTML标签方便控制
|
|
1674
|
-
singleLetters(element) {
|
|
1675
|
-
const target = this,
|
|
1676
|
-
myB = b(element).find("b");
|
|
1677
|
-
myB.each(function(e) {
|
|
1678
|
-
const myWord = b(e),
|
|
1679
|
-
letters = myWord.text().split(""),
|
|
1680
|
-
selected = myWord.hasClass("is-visible");
|
|
1681
|
-
for (const i in letters) {
|
|
1682
|
-
if (letters.hasOwnProperty(i)) {
|
|
1683
|
-
if (myWord.parents( target.selector ).length > 0) letters[i] = "<em>" + letters[i] + "</em>";
|
|
1684
|
-
letters[i] = (selected) ? "<i class='in'>" + letters[i] + "</i>" : "<i>" + letters[i] + "</i>";
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
const newLetters = letters.join("");
|
|
1688
|
-
myWord.html(newLetters).css("opacity", 1);
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
// 开始动画
|
|
1693
|
-
animateHeadline(element, options) {
|
|
1694
|
-
const target = this,
|
|
1695
|
-
myElement = b(element);
|
|
1696
|
-
let duration = options.animationDelay;
|
|
1697
|
-
myElement.each(function(ele){
|
|
1698
|
-
const myEle = b(ele);
|
|
1699
|
-
setTimeout(() => { target.hideWord( myEle.find(".is-visible").first() ) }, duration);
|
|
1700
|
-
})
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
// 文字隐藏显示切换,myWord: Base封装的每行文字
|
|
1704
|
-
hideWord(myWord) {
|
|
1705
|
-
const target = this,
|
|
1706
|
-
nextWord = target.takeNext(myWord);
|
|
1707
|
-
|
|
1708
|
-
const bool = myWord.children().length >= nextWord.children().length;
|
|
1709
|
-
target.hideLetter(myWord.find("i").first(), myWord, bool, target.options.lettersDelay);
|
|
1710
|
-
target.showLetter(nextWord.find("i").first(), nextWord, bool, target.options.lettersDelay);
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
// 获取下一行,如果是最后一行跳到第一行
|
|
1714
|
-
takeNext(myWord) {
|
|
1715
|
-
return (myWord.length !== 0 && !myWord.is(":last-child")) ? myWord.next() : myWord.parent().children().first();
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
hideLetter(myLetter, myWord, bool, duration) {
|
|
1719
|
-
const target = this;
|
|
1720
|
-
myLetter.removeClass("in").addClass("out");
|
|
1721
|
-
if(myLetter.length !== 0 && !myLetter.is(":last-child")) {
|
|
1722
|
-
setTimeout(() => { target.hideLetter(myLetter.next(), myWord, bool, duration); }, duration);
|
|
1723
|
-
} else if(bool) {
|
|
1724
|
-
setTimeout(() => { target.hideWord(target.takeNext(myWord)) }, target.options.animationDelay);
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
showLetter(myLetter, myWord, bool, duration) {
|
|
1729
|
-
const target = this;
|
|
1730
|
-
myLetter.addClass("in").removeClass("out");
|
|
1731
|
-
|
|
1732
|
-
if(myLetter.length !== 0 && !myLetter.is(":last-child")) {
|
|
1733
|
-
setTimeout(() => { target.showLetter(myLetter.next(), myWord, bool, duration); }, duration);
|
|
1734
|
-
} else {
|
|
1735
|
-
// if(myWord.parents(target.options.selector).hasClass("type")) { setTimeout(() => { myWord.parents("span").addClass("waiting"); }, 200);}
|
|
1736
|
-
if(!bool) { setTimeout(() => { target.hideWord(myWord) }, target.options.animationDelay) }
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
/* ========================================================================
|
|
1743
|
-
* 12. 绘制点线背景动画,依赖tweenlite
|
|
1744
|
-
* 2018年6月2日09:54:29
|
|
1745
|
-
* ========================================================================
|
|
1746
|
-
* <pre>
|
|
1747
|
-
<div id="canvas-warp">
|
|
1748
|
-
<canvas id="iCanvas" style="background-color: rgb(63, 81, 181)" ></canvas>
|
|
1749
|
-
</div>
|
|
1750
|
-
|
|
1751
|
-
import "./plugin/tweenlite/easepack.min"
|
|
1752
|
-
import "./plugin/tweenlite/tweenlite.min"
|
|
1753
|
-
new u.LineEffect("#canvas-warp", {
|
|
1754
|
-
//pointColor: "rgba(0, 0, 0, 1)",
|
|
1755
|
-
//lineColor: "0, 0, 0" ,
|
|
1756
|
-
//height: 302,
|
|
1757
|
-
isWindowWidth: false,
|
|
1758
|
-
width: 500,
|
|
1759
|
-
height: 600,
|
|
1760
|
-
num: 11,
|
|
1761
|
-
canvasId: "iCanvas"
|
|
1762
|
-
});
|
|
1763
|
-
* </pre>
|
|
1764
|
-
* ======================================================================== */
|
|
1765
|
-
class Circle {
|
|
1766
|
-
constructor(options, pos, rad) {
|
|
1767
|
-
this.pos = pos || null;
|
|
1768
|
-
this.radius = rad || null;
|
|
1769
|
-
// this.color = color || null;
|
|
1770
|
-
this.active = true; // 假设默认激活状态
|
|
1771
|
-
this.options = options;
|
|
1772
|
-
}
|
|
1773
|
-
draw(ctx) {
|
|
1774
|
-
if (!this.active) return;
|
|
1775
|
-
ctx.beginPath();
|
|
1776
|
-
ctx.arc(this.pos.x, this.pos.y, this.radius, 0, 2 * Math.PI, false);
|
|
1777
|
-
ctx.fillStyle = "rgba(" + this.options.pointColor + "," + this.active + ")";
|
|
1778
|
-
ctx.fill();
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
export class LineEffect {
|
|
1782
|
-
constructor( selector, custom ) {
|
|
1783
|
-
this.selector = selector;
|
|
1784
|
-
defaultConstructor( this, selector, custom, ( target ) => {
|
|
1785
|
-
target.elements.forEach( ( element ) => {
|
|
1786
|
-
let myElems = b( element );
|
|
1787
|
-
if (!myElems.data( "be.lineeffect" ))
|
|
1788
|
-
myElems.data( "be.lineeffect", target );
|
|
1789
|
-
|
|
1790
|
-
target.init( element, custom );
|
|
1791
|
-
} );
|
|
1792
|
-
} );
|
|
1793
|
-
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
options = {
|
|
1797
|
-
|
|
1798
|
-
canvasId: "targetCanvas",
|
|
1799
|
-
animateHeader: true,
|
|
1800
|
-
|
|
1801
|
-
width: window.innerWidth,
|
|
1802
|
-
height: window.innerHeight,
|
|
1803
|
-
isWindowWidth: false,
|
|
1804
|
-
isWindowHeight: false,
|
|
1805
|
-
num: 20,
|
|
1806
|
-
|
|
1807
|
-
pointColor: "156,217,249", //点颜色
|
|
1808
|
-
lineColor: "156,217,249" //线颜色
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
init(element, options) {
|
|
1812
|
-
const target = this,
|
|
1813
|
-
xy = { x: options.width/2, y: options.height/2 };
|
|
1814
|
-
|
|
1815
|
-
const canvas = document.getElementById(options.canvasId);
|
|
1816
|
-
canvas.width = options.width;
|
|
1817
|
-
canvas.height = options.height;
|
|
1818
|
-
const ctx = canvas.getContext("2d");
|
|
1819
|
-
|
|
1820
|
-
// 绘制点
|
|
1821
|
-
const points = [];
|
|
1822
|
-
for(let x = 0; x < options.width; x = x + options.width / options.num) {
|
|
1823
|
-
for(let y = 0; y < options.height; y = y + options.height / options.num) {
|
|
1824
|
-
let px = x + Math.random() * options.width / options.num;
|
|
1825
|
-
let py = y + Math.random() * options.height / options.num;
|
|
1826
|
-
let p = {x: px, originX: px, y: py, originY: py };
|
|
1827
|
-
points.push(p);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
// 绘制点周围的点
|
|
1832
|
-
for(let i = 0; i < points.length; i++) {
|
|
1833
|
-
const closest = [],
|
|
1834
|
-
p1 = points[i];
|
|
1835
|
-
for(let j = 0; j < points.length; j++) {
|
|
1836
|
-
let p2 = points[j]
|
|
1837
|
-
if(!(p1 === p2)) {
|
|
1838
|
-
let placed = false;
|
|
1839
|
-
for(let k = 0; k < 5; k++) {
|
|
1840
|
-
if(!placed) {
|
|
1841
|
-
if(closest[k] === undefined) {
|
|
1842
|
-
closest[k] = p2;
|
|
1843
|
-
placed = true;
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
for(let k = 0; k < 5; k++) {
|
|
1849
|
-
if(!placed) {
|
|
1850
|
-
if(target.getDistance(p1, p2) < target.getDistance(p1, closest[k])) {
|
|
1851
|
-
closest[k] = p2;
|
|
1852
|
-
placed = true;
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
p1.closest = closest;
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
// 给每个点分配一个圆
|
|
1863
|
-
for(let i in points) {
|
|
1864
|
-
if (points.hasOwnProperty(i)) {
|
|
1865
|
-
points[i].circle = new Circle( options, points[i], 2 + Math.random() * 2 );
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
options.points = points;
|
|
1869
|
-
target.initAnimation(options, ctx, xy);
|
|
1870
|
-
target.addListeners(options, xy, canvas);
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
getDistance(p1, p2) {
|
|
1874
|
-
return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
//开始绘制动画效果
|
|
1878
|
-
initAnimation(options, ctx, xy) {
|
|
1879
|
-
const target = this;
|
|
1880
|
-
target.animate(options, ctx, xy);
|
|
1881
|
-
for(let i in options.points) {
|
|
1882
|
-
if (options.points.hasOwnProperty(i)) {
|
|
1883
|
-
target.shiftPoint(options.points[i]);
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
animate(options, ctx, xy) {
|
|
1889
|
-
const target = this;
|
|
1890
|
-
if(options.animateHeader) {
|
|
1891
|
-
const points = options.points;
|
|
1892
|
-
ctx.clearRect(0, 0, options.width, options.height);
|
|
1893
|
-
for(let i in points) {
|
|
1894
|
-
if (points.hasOwnProperty(i)) {
|
|
1895
|
-
// 检测范围内的点
|
|
1896
|
-
if(Math.abs(target.getDistance(xy, points[i])) < 4000) {
|
|
1897
|
-
points[i].active = 0.3;
|
|
1898
|
-
points[i].circle.active = 0.6;
|
|
1899
|
-
} else if(Math.abs(target.getDistance(xy, points[i])) < 20000) {
|
|
1900
|
-
points[i].active = 0.1;
|
|
1901
|
-
points[i].circle.active = 0.3;
|
|
1902
|
-
} else if(Math.abs(target.getDistance(xy, points[i])) < 40000) {
|
|
1903
|
-
points[i].active = 0.02;
|
|
1904
|
-
points[i].circle.active = 0.1;
|
|
1905
|
-
} else {
|
|
1906
|
-
points[i].active = 0;
|
|
1907
|
-
points[i].circle.active = 0;
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
target.drawLines(options, points[i], ctx);
|
|
1911
|
-
points[i].circle.draw(ctx);
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
requestAnimationFrame(function() {
|
|
1916
|
-
target.animate(options, ctx, xy)
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
// 开始绘制动画效果 - 点
|
|
1921
|
-
shiftPoint(p) {
|
|
1922
|
-
const target = this;
|
|
1923
|
-
TweenLite.to(p, 1 + Math.random(), {
|
|
1924
|
-
x: p.originX - 50 + Math.random() * 100,
|
|
1925
|
-
y: p.originY - 50 + Math.random() * 100,
|
|
1926
|
-
ease: Circ.easeInOut,
|
|
1927
|
-
onComplete: function() {
|
|
1928
|
-
target.shiftPoint(p);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
)
|
|
1932
|
-
}
|
|
1933
|
-
|
|
1934
|
-
// 开始绘制动画效果 - 线
|
|
1935
|
-
drawLines(options, p, ctx) {
|
|
1936
|
-
if(!p.active) return;
|
|
1937
|
-
for(let i in p.closest) {
|
|
1938
|
-
if (p.closest.hasOwnProperty(i)) {
|
|
1939
|
-
ctx.beginPath();
|
|
1940
|
-
ctx.moveTo( p.x, p.y );
|
|
1941
|
-
ctx.lineTo( p.closest[i].x, p.closest[i].y );
|
|
1942
|
-
ctx.strokeStyle = "rgba(" + options.lineColor + "," + p.active + ")";
|
|
1943
|
-
ctx.stroke();
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
// 监听事件,移动鼠标, 滚动, 改变屏幕大小
|
|
1949
|
-
addListeners(options, xy, canvas) {
|
|
1950
|
-
const target = this;
|
|
1951
|
-
const mousemove = (e) => {
|
|
1952
|
-
target.mouseMove(e, xy);
|
|
1953
|
-
};
|
|
1954
|
-
const scroll = () => {
|
|
1955
|
-
target.scrollCheck(options);
|
|
1956
|
-
};
|
|
1957
|
-
const resize = () => {
|
|
1958
|
-
target.resize(options, canvas);
|
|
1959
|
-
};
|
|
1960
|
-
|
|
1961
|
-
if (document.getElementById(target.options.canvasId)) {
|
|
1962
|
-
if(!('ontouchstart' in window)) {
|
|
1963
|
-
window.addEventListener("mousemove", mousemove);
|
|
1964
|
-
}
|
|
1965
|
-
window.addEventListener("scroll", scroll);
|
|
1966
|
-
window.addEventListener("resize", resize);
|
|
1967
|
-
} else {
|
|
1968
|
-
if(!('ontouchstart' in window)) {
|
|
1969
|
-
window.removeEventListener("mousemove", mousemove);
|
|
1970
|
-
}
|
|
1971
|
-
window.removeEventListener("scroll", scroll);
|
|
1972
|
-
window.removeEventListener("resize", resize);
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
|
-
mouseMove(e, xy) {
|
|
1977
|
-
const canvas = document.getElementById(this.options.canvasId);
|
|
1978
|
-
if (canvas) {
|
|
1979
|
-
const rect = canvas.getBoundingClientRect(),
|
|
1980
|
-
scrollTop = window.pageYOffset || document.documentElement.scrollTop,
|
|
1981
|
-
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
|
|
1982
|
-
offsetTop = rect.top + scrollTop,
|
|
1983
|
-
offsetLeft = rect.left + scrollLeft;
|
|
1984
|
-
|
|
1985
|
-
let posx = 0,
|
|
1986
|
-
posy = 0;
|
|
1987
|
-
if (e.pageX || e.pageY) {
|
|
1988
|
-
posx = e.pageX;
|
|
1989
|
-
posy = e.pageY;
|
|
1990
|
-
} else if (e.clientX || e.clientY) {
|
|
1991
|
-
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
|
1992
|
-
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
|
1993
|
-
}
|
|
1994
|
-
xy.x = posx - offsetLeft;
|
|
1995
|
-
xy.y = posy - offsetTop;
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1999
|
-
scrollCheck(options) {
|
|
2000
|
-
options.animateHeader = document.body.scrollTop <= options.height
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
resize(options, canvas) {
|
|
2004
|
-
if (options.isWindowWidth) canvas.width = window.innerWidth;
|
|
2005
|
-
if (options.isWindowHeight) canvas.height = window.innerHeight;
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
/* ========================================================================
|
|
2011
|
-
* 12. 鼠标上下左右划入监听实现对应动画
|
|
2012
|
-
* 2022年7月28日 10:50:06
|
|
2013
|
-
* ========================================================================
|
|
2014
|
-
* <pre>
|
|
2015
|
-
<div class="p-3">
|
|
2016
|
-
<div class="ce-thumbs row" id="ce-thumbs">
|
|
2017
|
-
<div class="ce-thumb col-4">
|
|
2018
|
-
<a href="#">
|
|
2019
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="w-100" />
|
|
2020
|
-
<div>
|
|
2021
|
-
<div class="ce-ts-info"> MAPLE </div>
|
|
2022
|
-
</div>
|
|
2023
|
-
</a>
|
|
2024
|
-
</div>
|
|
2025
|
-
<div class="ce-thumb col-4">
|
|
2026
|
-
<a href="#">
|
|
2027
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="w-100" />
|
|
2028
|
-
<div>
|
|
2029
|
-
<div class="ce-ts-info"> BIRCH </div>
|
|
2030
|
-
</div>
|
|
2031
|
-
</a>
|
|
2032
|
-
</div>
|
|
2033
|
-
<div class="ce-thumb col-4">
|
|
2034
|
-
<a href="#">
|
|
2035
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="w-100" />
|
|
2036
|
-
<div>
|
|
2037
|
-
<div class="ce-ts-info"> BLACK WALNUT </div>
|
|
2038
|
-
</div>
|
|
2039
|
-
</a>
|
|
2040
|
-
</div>
|
|
2041
|
-
<div class="ce-thumb col-4">
|
|
2042
|
-
<a href="#">
|
|
2043
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="w-100" />
|
|
2044
|
-
<div>
|
|
2045
|
-
<div class="ce-ts-info"> OLIVE </div>
|
|
2046
|
-
</div>
|
|
2047
|
-
</a>
|
|
2048
|
-
</div>
|
|
2049
|
-
<div class="ce-thumb col-4">
|
|
2050
|
-
<a href="#">
|
|
2051
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="w-100" />
|
|
2052
|
-
<div class="ce-ts-info">
|
|
2053
|
-
<div class="ce-ts-info"> DOGWOOD </div>
|
|
2054
|
-
</div>
|
|
2055
|
-
</a>
|
|
2056
|
-
</div>
|
|
2057
|
-
<div class="ce-thumb col-4">
|
|
2058
|
-
<a href="#">
|
|
2059
|
-
<img src="//arisu.cn/file/images/res/anime/anime1470402086147.jpg" class="w-100" />
|
|
2060
|
-
<div>
|
|
2061
|
-
<div class="ce-ts-info"> POPLAR </div>
|
|
2062
|
-
</div>
|
|
2063
|
-
</a>
|
|
2064
|
-
</div>
|
|
2065
|
-
</div>
|
|
2066
|
-
</div>
|
|
2067
|
-
|
|
2068
|
-
import "istyle/src/css/case/ce-thumbs.css";
|
|
2069
|
-
new u.HoverDir(".ce-thumb", {
|
|
2070
|
-
reverse: false
|
|
2071
|
-
})
|
|
2072
|
-
* </pre>
|
|
2073
|
-
* ======================================================================== */
|
|
2074
|
-
export class HoverDir {
|
|
2075
|
-
constructor( selector, custom ) {
|
|
2076
|
-
this.selector = selector;
|
|
2077
|
-
defaultConstructor( this, selector, custom, ( target ) => {
|
|
2078
|
-
target.elements.forEach( ( element ) => {
|
|
2079
|
-
let myElems = b( element );
|
|
2080
|
-
if (!myElems.data( "be.hoverdir" ))
|
|
2081
|
-
myElems.data( "be.hoverdir", target );
|
|
2082
|
-
|
|
2083
|
-
target.init( element, custom );
|
|
2084
|
-
} );
|
|
2085
|
-
} )
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
options = {
|
|
2089
|
-
reverse: false
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
init(element, options) {
|
|
2093
|
-
const target = this,
|
|
2094
|
-
myElement = b(element);
|
|
2095
|
-
myElement.on("mouseenter", (event) => this.mouseEvent(event, target, options));
|
|
2096
|
-
myElement.on("mouseleave", (event) => this.mouseEvent(event, target, options));
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
mouseEvent(event, target, options) {
|
|
2100
|
-
const myEle = b(event.currentTarget),
|
|
2101
|
-
evType = event.type,
|
|
2102
|
-
myHoverElem = myEle.find("div"),
|
|
2103
|
-
direction = target.getDir(myEle, { x: event.pageX, y: event.pageY }),
|
|
2104
|
-
hoverClasses = target.getClasses(direction, options);
|
|
2105
|
-
myHoverElem.removeClass();
|
|
2106
|
-
if (evType === "mouseenter") {
|
|
2107
|
-
setTimeout(() => {
|
|
2108
|
-
myHoverElem.css('display', 'none').addClass(hoverClasses.from);
|
|
2109
|
-
myHoverElem.show(15, (e) => {
|
|
2110
|
-
b(e).addClass(hoverClasses.to);
|
|
2111
|
-
})
|
|
2112
|
-
}, 15);
|
|
2113
|
-
} else {
|
|
2114
|
-
myHoverElem.addClass(hoverClasses.from);
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
getDir(myEle, coordinates) {
|
|
2119
|
-
const w = myEle.width(),
|
|
2120
|
-
h = myEle.height(),
|
|
2121
|
-
x = (coordinates.x - myEle.offset().left - (w / 2)) * (w > h ? (h / w) : 1),
|
|
2122
|
-
y = (coordinates.y - myEle.offset().top - (h / 2)) * (h > w ? (w / h) : 1);
|
|
2123
|
-
return Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
|
-
getClasses(direction, options) {
|
|
2127
|
-
let fromClass, toClass;
|
|
2128
|
-
switch (direction) {
|
|
2129
|
-
case 0: (!options.reverse) ? fromClass = "ce-slideFromTop" : fromClass = "ce-slideFromBottom"; toClass = "ce-slideTop"; break;
|
|
2130
|
-
case 1: (!options.reverse) ? fromClass = "ce-slideFromRight" : fromClass = "ce-slideFromLeft"; toClass = "ce-slideLeft"; break;
|
|
2131
|
-
case 2: (!options.reverse) ? fromClass = "ce-slideFromBottom" : fromClass = "ce-slideFromTop"; toClass = "ce-slideTop"; break;
|
|
2132
|
-
case 3: (!options.reverse) ? fromClass = "ce-slideFromLeft" : fromClass = "ce-slideFromRight"; toClass = "ce-slideLeft"; break;
|
|
2133
|
-
}
|
|
2134
|
-
return {from: fromClass, to: toClass };
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
/* ========================================================================
|
|
2140
|
-
* 13. JS、CSS页面引入,多次引入只保留一个
|
|
2141
|
-
* 2024年9月15日 09:19:37
|
|
2142
|
-
* ========================================================================
|
|
2143
|
-
* <pre>
|
|
2144
|
-
const iloader = new u.ILoader();
|
|
2145
|
-
Promise.all([
|
|
2146
|
-
iloader.loadStyle('https://arisu.cn/te/WEB/css/animate.v4.css'),
|
|
2147
|
-
iloader.loadScript('https://arisu.cn/te/WEB/js/handlebars-v4.0.5.js'),
|
|
2148
|
-
iloader.loadScript('https://arisu.cn/te/WEB/js/imagesloaded.pkgd.min.js'),
|
|
2149
|
-
]).then(() => {
|
|
2150
|
-
console.log('All scripts、style loaded');
|
|
2151
|
-
}).catch(error => {
|
|
2152
|
-
console.error('Error loading scripts、style', error);
|
|
2153
|
-
});
|
|
2154
|
-
* </pre>
|
|
2155
|
-
* ======================================================================== */
|
|
2156
|
-
export class ILoader {
|
|
2157
|
-
constructor(custom) {
|
|
2158
|
-
/** @type {Array<{script: HTMLElement, url: string, isLoaded: boolean}>} **/
|
|
2159
|
-
this.jsLoaded = [];
|
|
2160
|
-
this.cssLoaded = [];
|
|
2161
|
-
this.options = b.extend( custom, this.options );
|
|
2162
|
-
}
|
|
2163
|
-
options = {
|
|
2164
|
-
// 脚本加载失败,重新尝试次数和每次使用时间(毫秒)
|
|
2165
|
-
times: 20,
|
|
2166
|
-
time: 1000
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
/** 定义一个加载并执行外部 JS 文件的函数
|
|
2170
|
-
const iloader = new u.ILoader();
|
|
2171
|
-
Promise.all([
|
|
2172
|
-
iloader.loadScript('https://arisu.cn/te/WEB/js/handlebars-v4.0.5.js'),
|
|
2173
|
-
iloader.loadScript('https://arisu.cn/te/WEB/js/imagesloaded.pkgd.min.js')
|
|
2174
|
-
]).then(() => {
|
|
2175
|
-
console.log('All scripts loaded');
|
|
2176
|
-
}).catch(error => {
|
|
2177
|
-
console.error('Error loading scripts', error);
|
|
2178
|
-
});
|
|
2179
|
-
* @param url
|
|
2180
|
-
* @returns {Promise<unknown>}
|
|
2181
|
-
*/
|
|
2182
|
-
loadScript(url) {
|
|
2183
|
-
const target = this;
|
|
2184
|
-
|
|
2185
|
-
return new Promise((resolve, reject) => {
|
|
2186
|
-
// 检查是否已经加载过该脚本
|
|
2187
|
-
const existingScript = target.jsLoaded.find(script => script.url === url);
|
|
2188
|
-
if (!existingScript) {
|
|
2189
|
-
// 页面上未引入
|
|
2190
|
-
let script = document.createElement('script'),
|
|
2191
|
-
isOnload = false,
|
|
2192
|
-
count = 0;
|
|
2193
|
-
|
|
2194
|
-
target.jsLoaded = [...target.jsLoaded, { script: script, url: url, isLoaded: false, count: 0 }];
|
|
2195
|
-
|
|
2196
|
-
script.src = url;
|
|
2197
|
-
// script.async = 'true';
|
|
2198
|
-
script.onload = () => {
|
|
2199
|
-
target.jsLoaded = target.jsLoaded.map(item =>
|
|
2200
|
-
item.url === url ? { ...item, isLoaded: true } : item
|
|
2201
|
-
);
|
|
2202
|
-
isOnload = true;
|
|
2203
|
-
resolve(script);
|
|
2204
|
-
};
|
|
2205
|
-
script.onerror = () => {
|
|
2206
|
-
target.jsLoaded = target.jsLoaded.filter(item => item.url !== url);
|
|
2207
|
-
reject(new Error('Script load error for ' + url));
|
|
2208
|
-
}
|
|
2209
|
-
document.body.append(script);
|
|
2210
|
-
const intervalId = setInterval(() => {
|
|
2211
|
-
if (isOnload) {
|
|
2212
|
-
// b.l('载入成功!: ', url)
|
|
2213
|
-
clearInterval(intervalId);
|
|
2214
|
-
return;
|
|
2215
|
-
} else {
|
|
2216
|
-
if (count > target.options.times) {
|
|
2217
|
-
// console.log('载入失败!: ', url)
|
|
2218
|
-
if (script.parentNode === document.body) document.body.removeChild(script);
|
|
2219
|
-
clearInterval(intervalId);
|
|
2220
|
-
return;
|
|
2221
|
-
}
|
|
2222
|
-
}
|
|
2223
|
-
count++;
|
|
2224
|
-
}, 100);
|
|
2225
|
-
} else {
|
|
2226
|
-
// 页面上已经引入,但是还未调用
|
|
2227
|
-
let count = 0, scriptItem;
|
|
2228
|
-
const intervalId = setInterval(() => {
|
|
2229
|
-
scriptItem = target.jsLoaded.find(item => item.url === url);
|
|
2230
|
-
b.l('尝试加载中: ', url, count)
|
|
2231
|
-
try {
|
|
2232
|
-
if (!scriptItem.isLoaded && count > target.options.times) {
|
|
2233
|
-
// b.l('删除了URL: ', scriptItem.url);
|
|
2234
|
-
target.jsLoaded = target.jsLoaded.filter(item => item.url !== url);
|
|
2235
|
-
if (scriptItem.script.parentNode === document.body) document.body.removeChild(scriptItem.script);
|
|
2236
|
-
clearInterval(intervalId);
|
|
2237
|
-
return;
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
if (scriptItem.isLoaded) {
|
|
2241
|
-
// b.l('载入成功 ');
|
|
2242
|
-
clearInterval(intervalId);
|
|
2243
|
-
resolve();
|
|
2244
|
-
return;
|
|
2245
|
-
}
|
|
2246
|
-
count++;
|
|
2247
|
-
} catch(e) { console.error(e) }
|
|
2248
|
-
}, target.options.time);
|
|
2249
|
-
}
|
|
2250
|
-
})
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
/** 定义一个加载并执行外部 JS 文件的函数
|
|
2254
|
-
Promise.all([
|
|
2255
|
-
loadScript('https://arisu.cn/te/WEB/css/buttons-plus.css'),
|
|
2256
|
-
loadStyle('https://arisu.cn/te/WEB/css/animate.v4.css')
|
|
2257
|
-
]).then(() => {
|
|
2258
|
-
console.log('All scripts/style loaded');
|
|
2259
|
-
}).catch(error => {
|
|
2260
|
-
console.error('Error loading', error);
|
|
2261
|
-
});
|
|
2262
|
-
* @param href 样式地址
|
|
2263
|
-
* @returns {Promise<unknown>}
|
|
2264
|
-
*/
|
|
2265
|
-
loadStyle(href) {
|
|
2266
|
-
const target = this;
|
|
2267
|
-
return new Promise((resolve, reject) => {
|
|
2268
|
-
// 检查是否已经加载了CSS文件
|
|
2269
|
-
const links = document.getElementsByTagName("link");
|
|
2270
|
-
for (let i = 0; i < links.length; i++) {
|
|
2271
|
-
if (links[i].getAttribute("href") === href) {
|
|
2272
|
-
resolve();
|
|
2273
|
-
return true;
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
let style = document.createElement('link');
|
|
2278
|
-
style.href = href;
|
|
2279
|
-
style.rel = 'stylesheet';
|
|
2280
|
-
style.type = 'text/css';
|
|
2281
|
-
style.onload = () => resolve(style);
|
|
2282
|
-
style.onerror = () => reject(new Error('Style load error for ' + href));
|
|
2283
|
-
document.head.append(style);
|
|
2284
|
-
target.cssLoaded.push(style);
|
|
2285
|
-
});
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
// 删除所有引入脚本、样式
|
|
2289
|
-
destroy() {
|
|
2290
|
-
this.jsLoaded.forEach((item)=>{
|
|
2291
|
-
if (item.script && item.script.parentNode === document.body) document.body.removeChild(item.script);
|
|
2292
|
-
})
|
|
2293
|
-
this.cssLoaded.forEach((item)=>{
|
|
2294
|
-
if (item.parentNode === document.head) document.head.removeChild(item);
|
|
2295
|
-
})
|
|
2296
|
-
this.jsLoaded = [];
|
|
2297
|
-
this.cssLoaded = [];
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
export { b };
|
|
2304
|
-
export default b;
|