arisu.js 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1090 +0,0 @@
1
- /* ========================================================================
2
- * @描述:常用JS方法
3
- * @作者:林舒涛
4
- * ========================================================================
5
-
6
- var base = new Base();
7
-
8
- 原有scroll方法删除,滚动条监听使用ScrollReveal插件
9
-
10
- * ======================================================================== */
11
-
12
- /** *
13
- * @描述:注释范例
14
- * @参数:
15
- * p1: 参数一
16
- * p2: 参数二
17
- * @脚本:
18
- * <pre>
19
- * 示范代码,外层加上pre标签保证显示能换行
20
- * </pre>
21
- * @返回:
22
- * 0: 返回值0
23
- * 1: 返回值1
24
- * @日期:时间
25
- * **/
26
-
27
-
28
-
29
- //window.springmvc = "http://ipc:8084/springmvc/";
30
- window.sp = "/springmvc/";
31
- //window.springmvc = "http://120.24.229.95/springmvc/";
32
-
33
- //window.host = "http://ipc:8084/";
34
- window.host = "http://120.24.229.95/";
35
-
36
- //window.ux = "http://ipc:8084/ext/examples/ux";
37
- //window.ux = "http://120.24.229.95/ext/examples/ux";
38
- window.login = "../login";
39
-
40
- window.server = "//" + document.domain + ":" + window.location.port + "/";
41
-
42
- $(function() {
43
-
44
- // 1、判断客户端是电脑还是移动设备
45
- // var system = {
46
- // win : false,
47
- // mac : false,
48
- // xll : false
49
- // };
50
- // var p = navigator.platform;
51
- // system.win = p.indexOf("Win") == 0;
52
- // system.mac = p.indexOf("Mac") == 0;
53
- // system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
54
- //
55
- // if(system.win || system.mac || system.xll) {
56
- // $("#load").load("pc.jsp", function(){alert("载入对应电脑页面")});
57
- // } else {
58
- // $("#load").load("mobile.jsp", function(){alert("载入对应移动设备页面")});
59
- // }
60
-
61
- // 2、统一添加icon
62
- // $("title").after("<link rel='shortcut icon' type='image/x-icon' href='/ari/WEB/images/logo2.ico' />");
63
-
64
-
65
- // 3、使用插件控制滚动条
66
- // $("#sidebar").niceScroll({
67
- // styler : "fb",
68
- // cursorcolor : "#333",
69
- // cursorwidth : "3",
70
- // cursorborderradius : "10px",
71
- // background : "#fff",
72
- // spacebarenabled : false,
73
- // cursorborder : ""
74
- // });
75
- // $("html").niceScroll({
76
- // styler : "fb",
77
- // cursorcolor : "#333",
78
- // cursorwidth : "7",
79
- // cursorborderradius : "3px",
80
- // background : "#fff",
81
- // spacebarenabled : false,
82
- // cursorborder : "",
83
- // zindex : "1000"
84
- // });
85
-
86
- // 4、添加链接跳转功能到普通标签
87
- // <div data-href="module2.html" data-target="_self" class="pointer">_self</div>,data-target和a中taregt标签一致
88
- $(document).off("click.href").on("click.href", "[data-href]", function(e) {
89
- var href = $(e.currentTarget).data("href");
90
- var target = $(e.currentTarget).data("target");
91
-
92
- if (target == "_self" || target == "_top" || target == "_parent")
93
- window.location.href = href;
94
- else if (target == "_blank" || target == "framename")
95
- window.open(href);
96
- })
97
-
98
-
99
-
100
- $(document).on("click", "[href='#'], .apijs-link", function (e) {e.preventDefault();});
101
-
102
- Base.prototype.menuResponse();
103
- });
104
-
105
-
106
- /** ----------------------------------------- <1> 常用的一些JS方法
107
- **/
108
-
109
- /******
110
- * @描述:替换全部 replace() 方法加强,如果是变量不会替换原变量
111
- * @脚本:"aba".replaceAll("a", "") //b
112
- * @日期:2015年11月4日14:14:48
113
- * **/
114
- String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
115
- if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
116
- return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
117
- } else {
118
- return this.replace(reallyDo, replaceWith);
119
- }
120
- }
121
-
122
- /******
123
- * @描述:清空格
124
- * @脚本:" a ".trim() //a
125
- * @日期:2016年2月14日13:33:46
126
- * **/
127
- String.prototype.trim = function() {
128
- return this.replace(/(^\s*)|(\s*$)/g, "");
129
- }
130
-
131
- /******
132
- * @描述:时间格式化
133
- * @脚本:new Date().format("yyyy-MM-dd hh:mm:ss:SSS")
134
- * @日期:2015年4月15日17:12:41
135
- * **/
136
- Date.prototype.format = function(fmt) {
137
- var o = {
138
- "M+" : this.getMonth() + 1,
139
- "d+" : this.getDate(),
140
- "h+" : this.getHours(),
141
- "m+" : this.getMinutes(),
142
- "s+" : this.getSeconds(),
143
- "q+" : Math.floor((this.getMonth() + 3) / 3),
144
- "S" : this.getMilliseconds()
145
- };
146
- if (/(y+)/.test(fmt))
147
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
148
- for ( var k in o)
149
- if (new RegExp("(" + k + ")").test(fmt))
150
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
151
- return fmt;
152
- }
153
-
154
- /******
155
- * @描述:数组根据下标删除扩展
156
- * @脚本:
157
- * <pre>
158
- * <1> array.remove(0);//删除第一个元素
159
- * <2> array.remove(-1);//删除倒数第一个元素
160
- * <3> array.remove(0, 2);///删除数组中下标为0-2的元素(3个)
161
- * </pre>
162
- * @日期:2016年1月25日13:42:20
163
- * **/
164
- Array.prototype.remove = function(from, to) {
165
- var rest = this.slice((to || from) + 1 || this.length);
166
- this.length = from < 0 ? this.length + from : from;
167
- return this.push.apply(this, rest);
168
- }
169
-
170
- /******
171
- * @描述:删除重复元素
172
- * @脚本:
173
- * <pre>
174
- * var oldArr = new Array(); //之前保存的
175
- * oldArr[0] = 1;
176
- * oldArr[1] = 2;
177
- *
178
- * var newArr = new Array(); //现在保存需要保存的
179
- * newArr[0] = 1;
180
- * newArr[1] = 2;
181
- * newArr[2] = 3;
182
- * newArr[3] = 1;
183
- *
184
- * var onArr = oldArr.concat(newArr);
185
- * console.log(onArr); // (6) [1, 2, 1, 2, 3, 1]
186
- * console.log(onArr.unique()); // (3) [1, 2, 3]
187
- * </pre>
188
- * @日期:2019年5月15日10:01:34
189
- * **/
190
- Array.prototype.unique = function () {
191
- var temp = new Array();
192
- this.sort();
193
- for(i = 0; i < this.length; i++) {
194
- if(this[i] == this[i+1]) {
195
- continue;
196
- }
197
- temp[temp.length]=this[i];
198
- }
199
- return temp;
200
- }
201
-
202
- var Base = function() {};
203
-
204
- /******
205
- * @描述:获取URL中的参数(url?name=alice)
206
- * @脚本:getParam("name"); //alice
207
- * @日期:2015年4月15日17:12:41
208
- * **/
209
- Base.prototype.getParam = function(key) {
210
- var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)", "i");
211
- var r = window.location.search.substr(1).match(reg);
212
- debug(window.location.search)
213
- if (r != null) return unescape(r[2]); return null;
214
- }
215
-
216
- /******
217
- * @描述:获取变量属性数值
218
- * @脚本:
219
- * <pre>
220
- * var o = {abc: "数据正常"}
221
- * var value = base.findPrototype(o, "abc");
222
- * alert(value);//数据正常
223
- * </pre>
224
- * @日期:2016年3月8日14:23:13
225
- * **/
226
- Base.prototype.findPrototype = function(object, prototype) {
227
- var result = "";
228
- for (var p in object)
229
- if (typeof object[p] === "string" && p == prototype)
230
- result = object[p];
231
- return result;
232
- }
233
-
234
- /******
235
- * @描述:删除变量属性
236
- * @脚本:
237
- * <pre>
238
- * var o = {abc: "数据正常"}
239
- * base.removePrototype(o, "abc");
240
- * </pre>
241
- * @日期:2016年3月8日14:23:13
242
- * **/
243
- Base.prototype.removePrototype = function(object, prototype) {
244
- for (var p in object)
245
- if (typeof object[p] === "string" && p == prototype)
246
- delete object[p];
247
- return object;
248
- }
249
-
250
- /******
251
- * @描述:判断两个对象属性以及值是否相等
252
- * @日期:2016年3月9日13:59:37
253
- * **/
254
- Base.prototype.isObjectValueEqual = function(a, b) {
255
- var result = true;
256
- var aProps = Object.getOwnPropertyNames(a);
257
- var bProps = Object.getOwnPropertyNames(b);
258
-
259
- if (aProps.length != bProps.length) {
260
- result = false;
261
- }
262
- for (var i = 0; i < aProps.length; i++) {
263
- var propName = aProps[i];
264
- if (a[propName] !== b[propName]) {
265
- result = false;
266
- }
267
- }
268
- return result;
269
- }
270
-
271
-
272
- /******
273
- * @描述:四舍五入保留n位
274
- * @脚本:toDecimal(3.14159, 2);
275
- * @日期:2015年11月4日14:12:47
276
- * **/
277
- Base.prototype.toDecimal = function(number, save) {
278
- var result = parseFloat(number);
279
- if (result)
280
- result = Math.round(number * Math.pow(10, save)) / Math.pow(10, save);
281
- else
282
- result = 0;
283
- return result;
284
- }
285
-
286
-
287
- /******
288
- * @描述:返回数据为空时设置默认值
289
- * @脚本:
290
- * <pre>
291
- * setDefault(data.id, 0);
292
- * 或者
293
- * var language = base.setDefault(base.getParam("language"), "");
294
- * </pre>
295
- * @日期:2015-10-19 17:36:37
296
- * **/
297
- Base.prototype.setDefault = function(target, defaultVal) {
298
- if (target == null || target == undefined || target == "" || target == "null")
299
- target = defaultVal;
300
- return target;
301
- }
302
-
303
- /******
304
- * @描述:判断变量是否为空
305
- * @脚本:
306
- * <pre>
307
- * if(base.isNull(变量)) {
308
- * } else {
309
- * }
310
- * </pre>
311
- * @日期:2020年1月15日10:34:45
312
- * **/
313
- Base.prototype.isNull = function(target) {
314
- var result = true;
315
- if (target == null || target == undefined || target == "" || target == "null")
316
- result = false;
317
- return result;
318
- }
319
-
320
- /******
321
- * @描述:获取两个数组相同的元素
322
- * @脚本:
323
- * <pre>
324
- * var oldArr = new Array(); //之前保存的
325
- * oldArr[0] = 1;
326
- * oldArr[1] = 2;
327
- * var newArr = new Array(); //现在保存需要保存的
328
- * newArr[0] = 1;
329
- * newArr[1] = 2;
330
- * newArr[2] = 3;
331
- * newArr[3] = 1;
332
- *
333
- * var a = base.same(oldArr, newArr);
334
- * console.log(a);//(2) [1, 2]
335
- * </pre>
336
- * @日期:2019年5月15日10:59:57
337
- * **/
338
- Base.prototype.same = function(arr1, arr2) {
339
- var arr3 = arr1.filter(function(v){
340
- return arr2.indexOf(v)!==-1
341
- });
342
- return arr3;
343
- }
344
-
345
-
346
- /******
347
- * @描述:获取两个数组不同的元素
348
- * @脚本:
349
- * <pre>
350
- * var oldArr = new Array(); //之前保存的
351
- * oldArr[0] = 1;
352
- * oldArr[1] = 2;
353
- *
354
- * var newArr = new Array(); //现在保存需要保存的
355
- * newArr[0] = 1;
356
- * newArr[1] = 2;
357
- * newArr[2] = 3;
358
- * newArr[3] = 1;
359
- *
360
- * var b = base.different(oldArr, newArr);
361
- * console.log(b);//[3]
362
- * </pre>
363
- * @日期:2019年5月15日10:59:57
364
- * **/
365
- Base.prototype.different = function(arr1, arr2) {
366
- //console.log(arr1.concat(arr2));
367
- //数组.filter循环数组,return的值为true则返回数v
368
- var arr3 = arr1.concat(arr2).filter(function (v) {
369
- // console.log(v); //1, 2, 1, 2, 3 数组的值
370
- // console.log(arr1.indexOf(v)); //0, 1, 0, 1, -1
371
- // console.log(arr2.indexOf(v)); //0, 1, 0, 1, 2
372
-
373
- //数组.indexOf(数组中的值),查询数组中该数是否存在,不存在返回-1,存在返回所在位置序号
374
- //合并后的数组列表如果不存在于其中一个合并前的数组就true,即返回该数
375
- return arr1.indexOf(v)===-1 || arr2.indexOf(v)===-1;
376
- })
377
- return arr3;
378
- }
379
-
380
- /******
381
- * @描述:对比arr1和arr2,如果arr2有arr1没有这返回该数
382
- * @脚本:
383
- * <pre>
384
- * var oldArr = new Array(); //之前保存的
385
- * oldArr[0] = 1;
386
- * oldArr[1] = 2;
387
- *
388
- * var newArr = new Array(); //现在保存需要保存的
389
- * newArr[0] = 3;
390
- *
391
- * var b = newArray(oldArr, newArr);
392
- * console.log("需要添加的数:" + b);
393
- *
394
- * var c = newArray(newArr, oldArr);
395
- * console.log("需要删除的数:" + c);
396
- * </pre>
397
- * @日期:2019年5月20日11:56:52
398
- * **/
399
- Base.prototype.newArray = function(arr1, arr2) {
400
- //console.log(arr1.concat(arr2));
401
- //数组.filter循环数组,return的值为true则返回数v
402
- var arr3 = arr1.concat(arr2).filter(function (v) {
403
- return arr1.indexOf(v)===-1 && arr2.indexOf(v)!=-1;
404
- })
405
- return arr3;
406
- }
407
-
408
- /** *
409
- * @描述:字符串复杂度验证
410
- * @参数:
411
- * str: 需要验证的字符串
412
- * lenMin: 字符串满足最小长度验证
413
- * lenMax: 字符串满足最大长度验证
414
- * @脚本:
415
- * <pre>
416
- * var str = $("#input1").val();
417
- * var lenMin = 0;
418
- * var lenMax = 32;
419
- * var result = b.strValidation(str, lenMin, lenMax);
420
- * if (result == 1) {
421
- * debug("字符串小于等于" + lenMin + ",或者大于等于" + lenMax);
422
- * } else if (result == 2) {
423
- * debug("全部为数字");
424
- * } else if (result == 3) {
425
- * debug("全部为字母");
426
- * } else if (result == 4) {
427
- * debug("包含字母数字");
428
- * } else if (result == 5) {
429
- * debug("只包含特殊字符");
430
- * } else if (result == 8) {
431
- * debug("包含字母数字及特殊字符");
432
- * } else {
433
- * debug("没有可以匹配的,必须包含英文字母数字及键盘上的特殊字符");
434
- * }
435
- * </pre>
436
- *
437
- * @返回:
438
- * 0: 没有可以匹配的,只匹配英文字母数字及键盘上的特殊字符
439
- * 1: 字符串小于等于len
440
- * 2: 全部为数字
441
- * 3: 全部为字母
442
- * 4: 包含字母数字
443
- * 5: 全部为特殊字符
444
- * 8: 包含字母数字及特殊字符
445
- * @日期:2020年1月20日18:27:21
446
- * **/
447
- Base.prototype.strValidation = function(str, lenMin, lenMax) {
448
- //没有可以匹配的,只匹配英文字母数字及键盘上的特殊字符
449
- var result = 0;
450
-
451
- var d1 = /^[^\u4e00-\u9fa5a-zA-Z\d,\.,。]{0,32}$/;//全部为特殊字符
452
- var d4 = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{0,}$/;//包含字母数字及特殊字符
453
- var medium = /^[0-9a-zA-z]{0,32}$/;//包含字母数字
454
- var e1 = /^[0-9]{0,32}$/;//全部为数字
455
- var e2 = /^[a-zA-z]{0,32}$/;//全部为字母
456
-
457
- if (str.length <= lenMin || str.length >= lenMax) {
458
- //字符串小于等于lenMin或者大于等于lenMax
459
- result = 1;
460
- } else if (e1.test(str)) {
461
- result = 2;
462
- } else if (e2.test(str)) {
463
- result = 3;
464
- } else if (medium.test(str)) {
465
- result = 4;
466
- } else if (d1.test(str)) {
467
- result = 5;
468
- // } else if (d2.test(str)) {
469
- // result = 6;
470
- // } else if (d3.test(str)) {
471
- // result = 7;
472
- } else if (d4.test(str)) {
473
- result = 8;
474
- }
475
- return result;
476
- }
477
-
478
- /******
479
- * @描述:页面内滑动特效
480
- * @参数:
481
- * $target: 需要移动的该jquery对象的位置
482
- * time: 动画执行时长(默认为500毫秒)
483
- * @脚本:
484
- * <pre>
485
- * moveToEF($("body"), 100);
486
- * 或者
487
- * moveToEF($("body"));
488
- * </pre>
489
- * @日期:2015年9月9日15:35:04
490
- * **/
491
- Base.prototype.moveToEF = function($target, time) {
492
- if (time == undefined || time == null || time == "" || time == "null")
493
- time = 500;
494
- $("html,body").animate({scrollTop: $target.offset().top}, time);
495
- }
496
-
497
- /******
498
- * @描述:判断对象是否存在,存在执行定义的方法
499
- * @参数:
500
- * elememt: 对象
501
- * times: 执行次数,每次100毫秒,一直不存在就停止执行
502
- * fun: 找到元素后要执行的方法
503
- * @脚本:
504
- * <pre>
505
- <div id="testdiv"></div>
506
-
507
- var base = new Base();
508
- base.runInExist("#testa", 8, function(e) {
509
- $("#testa").click(function(e) {
510
- alert("testa 存在");
511
- });
512
- })
513
- setTimeout(function() {
514
- $("#testdiv").html("<a id='testa' href='#'>testa</a>");
515
- }, 1000);
516
- * </pre>
517
- * @日期:2020年6月26日08:55:42
518
- * **/
519
- Base.prototype.runInExist = function(elememt, times, fun) {
520
- var timeout = 100;
521
- setTimeout(function() {
522
- if ($(elememt).length > 0) {
523
- if (fun)
524
- fun();
525
- } else {
526
- // debug("times: " + times);
527
- if (times > 0)
528
- Base.prototype.runInExist(elememt, times - 1, fun);
529
- }
530
- }, timeout);
531
- }
532
-
533
-
534
-
535
-
536
- /******
537
- * @描述:控制台打印
538
- * @脚本:debug(obj) // debug(obj, true)
539
- * @日期:2015年10月5日20:12:46
540
- * **/
541
- function debug(target, isDir) {
542
- if (window.console && window.console.log) {
543
- if (isDir) {
544
- window.console.dir(target);
545
- } else {
546
- window.console.log(target);
547
- }
548
- }
549
- }
550
-
551
- /******
552
- * @描述:添加删除class
553
- * @脚本:updateClass(class, remove, add);
554
- * @调用:<a id="d15-btn-2" class="button button-action" onclick="updateClass('.ce-foot', '', 'te-foot-1')">样式1</a>
555
- * @日期:2015-9-26 19:55:19
556
- * **/
557
- function updateClass(target, remove, add) {
558
- $(target).removeClass(remove);
559
- $(target).addClass(add);
560
- }
561
-
562
-
563
- /** ----------------------------------------- <2> 依赖于JS插件的方法 / JQUERY插件及常用方法方法封装
564
- **/
565
-
566
-
567
- /******
568
- * @描述:按钮特效
569
- * @参数:
570
- * target 添加事件的按钮
571
- * action 触发动作,eg: click or hover-in..
572
- * timing 运行时间
573
- * @脚本:
574
- * <pre>
575
- * base.pluginButtonStyle($("#be-btn"), "hover-in", 0.75);
576
- * </pre>
577
- * @日期:2016年2月18日09:53:42
578
- * **/
579
- Base.prototype.pluginButtonStyle = function(target, action, timing) {
580
- var ripple = target.find("use");
581
- target.unbind(action);
582
- target.bind(action, function(event) {
583
- var tl = new TimelineMax();
584
- x = event.offsetX,
585
- y = event.offsetY,
586
- w = event.target.offsetWidth,
587
- h = event.target.offsetHeight,
588
- offsetX = Math.abs((w / 2) - x),
589
- offsetY = Math.abs((h / 2) - y),
590
- deltaX = (w / 2) + offsetX,
591
- deltaY = (h / 2) + offsetY,
592
- scale_ratio = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
593
-
594
- tl.fromTo(ripple, timing, {
595
- x : x,
596
- y : y,
597
- transformOrigin : "50% 50%",
598
- scale : 0,
599
- opacity : 1,
600
- ease : Linear.easeIn
601
- }, {
602
- scale : scale_ratio,
603
- opacity : 0
604
- });
605
-
606
- });
607
- };
608
-
609
- /******
610
- * @描述:ztree等动态菜单生成
611
- * @脚本:
612
- * <pre>
613
- * 后台返回数据格式如:"trees":[{"name":"主菜单","id":1,"pId":null},{"name":"菜单","id":2,"pId":1}..
614
- * eg:
615
- * var html = new Base().menu(data.trees);
616
- * $("#nav-accordion").html(html);
617
- * <ul class="ce-accordion" id="nav-accordion"></ul>
618
- * </pre>
619
- * @日期:2017年2月25日19:54:02
620
- * **/
621
- Base.prototype.menu = function(trees, isIgnoreTop) {
622
- var html = "";
623
-
624
- var build = function(trees, level, pid) {
625
- var result = "";
626
- ++level;
627
- for ( var i = 0; i < trees.length; i++) {
628
- var tree = trees[i];
629
-
630
- var link = "#";
631
- if (tree.link)
632
- link = "../" + tree.link;
633
-
634
- if (tree.pId == null && level == 0) {
635
- if (isIgnoreTop) {
636
- //不显示第一层菜单
637
- result = build(trees, level, tree.id);
638
- } else {
639
- var html = build(trees, level, tree.id);
640
-
641
- if (html)
642
- html = "<ul class='sub'>" + html + "</ul>";
643
- result += "<li class='sub-menu'>" +
644
- "<a data-hash='" + tree.hash + "' id='" + tree.actionId + "' href='" + link + "'><span>" + tree.name + "</span></a>" +
645
- html +
646
- "</li>";
647
- }
648
- } else if (tree.pId == pid) {
649
- var html = "";
650
- if (tree.isParent) {//返回数据为节点即不再遍历
651
- html = build(trees, level, tree.id);
652
- if (html)
653
- html = "<ul class='sub'>" + html + "</ul>";
654
- }
655
-
656
- var icon = "";//第二层名称前加一个图标
657
- if (level == 1)
658
- icon = "<i class='" + tree.icon + "'/>";
659
-
660
- result += "<li class='sub-menu'>" +
661
- "<a data-hash='" + tree.hash + "' id='" + tree.actionId + "' href='" + link + "'>" +
662
- icon +
663
- "<span>" + tree.name + "</span>" +
664
- "</a>" +
665
- html +
666
- "</li>";
667
- }
668
- }
669
- return result;
670
- }
671
-
672
- var h = "";
673
- if (trees)
674
- h = build(trees, -1);
675
- return html + h;
676
- }
677
-
678
- /******
679
- * @描述:输入框特效
680
- * @脚本:
681
- * <pre>
682
- * base.search(function(txt) {
683
- * if (txt)
684
- * alert(txt);
685
- * });
686
- *
687
- * <div data-search="panent">
688
- * <span data-search="find" class="fa fa-search" aria-hidden="true"></span>
689
- * <input data-search="input" type="text" class="form-control" placeholder="检索你想找的内容">
690
- * <span data-search="clear" class="fa fa-trash-o" aria-hidden="true"></span>
691
- * </div>
692
- * </pre>
693
- * @日期:2015年4月15日17:12:41
694
- * **/
695
- Base.prototype.search = function(fun) {
696
- var $input = $("input[data-search='input']");
697
- var message = $input.attr("placeholder");
698
- $input.on("focus", "", function() {
699
- $(this).attr("placeholder", "");
700
- });
701
- $input.on("blur", "", function() {
702
- $(this).attr("placeholder", message);
703
- if ($(this).val().trim() != "")
704
- $(this).next().css("display", "inline-block");
705
- else
706
- $(this).next().css("display", "none");
707
- });
708
- if ($input.val().trim() != "")
709
- $input.next().css("display", "inline-block");
710
- $("span[data-search='clear']").on("click", "", function(){
711
- $(this).css("display", "none");
712
- $(this).prev().val("");
713
- });
714
- $("span[data-search='find']").on("click", "", function(){
715
- if(fun)
716
- fun($(this).next().val());
717
- });
718
- }
719
-
720
- /******
721
- * @描述:模板支持
722
- * @脚本:{{#if navType true}}{{/if}}
723
- * @日期:2015年4月17日09:27:50
724
- * **/
725
- Base.prototype.handlebars = function() {
726
- //等于
727
- Handlebars.registerHelper("if", function(v1, v2, options) {
728
- if (v1 == v2) {
729
- return options.fn(this);
730
- } else {
731
- return options.inverse(this);
732
- }
733
- });
734
-
735
- //小于
736
- Handlebars.registerHelper("lt", function(v1, v2, options) {
737
- if (v1 < v2) {
738
- return options.fn(this);
739
- } else {
740
- return options.inverse(this);
741
- }
742
- });
743
-
744
- //大于
745
- Handlebars.registerHelper("rt", function(v1, v2, options) {
746
- if (v1 > v2) {
747
- return options.fn(this);
748
- } else {
749
- return options.inverse(this);
750
- }
751
- });
752
-
753
- //小于等于
754
- Handlebars.registerHelper("lte", function(v1, v2, options) {
755
- if (v1 <= v2) {
756
- return options.fn(this);
757
- } else {
758
- return options.inverse(this);
759
- }
760
- });
761
-
762
- //大于等于
763
- Handlebars.registerHelper("rte", function(v1, v2, options) {
764
- if (v1 >= v2) {
765
- return options.fn(this);
766
- } else {
767
- return options.inverse(this);
768
- }
769
- });
770
- }
771
-
772
- /******
773
- * @描述:message插件方法封装 - 消息框
774
- * @参数:
775
- * @message: 消息
776
- * @type: info / error / success
777
- * @classes: 消息位置(2:顶部 / 6:左下下) ,按顺时针显示
778
- * @theme: 样式(2:黑色)
779
- * @脚本: al("操作成功!", "info", 2, "future");
780
- * @日期:2015年9月26日09:04:27
781
- * **/
782
- Base.prototype.al = function(message, type, classes, theme) {
783
- /**
784
- var theme;
785
- if (theme == 1) {
786
- theme = "flat";
787
- } else if (theme == 2) {
788
- theme = "future";
789
- } else if (theme == 3) {
790
- theme = "block";
791
- } else if (theme == 4) {
792
- theme = "air";
793
- } else if (theme == 5) {
794
- theme = "ice";
795
- } else {
796
- theme = "future";
797
- }
798
- **/
799
- if (!type) type = "info";
800
- if (!classes) classes = 3;
801
- if (!theme) theme = "future";
802
-
803
- var extraClasses;
804
- if (classes == 1) {
805
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-left";
806
- } else if (classes == 2) {
807
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
808
- } else if (classes == 3) {
809
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-right";
810
- } else if (classes == 4) {
811
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-right";
812
- } else if (classes == 5) {
813
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom";
814
- } else if (classes == 6) {
815
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-left";
816
- } else {
817
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
818
- }
819
-
820
- Messenger.options = {
821
- extraClasses: extraClasses,
822
- theme: theme
823
- }
824
-
825
- Messenger().post({
826
- message: message,
827
- type: type,
828
- hideAfter: 5,
829
- showCloseButton: true
830
- });
831
- }
832
- /******
833
- * @描述:message插件方法封装 - 确定框
834
- * @脚本:
835
- <pre>
836
- cf("是否确定删除该记录!", "确定删除", function(){
837
- al("删除成功!", "success", 2, "ice");
838
- }, 2, "ice")
839
- 默认样式为 future
840
- </pre>
841
-
842
- * @日期:2015年9月26日09:04:27
843
- * **/
844
- Base.prototype.cf = function(message, label, fun, classes, theme) {
845
- Messenger().hideAll();
846
-
847
- if (!theme) theme = "future";
848
- if (!classes) classes = 2;
849
-
850
- var extraClasses;
851
- if (classes == 1) {
852
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-left";
853
- } else if (classes == 2) {
854
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
855
- } else if (classes == 3) {
856
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top messenger-on-right";
857
- } else if (classes == 4) {
858
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-right";
859
- } else if (classes == 5) {
860
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom";
861
- } else if (classes == 6) {
862
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-bottom messenger-on-left";
863
- } else {
864
- extraClasses = "messenger-fixed messenger-theme-" + theme + " messenger-on-top";
865
- }
866
-
867
- Messenger.options = {
868
- extraClasses: extraClasses,
869
- theme: theme
870
- }
871
-
872
- msg = Messenger().post({
873
- message: message,
874
- actions: {
875
- retry: {
876
- label: label,
877
- phrase: "",
878
- auto: false,
879
- delay: 10,
880
- action: function() {
881
- fun();
882
- msg.cancel();
883
- }
884
- },
885
- cancel: {
886
- label: "取消",
887
- action: function() {
888
- return msg.cancel();
889
- }
890
- }
891
- }
892
- });
893
- }
894
-
895
- /******
896
- * @描述:jquery.hotkeys-master插件方法封装 - 绑定事件
897
- * @脚本:base.hotkeys($("#at-login-btn"), "return", $("body, #at-login input")); //点击回车触发按钮点击事件
898
- * @日期:2015年11月5日13:47:46
899
- * **/
900
- Base.prototype.hotkeys = function(target, code, bindTarget) {
901
- if (bindTarget)
902
- bindTarget.unbind("keydown");
903
- else
904
- $(document).unbind("keydown");
905
-
906
- if (bindTarget) {
907
- bindTarget.bind("keydown", code, function() {
908
- target.click();
909
- });
910
- } else {
911
- $(document).bind("keydown", code, function() {
912
- target.click();
913
- });
914
- }
915
- }
916
- /******
917
- * @描述:jquery.hotkeys-master插件方法封装 - 解除绑定
918
- * @脚本:base.hotkeysUnbind($("body, #at-login input"))
919
- * @日期:2015年11月5日14:24:58
920
- * **/
921
- Base.prototype.hotkeysUnbind = function(bindTarget) {
922
- if (bindTarget)
923
- bindTarget.unbind("keydown");
924
- else
925
- $(document).unbind("keydown");
926
- }
927
-
928
- /******
929
- * @描述:响应式下拉框,屏幕宽度大于767为HOVER显示,小于CLICK显示
930
- * @脚本:base.menuResponse()
931
- * @日期:2018年1月5日11:35:47
932
- * **/
933
- Base.prototype.menuResponse = function() {
934
-
935
- $(document).off("click.mu-nav-hover").on("click.mu-nav-hover", ".mu-nav-hover", function(e) {
936
- if ($(window).width() <= 767) {
937
- $(e.currentTarget).toggleClass("mn2c-open");
938
- }
939
- })
940
-
941
- var mr = function() {
942
- if ($(window).width() > 767)
943
- $(".mu-nav-hover").addClass("mu-nav-hover-hover").removeClass("mn2c-open");
944
- else
945
- $(".mu-nav-hover").removeClass("mu-nav-hover-hover");
946
- }
947
-
948
- mr();
949
- $(window).resize(function() {
950
- mr();
951
- });
952
- }
953
-
954
-
955
- /******
956
- * @描述:时间控件调用
957
- * @脚本:
958
- * <pre>
959
- * 1. datePicker($("#date"), "yyyy-MM-dd hh:ii:ss", 2);
960
- * 2. datePicker($("#date"), "hh:ii:ss", 1);
961
- * <input id="date" class="form-control" type="text" value="" readonly>
962
- * </pre>
963
- * @日期:2015年4月15日17:12:41
964
- * **/
965
- function datePicker($target, format, startView, minView, input) {
966
- $target.datetimepicker({
967
- language: "zh-CN",
968
- // format: format,
969
- weekStart: 0,
970
- todayBtn: true,
971
- autoclose: true,
972
- todayHighlight: true,
973
- startDate: "00:00",
974
- startView: startView,
975
- minView: minView,
976
- minuteStep: 1
977
- }).on("changeDate", function(e) {
978
- if (input)
979
- input.val(new Date(e.date.getTime()).format(format));
980
- });
981
- }
982
-
983
- /******
984
- * @描述:bootstrap分页插件
985
- * @脚本:
986
- * <pre>
987
- * pagination($("#target"), totalPages, function(event, page) { alert("Page: " + page); });
988
- * <ul id="target" class="pagination-sm"></ul>
989
- * </pre>
990
- * @日期:2015年4月15日17:12:41
991
- * **/
992
- function pagination(target, totalPages, fun) {
993
- target.twbsPagination({
994
- totalPages: totalPages,
995
- visiblePages: 7,
996
- first: "首页",
997
- prev: "上一页",
998
- next: "下一页",
999
- last: "尾页",
1000
- onPageClick: function(event, page) {
1001
- fun(event, page);
1002
- }
1003
- });
1004
- }
1005
-
1006
-
1007
- /******
1008
- * @描述:页首导航菜单事件
1009
- * @日期:2016年3月22日14:03:21
1010
- * **/
1011
- function headerInit() {
1012
- $(window).scroll(function() {
1013
- if ($(this).scrollTop()>100){
1014
- $(".header-fixed .header-sticky").addClass("header-fixed-shrink");
1015
- } else {
1016
- $(".header-fixed .header-sticky").removeClass("header-fixed-shrink");
1017
- }
1018
- });
1019
-
1020
- //header v5 搜索框
1021
- $(".header-v5 .search-button").click(function () {
1022
- $(".header-v5 .search-open").slideDown();
1023
- });
1024
- $(".header-v5 .search-close").click(function () {
1025
- $(".header-v5 .search-open").slideUp();
1026
- });
1027
- $(window).scroll(function(){
1028
- if($(this).scrollTop() > 1) jQuery(".header-v5 .search-open").fadeOut("fast");
1029
- });
1030
-
1031
-
1032
- //header v6 搜索框
1033
- $(".search").click(function () {
1034
- if($(".search-btn").hasClass("fa-search")){
1035
- $(".search-open").fadeIn(500);
1036
- $(".search-btn").removeClass("fa-search");
1037
- $(".search-btn").addClass("fa-times");
1038
- } else {
1039
- $(".search-open").fadeOut(500);
1040
- $(".search-btn").addClass("fa-search");
1041
- $(".search-btn").removeClass("fa-times");
1042
- }
1043
- });
1044
- }
1045
-
1046
-
1047
-
1048
- /** 1.3 [flexgrid]插件需要支持的事件 **/
1049
- function pluginEvent() {
1050
- //单选框事件
1051
- // var checkItem = $(".flex-check");
1052
- // checkItem.unbind("click");
1053
- // checkItem.click(function() {
1054
- // if ($(this).attr("checked") == "checked")
1055
- // $(this).parents("tr").addClass("trSelected");
1056
- // else
1057
- // $(this).parents("tr").removeClass("trSelected");
1058
- // });
1059
-
1060
- var checkAll = $(".flex-check-all[data-flag='flex-check-all']");
1061
- checkAll.unbind("click");
1062
- checkAll.click(function() {
1063
- if ($(this).is(":checked")) {
1064
- $(".flexigrid div.bDiv tr").addClass("trSelected");
1065
- checkItem.prop("checked", true);
1066
- } else {
1067
- $(".flexigrid div.bDiv tr").removeClass("trSelected");
1068
- checkItem.prop("checked", false);
1069
- }
1070
- });
1071
-
1072
- }
1073
- /** 1.3 [flexgrid]返回屏幕flexgrid列表高度 **/
1074
- function getFlexHeight() {
1075
- return $(window).height() - 305;
1076
- }
1077
- /** 1.3 [flexgrid]刷新列表 **/
1078
- function flexReload(target) {
1079
- $(target).flexReload();
1080
- $(".flex-check-all[data-flag='flex-check-all']").removeAttr("checked");
1081
- }
1082
-
1083
- /** 数据处理 - 获取树路径 **/
1084
- function getPathText(node) {
1085
- var path = node.name;
1086
- while (node = node.getParentNode())
1087
- path = node.name + "/" + path;
1088
- return path;
1089
- }
1090
-