arisu.js 1.0.0 → 1.0.3

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.
@@ -0,0 +1,3307 @@
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
+
993
+ * ======================================================================== */
994
+
995
+
996
+ /* ========================================================================
997
+ * 1. 设置数字对应描述,背景颜色或者字体颜色
998
+ * 2016年6月10日11:02:58
999
+ * ========================================================================
1000
+
1001
+ window.tagArray = [1, 2, 3, 4, 5];
1002
+ window.descArray = ["信息", "低危", "中危", "高危", "紧急"];
1003
+ window.colorArray = ["color-8", "color-9", "color-10", "color-11", "color-13"];
1004
+ window.bgcolorArray = ["color-bg-8", "color-bg-9", "color-bg-10", "color-bg-11", "color-bg-13"];
1005
+
1006
+ <span id="a"></span>
1007
+ $("#a").setColor({
1008
+ tag: 2,
1009
+ tagArray: window.tagArray,
1010
+ descArray: window.descArray,
1011
+ colorArray: window.colorArray,
1012
+ bgcolorArray: window.bgcolorArray,
1013
+ desc: "未知"
1014
+ });
1015
+ * ======================================================================== */
1016
+ +function ($) {
1017
+
1018
+ var SetColor = function (element, options) {
1019
+ this.options = $.extend({}, this.DEFAULTS, options);
1020
+ this.tag =
1021
+ this.colorArray =
1022
+ this.bgcolorArray =
1023
+ this.tagArray =
1024
+ this.descArray =
1025
+ this.$element = $(element);
1026
+
1027
+ this.init(this.$element, this.options);
1028
+ };
1029
+
1030
+ SetColor.DEFAULTS = {
1031
+ desc: "---"
1032
+ };
1033
+
1034
+ SetColor.prototype.init = function (element, options) {
1035
+ element.html(options.desc);
1036
+
1037
+ $(options.tagArray).each(function(i, t) {
1038
+ if (options.tag == t) {
1039
+ if (options.colorArray)
1040
+ element.addClass(options.colorArray[i]);
1041
+ if (options.bgcolorArray)
1042
+ element.addClass(options.bgcolorArray[i]);
1043
+ element.html(options.descArray[i]);
1044
+ }
1045
+ });
1046
+ };
1047
+
1048
+ var old = $.fn.setColor;
1049
+ $.fn.setColor = function (option) {
1050
+ return this.each(function () {
1051
+ var $this = $(this);
1052
+
1053
+ var data = $this.data("be.setcolor");
1054
+ var options = $.extend({}, SetColor.DEFAULTS, $this.data(), typeof option == "object" && option);
1055
+
1056
+ if (!data)
1057
+ $this.data("be.setcolor", (data = new SetColor(this, options)));
1058
+ else
1059
+ data["init"]();
1060
+
1061
+ if (typeof option == 'string') data[option]();
1062
+ });
1063
+ };
1064
+
1065
+ $.fn.setColor.Constructor = SetColor;
1066
+ $.fn.setColor.noConflict = function () {
1067
+ $.fn.setColor = old;
1068
+ return this;
1069
+ };
1070
+ }(jQuery);
1071
+
1072
+
1073
+ /* ========================================================================
1074
+ * 2. 点击切换css active class样式 ,不要使用在包含子元素的标签
1075
+ * @ 1:切换CLASS
1076
+ * @ 2:切换CLASS,如果该元素已经active就清除,同时只能一个active
1077
+ * @ 3:切换CLASS,如果该元素已经active就清除,可以多个active
1078
+ * 2016年6月11日10:36:03
1079
+ * ========================================================================
1080
+
1081
+ <button type="button" class="btn btn-info">按钮1</button>
1082
+ <button type="button" class="btn btn-info">按钮2</button>
1083
+
1084
+ $(".btn").setActive({flag: 2});
1085
+
1086
+ * ======================================================================== */
1087
+ +function ($) {
1088
+
1089
+ var SetActive = function (element, options) {
1090
+ var options = $.extend({}, SetActive.DEFAULTS, options);
1091
+ var $element = $(element);
1092
+
1093
+ $element.on("click.setactive", options, this.init);
1094
+ // $element.on("click.setactive", {element, options}, this.init);
1095
+ };
1096
+
1097
+ SetActive.DEFAULTS = {
1098
+ flag: 1,
1099
+ className: "active"
1100
+ };
1101
+
1102
+ SetActive.prototype.init = function (e) {
1103
+ var $target = $(this);
1104
+ var options = e.data;
1105
+ if (options.flag == 1) {//仅仅激活当前项
1106
+ $(options.selector).removeClass(options.className);
1107
+ $target.addClass(options.className);
1108
+ }
1109
+
1110
+ // else if (e.data.flag == 2) {
1111
+ // if ($this.hasClass(e.data.className)) {
1112
+ // $(ct).removeClass(e.data.className);
1113
+ // } else {
1114
+ // $(ct).removeClass(e.data.className);
1115
+ // $this.addClass(e.data.className);
1116
+ // }
1117
+ // } else if (e.data.flag == 3) {
1118
+ // if ($this.hasClass(e.data.className)) {
1119
+ // $this.removeClass(e.data.className);
1120
+ // } else {
1121
+ // $this.addClass(e.data.className);
1122
+ // }
1123
+ // }
1124
+ };
1125
+
1126
+ $.fn.setActive = function (option) {
1127
+ var selector = this.selector;
1128
+ return this.each(function (i, t) {
1129
+ var $this = $(this);
1130
+
1131
+ $this.attr("data-class", $this.attr("class"));
1132
+ var data = $this.data("be.setactive");
1133
+ options = $.extend({selector: selector}, SetActive.DEFAULTS, $this.data(), typeof option == "object" && option);
1134
+
1135
+ if (!data)
1136
+ $this.data("be.setactive", (data = new SetActive(this, options)));
1137
+ });
1138
+ };
1139
+ }(jQuery);
1140
+
1141
+
1142
+
1143
+ /* ========================================================================
1144
+ * 3. 页面加载遮罩效果,使交互按钮无法在点击
1145
+ * 2016年6月14日09:40:14
1146
+ * ========================================================================
1147
+
1148
+ <button id="c" type="button" class="btn btn-info">按钮2</button>
1149
+
1150
+
1151
+ $("#c").click(function() {
1152
+ $("body").loading();
1153
+
1154
+ setTimeout(function() {
1155
+ $("body").loading("complete");
1156
+ }, 1000);
1157
+ });
1158
+
1159
+ * ======================================================================== */
1160
+ +function ($) {
1161
+
1162
+ var Loading = function (element, options) {
1163
+ this.$element = $(element);
1164
+ this.options = $.extend({}, this.DEFAULTS, options);
1165
+
1166
+ this.toggle(options);
1167
+ };
1168
+
1169
+ Loading.DEFAULTS = {
1170
+ template: "<div id='ce-loading' class='ce-loading invisible'></div>",
1171
+ timeOut: -1
1172
+ };
1173
+
1174
+ Loading.prototype.loading = function () {
1175
+ var e = this.$element;
1176
+ if ($("#ce-loading").length == 0) {
1177
+
1178
+ e.children().eq(0).before(this.options.template);
1179
+
1180
+ var cl = new CanvasLoader("ce-loading");
1181
+ cl.setColor("#0a0a0a");
1182
+ cl.setShape("roundRect");
1183
+ cl.setDensity(11);
1184
+ cl.setRange(0.8);
1185
+ cl.setSpeed(1);
1186
+ cl.setFPS(10);
1187
+ cl.show();
1188
+ }
1189
+ e.addClass("ok");
1190
+
1191
+ $(".ce-loading").removeClass("invisible");
1192
+ $("body > *:not(.ce-loading)").addClass("be-blur-2");
1193
+ $("body").addClass("ce-loading-bg");
1194
+
1195
+ if (options.timeOut != -1) {
1196
+ setTimeout(function() {
1197
+ $("body").loading("complete");
1198
+ }, options.timeOut);
1199
+ }
1200
+ };
1201
+ Loading.prototype.complete = function() {
1202
+ this.$element.removeClass("ok");
1203
+
1204
+ $(".ce-loading").addClass("invisible");
1205
+ $("body > *:not(.ce-loading)").removeClass("be-blur-2");
1206
+ $("body").removeClass("ce-loading-bg");
1207
+ };
1208
+
1209
+ Loading.prototype.toggle = function (options) {
1210
+ this[this.$element.hasClass("ok") ? "complete" : "loading"](options);
1211
+ };
1212
+
1213
+ $.fn.loading = function (option) {
1214
+ return this.each(function () {
1215
+ var $this = $(this);
1216
+ var data = $this.data("be.loading");
1217
+
1218
+ var options = $.extend({}, Loading.DEFAULTS, $this.data(), typeof option == "object" && option);
1219
+ if (!data)
1220
+ $this.data("be.loading", (data = new Loading(this, options)));
1221
+ else
1222
+ data["toggle"]();
1223
+
1224
+ if (typeof option == "string") data[option]();
1225
+ });
1226
+ };
1227
+ }(jQuery);
1228
+
1229
+
1230
+ /* ========================================================================
1231
+ * 4. 多选框全选/全清
1232
+ * 2016年6月25日23:19:54
1233
+ * ========================================================================
1234
+
1235
+ <input type="checkbox" id="be-all-check"/>全选
1236
+ <input type="checkbox" class="be-check"/>选项一
1237
+ <input type="checkbox" class="be-check"/>选项二
1238
+
1239
+ $("#be-all-check").checkAll({
1240
+ targets: ".be-check"
1241
+ })
1242
+
1243
+ * ======================================================================== */
1244
+ +function ($) {
1245
+
1246
+ var CheckAll = function (element, options) {
1247
+ this.$element = $(element);
1248
+ this.options = $.extend({}, this.DEFAULTS, options);
1249
+
1250
+ this.$element.on("click", "", this.init);
1251
+ };
1252
+
1253
+ CheckAll.DEFAULTS = {
1254
+ targets: ".be-check"
1255
+ };
1256
+
1257
+ CheckAll.prototype.init = function () {
1258
+ var $this = $(this);
1259
+ $this.data("be.checkall")["toggle"]();
1260
+ };
1261
+
1262
+ CheckAll.prototype.checked = function () {
1263
+ var e = this.$element;
1264
+ e.addClass("checked-all");
1265
+ $(this.options.targets).prop("checked", true);
1266
+ };
1267
+
1268
+ CheckAll.prototype.clear = function() {
1269
+ this.$element.removeClass("checked-all");
1270
+ $(this.options.targets).prop("checked", false);
1271
+ };
1272
+
1273
+ CheckAll.prototype.toggle = function () {
1274
+ this[this.$element.hasClass("checked-all") ? "clear" : "checked"]();
1275
+ };
1276
+
1277
+ CheckAll.prototype.destroy = function () {
1278
+ $(this).removeData("be.checkall");
1279
+ };
1280
+
1281
+ $.fn.checkAll = function (option) {
1282
+ return this.each(function () {
1283
+ var $this = $(this);
1284
+ if ($this.is(":checked"))
1285
+ $this.addClass("checked-all");
1286
+ else
1287
+ $this.removeClass("checked-all");
1288
+
1289
+ var data = $this.data("be.checkall");
1290
+ var options = $.extend({}, CheckAll.DEFAULTS, $this.data(), typeof option == "object" && option);
1291
+ if (!data) $this.data("be.checkall", (data = new CheckAll(this, options)));
1292
+
1293
+ if (typeof option == "string") data[option]();
1294
+ });
1295
+ };
1296
+ }(jQuery);
1297
+
1298
+
1299
+ /* ========================================================================
1300
+ * 5. 提交后台过程中让按钮不可用,防止用户多次点击
1301
+ * 2016年6月26日10:08:11
1302
+ * ========================================================================
1303
+
1304
+ <button href="#" class="e1 btn btn-danger">按钮一</button>
1305
+
1306
+ $(".e1").click(function() {
1307
+ $(".e1").submitFlag();
1308
+
1309
+ setTimeout(function() {
1310
+ $(".e1").submitFlag();
1311
+ }, 1000);
1312
+ });
1313
+
1314
+ 或者
1315
+ <button href="#" class="e2 btn btn-danger">按钮二</button>
1316
+
1317
+ $(".e2").click(function() {
1318
+ $(".e2").submitFlag({
1319
+ text: "数据请求中..",
1320
+ useText: true
1321
+ });
1322
+
1323
+ setTimeout(function() {
1324
+ $(".e2").submitFlag();
1325
+ }, 1000);
1326
+ });
1327
+
1328
+
1329
+
1330
+ * ======================================================================== */
1331
+ +function ($) {
1332
+
1333
+ var SubmitFlag = function (element, options) {
1334
+ this.$element = $(element);
1335
+ this.options = $.extend({}, this.DEFAULTS, options);
1336
+
1337
+ this.toggle();
1338
+ };
1339
+
1340
+ SubmitFlag.DEFAULTS = {
1341
+ text: "处理中..",
1342
+ useText: true
1343
+ };
1344
+
1345
+ SubmitFlag.prototype.request = function () {
1346
+ var $this = this.$element;
1347
+
1348
+ $this.addClass("submit-flag-request").data("text", $this.text()).attr("disabled", "disabled");
1349
+ if (this.options.useText)
1350
+ $this.text(this.options.text);
1351
+ };
1352
+
1353
+ SubmitFlag.prototype.complete = function() {
1354
+ var $this = this.$element;
1355
+ $this.removeClass("submit-flag-request").removeAttr("disabled");
1356
+ if ($this.data("text") && this.options.useText)
1357
+ $this.text($this.data("text"));
1358
+ };
1359
+
1360
+ SubmitFlag.prototype.toggle = function () {
1361
+ this[this.$element.hasClass("submit-flag-request") ? "complete" : "request"]();
1362
+ };
1363
+
1364
+ $.fn.submitFlag = function (option) {
1365
+ return this.each(function () {
1366
+ var $this = $(this);
1367
+ var data = $this.data("be.submitflag");
1368
+
1369
+ var options = $.extend({}, SubmitFlag.DEFAULTS, $this.data(), typeof option == "object" && option);
1370
+ if (!data)
1371
+ $this.data("be.submitflag", (data = new SubmitFlag(this, options)));
1372
+ else
1373
+ data["toggle"]();
1374
+
1375
+ if (typeof option == "string") data[option]();
1376
+ });
1377
+ };
1378
+ }(jQuery);
1379
+
1380
+
1381
+ /* ========================================================================
1382
+ * 6. 数字特效递增特效
1383
+ * 2016年6月26日11:13:16
1384
+ * ========================================================================
1385
+
1386
+ <p id="f">0</p>
1387
+
1388
+ $("#f").numStep({
1389
+ number: 100,
1390
+ time: 1000
1391
+ });
1392
+
1393
+ setTimeout(function() {
1394
+ $("#f").numStep({
1395
+ number: 300,
1396
+ time: 1000
1397
+ });
1398
+ }, 2000);
1399
+
1400
+ * ======================================================================== */
1401
+ +function ($) {
1402
+
1403
+ var NumStep = function (element, options) {
1404
+ this.options = $.extend({}, this.DEFAULTS, options);
1405
+ this.$element = $(element);
1406
+
1407
+ this.init(this.options);
1408
+ };
1409
+
1410
+ NumStep.DEFAULTS = {
1411
+ number: 100,
1412
+ time: 1500
1413
+ };
1414
+
1415
+ NumStep.prototype.init = function (options) {
1416
+ var $element = this.$element;
1417
+
1418
+ $element.animate({count: options.number}, {
1419
+ duration: options.time,
1420
+ step: function() {
1421
+ if (this.count)
1422
+ $element.text(Math.round(this.count));
1423
+ }
1424
+ });
1425
+ };
1426
+
1427
+ $.fn.numStep = function (option) {
1428
+ var $this = $(this);
1429
+ return this.each(function () {
1430
+ var data = $this.data("be.numstep");
1431
+ var options = $.extend({}, NumStep.DEFAULTS, $this.data(), typeof option == "object" && option);
1432
+
1433
+ if (!data)
1434
+ $this.data("be.numstep", (data = new NumStep(this, options)));
1435
+ else
1436
+ data["init"](options);
1437
+ });
1438
+ };
1439
+ }(jQuery);
1440
+
1441
+
1442
+ /* ========================================================================
1443
+ * 7. bootstrap黑色提示消息显示
1444
+ * 2016年6月26日13:24:55
1445
+ * ========================================================================
1446
+
1447
+ <button href="#" class="g1 btn btn-danger margin-left-20">按钮一</button>
1448
+ <span id="g2"></span>
1449
+
1450
+ $(".g1").detail({
1451
+ placement: "bottom",
1452
+ title: "该按钮/区域说明"
1453
+ });
1454
+
1455
+ $("#g2").detail({
1456
+ title: "一定很长需要减少长度的文字说明",
1457
+ length: 5
1458
+ });
1459
+
1460
+ * ======================================================================== */
1461
+ +function ($) {
1462
+
1463
+ var Detail = function (element, options) {
1464
+ this.options = $.extend({}, this.DEFAULTS, options);
1465
+
1466
+ this.init(element, this.options);
1467
+ };
1468
+
1469
+ Detail.DEFAULTS = {
1470
+ isSelf: false,//是否使用原来文本作为提示显示内容
1471
+ isReplace: true,//是否替换原来文本
1472
+ placement: "top",
1473
+ title: "...",
1474
+ length : false
1475
+ };
1476
+
1477
+ Detail.prototype.init = function (element, options) {
1478
+ var $element = $(element);
1479
+
1480
+ if (options.isSelf)
1481
+ options.title = $element.text();
1482
+
1483
+ $element.tooltip({
1484
+ placement: options.placement,
1485
+ title: options.title
1486
+ });
1487
+
1488
+ if (options.isReplace) {
1489
+ if (options.length && options.length < options.title.length)
1490
+ $element.html(options.title.substring(0, options.length) + "...");
1491
+ else
1492
+ $element.html(options.title);
1493
+ }
1494
+ // if (options.isSelf)
1495
+ // $element.html(options.title.substring(0, options.length) + "...");
1496
+ };
1497
+
1498
+ $.fn.detail = function (option) {
1499
+ var $this = $(this);
1500
+ return this.each(function () {
1501
+ var data = $this.data("be.detail");
1502
+ var options = $.extend({}, Detail.DEFAULTS, $this.data(), typeof option == "object" && option);
1503
+
1504
+ if (!data)
1505
+ $this.data("be.detail", (data = new Detail(this, options)));
1506
+ else
1507
+ data["init"](this, options);
1508
+ });
1509
+ };
1510
+ }(jQuery);
1511
+
1512
+
1513
+ /* ========================================================================
1514
+ * 8. 图片按钮滑入滑出切换按钮图片
1515
+ * 2016年6月26日10:08:11
1516
+ * ========================================================================
1517
+
1518
+ <img id="more" src="WEB/images/resource/more.png" class="img-responsive center-block"></img>
1519
+ // more.png
1520
+ // more-hover.png
1521
+
1522
+ $("#more").imageBtn();
1523
+
1524
+ * ======================================================================== */
1525
+ +function ($) {
1526
+
1527
+ var ImageBtn = function (element, options) {
1528
+ this.$element = $(element);
1529
+ this.options = $.extend({}, this.DEFAULTS, options);
1530
+
1531
+ this.init(this.options);
1532
+ };
1533
+
1534
+ ImageBtn.DEFAULTS = {
1535
+ suffix: "-hover"
1536
+ };
1537
+
1538
+ ImageBtn.prototype.init = function (options) {
1539
+ var $element = this.$element;
1540
+
1541
+ $element.hover(function() {
1542
+ var t = $(this);
1543
+ var src = $(this).attr("src");
1544
+ var index = src.lastIndexOf(".");
1545
+ $(this).fadeOut(200);
1546
+ var srcHover = src.substr(0, index) + options.suffix + src.substr(index, src.length);
1547
+ $(this).attr("src", srcHover);
1548
+ $(this).fadeIn(200);
1549
+ }, function() {
1550
+ var srcHover = $(this).attr("src");
1551
+ var src = srcHover.replace(options.suffix, "");
1552
+ $(this).attr("src", src);
1553
+ });
1554
+ };
1555
+
1556
+ $.fn.imageBtn = function (option) {
1557
+ return this.each(function () {
1558
+ var $this = $(this);
1559
+ var data = $this.data("be.imagebtn");
1560
+
1561
+ var options = $.extend({}, ImageBtn.DEFAULTS, $this.data(), typeof option == "object" && option);
1562
+ if (!data)
1563
+ $this.data("be.imagebtn", (data = new ImageBtn(this, options)));
1564
+ else
1565
+ data["init"]();
1566
+ });
1567
+ };
1568
+ }(jQuery);
1569
+
1570
+
1571
+
1572
+ /* ========================================================================
1573
+ * 9. 弹框搜索面板
1574
+ * 2016年5月22日19:01:48
1575
+ * ========================================================================
1576
+
1577
+ <a id="ipopover" tabindex="0" class="btn btn-sm btn-danger">弹出搜索框</a>
1578
+ <div id="load"></div>
1579
+
1580
+ $("#load").load("WEB/page/template.html", function() {
1581
+ $("#ipopover").popoverSearch({
1582
+ items: [
1583
+ {name: "name", desc: "姓名", type: "text", value: ""},
1584
+ {name: "tiem", desc: "开始时间", type: "date", value: ""},
1585
+ {name: "select", desc: "选项", type: "select",
1586
+ options: [
1587
+ {name: "", value: "所有", selected: false},//如果默认查询所有,name设置为""
1588
+ {name: "o1", value: "选项1", selected: false},
1589
+ {name: "o2", value: "选项2", selected: true}
1590
+ ]}
1591
+ ],
1592
+ onSerach: function(e) {
1593
+ $("#ipopover").click();
1594
+ debug(e.param);//参数及参数值对象,{name: "arisu", tiem: "2016-07-16 17:02:59", select: "o2"}
1595
+ }
1596
+ });
1597
+ });
1598
+ * ======================================================================== */
1599
+ +function ($) {
1600
+
1601
+ var PopoverSearch = function (element, options) {
1602
+ this.options = $.extend({}, this.DEFAULTS, options);
1603
+
1604
+ this.init(element, this.options);
1605
+ };
1606
+
1607
+ PopoverSearch.DEFAULTS = {
1608
+ html: true,
1609
+ title: "详细搜索",
1610
+ trigger: "click",
1611
+ toggle: "popover",
1612
+ placement: "bottom",
1613
+ onSerach: false,
1614
+ items: [],
1615
+ startView: 2,
1616
+ minView: 2,
1617
+ format: "yyyy-MM-dd hh:mm:ss",
1618
+ bsVs: 5
1619
+ };
1620
+
1621
+ PopoverSearch.prototype.init = function (element, options) {
1622
+ var $element = $(element);
1623
+ var target = this;
1624
+
1625
+ var tplEl = $("#tp-popover");
1626
+ var template = Handlebars.compile(tplEl.html())({});
1627
+
1628
+ if (options.bsVs == 3) {
1629
+ $element.popover({
1630
+ html: options.html,
1631
+ title: options.title,
1632
+ trigger: options.trigger,
1633
+ toggle: options.toggle,
1634
+ placement: options.placement,
1635
+ template : template,
1636
+ param: null,
1637
+ });
1638
+
1639
+ $element.on("shown.bs.popover", function () {
1640
+ target.search(options, target);
1641
+ target.cancel(element);
1642
+ target.addItem(element, options);
1643
+ target.clear();
1644
+ });
1645
+
1646
+ $element.on("hide.bs.popover", function () {
1647
+ $(".popover-content-item").each(function(i, t) {
1648
+ var name = $(".popover-form-item", this).attr("name");
1649
+ if (options.items[i].type == "select") {
1650
+ var val = $(".popover-form-item", this).find("option:selected").attr("value");
1651
+ $(options.items[i].options).each(function(i, t) {
1652
+ if (this.name == val) {
1653
+ this.selected = true;
1654
+ } else {
1655
+ this.selected = false;
1656
+ }
1657
+ });
1658
+ } else {
1659
+ var val = $(".popover-form-item", this).val();
1660
+ options.items[i].value = val;
1661
+ }
1662
+
1663
+ });
1664
+ });
1665
+ } else {
1666
+ var popr = new bootstrap.Popover($element, {
1667
+ html: options.html,
1668
+ title: options.title,
1669
+ trigger: options.trigger,
1670
+ toggle: options.toggle,
1671
+ placement: options.placement,
1672
+ template : template,
1673
+ param: null
1674
+ });
1675
+ $element.on("shown.bs.popover", function (){
1676
+ target.search(options, target);
1677
+ target.close(popr);
1678
+ target.addItem(element, options);
1679
+ target.clear();
1680
+ });
1681
+ $element.on("hide.bs.popover", function () {
1682
+ $(".popover-content-item").each(function(i, t) {
1683
+ var name = $(".popover-form-item", this).attr("name");
1684
+ if (options.items[i].type == "select") {
1685
+ var val = $(".popover-form-item", this).find("option:selected").attr("value");
1686
+ $(options.items[i].options).each(function(i, t) {
1687
+ if (this.name == val) {
1688
+ this.selected = true;
1689
+ } else {
1690
+ this.selected = false;
1691
+ }
1692
+ });
1693
+ } else {
1694
+ var val = $(".popover-form-item", this).val();
1695
+ options.items[i].value = val;
1696
+ }
1697
+ });
1698
+ });
1699
+ }
1700
+ };
1701
+
1702
+ //获取参数
1703
+ PopoverSearch.prototype.getParam = function () {
1704
+ var params = new Object();
1705
+ $(".popover-content-item").each(function(i, t) {
1706
+ var name = $(".popover-form-item", this).attr("name");
1707
+ var val = $(".popover-form-item", this).val();
1708
+ if (val)
1709
+ params[name] = val;
1710
+ });
1711
+ return params;
1712
+ };
1713
+
1714
+ //搜索
1715
+ PopoverSearch.prototype.search = function (options, target) {
1716
+ $(".ce-popover-ok", ".ce-popover").off("click").on("click", "", function() {
1717
+ if (options.onSerach) {
1718
+ var e = {param: target.getParam()}
1719
+ options.onSerach(e);
1720
+ }
1721
+ });
1722
+ };
1723
+
1724
+ //关闭
1725
+ PopoverSearch.prototype.cancel = function (element) {
1726
+ var $element = $(element);
1727
+ $(".ce-popover-cancel", ".ce-popover").off("click").on("click", "", function() {
1728
+ $element.click();
1729
+ });
1730
+ };
1731
+
1732
+ //关闭
1733
+ PopoverSearch.prototype.close = function (popr) {
1734
+ $(".ce-popover-cancel", ".ce-popover").off("click").on("click", "", function() {
1735
+ popr.hide();
1736
+ });
1737
+ };
1738
+
1739
+ //清空条件
1740
+ PopoverSearch.prototype.clear = function (element) {
1741
+ $(".ce-popover-clear", ".ce-popover").off("click").on("click", "", function() {
1742
+ $("input", ".popover-content-item").val("");
1743
+ $("select option:first", ".popover-content-item").attr("selected", true);
1744
+ });
1745
+ };
1746
+
1747
+ //删除搜索项
1748
+ PopoverSearch.prototype.remove = function () {
1749
+ $(".ce-popover-remove", ".ce-popover").off("click").on("click", "", function() {
1750
+ $(this).parents(".popover-content-item.row").html("").removeClass("popover-content-item row");
1751
+ $(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last .ce-popover-add").css("display", "inline-block");
1752
+ });
1753
+ };
1754
+
1755
+ //添加搜索项
1756
+ PopoverSearch.prototype.add = function (element) {
1757
+ var target = this;
1758
+ $(".ce-popover-add", ".ce-popover").off("caddItemlick").on("click", "", function() {
1759
+ var tplEl = $("#tp-popover-option");
1760
+ var html = Handlebars.compile(tplEl.html())({});
1761
+ $(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last").after(html);
1762
+ $(".ce-popover > .popover-content .popover-content-items > .popover-content-item .ce-popover-add").css("display", "none");
1763
+ $(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last .ce-popover-add").css("display", "inline-block");
1764
+
1765
+ target.add(element);
1766
+ target.remove();
1767
+ });
1768
+ };
1769
+
1770
+ //添加搜索项
1771
+ PopoverSearch.prototype.addItem = function (element, options) {
1772
+ var tplEl = $("#tp-popover-items");
1773
+ var html = Handlebars.compile(tplEl.html())({
1774
+ items: options.items
1775
+ });
1776
+ $(".ce-popover > .popover-content .popover-content-items").html(html);
1777
+
1778
+ $(options.items).each(function(i, t) {
1779
+ //需要使用到日期控件
1780
+ if (t.type == "date") {
1781
+ var $input = $("input[name='" + t.name + "']", ".ce-popover");
1782
+ $(".ce-popover-date[date-flag='" + t.name + "']", ".ce-popover").datetimepicker({
1783
+ language: "zh-CN",
1784
+ format: options.format,
1785
+ weekStart: 0,
1786
+ todayBtn: true,
1787
+ autoclose: true,
1788
+ todayHighlight: true,
1789
+ startDate: "00:00",
1790
+ startView: options.startView,
1791
+ minView: options.minView,
1792
+ minuteStep: 1
1793
+ }).on("changeDate", function(e) {
1794
+ if ($input)
1795
+ $input.val(new Date(e.date.getTime()).format(options.format));
1796
+ });
1797
+ } else if (t.type == "time") {
1798
+ var $input = $("input[name='" + t.name + "']", ".ce-popover");
1799
+ $(".ce-popover-date[date-flag='" + t.name + "']", ".ce-popover").datetimepicker({
1800
+ language: "zh-CN",
1801
+ format: "hh:ii:00",
1802
+ weekStart: 0,
1803
+ //todayBtn: true,
1804
+ autoclose: true,
1805
+ todayHighlight: true,
1806
+ startDate: "00:00",
1807
+ startView: 1,
1808
+ minView: 0,
1809
+ minuteStep: 1
1810
+ }).on("changeDate", function(e) {
1811
+ if ($input)
1812
+ $input.val(new Date(e.date.getTime()).format("hh:mm:00"));
1813
+ });
1814
+
1815
+ }
1816
+ });
1817
+ };
1818
+
1819
+ $.fn.popoverSearch = function (option) {
1820
+ var $this = $(this);
1821
+ return this.each(function () {
1822
+ var data = $this.data("be.popover.search");
1823
+ var options = $.extend({}, PopoverSearch.DEFAULTS, $this.data(), typeof option == "object" && option);
1824
+
1825
+ if (!data) $this.data("be.popover.search", (data = new PopoverSearch(this, options)));
1826
+ if (typeof option == 'string') return data[option]();
1827
+ });
1828
+ };
1829
+ }(jQuery);
1830
+
1831
+
1832
+ /* ========================================================================
1833
+ * 10. 列表查询分页封装插件
1834
+ * 2016年7月27日15:02:29
1835
+ * ========================================================================
1836
+
1837
+ $("#user-list").iList({
1838
+ url: sp + "userManage/findUser.action",
1839
+ param: {name: "arisu"},
1840
+
1841
+ // 支持跨越
1842
+ // url: server + "springmvc/news/findNewsJsonp.action",
1843
+ // jsonp: "callback",
1844
+ // jsonpCallback:"showData",
1845
+ // dataType: "jsonp",
1846
+
1847
+ onSuccess: function(data) {
1848
+
1849
+ var tplEl = $("#tp-data-table-1");
1850
+ var html = Handlebars.compile(tplEl.html())({
1851
+ items: data.users
1852
+ });
1853
+ $(".be-list-data", "#user-list").html(html);
1854
+
1855
+ }
1856
+ });
1857
+
1858
+ * ======================================================================== */
1859
+ +function ($) {
1860
+
1861
+ var IList = function (element, options) {
1862
+ this.$element = $(element);
1863
+ this.options = $.extend({}, this.DEFAULTS, options);
1864
+
1865
+ this.init(element, this.options);
1866
+ };
1867
+
1868
+
1869
+ IList.DEFAULTS = {
1870
+ rp: "10",
1871
+ visiblePages: 7,
1872
+ sortname: "id",
1873
+ sortorder: "desc",
1874
+ method: "post",
1875
+ dataType: "json",
1876
+ async: true,
1877
+ jsonp: null,
1878
+ jsonpCallback: null,
1879
+ param: {},
1880
+ url: "",
1881
+ loadColor: "#0a0a0a",//必须是16进制,不能缩写
1882
+ lang: "cn",
1883
+ headerMap: null,
1884
+ onSuccess: false,
1885
+ onError: false
1886
+ };
1887
+
1888
+ IList.prototype.init = function (element, options) {
1889
+ $element = $(element);
1890
+ var target = this;
1891
+ $element.data("be.ilist.flag", true);
1892
+
1893
+ var tplEl = $("#tp-list");
1894
+ var html = Handlebars.compile(tplEl.html())({});
1895
+ $element.html(html);
1896
+
1897
+ // 不兼容jquery3.6
1898
+ $(".be-list-loading-canvas", $element).attr("id", $element.attr("id") + "-load");
1899
+ var cl = new CanvasLoader($element.attr("id") + "-load");
1900
+ cl.setColor(options.loadColor);
1901
+ cl.setShape("roundRect");
1902
+ cl.setDensity(11);
1903
+ cl.setRange(0.8);
1904
+ cl.setSpeed(1);
1905
+ cl.setFPS(10);
1906
+ cl.show();
1907
+
1908
+ var param = $.extend({}, {page: 1, rp: options.rp, sortname: options.sortname, sortorder: options.sortorder}, options.param);
1909
+ options.isPage = false;
1910
+ target.getData(element, options, param);
1911
+ };
1912
+
1913
+ IList.prototype.getData = function (element, options, param) {
1914
+ var target = this;
1915
+ if ($(".ilist-check-all[data-flag='1']", element).is(":checked"))
1916
+ $(".ilist-check-all[data-flag='1']", element).click();
1917
+ $(".be-list-loading", element).css("display", "block");
1918
+ if (options.isPage)
1919
+ $(".be-list-data-body", element).html("");
1920
+ else
1921
+ $(".be-list-data", element).css("display", "none");
1922
+
1923
+ $.ajax({
1924
+ type: options.method,
1925
+ url: options.url,
1926
+ beforeSend: function(request) {
1927
+ for (var key in options.headerMap) {
1928
+ if (options.headerMap.hasOwnProperty(key)) {
1929
+ request.setRequestHeader(key, options.headerMap[key]);
1930
+ }
1931
+ }
1932
+ },
1933
+ data: param,
1934
+ cache: false,
1935
+ jsonp: options.jsonp,
1936
+ jsonpCallback: options.jsonp,
1937
+ async: options.async,
1938
+ dataType: options.dataType,
1939
+ success: function (data) {
1940
+ $(".be-list-loading", element).css("display", "none");
1941
+
1942
+ data.isPage = options.isPage;
1943
+ if (options.isPage)
1944
+ $(".be-list-data-body", element).css("display", "table-row-group");
1945
+ else
1946
+ $(".be-list-data", element).css("display", "block");
1947
+
1948
+ if (options.onSuccess)
1949
+ options.onSuccess(data);
1950
+
1951
+ if (data.total) {
1952
+ var pageType = $(".be-list-page").data("type");
1953
+ if (pageType == 2)
1954
+ target.preNextPage(element, options, param, data.total);//上下两页页翻页
1955
+ else
1956
+ target.page(element, options, param, data.total);//多页翻页
1957
+
1958
+ if (param.page == 1)
1959
+ $(".be-list-page .previous").addClass("disabled");
1960
+ if (param.page == Math.ceil(data.total / options.rp))
1961
+ $(".be-list-page .next").addClass("disabled");
1962
+
1963
+ //全选/全清
1964
+ $(".ilist-check-all[data-flag='1']", element).checkAll({targets: ".ilist-check"});
1965
+
1966
+ //选择单列/取消选择单列
1967
+ $(".ilist-check", element).unbind("change");
1968
+ $(".ilist-check", element).change(function() {
1969
+ var isChecked = $(this).is(":checked");
1970
+ if (isChecked)
1971
+ $(this).parents("tr").addClass("active");
1972
+ else
1973
+ $(this).parents("tr").removeClass("active");
1974
+ });
1975
+
1976
+ //全选列/全清列
1977
+ $(".ilist-check-all[data-flag='1']", element).unbind("change");
1978
+ $(".ilist-check-all[data-flag='1']", element).change(function() {
1979
+ var isChecked = $(this).is(":checked");
1980
+ if (isChecked)
1981
+ $(".ilist-check").addClass("active").change();
1982
+ else
1983
+ $(".ilist-check").removeClass("active").change();
1984
+ });
1985
+
1986
+ //点击列选择单列/点击列取消选择单列
1987
+ $("table > tbody tr", element).unbind("click");
1988
+ $("table > tbody tr", element).click(function(e) {
1989
+ var target = $(e.target);
1990
+ if (!(target.is("input") || target.is("i") || target.is("a"))) {
1991
+ $(".ilist-check", this).click();
1992
+ }
1993
+ })
1994
+
1995
+ //排序
1996
+ $("table > thead tr td", element).unbind("click");
1997
+ $("table > thead tr td", element).click(function(e) {
1998
+ param.sortname = $(this).data("sortname");
1999
+
2000
+ if (!$(this).hasClass("is-check") && param.sortname) {
2001
+ var sortorder = $(this).attr("data-sort-order");
2002
+
2003
+ $("table > thead tr td", element).removeAttr("data-sort-order");
2004
+
2005
+ if (sortorder) {
2006
+ if (sortorder == "desc") {
2007
+ $(this).attr("data-sort-order", "asc");
2008
+ sortorder = "asc";
2009
+ } else {
2010
+ $(this).attr("data-sort-order", "desc");
2011
+ sortorder = "desc";
2012
+ }
2013
+ param.sortorder = sortorder;
2014
+ } else {
2015
+ $(this).attr("data-sort-order", "desc");
2016
+ param.sortorder = "desc";
2017
+ }
2018
+
2019
+ $element.data("be.ilist.flag", true);
2020
+ options.isPage = true;
2021
+ param.page = "1";
2022
+ target.getData(element, options, param);
2023
+ } else {
2024
+ $(this).css("cursor", "auto ! important");
2025
+ }
2026
+
2027
+ });
2028
+ $(".be-list-page", element).css("visibility", "visible");
2029
+ } else {
2030
+ $(".be-list-nofound", element).css("display", "block");
2031
+ }
2032
+ },
2033
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
2034
+ try {
2035
+ if (options.onError) options.onError(XMLHttpRequest, textStatus, errorThrown);
2036
+ } catch (e) {}
2037
+ }
2038
+ });
2039
+ }
2040
+
2041
+
2042
+ /** 分页查询 **/
2043
+ IList.prototype.page = function (element, options, param, total) {
2044
+ var rp = options.rp;
2045
+ if (options.rp == 0)
2046
+ rp = total;
2047
+ var totalPages = Math.ceil(total / rp);
2048
+ var target = this;
2049
+ var $element = $(element);
2050
+
2051
+ var end = ((param.page - 1) * rp + rp);
2052
+ if (end > total)
2053
+ end = total;
2054
+
2055
+ var html = "显示" + ((param.page - 1) * rp + 1) + "至 " + end + "条,共有" + total + "条 ";
2056
+ var first = "首页";
2057
+ var prev = "上一页";
2058
+ var next = "下一页";
2059
+ var last = "尾页";
2060
+ if (options.lang == "en") {
2061
+ html = "display data from " + ((param.page - 1) * rp + 1) + " to " + end + ",there are " + total + " data in total";
2062
+ first = "first";
2063
+ prev = "prev";
2064
+ next = "next";
2065
+ last = "last";
2066
+ }
2067
+
2068
+
2069
+ if ($element.data("be.ilist.flag")) {
2070
+ $(".pagination", element).parent().html("<span>" + html + "</span><ul class='pagination pagination-sm'></ul>");
2071
+ $(".pagination", element).twbsPagination({
2072
+ totalPages: totalPages,
2073
+ visiblePages: options.visiblePages,
2074
+ first: first,
2075
+ prev: prev,
2076
+ next: next,
2077
+ last: last,
2078
+ initiateStartPageClick: false,
2079
+ onPageClick: function(event, page) {
2080
+ param.page = page;
2081
+ var end = ((param.page - 1) * rp + rp);
2082
+ if (end > total)
2083
+ end = total;
2084
+ html = "显示 " + ((param.page - 1) * rp + 1) + " 至 " + end + " 条,共有 " + total + " 条";
2085
+ if (options.lang == "en")
2086
+ html = "display data from " + ((param.page - 1) * rp + 1) + " to " + end + ",there are " + total + " data in total";
2087
+
2088
+ $(".be-list-page > span", element).html(html);
2089
+
2090
+ options.isPage = true;
2091
+
2092
+ target.getData(element, options, param);
2093
+ }
2094
+ });
2095
+ }
2096
+ $element.data("be.ilist.flag", false);
2097
+ }
2098
+
2099
+ /** 上下两页分页查询 **/
2100
+ IList.prototype.preNextPage = function (element, options, param, total) {
2101
+ var rp = options.rp;
2102
+ if (options.rp == 0)
2103
+ rp = total;
2104
+ var totalPages = Math.ceil(total / rp);
2105
+ var target = this;
2106
+ var $element = $(element);
2107
+
2108
+ var end = ((param.page - 1) * rp + rp);
2109
+ if (end > total)
2110
+ end = total;
2111
+
2112
+
2113
+ $(document).off("click.clpp").on("click.clpp", ".be-list-page .previous:not(.disabled)", function(e) {
2114
+ param.page = param.page - 1;
2115
+ $(".be-list-page .next").removeClass("disabled");
2116
+
2117
+ if (param.page == 1) {
2118
+ $(this).addClass("disabled");
2119
+ }
2120
+
2121
+ options.isPage = true;
2122
+ target.getData(element, options, param);
2123
+ });
2124
+ $(document).off("click.clpn").on("click.clpn", ".be-list-page .next:not(.disabled)", function(e) {
2125
+ param.page = param.page + 1;
2126
+ $(".be-list-page .previous").removeClass("disabled");
2127
+
2128
+ if (param.page == totalPages) {
2129
+ $(this).addClass("disabled");
2130
+ }
2131
+ options.isPage = true;
2132
+ target.getData(element, options, param);
2133
+ });
2134
+
2135
+ $element.data("be.ilist.flag", false);
2136
+ }
2137
+
2138
+ /** 参数追加搜索 **/
2139
+ $.fn.iListReload = function (param) {
2140
+ var $this = $(this);
2141
+ var data = $this.data("be.ilist");
2142
+
2143
+ for (var pa in param) {
2144
+ if (typeof param[pa] == "string" && param[pa].trim() == "") {
2145
+ data.options.param[pa] = undefined;
2146
+ param[pa] = undefined;
2147
+ }
2148
+ }
2149
+
2150
+ // var p = $.extend({}, data.options.param, param);
2151
+ // data.options.param = p;
2152
+
2153
+ data.options.param = param;
2154
+ data["init"](this, data.options);
2155
+ // $this.data("be.ilist", (data = new IList(this, data.options)));
2156
+ };
2157
+
2158
+ $.fn.iList = function (option) {
2159
+ return this.each(function () {
2160
+ var $this = $(this);
2161
+ var data = $this.data("be.ilist");
2162
+
2163
+ var options = $.extend({}, IList.DEFAULTS, $this.data(), typeof option == "object" && option);
2164
+ if (!data)
2165
+ $this.data("be.ilist", (data = new IList(this, options)));
2166
+ else
2167
+ data["init"](this, options);
2168
+ });
2169
+ };
2170
+ }(jQuery);
2171
+
2172
+
2173
+ /* ========================================================================
2174
+ * 11. 元素显示切换
2175
+ * 2017年1月27日19:29:08
2176
+ * ========================================================================
2177
+
2178
+ <div class="ce-switch ce-switch-1 current">11111</div>
2179
+ <div class="ce-switch ce-switch-1 current">22222</div>
2180
+ <div class="ce-switch ce-switch-1 ce-switch-2 current">3333</div>
2181
+ <div class="ce-switch ce-switch-2">44444</div>
2182
+
2183
+ <button class="iswitch" data-show="ce-switch-1">a</button>
2184
+ <button class="iswitch" data-show="ce-switch-2">b</button>
2185
+
2186
+
2187
+
2188
+ <select id="iswitch-select">
2189
+ <option data-show="ce-switch-1">a</option>
2190
+ <option data-show="ce-switch-2">b</option>
2191
+ </select>
2192
+
2193
+ $(".iswitch").iSwitch({module: ".ce-switch2"});
2194
+
2195
+ $("#iswitch-select").iSwitch();
2196
+
2197
+ * ======================================================================== */
2198
+ +function ($) {
2199
+
2200
+ var ISwitch = function (element, options) {
2201
+ this.$element = $(element);
2202
+ this.options = $.extend({}, this.DEFAULTS, options);
2203
+
2204
+ this.init(this.options);
2205
+ };
2206
+
2207
+ ISwitch.DEFAULTS = {
2208
+ module: ".ce-switch"
2209
+ };
2210
+
2211
+ ISwitch.prototype.init = function (options) {
2212
+ var $element = this.$element;
2213
+
2214
+
2215
+ if ($element.is("select")) {
2216
+ $element.change(function() {
2217
+ $(options.module).removeClass("current");
2218
+
2219
+ var className = $element.find("option:selected").data("show");
2220
+ $("." + className).addClass("current").removeClass("hide");;
2221
+ });
2222
+ } else if($element.is("a") || $element.is("button")) {
2223
+ $element.click(function() {
2224
+ var className = $(this).data("show");
2225
+ $(options.module).removeClass("current").addClass("hide");
2226
+ $("." + className).addClass("current").removeClass("hide");
2227
+ });
2228
+ }
2229
+
2230
+ };
2231
+
2232
+ $.fn.iSwitch = function (option) {
2233
+ return this.each(function () {
2234
+ var $this = $(this);
2235
+ var data = $this.data("be.iswitch");
2236
+
2237
+ var options = $.extend({}, ISwitch.DEFAULTS, $this.data(), typeof option == "object" && option);
2238
+ if (!data)
2239
+ $this.data("be.iswitch", (data = new ISwitch(this, options)));
2240
+ else
2241
+ data["init"]();
2242
+ });
2243
+ };
2244
+ }(jQuery);
2245
+
2246
+
2247
+ /* ========================================================================
2248
+ * 12. 管理后台模式TAB页面
2249
+ * 2017年2月8日19:46:03
2250
+ * ========================================================================
2251
+
2252
+ $(".a").iTab();
2253
+
2254
+ <a href="#" class="a" data-page="test1.jsp">aaa</a>
2255
+ <a href="#" class="a" data-page="test2.jsp">aaa</a>
2256
+
2257
+ <div id="be-main" class="tab-panel ce-tab-panel">
2258
+ <ul class="nav nav-tabs" >
2259
+ <li class="active">
2260
+ <a href="#be-main-p1" data-toggle="tab">Home
2261
+ </a>
2262
+ <button class="close">X</button>
2263
+ </li>
2264
+ <li><a href="#be-main-p2" data-toggle="tab">Profile</a><button class="close">X</button></li>
2265
+ </ul>
2266
+
2267
+ <div class="tab-content">
2268
+ <div class="tab-pane fade in active" id="be-main-p1">a</div>
2269
+ <div class="tab-pane fade" id="be-main-p2">b</div>
2270
+ </div>
2271
+ </div>
2272
+ * ======================================================================== */
2273
+ +function ($) {
2274
+
2275
+ var ITab = function (element, options) {
2276
+ this.$element = $(element);
2277
+ this.options = $.extend({}, this.DEFAULTS, options);
2278
+
2279
+ this.init(this.options);
2280
+ };
2281
+
2282
+ ITab.DEFAULTS = {
2283
+ module: "#itab-main",
2284
+ isReload: false
2285
+ };
2286
+
2287
+ ITab.prototype.init = function (options) {
2288
+ var $element = this.$element;
2289
+ this.remove(options);
2290
+ };
2291
+
2292
+ ITab.prototype.add = function (element) {
2293
+ var $element = $(element);
2294
+ var page = $element.data("page");
2295
+ var isReload = $element.data("reload");
2296
+ var i = page.replaceAll("\\.", "-").replaceAll("\\/", "-");
2297
+ var isOpen = $("#be-main-p" + (i + 1)).size() >= 1;
2298
+
2299
+ var module = ITab.DEFAULTS.module;
2300
+ if (isOpen) {
2301
+ $(".nav-tabs li > a[data-page='" + page + "']", module).click();
2302
+
2303
+ if (isReload) {
2304
+ var data = new Object();
2305
+ var t = $element.data();
2306
+ for (var p in t) {
2307
+ var isBs = p.indexOf(".");
2308
+ if (isBs <= 0)
2309
+ data[p] = t[p];
2310
+ }
2311
+ $("#be-main-p" + (i + 1)).load(page, data, function() {});
2312
+ }
2313
+ } else {
2314
+
2315
+ var len = $(".nav-tabs li", module).size();
2316
+ var name = $element.data("name");
2317
+ if (!name)
2318
+ name = $element.text();
2319
+
2320
+ if (len) {
2321
+ $(".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>");
2322
+ $(".tab-content .tab-pane:last", module).after("<div class=\"tab-pane fade\" id=\"be-main-p" + (i + 1) + "\"></div>");
2323
+ $(".nav-tabs li:last > a", module).click();
2324
+ } else {
2325
+ $(".nav-tabs", module).html("<li><a href=\"#be-main-p" + (i + 1) + "\" data-toggle=\"tab\">" + name + "</a><button class=\"close\">X</button></li>");
2326
+ $(".tab-content", module).html("<div class=\"tab-pane fade\" id=\"be-main-p" + (i + 1) + "\"></div>");
2327
+ $(".nav-tabs li:last > a", module).click();
2328
+ }
2329
+
2330
+ $(".nav-tabs li:last > a", module).attr("data-page", page);
2331
+
2332
+ var data = new Object();
2333
+ var t = $element.data();
2334
+ for (var p in t) {
2335
+ var isBs = p.indexOf(".");
2336
+ if (isBs <= 0)
2337
+ data[p] = t[p];
2338
+ }
2339
+
2340
+ $("#be-main-p" + (i + 1)).load(page, data, function() {});
2341
+ }
2342
+ };
2343
+
2344
+ ITab.prototype.remove = function (options) {
2345
+ var t = this.$element;
2346
+ $(options.module).on("click", ".close", function() {
2347
+ var html = $(".nav-tabs", options.module).html();
2348
+
2349
+ var target = $(this).parents("li");
2350
+ var isActive = target.hasClass("active");
2351
+
2352
+ if (isActive) {
2353
+ $(".nav-tabs", options.module).html(html.replace("<li class=\"active\">" + target.html() + "</li>", ""));
2354
+ var href = $("a", target).attr("href");
2355
+ $(href).attr("id", "").html("");
2356
+ $(".nav-tabs li:last > a", options.module).click();
2357
+ } else {
2358
+ var href = $("a", target).attr("href");
2359
+ $(href).attr("id", "").html("");
2360
+ $(".nav-tabs", options.module).html(html.replace("<li>" + target.html() + "</li>", "").replace("<li class=\"\">" + target.html() + "</li>", ""));
2361
+ }
2362
+ })
2363
+ };
2364
+
2365
+ $.fn.iTab = function (option) {
2366
+ return this.each(function () {
2367
+ var $this = $(this);
2368
+ var data = $this.data("be.itab");
2369
+
2370
+ var options = $.extend({}, ITab.DEFAULTS, $this.data(), typeof option == "object" && option);
2371
+ if (!data)
2372
+ $this.data("be.itab", (data = new ITab(this, options)));
2373
+ else
2374
+ data["init"]();
2375
+ });
2376
+ };
2377
+
2378
+ $(document).on("click", "[data-toggle='itab']", function(e) {
2379
+ ITab.prototype.add(this);
2380
+ });
2381
+ }(jQuery);
2382
+
2383
+
2384
+ /* ========================================================================
2385
+ * 13. 多选框反选
2386
+ * 2017年6月19日10:53:26
2387
+ * ========================================================================
2388
+
2389
+ $("#be-reverse-check").checkReverse({
2390
+ targets: ".be-check"
2391
+ })
2392
+
2393
+ <a href="#" id="be-reverse-check"/>反选</a>
2394
+ <input type="checkbox" class="be-check" checked="checked"/>选项一
2395
+ <input type="checkbox" class="be-check"/>选项二
2396
+
2397
+ * ======================================================================== */
2398
+ +function ($) {
2399
+
2400
+ var CheckReverse = function (element, options) {
2401
+ this.$element = $(element);
2402
+ this.options = $.extend({}, this.DEFAULTS, options);
2403
+
2404
+ this.$element.on("click", this.options, this.init);
2405
+ };
2406
+
2407
+ CheckReverse.DEFAULTS = {
2408
+ targets: ".be-check",
2409
+ checkedFlag: "checked-now",
2410
+ uncheckedFlag: "unchecked-now"
2411
+ };
2412
+
2413
+ CheckReverse.prototype.init = function (e) {
2414
+ var options = e.data;
2415
+ $(options.targets).addClass(options.uncheckedFlag);
2416
+ $(options.targets + ":checked").removeClass(options.uncheckedFlag).addClass(options.checkedFlag);
2417
+
2418
+ var data = e.data;
2419
+ var a = $("." + data.checkedFlag);
2420
+ var b = $("." + data.uncheckedFlag);
2421
+ a.removeClass(data.checkedFlag).addClass(data.uncheckedFlag).prop("checked", false);
2422
+ b.addClass(data.checkedFlag).removeClass(data.uncheckedFlag).prop("checked", true);
2423
+ };
2424
+
2425
+ CheckReverse.prototype.destroy = function () {
2426
+ $(this).removeData("be.checkreverse");
2427
+ };
2428
+
2429
+ $.fn.checkReverse = function (option) {
2430
+ return this.each(function () {
2431
+ var $this = $(this);
2432
+ var data = $this.data("be.checkreverse");
2433
+ var options = $.extend({}, CheckReverse.DEFAULTS, $this.data(), typeof option == "object" && option);
2434
+
2435
+ if (!data) $this.data("be.checkreverse", (data = new CheckReverse(this, options)));
2436
+ if (typeof option == "string") data[option]();
2437
+ });
2438
+ };
2439
+ }(jQuery);
2440
+
2441
+
2442
+ /* ========================================================================
2443
+ * 14. 数字增加减少,购物数量控制
2444
+ * 2018年1月20日22:14:46
2445
+ * ========================================================================
2446
+
2447
+ $(".fmc1").itemCount({num: 6});
2448
+
2449
+ <div class="fm-count fmc1">
2450
+ <input class="form-control fmc-result" type="text" value="1" readonly="">
2451
+ <div class="fmc-btns">
2452
+ <i class="fmc-plus fa fa-angle-up"></i>
2453
+ <i class="fmc-minus fa fa-angle-down"></i>
2454
+ </div>
2455
+ </div>
2456
+
2457
+ * ======================================================================== */
2458
+ +function ($) {
2459
+
2460
+ var ItemCount = function (element, options) {
2461
+ this.$element = $(element);
2462
+ this.options = $.extend({}, this.DEFAULTS, options);
2463
+
2464
+ this.init(this);
2465
+ };
2466
+
2467
+ ItemCount.DEFAULTS = {
2468
+ num: 1
2469
+ };
2470
+
2471
+ ItemCount.prototype.init = function (e) {
2472
+ var $this = $(e.$element),
2473
+ options = e.options,
2474
+ $plus = $this.find(".fmc-plus"),
2475
+ $minus = $this.find(".fmc-minus"),
2476
+ $result = $this.find(".fmc-result"),
2477
+ resultVal = parseInt($result.val());
2478
+
2479
+ $plus.on("click", function (e) {
2480
+ e.preventDefault();
2481
+ resultVal += options.num;
2482
+ $result.val(resultVal);
2483
+ });
2484
+
2485
+ $minus.on("click", function (e) {
2486
+ e.preventDefault();
2487
+
2488
+ if (resultVal - options.num >= 0) {
2489
+ resultVal -= options.num;
2490
+
2491
+ $result.val(resultVal);
2492
+ } else {
2493
+ return false;
2494
+ }
2495
+ });
2496
+ };
2497
+
2498
+ ItemCount.prototype.destroy = function () {
2499
+ $(this).removeData("be.itemcount");
2500
+ };
2501
+
2502
+ $.fn.itemCount = function (option) {
2503
+ return this.each(function () {
2504
+ var $this = $(this);
2505
+ var data = $this.data("be.itemcount");
2506
+ var options = $.extend({}, ItemCount.DEFAULTS, $this.data(), typeof option == "object" && option);
2507
+
2508
+ if (!data) $this.data("be.itemcount", (data = new ItemCount(this, options)));
2509
+ if (typeof option == "string") data[option]();
2510
+ });
2511
+ };
2512
+ }(jQuery);
2513
+
2514
+
2515
+
2516
+ /* ========================================================================
2517
+ * 15. 绘制点线动画
2518
+ * 2018年6月2日09:54:29
2519
+ * ========================================================================
2520
+
2521
+ <script type="text/javascript" src="WEB/js/tweenlite/easepack.min.js"></script>
2522
+ <script type="text/javascript" src="WEB/js/tweenlite/tweenlite.min.js"></script>
2523
+
2524
+ $(function() {
2525
+ $("#container").lineEffect({
2526
+ //pointColor: "rgba(0, 0, 0, 1)",
2527
+ //lineColor: "0, 0, 0" ,
2528
+ //height: 302,
2529
+ isWindowWidth: true,
2530
+ num: 11,
2531
+ canvasId: "iCanvas"
2532
+ });
2533
+ })
2534
+
2535
+
2536
+ <div id="container" >
2537
+ <canvas id="iCanvas"></canvas>
2538
+ </div>
2539
+
2540
+ * ======================================================================== */
2541
+ +function ($) {
2542
+
2543
+ var LineEffect = function (element, options) {
2544
+ this.$element = $(element);
2545
+ this.options = $.extend({}, this.DEFAULTS, options);
2546
+
2547
+ this.init(this);
2548
+ };
2549
+
2550
+ LineEffect.DEFAULTS = {
2551
+ canvasId: "targetCanvas",
2552
+ animateHeader: true,
2553
+
2554
+ width: window.innerWidth,
2555
+ height: window.innerHeight,
2556
+ isWindowWidth: false,
2557
+ isWindowHeight: false,
2558
+ num: 20,
2559
+
2560
+ pointColor: "156,217,249", //点颜色
2561
+ lineColor: "156,217,249" //线颜色
2562
+ };
2563
+
2564
+
2565
+ LineEffect.prototype.init = function (e) {
2566
+ var $this = $(e.$element),
2567
+ options = e.options,
2568
+ thisTarget = this;
2569
+
2570
+
2571
+ var target = {x: options.width/2, y: options.height/2};
2572
+
2573
+ var canvas = document.getElementById(options.canvasId);
2574
+ canvas.width = options.width;
2575
+ canvas.height = options.height;
2576
+ var ctx = canvas.getContext("2d");
2577
+
2578
+ // create points
2579
+ var points = [];
2580
+ for(var x = 0; x < options.width; x = x + options.width / options.num) {
2581
+ for(var y = 0; y < options.height; y = y + options.height / options.num) {
2582
+ var px = x + Math.random() * options.width / options.num;
2583
+ var py = y + Math.random() * options.height / options.num;
2584
+ var p = {x: px, originX: px, y: py, originY: py };
2585
+ points.push(p);
2586
+ }
2587
+ }
2588
+
2589
+ // for each point find the 5 closest points
2590
+ for(var i = 0; i < points.length; i++) {
2591
+ var closest = [];
2592
+ var p1 = points[i];
2593
+ for(var j = 0; j < points.length; j++) {
2594
+ var p2 = points[j]
2595
+ if(!(p1 == p2)) {
2596
+ var placed = false;
2597
+ for(var k = 0; k < 5; k++) {
2598
+ if(!placed) {
2599
+ if(closest[k] == undefined) {
2600
+ closest[k] = p2;
2601
+ placed = true;
2602
+ }
2603
+ }
2604
+ }
2605
+
2606
+ for(var k = 0; k < 5; k++) {
2607
+ if(!placed) {
2608
+ if(thisTarget.getDistance(p1, p2) < thisTarget.getDistance(p1, closest[k])) {
2609
+ closest[k] = p2;
2610
+ placed = true;
2611
+ }
2612
+ }
2613
+ }
2614
+ }
2615
+ }
2616
+ p1.closest = closest;
2617
+ }
2618
+
2619
+
2620
+ // assign a circle to each point
2621
+ for(var i in points) {
2622
+ var c = new thisTarget.Circle(options, points[i], 2 + Math.random() * 2);
2623
+ points[i].circle = c;
2624
+ }
2625
+ options.points = points;
2626
+ thisTarget.initAnimation(options, ctx, target);
2627
+ thisTarget.addListeners(options, target, canvas);
2628
+ };
2629
+
2630
+
2631
+
2632
+ LineEffect.prototype.getDistance = function(p1, p2) {
2633
+ return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
2634
+ };
2635
+
2636
+
2637
+ LineEffect.prototype.Circle = function(options, pos, rad) {
2638
+ var _this = this;
2639
+ // constructor
2640
+ (function() {
2641
+ _this.pos = pos || null;
2642
+ _this.radius = rad || null;
2643
+ // _this.color = color || null;
2644
+ })();
2645
+
2646
+
2647
+ this.draw = function(ctx) {
2648
+ if(!_this.active) return;
2649
+ ctx.beginPath();
2650
+ ctx.arc(_this.pos.x, _this.pos.y, _this.radius, 0, 2 * Math.PI, false);
2651
+ ctx.fillStyle = "rgba(" + options.pointColor + "," + _this.active + ")";
2652
+
2653
+ ctx.fill();
2654
+ };
2655
+ };
2656
+
2657
+
2658
+ /**----------------- 开始绘制动画效果 -----------------------**/
2659
+ LineEffect.prototype.initAnimation = function(options, ctx, target) {
2660
+ var thisTarget = this;
2661
+ thisTarget.animate(options, ctx, target);
2662
+ for(var i in options.points) {
2663
+ thisTarget.shiftPoint(options.points[i]);
2664
+ }
2665
+ }
2666
+
2667
+ LineEffect.prototype.animate = function(options, ctx, target) {
2668
+ var thisTarget = this;
2669
+ if(options.animateHeader) {
2670
+
2671
+ var points = options.points;
2672
+ ctx.clearRect(0, 0, options.width, options.height);
2673
+ for(var i in points) {
2674
+ // detect points in range
2675
+ if(Math.abs(thisTarget.getDistance(target, points[i])) < 4000) {
2676
+ points[i].active = 0.3;
2677
+ points[i].circle.active = 0.6;
2678
+ } else if(Math.abs(thisTarget.getDistance(target, points[i])) < 20000) {
2679
+ points[i].active = 0.1;
2680
+ points[i].circle.active = 0.3;
2681
+ } else if(Math.abs(thisTarget.getDistance(target, points[i])) < 40000) {
2682
+ points[i].active = 0.02;
2683
+ points[i].circle.active = 0.1;
2684
+ } else {
2685
+ points[i].active = 0;
2686
+ points[i].circle.active = 0;
2687
+ }
2688
+
2689
+ thisTarget.drawLines(options, points[i], ctx);
2690
+ points[i].circle.draw(ctx);
2691
+ }
2692
+ }
2693
+ requestAnimationFrame(function() {
2694
+ thisTarget.animate(options, ctx, target)
2695
+ });
2696
+
2697
+ }
2698
+
2699
+ /**----------------- 开始绘制动画效果 - 点 -----------------------**/
2700
+ LineEffect.prototype.shiftPoint = function(p) {
2701
+ var thisTarget = this;
2702
+ TweenLite.to(p,
2703
+ 1 + 1 * Math.random(),
2704
+ {
2705
+ x: p.originX - 50 + Math.random() * 100,
2706
+ y: p.originY - 50 + Math.random() * 100,
2707
+ ease:Circ.easeInOut,
2708
+ onComplete: function() {
2709
+ thisTarget.shiftPoint(p);
2710
+ }
2711
+ }
2712
+ );
2713
+ }
2714
+
2715
+ /**----------------- 开始绘制动画效果 - 线 -----------------------**/
2716
+ LineEffect.prototype.drawLines = function(options, p, ctx) {
2717
+ if(!p.active) return;
2718
+ for(var i in p.closest) {
2719
+ ctx.beginPath();
2720
+ ctx.moveTo(p.x, p.y);
2721
+ ctx.lineTo(p.closest[i].x, p.closest[i].y);
2722
+ ctx.strokeStyle = "rgba(" + options.lineColor + "," + p.active + ")";
2723
+ ctx.stroke();
2724
+ }
2725
+ }
2726
+
2727
+
2728
+ /**----------------- 监听事件,移动鼠标, 滚动, 改变屏幕大小 -----------------------**/
2729
+ LineEffect.prototype.addListeners = function(options, target, canvas) {
2730
+ var thisTarget = this;
2731
+ if(!('ontouchstart' in window)) {
2732
+ window.addEventListener("mousemove",
2733
+ function(e) {
2734
+ thisTarget.mouseMove(e, target);
2735
+ }
2736
+ );
2737
+ }
2738
+ window.addEventListener("scroll",
2739
+ function(e) {
2740
+ thisTarget.scrollCheck(options);
2741
+ }
2742
+ );
2743
+ window.addEventListener("resize",
2744
+ function(e) {
2745
+ thisTarget.resize(options, canvas);
2746
+ }
2747
+ );
2748
+ }
2749
+
2750
+ LineEffect.prototype.mouseMove = function(e, target) {
2751
+ var offsetTop = this.$element.offset().top
2752
+ var offsetLeft = this.$element.offset().left
2753
+
2754
+ var posx = posy = 0;
2755
+ if (e.pageX || e.pageY) {
2756
+ posx = e.pageX;
2757
+ posy = e.pageY;
2758
+ }
2759
+ else if (e.clientX || e.clientY) {
2760
+ posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
2761
+ posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
2762
+ }
2763
+ target.x = posx - offsetLeft;
2764
+ target.y = posy - offsetTop;
2765
+ }
2766
+
2767
+ LineEffect.prototype.scrollCheck = function(options) {
2768
+ if(document.body.scrollTop > options.height) options.animateHeader = false;
2769
+ else options.animateHeader = true;
2770
+ }
2771
+
2772
+ LineEffect.prototype.resize = function(options, canvas) {
2773
+ if (options.isWindowWidth)
2774
+ canvas.width = window.innerWidth;
2775
+
2776
+ if (options.isWindowHeight)
2777
+ canvas.height = window.innerHeight;
2778
+
2779
+ }
2780
+
2781
+
2782
+ /**----------------- 销毁 -----------------------**/
2783
+ LineEffect.prototype.destroy = function () {
2784
+ $(this).removeData("be.lineEffect");
2785
+ };
2786
+
2787
+
2788
+ $.fn.lineEffect = function (option) {
2789
+ return this.each(function () {
2790
+ var $this = $(this);
2791
+ var data = $this.data("be.lineEffect");
2792
+ options = $.extend({}, LineEffect.DEFAULTS, $this.data(), typeof option == "object" && option);
2793
+
2794
+ if (!data) $this.data("be.lineEffect", (data = new LineEffect(this, options)));
2795
+ if (typeof option == "string") data[option]();
2796
+ });
2797
+ };
2798
+ }(jQuery);
2799
+
2800
+
2801
+ /* ========================================================================
2802
+ * 16.底部按钮快速移动到顶部
2803
+ * 2018年7月3日11:55:06
2804
+ * ========================================================================
2805
+
2806
+ $(function() {
2807
+ //参数赋值,js构造方法赋值优先级高于html中data-*中赋值
2808
+ $(".ce-gotop").gotop({
2809
+ position: {
2810
+ "bottom": 15,
2811
+ "right": 15
2812
+ },
2813
+ showeffect: "zoomIn",
2814
+ type: "fixed",
2815
+ offsettop: "400"
2816
+ });
2817
+ })
2818
+
2819
+ <a class="ce-gotop" href="#">
2820
+ <i class="fa fa-angle-up"></i>
2821
+ </a>
2822
+ 或者可以直接在a标签添加如下属性
2823
+ data-type="fixed"
2824
+ data-position='{
2825
+ "bottom": 15,
2826
+ "right": 15
2827
+ }'
2828
+ data-offsettop="400"
2829
+ data-showeffect="zoomIn"
2830
+
2831
+ * ======================================================================== */
2832
+ +function ($) {
2833
+
2834
+ var GoTop = function (element, options) {
2835
+ this.options = $.extend({}, this.DEFAULTS, options);
2836
+ this.$element = $(element);
2837
+
2838
+ this.init(this.$element, this.options);
2839
+ };
2840
+
2841
+ GoTop.DEFAULTS = {
2842
+ position: {
2843
+ "bottom": 15,
2844
+ "right": 15
2845
+ },
2846
+ showeffect: "zoomIn",
2847
+ hideeffect: "zoomOut",
2848
+ type: "fixed",
2849
+ offsettop: "400",
2850
+ compensation: "#js-header"
2851
+ };
2852
+
2853
+ GoTop.prototype.init = function (element, options) {
2854
+ this.$element = $(element);
2855
+ this.options = $.extend({}, this.DEFAULTS, options);
2856
+
2857
+ this.initGoTop(this);
2858
+ };
2859
+
2860
+ GoTop.prototype.initGoTop = function (e) {
2861
+ var options = e.options;
2862
+ e.$element.each(function (i, el) {
2863
+ //Variables
2864
+
2865
+ var $this = $(el),
2866
+ $target = $this.data("target"),
2867
+ type = options.type,
2868
+ showeffect = options.showeffect,
2869
+ position = options.position,
2870
+ compensation = $(options.compensation).outerHeight(),
2871
+ offsettop = options.offsettop,
2872
+ hideeffect = options.hideeffect;
2873
+
2874
+ $this.addClass("animated").css({
2875
+ "display": "inline-block",
2876
+ "position": type,
2877
+ "opacity": 0
2878
+ });
2879
+
2880
+ if (type == "fixed" || type == "absolute") {
2881
+ $this.css(position);
2882
+ }
2883
+
2884
+ $this.on("click", function (e) {
2885
+ e.preventDefault();
2886
+
2887
+ $("html, body").stop().animate({
2888
+ "scrollTop": $target ? $($target).offset().top - compensation : 0
2889
+ }, 300);
2890
+ });
2891
+
2892
+ if (!offsettop && !$this.hasClass("animated-running")) {
2893
+ if ($this.offset().top <= $(window).height()) {
2894
+ $this.addClass("animated-running " + showeffect).css({
2895
+ "opacity": ""
2896
+ });
2897
+ }
2898
+ }
2899
+
2900
+ $(window).on("scroll", function () {
2901
+ if (offsettop) {
2902
+ if ($(window).scrollTop() >= offsettop && !$this.hasClass("animated-running")) {
2903
+ $this.addClass("animated-running " + showeffect).css({
2904
+ "opacity": ""
2905
+ });
2906
+ $this.removeClass(hideeffect);
2907
+ } else if ($(window).scrollTop() <= offsettop && $this.hasClass("animated-running")) {
2908
+ $this.removeClass("animated-running " + showeffect).css({
2909
+ "opacity": 0
2910
+ });
2911
+ $this.addClass(hideeffect);
2912
+ }
2913
+ } else {
2914
+ var thisOffsetTop = $this.offset().top;
2915
+
2916
+ if (!$this.hasClass("animated-running")) {
2917
+ if ($(window).scrollTop() >= thisOffsetTop - $(window).height()) {
2918
+ $this.addClass("animated-running " + showeffect).css({
2919
+ "opacity": ""
2920
+ });
2921
+ $this.removeClass(hideeffect);
2922
+ }
2923
+ }
2924
+ }
2925
+ });
2926
+
2927
+ $(window).trigger("scroll");
2928
+ //Actions
2929
+ //collection = collection.add($this);
2930
+ });
2931
+ };
2932
+
2933
+ var old = $.fn.gotop;
2934
+ $.fn.gotop = function (option) {
2935
+ return this.each(function () {
2936
+ var $this = $(this);
2937
+
2938
+ var data = $this.data("be.gotop");
2939
+ var options = $.extend({}, GoTop.DEFAULTS, $this.data(), typeof option == "object" && option);
2940
+
2941
+ if (!data)
2942
+ $this.data("be.gotop", (data = new GoTop(this, options)));
2943
+ else
2944
+ data["init"]();
2945
+
2946
+ if (typeof option == "string") data[option]();
2947
+ });
2948
+ };
2949
+
2950
+ $.fn.gotop.Constructor = GoTop;
2951
+ $.fn.gotop.noConflict = function () {
2952
+ $.fn.gotop = old;
2953
+ return this;
2954
+ };
2955
+ }(jQuery);
2956
+
2957
+
2958
+ /* ========================================================================
2959
+ * 17.背景滚动特效
2960
+ * 2019年1月16日12:06:19
2961
+ * ========================================================================
2962
+
2963
+ $(".ce-bg-ef").scrollBackground({speed: 6});
2964
+
2965
+ 样式:
2966
+ .ce-bg-ef {
2967
+ width: 100%;
2968
+ height: 400px;
2969
+ background: url("http://120.24.229.95/file/images/sample/anime/0/anime1470402086147.jpg");
2970
+
2971
+ transition: all 0.7s ease-in-out;
2972
+ -o-transition: all 0.7s ease-in-out;
2973
+ -ms-transition: all 0.7s ease-in-out;
2974
+ -moz-transition: all 0.7s ease-in-out;
2975
+ -webkit-transition: all 0.7s ease-in-out;
2976
+ }
2977
+ * ======================================================================== */
2978
+ +function ($) { "use strict";
2979
+
2980
+ // SCROLLBACKGROUND CLASS DEFINITION
2981
+ // ====================
2982
+
2983
+ var ScrollBackground = function(element, options) {
2984
+ this.element = $(element);
2985
+ this.options = $.extend({}, this.DEFAULTS, options);
2986
+ this.init(options);
2987
+ }
2988
+
2989
+ ScrollBackground.DEFAULTS = {
2990
+ speed: 5
2991
+ };
2992
+
2993
+ ScrollBackground.prototype.init = function (options) {
2994
+ var $this = this.element;
2995
+
2996
+ $this.css("background-position", "50% 0px");
2997
+ $(window).scroll(function() {
2998
+ var y = $this.offset().top;
2999
+ var h = $this.height();
3000
+ var windowY = $(this).scrollTop();
3001
+ var windowH = $(this).height();
3002
+ if (windowH + windowY > y && windowH + windowY < y + windowH + h) {
3003
+ var bgY = (y + h - windowY) / options.speed;
3004
+ $this.css("background-position", "50% -" + bgY + "px");
3005
+ }
3006
+ });
3007
+ }
3008
+
3009
+ // SCROLLBACKGROUND PLUGIN DEFINITION
3010
+ // =====================
3011
+
3012
+ var old = $.fn.scrollBackground
3013
+
3014
+ $.fn.scrollBackground = function ( option ) {
3015
+ return this.each(function () {
3016
+ var $this = $(this)
3017
+ var data = $this.data('bs.scrollbackground');
3018
+ var options = $.extend({}, ScrollBackground.DEFAULTS, $this.data(), typeof option == "object" && option);
3019
+
3020
+ if (!data) $this.data('bs.scrollbackground', (data = new ScrollBackground(this, options)))
3021
+ else if (typeof option == 'string') data[option]();
3022
+ })
3023
+ }
3024
+
3025
+ $.fn.scrollBackground.Constructor = ScrollBackground
3026
+
3027
+
3028
+ // SCROLLBACKGROUND NO CONFLICT
3029
+ // ===============
3030
+
3031
+ $.fn.scrollBackground.noConflict = function () {
3032
+ $.fn.scrollBackground = old
3033
+ return this
3034
+ }
3035
+ }(jQuery);
3036
+
3037
+
3038
+ /* ========================================================================
3039
+ * 18. 鼠标上下左右划入监听实现对应动画
3040
+ * 2022年7月28日 10:50:06
3041
+ * ========================================================================
3042
+
3043
+ $(".ce-thumb").hoverdir({
3044
+ hoverDelay: 0,
3045
+ reverse: false
3046
+ });
3047
+
3048
+ * ======================================================================== */
3049
+ +function ($) {
3050
+ "use strict";
3051
+
3052
+ var HoverDir = function(element, options) {
3053
+ this.element = $(element);
3054
+ this.options = $.extend({}, this.DEFAULTS, options);
3055
+ this.init(options);
3056
+ }
3057
+ HoverDir.DEFAULTS = {
3058
+ hoverDelay: 0,
3059
+ reverse: false
3060
+ };
3061
+
3062
+ HoverDir.prototype.init = function (options) {
3063
+ this.options = $.extend(true, {}, HoverDir.DEFAULTS, options);
3064
+ this._loadEvents();
3065
+ },
3066
+ HoverDir.prototype._loadEvents = function () {
3067
+ var _self = this;
3068
+ debug(_self.options.hoverDelay);
3069
+ this.element.on("mouseenter.hoverdir, mouseleave.hoverdir", function (event) {
3070
+ var $el = $(this), evType = event.type, $hoverElem = $el.find("div"), direction = _self._getDir($el, { x: event.pageX, y: event.pageY }), hoverClasses = _self._getClasses(direction);
3071
+ $hoverElem.removeClass();
3072
+ if (evType === "mouseenter") {
3073
+ $hoverElem.hide().addClass(hoverClasses.from);
3074
+ clearTimeout(_self.tmhover);
3075
+ _self.tmhover = setTimeout(function () {
3076
+ $hoverElem.show(0, function () {
3077
+ $(this).addClass("be-ts").addClass(hoverClasses.to);
3078
+ });
3079
+ }, _self.options.hoverDelay);
3080
+ } else {
3081
+ $hoverElem.addClass("be-ts");
3082
+ clearTimeout(_self.tmhover);
3083
+ $hoverElem.addClass(hoverClasses.from);
3084
+ }
3085
+ });
3086
+ },
3087
+ HoverDir.prototype._getDir = function ($el, coordinates) {
3088
+ var w = $el.width(),
3089
+ h = $el.height(),
3090
+ x = (coordinates.x - $el.offset().left - (w / 2)) * (w > h ? (h / w) : 1),
3091
+ y = (coordinates.y - $el.offset().top - (h / 2)) * (h > w ? (w / h) : 1),
3092
+ direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
3093
+ return direction;
3094
+ },
3095
+ HoverDir.prototype._getClasses = function (direction) {
3096
+ var fromClass, toClass;
3097
+ switch (direction) {
3098
+ case 0: (!this.options.reverse) ? fromClass = "ce-slideFromTop" : fromClass = "ce-slideFromBottom"; toClass = "ce-slideTop"; break;
3099
+ case 1: (!this.options.reverse) ? fromClass = "ce-slideFromRight" : fromClass = "ce-slideFromLeft"; toClass = "ce-slideLeft"; break;
3100
+ case 2: (!this.options.reverse) ? fromClass = "ce-slideFromBottom" : fromClass = "ce-slideFromTop"; toClass = "ce-slideTop"; break;
3101
+ case 3: (!this.options.reverse) ? fromClass = "ce-slideFromLeft" : fromClass = "ce-slideFromRight"; toClass = "ce-slideLeft"; break;
3102
+ };
3103
+ return { from: fromClass, to: toClass };
3104
+ }
3105
+
3106
+ $.fn.hoverdir = function(options) {
3107
+ if (typeof options === "string") {
3108
+ var args = Array.prototype.slice.call(arguments, 1);
3109
+ this.each(function () {
3110
+ var instance = $.data(this, "hoverdir");
3111
+ if (!instance) {
3112
+ return;
3113
+ }
3114
+ if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
3115
+ return;
3116
+ }
3117
+ instance[options].apply(instance, args);
3118
+ });
3119
+ } else {
3120
+ this.each(function () {
3121
+ var instance = $.data(this, "hoverdir");
3122
+ if (!instance) {
3123
+ $.data(this, "hoverdir", new HoverDir(this, options));
3124
+ }
3125
+ });
3126
+ }
3127
+ return this;
3128
+ }
3129
+ }(jQuery);
3130
+
3131
+
3132
+ /* ========================================================================
3133
+ * 19. niceSelect下拉框
3134
+ * 2022年8月14日 21:41:21
3135
+ * ========================================================================
3136
+ //初始化
3137
+ $(".ns-select").niceSelect();
3138
+
3139
+ //获取选中选项值
3140
+ $(".ns-select").change(function() {
3141
+ debug($(".ce-nice-select.ns-select .list .selected").data("value"));
3142
+ debug($(".ce-nice-select.ns-select .list .selected").html());
3143
+ })
3144
+ * ======================================================================== */
3145
+ +function ($) {
3146
+ "use strict";
3147
+
3148
+ $.fn.niceSelect = function(options) {
3149
+ if (typeof method == 'string') {
3150
+ if (method == 'update') {
3151
+ this.each(function() {
3152
+ var $select = $(this);
3153
+ var $dropdown = $(this).next('.ce-nice-select');
3154
+ var open = $dropdown.hasClass('open');
3155
+
3156
+ if ($dropdown.length) {
3157
+ $dropdown.remove();
3158
+ create_nice_select($select);
3159
+
3160
+ if (open) {
3161
+ $select.next().trigger('click');
3162
+ }
3163
+ }
3164
+ });
3165
+ } else if (method == 'destroy') {
3166
+ this.each(function() {
3167
+ var $select = $(this);
3168
+ var $dropdown = $(this).next('.ce-nice-select');
3169
+
3170
+ if ($dropdown.length) {
3171
+ $dropdown.remove();
3172
+ $select.css('display', '');
3173
+ }
3174
+ });
3175
+ if ($('.ce-nice-select').length == 0) {
3176
+ $(document).off('.nice_select');
3177
+ }
3178
+ } else {}
3179
+ return this;
3180
+ }
3181
+
3182
+ this.hide();
3183
+
3184
+ this.each(function() {
3185
+ var $select = $(this);
3186
+ if (!$select.next().hasClass('ce-nice-select')) {
3187
+ create_nice_select($select);
3188
+ }
3189
+ });
3190
+
3191
+ function create_nice_select($select) {
3192
+ $select.after($('<div></div>')
3193
+ .addClass('ce-nice-select')
3194
+ .addClass($select.attr('class') || '')
3195
+ .addClass($select.attr('disabled') ? 'disabled' : '')
3196
+ .attr('tabindex', $select.attr('disabled') ? null : '0')
3197
+ .html('<span class="current"></span><ul class="list"></ul>')
3198
+ );
3199
+
3200
+ var $dropdown = $select.next();
3201
+ var $options = $select.find('option');
3202
+ var $selected = $select.find('option:selected');
3203
+
3204
+ $dropdown.find('.current').html($selected.data('display') || $selected.text());
3205
+
3206
+ $options.each(function(i) {
3207
+ var $option = $(this);
3208
+ var display = $option.data('display');
3209
+
3210
+ $dropdown.find('ul').append($('<li></li>')
3211
+ .attr('data-value', $option.val())
3212
+ .attr('data-display', (display || null))
3213
+ .addClass('option' + ($option.is(':selected') ? ' selected' : '') + ($option.is(':disabled') ? ' disabled' : ''))
3214
+ .html($option.text())
3215
+ );
3216
+ });
3217
+ }
3218
+
3219
+ $(document).off('.nice_select');
3220
+
3221
+ $(document).on('click.nice_select', '.ce-nice-select', function(event) {
3222
+ var $dropdown = $(this);
3223
+ $('.ce-nice-select').not($dropdown).removeClass('open');
3224
+ $dropdown.toggleClass('open');
3225
+
3226
+ if ($dropdown.hasClass('open')) {
3227
+ $dropdown.find('.option');
3228
+ $dropdown.find('.focus').removeClass('focus');
3229
+ $dropdown.find('.selected').addClass('focus');
3230
+ } else {
3231
+ $dropdown.focus();
3232
+ }
3233
+ });
3234
+
3235
+ $(document).on('click.nice_select', function(event) {
3236
+ if ($(event.target).closest('.ce-nice-select').length === 0) {
3237
+ $('.ce-nice-select').removeClass('open').find('.option');
3238
+ }
3239
+ });
3240
+
3241
+ $(document).on('click.nice_select', '.ce-nice-select .option:not(.disabled)', function(event) {
3242
+ var $option = $(this);
3243
+ var $dropdown = $option.closest('.ce-nice-select');
3244
+
3245
+ $dropdown.find('.selected').removeClass('selected');
3246
+ $option.addClass('selected');
3247
+
3248
+ var text = $option.data('display') || $option.text();
3249
+ $dropdown.find('.current').text(text);
3250
+
3251
+ $dropdown.prev('select').val($option.data('value')).trigger('change');
3252
+ });
3253
+
3254
+ $(document).on('keydown.nice_select', '.ce-nice-select', function(event) {
3255
+ var $dropdown = $(this);
3256
+ var $focused_option = $($dropdown.find('.focus') || $dropdown.find('.list .option.selected'));
3257
+
3258
+ if (event.keyCode == 32 || event.keyCode == 13) {
3259
+ if ($dropdown.hasClass('open')) {
3260
+ $focused_option.trigger('click');
3261
+ } else {
3262
+ $dropdown.trigger('click');
3263
+ }
3264
+ return false;
3265
+ } else if (event.keyCode == 40) {
3266
+ if (!$dropdown.hasClass('open')) {
3267
+ $dropdown.trigger('click');
3268
+ } else {
3269
+ var $next = $focused_option.nextAll('.option:not(.disabled)').first();
3270
+ if ($next.length > 0) {
3271
+ $dropdown.find('.focus').removeClass('focus');
3272
+ $next.addClass('focus');
3273
+ }
3274
+ }
3275
+ return false;
3276
+ } else if (event.keyCode == 38) {
3277
+ if (!$dropdown.hasClass('open')) {
3278
+ $dropdown.trigger('click');
3279
+ } else {
3280
+ var $prev = $focused_option.prevAll('.option:not(.disabled)').first();
3281
+ if ($prev.length > 0) {
3282
+ $dropdown.find('.focus').removeClass('focus');
3283
+ $prev.addClass('focus');
3284
+ }
3285
+ }
3286
+ return false;
3287
+ } else if (event.keyCode == 27) {
3288
+ if ($dropdown.hasClass('open')) {
3289
+ $dropdown.trigger('click');
3290
+ }
3291
+ } else if (event.keyCode == 9) {
3292
+ if ($dropdown.hasClass('open')) {
3293
+ return false;
3294
+ }
3295
+ }
3296
+ });
3297
+
3298
+ // Detect CSS pointer-events support, for IE <= 10. From Modernizr.
3299
+ var style = document.createElement('a').style;
3300
+ style.cssText = 'pointer-events:auto';
3301
+ if (style.pointerEvents !== 'auto') {
3302
+ $('html').addClass('no-csspointerevents');
3303
+ }
3304
+ return this;
3305
+ }
3306
+ }(jQuery);
3307
+