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.
@@ -1,3718 +0,0 @@
1
- /* ========================================================================
2
- * @描述:常用JS方法
3
- * @作者:林舒涛
4
- * ========================================================================
5
-
6
- var base = new Base();
7
-
8
- typescript:
9
- import { Base } from 'src/assets/js/base/base-1.2.js';
10
- var b:Base = new Base();
11
-
12
- * ======================================================================== */
13
-
14
- /** *
15
- * @描述:注释范例
16
- * @参数:
17
- * p1: 参数一
18
- * p2: 参数二
19
- * @脚本:
20
- * <pre>
21
- * 示范代码,外层加上pre标签保证显示能换行
22
- * </pre>
23
- * @返回:
24
- * 0: 返回值0
25
- * 1: 返回值1
26
- * @日期:时间
27
- * **/
28
-
29
- //$(function() {
30
- // var system = {
31
- // win : false,
32
- // mac : false,
33
- // xll : false
34
- // };
35
- // var p = navigator.platform;
36
- // system.win = p.indexOf("Win") == 0;
37
- // system.mac = p.indexOf("Mac") == 0;
38
- // system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
39
- //
40
- // if(system.win || system.mac || system.xll) {
41
- // $("#load").load("pc.jsp", function(){alert("载入对应电脑页面")});
42
- // } else {
43
- // $("#load").load("mobile.jsp", function(){alert("载入对应移动设备页面")});
44
- // }
45
- //});
46
-
47
-
48
- /** ----------------------------------------- <1> 常用的一些JS方法
49
- **/
50
-
51
- /******
52
- * @描述:替换全部 replace() 方法加强,如果是变量不会替换原变量
53
- * @脚本:"aba".replaceAll("a", "") //b
54
- * @日期:2015年11月4日14:14:48
55
- * **/
56
- String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
57
- if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
58
- return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
59
- } else {
60
- return this.replace(reallyDo, replaceWith);
61
- }
62
- }
63
-
64
- /******
65
- * @描述:清空格
66
- * @脚本:" a ".trim() //a
67
- * @日期:2016年2月14日13:33:46
68
- * **/
69
- String.prototype.trim = function() {
70
- return this.replace(/(^\s*)|(\s*$)/g, "");
71
- }
72
-
73
- /******
74
- * @描述:时间格式化
75
- * @脚本:new Date().format("yyyy-MM-dd hh:mm:ss:SSS")
76
- * @日期:2015年4月15日17:12:41
77
- * **/
78
- Date.prototype.format = function(fmt) {
79
- var o = {
80
- "M+" : this.getMonth() + 1,
81
- "d+" : this.getDate(),
82
- "h+" : this.getHours(),
83
- "m+" : this.getMinutes(),
84
- "s+" : this.getSeconds(),
85
- "q+" : Math.floor((this.getMonth() + 3) / 3),
86
- "S" : this.getMilliseconds()
87
- };
88
- if (/(y+)/.test(fmt))
89
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
90
- for ( var k in o)
91
- if (new RegExp("(" + k + ")").test(fmt))
92
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
93
- return fmt;
94
- }
95
-
96
- /******
97
- * @描述:数组根据下标删除扩展
98
- * @脚本:
99
- * <pre>
100
- * <1> array.remove(0);//删除第一个元素
101
- * <2> array.remove(-1);//删除倒数第一个元素
102
- * <3> array.remove(0, 2);///删除数组中下标为0-2的元素(3个)
103
- * </pre>
104
- * @日期:2016年1月25日13:42:20
105
- * **/
106
- Array.prototype.remove = function(from, to) {
107
- var rest = this.slice((to || from) + 1 || this.length);
108
- this.length = from < 0 ? this.length + from : from;
109
- return this.push.apply(this, rest);
110
- }
111
-
112
- /******
113
- * @描述:删除重复元素
114
- * @脚本:
115
- * <pre>
116
- * var oldArr = new Array(); //之前保存的
117
- * oldArr[0] = 1;
118
- * oldArr[1] = 2;
119
- *
120
- * var newArr = new Array(); //现在保存需要保存的
121
- * newArr[0] = 1;
122
- * newArr[1] = 2;
123
- * newArr[2] = 3;
124
- * newArr[3] = 1;
125
- *
126
- * var onArr = oldArr.concat(newArr);
127
- * console.log(onArr); // (6) [1, 2, 1, 2, 3, 1]
128
- * console.log(onArr.unique()); // (3) [1, 2, 3]
129
- * </pre>
130
- * @日期:2019年5月15日10:01:34
131
- * **/
132
- Array.prototype.unique = function () {
133
- var temp = new Array();
134
- this.sort();
135
- for(i = 0; i < this.length; i++) {
136
- if(this[i] == this[i+1]) {
137
- continue;
138
- }
139
- temp[temp.length]=this[i];
140
- }
141
- return temp;
142
- }
143
-
144
- //export class Base {};
145
- var Base = function() {};
146
-
147
- /******
148
- * @描述:获取URL中的参数(url?name=alice)
149
- * @脚本:getParam("name"); //alice
150
- * @日期:2015年4月15日17:12:41
151
- * **/
152
- Base.prototype.getParam = function(key) {
153
- var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)", "i");
154
- var r = window.location.search.substr(1).match(reg);
155
- debug(window.location.search)
156
- if (r != null) return unescape(r[2]); return null;
157
- }
158
-
159
- /******
160
- * @描述:获取变量属性数值
161
- * @脚本:
162
- * <pre>
163
- * var o = {abc: "数据正常"}
164
- * var value = base.findPrototype(o, "abc");
165
- * alert(value);//数据正常
166
- * </pre>
167
- * @日期:2016年3月8日14:23:13
168
- * **/
169
- Base.prototype.findPrototype = function(object, prototype) {
170
- var result = "";
171
- for (var p in object)
172
- if (typeof object[p] === "string" && p == prototype)
173
- result = object[p];
174
- return result;
175
- }
176
-
177
- /******
178
- * @描述:删除变量属性
179
- * @脚本:
180
- * <pre>
181
- * var o = {abc: "数据正常"}
182
- * base.removePrototype(o, "abc");
183
- * </pre>
184
- * @日期:2016年3月8日14:23:13
185
- * **/
186
- Base.prototype.removePrototype = function(object, prototype) {
187
- for (var p in object)
188
- if (typeof object[p] === "string" && p == prototype)
189
- delete object[p];
190
- return object;
191
- }
192
-
193
- /******
194
- * @描述:判断两个对象属性以及值是否相等
195
- * @日期:2016年3月9日13:59:37
196
- * **/
197
- Base.prototype.isObjectValueEqual = function(a, b) {
198
- var result = true;
199
- var aProps = Object.getOwnPropertyNames(a);
200
- var bProps = Object.getOwnPropertyNames(b);
201
-
202
- if (aProps.length != bProps.length) {
203
- result = false;
204
- }
205
- for (var i = 0; i < aProps.length; i++) {
206
- var propName = aProps[i];
207
- if (a[propName] !== b[propName]) {
208
- result = false;
209
- }
210
- }
211
- return result;
212
- }
213
-
214
-
215
- /******
216
- * @描述:四舍五入保留n位
217
- * @脚本:toDecimal(3.14159, 2);
218
- * @日期:2015年11月4日14:12:47
219
- * **/
220
- Base.prototype.toDecimal = function(number, save) {
221
- var result = parseFloat(number);
222
- if (result)
223
- result = Math.round(number * Math.pow(10, save)) / Math.pow(10, save);
224
- else
225
- result = 0;
226
- return result;
227
- }
228
-
229
-
230
- /******
231
- * @描述:返回数据为空时设置默认值
232
- * @脚本:
233
- * <pre>
234
- * setDefault(data.id, 0);
235
- * 或者
236
- * var language = base.setDefault(base.getParam("language"), "");
237
- * </pre>
238
- * @日期:2015-10-19 17:36:37
239
- * **/
240
- Base.prototype.setDefault = function(target, defaultVal) {
241
- if (target == null || target == undefined || target == "" || target == "null")
242
- target = defaultVal;
243
- return target;
244
- }
245
-
246
- /******
247
- * @描述:判断变量是否为空
248
- * @脚本:
249
- * <pre>
250
- * if(base.isNull(变量)) {
251
- * } else {
252
- * }
253
- * </pre>
254
- * @日期:2020年1月15日10:34:45
255
- * **/
256
- Base.prototype.isNull = function(target) {
257
- var result = true;
258
- if (target == null || target == undefined || target == "" || target == "null")
259
- result = false;
260
- return result;
261
- }
262
-
263
- /******
264
- * @描述:获取两个数组相同的元素
265
- * @脚本:
266
- * <pre>
267
- * var oldArr = new Array(); //之前保存的
268
- * oldArr[0] = 1;
269
- * oldArr[1] = 2;
270
- * var newArr = new Array(); //现在保存需要保存的
271
- * newArr[0] = 1;
272
- * newArr[1] = 2;
273
- * newArr[2] = 3;
274
- * newArr[3] = 1;
275
- *
276
- * var a = base.same(oldArr, newArr);
277
- * console.log(a);//(2) [1, 2]
278
- * </pre>
279
- * @日期:2019年5月15日10:59:57
280
- * **/
281
- Base.prototype.same = function(arr1, arr2) {
282
- var arr3 = arr1.filter(function(v){
283
- return arr2.indexOf(v)!==-1
284
- });
285
- return arr3;
286
- }
287
-
288
-
289
- /******
290
- * @描述:获取两个数组不同的元素
291
- * @脚本:
292
- * <pre>
293
- * var oldArr = new Array(); //之前保存的
294
- * oldArr[0] = 1;
295
- * oldArr[1] = 2;
296
- *
297
- * var newArr = new Array(); //现在保存需要保存的
298
- * newArr[0] = 1;
299
- * newArr[1] = 2;
300
- * newArr[2] = 3;
301
- * newArr[3] = 1;
302
- *
303
- * var b = base.different(oldArr, newArr);
304
- * console.log(b);//[3]
305
- * </pre>
306
- * @日期:2019年5月15日10:59:57
307
- * **/
308
- Base.prototype.different = function(arr1, arr2) {
309
- //console.log(arr1.concat(arr2));
310
- //数组.filter循环数组,return的值为true则返回数v
311
- var arr3 = arr1.concat(arr2).filter(function (v) {
312
- // console.log(v); //1, 2, 1, 2, 3 数组的值
313
- // console.log(arr1.indexOf(v)); //0, 1, 0, 1, -1
314
- // console.log(arr2.indexOf(v)); //0, 1, 0, 1, 2
315
-
316
- //数组.indexOf(数组中的值),查询数组中该数是否存在,不存在返回-1,存在返回所在位置序号
317
- //合并后的数组列表如果不存在于其中一个合并前的数组就true,即返回该数
318
- return arr1.indexOf(v)===-1 || arr2.indexOf(v)===-1;
319
- })
320
- return arr3;
321
- }
322
-
323
- /******
324
- * @描述:对比arr1和arr2,如果arr2有arr1没有这返回该数
325
- * @脚本:
326
- * <pre>
327
- * var oldArr = new Array(); //之前保存的
328
- * oldArr[0] = 1;
329
- * oldArr[1] = 2;
330
- *
331
- * var newArr = new Array(); //现在保存需要保存的
332
- * newArr[0] = 3;
333
- *
334
- * var b = newArray(oldArr, newArr);
335
- * console.log("需要添加的数:" + b);
336
- *
337
- * var c = newArray(newArr, oldArr);
338
- * console.log("需要删除的数:" + c);
339
- * </pre>
340
- * @日期:2019年5月20日11:56:52
341
- * **/
342
- Base.prototype.newArray = function(arr1, arr2) {
343
- //console.log(arr1.concat(arr2));
344
- //数组.filter循环数组,return的值为true则返回数v
345
- var arr3 = arr1.concat(arr2).filter(function (v) {
346
- return arr1.indexOf(v)===-1 && arr2.indexOf(v)!=-1;
347
- })
348
- return arr3;
349
- }
350
-
351
- /** *
352
- * @描述:字符串复杂度验证
353
- * @参数:
354
- * str: 需要验证的字符串
355
- * lenMin: 字符串满足最小长度验证
356
- * lenMax: 字符串满足最大长度验证
357
- * @脚本:
358
- * <pre>
359
- * var str = $("#input1").val();
360
- * var lenMin = 0;
361
- * var lenMax = 32;
362
- * var result = b.strValidation(str, lenMin, lenMax);
363
- * if (result == 1) {
364
- * debug("字符串小于等于" + lenMin + ",或者大于等于" + lenMax);
365
- * } else if (result == 2) {
366
- * debug("全部为数字");
367
- * } else if (result == 3) {
368
- * debug("全部为字母");
369
- * } else if (result == 4) {
370
- * debug("包含字母数字");
371
- * } else if (result == 5) {
372
- * debug("只包含特殊字符");
373
- * } else if (result == 8) {
374
- * debug("包含字母数字及特殊字符");
375
- * } else {
376
- * debug("没有可以匹配的,必须包含英文字母数字及键盘上的特殊字符");
377
- * }
378
- * </pre>
379
- *
380
- * @返回:
381
- * 0: 没有可以匹配的,只匹配英文字母数字及键盘上的特殊字符
382
- * 1: 字符串小于等于len
383
- * 2: 全部为数字
384
- * 3: 全部为字母
385
- * 4: 包含字母数字
386
- * 5: 全部为特殊字符
387
- * 8: 包含字母数字及特殊字符
388
- * @日期:2020年1月20日18:27:21
389
- * **/
390
- Base.prototype.strValidation = function(str, lenMin, lenMax) {
391
- //没有可以匹配的,只匹配英文字母数字及键盘上的特殊字符
392
- var result = 0;
393
-
394
- var d1 = /^[^\u4e00-\u9fa5a-zA-Z\d,\.,。]{0,32}$/;//全部为特殊字符
395
- var d4 = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{0,}$/;//包含字母数字及特殊字符
396
- var medium = /^[0-9a-zA-z]{0,32}$/;//包含字母数字
397
- var e1 = /^[0-9]{0,32}$/;//全部为数字
398
- var e2 = /^[a-zA-z]{0,32}$/;//全部为字母
399
-
400
- if (str.length <= lenMin || str.length >= lenMax) {
401
- //字符串小于等于lenMin或者大于等于lenMax
402
- result = 1;
403
- } else if (e1.test(str)) {
404
- result = 2;
405
- } else if (e2.test(str)) {
406
- result = 3;
407
- } else if (medium.test(str)) {
408
- result = 4;
409
- } else if (d1.test(str)) {
410
- result = 5;
411
- // } else if (d2.test(str)) {
412
- // result = 6;
413
- // } else if (d3.test(str)) {
414
- // result = 7;
415
- } else if (d4.test(str)) {
416
- result = 8;
417
- }
418
- return result;
419
- }
420
-
421
- /******
422
- * @描述:页面内滑动特效
423
- * @参数:
424
- * $target: 需要移动的该jquery对象的位置
425
- * time: 动画执行时长(默认为500毫秒)
426
- * @脚本:
427
- * <pre>
428
- * moveToEF($("body"), 100);
429
- * 或者
430
- * moveToEF($("body"));
431
- * </pre>
432
- * @日期:2015年9月9日15:35:04
433
- * **/
434
- Base.prototype.moveToEF = function($target, time) {
435
- if (time == undefined || time == null || time == "" || time == "null")
436
- time = 500;
437
- $("html,body").animate({scrollTop: $target.offset().top}, time);
438
- }
439
-
440
- /******
441
- * @描述:判断对象是否存在,存在执行定义的方法
442
- * @参数:
443
- * elememt: 对象
444
- * times: 执行次数,每次100毫秒,一直不存在就停止执行
445
- * fun: 找到元素后要执行的方法
446
- * @脚本:
447
- * <pre>
448
- <div id="testdiv"></div>
449
-
450
- var base = new Base();
451
- base.runInExist("#testa", 8, function(e) {
452
- $("#testa").click(function(e) {
453
- alert("testa 存在");
454
- });
455
- })
456
- setTimeout(function() {
457
- $("#testdiv").html("<a id='testa' href='#'>testa</a>");
458
- }, 1000);
459
- * </pre>
460
- * @日期:2020年6月26日08:55:42
461
- * **/
462
- Base.prototype.runInExist = function(elememt, times, fun) {
463
- var timeout = 100;
464
- setTimeout(function() {
465
- if ($(elememt).length > 0) {
466
- if (fun)
467
- fun();
468
- } else {
469
- // debug("times: " + times);
470
- if (times > 0)
471
- Base.prototype.runInExist(elememt, times - 1, fun);
472
- }
473
- }, timeout);
474
- }
475
-
476
-
477
-
478
-
479
- /******
480
- * @描述:控制台打印
481
- * @脚本:base.debug(obj) // debug(obj, true)
482
- * @日期:2015年10月5日20:12:46
483
- * **/
484
- Base.prototype.debug = function(target, isDir) {
485
- if (window.console && window.console.log) {
486
- if (isDir) {
487
- window.console.dir(target);
488
- } else {
489
- window.console.log(target);
490
- }
491
- }
492
- }
493
-
494
- /******
495
- * @描述:添加删除class
496
- * @脚本:base.updateClass(class, remove, add);
497
- * @调用:<a id="d15-btn-2" class="button button-action" onclick="updateClass('.ce-foot', '', 'te-foot-1')">样式1</a>
498
- * @日期:2015-9-26 19:55:19
499
- * **/
500
- Base.prototype.updateClass = function(target, remove, add) {
501
- $(target).removeClass(remove);
502
- $(target).addClass(add);
503
- }
504
-
505
-
506
- /** ----------------------------------------- <2> 依赖于JS插件的方法 / JQUERY插件及常用方法方法封装
507
- **/
508
-
509
-
510
- /******
511
- * @描述:按钮特效
512
- * @参数:
513
- * target 添加事件的按钮
514
- * action 触发动作,eg: click or hover-in..
515
- * timing 运行时间
516
- * @脚本:
517
- * <pre>
518
- * base.pluginButtonStyle($("#be-btn"), "hover-in", 0.75);
519
- * </pre>
520
- * @日期:2016年2月18日09:53:42
521
- * **/
522
- Base.prototype.pluginButtonStyle = function(target, action, timing) {
523
- var ripple = target.find("use");
524
- target.unbind(action);
525
- target.bind(action, function(event) {
526
- var tl = new TimelineMax();
527
- x = event.offsetX,
528
- y = event.offsetY,
529
- w = event.target.offsetWidth,
530
- h = event.target.offsetHeight,
531
- offsetX = Math.abs((w / 2) - x),
532
- offsetY = Math.abs((h / 2) - y),
533
- deltaX = (w / 2) + offsetX,
534
- deltaY = (h / 2) + offsetY,
535
- scale_ratio = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
536
-
537
- tl.fromTo(ripple, timing, {
538
- x : x,
539
- y : y,
540
- transformOrigin : "50% 50%",
541
- scale : 0,
542
- opacity : 1,
543
- ease : Linear.easeIn
544
- }, {
545
- scale : scale_ratio,
546
- opacity : 0
547
- });
548
-
549
- });
550
- };
551
-
552
- /******
553
- * @描述:ztree等动态菜单生成
554
- * @脚本:
555
- * <pre>
556
- * 后台返回数据格式如:"trees":[{"name":"主菜单","id":1,"pId":null},{"name":"菜单","id":2,"pId":1}..
557
- * eg:
558
- * var html = new Base().menu(data.trees);
559
- * $("#nav-accordion").html(html);
560
- * <ul class="ce-accordion" id="nav-accordion"></ul>
561
- * </pre>
562
- * @日期:2017年2月25日19:54:02
563
- * **/
564
- Base.prototype.menu = function(trees, isIgnoreTop) {
565
- var html = "";
566
-
567
- var build = function(trees, level, pid) {
568
- var result = "";
569
- ++level;
570
- for ( var i = 0; i < trees.length; i++) {
571
- var tree = trees[i];
572
-
573
- var link = "#";
574
- if (tree.link)
575
- link = "../" + tree.link;
576
-
577
- if (tree.pId == null && level == 0) {
578
- if (isIgnoreTop) {
579
- //不显示第一层菜单
580
- result = build(trees, level, tree.id);
581
- } else {
582
- var html = build(trees, level, tree.id);
583
-
584
- if (html)
585
- html = "<ul class='sub'>" + html + "</ul>";
586
- result += "<li class='sub-menu'>" +
587
- "<a data-hash='" + tree.hash + "' id='" + tree.actionId + "' href='" + link + "'><span>" + tree.name + "</span></a>" +
588
- html +
589
- "</li>";
590
- }
591
- } else if (tree.pId == pid) {
592
- var html = "";
593
- if (tree.isParent) {//返回数据为节点即不再遍历
594
- html = build(trees, level, tree.id);
595
- if (html)
596
- html = "<ul class='sub'>" + html + "</ul>";
597
- }
598
-
599
- var icon = "";//第二层名称前加一个图标
600
- if (level == 1)
601
- icon = "<i class='" + tree.icon + "'/>";
602
-
603
- result += "<li class='sub-menu'>" +
604
- "<a data-hash='" + tree.hash + "' id='" + tree.actionId + "' href='" + link + "'>" +
605
- icon +
606
- "<span>" + tree.name + "</span>" +
607
- "</a>" +
608
- html +
609
- "</li>";
610
- }
611
- }
612
- return result;
613
- }
614
-
615
- var h = "";
616
- if (trees)
617
- h = build(trees, -1);
618
- return html + h;
619
- }
620
-
621
- /******
622
- * @描述:输入框特效
623
- * @脚本:
624
- * <pre>
625
- * base.search(function(txt) {
626
- * if (txt)
627
- * alert(txt);
628
- * });
629
- *
630
- * <div data-search="panent">
631
- * <span data-search="find" class="fa fa-search" aria-hidden="true"></span>
632
- * <input data-search="input" type="text" class="form-control" placeholder="检索你想找的内容">
633
- * <span data-search="clear" class="fa fa-trash-o" aria-hidden="true"></span>
634
- * </div>
635
- * </pre>
636
- * @日期:2015年4月15日17:12:41
637
- * **/
638
- Base.prototype.search = function(fun) {
639
- var $input = $("input[data-search='input']");
640
- var message = $input.attr("placeholder");
641
- $input.on("focus", "", function() {
642
- $(this).attr("placeholder", "");
643
- });
644
- $input.on("blur", "", function() {
645
- $(this).attr("placeholder", message);
646
- if ($(this).val().trim() != "")
647
- $(this).next().css("display", "inline-block");
648
- else
649
- $(this).next().css("display", "none");
650
- });
651
- if ($input.val().trim() != "")
652
- $input.next().css("display", "inline-block");
653
- $("span[data-search='clear']").on("click", "", function(){
654
- $(this).css("display", "none");
655
- $(this).prev().val("");
656
- });
657
- $("span[data-search='find']").on("click", "", function(){
658
- if(fun)
659
- fun($(this).next().val());
660
- });
661
- }
662
-
663
- /******
664
- * @描述:模板支持
665
- * @脚本:{{#if navType true}}{{/if}}
666
- * @日期:2015年4月17日09:27:50
667
- * **/
668
- Base.prototype.handlebars = function() {
669
- //等于
670
- Handlebars.registerHelper("if", function(v1, v2, options) {
671
- if (v1 == v2) {
672
- return options.fn(this);
673
- } else {
674
- return options.inverse(this);
675
- }
676
- });
677
-
678
- //小于
679
- Handlebars.registerHelper("lt", function(v1, v2, options) {
680
- if (v1 < v2) {
681
- return options.fn(this);
682
- } else {
683
- return options.inverse(this);
684
- }
685
- });
686
-
687
- //大于
688
- Handlebars.registerHelper("rt", function(v1, v2, options) {
689
- if (v1 > v2) {
690
- return options.fn(this);
691
- } else {
692
- return options.inverse(this);
693
- }
694
- });
695
-
696
- //小于等于
697
- Handlebars.registerHelper("lte", function(v1, v2, options) {
698
- if (v1 <= v2) {
699
- return options.fn(this);
700
- } else {
701
- return options.inverse(this);
702
- }
703
- });
704
-
705
- //大于等于
706
- Handlebars.registerHelper("rte", function(v1, v2, options) {
707
- if (v1 >= v2) {
708
- return options.fn(this);
709
- } else {
710
- return options.inverse(this);
711
- }
712
- });
713
- }
714
-
715
- /******
716
- * @描述:message插件方法封装 - 消息框
717
- * @参数:
718
- * @message: 消息
719
- * @type: info / error / success
720
- * @classes: 消息位置(2:顶部 / 6:左下下) ,按顺时针显示
721
- * @theme: 样式(2:黑色)
722
- * @脚本: al("操作成功!", "info", 2, "future");
723
- * @日期:2015年9月26日09:04:27
724
- * **/
725
- Base.prototype.al = function(message, type, classes, theme) {
726
- /**
727
- var theme;
728
- if (theme == 1) {
729
- theme = "flat";
730
- } else if (theme == 2) {
731
- theme = "future";
732
- } else if (theme == 3) {
733
- theme = "block";
734
- } else if (theme == 4) {
735
- theme = "air";
736
- } else if (theme == 5) {
737
- theme = "ice";
738
- } else {
739
- theme = "future";
740
- }
741
- **/
742
- if (!type) type = "info";
743
- if (!classes) classes = 3;
744
- if (!theme) theme = "future";
745
-
746
- var extraClasses;
747
- if (classes == 1) {
748
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-left";
749
- } else if (classes == 2) {
750
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
751
- } else if (classes == 3) {
752
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-right";
753
- } else if (classes == 4) {
754
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-right";
755
- } else if (classes == 5) {
756
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom";
757
- } else if (classes == 6) {
758
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-left";
759
- } else {
760
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
761
- }
762
-
763
- Messenger.options = {
764
- extraClasses: extraClasses,
765
- theme: theme
766
- }
767
-
768
- Messenger().post({
769
- message: message,
770
- type: type,
771
- hideAfter: 5,
772
- showCloseButton: true
773
- });
774
- }
775
- /******
776
- * @描述:message插件方法封装 - 确定框
777
- * @脚本:
778
- <pre>
779
- cf("是否确定删除该记录!", "确定删除", function(){
780
- al("删除成功!", "success", 2, "ice");
781
- }, 2, "ice")
782
- 默认样式为 future
783
- </pre>
784
-
785
- * @日期:2015年9月26日09:04:27
786
- * **/
787
- Base.prototype.cf = function(message, label, fun, classes, theme) {
788
- Messenger().hideAll();
789
-
790
- if (!theme) theme = "future";
791
- if (!classes) classes = 2;
792
-
793
- var extraClasses;
794
- if (classes == 1) {
795
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-left";
796
- } else if (classes == 2) {
797
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
798
- } else if (classes == 3) {
799
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-right";
800
- } else if (classes == 4) {
801
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-right";
802
- } else if (classes == 5) {
803
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom";
804
- } else if (classes == 6) {
805
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-left";
806
- } else {
807
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
808
- }
809
-
810
- Messenger.options = {
811
- extraClasses: extraClasses,
812
- theme: theme
813
- }
814
-
815
- msg = Messenger().post({
816
- message: message,
817
- actions: {
818
- retry: {
819
- label: label,
820
- phrase: "",
821
- auto: false,
822
- delay: 10,
823
- action: function() {
824
- fun();
825
- msg.cancel();
826
- }
827
- },
828
- cancel: {
829
- label: "取消",
830
- action: function() {
831
- return msg.cancel();
832
- }
833
- }
834
- }
835
- });
836
- }
837
-
838
- /******
839
- * @描述:jquery.hotkeys-master插件方法封装 - 绑定事件
840
- * @脚本:base.hotkeys($("#at-login-btn"), "return", $("body, #at-login input")); //点击回车触发按钮点击事件
841
- * @日期:2015年11月5日13:47:46
842
- * **/
843
- Base.prototype.hotkeys = function(target, code, bindTarget) {
844
- if (bindTarget)
845
- bindTarget.unbind("keydown");
846
- else
847
- $(document).unbind("keydown");
848
-
849
- if (bindTarget) {
850
- bindTarget.bind("keydown", code, function() {
851
- target.click();
852
- });
853
- } else {
854
- $(document).bind("keydown", code, function() {
855
- target.click();
856
- });
857
- }
858
- }
859
- /******
860
- * @描述:jquery.hotkeys-master插件方法封装 - 解除绑定
861
- * @脚本:base.hotkeysUnbind($("body, #at-login input"))
862
- * @日期:2015年11月5日14:24:58
863
- * **/
864
- Base.prototype.hotkeysUnbind = function(bindTarget) {
865
- if (bindTarget)
866
- bindTarget.unbind("keydown");
867
- else
868
- $(document).unbind("keydown");
869
- }
870
-
871
- /******
872
- * @描述:响应式下拉框,屏幕宽度大于767为HOVER显示,小于CLICK显示
873
- * @脚本:base.menuResponse()
874
- * @日期:2018年1月5日11:35:47
875
- * **/
876
- Base.prototype.menuResponse = function() {
877
-
878
- $(document).off("click.mu-nav-hover").on("click.mu-nav-hover", ".mu-nav-hover", function(e) {
879
- if ($(window).width() <= 767) {
880
- $(e.currentTarget).toggleClass("mn2c-open");
881
- }
882
- })
883
-
884
- var mr = function() {
885
- if ($(window).width() > 767)
886
- $(".mu-nav-hover").addClass("mu-nav-hover-hover").removeClass("mn2c-open");
887
- else
888
- $(".mu-nav-hover").removeClass("mu-nav-hover-hover");
889
- }
890
-
891
- mr();
892
- $(window).resize(function() {
893
- mr();
894
- });
895
- }
896
-
897
-
898
- /******
899
- * @描述:时间控件调用
900
- * @脚本:
901
- * <pre>
902
- * 1. datePicker($("#date"), "yyyy-MM-dd hh:ii:ss", 2);
903
- * 2. datePicker($("#date"), "hh:ii:ss", 1);
904
- * <input id="date" class="form-control" type="text" value="" readonly>
905
- * </pre>
906
- * @日期:2015年4月15日17:12:41
907
- * **/
908
- Base.prototype.datePicker = function($target, format, startView, minView, input) {
909
- $target.datetimepicker({
910
- language: "zh-CN",
911
- // format: format,
912
- weekStart: 0,
913
- todayBtn: true,
914
- autoclose: true,
915
- todayHighlight: true,
916
- startDate: "00:00",
917
- startView: startView,
918
- minView: minView,
919
- minuteStep: 1
920
- }).on("changeDate", function(e) {
921
- if (input)
922
- input.val(new Date(e.date.getTime()).format(format));
923
- });
924
- }
925
-
926
- /******
927
- * @描述:bootstrap分页插件
928
- * @脚本:
929
- * <pre>
930
- * pagination($("#target"), totalPages, function(event, page) { alert("Page: " + page); });
931
- * <ul id="target" class="pagination-sm"></ul>
932
- * </pre>
933
- * @日期:2015年4月15日17:12:41
934
- * **/
935
- Base.prototype.pagination = function(target, totalPages, fun) {
936
- target.twbsPagination({
937
- totalPages: totalPages,
938
- visiblePages: 7,
939
- first: "首页",
940
- prev: "上一页",
941
- next: "下一页",
942
- last: "尾页",
943
- onPageClick: function(event, page) {
944
- fun(event, page);
945
- }
946
- });
947
- }
948
-
949
- /* ========================================================================
950
- * @描述:常用JS工具类
951
- * @作者:林舒涛
952
- * ========================================================================
953
-
954
- 1. 设置数字对应描述,背景颜色或者字体颜色, eg:
955
- $("#a").setColor({...
956
- 2. 点击切换css active class样式 ,不要使用在包含子元素的标签, eg:
957
- $(".btn").setActive();
958
- 3. 页面加载遮罩效果,使交互按钮无法在点击, eg:.
959
- $("body").loading();
960
- 4. 多选框全选/全清, eg:
961
- $("#be-all-check").checkAll({...
962
- 5. 提交后台过程中让按钮不可用,防止用户多次点击, eg:
963
- $("#f").numStep({...
964
- 6. 数字特效递增特效, eg:
965
- $("#f").numStep({...
966
- 7. bootstrap黑色提示消息显示, eg:
967
- $("#g2").detail({...
968
- 8. 图片按钮滑入滑出切换按钮图片, eg:
969
- $("#more").imageBtn();
970
- 9. 弹框搜索面板, eg:
971
- $("#ipopover").popoverSearch({...
972
- 10. 列表查询分页封装插件, eg:
973
- $("#user-list").iList({...
974
- 11. 元素显示切换, eg:
975
- $(".iswitch").iSwitch({module: ".ce-switch2"});
976
- 12. 管理后台模式TAB页面, eg:
977
- $(".a").iTab();
978
- 13. 多选框反选, eg:
979
- $("#be-reverse-check").checkReverse({...
980
- 14. 数字增加减少,购物数量控制, eg:
981
- $(".fmc1").itemCount({num: 6});
982
- 15. 绘制点线动画, eg:
983
- $("#container").lineEffect({...
984
- 16. 底部按钮快速移动到顶部, eg:
985
- $(".ce-gotop").gotop({...
986
- 17. 背景滚动特效, eg:
987
- $(".ce-bg-ef").scrollBackground({speed: 6});
988
- 18. 鼠标上下左右划入监听实现对应动画, eg:
989
- $(".ce-thumb").hoverdir({...
990
- 19. niceSelect下拉框, eg:
991
- $(".ns-select").niceSelect();
992
- 20. 文字切换动画特效, eg:
993
- $("#ce-flash").flash({});
994
- 21. 局部loading动画, eg:
995
- new AeLoader().init();
996
- 22. 按钮动画
997
- $(".ce-btn-5").btnEf();
998
-
999
- * ======================================================================== */
1000
-
1001
-
1002
- /* ========================================================================
1003
- * 1. 设置数字对应描述,背景颜色或者字体颜色
1004
- * 2016年6月10日11:02:58
1005
- * ========================================================================
1006
-
1007
- window.tagArray = [1, 2, 3, 4, 5];
1008
- window.descArray = ["信息", "低危", "中危", "高危", "紧急"];
1009
- window.colorArray = ["color-8", "color-9", "color-10", "color-11", "color-13"];
1010
- window.bgcolorArray = ["color-bg-8", "color-bg-9", "color-bg-10", "color-bg-11", "color-bg-13"];
1011
-
1012
- <span id="a"></span>
1013
- $("#a").setColor({
1014
- tag: 2,
1015
- tagArray: window.tagArray,
1016
- descArray: window.descArray,
1017
- colorArray: window.colorArray,
1018
- bgcolorArray: window.bgcolorArray,
1019
- desc: "未知"
1020
- });
1021
- * ======================================================================== */
1022
- +function ($) {
1023
-
1024
- var SetColor = function (element, options) {
1025
- this.options = $.extend({}, this.DEFAULTS, options);
1026
- this.tag =
1027
- this.colorArray =
1028
- this.bgcolorArray =
1029
- this.tagArray =
1030
- this.descArray =
1031
- this.$element = $(element);
1032
-
1033
- this.init(this.$element, this.options);
1034
- };
1035
-
1036
- SetColor.DEFAULTS = {
1037
- desc: "---"
1038
- };
1039
-
1040
- SetColor.prototype.init = function (element, options) {
1041
- element.html(options.desc);
1042
-
1043
- $(options.tagArray).each(function(i, t) {
1044
- if (options.tag == t) {
1045
- if (options.colorArray)
1046
- element.addClass(options.colorArray[i]);
1047
- if (options.bgcolorArray)
1048
- element.addClass(options.bgcolorArray[i]);
1049
- element.html(options.descArray[i]);
1050
- }
1051
- });
1052
- };
1053
-
1054
- var old = $.fn.setColor;
1055
- $.fn.setColor = function (option) {
1056
- return this.each(function () {
1057
- var $this = $(this);
1058
-
1059
- var data = $this.data("be.setcolor");
1060
- var options = $.extend({}, SetColor.DEFAULTS, $this.data(), typeof option == "object" && option);
1061
-
1062
- if (!data)
1063
- $this.data("be.setcolor", (data = new SetColor(this, options)));
1064
- else
1065
- data["init"]();
1066
-
1067
- if (typeof option == 'string') data[option]();
1068
- });
1069
- };
1070
-
1071
- $.fn.setColor.Constructor = SetColor;
1072
- $.fn.setColor.noConflict = function () {
1073
- $.fn.setColor = old;
1074
- return this;
1075
- };
1076
- }(jQuery);
1077
-
1078
-
1079
- /* ========================================================================
1080
- * 2. 点击切换css active class样式 ,不要使用在包含子元素的标签
1081
- * @ 1:切换CLASS
1082
- * @ 2:切换CLASS,如果该元素已经active就清除,同时只能一个active
1083
- * @ 3:切换CLASS,如果该元素已经active就清除,可以多个active
1084
- * 2016年6月11日10:36:03
1085
- * ========================================================================
1086
-
1087
- <button type="button" class="btn btn-info">按钮1</button>
1088
- <button type="button" class="btn btn-info">按钮2</button>
1089
-
1090
- $(".btn").setActive({flag: 2});
1091
-
1092
- * ======================================================================== */
1093
- +function ($) {
1094
-
1095
- var SetActive = function (element, options) {
1096
- var options = $.extend({}, SetActive.DEFAULTS, options);
1097
- var $element = $(element);
1098
-
1099
- $element.on("click.setactive", options, this.init);
1100
- // $element.on("click.setactive", {element, options}, this.init);
1101
- };
1102
-
1103
- SetActive.DEFAULTS = {
1104
- flag: 1,
1105
- className: "active"
1106
- };
1107
-
1108
- SetActive.prototype.init = function (e) {
1109
- var $target = $(this);
1110
- var options = e.data;
1111
- if (options.flag == 1) {//仅仅激活当前项
1112
- $(options.selector).removeClass(options.className);
1113
- $target.addClass(options.className);
1114
- }
1115
-
1116
- // else if (e.data.flag == 2) {
1117
- // if ($this.hasClass(e.data.className)) {
1118
- // $(ct).removeClass(e.data.className);
1119
- // } else {
1120
- // $(ct).removeClass(e.data.className);
1121
- // $this.addClass(e.data.className);
1122
- // }
1123
- // } else if (e.data.flag == 3) {
1124
- // if ($this.hasClass(e.data.className)) {
1125
- // $this.removeClass(e.data.className);
1126
- // } else {
1127
- // $this.addClass(e.data.className);
1128
- // }
1129
- // }
1130
- };
1131
-
1132
- $.fn.setActive = function (option) {
1133
- var selector = this.selector;
1134
- return this.each(function (i, t) {
1135
- var $this = $(this);
1136
-
1137
- $this.attr("data-class", $this.attr("class"));
1138
- var data = $this.data("be.setactive");
1139
- options = $.extend({selector: selector}, SetActive.DEFAULTS, $this.data(), typeof option == "object" && option);
1140
-
1141
- if (!data)
1142
- $this.data("be.setactive", (data = new SetActive(this, options)));
1143
- });
1144
- };
1145
- }(jQuery);
1146
-
1147
-
1148
-
1149
- /* ========================================================================
1150
- * 3. 页面加载遮罩效果,使交互按钮无法在点击
1151
- * 2016年6月14日09:40:14
1152
- * ========================================================================
1153
-
1154
- <button id="c" type="button" class="btn btn-info">按钮2</button>
1155
-
1156
-
1157
- $("#c").click(function() {
1158
- $("body").loading();
1159
-
1160
- setTimeout(function() {
1161
- $("body").loading("complete");
1162
- }, 1000);
1163
- });
1164
-
1165
- * ======================================================================== */
1166
- +function ($) {
1167
-
1168
- var Loading = function (element, options) {
1169
- this.$element = $(element);
1170
- this.options = $.extend({}, this.DEFAULTS, options);
1171
-
1172
- this.toggle(options);
1173
- };
1174
-
1175
- Loading.DEFAULTS = {
1176
- template: "<div id='ce-loading' class='ce-loading invisible'></div>",
1177
- timeOut: -1
1178
- };
1179
-
1180
- Loading.prototype.loading = function () {
1181
- var e = this.$element;
1182
- if ($("#ce-loading").length == 0) {
1183
-
1184
- e.children().eq(0).before(this.options.template);
1185
-
1186
- var cl = new CanvasLoader("ce-loading");
1187
- cl.setColor("#0a0a0a");
1188
- cl.setShape("roundRect");
1189
- cl.setDensity(11);
1190
- cl.setRange(0.8);
1191
- cl.setSpeed(1);
1192
- cl.setFPS(10);
1193
- cl.show();
1194
- }
1195
- e.addClass("ok");
1196
-
1197
- $(".ce-loading").removeClass("invisible");
1198
- $("body > *:not(.ce-loading)").addClass("be-blur-2");
1199
- $("body").addClass("ce-loading-bg");
1200
-
1201
- if (options.timeOut != -1) {
1202
- setTimeout(function() {
1203
- $("body").loading("complete");
1204
- }, options.timeOut);
1205
- }
1206
- };
1207
- Loading.prototype.complete = function() {
1208
- this.$element.removeClass("ok");
1209
-
1210
- $(".ce-loading").addClass("invisible");
1211
- $("body > *:not(.ce-loading)").removeClass("be-blur-2");
1212
- $("body").removeClass("ce-loading-bg");
1213
- };
1214
-
1215
- Loading.prototype.toggle = function (options) {
1216
- this[this.$element.hasClass("ok") ? "complete" : "loading"](options);
1217
- };
1218
-
1219
- $.fn.loading = function (option) {
1220
- return this.each(function () {
1221
- var $this = $(this);
1222
- var data = $this.data("be.loading");
1223
-
1224
- var options = $.extend({}, Loading.DEFAULTS, $this.data(), typeof option == "object" && option);
1225
- if (!data)
1226
- $this.data("be.loading", (data = new Loading(this, options)));
1227
- else
1228
- data["toggle"]();
1229
-
1230
- if (typeof option == "string") data[option]();
1231
- });
1232
- };
1233
- }(jQuery);
1234
-
1235
-
1236
- /* ========================================================================
1237
- * 4. 多选框全选/全清
1238
- * 2016年6月25日23:19:54
1239
- * ========================================================================
1240
-
1241
- <input type="checkbox" id="be-all-check"/>全选
1242
- <input type="checkbox" class="be-check"/>选项一
1243
- <input type="checkbox" class="be-check"/>选项二
1244
-
1245
- $("#be-all-check").checkAll({
1246
- targets: ".be-check"
1247
- })
1248
-
1249
- * ======================================================================== */
1250
- +function ($) {
1251
-
1252
- var CheckAll = function (element, options) {
1253
- this.$element = $(element);
1254
- this.options = $.extend({}, this.DEFAULTS, options);
1255
-
1256
- this.$element.on("click", "", this.init);
1257
- };
1258
-
1259
- CheckAll.DEFAULTS = {
1260
- targets: ".be-check"
1261
- };
1262
-
1263
- CheckAll.prototype.init = function () {
1264
- var $this = $(this);
1265
- $this.data("be.checkall")["toggle"]();
1266
- };
1267
-
1268
- CheckAll.prototype.checked = function () {
1269
- var e = this.$element;
1270
- e.addClass("checked-all");
1271
- $(this.options.targets).prop("checked", true);
1272
- };
1273
-
1274
- CheckAll.prototype.clear = function() {
1275
- this.$element.removeClass("checked-all");
1276
- $(this.options.targets).prop("checked", false);
1277
- };
1278
-
1279
- CheckAll.prototype.toggle = function () {
1280
- this[this.$element.hasClass("checked-all") ? "clear" : "checked"]();
1281
- };
1282
-
1283
- CheckAll.prototype.destroy = function () {
1284
- $(this).removeData("be.checkall");
1285
- };
1286
-
1287
- $.fn.checkAll = function (option) {
1288
- return this.each(function () {
1289
- var $this = $(this);
1290
- if ($this.is(":checked"))
1291
- $this.addClass("checked-all");
1292
- else
1293
- $this.removeClass("checked-all");
1294
-
1295
- var data = $this.data("be.checkall");
1296
- var options = $.extend({}, CheckAll.DEFAULTS, $this.data(), typeof option == "object" && option);
1297
- if (!data) $this.data("be.checkall", (data = new CheckAll(this, options)));
1298
-
1299
- if (typeof option == "string") data[option]();
1300
- });
1301
- };
1302
- }(jQuery);
1303
-
1304
-
1305
- /* ========================================================================
1306
- * 5. 提交后台过程中让按钮不可用,防止用户多次点击
1307
- * 2016年6月26日10:08:11
1308
- * ========================================================================
1309
-
1310
- <button href="#" class="e1 btn btn-danger">按钮一</button>
1311
-
1312
- $(".e1").click(function() {
1313
- $(".e1").submitFlag();
1314
-
1315
- setTimeout(function() {
1316
- $(".e1").submitFlag();
1317
- }, 1000);
1318
- });
1319
-
1320
- 或者
1321
- <button href="#" class="e2 btn btn-danger">按钮二</button>
1322
-
1323
- $(".e2").click(function() {
1324
- $(".e2").submitFlag({
1325
- text: "数据请求中..",
1326
- useText: true
1327
- });
1328
-
1329
- setTimeout(function() {
1330
- $(".e2").submitFlag();
1331
- }, 1000);
1332
- });
1333
-
1334
-
1335
-
1336
- * ======================================================================== */
1337
- +function ($) {
1338
-
1339
- var SubmitFlag = function (element, options) {
1340
- this.$element = $(element);
1341
- this.options = $.extend({}, this.DEFAULTS, options);
1342
-
1343
- this.toggle();
1344
- };
1345
-
1346
- SubmitFlag.DEFAULTS = {
1347
- text: "处理中..",
1348
- useText: true
1349
- };
1350
-
1351
- SubmitFlag.prototype.request = function () {
1352
- var $this = this.$element;
1353
-
1354
- $this.addClass("submit-flag-request").data("text", $this.text()).attr("disabled", "disabled");
1355
- if (this.options.useText)
1356
- $this.text(this.options.text);
1357
- };
1358
-
1359
- SubmitFlag.prototype.complete = function() {
1360
- var $this = this.$element;
1361
- $this.removeClass("submit-flag-request").removeAttr("disabled");
1362
- if ($this.data("text") && this.options.useText)
1363
- $this.text($this.data("text"));
1364
- };
1365
-
1366
- SubmitFlag.prototype.toggle = function () {
1367
- this[this.$element.hasClass("submit-flag-request") ? "complete" : "request"]();
1368
- };
1369
-
1370
- $.fn.submitFlag = function (option) {
1371
- return this.each(function () {
1372
- var $this = $(this);
1373
- var data = $this.data("be.submitflag");
1374
-
1375
- var options = $.extend({}, SubmitFlag.DEFAULTS, $this.data(), typeof option == "object" && option);
1376
- if (!data)
1377
- $this.data("be.submitflag", (data = new SubmitFlag(this, options)));
1378
- else
1379
- data["toggle"]();
1380
-
1381
- if (typeof option == "string") data[option]();
1382
- });
1383
- };
1384
- }(jQuery);
1385
-
1386
-
1387
- /* ========================================================================
1388
- * 6. 数字特效递增特效
1389
- * 2016年6月26日11:13:16
1390
- * ========================================================================
1391
-
1392
- <p id="f">0</p>
1393
-
1394
- $("#f").numStep({
1395
- number: 100,
1396
- time: 1000
1397
- });
1398
-
1399
- setTimeout(function() {
1400
- $("#f").numStep({
1401
- number: 300,
1402
- time: 1000
1403
- });
1404
- }, 2000);
1405
-
1406
- * ======================================================================== */
1407
- +function ($) {
1408
-
1409
- var NumStep = function (element, options) {
1410
- this.options = $.extend({}, this.DEFAULTS, options);
1411
- this.$element = $(element);
1412
-
1413
- this.init(this.options);
1414
- };
1415
-
1416
- NumStep.DEFAULTS = {
1417
- number: 100,
1418
- time: 1500
1419
- };
1420
-
1421
- NumStep.prototype.init = function (options) {
1422
- var $element = this.$element;
1423
-
1424
- $element.animate({count: options.number}, {
1425
- duration: options.time,
1426
- step: function() {
1427
- if (this.count)
1428
- $element.text(Math.round(this.count));
1429
- }
1430
- });
1431
- };
1432
-
1433
- $.fn.numStep = function (option) {
1434
- var $this = $(this);
1435
- return this.each(function () {
1436
- var data = $this.data("be.numstep");
1437
- var options = $.extend({}, NumStep.DEFAULTS, $this.data(), typeof option == "object" && option);
1438
-
1439
- if (!data)
1440
- $this.data("be.numstep", (data = new NumStep(this, options)));
1441
- else
1442
- data["init"](options);
1443
- });
1444
- };
1445
- }(jQuery);
1446
-
1447
-
1448
- /* ========================================================================
1449
- * 7. bootstrap黑色提示消息显示
1450
- * 2016年6月26日13:24:55
1451
- * ========================================================================
1452
-
1453
- <button href="#" class="g1 btn btn-danger margin-left-20">按钮一</button>
1454
- <span id="g2"></span>
1455
-
1456
- $(".g1").detail({
1457
- placement: "bottom",
1458
- title: "该按钮/区域说明"
1459
- });
1460
-
1461
- $("#g2").detail({
1462
- title: "一定很长需要减少长度的文字说明",
1463
- length: 5
1464
- });
1465
-
1466
- * ======================================================================== */
1467
- +function ($) {
1468
-
1469
- var Detail = function (element, options) {
1470
- this.options = $.extend({}, this.DEFAULTS, options);
1471
-
1472
- this.init(element, this.options);
1473
- };
1474
-
1475
- Detail.DEFAULTS = {
1476
- isSelf: false,//是否使用原来文本作为提示显示内容
1477
- isReplace: true,//是否替换原来文本
1478
- placement: "top",
1479
- title: "...",
1480
- length : false
1481
- };
1482
-
1483
- Detail.prototype.init = function (element, options) {
1484
- var $element = $(element);
1485
-
1486
- if (options.isSelf)
1487
- options.title = $element.text();
1488
-
1489
- $element.tooltip({
1490
- placement: options.placement,
1491
- title: options.title
1492
- });
1493
-
1494
- if (options.isReplace) {
1495
- if (options.length && options.length < options.title.length)
1496
- $element.html(options.title.substring(0, options.length) + "...");
1497
- else
1498
- $element.html(options.title);
1499
- }
1500
- // if (options.isSelf)
1501
- // $element.html(options.title.substring(0, options.length) + "...");
1502
- };
1503
-
1504
- $.fn.detail = function (option) {
1505
- var $this = $(this);
1506
- return this.each(function () {
1507
- var data = $this.data("be.detail");
1508
- var options = $.extend({}, Detail.DEFAULTS, $this.data(), typeof option == "object" && option);
1509
-
1510
- if (!data)
1511
- $this.data("be.detail", (data = new Detail(this, options)));
1512
- else
1513
- data["init"](this, options);
1514
- });
1515
- };
1516
- }(jQuery);
1517
-
1518
-
1519
- /* ========================================================================
1520
- * 8. 图片按钮滑入滑出切换按钮图片
1521
- * 2016年6月26日10:08:11
1522
- * ========================================================================
1523
-
1524
- <img id="more" src="WEB/images/resource/more.png" class="img-responsive center-block"></img>
1525
- // more.png
1526
- // more-hover.png
1527
-
1528
- $("#more").imageBtn();
1529
-
1530
- * ======================================================================== */
1531
- +function ($) {
1532
-
1533
- var ImageBtn = function (element, options) {
1534
- this.$element = $(element);
1535
- this.options = $.extend({}, this.DEFAULTS, options);
1536
-
1537
- this.init(this.options);
1538
- };
1539
-
1540
- ImageBtn.DEFAULTS = {
1541
- suffix: "-hover"
1542
- };
1543
-
1544
- ImageBtn.prototype.init = function (options) {
1545
- var $element = this.$element;
1546
-
1547
- $element.hover(function() {
1548
- var t = $(this);
1549
- var src = $(this).attr("src");
1550
- var index = src.lastIndexOf(".");
1551
- $(this).fadeOut(200);
1552
- var srcHover = src.substr(0, index) + options.suffix + src.substr(index, src.length);
1553
- $(this).attr("src", srcHover);
1554
- $(this).fadeIn(200);
1555
- }, function() {
1556
- var srcHover = $(this).attr("src");
1557
- var src = srcHover.replace(options.suffix, "");
1558
- $(this).attr("src", src);
1559
- });
1560
- };
1561
-
1562
- $.fn.imageBtn = function (option) {
1563
- return this.each(function () {
1564
- var $this = $(this);
1565
- var data = $this.data("be.imagebtn");
1566
-
1567
- var options = $.extend({}, ImageBtn.DEFAULTS, $this.data(), typeof option == "object" && option);
1568
- if (!data)
1569
- $this.data("be.imagebtn", (data = new ImageBtn(this, options)));
1570
- else
1571
- data["init"]();
1572
- });
1573
- };
1574
- }(jQuery);
1575
-
1576
-
1577
-
1578
- /* ========================================================================
1579
- * 9. 弹框搜索面板
1580
- * 2016年5月22日19:01:48
1581
- * ========================================================================
1582
-
1583
- <a id="ipopover" tabindex="0" class="btn btn-sm btn-danger">弹出搜索框</a>
1584
- <div id="load"></div>
1585
-
1586
- $("#load").load("WEB/page/template.html", function() {
1587
- $("#ipopover").popoverSearch({
1588
- items: [
1589
- {name: "name", desc: "姓名", type: "text", value: ""},
1590
- {name: "tiem", desc: "开始时间", type: "date", value: ""},
1591
- {name: "select", desc: "选项", type: "select",
1592
- options: [
1593
- {name: "", value: "所有", selected: false},//如果默认查询所有,name设置为""
1594
- {name: "o1", value: "选项1", selected: false},
1595
- {name: "o2", value: "选项2", selected: true}
1596
- ]}
1597
- ],
1598
- onSerach: function(e) {
1599
- $("#ipopover").click();
1600
- debug(e.param);//参数及参数值对象,{name: "arisu", tiem: "2016-07-16 17:02:59", select: "o2"}
1601
- }
1602
- });
1603
- });
1604
- * ======================================================================== */
1605
- +function ($) {
1606
-
1607
- var PopoverSearch = function (element, options) {
1608
- this.options = $.extend({}, this.DEFAULTS, options);
1609
-
1610
- this.init(element, this.options);
1611
- };
1612
-
1613
- PopoverSearch.DEFAULTS = {
1614
- html: true,
1615
- title: "详细搜索",
1616
- trigger: "click",
1617
- toggle: "popover",
1618
- placement: "bottom",
1619
- onSerach: false,
1620
- items: [],
1621
- startView: 2,
1622
- minView: 2,
1623
- format: "yyyy-MM-dd hh:mm:ss",
1624
- bsVs: 5
1625
- };
1626
-
1627
- PopoverSearch.prototype.init = function (element, options) {
1628
- var $element = $(element);
1629
- var target = this;
1630
-
1631
- var tplEl = $("#tp-popover");
1632
- var template = Handlebars.compile(tplEl.html())({});
1633
-
1634
- if (options.bsVs == 3) {
1635
- $element.popover({
1636
- html: options.html,
1637
- title: options.title,
1638
- trigger: options.trigger,
1639
- toggle: options.toggle,
1640
- placement: options.placement,
1641
- template : template,
1642
- param: null,
1643
- });
1644
-
1645
- $element.on("shown.bs.popover", function () {
1646
- target.search(options, target);
1647
- target.cancel(element);
1648
- target.addItem(element, options);
1649
- target.clear();
1650
- });
1651
-
1652
- $element.on("hide.bs.popover", function () {
1653
- $(".popover-content-item").each(function(i, t) {
1654
- var name = $(".popover-form-item", this).attr("name");
1655
- if (options.items[i].type == "select") {
1656
- var val = $(".popover-form-item", this).find("option:selected").attr("value");
1657
- $(options.items[i].options).each(function(i, t) {
1658
- if (this.name == val) {
1659
- this.selected = true;
1660
- } else {
1661
- this.selected = false;
1662
- }
1663
- });
1664
- } else {
1665
- var val = $(".popover-form-item", this).val();
1666
- options.items[i].value = val;
1667
- }
1668
-
1669
- });
1670
- });
1671
- } else {
1672
- var popr = new bootstrap.Popover($element, {
1673
- html: options.html,
1674
- title: options.title,
1675
- trigger: options.trigger,
1676
- toggle: options.toggle,
1677
- placement: options.placement,
1678
- template : template,
1679
- param: null
1680
- });
1681
- $element.on("shown.bs.popover", function (){
1682
- target.search(options, target);
1683
- target.close(popr);
1684
- target.addItem(element, options);
1685
- target.clear();
1686
- });
1687
- $element.on("hide.bs.popover", function () {
1688
- $(".popover-content-item").each(function(i, t) {
1689
- var name = $(".popover-form-item", this).attr("name");
1690
- if (options.items[i].type == "select") {
1691
- var val = $(".popover-form-item", this).find("option:selected").attr("value");
1692
- $(options.items[i].options).each(function(i, t) {
1693
- if (this.name == val) {
1694
- this.selected = true;
1695
- } else {
1696
- this.selected = false;
1697
- }
1698
- });
1699
- } else {
1700
- var val = $(".popover-form-item", this).val();
1701
- options.items[i].value = val;
1702
- }
1703
- });
1704
- });
1705
- }
1706
- };
1707
-
1708
- //获取参数
1709
- PopoverSearch.prototype.getParam = function () {
1710
- var params = new Object();
1711
- $(".popover-content-item").each(function(i, t) {
1712
- var name = $(".popover-form-item", this).attr("name");
1713
- var val = $(".popover-form-item", this).val();
1714
- if (val)
1715
- params[name] = val;
1716
- });
1717
- return params;
1718
- };
1719
-
1720
- //搜索
1721
- PopoverSearch.prototype.search = function (options, target) {
1722
- $(".ce-popover-ok", ".ce-popover").off("click").on("click", "", function() {
1723
- if (options.onSerach) {
1724
- var e = {param: target.getParam()}
1725
- options.onSerach(e);
1726
- }
1727
- });
1728
- };
1729
-
1730
- //关闭
1731
- PopoverSearch.prototype.cancel = function (element) {
1732
- var $element = $(element);
1733
- $(".ce-popover-cancel", ".ce-popover").off("click").on("click", "", function() {
1734
- $element.click();
1735
- });
1736
- };
1737
-
1738
- //关闭
1739
- PopoverSearch.prototype.close = function (popr) {
1740
- $(".ce-popover-cancel", ".ce-popover").off("click").on("click", "", function() {
1741
- popr.hide();
1742
- });
1743
- };
1744
-
1745
- //清空条件
1746
- PopoverSearch.prototype.clear = function (element) {
1747
- $(".ce-popover-clear", ".ce-popover").off("click").on("click", "", function() {
1748
- $("input", ".popover-content-item").val("");
1749
- $("select option:first", ".popover-content-item").attr("selected", true);
1750
- });
1751
- };
1752
-
1753
- //删除搜索项
1754
- PopoverSearch.prototype.remove = function () {
1755
- $(".ce-popover-remove", ".ce-popover").off("click").on("click", "", function() {
1756
- $(this).parents(".popover-content-item.row").html("").removeClass("popover-content-item row");
1757
- $(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last .ce-popover-add").css("display", "inline-block");
1758
- });
1759
- };
1760
-
1761
- //添加搜索项
1762
- PopoverSearch.prototype.add = function (element) {
1763
- var target = this;
1764
- $(".ce-popover-add", ".ce-popover").off("caddItemlick").on("click", "", function() {
1765
- var tplEl = $("#tp-popover-option");
1766
- var html = Handlebars.compile(tplEl.html())({});
1767
- $(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last").after(html);
1768
- $(".ce-popover > .popover-content .popover-content-items > .popover-content-item .ce-popover-add").css("display", "none");
1769
- $(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last .ce-popover-add").css("display", "inline-block");
1770
-
1771
- target.add(element);
1772
- target.remove();
1773
- });
1774
- };
1775
-
1776
- //添加搜索项
1777
- PopoverSearch.prototype.addItem = function (element, options) {
1778
- var tplEl = $("#tp-popover-items");
1779
- var html = Handlebars.compile(tplEl.html())({
1780
- items: options.items
1781
- });
1782
- $(".ce-popover > .popover-content .popover-content-items").html(html);
1783
-
1784
- $(options.items).each(function(i, t) {
1785
- //需要使用到日期控件
1786
- if (t.type == "date") {
1787
- var $input = $("input[name='" + t.name + "']", ".ce-popover");
1788
- $(".ce-popover-date[date-flag='" + t.name + "']", ".ce-popover").datetimepicker({
1789
- language: "zh-CN",
1790
- format: options.format,
1791
- weekStart: 0,
1792
- todayBtn: true,
1793
- autoclose: true,
1794
- todayHighlight: true,
1795
- startDate: "00:00",
1796
- startView: options.startView,
1797
- minView: options.minView,
1798
- minuteStep: 1
1799
- }).on("changeDate", function(e) {
1800
- if ($input)
1801
- $input.val(new Date(e.date.getTime()).format(options.format));
1802
- });
1803
- } else if (t.type == "time") {
1804
- var $input = $("input[name='" + t.name + "']", ".ce-popover");
1805
- $(".ce-popover-date[date-flag='" + t.name + "']", ".ce-popover").datetimepicker({
1806
- language: "zh-CN",
1807
- format: "hh:ii:00",
1808
- weekStart: 0,
1809
- //todayBtn: true,
1810
- autoclose: true,
1811
- todayHighlight: true,
1812
- startDate: "00:00",
1813
- startView: 1,
1814
- minView: 0,
1815
- minuteStep: 1
1816
- }).on("changeDate", function(e) {
1817
- if ($input)
1818
- $input.val(new Date(e.date.getTime()).format("hh:mm:00"));
1819
- });
1820
-
1821
- }
1822
- });
1823
- };
1824
-
1825
- $.fn.popoverSearch = function (option) {
1826
- var $this = $(this);
1827
- return this.each(function () {
1828
- var data = $this.data("be.popover.search");
1829
- var options = $.extend({}, PopoverSearch.DEFAULTS, $this.data(), typeof option == "object" && option);
1830
-
1831
- if (!data) $this.data("be.popover.search", (data = new PopoverSearch(this, options)));
1832
- if (typeof option == 'string') return data[option]();
1833
- });
1834
- };
1835
- }(jQuery);
1836
-
1837
-
1838
- /* ========================================================================
1839
- * 10. 列表查询分页封装插件
1840
- * 2016年7月27日15:02:29
1841
- * ========================================================================
1842
-
1843
- $("#user-list").iList({
1844
- url: sp + "userManage/findUser.action",
1845
- param: {name: "arisu"},
1846
-
1847
- // 支持跨越
1848
- // url: server + "springmvc/news/findNewsJsonp.action",
1849
- // jsonp: "callback",
1850
- // jsonpCallback:"showData",
1851
- // dataType: "jsonp",
1852
-
1853
- onSuccess: function(data) {
1854
-
1855
- var tplEl = $("#tp-data-table-1");
1856
- var html = Handlebars.compile(tplEl.html())({
1857
- items: data.users
1858
- });
1859
- $(".be-list-data", "#user-list").html(html);
1860
-
1861
- }
1862
- });
1863
-
1864
- * ======================================================================== */
1865
- +function ($) {
1866
-
1867
- var IList = function (element, options) {
1868
- this.$element = $(element);
1869
- this.options = $.extend({}, this.DEFAULTS, options);
1870
-
1871
- this.init(element, this.options);
1872
- };
1873
-
1874
-
1875
- IList.DEFAULTS = {
1876
- rp: "10",
1877
- visiblePages: 7,
1878
- sortname: "id",
1879
- sortorder: "desc",
1880
- method: "post",
1881
- dataType: "json",
1882
- async: true,
1883
- jsonp: null,
1884
- jsonpCallback: null,
1885
- param: {},
1886
- url: "",
1887
- loadColor: "#0a0a0a",//必须是16进制,不能缩写
1888
- lang: "cn",
1889
- headerMap: null,
1890
- onSuccess: false,
1891
- onError: false
1892
- };
1893
-
1894
- IList.prototype.init = function (element, options) {
1895
- $element = $(element);
1896
- var target = this;
1897
- $element.data("be.ilist.flag", true);
1898
-
1899
- var tplEl = $("#tp-list");
1900
- var html = Handlebars.compile(tplEl.html())({});
1901
- $element.html(html);
1902
-
1903
- // 不兼容jquery3.6
1904
- $(".be-list-loading-canvas", $element).attr("id", $element.attr("id") + "-load");
1905
- var cl = new CanvasLoader($element.attr("id") + "-load");
1906
- cl.setColor(options.loadColor);
1907
- cl.setShape("roundRect");
1908
- cl.setDensity(11);
1909
- cl.setRange(0.8);
1910
- cl.setSpeed(1);
1911
- cl.setFPS(10);
1912
- cl.show();
1913
-
1914
- var param = $.extend({}, {page: 1, rp: options.rp, sortname: options.sortname, sortorder: options.sortorder}, options.param);
1915
- options.isPage = false;
1916
- target.getData(element, options, param);
1917
- };
1918
-
1919
- IList.prototype.getData = function (element, options, param) {
1920
- var target = this;
1921
- if ($(".ilist-check-all[data-flag='1']", element).is(":checked"))
1922
- $(".ilist-check-all[data-flag='1']", element).click();
1923
- $(".be-list-loading", element).css("display", "block");
1924
- if (options.isPage)
1925
- $(".be-list-data-body", element).html("");
1926
- else
1927
- $(".be-list-data", element).css("display", "none");
1928
-
1929
- $.ajax({
1930
- type: options.method,
1931
- url: options.url,
1932
- beforeSend: function(request) {
1933
- for (var key in options.headerMap) {
1934
- if (options.headerMap.hasOwnProperty(key)) {
1935
- request.setRequestHeader(key, options.headerMap[key]);
1936
- }
1937
- }
1938
- },
1939
- data: param,
1940
- cache: false,
1941
- jsonp: options.jsonp,
1942
- jsonpCallback: options.jsonp,
1943
- async: options.async,
1944
- dataType: options.dataType,
1945
- success: function (data) {
1946
- $(".be-list-loading", element).css("display", "none");
1947
-
1948
- data.isPage = options.isPage;
1949
- if (options.isPage)
1950
- $(".be-list-data-body", element).css("display", "table-row-group");
1951
- else
1952
- $(".be-list-data", element).css("display", "block");
1953
-
1954
- if (options.onSuccess)
1955
- options.onSuccess(data);
1956
-
1957
- if (data.total) {
1958
- var pageType = $(".be-list-page").data("type");
1959
- if (pageType == 2)
1960
- target.preNextPage(element, options, param, data.total);//上下两页页翻页
1961
- else
1962
- target.page(element, options, param, data.total);//多页翻页
1963
-
1964
- if (param.page == 1)
1965
- $(".be-list-page .previous").addClass("disabled");
1966
- if (param.page == Math.ceil(data.total / options.rp))
1967
- $(".be-list-page .next").addClass("disabled");
1968
-
1969
- //全选/全清
1970
- $(".ilist-check-all[data-flag='1']", element).checkAll({targets: ".ilist-check"});
1971
-
1972
- //选择单列/取消选择单列
1973
- $(".ilist-check", element).unbind("change");
1974
- $(".ilist-check", element).change(function() {
1975
- var isChecked = $(this).is(":checked");
1976
- if (isChecked)
1977
- $(this).parents("tr").addClass("active");
1978
- else
1979
- $(this).parents("tr").removeClass("active");
1980
- });
1981
-
1982
- //全选列/全清列
1983
- $(".ilist-check-all[data-flag='1']", element).unbind("change");
1984
- $(".ilist-check-all[data-flag='1']", element).change(function() {
1985
- var isChecked = $(this).is(":checked");
1986
- if (isChecked)
1987
- $(".ilist-check").addClass("active").change();
1988
- else
1989
- $(".ilist-check").removeClass("active").change();
1990
- });
1991
-
1992
- //点击列选择单列/点击列取消选择单列
1993
- $("table > tbody tr", element).unbind("click");
1994
- $("table > tbody tr", element).click(function(e) {
1995
- var target = $(e.target);
1996
- if (!(target.is("input") || target.is("i") || target.is("a"))) {
1997
- $(".ilist-check", this).click();
1998
- }
1999
- })
2000
-
2001
- //排序
2002
- $("table > thead tr td", element).unbind("click");
2003
- $("table > thead tr td", element).click(function(e) {
2004
- param.sortname = $(this).data("sortname");
2005
-
2006
- if (!$(this).hasClass("is-check") && param.sortname) {
2007
- var sortorder = $(this).attr("data-sort-order");
2008
-
2009
- $("table > thead tr td", element).removeAttr("data-sort-order");
2010
-
2011
- if (sortorder) {
2012
- if (sortorder == "desc") {
2013
- $(this).attr("data-sort-order", "asc");
2014
- sortorder = "asc";
2015
- } else {
2016
- $(this).attr("data-sort-order", "desc");
2017
- sortorder = "desc";
2018
- }
2019
- param.sortorder = sortorder;
2020
- } else {
2021
- $(this).attr("data-sort-order", "desc");
2022
- param.sortorder = "desc";
2023
- }
2024
-
2025
- $element.data("be.ilist.flag", true);
2026
- options.isPage = true;
2027
- param.page = "1";
2028
- target.getData(element, options, param);
2029
- } else {
2030
- $(this).css("cursor", "auto ! important");
2031
- }
2032
-
2033
- });
2034
- $(".be-list-page", element).css("visibility", "visible");
2035
- } else {
2036
- $(".be-list-nofound", element).css("display", "block");
2037
- }
2038
- },
2039
- error: function (XMLHttpRequest, textStatus, errorThrown) {
2040
- try {
2041
- if (options.onError) options.onError(XMLHttpRequest, textStatus, errorThrown);
2042
- } catch (e) {}
2043
- }
2044
- });
2045
- }
2046
-
2047
-
2048
- /** 分页查询 **/
2049
- IList.prototype.page = function (element, options, param, total) {
2050
- var rp = options.rp;
2051
- if (options.rp == 0)
2052
- rp = total;
2053
- var totalPages = Math.ceil(total / rp);
2054
- var target = this;
2055
- var $element = $(element);
2056
-
2057
- var end = ((param.page - 1) * rp + rp);
2058
- if (end > total)
2059
- end = total;
2060
-
2061
- var html = "显示" + ((param.page - 1) * rp + 1) + "至 " + end + "条,共有" + total + "条 ";
2062
- var first = "首页";
2063
- var prev = "上一页";
2064
- var next = "下一页";
2065
- var last = "尾页";
2066
- if (options.lang == "en") {
2067
- html = "display data from " + ((param.page - 1) * rp + 1) + " to " + end + ",there are " + total + " data in total";
2068
- first = "first";
2069
- prev = "prev";
2070
- next = "next";
2071
- last = "last";
2072
- }
2073
-
2074
-
2075
- if ($element.data("be.ilist.flag")) {
2076
- $(".pagination", element).parent().html("<span>" + html + "</span><ul class='pagination pagination-sm'></ul>");
2077
- $(".pagination", element).twbsPagination({
2078
- totalPages: totalPages,
2079
- visiblePages: options.visiblePages,
2080
- first: first,
2081
- prev: prev,
2082
- next: next,
2083
- last: last,
2084
- initiateStartPageClick: false,
2085
- onPageClick: function(event, page) {
2086
- param.page = page;
2087
- var end = ((param.page - 1) * rp + rp);
2088
- if (end > total)
2089
- end = total;
2090
- html = "显示 " + ((param.page - 1) * rp + 1) + " 至 " + end + " 条,共有 " + total + " 条";
2091
- if (options.lang == "en")
2092
- html = "display data from " + ((param.page - 1) * rp + 1) + " to " + end + ",there are " + total + " data in total";
2093
-
2094
- $(".be-list-page > span", element).html(html);
2095
-
2096
- options.isPage = true;
2097
-
2098
- target.getData(element, options, param);
2099
- }
2100
- });
2101
- }
2102
- $element.data("be.ilist.flag", false);
2103
- }
2104
-
2105
- /** 上下两页分页查询 **/
2106
- IList.prototype.preNextPage = function (element, options, param, total) {
2107
- var rp = options.rp;
2108
- if (options.rp == 0)
2109
- rp = total;
2110
- var totalPages = Math.ceil(total / rp);
2111
- var target = this;
2112
- var $element = $(element);
2113
-
2114
- var end = ((param.page - 1) * rp + rp);
2115
- if (end > total)
2116
- end = total;
2117
-
2118
-
2119
- $(document).off("click.clpp").on("click.clpp", ".be-list-page .previous:not(.disabled)", function(e) {
2120
- param.page = param.page - 1;
2121
- $(".be-list-page .next").removeClass("disabled");
2122
-
2123
- if (param.page == 1) {
2124
- $(this).addClass("disabled");
2125
- }
2126
-
2127
- options.isPage = true;
2128
- target.getData(element, options, param);
2129
- });
2130
- $(document).off("click.clpn").on("click.clpn", ".be-list-page .next:not(.disabled)", function(e) {
2131
- param.page = param.page + 1;
2132
- $(".be-list-page .previous").removeClass("disabled");
2133
-
2134
- if (param.page == totalPages) {
2135
- $(this).addClass("disabled");
2136
- }
2137
- options.isPage = true;
2138
- target.getData(element, options, param);
2139
- });
2140
-
2141
- $element.data("be.ilist.flag", false);
2142
- }
2143
-
2144
- /** 参数追加搜索 **/
2145
- $.fn.iListReload = function (param) {
2146
- var $this = $(this);
2147
- var data = $this.data("be.ilist");
2148
-
2149
- for (var pa in param) {
2150
- if (typeof param[pa] == "string" && param[pa].trim() == "") {
2151
- data.options.param[pa] = undefined;
2152
- param[pa] = undefined;
2153
- }
2154
- }
2155
-
2156
- // var p = $.extend({}, data.options.param, param);
2157
- // data.options.param = p;
2158
-
2159
- data.options.param = param;
2160
- data["init"](this, data.options);
2161
- // $this.data("be.ilist", (data = new IList(this, data.options)));
2162
- };
2163
-
2164
- $.fn.iList = function (option) {
2165
- return this.each(function () {
2166
- var $this = $(this);
2167
- var data = $this.data("be.ilist");
2168
-
2169
- var options = $.extend({}, IList.DEFAULTS, $this.data(), typeof option == "object" && option);
2170
- if (!data)
2171
- $this.data("be.ilist", (data = new IList(this, options)));
2172
- else
2173
- data["init"](this, options);
2174
- });
2175
- };
2176
- }(jQuery);
2177
-
2178
-
2179
- /* ========================================================================
2180
- * 11. 元素显示切换
2181
- * 2017年1月27日19:29:08
2182
- * ========================================================================
2183
-
2184
- <div class="ce-switch ce-switch-1 current">11111</div>
2185
- <div class="ce-switch ce-switch-1 current">22222</div>
2186
- <div class="ce-switch ce-switch-1 ce-switch-2 current">3333</div>
2187
- <div class="ce-switch ce-switch-2">44444</div>
2188
-
2189
- <button class="iswitch" data-show="ce-switch-1">a</button>
2190
- <button class="iswitch" data-show="ce-switch-2">b</button>
2191
-
2192
-
2193
-
2194
- <select id="iswitch-select">
2195
- <option data-show="ce-switch-1">a</option>
2196
- <option data-show="ce-switch-2">b</option>
2197
- </select>
2198
-
2199
- $(".iswitch").iSwitch({module: ".ce-switch2"});
2200
-
2201
- $("#iswitch-select").iSwitch();
2202
-
2203
- * ======================================================================== */
2204
- +function ($) {
2205
-
2206
- var ISwitch = function (element, options) {
2207
- this.$element = $(element);
2208
- this.options = $.extend({}, this.DEFAULTS, options);
2209
-
2210
- this.init(this.options);
2211
- };
2212
-
2213
- ISwitch.DEFAULTS = {
2214
- module: ".ce-switch"
2215
- };
2216
-
2217
- ISwitch.prototype.init = function (options) {
2218
- var $element = this.$element;
2219
-
2220
-
2221
- if ($element.is("select")) {
2222
- $element.change(function() {
2223
- $(options.module).removeClass("current");
2224
-
2225
- var className = $element.find("option:selected").data("show");
2226
- $("." + className).addClass("current").removeClass("hide");;
2227
- });
2228
- } else if($element.is("a") || $element.is("button")) {
2229
- $element.click(function() {
2230
- var className = $(this).data("show");
2231
- $(options.module).removeClass("current").addClass("hide");
2232
- $("." + className).addClass("current").removeClass("hide");
2233
- });
2234
- }
2235
-
2236
- };
2237
-
2238
- $.fn.iSwitch = function (option) {
2239
- return this.each(function () {
2240
- var $this = $(this);
2241
- var data = $this.data("be.iswitch");
2242
-
2243
- var options = $.extend({}, ISwitch.DEFAULTS, $this.data(), typeof option == "object" && option);
2244
- if (!data)
2245
- $this.data("be.iswitch", (data = new ISwitch(this, options)));
2246
- else
2247
- data["init"]();
2248
- });
2249
- };
2250
- }(jQuery);
2251
-
2252
-
2253
- /* ========================================================================
2254
- * 12. 管理后台模式TAB页面
2255
- * 2017年2月8日19:46:03
2256
- * ========================================================================
2257
-
2258
- $(".a").iTab();
2259
-
2260
- <a href="#" class="a" data-page="test1.jsp">aaa</a>
2261
- <a href="#" class="a" data-page="test2.jsp">aaa</a>
2262
-
2263
- <div id="be-main" class="tab-panel ce-tab-panel">
2264
- <ul class="nav nav-tabs" >
2265
- <li class="active">
2266
- <a href="#be-main-p1" data-toggle="tab">Home
2267
- </a>
2268
- <button class="close">X</button>
2269
- </li>
2270
- <li><a href="#be-main-p2" data-toggle="tab">Profile</a><button class="close">X</button></li>
2271
- </ul>
2272
-
2273
- <div class="tab-content">
2274
- <div class="tab-pane fade in active" id="be-main-p1">a</div>
2275
- <div class="tab-pane fade" id="be-main-p2">b</div>
2276
- </div>
2277
- </div>
2278
- * ======================================================================== */
2279
- +function ($) {
2280
-
2281
- var ITab = function (element, options) {
2282
- this.$element = $(element);
2283
- this.options = $.extend({}, this.DEFAULTS, options);
2284
-
2285
- this.init(this.options);
2286
- };
2287
-
2288
- ITab.DEFAULTS = {
2289
- module: "#itab-main",
2290
- isReload: false
2291
- };
2292
-
2293
- ITab.prototype.init = function (options) {
2294
- var $element = this.$element;
2295
- this.remove(options);
2296
- };
2297
-
2298
- ITab.prototype.add = function (element) {
2299
- var $element = $(element);
2300
- var page = $element.data("page");
2301
- var isReload = $element.data("reload");
2302
- var i = page.replaceAll("\\.", "-").replaceAll("\\/", "-");
2303
- var isOpen = $("#be-main-p" + (i + 1)).size() >= 1;
2304
-
2305
- var module = ITab.DEFAULTS.module;
2306
- if (isOpen) {
2307
- $(".nav-tabs li > a[data-page='" + page + "']", module).click();
2308
-
2309
- if (isReload) {
2310
- var data = new Object();
2311
- var t = $element.data();
2312
- for (var p in t) {
2313
- var isBs = p.indexOf(".");
2314
- if (isBs <= 0)
2315
- data[p] = t[p];
2316
- }
2317
- $("#be-main-p" + (i + 1)).load(page, data, function() {});
2318
- }
2319
- } else {
2320
-
2321
- var len = $(".nav-tabs li", module).size();
2322
- var name = $element.data("name");
2323
- if (!name)
2324
- name = $element.text();
2325
-
2326
- if (len) {
2327
- $(".nav-tabs li:last", module).after("<li><a href=\"#be-main-p" + (i + 1) + "\" data-toggle=\"tab\">" + name + "</a><button class=\"close\">X</button></li>");
2328
- $(".tab-content .tab-pane:last", module).after("<div class=\"tab-pane fade\" id=\"be-main-p" + (i + 1) + "\"></div>");
2329
- $(".nav-tabs li:last > a", module).click();
2330
- } else {
2331
- $(".nav-tabs", module).html("<li><a href=\"#be-main-p" + (i + 1) + "\" data-toggle=\"tab\">" + name + "</a><button class=\"close\">X</button></li>");
2332
- $(".tab-content", module).html("<div class=\"tab-pane fade\" id=\"be-main-p" + (i + 1) + "\"></div>");
2333
- $(".nav-tabs li:last > a", module).click();
2334
- }
2335
-
2336
- $(".nav-tabs li:last > a", module).attr("data-page", page);
2337
-
2338
- var data = new Object();
2339
- var t = $element.data();
2340
- for (var p in t) {
2341
- var isBs = p.indexOf(".");
2342
- if (isBs <= 0)
2343
- data[p] = t[p];
2344
- }
2345
-
2346
- $("#be-main-p" + (i + 1)).load(page, data, function() {});
2347
- }
2348
- };
2349
-
2350
- ITab.prototype.remove = function (options) {
2351
- var t = this.$element;
2352
- $(options.module).on("click", ".close", function() {
2353
- var html = $(".nav-tabs", options.module).html();
2354
-
2355
- var target = $(this).parents("li");
2356
- var isActive = target.hasClass("active");
2357
-
2358
- if (isActive) {
2359
- $(".nav-tabs", options.module).html(html.replace("<li class=\"active\">" + target.html() + "</li>", ""));
2360
- var href = $("a", target).attr("href");
2361
- $(href).attr("id", "").html("");
2362
- $(".nav-tabs li:last > a", options.module).click();
2363
- } else {
2364
- var href = $("a", target).attr("href");
2365
- $(href).attr("id", "").html("");
2366
- $(".nav-tabs", options.module).html(html.replace("<li>" + target.html() + "</li>", "").replace("<li class=\"\">" + target.html() + "</li>", ""));
2367
- }
2368
- })
2369
- };
2370
-
2371
- $.fn.iTab = function (option) {
2372
- return this.each(function () {
2373
- var $this = $(this);
2374
- var data = $this.data("be.itab");
2375
-
2376
- var options = $.extend({}, ITab.DEFAULTS, $this.data(), typeof option == "object" && option);
2377
- if (!data)
2378
- $this.data("be.itab", (data = new ITab(this, options)));
2379
- else
2380
- data["init"]();
2381
- });
2382
- };
2383
-
2384
- $(document).on("click", "[data-toggle='itab']", function(e) {
2385
- ITab.prototype.add(this);
2386
- });
2387
- }(jQuery);
2388
-
2389
-
2390
- /* ========================================================================
2391
- * 13. 多选框反选
2392
- * 2017年6月19日10:53:26
2393
- * ========================================================================
2394
-
2395
- $("#be-reverse-check").checkReverse({
2396
- targets: ".be-check"
2397
- })
2398
-
2399
- <a href="#" id="be-reverse-check"/>反选</a>
2400
- <input type="checkbox" class="be-check" checked="checked"/>选项一
2401
- <input type="checkbox" class="be-check"/>选项二
2402
-
2403
- * ======================================================================== */
2404
- +function ($) {
2405
-
2406
- var CheckReverse = function (element, options) {
2407
- this.$element = $(element);
2408
- this.options = $.extend({}, this.DEFAULTS, options);
2409
-
2410
- this.$element.on("click", this.options, this.init);
2411
- };
2412
-
2413
- CheckReverse.DEFAULTS = {
2414
- targets: ".be-check",
2415
- checkedFlag: "checked-now",
2416
- uncheckedFlag: "unchecked-now"
2417
- };
2418
-
2419
- CheckReverse.prototype.init = function (e) {
2420
- var options = e.data;
2421
- $(options.targets).addClass(options.uncheckedFlag);
2422
- $(options.targets + ":checked").removeClass(options.uncheckedFlag).addClass(options.checkedFlag);
2423
-
2424
- var data = e.data;
2425
- var a = $("." + data.checkedFlag);
2426
- var b = $("." + data.uncheckedFlag);
2427
- a.removeClass(data.checkedFlag).addClass(data.uncheckedFlag).prop("checked", false);
2428
- b.addClass(data.checkedFlag).removeClass(data.uncheckedFlag).prop("checked", true);
2429
- };
2430
-
2431
- CheckReverse.prototype.destroy = function () {
2432
- $(this).removeData("be.checkreverse");
2433
- };
2434
-
2435
- $.fn.checkReverse = function (option) {
2436
- return this.each(function () {
2437
- var $this = $(this);
2438
- var data = $this.data("be.checkreverse");
2439
- var options = $.extend({}, CheckReverse.DEFAULTS, $this.data(), typeof option == "object" && option);
2440
-
2441
- if (!data) $this.data("be.checkreverse", (data = new CheckReverse(this, options)));
2442
- if (typeof option == "string") data[option]();
2443
- });
2444
- };
2445
- }(jQuery);
2446
-
2447
-
2448
- /* ========================================================================
2449
- * 14. 数字增加减少,购物数量控制
2450
- * 2018年1月20日22:14:46
2451
- * ========================================================================
2452
-
2453
- $(".fmc1").itemCount({num: 6});
2454
-
2455
- <div class="fm-count fmc1">
2456
- <input class="form-control fmc-result" type="text" value="1" readonly="">
2457
- <div class="fmc-btns">
2458
- <i class="fmc-plus fa fa-angle-up"></i>
2459
- <i class="fmc-minus fa fa-angle-down"></i>
2460
- </div>
2461
- </div>
2462
-
2463
- * ======================================================================== */
2464
- +function ($) {
2465
-
2466
- var ItemCount = function (element, options) {
2467
- this.$element = $(element);
2468
- this.options = $.extend({}, this.DEFAULTS, options);
2469
-
2470
- this.init(this);
2471
- };
2472
-
2473
- ItemCount.DEFAULTS = {
2474
- num: 1
2475
- };
2476
-
2477
- ItemCount.prototype.init = function (e) {
2478
- var $this = $(e.$element),
2479
- options = e.options,
2480
- $plus = $this.find(".fmc-plus"),
2481
- $minus = $this.find(".fmc-minus"),
2482
- $result = $this.find(".fmc-result"),
2483
- resultVal = parseInt($result.val());
2484
-
2485
- $plus.on("click", function (e) {
2486
- e.preventDefault();
2487
- resultVal += options.num;
2488
- $result.val(resultVal);
2489
- });
2490
-
2491
- $minus.on("click", function (e) {
2492
- e.preventDefault();
2493
-
2494
- if (resultVal - options.num >= 0) {
2495
- resultVal -= options.num;
2496
-
2497
- $result.val(resultVal);
2498
- } else {
2499
- return false;
2500
- }
2501
- });
2502
- };
2503
-
2504
- ItemCount.prototype.destroy = function () {
2505
- $(this).removeData("be.itemcount");
2506
- };
2507
-
2508
- $.fn.itemCount = function (option) {
2509
- return this.each(function () {
2510
- var $this = $(this);
2511
- var data = $this.data("be.itemcount");
2512
- var options = $.extend({}, ItemCount.DEFAULTS, $this.data(), typeof option == "object" && option);
2513
-
2514
- if (!data) $this.data("be.itemcount", (data = new ItemCount(this, options)));
2515
- if (typeof option == "string") data[option]();
2516
- });
2517
- };
2518
- }(jQuery);
2519
-
2520
-
2521
-
2522
- /* ========================================================================
2523
- * 15. 绘制点线动画
2524
- * 2018年6月2日09:54:29
2525
- * ========================================================================
2526
-
2527
- <script type="text/javascript" src="WEB/js/tweenlite/easepack.min.js"></script>
2528
- <script type="text/javascript" src="WEB/js/tweenlite/tweenlite.min.js"></script>
2529
-
2530
- $(function() {
2531
- $("#container").lineEffect({
2532
- //pointColor: "rgba(0, 0, 0, 1)",
2533
- //lineColor: "0, 0, 0" ,
2534
- //height: 302,
2535
- isWindowWidth: true,
2536
- num: 11,
2537
- canvasId: "iCanvas"
2538
- });
2539
- })
2540
-
2541
-
2542
- <div id="container" >
2543
- <canvas id="iCanvas"></canvas>
2544
- </div>
2545
-
2546
- * ======================================================================== */
2547
- +function ($) {
2548
-
2549
- var LineEffect = function (element, options) {
2550
- this.$element = $(element);
2551
- this.options = $.extend({}, this.DEFAULTS, options);
2552
-
2553
- this.init(this);
2554
- };
2555
-
2556
- LineEffect.DEFAULTS = {
2557
- canvasId: "targetCanvas",
2558
- animateHeader: true,
2559
-
2560
- width: window.innerWidth,
2561
- height: window.innerHeight,
2562
- isWindowWidth: false,
2563
- isWindowHeight: false,
2564
- num: 20,
2565
-
2566
- pointColor: "156,217,249", //点颜色
2567
- lineColor: "156,217,249" //线颜色
2568
- };
2569
-
2570
-
2571
- LineEffect.prototype.init = function (e) {
2572
- var $this = $(e.$element),
2573
- options = e.options,
2574
- thisTarget = this;
2575
-
2576
-
2577
- var target = {x: options.width/2, y: options.height/2};
2578
-
2579
- var canvas = document.getElementById(options.canvasId);
2580
- canvas.width = options.width;
2581
- canvas.height = options.height;
2582
- var ctx = canvas.getContext("2d");
2583
-
2584
- // create points
2585
- var points = [];
2586
- for(var x = 0; x < options.width; x = x + options.width / options.num) {
2587
- for(var y = 0; y < options.height; y = y + options.height / options.num) {
2588
- var px = x + Math.random() * options.width / options.num;
2589
- var py = y + Math.random() * options.height / options.num;
2590
- var p = {x: px, originX: px, y: py, originY: py };
2591
- points.push(p);
2592
- }
2593
- }
2594
-
2595
- // for each point find the 5 closest points
2596
- for(var i = 0; i < points.length; i++) {
2597
- var closest = [];
2598
- var p1 = points[i];
2599
- for(var j = 0; j < points.length; j++) {
2600
- var p2 = points[j]
2601
- if(!(p1 == p2)) {
2602
- var placed = false;
2603
- for(var k = 0; k < 5; k++) {
2604
- if(!placed) {
2605
- if(closest[k] == undefined) {
2606
- closest[k] = p2;
2607
- placed = true;
2608
- }
2609
- }
2610
- }
2611
-
2612
- for(var k = 0; k < 5; k++) {
2613
- if(!placed) {
2614
- if(thisTarget.getDistance(p1, p2) < thisTarget.getDistance(p1, closest[k])) {
2615
- closest[k] = p2;
2616
- placed = true;
2617
- }
2618
- }
2619
- }
2620
- }
2621
- }
2622
- p1.closest = closest;
2623
- }
2624
-
2625
-
2626
- // assign a circle to each point
2627
- for(var i in points) {
2628
- var c = new thisTarget.Circle(options, points[i], 2 + Math.random() * 2);
2629
- points[i].circle = c;
2630
- }
2631
- options.points = points;
2632
- thisTarget.initAnimation(options, ctx, target);
2633
- thisTarget.addListeners(options, target, canvas);
2634
- };
2635
-
2636
-
2637
-
2638
- LineEffect.prototype.getDistance = function(p1, p2) {
2639
- return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
2640
- };
2641
-
2642
-
2643
- LineEffect.prototype.Circle = function(options, pos, rad) {
2644
- var _this = this;
2645
- // constructor
2646
- (function() {
2647
- _this.pos = pos || null;
2648
- _this.radius = rad || null;
2649
- // _this.color = color || null;
2650
- })();
2651
-
2652
-
2653
- this.draw = function(ctx) {
2654
- if(!_this.active) return;
2655
- ctx.beginPath();
2656
- ctx.arc(_this.pos.x, _this.pos.y, _this.radius, 0, 2 * Math.PI, false);
2657
- ctx.fillStyle = "rgba(" + options.pointColor + "," + _this.active + ")";
2658
-
2659
- ctx.fill();
2660
- };
2661
- };
2662
-
2663
-
2664
- /**----------------- 开始绘制动画效果 -----------------------**/
2665
- LineEffect.prototype.initAnimation = function(options, ctx, target) {
2666
- var thisTarget = this;
2667
- thisTarget.animate(options, ctx, target);
2668
- for(var i in options.points) {
2669
- thisTarget.shiftPoint(options.points[i]);
2670
- }
2671
- }
2672
-
2673
- LineEffect.prototype.animate = function(options, ctx, target) {
2674
- var thisTarget = this;
2675
- if(options.animateHeader) {
2676
-
2677
- var points = options.points;
2678
- ctx.clearRect(0, 0, options.width, options.height);
2679
- for(var i in points) {
2680
- // detect points in range
2681
- if(Math.abs(thisTarget.getDistance(target, points[i])) < 4000) {
2682
- points[i].active = 0.3;
2683
- points[i].circle.active = 0.6;
2684
- } else if(Math.abs(thisTarget.getDistance(target, points[i])) < 20000) {
2685
- points[i].active = 0.1;
2686
- points[i].circle.active = 0.3;
2687
- } else if(Math.abs(thisTarget.getDistance(target, points[i])) < 40000) {
2688
- points[i].active = 0.02;
2689
- points[i].circle.active = 0.1;
2690
- } else {
2691
- points[i].active = 0;
2692
- points[i].circle.active = 0;
2693
- }
2694
-
2695
- thisTarget.drawLines(options, points[i], ctx);
2696
- points[i].circle.draw(ctx);
2697
- }
2698
- }
2699
- requestAnimationFrame(function() {
2700
- thisTarget.animate(options, ctx, target)
2701
- });
2702
-
2703
- }
2704
-
2705
- /**----------------- 开始绘制动画效果 - 点 -----------------------**/
2706
- LineEffect.prototype.shiftPoint = function(p) {
2707
- var thisTarget = this;
2708
- TweenLite.to(p,
2709
- 1 + 1 * Math.random(),
2710
- {
2711
- x: p.originX - 50 + Math.random() * 100,
2712
- y: p.originY - 50 + Math.random() * 100,
2713
- ease:Circ.easeInOut,
2714
- onComplete: function() {
2715
- thisTarget.shiftPoint(p);
2716
- }
2717
- }
2718
- );
2719
- }
2720
-
2721
- /**----------------- 开始绘制动画效果 - 线 -----------------------**/
2722
- LineEffect.prototype.drawLines = function(options, p, ctx) {
2723
- if(!p.active) return;
2724
- for(var i in p.closest) {
2725
- ctx.beginPath();
2726
- ctx.moveTo(p.x, p.y);
2727
- ctx.lineTo(p.closest[i].x, p.closest[i].y);
2728
- ctx.strokeStyle = "rgba(" + options.lineColor + "," + p.active + ")";
2729
- ctx.stroke();
2730
- }
2731
- }
2732
-
2733
-
2734
- /**----------------- 监听事件,移动鼠标, 滚动, 改变屏幕大小 -----------------------**/
2735
- LineEffect.prototype.addListeners = function(options, target, canvas) {
2736
- var thisTarget = this;
2737
- if(!('ontouchstart' in window)) {
2738
- window.addEventListener("mousemove",
2739
- function(e) {
2740
- thisTarget.mouseMove(e, target);
2741
- }
2742
- );
2743
- }
2744
- window.addEventListener("scroll",
2745
- function(e) {
2746
- thisTarget.scrollCheck(options);
2747
- }
2748
- );
2749
- window.addEventListener("resize",
2750
- function(e) {
2751
- thisTarget.resize(options, canvas);
2752
- }
2753
- );
2754
- }
2755
-
2756
- LineEffect.prototype.mouseMove = function(e, target) {
2757
- var offsetTop = this.$element.offset().top
2758
- var offsetLeft = this.$element.offset().left
2759
-
2760
- var posx = posy = 0;
2761
- if (e.pageX || e.pageY) {
2762
- posx = e.pageX;
2763
- posy = e.pageY;
2764
- }
2765
- else if (e.clientX || e.clientY) {
2766
- posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
2767
- posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
2768
- }
2769
- target.x = posx - offsetLeft;
2770
- target.y = posy - offsetTop;
2771
- }
2772
-
2773
- LineEffect.prototype.scrollCheck = function(options) {
2774
- if(document.body.scrollTop > options.height) options.animateHeader = false;
2775
- else options.animateHeader = true;
2776
- }
2777
-
2778
- LineEffect.prototype.resize = function(options, canvas) {
2779
- if (options.isWindowWidth)
2780
- canvas.width = window.innerWidth;
2781
-
2782
- if (options.isWindowHeight)
2783
- canvas.height = window.innerHeight;
2784
-
2785
- }
2786
-
2787
-
2788
- /**----------------- 销毁 -----------------------**/
2789
- LineEffect.prototype.destroy = function () {
2790
- $(this).removeData("be.lineEffect");
2791
- };
2792
-
2793
-
2794
- $.fn.lineEffect = function (option) {
2795
- return this.each(function () {
2796
- var $this = $(this);
2797
- var data = $this.data("be.lineEffect");
2798
- options = $.extend({}, LineEffect.DEFAULTS, $this.data(), typeof option == "object" && option);
2799
-
2800
- if (!data) $this.data("be.lineEffect", (data = new LineEffect(this, options)));
2801
- if (typeof option == "string") data[option]();
2802
- });
2803
- };
2804
- }(jQuery);
2805
-
2806
-
2807
- /* ========================================================================
2808
- * 16.底部按钮快速移动到顶部
2809
- * 2018年7月3日11:55:06
2810
- * ========================================================================
2811
-
2812
- $(function() {
2813
- //参数赋值,js构造方法赋值优先级高于html中data-*中赋值
2814
- $(".ce-gotop").gotop({
2815
- position: {
2816
- "bottom": 15,
2817
- "right": 15
2818
- },
2819
- showeffect: "zoomIn",
2820
- type: "fixed",
2821
- offsettop: "400"
2822
- });
2823
- })
2824
-
2825
- <a class="ce-gotop" href="#">
2826
- <i class="fa fa-angle-up"></i>
2827
- </a>
2828
- 或者可以直接在a标签添加如下属性
2829
- data-type="fixed"
2830
- data-position='{
2831
- "bottom": 15,
2832
- "right": 15
2833
- }'
2834
- data-offsettop="400"
2835
- data-showeffect="zoomIn"
2836
-
2837
- * ======================================================================== */
2838
- +function ($) {
2839
-
2840
- var GoTop = function (element, options) {
2841
- this.options = $.extend({}, this.DEFAULTS, options);
2842
- this.$element = $(element);
2843
-
2844
- this.init(this.$element, this.options);
2845
- };
2846
-
2847
- GoTop.DEFAULTS = {
2848
- position: {
2849
- "bottom": 15,
2850
- "right": 15
2851
- },
2852
- showeffect: " animate__zoomIn ",
2853
- hideeffect: " animate__zoomOut ",
2854
- type: "fixed",
2855
- offsettop: "400",
2856
- compensation: "#js-header"
2857
- };
2858
-
2859
- GoTop.prototype.init = function (element, options) {
2860
- this.$element = $(element);
2861
- this.options = $.extend({}, this.DEFAULTS, options);
2862
-
2863
- this.initGoTop(this);
2864
- };
2865
-
2866
- GoTop.prototype.initGoTop = function (e) {
2867
- var options = e.options;
2868
- e.$element.each(function (i, el) {
2869
- //Variables
2870
-
2871
- var $this = $(el),
2872
- $target = $this.data("target"),
2873
- type = options.type,
2874
- showeffect = options.showeffect,
2875
- position = options.position,
2876
- compensation = $(options.compensation).outerHeight(),
2877
- offsettop = options.offsettop,
2878
- hideeffect = options.hideeffect;
2879
-
2880
- $this.addClass("animate__animated").css({
2881
- "display": "inline-block",
2882
- "position": type,
2883
- "opacity": 0
2884
- });
2885
-
2886
- if (type == "fixed" || type == "absolute") {
2887
- $this.css(position);
2888
- }
2889
-
2890
- $this.on("click", function (e) {
2891
- e.preventDefault();
2892
- scrollTo(0, 0);
2893
- // $("html, body").stop().animate({
2894
- // "scrollTop": $target ? $($target).offset().top - compensation : 0
2895
- // }, 300);
2896
- });
2897
-
2898
- if (!offsettop && !$this.hasClass("animated-running")) {
2899
- if ($this.offset().top <= $(window).height()) {
2900
- $this.addClass("animated-running " + showeffect).css({
2901
- "opacity": ""
2902
- });
2903
- }
2904
- }
2905
-
2906
- $(window).on("scroll", function () {
2907
- if (offsettop) {
2908
- if ($(window).scrollTop() >= offsettop && !$this.hasClass("animated-running")) {
2909
- $this.addClass("animated-running " + showeffect).css({
2910
- "opacity": ""
2911
- });
2912
- $this.removeClass(hideeffect);
2913
- } else if ($(window).scrollTop() <= offsettop && $this.hasClass("animated-running")) {
2914
- $this.removeClass("animated-running " + showeffect).css({
2915
- "opacity": 0
2916
- });
2917
- $this.addClass(hideeffect);
2918
- }
2919
- } else {
2920
- var thisOffsetTop = $this.offset().top;
2921
-
2922
- if (!$this.hasClass("animated-running")) {
2923
- if ($(window).scrollTop() >= thisOffsetTop - $(window).height()) {
2924
- $this.addClass("animated-running " + showeffect).css({
2925
- "opacity": ""
2926
- });
2927
- $this.removeClass(hideeffect);
2928
- }
2929
- }
2930
- }
2931
- });
2932
-
2933
- $(window).trigger("scroll");
2934
- //Actions
2935
- //collection = collection.add($this);
2936
- });
2937
- };
2938
-
2939
- var old = $.fn.gotop;
2940
- $.fn.gotop = function (option) {
2941
- return this.each(function () {
2942
- var $this = $(this);
2943
-
2944
- var data = $this.data("be.gotop");
2945
- var options = $.extend({}, GoTop.DEFAULTS, $this.data(), typeof option == "object" && option);
2946
-
2947
- if (!data)
2948
- $this.data("be.gotop", (data = new GoTop(this, options)));
2949
- else
2950
- data["init"]();
2951
-
2952
- if (typeof option == "string") data[option]();
2953
- });
2954
- };
2955
-
2956
- $.fn.gotop.Constructor = GoTop;
2957
- $.fn.gotop.noConflict = function () {
2958
- $.fn.gotop = old;
2959
- return this;
2960
- };
2961
- }(jQuery);
2962
-
2963
-
2964
- /* ========================================================================
2965
- * 17.背景滚动特效
2966
- * 2019年1月16日12:06:19
2967
- * ========================================================================
2968
-
2969
- $(".ce-bg-ef").scrollBackground({speed: 6});
2970
-
2971
- 样式:
2972
- .ce-bg-ef {
2973
- width: 100%;
2974
- height: 400px;
2975
- background: url("http://120.24.229.95/file/images/sample/anime/0/anime1470402086147.jpg");
2976
-
2977
- transition: all 0.7s ease-in-out;
2978
- -o-transition: all 0.7s ease-in-out;
2979
- -ms-transition: all 0.7s ease-in-out;
2980
- -moz-transition: all 0.7s ease-in-out;
2981
- -webkit-transition: all 0.7s ease-in-out;
2982
- }
2983
- * ======================================================================== */
2984
- +function ($) { "use strict";
2985
-
2986
- // SCROLLBACKGROUND CLASS DEFINITION
2987
- // ====================
2988
-
2989
- var ScrollBackground = function(element, options) {
2990
- this.element = $(element);
2991
- this.options = $.extend({}, this.DEFAULTS, options);
2992
- this.init(options);
2993
- }
2994
-
2995
- ScrollBackground.DEFAULTS = {
2996
- speed: 5
2997
- };
2998
-
2999
- ScrollBackground.prototype.init = function (options) {
3000
- var $this = this.element;
3001
-
3002
- $this.css("background-position", "50% 0px");
3003
- $(window).scroll(function() {
3004
- var y = $this.offset().top;
3005
- var h = $this.height();
3006
- var windowY = $(this).scrollTop();
3007
- var windowH = $(this).height();
3008
- if (windowH + windowY > y && windowH + windowY < y + windowH + h) {
3009
- var bgY = (y + h - windowY) / options.speed;
3010
- $this.css("background-position", "50% -" + bgY + "px");
3011
- }
3012
- });
3013
- }
3014
-
3015
- // SCROLLBACKGROUND PLUGIN DEFINITION
3016
- // =====================
3017
-
3018
- var old = $.fn.scrollBackground
3019
-
3020
- $.fn.scrollBackground = function ( option ) {
3021
- return this.each(function () {
3022
- var $this = $(this)
3023
- var data = $this.data('bs.scrollbackground');
3024
- var options = $.extend({}, ScrollBackground.DEFAULTS, $this.data(), typeof option == "object" && option);
3025
-
3026
- if (!data) $this.data('bs.scrollbackground', (data = new ScrollBackground(this, options)))
3027
- else if (typeof option == 'string') data[option]();
3028
- })
3029
- }
3030
-
3031
- $.fn.scrollBackground.Constructor = ScrollBackground
3032
-
3033
-
3034
- // SCROLLBACKGROUND NO CONFLICT
3035
- // ===============
3036
-
3037
- $.fn.scrollBackground.noConflict = function () {
3038
- $.fn.scrollBackground = old
3039
- return this
3040
- }
3041
- }(jQuery);
3042
-
3043
-
3044
- /* ========================================================================
3045
- * 18. 鼠标上下左右划入监听实现对应动画
3046
- * 2022年7月28日 10:50:06
3047
- * ========================================================================
3048
-
3049
- $(".ce-thumb").hoverdir({
3050
- hoverDelay: 0,
3051
- reverse: false
3052
- });
3053
-
3054
- * ======================================================================== */
3055
- +function ($) {
3056
- "use strict";
3057
-
3058
- var HoverDir = function(element, options) {
3059
- this.element = $(element);
3060
- this.options = $.extend({}, this.DEFAULTS, options);
3061
- this.init(options);
3062
- }
3063
- HoverDir.DEFAULTS = {
3064
- hoverDelay: 0,
3065
- reverse: false
3066
- };
3067
-
3068
- HoverDir.prototype.init = function (options) {
3069
- this.options = $.extend(true, {}, HoverDir.DEFAULTS, options);
3070
- this._loadEvents();
3071
- },
3072
- HoverDir.prototype._loadEvents = function () {
3073
- var _self = this;
3074
- debug(_self.options.hoverDelay);
3075
- this.element.on("mouseenter.hoverdir, mouseleave.hoverdir", function (event) {
3076
- var $el = $(this), evType = event.type, $hoverElem = $el.find("div"), direction = _self._getDir($el, { x: event.pageX, y: event.pageY }), hoverClasses = _self._getClasses(direction);
3077
- $hoverElem.removeClass();
3078
- if (evType === "mouseenter") {
3079
- $hoverElem.hide().addClass(hoverClasses.from);
3080
- clearTimeout(_self.tmhover);
3081
- _self.tmhover = setTimeout(function () {
3082
- $hoverElem.show(0, function () {
3083
- $(this).addClass("be-ts").addClass(hoverClasses.to);
3084
- });
3085
- }, _self.options.hoverDelay);
3086
- } else {
3087
- $hoverElem.addClass("be-ts");
3088
- clearTimeout(_self.tmhover);
3089
- $hoverElem.addClass(hoverClasses.from);
3090
- }
3091
- });
3092
- },
3093
- HoverDir.prototype._getDir = function ($el, coordinates) {
3094
- var w = $el.width(),
3095
- h = $el.height(),
3096
- x = (coordinates.x - $el.offset().left - (w / 2)) * (w > h ? (h / w) : 1),
3097
- y = (coordinates.y - $el.offset().top - (h / 2)) * (h > w ? (w / h) : 1),
3098
- direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
3099
- return direction;
3100
- },
3101
- HoverDir.prototype._getClasses = function (direction) {
3102
- var fromClass, toClass;
3103
- switch (direction) {
3104
- case 0: (!this.options.reverse) ? fromClass = "ce-slideFromTop" : fromClass = "ce-slideFromBottom"; toClass = "ce-slideTop"; break;
3105
- case 1: (!this.options.reverse) ? fromClass = "ce-slideFromRight" : fromClass = "ce-slideFromLeft"; toClass = "ce-slideLeft"; break;
3106
- case 2: (!this.options.reverse) ? fromClass = "ce-slideFromBottom" : fromClass = "ce-slideFromTop"; toClass = "ce-slideTop"; break;
3107
- case 3: (!this.options.reverse) ? fromClass = "ce-slideFromLeft" : fromClass = "ce-slideFromRight"; toClass = "ce-slideLeft"; break;
3108
- };
3109
- return { from: fromClass, to: toClass };
3110
- }
3111
-
3112
- $.fn.hoverdir = function(options) {
3113
- if (typeof options === "string") {
3114
- var args = Array.prototype.slice.call(arguments, 1);
3115
- this.each(function () {
3116
- var instance = $.data(this, "hoverdir");
3117
- if (!instance) {
3118
- return;
3119
- }
3120
- if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
3121
- return;
3122
- }
3123
- instance[options].apply(instance, args);
3124
- });
3125
- } else {
3126
- this.each(function () {
3127
- var instance = $.data(this, "hoverdir");
3128
- if (!instance) {
3129
- $.data(this, "hoverdir", new HoverDir(this, options));
3130
- }
3131
- });
3132
- }
3133
- return this;
3134
- }
3135
- }(jQuery);
3136
-
3137
-
3138
- /* ========================================================================
3139
- * 19. niceSelect下拉框
3140
- * 2022年8月14日 21:41:21
3141
- * ========================================================================
3142
- //初始化
3143
- $(".ns-select").niceSelect();
3144
-
3145
- //获取选中选项值
3146
- $(".ns-select").change(function() {
3147
- debug($(".ce-nice-select.ns-select .list .selected").data("value"));
3148
- debug($(".ce-nice-select.ns-select .list .selected").html());
3149
- })
3150
- * ======================================================================== */
3151
- +function ($) {
3152
- "use strict";
3153
-
3154
- $.fn.niceSelect = function(options) {
3155
- if (typeof method == 'string') {
3156
- if (method == 'update') {
3157
- this.each(function() {
3158
- var $select = $(this);
3159
- var $dropdown = $(this).next('.ce-nice-select');
3160
- var open = $dropdown.hasClass('open');
3161
-
3162
- if ($dropdown.length) {
3163
- $dropdown.remove();
3164
- create_nice_select($select);
3165
-
3166
- if (open) {
3167
- $select.next().trigger('click');
3168
- }
3169
- }
3170
- });
3171
- } else if (method == 'destroy') {
3172
- this.each(function() {
3173
- var $select = $(this);
3174
- var $dropdown = $(this).next('.ce-nice-select');
3175
-
3176
- if ($dropdown.length) {
3177
- $dropdown.remove();
3178
- $select.css('display', '');
3179
- }
3180
- });
3181
- if ($('.ce-nice-select').length == 0) {
3182
- $(document).off('.nice_select');
3183
- }
3184
- } else {}
3185
- return this;
3186
- }
3187
-
3188
- this.hide();
3189
-
3190
- this.each(function() {
3191
- var $select = $(this);
3192
- if (!$select.next().hasClass('ce-nice-select')) {
3193
- create_nice_select($select);
3194
- }
3195
- });
3196
-
3197
- function create_nice_select($select) {
3198
- $select.after($('<div></div>')
3199
- .addClass('ce-nice-select')
3200
- .addClass($select.attr('class') || '')
3201
- .addClass($select.attr('disabled') ? 'disabled' : '')
3202
- .attr('tabindex', $select.attr('disabled') ? null : '0')
3203
- .html('<span class="current"></span><ul class="list"></ul>')
3204
- );
3205
-
3206
- var $dropdown = $select.next();
3207
- var $options = $select.find('option');
3208
- var $selected = $select.find('option:selected');
3209
-
3210
- $dropdown.find('.current').html($selected.data('display') || $selected.text());
3211
-
3212
- $options.each(function(i) {
3213
- var $option = $(this);
3214
- var display = $option.data('display');
3215
-
3216
- $dropdown.find('ul').append($('<li></li>')
3217
- .attr('data-value', $option.val())
3218
- .attr('data-display', (display || null))
3219
- .addClass('option' + ($option.is(':selected') ? ' selected' : '') + ($option.is(':disabled') ? ' disabled' : ''))
3220
- .html($option.text())
3221
- );
3222
- });
3223
- }
3224
-
3225
- $(document).off('.nice_select');
3226
-
3227
- $(document).on('click.nice_select', '.ce-nice-select', function(event) {
3228
- var $dropdown = $(this);
3229
- $('.ce-nice-select').not($dropdown).removeClass('open');
3230
- $dropdown.toggleClass('open');
3231
-
3232
- if ($dropdown.hasClass('open')) {
3233
- $dropdown.find('.option');
3234
- $dropdown.find('.focus').removeClass('focus');
3235
- $dropdown.find('.selected').addClass('focus');
3236
- } else {
3237
- $dropdown.focus();
3238
- }
3239
- });
3240
-
3241
- $(document).on('click.nice_select', function(event) {
3242
- if ($(event.target).closest('.ce-nice-select').length === 0) {
3243
- $('.ce-nice-select').removeClass('open').find('.option');
3244
- }
3245
- });
3246
-
3247
- $(document).on('click.nice_select', '.ce-nice-select .option:not(.disabled)', function(event) {
3248
- var $option = $(this);
3249
- var $dropdown = $option.closest('.ce-nice-select');
3250
-
3251
- $dropdown.find('.selected').removeClass('selected');
3252
- $option.addClass('selected');
3253
-
3254
- var text = $option.data('display') || $option.text();
3255
- $dropdown.find('.current').text(text);
3256
-
3257
- $dropdown.prev('select').val($option.data('value')).trigger('change');
3258
- });
3259
-
3260
- $(document).on('keydown.nice_select', '.ce-nice-select', function(event) {
3261
- var $dropdown = $(this);
3262
- var $focused_option = $($dropdown.find('.focus') || $dropdown.find('.list .option.selected'));
3263
-
3264
- if (event.keyCode == 32 || event.keyCode == 13) {
3265
- if ($dropdown.hasClass('open')) {
3266
- $focused_option.trigger('click');
3267
- } else {
3268
- $dropdown.trigger('click');
3269
- }
3270
- return false;
3271
- } else if (event.keyCode == 40) {
3272
- if (!$dropdown.hasClass('open')) {
3273
- $dropdown.trigger('click');
3274
- } else {
3275
- var $next = $focused_option.nextAll('.option:not(.disabled)').first();
3276
- if ($next.length > 0) {
3277
- $dropdown.find('.focus').removeClass('focus');
3278
- $next.addClass('focus');
3279
- }
3280
- }
3281
- return false;
3282
- } else if (event.keyCode == 38) {
3283
- if (!$dropdown.hasClass('open')) {
3284
- $dropdown.trigger('click');
3285
- } else {
3286
- var $prev = $focused_option.prevAll('.option:not(.disabled)').first();
3287
- if ($prev.length > 0) {
3288
- $dropdown.find('.focus').removeClass('focus');
3289
- $prev.addClass('focus');
3290
- }
3291
- }
3292
- return false;
3293
- } else if (event.keyCode == 27) {
3294
- if ($dropdown.hasClass('open')) {
3295
- $dropdown.trigger('click');
3296
- }
3297
- } else if (event.keyCode == 9) {
3298
- if ($dropdown.hasClass('open')) {
3299
- return false;
3300
- }
3301
- }
3302
- });
3303
-
3304
- var style = document.createElement('a').style;
3305
- style.cssText = 'pointer-events:auto';
3306
- if (style.pointerEvents !== 'auto') {
3307
- $('html').addClass('no-csspointerevents');
3308
- }
3309
- return this;
3310
- }
3311
- }(jQuery);
3312
-
3313
- /* ========================================================================
3314
- * 20. 文字切换动画特效
3315
- * 2023年7月5日 12:58:24
3316
- * ========================================================================
3317
-
3318
- $(function() {
3319
- $("#ce-flash").flash({
3320
- type: 1,
3321
- animationDelay: 3000,
3322
- lettersDelay: 50
3323
- });
3324
- })
3325
-
3326
- <div id="ce-flash" class="ce-txt">
3327
- <span>
3328
- <b class="is-visible">design.</b>
3329
- <b>coding.</b>
3330
- <b>graphic.</b>
3331
- </span>
3332
- </div>
3333
-
3334
- * ======================================================================== */
3335
- +function ($) {
3336
- "use strict";
3337
-
3338
- var Flash = function(element, options) {
3339
- this.element = $(element);
3340
- if (options.type == 1) {
3341
- this.element.addClass("letters");
3342
- } else if (options.type == 2) {
3343
- this.element.addClass("clip");
3344
- } else if (options.type == 3) {
3345
- this.element.addClass("type");
3346
- } else {
3347
- this.element.addClass("letters");
3348
- }
3349
- this.options = $.extend({}, this.DEFAULTS, options);
3350
- this.init(options);
3351
- }
3352
-
3353
- Flash.DEFAULTS = {
3354
- //动画类型 1-3
3355
- type: 1,
3356
- //动画间隔时间5秒
3357
- animationDelay: 5000,
3358
- //loading bar effect
3359
- barAnimationDelay: 3800,
3360
- barWaiting: Flash.barAnimationDelay - 3000,
3361
- //letters: 每个字特效的时间间隔
3362
- lettersDelay: 50,
3363
- //type 特效
3364
- typeLettersDelay: 50,
3365
- selectionDuration: 100,
3366
- typeAnimationDelay: Flash.selectionDuration + 800,
3367
- //clip 特效
3368
- revealDuration: 600,
3369
- revealAnimationDelay: 1500
3370
- };
3371
-
3372
- Flash.prototype.init = function(options) {
3373
- this.options = $.extend(true, {}, Flash.DEFAULTS, options);
3374
- this.loadEvents();
3375
- };
3376
-
3377
- Flash.prototype.loadEvents = function() {
3378
- var self = this;
3379
- //为变化单词的每个字母插入<i>元素
3380
- self.singleLetters($(self.options.selector).find("b"));
3381
- //初始化动画
3382
- self.animateHeadline($(self.options.selector));
3383
- };
3384
-
3385
- Flash.prototype.singleLetters = function($words) {
3386
- var self = this;
3387
- $words.each(function() {
3388
- var word = $(this),
3389
- letters = word.text().split(""),
3390
- selected = word.hasClass("is-visible");
3391
- for (var i in letters) {
3392
- if(word.parents(self.options.selector).length > 0) letters[i] = "<em>" + letters[i] + "</em>";
3393
- letters[i] = (selected) ? "<i class='in'>" + letters[i] + "</i>": "<i>" + letters[i] + "</i>";
3394
- }
3395
- var newLetters = letters.join("");
3396
- word.html(newLetters).css("opacity", 1);
3397
- });
3398
- };
3399
-
3400
- Flash.prototype.animateHeadline = function($headlines) {
3401
- var self = this;
3402
- var duration = self.options.animationDelay;
3403
- $headlines.each(function(){
3404
- var headline = $(this);
3405
-
3406
- if(headline.hasClass("loading-bar")) {
3407
- duration = self.options.barAnimationDelay;
3408
- setTimeout(function(){ headline.find("span").addClass("is-loading") }, self.options.barWaiting);
3409
- } else if (headline.hasClass("clip")){
3410
- var spanWrapper = headline.find("span"),
3411
- newWidth = spanWrapper.width() + 10
3412
- spanWrapper.css("width", newWidth);
3413
- } else if (!headline.hasClass("type") ) {
3414
- //将其最长单词的宽度分配给第一级节点
3415
- var words = headline.find("span b"),
3416
- width = 0;
3417
- words.each(function(){
3418
- var wordWidth = $(this).width();
3419
- if (wordWidth > width) width = wordWidth;
3420
- });
3421
- headline.find("span").css("width", width);
3422
- };
3423
-
3424
- //开始动画
3425
- setTimeout(function(){ self.hideWord( headline.find(".is-visible").eq(0) ) }, duration);
3426
- });
3427
- };
3428
-
3429
- Flash.prototype.hideWord = function($word) {
3430
- var self = this;
3431
- var nextWord = self.takeNext($word);
3432
-
3433
- if($word.parents(self.options.selector).hasClass("type")) {
3434
- var parentSpan = $word.parent("span");
3435
- parentSpan.addClass("selected").removeClass("waiting");
3436
- setTimeout(function(){
3437
- parentSpan.removeClass("selected");
3438
- $word.removeClass("is-visible").addClass("is-hidden").children("i").removeClass("in").addClass("out");
3439
- }, self.options.selectionDuration);
3440
- setTimeout(function(){ self.showWord(nextWord, self.options.typeLettersDelay) }, self.options.typeAnimationDelay);
3441
-
3442
- } else if($word.parents(self.options.selector).hasClass("letters")) {
3443
- var bool = ($word.children("i").length >= nextWord.children("i").length) ? true : false;
3444
- self.hideLetter($word.find("i").eq(0), $word, bool, self.options.lettersDelay);
3445
- self.showLetter(nextWord.find("i").eq(0), nextWord, bool, self.options.lettersDelay);
3446
-
3447
- } else if($word.parents(self.options.selector).hasClass("clip")) {
3448
- $word.parents("span").animate({ width : "2px" }, self.options.revealDuration, function(){
3449
- self.switchWord($word, nextWord);
3450
- self.showWord(nextWord);
3451
- });
3452
-
3453
- } else if ($word.parents(self.options.selector).hasClass("loading-bar")){
3454
- $word.parents("span").removeClass("is-loading");
3455
- self.switchWord($word, nextWord);
3456
- setTimeout(function(){ self.hideWord(nextWord) }, self.options.barAnimationDelay);
3457
- setTimeout(function(){ $word.parents("span").addClass("is-loading") }, self.options.barWaiting);
3458
-
3459
- } else {
3460
- self.switchWord($word, nextWord);
3461
- setTimeout(function(){ self.hideWord(nextWord) }, self.options.animationDelay);
3462
- }
3463
- };
3464
-
3465
- Flash.prototype.showWord = function($word, $duration) {
3466
- var self = this;
3467
- if($word.parents(self.options.selector).hasClass("type")) {
3468
- self.showLetter($word.find("i").eq(0), $word, false, $duration);
3469
- $word.addClass("is-visible").removeClass("is-hidden");
3470
-
3471
- } else if($word.parents(self.options.selector).hasClass("clip")) {
3472
- $word.parents("span").animate({ "width" : $word.width() + 10 }, self.options.revealDuration, function(){
3473
- setTimeout(function(){ self.hideWord($word) }, self.options.revealAnimationDelay);
3474
- });
3475
- }
3476
- };
3477
-
3478
- Flash.prototype.hideLetter = function($letter, $word, $bool, $duration) {
3479
- var self = this;
3480
- $letter.removeClass("in").addClass("out");
3481
-
3482
- if(!$letter.is(":last-child")) {
3483
- setTimeout(function(){ self.hideLetter($letter.next(), $word, $bool, $duration); }, $duration);
3484
- } else if($bool) {
3485
- setTimeout(function(){ self.hideWord(self.takeNext($word)) }, self.options.animationDelay);
3486
- }
3487
-
3488
- if($letter.is(":last-child") && $("html").hasClass("no-csstransitions")) {
3489
- var nextWord = self.takeNext($word);
3490
- self.switchWord($word, nextWord);
3491
- }
3492
- };
3493
-
3494
- Flash.prototype.showLetter = function($letter, $word, $bool, $duration) {
3495
- var self = this;
3496
- $letter.addClass("in").removeClass("out");
3497
-
3498
- if(!$letter.is(":last-child")) {
3499
- setTimeout(function(){ self.showLetter($letter.next(), $word, $bool, $duration); }, $duration);
3500
- } else {
3501
- if($word.parents(self.options.selector).hasClass("type")) { setTimeout(function(){ $word.parents("span").addClass("waiting"); }, 200);}
3502
- if(!$bool) { setTimeout(function(){ self.hideWord($word) }, self.options.animationDelay) }
3503
- }
3504
- };
3505
-
3506
- Flash.prototype.takeNext = function($word) {
3507
- return (!$word.is(":last-child")) ? $word.next() : $word.parent().children().eq(0);
3508
- };
3509
-
3510
- Flash.prototype.takePrev = function($word) {
3511
- return (!$word.is(":first-child")) ? $word.prev() : $word.parent().children().last();
3512
- };
3513
-
3514
- Flash.prototype.switchWord = function($oldWord, $newWord) {
3515
- $oldWord.removeClass("is-visible").addClass("is-hidden");
3516
- $newWord.removeClass("is-hidden").addClass("is-visible");
3517
- };
3518
-
3519
- $.fn.flash = function(option) {
3520
- var selector = this.selector;
3521
- return this.each(function (i, t) {
3522
- var $this = $(this);
3523
-
3524
- var data = $this.data("be.flash");
3525
- var options = $.extend({selector: selector}, Flash.DEFAULTS, $this.data(), typeof option == "object" && option);
3526
-
3527
- if (!data)
3528
- $this.data("be.flash", (data = new Flash(this, options)));
3529
- });
3530
- };
3531
-
3532
- }(jQuery);
3533
-
3534
- /* ========================================================================
3535
- * 21. 局部loading动画
3536
- * 2023年8月5日 10:55:51
3537
- * ========================================================================
3538
-
3539
- <p data-ae-load>需要使用loading动画的页面标签</p>
3540
-
3541
- var al = new AeLoader();
3542
- al.init();
3543
-
3544
- //不需要加载数据,完整的loading动画
3545
- $("#ae-load-start").click(function() {
3546
- //全部触发
3547
- al.start();
3548
- //指定触发
3549
- //al.start(".ae-test-target");
3550
- });
3551
- //显示loading动画
3552
- $("#ae-load-loading").click(function() {
3553
- //全部触发
3554
- al.loading();
3555
- //指定触发
3556
- //al.loading(".ae-test-target");
3557
- });
3558
- //loading动画完成,显示数据
3559
- $("#ae-load-done").click(function() {
3560
- //全部触发
3561
- al.done();
3562
- //指定触发
3563
- //al.done(".ae-test-target");
3564
- });
3565
-
3566
- * ======================================================================== */
3567
- (function() {
3568
- var u, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
3569
-
3570
- u = (function() {
3571
- function u() {}
3572
- u.prototype.extend = function(custom, defaults) {
3573
- var key, value;
3574
- for (key in defaults) {
3575
- value = defaults[key];
3576
- if (custom[key] == null) {
3577
- custom[key] = value;
3578
- }
3579
- }
3580
- return custom;
3581
- };
3582
- return u;
3583
- })();
3584
-
3585
- window.AeLoader = (function() {
3586
- AeLoader.prototype.defaults = {};
3587
-
3588
- function AeLoader(options) {
3589
- if (options == null) {
3590
- options = {};
3591
- }
3592
- this.config = this.util().extend(options, this.defaults);
3593
- this.start = bind(this.start, this);
3594
- this.loading = bind(this.loading, this);
3595
- this.done = bind(this.done, this);
3596
- }
3597
-
3598
- AeLoader.prototype.init = function() {
3599
- $("[data-ae-load]").addClass("ae-load");
3600
- return this.finished = [];
3601
- };
3602
-
3603
- //不需要加载数据,完整的loading动画
3604
- AeLoader.prototype.start = function(target) {
3605
- if (target) {
3606
- console.log(this);
3607
- } else {
3608
- target = "";
3609
- }
3610
- $(target + "[data-ae-load]").addClass("ae-load");
3611
- $(target + "[data-ae-load]").removeClass("ae-tt-complete ae-tt-done ae-tt-loading");
3612
- setTimeout(function() {
3613
- $(target + "[data-ae-load]").addClass("ae-tt-complete");
3614
- setTimeout(function() {$(target + "[data-ae-load]").removeClass("ae-load ae-tt-complete");}, 1000);
3615
- }, 100);
3616
- };
3617
-
3618
- //显示loading动画
3619
- AeLoader.prototype.loading = function(target) {
3620
- if (!target) target = "";
3621
-
3622
- $("[data-ae-load]").addClass("ae-load");
3623
- $(target + "[data-ae-load]").each(function(index, currentTarget) {
3624
- var minWidth = $(currentTarget).data("al-mw");
3625
- var minHeight = $(currentTarget).data("al-mh");
3626
- if (minWidth) $(currentTarget).css("min-width", minWidth);
3627
- if (minHeight) $(currentTarget).css("min-height", minHeight);
3628
-
3629
- $(currentTarget).removeClass("ae-tt-complete ae-tt-done ae-tt-loading");
3630
- setTimeout(function() {
3631
- $(currentTarget).addClass("ae-tt-loading");
3632
- }, 1);
3633
- })
3634
- };
3635
-
3636
- //loading动画完成,显示数据
3637
- AeLoader.prototype.done = function(target) {
3638
- if (!target) target = "";
3639
- $(target + "[data-ae-load]").removeClass("ae-tt-done");
3640
- setTimeout(function() {
3641
- $(target + "[data-ae-load]").addClass("ae-tt-done");
3642
- setTimeout(function() {$(target + "[data-ae-load]").removeClass("ae-load ae-tt-loading ae-tt-done");}, 1000);
3643
- }, 1);
3644
- };
3645
-
3646
- AeLoader.prototype.util = function() {
3647
- return this._util != null ? this._util : this._util = new u();
3648
- };
3649
-
3650
- return AeLoader;
3651
- })();
3652
-
3653
- }).call(this);
3654
-
3655
-
3656
- /* ========================================================================
3657
- * 22. 按钮动画
3658
- * 2023年8月30日 10:41:03
3659
- * ========================================================================
3660
-
3661
- <a href="#" class="ce-btn-5">
3662
- <span>了解更多</span>
3663
- </a>
3664
-
3665
- $(".ce-btn-5").btnEf();
3666
-
3667
- * ======================================================================== */
3668
- +function ($) {
3669
-
3670
- var BtnEf = function (element, options) {
3671
- this.options = $.extend({}, this.DEFAULTS, options);
3672
-
3673
- this.init(element, this.options);
3674
- };
3675
-
3676
- BtnEf.DEFAULTS = {};
3677
-
3678
- BtnEf.prototype.init = function (element, options) {
3679
- $('<b></b>').appendTo(element);
3680
- $(element)
3681
- .on('mouseenter', function (e) {
3682
- var parentOffset = $(this).offset(),
3683
- relX = e.pageX - parentOffset.left,
3684
- relY = e.pageY - parentOffset.top;
3685
- $(this).find('b').css({
3686
- top: relY,
3687
- left: relX
3688
- });
3689
- })
3690
- .on('mouseout', function (e) {
3691
- var parentOffset = $(this).offset(),
3692
- relX = e.pageX - parentOffset.left,
3693
- relY = e.pageY - parentOffset.top;
3694
- $(this).find('b').css({
3695
- top: relY,
3696
- left: relX
3697
- });
3698
- });
3699
- $($(element).attr('class') + "[href='#']").click(function () {
3700
- return false;
3701
- });
3702
- };
3703
-
3704
- $.fn.btnEf = function (option) {
3705
- var $this = $(this);
3706
- return this.each(function () {
3707
- var data = $this.data("be.btnef");
3708
- var options = $.extend({}, BtnEf.DEFAULTS, $this.data(), typeof option == "object" && option);
3709
-
3710
- if (!data)
3711
- $this.data("be.btnef", (data = new BtnEf(this, options)));
3712
- else
3713
- data["init"](options);
3714
- });
3715
- };
3716
- }(jQuery);
3717
-
3718
-