arisu.js 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/arisu.commonjs.min.js +1 -1
- package/dist/arisu.js +468 -189
- package/dist/arisu.min.js +1 -1
- package/dist/arisu.module.min.js +1 -1
- package/dist/arisu.window.min.js +1 -1
- package/package.json +1 -1
- package/src/js/base.js +200 -122
- package/src/js/main.js +11 -4
- package/src/js/utils.js +256 -63
- package/webpack.config.js +20 -20
- package/deprecated/arisu-1.2.js +0 -3307
- package/deprecated/arisu-1.3.js +0 -3718
- package/deprecated/arisu.min.js +0 -1
- package/deprecated/base-2.0.js +0 -948
- package/deprecated/early/base-1.2.js +0 -1090
- package/deprecated/export-method.js +0 -467
- package/deprecated/jquery.module.js +0 -299
- package/deprecated/jquery.template.js +0 -82
- package/deprecated/main-2.0.js +0 -278
- package/deprecated/single-vue.js +0 -47
- package/deprecated/single.js +0 -130
- package/deprecated/utils-1.2.js +0 -2774
package/deprecated/utils-1.2.js
DELETED
|
@@ -1,2774 +0,0 @@
|
|
|
1
|
-
/* ========================================================================
|
|
2
|
-
* @描述:常用JS工具类
|
|
3
|
-
* @作者:林舒涛
|
|
4
|
-
* ========================================================================
|
|
5
|
-
|
|
6
|
-
1. 设置数字对应描述,背景颜色或者字体颜色, eg:
|
|
7
|
-
$("#a").setColor({...
|
|
8
|
-
2. 点击切换css active class样式 ,不要使用在包含子元素的标签, eg:
|
|
9
|
-
$(".btn").setActive();
|
|
10
|
-
3. 页面加载遮罩效果,使交互按钮无法在点击, eg:.
|
|
11
|
-
$("body").loading();
|
|
12
|
-
4. 多选框全选/全清, eg:
|
|
13
|
-
$("#be-all-check").checkAll({...
|
|
14
|
-
5. 提交后台过程中让按钮不可用,防止用户多次点击, eg:
|
|
15
|
-
$("#f").numStep({...
|
|
16
|
-
6. 数字特效递增特效, eg:
|
|
17
|
-
$("#f").numStep({...
|
|
18
|
-
7. bootstrap黑色提示消息显示, eg:
|
|
19
|
-
$("#g2").detail({...
|
|
20
|
-
8. 图片按钮滑入滑出切换按钮图片, eg:
|
|
21
|
-
$("#more").imageBtn();
|
|
22
|
-
9. 弹框搜索面板, eg:
|
|
23
|
-
$("#ipopover").popoverSearch({...
|
|
24
|
-
10. 列表查询分页封装插件, eg:
|
|
25
|
-
$("#user-list").iList({...
|
|
26
|
-
11. 元素显示切换, eg:
|
|
27
|
-
$(".iswitch").iSwitch({module: ".ce-switch2"});
|
|
28
|
-
12. 管理后台模式TAB页面, eg:
|
|
29
|
-
$(".a").iTab();
|
|
30
|
-
13. 多选框反选, eg:
|
|
31
|
-
$("#be-reverse-check").checkReverse({...
|
|
32
|
-
14. 数字增加减少,购物数量控制, eg:
|
|
33
|
-
$(".fmc1").itemCount({num: 6});
|
|
34
|
-
15. 绘制点线动画, eg:
|
|
35
|
-
$("#container").lineEffect({...
|
|
36
|
-
16. 底部按钮快速移动到顶部, eg:
|
|
37
|
-
$(".ce-gotop").gotop({...
|
|
38
|
-
17. 背景滚动特效, eg:
|
|
39
|
-
$(".ce-bg-ef").scrollBackground({speed: 6});
|
|
40
|
-
18. 鼠标上下左右划入监听实现对应动画, eg:
|
|
41
|
-
$(".ce-thumb").hoverdir({...
|
|
42
|
-
19. niceSelect下拉框, eg:
|
|
43
|
-
$(".ns-select").niceSelect();
|
|
44
|
-
20. 文字切换动画特效, eg:
|
|
45
|
-
$("#ce-flash").flash({});
|
|
46
|
-
21. 局部loading动画, eg:
|
|
47
|
-
new AeLoader().init();
|
|
48
|
-
22. 按钮动画
|
|
49
|
-
$(".ce-btn-5").btnEf();
|
|
50
|
-
|
|
51
|
-
* ======================================================================== */
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/* ========================================================================
|
|
55
|
-
* 1. 设置数字对应描述,背景颜色或者字体颜色
|
|
56
|
-
* 2016年6月10日11:02:58
|
|
57
|
-
* ========================================================================
|
|
58
|
-
|
|
59
|
-
window.tagArray = [1, 2, 3, 4, 5];
|
|
60
|
-
window.descArray = ["信息", "低危", "中危", "高危", "紧急"];
|
|
61
|
-
window.colorArray = ["color-8", "color-9", "color-10", "color-11", "color-13"];
|
|
62
|
-
window.bgcolorArray = ["color-bg-8", "color-bg-9", "color-bg-10", "color-bg-11", "color-bg-13"];
|
|
63
|
-
|
|
64
|
-
<span id="a"></span>
|
|
65
|
-
$("#a").setColor({
|
|
66
|
-
tag: 2,
|
|
67
|
-
tagArray: window.tagArray,
|
|
68
|
-
descArray: window.descArray,
|
|
69
|
-
colorArray: window.colorArray,
|
|
70
|
-
bgcolorArray: window.bgcolorArray,
|
|
71
|
-
desc: "未知"
|
|
72
|
-
});
|
|
73
|
-
* ======================================================================== */
|
|
74
|
-
+function ($) {
|
|
75
|
-
|
|
76
|
-
var SetColor = function (element, options) {
|
|
77
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
78
|
-
this.tag =
|
|
79
|
-
this.colorArray =
|
|
80
|
-
this.bgcolorArray =
|
|
81
|
-
this.tagArray =
|
|
82
|
-
this.descArray =
|
|
83
|
-
this.$element = $(element);
|
|
84
|
-
|
|
85
|
-
this.init(this.$element, this.options);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
SetColor.DEFAULTS = {
|
|
89
|
-
desc: "---"
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
SetColor.prototype.init = function (element, options) {
|
|
93
|
-
element.html(options.desc);
|
|
94
|
-
|
|
95
|
-
$(options.tagArray).each(function(i, t) {
|
|
96
|
-
if (options.tag == t) {
|
|
97
|
-
if (options.colorArray)
|
|
98
|
-
element.addClass(options.colorArray[i]);
|
|
99
|
-
if (options.bgcolorArray)
|
|
100
|
-
element.addClass(options.bgcolorArray[i]);
|
|
101
|
-
element.html(options.descArray[i]);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
var old = $.fn.setColor;
|
|
107
|
-
$.fn.setColor = function (option) {
|
|
108
|
-
return this.each(function () {
|
|
109
|
-
var $this = $(this);
|
|
110
|
-
|
|
111
|
-
var data = $this.data("be.setcolor");
|
|
112
|
-
var options = $.extend({}, SetColor.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
113
|
-
|
|
114
|
-
if (!data)
|
|
115
|
-
$this.data("be.setcolor", (data = new SetColor(this, options)));
|
|
116
|
-
else
|
|
117
|
-
data["init"]();
|
|
118
|
-
|
|
119
|
-
if (typeof option == 'string') data[option]();
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
$.fn.setColor.Constructor = SetColor;
|
|
124
|
-
$.fn.setColor.noConflict = function () {
|
|
125
|
-
$.fn.setColor = old;
|
|
126
|
-
return this;
|
|
127
|
-
};
|
|
128
|
-
}(jQuery);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/* ========================================================================
|
|
132
|
-
* 2. 点击切换css active class样式 ,不要使用在包含子元素的标签
|
|
133
|
-
* @ 1:切换CLASS
|
|
134
|
-
* @ 2:切换CLASS,如果该元素已经active就清除,同时只能一个active
|
|
135
|
-
* @ 3:切换CLASS,如果该元素已经active就清除,可以多个active
|
|
136
|
-
* 2016年6月11日10:36:03
|
|
137
|
-
* ========================================================================
|
|
138
|
-
|
|
139
|
-
<button type="button" class="btn btn-info">按钮1</button>
|
|
140
|
-
<button type="button" class="btn btn-info">按钮2</button>
|
|
141
|
-
|
|
142
|
-
$(".btn").setActive({flag: 2});
|
|
143
|
-
|
|
144
|
-
* ======================================================================== */
|
|
145
|
-
+function ($) {
|
|
146
|
-
|
|
147
|
-
var SetActive = function (element, options) {
|
|
148
|
-
var options = $.extend({}, SetActive.DEFAULTS, options);
|
|
149
|
-
var $element = $(element);
|
|
150
|
-
|
|
151
|
-
$element.on("click.setactive", options, this.init);
|
|
152
|
-
// $element.on("click.setactive", {element, options}, this.init);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
SetActive.DEFAULTS = {
|
|
156
|
-
flag: 1,
|
|
157
|
-
className: "active"
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
SetActive.prototype.init = function (e) {
|
|
161
|
-
var $target = $(this);
|
|
162
|
-
var options = e.data;
|
|
163
|
-
if (options.flag == 1) {//仅仅激活当前项
|
|
164
|
-
$(options.selector).removeClass(options.className);
|
|
165
|
-
$target.addClass(options.className);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// else if (e.data.flag == 2) {
|
|
169
|
-
// if ($this.hasClass(e.data.className)) {
|
|
170
|
-
// $(ct).removeClass(e.data.className);
|
|
171
|
-
// } else {
|
|
172
|
-
// $(ct).removeClass(e.data.className);
|
|
173
|
-
// $this.addClass(e.data.className);
|
|
174
|
-
// }
|
|
175
|
-
// } else if (e.data.flag == 3) {
|
|
176
|
-
// if ($this.hasClass(e.data.className)) {
|
|
177
|
-
// $this.removeClass(e.data.className);
|
|
178
|
-
// } else {
|
|
179
|
-
// $this.addClass(e.data.className);
|
|
180
|
-
// }
|
|
181
|
-
// }
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
$.fn.setActive = function (option) {
|
|
185
|
-
var selector = this.selector;
|
|
186
|
-
return this.each(function (i, t) {
|
|
187
|
-
var $this = $(this);
|
|
188
|
-
|
|
189
|
-
$this.attr("data-class", $this.attr("class"));
|
|
190
|
-
var data = $this.data("be.setactive");
|
|
191
|
-
options = $.extend({selector: selector}, SetActive.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
192
|
-
|
|
193
|
-
if (!data)
|
|
194
|
-
$this.data("be.setactive", (data = new SetActive(this, options)));
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
}(jQuery);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
/* ========================================================================
|
|
202
|
-
* 3. 页面加载遮罩效果,使交互按钮无法在点击
|
|
203
|
-
* 2016年6月14日09:40:14
|
|
204
|
-
* ========================================================================
|
|
205
|
-
|
|
206
|
-
<button id="c" type="button" class="btn btn-info">按钮2</button>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
$("#c").click(function() {
|
|
210
|
-
$("body").loading();
|
|
211
|
-
|
|
212
|
-
setTimeout(function() {
|
|
213
|
-
$("body").loading("complete");
|
|
214
|
-
}, 1000);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
* ======================================================================== */
|
|
218
|
-
+function ($) {
|
|
219
|
-
|
|
220
|
-
var Loading = function (element, options) {
|
|
221
|
-
this.$element = $(element);
|
|
222
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
223
|
-
|
|
224
|
-
this.toggle(options);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
Loading.DEFAULTS = {
|
|
228
|
-
template: "<div id='ce-loading' class='ce-loading invisible'></div>",
|
|
229
|
-
timeOut: -1
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
Loading.prototype.loading = function () {
|
|
233
|
-
var e = this.$element;
|
|
234
|
-
if ($("#ce-loading").length == 0) {
|
|
235
|
-
|
|
236
|
-
e.children().eq(0).before(this.options.template);
|
|
237
|
-
|
|
238
|
-
var cl = new CanvasLoader("ce-loading");
|
|
239
|
-
cl.setColor("#0a0a0a");
|
|
240
|
-
cl.setShape("roundRect");
|
|
241
|
-
cl.setDensity(11);
|
|
242
|
-
cl.setRange(0.8);
|
|
243
|
-
cl.setSpeed(1);
|
|
244
|
-
cl.setFPS(10);
|
|
245
|
-
cl.show();
|
|
246
|
-
}
|
|
247
|
-
e.addClass("ok");
|
|
248
|
-
|
|
249
|
-
$(".ce-loading").removeClass("invisible");
|
|
250
|
-
$("body > *:not(.ce-loading)").addClass("be-blur-2");
|
|
251
|
-
$("body").addClass("ce-loading-bg");
|
|
252
|
-
|
|
253
|
-
if (options.timeOut != -1) {
|
|
254
|
-
setTimeout(function() {
|
|
255
|
-
$("body").loading("complete");
|
|
256
|
-
}, options.timeOut);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
Loading.prototype.complete = function() {
|
|
260
|
-
this.$element.removeClass("ok");
|
|
261
|
-
|
|
262
|
-
$(".ce-loading").addClass("invisible");
|
|
263
|
-
$("body > *:not(.ce-loading)").removeClass("be-blur-2");
|
|
264
|
-
$("body").removeClass("ce-loading-bg");
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
Loading.prototype.toggle = function (options) {
|
|
268
|
-
this[this.$element.hasClass("ok") ? "complete" : "loading"](options);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
$.fn.loading = function (option) {
|
|
272
|
-
return this.each(function () {
|
|
273
|
-
var $this = $(this);
|
|
274
|
-
var data = $this.data("be.loading");
|
|
275
|
-
|
|
276
|
-
var options = $.extend({}, Loading.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
277
|
-
if (!data)
|
|
278
|
-
$this.data("be.loading", (data = new Loading(this, options)));
|
|
279
|
-
else
|
|
280
|
-
data["toggle"]();
|
|
281
|
-
|
|
282
|
-
if (typeof option == "string") data[option]();
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
}(jQuery);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
/* ========================================================================
|
|
289
|
-
* 4. 多选框全选/全清
|
|
290
|
-
* 2016年6月25日23:19:54
|
|
291
|
-
* ========================================================================
|
|
292
|
-
|
|
293
|
-
<input type="checkbox" id="be-all-check"/>全选
|
|
294
|
-
<input type="checkbox" class="be-check"/>选项一
|
|
295
|
-
<input type="checkbox" class="be-check"/>选项二
|
|
296
|
-
|
|
297
|
-
$("#be-all-check").checkAll({
|
|
298
|
-
targets: ".be-check"
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
* ======================================================================== */
|
|
302
|
-
+function ($) {
|
|
303
|
-
|
|
304
|
-
var CheckAll = function (element, options) {
|
|
305
|
-
this.$element = $(element);
|
|
306
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
307
|
-
|
|
308
|
-
this.$element.on("click", "", this.init);
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
CheckAll.DEFAULTS = {
|
|
312
|
-
targets: ".be-check"
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
CheckAll.prototype.init = function () {
|
|
316
|
-
var $this = $(this);
|
|
317
|
-
$this.data("be.checkall")["toggle"]();
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
CheckAll.prototype.checked = function () {
|
|
321
|
-
var e = this.$element;
|
|
322
|
-
e.addClass("checked-all");
|
|
323
|
-
$(this.options.targets).prop("checked", true);
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
CheckAll.prototype.clear = function() {
|
|
327
|
-
this.$element.removeClass("checked-all");
|
|
328
|
-
$(this.options.targets).prop("checked", false);
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
CheckAll.prototype.toggle = function () {
|
|
332
|
-
this[this.$element.hasClass("checked-all") ? "clear" : "checked"]();
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
CheckAll.prototype.destroy = function () {
|
|
336
|
-
$(this).removeData("be.checkall");
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
$.fn.checkAll = function (option) {
|
|
340
|
-
return this.each(function () {
|
|
341
|
-
var $this = $(this);
|
|
342
|
-
if ($this.is(":checked"))
|
|
343
|
-
$this.addClass("checked-all");
|
|
344
|
-
else
|
|
345
|
-
$this.removeClass("checked-all");
|
|
346
|
-
|
|
347
|
-
var data = $this.data("be.checkall");
|
|
348
|
-
var options = $.extend({}, CheckAll.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
349
|
-
if (!data) $this.data("be.checkall", (data = new CheckAll(this, options)));
|
|
350
|
-
|
|
351
|
-
if (typeof option == "string") data[option]();
|
|
352
|
-
});
|
|
353
|
-
};
|
|
354
|
-
}(jQuery);
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
/* ========================================================================
|
|
358
|
-
* 5. 提交后台过程中让按钮不可用,防止用户多次点击
|
|
359
|
-
* 2016年6月26日10:08:11
|
|
360
|
-
* ========================================================================
|
|
361
|
-
|
|
362
|
-
<button href="#" class="e1 btn btn-danger">按钮一</button>
|
|
363
|
-
|
|
364
|
-
$(".e1").click(function() {
|
|
365
|
-
$(".e1").submitFlag();
|
|
366
|
-
|
|
367
|
-
setTimeout(function() {
|
|
368
|
-
$(".e1").submitFlag();
|
|
369
|
-
}, 1000);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
或者
|
|
373
|
-
<button href="#" class="e2 btn btn-danger">按钮二</button>
|
|
374
|
-
|
|
375
|
-
$(".e2").click(function() {
|
|
376
|
-
$(".e2").submitFlag({
|
|
377
|
-
text: "数据请求中..",
|
|
378
|
-
useText: true
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
setTimeout(function() {
|
|
382
|
-
$(".e2").submitFlag();
|
|
383
|
-
}, 1000);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
* ======================================================================== */
|
|
389
|
-
+function ($) {
|
|
390
|
-
|
|
391
|
-
var SubmitFlag = function (element, options) {
|
|
392
|
-
this.$element = $(element);
|
|
393
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
394
|
-
|
|
395
|
-
this.toggle();
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
SubmitFlag.DEFAULTS = {
|
|
399
|
-
text: "处理中..",
|
|
400
|
-
useText: true
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
SubmitFlag.prototype.request = function () {
|
|
404
|
-
var $this = this.$element;
|
|
405
|
-
|
|
406
|
-
$this.addClass("submit-flag-request").data("text", $this.text()).attr("disabled", "disabled");
|
|
407
|
-
if (this.options.useText)
|
|
408
|
-
$this.text(this.options.text);
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
SubmitFlag.prototype.complete = function() {
|
|
412
|
-
var $this = this.$element;
|
|
413
|
-
$this.removeClass("submit-flag-request").removeAttr("disabled");
|
|
414
|
-
if ($this.data("text") && this.options.useText)
|
|
415
|
-
$this.text($this.data("text"));
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
SubmitFlag.prototype.toggle = function () {
|
|
419
|
-
this[this.$element.hasClass("submit-flag-request") ? "complete" : "request"]();
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
$.fn.submitFlag = function (option) {
|
|
423
|
-
return this.each(function () {
|
|
424
|
-
var $this = $(this);
|
|
425
|
-
var data = $this.data("be.submitflag");
|
|
426
|
-
|
|
427
|
-
var options = $.extend({}, SubmitFlag.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
428
|
-
if (!data)
|
|
429
|
-
$this.data("be.submitflag", (data = new SubmitFlag(this, options)));
|
|
430
|
-
else
|
|
431
|
-
data["toggle"]();
|
|
432
|
-
|
|
433
|
-
if (typeof option == "string") data[option]();
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
}(jQuery);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
/* ========================================================================
|
|
440
|
-
* 6. 数字特效递增特效
|
|
441
|
-
* 2016年6月26日11:13:16
|
|
442
|
-
* ========================================================================
|
|
443
|
-
|
|
444
|
-
<p id="f">0</p>
|
|
445
|
-
|
|
446
|
-
$("#f").numStep({
|
|
447
|
-
number: 100,
|
|
448
|
-
time: 1000
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
setTimeout(function() {
|
|
452
|
-
$("#f").numStep({
|
|
453
|
-
number: 300,
|
|
454
|
-
time: 1000
|
|
455
|
-
});
|
|
456
|
-
}, 2000);
|
|
457
|
-
|
|
458
|
-
* ======================================================================== */
|
|
459
|
-
+function ($) {
|
|
460
|
-
|
|
461
|
-
var NumStep = function (element, options) {
|
|
462
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
463
|
-
this.$element = $(element);
|
|
464
|
-
|
|
465
|
-
this.init(this.options);
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
NumStep.DEFAULTS = {
|
|
469
|
-
number: 100,
|
|
470
|
-
time: 1500
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
NumStep.prototype.init = function (options) {
|
|
474
|
-
var $element = this.$element;
|
|
475
|
-
|
|
476
|
-
$element.animate({count: options.number}, {
|
|
477
|
-
duration: options.time,
|
|
478
|
-
step: function() {
|
|
479
|
-
if (this.count)
|
|
480
|
-
$element.text(Math.round(this.count));
|
|
481
|
-
},
|
|
482
|
-
complete: function () {
|
|
483
|
-
if (this.count)
|
|
484
|
-
$element.text(Math.round(this.count));
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
$.fn.numStep = function (option) {
|
|
490
|
-
var $this = $(this);
|
|
491
|
-
return this.each(function () {
|
|
492
|
-
var data = $this.data("be.numstep");
|
|
493
|
-
var options = $.extend({}, NumStep.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
494
|
-
|
|
495
|
-
if (!data)
|
|
496
|
-
$this.data("be.numstep", (data = new NumStep(this, options)));
|
|
497
|
-
else
|
|
498
|
-
data["init"](options);
|
|
499
|
-
});
|
|
500
|
-
};
|
|
501
|
-
}(jQuery);
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
/* ========================================================================
|
|
505
|
-
* 7. bootstrap黑色提示消息显示
|
|
506
|
-
* 2016年6月26日13:24:55
|
|
507
|
-
* ========================================================================
|
|
508
|
-
|
|
509
|
-
<button href="#" class="g1 btn btn-danger margin-left-20">按钮一</button>
|
|
510
|
-
<span id="g2"></span>
|
|
511
|
-
|
|
512
|
-
$(".g1").detail({
|
|
513
|
-
placement: "bottom",
|
|
514
|
-
title: "该按钮/区域说明"
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
$("#g2").detail({
|
|
518
|
-
title: "一定很长需要减少长度的文字说明",
|
|
519
|
-
length: 5
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
* ======================================================================== */
|
|
523
|
-
+function ($) {
|
|
524
|
-
|
|
525
|
-
var Detail = function (element, options) {
|
|
526
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
527
|
-
|
|
528
|
-
this.init(element, this.options);
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
Detail.DEFAULTS = {
|
|
532
|
-
isSelf: false,//是否使用原来文本作为提示显示内容
|
|
533
|
-
isReplace: true,//是否替换原来文本
|
|
534
|
-
placement: "top",
|
|
535
|
-
title: "...",
|
|
536
|
-
length : false
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
Detail.prototype.init = function (element, options) {
|
|
540
|
-
var $element = $(element);
|
|
541
|
-
|
|
542
|
-
if (options.isSelf)
|
|
543
|
-
options.title = $element.text();
|
|
544
|
-
|
|
545
|
-
$element.tooltip({
|
|
546
|
-
placement: options.placement,
|
|
547
|
-
title: options.title
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
if (options.isReplace) {
|
|
551
|
-
if (options.length && options.length < options.title.length)
|
|
552
|
-
$element.html(options.title.substring(0, options.length) + "...");
|
|
553
|
-
else
|
|
554
|
-
$element.html(options.title);
|
|
555
|
-
}
|
|
556
|
-
// if (options.isSelf)
|
|
557
|
-
// $element.html(options.title.substring(0, options.length) + "...");
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
$.fn.detail = function (option) {
|
|
561
|
-
var $this = $(this);
|
|
562
|
-
return this.each(function () {
|
|
563
|
-
var data = $this.data("be.detail");
|
|
564
|
-
var options = $.extend({}, Detail.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
565
|
-
|
|
566
|
-
if (!data)
|
|
567
|
-
$this.data("be.detail", (data = new Detail(this, options)));
|
|
568
|
-
else
|
|
569
|
-
data["init"](this, options);
|
|
570
|
-
});
|
|
571
|
-
};
|
|
572
|
-
}(jQuery);
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
/* ========================================================================
|
|
576
|
-
* 8. 图片按钮滑入滑出切换按钮图片
|
|
577
|
-
* 2016年6月26日10:08:11
|
|
578
|
-
* ========================================================================
|
|
579
|
-
|
|
580
|
-
<img id="more" src="WEB/images/resource/more.png" class="img-responsive center-block"></img>
|
|
581
|
-
// more.png
|
|
582
|
-
// more-hover.png
|
|
583
|
-
|
|
584
|
-
$("#more").imageBtn();
|
|
585
|
-
|
|
586
|
-
* ======================================================================== */
|
|
587
|
-
+function ($) {
|
|
588
|
-
|
|
589
|
-
var ImageBtn = function (element, options) {
|
|
590
|
-
this.$element = $(element);
|
|
591
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
592
|
-
|
|
593
|
-
this.init(this.options);
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
ImageBtn.DEFAULTS = {
|
|
597
|
-
suffix: "-hover"
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
ImageBtn.prototype.init = function (options) {
|
|
601
|
-
var $element = this.$element;
|
|
602
|
-
|
|
603
|
-
$element.hover(function() {
|
|
604
|
-
var t = $(this);
|
|
605
|
-
var src = $(this).attr("src");
|
|
606
|
-
var index = src.lastIndexOf(".");
|
|
607
|
-
$(this).fadeOut(200);
|
|
608
|
-
var srcHover = src.substr(0, index) + options.suffix + src.substr(index, src.length);
|
|
609
|
-
$(this).attr("src", srcHover);
|
|
610
|
-
$(this).fadeIn(200);
|
|
611
|
-
}, function() {
|
|
612
|
-
var srcHover = $(this).attr("src");
|
|
613
|
-
var src = srcHover.replace(options.suffix, "");
|
|
614
|
-
$(this).attr("src", src);
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
$.fn.imageBtn = function (option) {
|
|
619
|
-
return this.each(function () {
|
|
620
|
-
var $this = $(this);
|
|
621
|
-
var data = $this.data("be.imagebtn");
|
|
622
|
-
|
|
623
|
-
var options = $.extend({}, ImageBtn.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
624
|
-
if (!data)
|
|
625
|
-
$this.data("be.imagebtn", (data = new ImageBtn(this, options)));
|
|
626
|
-
else
|
|
627
|
-
data["init"]();
|
|
628
|
-
});
|
|
629
|
-
};
|
|
630
|
-
}(jQuery);
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
/* ========================================================================
|
|
635
|
-
* 9. 弹框搜索面板
|
|
636
|
-
* 2016年5月22日19:01:48
|
|
637
|
-
* ========================================================================
|
|
638
|
-
|
|
639
|
-
<a id="ipopover" tabindex="0" class="btn btn-sm btn-danger">弹出搜索框</a>
|
|
640
|
-
<div id="load"></div>
|
|
641
|
-
|
|
642
|
-
$("#load").load("WEB/page/template.html", function() {
|
|
643
|
-
$("#ipopover").popoverSearch({
|
|
644
|
-
items: [
|
|
645
|
-
{name: "name", desc: "姓名", type: "text", value: ""},
|
|
646
|
-
{name: "tiem", desc: "开始时间", type: "date", value: ""},
|
|
647
|
-
{name: "select", desc: "选项", type: "select",
|
|
648
|
-
options: [
|
|
649
|
-
{name: "", value: "所有", selected: false},//如果默认查询所有,name设置为""
|
|
650
|
-
{name: "o1", value: "选项1", selected: false},
|
|
651
|
-
{name: "o2", value: "选项2", selected: true}
|
|
652
|
-
]}
|
|
653
|
-
],
|
|
654
|
-
onSerach: function(e) {
|
|
655
|
-
$("#ipopover").click();
|
|
656
|
-
debug(e.param);//参数及参数值对象,{name: "arisu", tiem: "2016-07-16 17:02:59", select: "o2"}
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
});
|
|
660
|
-
* ======================================================================== */
|
|
661
|
-
+function ($) {
|
|
662
|
-
|
|
663
|
-
var PopoverSearch = function (element, options) {
|
|
664
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
665
|
-
|
|
666
|
-
this.init(element, this.options);
|
|
667
|
-
};
|
|
668
|
-
|
|
669
|
-
PopoverSearch.DEFAULTS = {
|
|
670
|
-
html: true,
|
|
671
|
-
title: "详细搜索",
|
|
672
|
-
trigger: "click",
|
|
673
|
-
toggle: "popover",
|
|
674
|
-
placement: "bottom",
|
|
675
|
-
onSerach: false,
|
|
676
|
-
items: [],
|
|
677
|
-
startView: 2,
|
|
678
|
-
minView: 2,
|
|
679
|
-
format: "yyyy-MM-dd hh:mm:ss",
|
|
680
|
-
bsVs: 5
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
PopoverSearch.prototype.init = function (element, options) {
|
|
684
|
-
var $element = $(element);
|
|
685
|
-
var target = this;
|
|
686
|
-
|
|
687
|
-
var tplEl = $("#tp-popover");
|
|
688
|
-
var template = Handlebars.compile(tplEl.html())({});
|
|
689
|
-
|
|
690
|
-
if (options.bsVs == 3) {
|
|
691
|
-
$element.popover({
|
|
692
|
-
html: options.html,
|
|
693
|
-
title: options.title,
|
|
694
|
-
trigger: options.trigger,
|
|
695
|
-
toggle: options.toggle,
|
|
696
|
-
placement: options.placement,
|
|
697
|
-
template : template,
|
|
698
|
-
param: null,
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
$element.on("shown.bs.popover", function () {
|
|
702
|
-
target.search(options, target);
|
|
703
|
-
target.cancel(element);
|
|
704
|
-
target.addItem(element, options);
|
|
705
|
-
target.clear();
|
|
706
|
-
});
|
|
707
|
-
|
|
708
|
-
$element.on("hide.bs.popover", function () {
|
|
709
|
-
$(".popover-content-item").each(function(i, t) {
|
|
710
|
-
var name = $(".popover-form-item", this).attr("name");
|
|
711
|
-
if (options.items[i].type == "select") {
|
|
712
|
-
var val = $(".popover-form-item", this).find("option:selected").attr("value");
|
|
713
|
-
$(options.items[i].options).each(function(i, t) {
|
|
714
|
-
if (this.name == val) {
|
|
715
|
-
this.selected = true;
|
|
716
|
-
} else {
|
|
717
|
-
this.selected = false;
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
} else {
|
|
721
|
-
var val = $(".popover-form-item", this).val();
|
|
722
|
-
options.items[i].value = val;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
} else {
|
|
728
|
-
var popr = new bootstrap.Popover($element, {
|
|
729
|
-
html: options.html,
|
|
730
|
-
title: options.title,
|
|
731
|
-
trigger: options.trigger,
|
|
732
|
-
toggle: options.toggle,
|
|
733
|
-
placement: options.placement,
|
|
734
|
-
template : template,
|
|
735
|
-
param: null
|
|
736
|
-
});
|
|
737
|
-
$element.on("shown.bs.popover", function (){
|
|
738
|
-
target.search(options, target);
|
|
739
|
-
target.close(popr);
|
|
740
|
-
target.addItem(element, options);
|
|
741
|
-
target.clear();
|
|
742
|
-
});
|
|
743
|
-
$element.on("hide.bs.popover", function () {
|
|
744
|
-
$(".popover-content-item").each(function(i, t) {
|
|
745
|
-
var name = $(".popover-form-item", this).attr("name");
|
|
746
|
-
if (options.items[i].type == "select") {
|
|
747
|
-
var val = $(".popover-form-item", this).find("option:selected").attr("value");
|
|
748
|
-
$(options.items[i].options).each(function(i, t) {
|
|
749
|
-
if (this.name == val) {
|
|
750
|
-
this.selected = true;
|
|
751
|
-
} else {
|
|
752
|
-
this.selected = false;
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
} else {
|
|
756
|
-
var val = $(".popover-form-item", this).val();
|
|
757
|
-
options.items[i].value = val;
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
//获取参数
|
|
765
|
-
PopoverSearch.prototype.getParam = function () {
|
|
766
|
-
var params = new Object();
|
|
767
|
-
$(".popover-content-item").each(function(i, t) {
|
|
768
|
-
var name = $(".popover-form-item", this).attr("name");
|
|
769
|
-
var val = $(".popover-form-item", this).val();
|
|
770
|
-
if (val)
|
|
771
|
-
params[name] = val;
|
|
772
|
-
});
|
|
773
|
-
return params;
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
//搜索
|
|
777
|
-
PopoverSearch.prototype.search = function (options, target) {
|
|
778
|
-
$(".ce-popover-ok", ".ce-popover").off("click").on("click", "", function() {
|
|
779
|
-
if (options.onSerach) {
|
|
780
|
-
var e = {param: target.getParam()}
|
|
781
|
-
options.onSerach(e);
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
//关闭
|
|
787
|
-
PopoverSearch.prototype.cancel = function (element) {
|
|
788
|
-
var $element = $(element);
|
|
789
|
-
$(".ce-popover-cancel", ".ce-popover").off("click").on("click", "", function() {
|
|
790
|
-
$element.click();
|
|
791
|
-
});
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
//关闭
|
|
795
|
-
PopoverSearch.prototype.close = function (popr) {
|
|
796
|
-
$(".ce-popover-cancel", ".ce-popover").off("click").on("click", "", function() {
|
|
797
|
-
popr.hide();
|
|
798
|
-
});
|
|
799
|
-
};
|
|
800
|
-
|
|
801
|
-
//清空条件
|
|
802
|
-
PopoverSearch.prototype.clear = function (element) {
|
|
803
|
-
$(".ce-popover-clear", ".ce-popover").off("click").on("click", "", function() {
|
|
804
|
-
$("input", ".popover-content-item").val("");
|
|
805
|
-
$("select option:first", ".popover-content-item").attr("selected", true);
|
|
806
|
-
});
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
//删除搜索项
|
|
810
|
-
PopoverSearch.prototype.remove = function () {
|
|
811
|
-
$(".ce-popover-remove", ".ce-popover").off("click").on("click", "", function() {
|
|
812
|
-
$(this).parents(".popover-content-item.row").html("").removeClass("popover-content-item row");
|
|
813
|
-
$(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last .ce-popover-add").css("display", "inline-block");
|
|
814
|
-
});
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
//添加搜索项
|
|
818
|
-
PopoverSearch.prototype.add = function (element) {
|
|
819
|
-
var target = this;
|
|
820
|
-
$(".ce-popover-add", ".ce-popover").off("caddItemlick").on("click", "", function() {
|
|
821
|
-
var tplEl = $("#tp-popover-option");
|
|
822
|
-
var html = Handlebars.compile(tplEl.html())({});
|
|
823
|
-
$(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last").after(html);
|
|
824
|
-
$(".ce-popover > .popover-content .popover-content-items > .popover-content-item .ce-popover-add").css("display", "none");
|
|
825
|
-
$(".ce-popover > .popover-content .popover-content-items > .popover-content-item:last .ce-popover-add").css("display", "inline-block");
|
|
826
|
-
|
|
827
|
-
target.add(element);
|
|
828
|
-
target.remove();
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
//添加搜索项
|
|
833
|
-
PopoverSearch.prototype.addItem = function (element, options) {
|
|
834
|
-
var tplEl = $("#tp-popover-items");
|
|
835
|
-
var html = Handlebars.compile(tplEl.html())({
|
|
836
|
-
items: options.items
|
|
837
|
-
});
|
|
838
|
-
$(".ce-popover > .popover-content .popover-content-items").html(html);
|
|
839
|
-
|
|
840
|
-
$(options.items).each(function(i, t) {
|
|
841
|
-
//需要使用到日期控件
|
|
842
|
-
if (t.type == "date") {
|
|
843
|
-
var $input = $("input[name='" + t.name + "']", ".ce-popover");
|
|
844
|
-
$(".ce-popover-date[date-flag='" + t.name + "']", ".ce-popover").datetimepicker({
|
|
845
|
-
language: "zh-CN",
|
|
846
|
-
format: options.format,
|
|
847
|
-
weekStart: 0,
|
|
848
|
-
todayBtn: true,
|
|
849
|
-
autoclose: true,
|
|
850
|
-
todayHighlight: true,
|
|
851
|
-
startDate: "00:00",
|
|
852
|
-
startView: options.startView,
|
|
853
|
-
minView: options.minView,
|
|
854
|
-
minuteStep: 1
|
|
855
|
-
}).on("changeDate", function(e) {
|
|
856
|
-
if ($input)
|
|
857
|
-
$input.val(new Date(e.date.getTime()).format(options.format));
|
|
858
|
-
});
|
|
859
|
-
} else if (t.type == "time") {
|
|
860
|
-
var $input = $("input[name='" + t.name + "']", ".ce-popover");
|
|
861
|
-
$(".ce-popover-date[date-flag='" + t.name + "']", ".ce-popover").datetimepicker({
|
|
862
|
-
language: "zh-CN",
|
|
863
|
-
format: "hh:ii:00",
|
|
864
|
-
weekStart: 0,
|
|
865
|
-
//todayBtn: true,
|
|
866
|
-
autoclose: true,
|
|
867
|
-
todayHighlight: true,
|
|
868
|
-
startDate: "00:00",
|
|
869
|
-
startView: 1,
|
|
870
|
-
minView: 0,
|
|
871
|
-
minuteStep: 1
|
|
872
|
-
}).on("changeDate", function(e) {
|
|
873
|
-
if ($input)
|
|
874
|
-
$input.val(new Date(e.date.getTime()).format("hh:mm:00"));
|
|
875
|
-
});
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
$.fn.popoverSearch = function (option) {
|
|
882
|
-
var $this = $(this);
|
|
883
|
-
return this.each(function () {
|
|
884
|
-
var data = $this.data("be.popover.search");
|
|
885
|
-
var options = $.extend({}, PopoverSearch.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
886
|
-
|
|
887
|
-
if (!data) $this.data("be.popover.search", (data = new PopoverSearch(this, options)));
|
|
888
|
-
if (typeof option == 'string') return data[option]();
|
|
889
|
-
});
|
|
890
|
-
};
|
|
891
|
-
}(jQuery);
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
/* ========================================================================
|
|
895
|
-
* 10. 列表查询分页封装插件
|
|
896
|
-
* 2016年7月27日15:02:29
|
|
897
|
-
* ========================================================================
|
|
898
|
-
|
|
899
|
-
$("#user-list").iList({
|
|
900
|
-
url: sp + "userManage/findUser.action",
|
|
901
|
-
param: {name: "arisu"},
|
|
902
|
-
|
|
903
|
-
// 支持跨越
|
|
904
|
-
// url: server + "springmvc/news/findNewsJsonp.action",
|
|
905
|
-
// jsonp: "callback",
|
|
906
|
-
// jsonpCallback:"showData",
|
|
907
|
-
// dataType: "jsonp",
|
|
908
|
-
|
|
909
|
-
onSuccess: function(data) {
|
|
910
|
-
|
|
911
|
-
var tplEl = $("#tp-data-table-1");
|
|
912
|
-
var html = Handlebars.compile(tplEl.html())({
|
|
913
|
-
items: data.users
|
|
914
|
-
});
|
|
915
|
-
$(".be-list-data", "#user-list").html(html);
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
* ======================================================================== */
|
|
921
|
-
+function ($) {
|
|
922
|
-
|
|
923
|
-
var IList = function (element, options) {
|
|
924
|
-
this.$element = $(element);
|
|
925
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
926
|
-
|
|
927
|
-
this.init(element, this.options);
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
IList.DEFAULTS = {
|
|
932
|
-
rp: "10",
|
|
933
|
-
visiblePages: 7,
|
|
934
|
-
sortname: "id",
|
|
935
|
-
sortorder: "desc",
|
|
936
|
-
method: "post",
|
|
937
|
-
dataType: "json",
|
|
938
|
-
async: true,
|
|
939
|
-
jsonp: null,
|
|
940
|
-
jsonpCallback: null,
|
|
941
|
-
param: {},
|
|
942
|
-
url: "",
|
|
943
|
-
loadColor: "#0a0a0a",//必须是16进制,不能缩写
|
|
944
|
-
lang: "cn",
|
|
945
|
-
headerMap: null,
|
|
946
|
-
onSuccess: false,
|
|
947
|
-
onError: false
|
|
948
|
-
};
|
|
949
|
-
|
|
950
|
-
IList.prototype.init = function (element, options) {
|
|
951
|
-
$element = $(element);
|
|
952
|
-
var target = this;
|
|
953
|
-
$element.data("be.ilist.flag", true);
|
|
954
|
-
|
|
955
|
-
var tplEl = $("#tp-list");
|
|
956
|
-
var html = Handlebars.compile(tplEl.html())({});
|
|
957
|
-
$element.html(html);
|
|
958
|
-
|
|
959
|
-
// 不兼容jquery3.6
|
|
960
|
-
$(".be-list-loading-canvas", $element).attr("id", $element.attr("id") + "-load");
|
|
961
|
-
var cl = new CanvasLoader($element.attr("id") + "-load");
|
|
962
|
-
cl.setColor(options.loadColor);
|
|
963
|
-
cl.setShape("roundRect");
|
|
964
|
-
cl.setDensity(11);
|
|
965
|
-
cl.setRange(0.8);
|
|
966
|
-
cl.setSpeed(1);
|
|
967
|
-
cl.setFPS(10);
|
|
968
|
-
cl.show();
|
|
969
|
-
|
|
970
|
-
var param = $.extend({}, {page: 1, rp: options.rp, sortname: options.sortname, sortorder: options.sortorder}, options.param);
|
|
971
|
-
options.isPage = false;
|
|
972
|
-
target.getData(element, options, param);
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
IList.prototype.getData = function (element, options, param) {
|
|
976
|
-
var target = this;
|
|
977
|
-
if ($(".ilist-check-all[data-flag='1']", element).is(":checked"))
|
|
978
|
-
$(".ilist-check-all[data-flag='1']", element).click();
|
|
979
|
-
$(".be-list-loading", element).css("display", "block");
|
|
980
|
-
if (options.isPage)
|
|
981
|
-
$(".be-list-data-body", element).html("");
|
|
982
|
-
else
|
|
983
|
-
$(".be-list-data", element).css("display", "none");
|
|
984
|
-
|
|
985
|
-
$.ajax({
|
|
986
|
-
type: options.method,
|
|
987
|
-
url: options.url,
|
|
988
|
-
beforeSend: function(request) {
|
|
989
|
-
for (var key in options.headerMap) {
|
|
990
|
-
if (options.headerMap.hasOwnProperty(key)) {
|
|
991
|
-
request.setRequestHeader(key, options.headerMap[key]);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
},
|
|
995
|
-
data: param,
|
|
996
|
-
cache: false,
|
|
997
|
-
jsonp: options.jsonp,
|
|
998
|
-
jsonpCallback: options.jsonp,
|
|
999
|
-
async: options.async,
|
|
1000
|
-
dataType: options.dataType,
|
|
1001
|
-
success: function (data) {
|
|
1002
|
-
$(".be-list-loading", element).css("display", "none");
|
|
1003
|
-
|
|
1004
|
-
data.isPage = options.isPage;
|
|
1005
|
-
if (options.isPage)
|
|
1006
|
-
$(".be-list-data-body", element).css("display", "table-row-group");
|
|
1007
|
-
else
|
|
1008
|
-
$(".be-list-data", element).css("display", "block");
|
|
1009
|
-
|
|
1010
|
-
if (options.onSuccess)
|
|
1011
|
-
options.onSuccess(data);
|
|
1012
|
-
|
|
1013
|
-
if (data.total) {
|
|
1014
|
-
var pageType = $(".be-list-page").data("type");
|
|
1015
|
-
if (pageType == 2)
|
|
1016
|
-
target.preNextPage(element, options, param, data.total);//上下两页页翻页
|
|
1017
|
-
else
|
|
1018
|
-
target.page(element, options, param, data.total);//多页翻页
|
|
1019
|
-
|
|
1020
|
-
if (param.page == 1)
|
|
1021
|
-
$(".be-list-page .previous").addClass("disabled");
|
|
1022
|
-
if (param.page == Math.ceil(data.total / options.rp))
|
|
1023
|
-
$(".be-list-page .next").addClass("disabled");
|
|
1024
|
-
|
|
1025
|
-
//全选/全清
|
|
1026
|
-
$(".ilist-check-all[data-flag='1']", element).checkAll({targets: ".ilist-check"});
|
|
1027
|
-
|
|
1028
|
-
//选择单列/取消选择单列
|
|
1029
|
-
$(".ilist-check", element).unbind("change");
|
|
1030
|
-
$(".ilist-check", element).change(function() {
|
|
1031
|
-
var isChecked = $(this).is(":checked");
|
|
1032
|
-
if (isChecked)
|
|
1033
|
-
$(this).parents("tr").addClass("active");
|
|
1034
|
-
else
|
|
1035
|
-
$(this).parents("tr").removeClass("active");
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
//全选列/全清列
|
|
1039
|
-
$(".ilist-check-all[data-flag='1']", element).unbind("change");
|
|
1040
|
-
$(".ilist-check-all[data-flag='1']", element).change(function() {
|
|
1041
|
-
var isChecked = $(this).is(":checked");
|
|
1042
|
-
if (isChecked)
|
|
1043
|
-
$(".ilist-check").addClass("active").change();
|
|
1044
|
-
else
|
|
1045
|
-
$(".ilist-check").removeClass("active").change();
|
|
1046
|
-
});
|
|
1047
|
-
|
|
1048
|
-
//点击列选择单列/点击列取消选择单列
|
|
1049
|
-
$("table > tbody tr", element).unbind("click");
|
|
1050
|
-
$("table > tbody tr", element).click(function(e) {
|
|
1051
|
-
var target = $(e.target);
|
|
1052
|
-
if (!(target.is("input") || target.is("i") || target.is("a"))) {
|
|
1053
|
-
$(".ilist-check", this).click();
|
|
1054
|
-
}
|
|
1055
|
-
})
|
|
1056
|
-
|
|
1057
|
-
//排序
|
|
1058
|
-
$("table > thead tr td", element).unbind("click");
|
|
1059
|
-
$("table > thead tr td", element).click(function(e) {
|
|
1060
|
-
param.sortname = $(this).data("sortname");
|
|
1061
|
-
|
|
1062
|
-
if (!$(this).hasClass("is-check") && param.sortname) {
|
|
1063
|
-
var sortorder = $(this).attr("data-sort-order");
|
|
1064
|
-
|
|
1065
|
-
$("table > thead tr td", element).removeAttr("data-sort-order");
|
|
1066
|
-
|
|
1067
|
-
if (sortorder) {
|
|
1068
|
-
if (sortorder == "desc") {
|
|
1069
|
-
$(this).attr("data-sort-order", "asc");
|
|
1070
|
-
sortorder = "asc";
|
|
1071
|
-
} else {
|
|
1072
|
-
$(this).attr("data-sort-order", "desc");
|
|
1073
|
-
sortorder = "desc";
|
|
1074
|
-
}
|
|
1075
|
-
param.sortorder = sortorder;
|
|
1076
|
-
} else {
|
|
1077
|
-
$(this).attr("data-sort-order", "desc");
|
|
1078
|
-
param.sortorder = "desc";
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
$element.data("be.ilist.flag", true);
|
|
1082
|
-
options.isPage = true;
|
|
1083
|
-
param.page = "1";
|
|
1084
|
-
target.getData(element, options, param);
|
|
1085
|
-
} else {
|
|
1086
|
-
$(this).css("cursor", "auto ! important");
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
});
|
|
1090
|
-
$(".be-list-page", element).css("visibility", "visible");
|
|
1091
|
-
} else {
|
|
1092
|
-
$(".be-list-nofound", element).css("display", "block");
|
|
1093
|
-
}
|
|
1094
|
-
},
|
|
1095
|
-
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
1096
|
-
try {
|
|
1097
|
-
if (options.onError) options.onError(XMLHttpRequest, textStatus, errorThrown);
|
|
1098
|
-
} catch (e) {}
|
|
1099
|
-
}
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
/** 分页查询 **/
|
|
1105
|
-
IList.prototype.page = function (element, options, param, total) {
|
|
1106
|
-
var rp = options.rp;
|
|
1107
|
-
if (options.rp == 0)
|
|
1108
|
-
rp = total;
|
|
1109
|
-
var totalPages = Math.ceil(total / rp);
|
|
1110
|
-
var target = this;
|
|
1111
|
-
var $element = $(element);
|
|
1112
|
-
|
|
1113
|
-
var end = ((param.page - 1) * rp + rp);
|
|
1114
|
-
if (end > total)
|
|
1115
|
-
end = total;
|
|
1116
|
-
|
|
1117
|
-
var html = "显示" + ((param.page - 1) * rp + 1) + "至 " + end + "条,共有" + total + "条 ";
|
|
1118
|
-
var first = "首页";
|
|
1119
|
-
var prev = "上一页";
|
|
1120
|
-
var next = "下一页";
|
|
1121
|
-
var last = "尾页";
|
|
1122
|
-
if (options.lang == "en") {
|
|
1123
|
-
html = "display data from " + ((param.page - 1) * rp + 1) + " to " + end + ",there are " + total + " data in total";
|
|
1124
|
-
first = "first";
|
|
1125
|
-
prev = "prev";
|
|
1126
|
-
next = "next";
|
|
1127
|
-
last = "last";
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
if ($element.data("be.ilist.flag")) {
|
|
1132
|
-
$(".pagination", element).parent().html("<span>" + html + "</span><ul class='pagination pagination-sm'></ul>");
|
|
1133
|
-
$(".pagination", element).twbsPagination({
|
|
1134
|
-
totalPages: totalPages,
|
|
1135
|
-
visiblePages: options.visiblePages,
|
|
1136
|
-
first: first,
|
|
1137
|
-
prev: prev,
|
|
1138
|
-
next: next,
|
|
1139
|
-
last: last,
|
|
1140
|
-
initiateStartPageClick: false,
|
|
1141
|
-
onPageClick: function(event, page) {
|
|
1142
|
-
param.page = page;
|
|
1143
|
-
var end = ((param.page - 1) * rp + rp);
|
|
1144
|
-
if (end > total)
|
|
1145
|
-
end = total;
|
|
1146
|
-
html = "显示 " + ((param.page - 1) * rp + 1) + " 至 " + end + " 条,共有 " + total + " 条";
|
|
1147
|
-
if (options.lang == "en")
|
|
1148
|
-
html = "display data from " + ((param.page - 1) * rp + 1) + " to " + end + ",there are " + total + " data in total";
|
|
1149
|
-
|
|
1150
|
-
$(".be-list-page > span", element).html(html);
|
|
1151
|
-
|
|
1152
|
-
options.isPage = true;
|
|
1153
|
-
|
|
1154
|
-
target.getData(element, options, param);
|
|
1155
|
-
}
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
$element.data("be.ilist.flag", false);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
/** 上下两页分页查询 **/
|
|
1162
|
-
IList.prototype.preNextPage = function (element, options, param, total) {
|
|
1163
|
-
var rp = options.rp;
|
|
1164
|
-
if (options.rp == 0)
|
|
1165
|
-
rp = total;
|
|
1166
|
-
var totalPages = Math.ceil(total / rp);
|
|
1167
|
-
var target = this;
|
|
1168
|
-
var $element = $(element);
|
|
1169
|
-
|
|
1170
|
-
var end = ((param.page - 1) * rp + rp);
|
|
1171
|
-
if (end > total)
|
|
1172
|
-
end = total;
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
$(document).off("click.clpp").on("click.clpp", ".be-list-page .previous:not(.disabled)", function(e) {
|
|
1176
|
-
param.page = param.page - 1;
|
|
1177
|
-
$(".be-list-page .next").removeClass("disabled");
|
|
1178
|
-
|
|
1179
|
-
if (param.page == 1) {
|
|
1180
|
-
$(this).addClass("disabled");
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
options.isPage = true;
|
|
1184
|
-
target.getData(element, options, param);
|
|
1185
|
-
});
|
|
1186
|
-
$(document).off("click.clpn").on("click.clpn", ".be-list-page .next:not(.disabled)", function(e) {
|
|
1187
|
-
param.page = param.page + 1;
|
|
1188
|
-
$(".be-list-page .previous").removeClass("disabled");
|
|
1189
|
-
|
|
1190
|
-
if (param.page == totalPages) {
|
|
1191
|
-
$(this).addClass("disabled");
|
|
1192
|
-
}
|
|
1193
|
-
options.isPage = true;
|
|
1194
|
-
target.getData(element, options, param);
|
|
1195
|
-
});
|
|
1196
|
-
|
|
1197
|
-
$element.data("be.ilist.flag", false);
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
/** 参数追加搜索 **/
|
|
1201
|
-
$.fn.iListReload = function (param) {
|
|
1202
|
-
var $this = $(this);
|
|
1203
|
-
var data = $this.data("be.ilist");
|
|
1204
|
-
|
|
1205
|
-
for (var pa in param) {
|
|
1206
|
-
if (typeof param[pa] == "string" && param[pa].trim() == "") {
|
|
1207
|
-
data.options.param[pa] = undefined;
|
|
1208
|
-
param[pa] = undefined;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
// var p = $.extend({}, data.options.param, param);
|
|
1213
|
-
// data.options.param = p;
|
|
1214
|
-
|
|
1215
|
-
data.options.param = param;
|
|
1216
|
-
data["init"](this, data.options);
|
|
1217
|
-
// $this.data("be.ilist", (data = new IList(this, data.options)));
|
|
1218
|
-
};
|
|
1219
|
-
|
|
1220
|
-
$.fn.iList = function (option) {
|
|
1221
|
-
return this.each(function () {
|
|
1222
|
-
var $this = $(this);
|
|
1223
|
-
var data = $this.data("be.ilist");
|
|
1224
|
-
|
|
1225
|
-
var options = $.extend({}, IList.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
1226
|
-
if (!data)
|
|
1227
|
-
$this.data("be.ilist", (data = new IList(this, options)));
|
|
1228
|
-
else
|
|
1229
|
-
data["init"](this, options);
|
|
1230
|
-
});
|
|
1231
|
-
};
|
|
1232
|
-
}(jQuery);
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
/* ========================================================================
|
|
1236
|
-
* 11. 元素显示切换
|
|
1237
|
-
* 2017年1月27日19:29:08
|
|
1238
|
-
* ========================================================================
|
|
1239
|
-
|
|
1240
|
-
<div class="ce-switch ce-switch-1 current">11111</div>
|
|
1241
|
-
<div class="ce-switch ce-switch-1 current">22222</div>
|
|
1242
|
-
<div class="ce-switch ce-switch-1 ce-switch-2 current">3333</div>
|
|
1243
|
-
<div class="ce-switch ce-switch-2">44444</div>
|
|
1244
|
-
|
|
1245
|
-
<button class="iswitch" data-show="ce-switch-1">a</button>
|
|
1246
|
-
<button class="iswitch" data-show="ce-switch-2">b</button>
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
<select id="iswitch-select">
|
|
1251
|
-
<option data-show="ce-switch-1">a</option>
|
|
1252
|
-
<option data-show="ce-switch-2">b</option>
|
|
1253
|
-
</select>
|
|
1254
|
-
|
|
1255
|
-
$(".iswitch").iSwitch({module: ".ce-switch2"});
|
|
1256
|
-
|
|
1257
|
-
$("#iswitch-select").iSwitch();
|
|
1258
|
-
|
|
1259
|
-
* ======================================================================== */
|
|
1260
|
-
+function ($) {
|
|
1261
|
-
|
|
1262
|
-
var ISwitch = function (element, options) {
|
|
1263
|
-
this.$element = $(element);
|
|
1264
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1265
|
-
|
|
1266
|
-
this.init(this.options);
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
|
-
ISwitch.DEFAULTS = {
|
|
1270
|
-
module: ".ce-switch"
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
|
-
ISwitch.prototype.init = function (options) {
|
|
1274
|
-
var $element = this.$element;
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if ($element.is("select")) {
|
|
1278
|
-
$element.change(function() {
|
|
1279
|
-
$(options.module).removeClass("current");
|
|
1280
|
-
|
|
1281
|
-
var className = $element.find("option:selected").data("show");
|
|
1282
|
-
$("." + className).addClass("current").removeClass("hide");;
|
|
1283
|
-
});
|
|
1284
|
-
} else if($element.is("a") || $element.is("button")) {
|
|
1285
|
-
$element.click(function() {
|
|
1286
|
-
var className = $(this).data("show");
|
|
1287
|
-
$(options.module).removeClass("current").addClass("hide");
|
|
1288
|
-
$("." + className).addClass("current").removeClass("hide");
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
};
|
|
1293
|
-
|
|
1294
|
-
$.fn.iSwitch = function (option) {
|
|
1295
|
-
return this.each(function () {
|
|
1296
|
-
var $this = $(this);
|
|
1297
|
-
var data = $this.data("be.iswitch");
|
|
1298
|
-
|
|
1299
|
-
var options = $.extend({}, ISwitch.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
1300
|
-
if (!data)
|
|
1301
|
-
$this.data("be.iswitch", (data = new ISwitch(this, options)));
|
|
1302
|
-
else
|
|
1303
|
-
data["init"]();
|
|
1304
|
-
});
|
|
1305
|
-
};
|
|
1306
|
-
}(jQuery);
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
/* ========================================================================
|
|
1310
|
-
* 12. 管理后台模式TAB页面
|
|
1311
|
-
* 2017年2月8日19:46:03
|
|
1312
|
-
* ========================================================================
|
|
1313
|
-
|
|
1314
|
-
$(".a").iTab();
|
|
1315
|
-
|
|
1316
|
-
<a href="#" class="a" data-page="test1.jsp">aaa</a>
|
|
1317
|
-
<a href="#" class="a" data-page="test2.jsp">aaa</a>
|
|
1318
|
-
|
|
1319
|
-
<div id="be-main" class="tab-panel ce-tab-panel">
|
|
1320
|
-
<ul class="nav nav-tabs" >
|
|
1321
|
-
<li class="active">
|
|
1322
|
-
<a href="#be-main-p1" data-toggle="tab">Home
|
|
1323
|
-
</a>
|
|
1324
|
-
<button class="close">X</button>
|
|
1325
|
-
</li>
|
|
1326
|
-
<li><a href="#be-main-p2" data-toggle="tab">Profile</a><button class="close">X</button></li>
|
|
1327
|
-
</ul>
|
|
1328
|
-
|
|
1329
|
-
<div class="tab-content">
|
|
1330
|
-
<div class="tab-pane fade in active" id="be-main-p1">a</div>
|
|
1331
|
-
<div class="tab-pane fade" id="be-main-p2">b</div>
|
|
1332
|
-
</div>
|
|
1333
|
-
</div>
|
|
1334
|
-
* ======================================================================== */
|
|
1335
|
-
+function ($) {
|
|
1336
|
-
|
|
1337
|
-
var ITab = function (element, options) {
|
|
1338
|
-
this.$element = $(element);
|
|
1339
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1340
|
-
|
|
1341
|
-
this.init(this.options);
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
|
-
ITab.DEFAULTS = {
|
|
1345
|
-
module: "#itab-main",
|
|
1346
|
-
isReload: false
|
|
1347
|
-
};
|
|
1348
|
-
|
|
1349
|
-
ITab.prototype.init = function (options) {
|
|
1350
|
-
var $element = this.$element;
|
|
1351
|
-
this.remove(options);
|
|
1352
|
-
};
|
|
1353
|
-
|
|
1354
|
-
ITab.prototype.add = function (element) {
|
|
1355
|
-
var $element = $(element);
|
|
1356
|
-
var page = $element.data("page");
|
|
1357
|
-
var isReload = $element.data("reload");
|
|
1358
|
-
var i = page.replaceAll("\\.", "-").replaceAll("\\/", "-");
|
|
1359
|
-
var isOpen = $("#be-main-p" + (i + 1)).size() >= 1;
|
|
1360
|
-
|
|
1361
|
-
var module = ITab.DEFAULTS.module;
|
|
1362
|
-
if (isOpen) {
|
|
1363
|
-
$(".nav-tabs li > a[data-page='" + page + "']", module).click();
|
|
1364
|
-
|
|
1365
|
-
if (isReload) {
|
|
1366
|
-
var data = new Object();
|
|
1367
|
-
var t = $element.data();
|
|
1368
|
-
for (var p in t) {
|
|
1369
|
-
var isBs = p.indexOf(".");
|
|
1370
|
-
if (isBs <= 0)
|
|
1371
|
-
data[p] = t[p];
|
|
1372
|
-
}
|
|
1373
|
-
$("#be-main-p" + (i + 1)).load(page, data, function() {});
|
|
1374
|
-
}
|
|
1375
|
-
} else {
|
|
1376
|
-
|
|
1377
|
-
var len = $(".nav-tabs li", module).size();
|
|
1378
|
-
var name = $element.data("name");
|
|
1379
|
-
if (!name)
|
|
1380
|
-
name = $element.text();
|
|
1381
|
-
|
|
1382
|
-
if (len) {
|
|
1383
|
-
$(".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>");
|
|
1384
|
-
$(".tab-content .tab-pane:last", module).after("<div class=\"tab-pane fade\" id=\"be-main-p" + (i + 1) + "\"></div>");
|
|
1385
|
-
$(".nav-tabs li:last > a", module).click();
|
|
1386
|
-
} else {
|
|
1387
|
-
$(".nav-tabs", module).html("<li><a href=\"#be-main-p" + (i + 1) + "\" data-toggle=\"tab\">" + name + "</a><button class=\"close\">X</button></li>");
|
|
1388
|
-
$(".tab-content", module).html("<div class=\"tab-pane fade\" id=\"be-main-p" + (i + 1) + "\"></div>");
|
|
1389
|
-
$(".nav-tabs li:last > a", module).click();
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
$(".nav-tabs li:last > a", module).attr("data-page", page);
|
|
1393
|
-
|
|
1394
|
-
var data = new Object();
|
|
1395
|
-
var t = $element.data();
|
|
1396
|
-
for (var p in t) {
|
|
1397
|
-
var isBs = p.indexOf(".");
|
|
1398
|
-
if (isBs <= 0)
|
|
1399
|
-
data[p] = t[p];
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
$("#be-main-p" + (i + 1)).load(page, data, function() {});
|
|
1403
|
-
}
|
|
1404
|
-
};
|
|
1405
|
-
|
|
1406
|
-
ITab.prototype.remove = function (options) {
|
|
1407
|
-
var t = this.$element;
|
|
1408
|
-
$(options.module).on("click", ".close", function() {
|
|
1409
|
-
var html = $(".nav-tabs", options.module).html();
|
|
1410
|
-
|
|
1411
|
-
var target = $(this).parents("li");
|
|
1412
|
-
var isActive = target.hasClass("active");
|
|
1413
|
-
|
|
1414
|
-
if (isActive) {
|
|
1415
|
-
$(".nav-tabs", options.module).html(html.replace("<li class=\"active\">" + target.html() + "</li>", ""));
|
|
1416
|
-
var href = $("a", target).attr("href");
|
|
1417
|
-
$(href).attr("id", "").html("");
|
|
1418
|
-
$(".nav-tabs li:last > a", options.module).click();
|
|
1419
|
-
} else {
|
|
1420
|
-
var href = $("a", target).attr("href");
|
|
1421
|
-
$(href).attr("id", "").html("");
|
|
1422
|
-
$(".nav-tabs", options.module).html(html.replace("<li>" + target.html() + "</li>", "").replace("<li class=\"\">" + target.html() + "</li>", ""));
|
|
1423
|
-
}
|
|
1424
|
-
})
|
|
1425
|
-
};
|
|
1426
|
-
|
|
1427
|
-
$.fn.iTab = function (option) {
|
|
1428
|
-
return this.each(function () {
|
|
1429
|
-
var $this = $(this);
|
|
1430
|
-
var data = $this.data("be.itab");
|
|
1431
|
-
|
|
1432
|
-
var options = $.extend({}, ITab.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
1433
|
-
if (!data)
|
|
1434
|
-
$this.data("be.itab", (data = new ITab(this, options)));
|
|
1435
|
-
else
|
|
1436
|
-
data["init"]();
|
|
1437
|
-
});
|
|
1438
|
-
};
|
|
1439
|
-
|
|
1440
|
-
$(document).on("click", "[data-toggle='itab']", function(e) {
|
|
1441
|
-
ITab.prototype.add(this);
|
|
1442
|
-
});
|
|
1443
|
-
}(jQuery);
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
/* ========================================================================
|
|
1447
|
-
* 13. 多选框反选
|
|
1448
|
-
* 2017年6月19日10:53:26
|
|
1449
|
-
* ========================================================================
|
|
1450
|
-
|
|
1451
|
-
$("#be-reverse-check").checkReverse({
|
|
1452
|
-
targets: ".be-check"
|
|
1453
|
-
})
|
|
1454
|
-
|
|
1455
|
-
<a href="#" id="be-reverse-check"/>反选</a>
|
|
1456
|
-
<input type="checkbox" class="be-check" checked="checked"/>选项一
|
|
1457
|
-
<input type="checkbox" class="be-check"/>选项二
|
|
1458
|
-
|
|
1459
|
-
* ======================================================================== */
|
|
1460
|
-
+function ($) {
|
|
1461
|
-
|
|
1462
|
-
var CheckReverse = function (element, options) {
|
|
1463
|
-
this.$element = $(element);
|
|
1464
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1465
|
-
|
|
1466
|
-
this.$element.on("click", this.options, this.init);
|
|
1467
|
-
};
|
|
1468
|
-
|
|
1469
|
-
CheckReverse.DEFAULTS = {
|
|
1470
|
-
targets: ".be-check",
|
|
1471
|
-
checkedFlag: "checked-now",
|
|
1472
|
-
uncheckedFlag: "unchecked-now"
|
|
1473
|
-
};
|
|
1474
|
-
|
|
1475
|
-
CheckReverse.prototype.init = function (e) {
|
|
1476
|
-
var options = e.data;
|
|
1477
|
-
$(options.targets).addClass(options.uncheckedFlag);
|
|
1478
|
-
$(options.targets + ":checked").removeClass(options.uncheckedFlag).addClass(options.checkedFlag);
|
|
1479
|
-
|
|
1480
|
-
var data = e.data;
|
|
1481
|
-
var a = $("." + data.checkedFlag);
|
|
1482
|
-
var b = $("." + data.uncheckedFlag);
|
|
1483
|
-
a.removeClass(data.checkedFlag).addClass(data.uncheckedFlag).prop("checked", false);
|
|
1484
|
-
b.addClass(data.checkedFlag).removeClass(data.uncheckedFlag).prop("checked", true);
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
CheckReverse.prototype.destroy = function () {
|
|
1488
|
-
$(this).removeData("be.checkreverse");
|
|
1489
|
-
};
|
|
1490
|
-
|
|
1491
|
-
$.fn.checkReverse = function (option) {
|
|
1492
|
-
return this.each(function () {
|
|
1493
|
-
var $this = $(this);
|
|
1494
|
-
var data = $this.data("be.checkreverse");
|
|
1495
|
-
var options = $.extend({}, CheckReverse.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
1496
|
-
|
|
1497
|
-
if (!data) $this.data("be.checkreverse", (data = new CheckReverse(this, options)));
|
|
1498
|
-
if (typeof option == "string") data[option]();
|
|
1499
|
-
});
|
|
1500
|
-
};
|
|
1501
|
-
}(jQuery);
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
/* ========================================================================
|
|
1505
|
-
* 14. 数字增加减少,购物数量控制
|
|
1506
|
-
* 2018年1月20日22:14:46
|
|
1507
|
-
* ========================================================================
|
|
1508
|
-
|
|
1509
|
-
$(".fmc1").itemCount({num: 6});
|
|
1510
|
-
|
|
1511
|
-
<div class="fm-count fmc1">
|
|
1512
|
-
<input class="form-control fmc-result" type="text" value="1" readonly="">
|
|
1513
|
-
<div class="fmc-btns">
|
|
1514
|
-
<i class="fmc-plus fa fa-angle-up"></i>
|
|
1515
|
-
<i class="fmc-minus fa fa-angle-down"></i>
|
|
1516
|
-
</div>
|
|
1517
|
-
</div>
|
|
1518
|
-
|
|
1519
|
-
* ======================================================================== */
|
|
1520
|
-
+function ($) {
|
|
1521
|
-
|
|
1522
|
-
var ItemCount = function (element, options) {
|
|
1523
|
-
this.$element = $(element);
|
|
1524
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1525
|
-
|
|
1526
|
-
this.init(this);
|
|
1527
|
-
};
|
|
1528
|
-
|
|
1529
|
-
ItemCount.DEFAULTS = {
|
|
1530
|
-
num: 1
|
|
1531
|
-
};
|
|
1532
|
-
|
|
1533
|
-
ItemCount.prototype.init = function (e) {
|
|
1534
|
-
var $this = $(e.$element),
|
|
1535
|
-
options = e.options,
|
|
1536
|
-
$plus = $this.find(".fmc-plus"),
|
|
1537
|
-
$minus = $this.find(".fmc-minus"),
|
|
1538
|
-
$result = $this.find(".fmc-result"),
|
|
1539
|
-
resultVal = parseInt($result.val());
|
|
1540
|
-
|
|
1541
|
-
$plus.on("click", function (e) {
|
|
1542
|
-
e.preventDefault();
|
|
1543
|
-
resultVal += options.num;
|
|
1544
|
-
$result.val(resultVal);
|
|
1545
|
-
});
|
|
1546
|
-
|
|
1547
|
-
$minus.on("click", function (e) {
|
|
1548
|
-
e.preventDefault();
|
|
1549
|
-
|
|
1550
|
-
if (resultVal - options.num >= 0) {
|
|
1551
|
-
resultVal -= options.num;
|
|
1552
|
-
|
|
1553
|
-
$result.val(resultVal);
|
|
1554
|
-
} else {
|
|
1555
|
-
return false;
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
};
|
|
1559
|
-
|
|
1560
|
-
ItemCount.prototype.destroy = function () {
|
|
1561
|
-
$(this).removeData("be.itemcount");
|
|
1562
|
-
};
|
|
1563
|
-
|
|
1564
|
-
$.fn.itemCount = function (option) {
|
|
1565
|
-
return this.each(function () {
|
|
1566
|
-
var $this = $(this);
|
|
1567
|
-
var data = $this.data("be.itemcount");
|
|
1568
|
-
var options = $.extend({}, ItemCount.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
1569
|
-
|
|
1570
|
-
if (!data) $this.data("be.itemcount", (data = new ItemCount(this, options)));
|
|
1571
|
-
if (typeof option == "string") data[option]();
|
|
1572
|
-
});
|
|
1573
|
-
};
|
|
1574
|
-
}(jQuery);
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
/* ========================================================================
|
|
1579
|
-
* 15. 绘制点线动画
|
|
1580
|
-
* 2018年6月2日09:54:29
|
|
1581
|
-
* ========================================================================
|
|
1582
|
-
|
|
1583
|
-
<script type="text/javascript" src="WEB/js/tweenlite/easepack.min.js"></script>
|
|
1584
|
-
<script type="text/javascript" src="WEB/js/tweenlite/tweenlite.min.js"></script>
|
|
1585
|
-
|
|
1586
|
-
$(function() {
|
|
1587
|
-
$("#container").lineEffect({
|
|
1588
|
-
//pointColor: "rgba(0, 0, 0, 1)",
|
|
1589
|
-
//lineColor: "0, 0, 0" ,
|
|
1590
|
-
//height: 302,
|
|
1591
|
-
isWindowWidth: true,
|
|
1592
|
-
num: 11,
|
|
1593
|
-
canvasId: "iCanvas"
|
|
1594
|
-
});
|
|
1595
|
-
})
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
<div id="container" >
|
|
1599
|
-
<canvas id="iCanvas"></canvas>
|
|
1600
|
-
</div>
|
|
1601
|
-
|
|
1602
|
-
* ======================================================================== */
|
|
1603
|
-
+function ($) {
|
|
1604
|
-
|
|
1605
|
-
var LineEffect = function (element, options) {
|
|
1606
|
-
this.$element = $(element);
|
|
1607
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1608
|
-
|
|
1609
|
-
this.init(this);
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
|
-
LineEffect.DEFAULTS = {
|
|
1613
|
-
canvasId: "targetCanvas",
|
|
1614
|
-
animateHeader: true,
|
|
1615
|
-
|
|
1616
|
-
width: window.innerWidth,
|
|
1617
|
-
height: window.innerHeight,
|
|
1618
|
-
isWindowWidth: false,
|
|
1619
|
-
isWindowHeight: false,
|
|
1620
|
-
num: 20,
|
|
1621
|
-
|
|
1622
|
-
pointColor: "156,217,249", //点颜色
|
|
1623
|
-
lineColor: "156,217,249" //线颜色
|
|
1624
|
-
};
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
LineEffect.prototype.init = function (e) {
|
|
1628
|
-
var $this = $(e.$element),
|
|
1629
|
-
options = e.options,
|
|
1630
|
-
thisTarget = this;
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
var target = {x: options.width/2, y: options.height/2};
|
|
1634
|
-
|
|
1635
|
-
var canvas = document.getElementById(options.canvasId);
|
|
1636
|
-
canvas.width = options.width;
|
|
1637
|
-
canvas.height = options.height;
|
|
1638
|
-
var ctx = canvas.getContext("2d");
|
|
1639
|
-
|
|
1640
|
-
// create points
|
|
1641
|
-
var points = [];
|
|
1642
|
-
for(var x = 0; x < options.width; x = x + options.width / options.num) {
|
|
1643
|
-
for(var y = 0; y < options.height; y = y + options.height / options.num) {
|
|
1644
|
-
var px = x + Math.random() * options.width / options.num;
|
|
1645
|
-
var py = y + Math.random() * options.height / options.num;
|
|
1646
|
-
var p = {x: px, originX: px, y: py, originY: py };
|
|
1647
|
-
points.push(p);
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
// for each point find the 5 closest points
|
|
1652
|
-
for(var i = 0; i < points.length; i++) {
|
|
1653
|
-
var closest = [];
|
|
1654
|
-
var p1 = points[i];
|
|
1655
|
-
for(var j = 0; j < points.length; j++) {
|
|
1656
|
-
var p2 = points[j]
|
|
1657
|
-
if(!(p1 == p2)) {
|
|
1658
|
-
var placed = false;
|
|
1659
|
-
for(var k = 0; k < 5; k++) {
|
|
1660
|
-
if(!placed) {
|
|
1661
|
-
if(closest[k] == undefined) {
|
|
1662
|
-
closest[k] = p2;
|
|
1663
|
-
placed = true;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
for(var k = 0; k < 5; k++) {
|
|
1669
|
-
if(!placed) {
|
|
1670
|
-
if(thisTarget.getDistance(p1, p2) < thisTarget.getDistance(p1, closest[k])) {
|
|
1671
|
-
closest[k] = p2;
|
|
1672
|
-
placed = true;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
p1.closest = closest;
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
// assign a circle to each point
|
|
1683
|
-
for(var i in points) {
|
|
1684
|
-
var c = new thisTarget.Circle(options, points[i], 2 + Math.random() * 2);
|
|
1685
|
-
points[i].circle = c;
|
|
1686
|
-
}
|
|
1687
|
-
options.points = points;
|
|
1688
|
-
thisTarget.initAnimation(options, ctx, target);
|
|
1689
|
-
thisTarget.addListeners(options, target, canvas);
|
|
1690
|
-
};
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
LineEffect.prototype.getDistance = function(p1, p2) {
|
|
1695
|
-
return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
|
|
1696
|
-
};
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
LineEffect.prototype.Circle = function(options, pos, rad) {
|
|
1700
|
-
var _this = this;
|
|
1701
|
-
// constructor
|
|
1702
|
-
(function() {
|
|
1703
|
-
_this.pos = pos || null;
|
|
1704
|
-
_this.radius = rad || null;
|
|
1705
|
-
// _this.color = color || null;
|
|
1706
|
-
})();
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
this.draw = function(ctx) {
|
|
1710
|
-
if(!_this.active) return;
|
|
1711
|
-
ctx.beginPath();
|
|
1712
|
-
ctx.arc(_this.pos.x, _this.pos.y, _this.radius, 0, 2 * Math.PI, false);
|
|
1713
|
-
ctx.fillStyle = "rgba(" + options.pointColor + "," + _this.active + ")";
|
|
1714
|
-
|
|
1715
|
-
ctx.fill();
|
|
1716
|
-
};
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
/**----------------- 开始绘制动画效果 -----------------------**/
|
|
1721
|
-
LineEffect.prototype.initAnimation = function(options, ctx, target) {
|
|
1722
|
-
var thisTarget = this;
|
|
1723
|
-
thisTarget.animate(options, ctx, target);
|
|
1724
|
-
for(var i in options.points) {
|
|
1725
|
-
thisTarget.shiftPoint(options.points[i]);
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
LineEffect.prototype.animate = function(options, ctx, target) {
|
|
1730
|
-
var thisTarget = this;
|
|
1731
|
-
if(options.animateHeader) {
|
|
1732
|
-
|
|
1733
|
-
var points = options.points;
|
|
1734
|
-
ctx.clearRect(0, 0, options.width, options.height);
|
|
1735
|
-
for(var i in points) {
|
|
1736
|
-
// detect points in range
|
|
1737
|
-
if(Math.abs(thisTarget.getDistance(target, points[i])) < 4000) {
|
|
1738
|
-
points[i].active = 0.3;
|
|
1739
|
-
points[i].circle.active = 0.6;
|
|
1740
|
-
} else if(Math.abs(thisTarget.getDistance(target, points[i])) < 20000) {
|
|
1741
|
-
points[i].active = 0.1;
|
|
1742
|
-
points[i].circle.active = 0.3;
|
|
1743
|
-
} else if(Math.abs(thisTarget.getDistance(target, points[i])) < 40000) {
|
|
1744
|
-
points[i].active = 0.02;
|
|
1745
|
-
points[i].circle.active = 0.1;
|
|
1746
|
-
} else {
|
|
1747
|
-
points[i].active = 0;
|
|
1748
|
-
points[i].circle.active = 0;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
thisTarget.drawLines(options, points[i], ctx);
|
|
1752
|
-
points[i].circle.draw(ctx);
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
requestAnimationFrame(function() {
|
|
1756
|
-
thisTarget.animate(options, ctx, target)
|
|
1757
|
-
});
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
/**----------------- 开始绘制动画效果 - 点 -----------------------**/
|
|
1762
|
-
LineEffect.prototype.shiftPoint = function(p) {
|
|
1763
|
-
var thisTarget = this;
|
|
1764
|
-
TweenLite.to(p,
|
|
1765
|
-
1 + 1 * Math.random(),
|
|
1766
|
-
{
|
|
1767
|
-
x: p.originX - 50 + Math.random() * 100,
|
|
1768
|
-
y: p.originY - 50 + Math.random() * 100,
|
|
1769
|
-
ease:Circ.easeInOut,
|
|
1770
|
-
onComplete: function() {
|
|
1771
|
-
thisTarget.shiftPoint(p);
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
);
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
/**----------------- 开始绘制动画效果 - 线 -----------------------**/
|
|
1778
|
-
LineEffect.prototype.drawLines = function(options, p, ctx) {
|
|
1779
|
-
if(!p.active) return;
|
|
1780
|
-
for(var i in p.closest) {
|
|
1781
|
-
ctx.beginPath();
|
|
1782
|
-
ctx.moveTo(p.x, p.y);
|
|
1783
|
-
ctx.lineTo(p.closest[i].x, p.closest[i].y);
|
|
1784
|
-
ctx.strokeStyle = "rgba(" + options.lineColor + "," + p.active + ")";
|
|
1785
|
-
ctx.stroke();
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
/**----------------- 监听事件,移动鼠标, 滚动, 改变屏幕大小 -----------------------**/
|
|
1791
|
-
LineEffect.prototype.addListeners = function(options, target, canvas) {
|
|
1792
|
-
var thisTarget = this;
|
|
1793
|
-
if(!('ontouchstart' in window)) {
|
|
1794
|
-
window.addEventListener("mousemove",
|
|
1795
|
-
function(e) {
|
|
1796
|
-
thisTarget.mouseMove(e, target);
|
|
1797
|
-
}
|
|
1798
|
-
);
|
|
1799
|
-
}
|
|
1800
|
-
window.addEventListener("scroll",
|
|
1801
|
-
function(e) {
|
|
1802
|
-
thisTarget.scrollCheck(options);
|
|
1803
|
-
}
|
|
1804
|
-
);
|
|
1805
|
-
window.addEventListener("resize",
|
|
1806
|
-
function(e) {
|
|
1807
|
-
thisTarget.resize(options, canvas);
|
|
1808
|
-
}
|
|
1809
|
-
);
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
LineEffect.prototype.mouseMove = function(e, target) {
|
|
1813
|
-
var offsetTop = this.$element.offset().top
|
|
1814
|
-
var offsetLeft = this.$element.offset().left
|
|
1815
|
-
|
|
1816
|
-
var posx = posy = 0;
|
|
1817
|
-
if (e.pageX || e.pageY) {
|
|
1818
|
-
posx = e.pageX;
|
|
1819
|
-
posy = e.pageY;
|
|
1820
|
-
}
|
|
1821
|
-
else if (e.clientX || e.clientY) {
|
|
1822
|
-
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
|
1823
|
-
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
|
1824
|
-
}
|
|
1825
|
-
target.x = posx - offsetLeft;
|
|
1826
|
-
target.y = posy - offsetTop;
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
LineEffect.prototype.scrollCheck = function(options) {
|
|
1830
|
-
if(document.body.scrollTop > options.height) options.animateHeader = false;
|
|
1831
|
-
else options.animateHeader = true;
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
LineEffect.prototype.resize = function(options, canvas) {
|
|
1835
|
-
if (options.isWindowWidth)
|
|
1836
|
-
canvas.width = window.innerWidth;
|
|
1837
|
-
|
|
1838
|
-
if (options.isWindowHeight)
|
|
1839
|
-
canvas.height = window.innerHeight;
|
|
1840
|
-
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
/**----------------- 销毁 -----------------------**/
|
|
1845
|
-
LineEffect.prototype.destroy = function () {
|
|
1846
|
-
$(this).removeData("be.lineEffect");
|
|
1847
|
-
};
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
$.fn.lineEffect = function (option) {
|
|
1851
|
-
return this.each(function () {
|
|
1852
|
-
var $this = $(this);
|
|
1853
|
-
var data = $this.data("be.lineEffect");
|
|
1854
|
-
options = $.extend({}, LineEffect.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
1855
|
-
|
|
1856
|
-
if (!data) $this.data("be.lineEffect", (data = new LineEffect(this, options)));
|
|
1857
|
-
if (typeof option == "string") data[option]();
|
|
1858
|
-
});
|
|
1859
|
-
};
|
|
1860
|
-
}(jQuery);
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
/* ========================================================================
|
|
1864
|
-
* 16.底部按钮快速移动到顶部
|
|
1865
|
-
* 2018年7月3日11:55:06
|
|
1866
|
-
* ========================================================================
|
|
1867
|
-
|
|
1868
|
-
$(function() {
|
|
1869
|
-
//参数赋值,js构造方法赋值优先级高于html中data-*中赋值
|
|
1870
|
-
$(".ce-gotop").gotop({
|
|
1871
|
-
position: {
|
|
1872
|
-
"bottom": 15,
|
|
1873
|
-
"right": 15
|
|
1874
|
-
},
|
|
1875
|
-
showeffect: "zoomIn",
|
|
1876
|
-
type: "fixed",
|
|
1877
|
-
offsettop: "400"
|
|
1878
|
-
});
|
|
1879
|
-
})
|
|
1880
|
-
|
|
1881
|
-
<a class="ce-gotop" href="#">
|
|
1882
|
-
<i class="fa fa-angle-up"></i>
|
|
1883
|
-
</a>
|
|
1884
|
-
或者可以直接在a标签添加如下属性
|
|
1885
|
-
data-type="fixed"
|
|
1886
|
-
data-position='{
|
|
1887
|
-
"bottom": 15,
|
|
1888
|
-
"right": 15
|
|
1889
|
-
}'
|
|
1890
|
-
data-offsettop="400"
|
|
1891
|
-
data-showeffect="zoomIn"
|
|
1892
|
-
|
|
1893
|
-
* ======================================================================== */
|
|
1894
|
-
+function ($) {
|
|
1895
|
-
|
|
1896
|
-
var GoTop = function (element, options) {
|
|
1897
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1898
|
-
this.$element = $(element);
|
|
1899
|
-
|
|
1900
|
-
this.init(this.$element, this.options);
|
|
1901
|
-
};
|
|
1902
|
-
|
|
1903
|
-
GoTop.DEFAULTS = {
|
|
1904
|
-
position: {
|
|
1905
|
-
"bottom": 15,
|
|
1906
|
-
"right": 15
|
|
1907
|
-
},
|
|
1908
|
-
showeffect: " animate__zoomIn ",
|
|
1909
|
-
hideeffect: " animate__zoomOut ",
|
|
1910
|
-
type: "fixed",
|
|
1911
|
-
offsettop: "400",
|
|
1912
|
-
compensation: "#js-header"
|
|
1913
|
-
};
|
|
1914
|
-
|
|
1915
|
-
GoTop.prototype.init = function (element, options) {
|
|
1916
|
-
this.$element = $(element);
|
|
1917
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
1918
|
-
|
|
1919
|
-
this.initGoTop(this);
|
|
1920
|
-
};
|
|
1921
|
-
|
|
1922
|
-
GoTop.prototype.initGoTop = function (e) {
|
|
1923
|
-
var options = e.options;
|
|
1924
|
-
e.$element.each(function (i, el) {
|
|
1925
|
-
//Variables
|
|
1926
|
-
|
|
1927
|
-
var $this = $(el),
|
|
1928
|
-
$target = $this.data("target"),
|
|
1929
|
-
type = options.type,
|
|
1930
|
-
showeffect = options.showeffect,
|
|
1931
|
-
position = options.position,
|
|
1932
|
-
compensation = $(options.compensation).outerHeight(),
|
|
1933
|
-
offsettop = options.offsettop,
|
|
1934
|
-
hideeffect = options.hideeffect;
|
|
1935
|
-
|
|
1936
|
-
$this.addClass("animate__animated").css({
|
|
1937
|
-
"display": "inline-block",
|
|
1938
|
-
"position": type,
|
|
1939
|
-
"opacity": 0
|
|
1940
|
-
});
|
|
1941
|
-
|
|
1942
|
-
if (type == "fixed" || type == "absolute") {
|
|
1943
|
-
$this.css(position);
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
$this.on("click", function (e) {
|
|
1947
|
-
e.preventDefault();
|
|
1948
|
-
scrollTo(0, 0);
|
|
1949
|
-
// $("html, body").stop().animate({
|
|
1950
|
-
// "scrollTop": $target ? $($target).offset().top - compensation : 0
|
|
1951
|
-
// }, 300);
|
|
1952
|
-
});
|
|
1953
|
-
|
|
1954
|
-
if (!offsettop && !$this.hasClass("animated-running")) {
|
|
1955
|
-
if ($this.offset().top <= $(window).height()) {
|
|
1956
|
-
$this.addClass("animated-running " + showeffect).css({
|
|
1957
|
-
"opacity": ""
|
|
1958
|
-
});
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
$(window).on("scroll", function () {
|
|
1963
|
-
if (offsettop) {
|
|
1964
|
-
if ($(window).scrollTop() >= offsettop && !$this.hasClass("animated-running")) {
|
|
1965
|
-
$this.addClass("animated-running " + showeffect).css({
|
|
1966
|
-
"opacity": ""
|
|
1967
|
-
});
|
|
1968
|
-
$this.removeClass(hideeffect);
|
|
1969
|
-
} else if ($(window).scrollTop() <= offsettop && $this.hasClass("animated-running")) {
|
|
1970
|
-
$this.removeClass("animated-running " + showeffect).css({
|
|
1971
|
-
"opacity": 0
|
|
1972
|
-
});
|
|
1973
|
-
$this.addClass(hideeffect);
|
|
1974
|
-
}
|
|
1975
|
-
} else {
|
|
1976
|
-
var thisOffsetTop = $this.offset().top;
|
|
1977
|
-
|
|
1978
|
-
if (!$this.hasClass("animated-running")) {
|
|
1979
|
-
if ($(window).scrollTop() >= thisOffsetTop - $(window).height()) {
|
|
1980
|
-
$this.addClass("animated-running " + showeffect).css({
|
|
1981
|
-
"opacity": ""
|
|
1982
|
-
});
|
|
1983
|
-
$this.removeClass(hideeffect);
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
});
|
|
1988
|
-
|
|
1989
|
-
$(window).trigger("scroll");
|
|
1990
|
-
//Actions
|
|
1991
|
-
//collection = collection.add($this);
|
|
1992
|
-
});
|
|
1993
|
-
};
|
|
1994
|
-
|
|
1995
|
-
var old = $.fn.gotop;
|
|
1996
|
-
$.fn.gotop = function (option) {
|
|
1997
|
-
return this.each(function () {
|
|
1998
|
-
var $this = $(this);
|
|
1999
|
-
|
|
2000
|
-
var data = $this.data("be.gotop");
|
|
2001
|
-
var options = $.extend({}, GoTop.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
2002
|
-
|
|
2003
|
-
if (!data)
|
|
2004
|
-
$this.data("be.gotop", (data = new GoTop(this, options)));
|
|
2005
|
-
else
|
|
2006
|
-
data["init"]();
|
|
2007
|
-
|
|
2008
|
-
if (typeof option == "string") data[option]();
|
|
2009
|
-
});
|
|
2010
|
-
};
|
|
2011
|
-
|
|
2012
|
-
$.fn.gotop.Constructor = GoTop;
|
|
2013
|
-
$.fn.gotop.noConflict = function () {
|
|
2014
|
-
$.fn.gotop = old;
|
|
2015
|
-
return this;
|
|
2016
|
-
};
|
|
2017
|
-
}(jQuery);
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
/* ========================================================================
|
|
2021
|
-
* 17.背景滚动特效
|
|
2022
|
-
* 2019年1月16日12:06:19
|
|
2023
|
-
* ========================================================================
|
|
2024
|
-
|
|
2025
|
-
$(".ce-bg-ef").scrollBackground({speed: 6});
|
|
2026
|
-
|
|
2027
|
-
样式:
|
|
2028
|
-
.ce-bg-ef {
|
|
2029
|
-
width: 100%;
|
|
2030
|
-
height: 400px;
|
|
2031
|
-
background: url("http://120.24.229.95/file/images/sample/anime/0/anime1470402086147.jpg");
|
|
2032
|
-
|
|
2033
|
-
transition: all 0.7s ease-in-out;
|
|
2034
|
-
-o-transition: all 0.7s ease-in-out;
|
|
2035
|
-
-ms-transition: all 0.7s ease-in-out;
|
|
2036
|
-
-moz-transition: all 0.7s ease-in-out;
|
|
2037
|
-
-webkit-transition: all 0.7s ease-in-out;
|
|
2038
|
-
}
|
|
2039
|
-
* ======================================================================== */
|
|
2040
|
-
+function ($) { "use strict";
|
|
2041
|
-
|
|
2042
|
-
// SCROLLBACKGROUND CLASS DEFINITION
|
|
2043
|
-
// ====================
|
|
2044
|
-
|
|
2045
|
-
var ScrollBackground = function(element, options) {
|
|
2046
|
-
this.element = $(element);
|
|
2047
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
2048
|
-
this.init(options);
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
ScrollBackground.DEFAULTS = {
|
|
2052
|
-
speed: 5
|
|
2053
|
-
};
|
|
2054
|
-
|
|
2055
|
-
ScrollBackground.prototype.init = function (options) {
|
|
2056
|
-
var $this = this.element;
|
|
2057
|
-
|
|
2058
|
-
$this.css("background-position", "50% 0px");
|
|
2059
|
-
$(window).scroll(function() {
|
|
2060
|
-
var y = $this.offset().top;
|
|
2061
|
-
var h = $this.height();
|
|
2062
|
-
var windowY = $(this).scrollTop();
|
|
2063
|
-
var windowH = $(this).height();
|
|
2064
|
-
if (windowH + windowY > y && windowH + windowY < y + windowH + h) {
|
|
2065
|
-
var bgY = (y + h - windowY) / options.speed;
|
|
2066
|
-
$this.css("background-position", "50% -" + bgY + "px");
|
|
2067
|
-
}
|
|
2068
|
-
});
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
// SCROLLBACKGROUND PLUGIN DEFINITION
|
|
2072
|
-
// =====================
|
|
2073
|
-
|
|
2074
|
-
var old = $.fn.scrollBackground
|
|
2075
|
-
|
|
2076
|
-
$.fn.scrollBackground = function ( option ) {
|
|
2077
|
-
return this.each(function () {
|
|
2078
|
-
var $this = $(this)
|
|
2079
|
-
var data = $this.data('bs.scrollbackground');
|
|
2080
|
-
var options = $.extend({}, ScrollBackground.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
2081
|
-
|
|
2082
|
-
if (!data) $this.data('bs.scrollbackground', (data = new ScrollBackground(this, options)))
|
|
2083
|
-
else if (typeof option == 'string') data[option]();
|
|
2084
|
-
})
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
$.fn.scrollBackground.Constructor = ScrollBackground
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
// SCROLLBACKGROUND NO CONFLICT
|
|
2091
|
-
// ===============
|
|
2092
|
-
|
|
2093
|
-
$.fn.scrollBackground.noConflict = function () {
|
|
2094
|
-
$.fn.scrollBackground = old
|
|
2095
|
-
return this
|
|
2096
|
-
}
|
|
2097
|
-
}(jQuery);
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
/* ========================================================================
|
|
2101
|
-
* 18. 鼠标上下左右划入监听实现对应动画
|
|
2102
|
-
* 2022年7月28日 10:50:06
|
|
2103
|
-
* ========================================================================
|
|
2104
|
-
|
|
2105
|
-
$(".ce-thumb").hoverdir({
|
|
2106
|
-
hoverDelay: 0,
|
|
2107
|
-
reverse: false
|
|
2108
|
-
});
|
|
2109
|
-
|
|
2110
|
-
* ======================================================================== */
|
|
2111
|
-
+function ($) {
|
|
2112
|
-
"use strict";
|
|
2113
|
-
|
|
2114
|
-
var HoverDir = function(element, options) {
|
|
2115
|
-
this.element = $(element);
|
|
2116
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
2117
|
-
this.init(options);
|
|
2118
|
-
}
|
|
2119
|
-
HoverDir.DEFAULTS = {
|
|
2120
|
-
hoverDelay: 0,
|
|
2121
|
-
reverse: false
|
|
2122
|
-
};
|
|
2123
|
-
|
|
2124
|
-
HoverDir.prototype.init = function (options) {
|
|
2125
|
-
this.options = $.extend(true, {}, HoverDir.DEFAULTS, options);
|
|
2126
|
-
this._loadEvents();
|
|
2127
|
-
},
|
|
2128
|
-
HoverDir.prototype._loadEvents = function () {
|
|
2129
|
-
var _self = this;
|
|
2130
|
-
debug(_self.options.hoverDelay);
|
|
2131
|
-
this.element.on("mouseenter.hoverdir, mouseleave.hoverdir", function (event) {
|
|
2132
|
-
var $el = $(this), evType = event.type, $hoverElem = $el.find("div"), direction = _self._getDir($el, { x: event.pageX, y: event.pageY }), hoverClasses = _self._getClasses(direction);
|
|
2133
|
-
$hoverElem.removeClass();
|
|
2134
|
-
if (evType === "mouseenter") {
|
|
2135
|
-
$hoverElem.hide().addClass(hoverClasses.from);
|
|
2136
|
-
clearTimeout(_self.tmhover);
|
|
2137
|
-
_self.tmhover = setTimeout(function () {
|
|
2138
|
-
$hoverElem.show(0, function () {
|
|
2139
|
-
$(this).addClass("be-ts").addClass(hoverClasses.to);
|
|
2140
|
-
});
|
|
2141
|
-
}, _self.options.hoverDelay);
|
|
2142
|
-
} else {
|
|
2143
|
-
$hoverElem.addClass("be-ts");
|
|
2144
|
-
clearTimeout(_self.tmhover);
|
|
2145
|
-
$hoverElem.addClass(hoverClasses.from);
|
|
2146
|
-
}
|
|
2147
|
-
});
|
|
2148
|
-
},
|
|
2149
|
-
HoverDir.prototype._getDir = function ($el, coordinates) {
|
|
2150
|
-
var w = $el.width(),
|
|
2151
|
-
h = $el.height(),
|
|
2152
|
-
x = (coordinates.x - $el.offset().left - (w / 2)) * (w > h ? (h / w) : 1),
|
|
2153
|
-
y = (coordinates.y - $el.offset().top - (h / 2)) * (h > w ? (w / h) : 1),
|
|
2154
|
-
direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
|
|
2155
|
-
return direction;
|
|
2156
|
-
},
|
|
2157
|
-
HoverDir.prototype._getClasses = function (direction) {
|
|
2158
|
-
var fromClass, toClass;
|
|
2159
|
-
switch (direction) {
|
|
2160
|
-
case 0: (!this.options.reverse) ? fromClass = "ce-slideFromTop" : fromClass = "ce-slideFromBottom"; toClass = "ce-slideTop"; break;
|
|
2161
|
-
case 1: (!this.options.reverse) ? fromClass = "ce-slideFromRight" : fromClass = "ce-slideFromLeft"; toClass = "ce-slideLeft"; break;
|
|
2162
|
-
case 2: (!this.options.reverse) ? fromClass = "ce-slideFromBottom" : fromClass = "ce-slideFromTop"; toClass = "ce-slideTop"; break;
|
|
2163
|
-
case 3: (!this.options.reverse) ? fromClass = "ce-slideFromLeft" : fromClass = "ce-slideFromRight"; toClass = "ce-slideLeft"; break;
|
|
2164
|
-
};
|
|
2165
|
-
return { from: fromClass, to: toClass };
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
$.fn.hoverdir = function(options) {
|
|
2169
|
-
if (typeof options === "string") {
|
|
2170
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
2171
|
-
this.each(function () {
|
|
2172
|
-
var instance = $.data(this, "hoverdir");
|
|
2173
|
-
if (!instance) {
|
|
2174
|
-
return;
|
|
2175
|
-
}
|
|
2176
|
-
if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
|
|
2177
|
-
return;
|
|
2178
|
-
}
|
|
2179
|
-
instance[options].apply(instance, args);
|
|
2180
|
-
});
|
|
2181
|
-
} else {
|
|
2182
|
-
this.each(function () {
|
|
2183
|
-
var instance = $.data(this, "hoverdir");
|
|
2184
|
-
if (!instance) {
|
|
2185
|
-
$.data(this, "hoverdir", new HoverDir(this, options));
|
|
2186
|
-
}
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
return this;
|
|
2190
|
-
}
|
|
2191
|
-
}(jQuery);
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
/* ========================================================================
|
|
2195
|
-
* 19. niceSelect下拉框
|
|
2196
|
-
* 2022年8月14日 21:41:21
|
|
2197
|
-
* ========================================================================
|
|
2198
|
-
//初始化
|
|
2199
|
-
$(".ns-select").niceSelect();
|
|
2200
|
-
|
|
2201
|
-
//获取选中选项值
|
|
2202
|
-
$(".ns-select").change(function() {
|
|
2203
|
-
debug($(".ce-nice-select.ns-select .list .selected").data("value"));
|
|
2204
|
-
debug($(".ce-nice-select.ns-select .list .selected").html());
|
|
2205
|
-
})
|
|
2206
|
-
* ======================================================================== */
|
|
2207
|
-
+function ($) {
|
|
2208
|
-
"use strict";
|
|
2209
|
-
|
|
2210
|
-
$.fn.niceSelect = function(options) {
|
|
2211
|
-
if (typeof method == 'string') {
|
|
2212
|
-
if (method == 'update') {
|
|
2213
|
-
this.each(function() {
|
|
2214
|
-
var $select = $(this);
|
|
2215
|
-
var $dropdown = $(this).next('.ce-nice-select');
|
|
2216
|
-
var open = $dropdown.hasClass('open');
|
|
2217
|
-
|
|
2218
|
-
if ($dropdown.length) {
|
|
2219
|
-
$dropdown.remove();
|
|
2220
|
-
create_nice_select($select);
|
|
2221
|
-
|
|
2222
|
-
if (open) {
|
|
2223
|
-
$select.next().trigger('click');
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
});
|
|
2227
|
-
} else if (method == 'destroy') {
|
|
2228
|
-
this.each(function() {
|
|
2229
|
-
var $select = $(this);
|
|
2230
|
-
var $dropdown = $(this).next('.ce-nice-select');
|
|
2231
|
-
|
|
2232
|
-
if ($dropdown.length) {
|
|
2233
|
-
$dropdown.remove();
|
|
2234
|
-
$select.css('display', '');
|
|
2235
|
-
}
|
|
2236
|
-
});
|
|
2237
|
-
if ($('.ce-nice-select').length == 0) {
|
|
2238
|
-
$(document).off('.nice_select');
|
|
2239
|
-
}
|
|
2240
|
-
} else {}
|
|
2241
|
-
return this;
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
|
-
this.hide();
|
|
2245
|
-
|
|
2246
|
-
this.each(function() {
|
|
2247
|
-
var $select = $(this);
|
|
2248
|
-
if (!$select.next().hasClass('ce-nice-select')) {
|
|
2249
|
-
create_nice_select($select);
|
|
2250
|
-
}
|
|
2251
|
-
});
|
|
2252
|
-
|
|
2253
|
-
function create_nice_select($select) {
|
|
2254
|
-
$select.after($('<div></div>')
|
|
2255
|
-
.addClass('ce-nice-select')
|
|
2256
|
-
.addClass($select.attr('class') || '')
|
|
2257
|
-
.addClass($select.attr('disabled') ? 'disabled' : '')
|
|
2258
|
-
.attr('tabindex', $select.attr('disabled') ? null : '0')
|
|
2259
|
-
.html('<span class="current"></span><ul class="list"></ul>')
|
|
2260
|
-
);
|
|
2261
|
-
|
|
2262
|
-
var $dropdown = $select.next();
|
|
2263
|
-
var $options = $select.find('option');
|
|
2264
|
-
var $selected = $select.find('option:selected');
|
|
2265
|
-
|
|
2266
|
-
$dropdown.find('.current').html($selected.data('display') || $selected.text());
|
|
2267
|
-
|
|
2268
|
-
$options.each(function(i) {
|
|
2269
|
-
var $option = $(this);
|
|
2270
|
-
var display = $option.data('display');
|
|
2271
|
-
|
|
2272
|
-
$dropdown.find('ul').append($('<li></li>')
|
|
2273
|
-
.attr('data-value', $option.val())
|
|
2274
|
-
.attr('data-display', (display || null))
|
|
2275
|
-
.addClass('option' + ($option.is(':selected') ? ' selected' : '') + ($option.is(':disabled') ? ' disabled' : ''))
|
|
2276
|
-
.html($option.text())
|
|
2277
|
-
);
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
$(document).off('.nice_select');
|
|
2282
|
-
|
|
2283
|
-
$(document).on('click.nice_select', '.ce-nice-select', function(event) {
|
|
2284
|
-
var $dropdown = $(this);
|
|
2285
|
-
$('.ce-nice-select').not($dropdown).removeClass('open');
|
|
2286
|
-
$dropdown.toggleClass('open');
|
|
2287
|
-
|
|
2288
|
-
if ($dropdown.hasClass('open')) {
|
|
2289
|
-
$dropdown.find('.option');
|
|
2290
|
-
$dropdown.find('.focus').removeClass('focus');
|
|
2291
|
-
$dropdown.find('.selected').addClass('focus');
|
|
2292
|
-
} else {
|
|
2293
|
-
$dropdown.focus();
|
|
2294
|
-
}
|
|
2295
|
-
});
|
|
2296
|
-
|
|
2297
|
-
$(document).on('click.nice_select', function(event) {
|
|
2298
|
-
if ($(event.target).closest('.ce-nice-select').length === 0) {
|
|
2299
|
-
$('.ce-nice-select').removeClass('open').find('.option');
|
|
2300
|
-
}
|
|
2301
|
-
});
|
|
2302
|
-
|
|
2303
|
-
$(document).on('click.nice_select', '.ce-nice-select .option:not(.disabled)', function(event) {
|
|
2304
|
-
var $option = $(this);
|
|
2305
|
-
var $dropdown = $option.closest('.ce-nice-select');
|
|
2306
|
-
|
|
2307
|
-
$dropdown.find('.selected').removeClass('selected');
|
|
2308
|
-
$option.addClass('selected');
|
|
2309
|
-
|
|
2310
|
-
var text = $option.data('display') || $option.text();
|
|
2311
|
-
$dropdown.find('.current').text(text);
|
|
2312
|
-
|
|
2313
|
-
$dropdown.prev('select').val($option.data('value')).trigger('change');
|
|
2314
|
-
});
|
|
2315
|
-
|
|
2316
|
-
$(document).on('keydown.nice_select', '.ce-nice-select', function(event) {
|
|
2317
|
-
var $dropdown = $(this);
|
|
2318
|
-
var $focused_option = $($dropdown.find('.focus') || $dropdown.find('.list .option.selected'));
|
|
2319
|
-
|
|
2320
|
-
if (event.keyCode == 32 || event.keyCode == 13) {
|
|
2321
|
-
if ($dropdown.hasClass('open')) {
|
|
2322
|
-
$focused_option.trigger('click');
|
|
2323
|
-
} else {
|
|
2324
|
-
$dropdown.trigger('click');
|
|
2325
|
-
}
|
|
2326
|
-
return false;
|
|
2327
|
-
} else if (event.keyCode == 40) {
|
|
2328
|
-
if (!$dropdown.hasClass('open')) {
|
|
2329
|
-
$dropdown.trigger('click');
|
|
2330
|
-
} else {
|
|
2331
|
-
var $next = $focused_option.nextAll('.option:not(.disabled)').first();
|
|
2332
|
-
if ($next.length > 0) {
|
|
2333
|
-
$dropdown.find('.focus').removeClass('focus');
|
|
2334
|
-
$next.addClass('focus');
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
return false;
|
|
2338
|
-
} else if (event.keyCode == 38) {
|
|
2339
|
-
if (!$dropdown.hasClass('open')) {
|
|
2340
|
-
$dropdown.trigger('click');
|
|
2341
|
-
} else {
|
|
2342
|
-
var $prev = $focused_option.prevAll('.option:not(.disabled)').first();
|
|
2343
|
-
if ($prev.length > 0) {
|
|
2344
|
-
$dropdown.find('.focus').removeClass('focus');
|
|
2345
|
-
$prev.addClass('focus');
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
return false;
|
|
2349
|
-
} else if (event.keyCode == 27) {
|
|
2350
|
-
if ($dropdown.hasClass('open')) {
|
|
2351
|
-
$dropdown.trigger('click');
|
|
2352
|
-
}
|
|
2353
|
-
} else if (event.keyCode == 9) {
|
|
2354
|
-
if ($dropdown.hasClass('open')) {
|
|
2355
|
-
return false;
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
});
|
|
2359
|
-
|
|
2360
|
-
var style = document.createElement('a').style;
|
|
2361
|
-
style.cssText = 'pointer-events:auto';
|
|
2362
|
-
if (style.pointerEvents !== 'auto') {
|
|
2363
|
-
$('html').addClass('no-csspointerevents');
|
|
2364
|
-
}
|
|
2365
|
-
return this;
|
|
2366
|
-
}
|
|
2367
|
-
}(jQuery);
|
|
2368
|
-
|
|
2369
|
-
/* ========================================================================
|
|
2370
|
-
* 20. 文字切换动画特效
|
|
2371
|
-
* 2023年7月5日 12:58:24
|
|
2372
|
-
* ========================================================================
|
|
2373
|
-
|
|
2374
|
-
$(function() {
|
|
2375
|
-
$("#ce-flash").flash({
|
|
2376
|
-
type: 1,
|
|
2377
|
-
animationDelay: 3000,
|
|
2378
|
-
lettersDelay: 50
|
|
2379
|
-
});
|
|
2380
|
-
})
|
|
2381
|
-
|
|
2382
|
-
<div id="ce-flash" class="ce-txt">
|
|
2383
|
-
<span>
|
|
2384
|
-
<b class="is-visible">design.</b>
|
|
2385
|
-
<b>coding.</b>
|
|
2386
|
-
<b>graphic.</b>
|
|
2387
|
-
</span>
|
|
2388
|
-
</div>
|
|
2389
|
-
|
|
2390
|
-
* ======================================================================== */
|
|
2391
|
-
+function ($) {
|
|
2392
|
-
"use strict";
|
|
2393
|
-
|
|
2394
|
-
var Flash = function(element, options) {
|
|
2395
|
-
this.element = $(element);
|
|
2396
|
-
if (options.type == 1) {
|
|
2397
|
-
this.element.addClass("letters");
|
|
2398
|
-
} else if (options.type == 2) {
|
|
2399
|
-
this.element.addClass("clip");
|
|
2400
|
-
} else if (options.type == 3) {
|
|
2401
|
-
this.element.addClass("type");
|
|
2402
|
-
} else {
|
|
2403
|
-
this.element.addClass("letters");
|
|
2404
|
-
}
|
|
2405
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
2406
|
-
this.init(options);
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
Flash.DEFAULTS = {
|
|
2410
|
-
//动画类型 1-3
|
|
2411
|
-
type: 1,
|
|
2412
|
-
//动画间隔时间5秒
|
|
2413
|
-
animationDelay: 5000,
|
|
2414
|
-
//loading bar effect
|
|
2415
|
-
barAnimationDelay: 3800,
|
|
2416
|
-
barWaiting: Flash.barAnimationDelay - 3000,
|
|
2417
|
-
//letters: 每个字特效的时间间隔
|
|
2418
|
-
lettersDelay: 50,
|
|
2419
|
-
//type 特效
|
|
2420
|
-
typeLettersDelay: 50,
|
|
2421
|
-
selectionDuration: 100,
|
|
2422
|
-
typeAnimationDelay: Flash.selectionDuration + 800,
|
|
2423
|
-
//clip 特效
|
|
2424
|
-
revealDuration: 600,
|
|
2425
|
-
revealAnimationDelay: 1500
|
|
2426
|
-
};
|
|
2427
|
-
|
|
2428
|
-
Flash.prototype.init = function(options) {
|
|
2429
|
-
this.options = $.extend(true, {}, Flash.DEFAULTS, options);
|
|
2430
|
-
this.loadEvents();
|
|
2431
|
-
};
|
|
2432
|
-
|
|
2433
|
-
Flash.prototype.loadEvents = function() {
|
|
2434
|
-
var self = this;
|
|
2435
|
-
//为变化单词的每个字母插入<i>元素
|
|
2436
|
-
self.singleLetters($(self.options.selector).find("b"));
|
|
2437
|
-
//初始化动画
|
|
2438
|
-
self.animateHeadline($(self.options.selector));
|
|
2439
|
-
};
|
|
2440
|
-
|
|
2441
|
-
Flash.prototype.singleLetters = function($words) {
|
|
2442
|
-
var self = this;
|
|
2443
|
-
$words.each(function() {
|
|
2444
|
-
var word = $(this),
|
|
2445
|
-
letters = word.text().split(""),
|
|
2446
|
-
selected = word.hasClass("is-visible");
|
|
2447
|
-
for (var i in letters) {
|
|
2448
|
-
if(word.parents(self.options.selector).length > 0) letters[i] = "<em>" + letters[i] + "</em>";
|
|
2449
|
-
letters[i] = (selected) ? "<i class='in'>" + letters[i] + "</i>": "<i>" + letters[i] + "</i>";
|
|
2450
|
-
}
|
|
2451
|
-
var newLetters = letters.join("");
|
|
2452
|
-
word.html(newLetters).css("opacity", 1);
|
|
2453
|
-
});
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
Flash.prototype.animateHeadline = function($headlines) {
|
|
2457
|
-
var self = this;
|
|
2458
|
-
var duration = self.options.animationDelay;
|
|
2459
|
-
$headlines.each(function(){
|
|
2460
|
-
var headline = $(this);
|
|
2461
|
-
|
|
2462
|
-
if(headline.hasClass("loading-bar")) {
|
|
2463
|
-
duration = self.options.barAnimationDelay;
|
|
2464
|
-
setTimeout(function(){ headline.find("span").addClass("is-loading") }, self.options.barWaiting);
|
|
2465
|
-
} else if (headline.hasClass("clip")){
|
|
2466
|
-
var spanWrapper = headline.find("span"),
|
|
2467
|
-
newWidth = spanWrapper.width() + 10
|
|
2468
|
-
spanWrapper.css("width", newWidth);
|
|
2469
|
-
} else if (!headline.hasClass("type") ) {
|
|
2470
|
-
//将其最长单词的宽度分配给第一级节点
|
|
2471
|
-
var words = headline.find("span b"),
|
|
2472
|
-
width = 0;
|
|
2473
|
-
words.each(function(){
|
|
2474
|
-
var wordWidth = $(this).width();
|
|
2475
|
-
if (wordWidth > width) width = wordWidth;
|
|
2476
|
-
});
|
|
2477
|
-
headline.find("span").css("width", width);
|
|
2478
|
-
};
|
|
2479
|
-
|
|
2480
|
-
//开始动画
|
|
2481
|
-
setTimeout(function(){ self.hideWord( headline.find(".is-visible").eq(0) ) }, duration);
|
|
2482
|
-
});
|
|
2483
|
-
};
|
|
2484
|
-
|
|
2485
|
-
Flash.prototype.hideWord = function($word) {
|
|
2486
|
-
var self = this;
|
|
2487
|
-
var nextWord = self.takeNext($word);
|
|
2488
|
-
|
|
2489
|
-
if($word.parents(self.options.selector).hasClass("type")) {
|
|
2490
|
-
var parentSpan = $word.parent("span");
|
|
2491
|
-
parentSpan.addClass("selected").removeClass("waiting");
|
|
2492
|
-
setTimeout(function(){
|
|
2493
|
-
parentSpan.removeClass("selected");
|
|
2494
|
-
$word.removeClass("is-visible").addClass("is-hidden").children("i").removeClass("in").addClass("out");
|
|
2495
|
-
}, self.options.selectionDuration);
|
|
2496
|
-
setTimeout(function(){ self.showWord(nextWord, self.options.typeLettersDelay) }, self.options.typeAnimationDelay);
|
|
2497
|
-
|
|
2498
|
-
} else if($word.parents(self.options.selector).hasClass("letters")) {
|
|
2499
|
-
var bool = ($word.children("i").length >= nextWord.children("i").length) ? true : false;
|
|
2500
|
-
self.hideLetter($word.find("i").eq(0), $word, bool, self.options.lettersDelay);
|
|
2501
|
-
self.showLetter(nextWord.find("i").eq(0), nextWord, bool, self.options.lettersDelay);
|
|
2502
|
-
|
|
2503
|
-
} else if($word.parents(self.options.selector).hasClass("clip")) {
|
|
2504
|
-
$word.parents("span").animate({ width : "2px" }, self.options.revealDuration, function(){
|
|
2505
|
-
self.switchWord($word, nextWord);
|
|
2506
|
-
self.showWord(nextWord);
|
|
2507
|
-
});
|
|
2508
|
-
|
|
2509
|
-
} else if ($word.parents(self.options.selector).hasClass("loading-bar")){
|
|
2510
|
-
$word.parents("span").removeClass("is-loading");
|
|
2511
|
-
self.switchWord($word, nextWord);
|
|
2512
|
-
setTimeout(function(){ self.hideWord(nextWord) }, self.options.barAnimationDelay);
|
|
2513
|
-
setTimeout(function(){ $word.parents("span").addClass("is-loading") }, self.options.barWaiting);
|
|
2514
|
-
|
|
2515
|
-
} else {
|
|
2516
|
-
self.switchWord($word, nextWord);
|
|
2517
|
-
setTimeout(function(){ self.hideWord(nextWord) }, self.options.animationDelay);
|
|
2518
|
-
}
|
|
2519
|
-
};
|
|
2520
|
-
|
|
2521
|
-
Flash.prototype.showWord = function($word, $duration) {
|
|
2522
|
-
var self = this;
|
|
2523
|
-
if($word.parents(self.options.selector).hasClass("type")) {
|
|
2524
|
-
self.showLetter($word.find("i").eq(0), $word, false, $duration);
|
|
2525
|
-
$word.addClass("is-visible").removeClass("is-hidden");
|
|
2526
|
-
|
|
2527
|
-
} else if($word.parents(self.options.selector).hasClass("clip")) {
|
|
2528
|
-
$word.parents("span").animate({ "width" : $word.width() + 10 }, self.options.revealDuration, function(){
|
|
2529
|
-
setTimeout(function(){ self.hideWord($word) }, self.options.revealAnimationDelay);
|
|
2530
|
-
});
|
|
2531
|
-
}
|
|
2532
|
-
};
|
|
2533
|
-
|
|
2534
|
-
Flash.prototype.hideLetter = function($letter, $word, $bool, $duration) {
|
|
2535
|
-
var self = this;
|
|
2536
|
-
$letter.removeClass("in").addClass("out");
|
|
2537
|
-
|
|
2538
|
-
if(!$letter.is(":last-child")) {
|
|
2539
|
-
setTimeout(function(){ self.hideLetter($letter.next(), $word, $bool, $duration); }, $duration);
|
|
2540
|
-
} else if($bool) {
|
|
2541
|
-
setTimeout(function(){ self.hideWord(self.takeNext($word)) }, self.options.animationDelay);
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2544
|
-
if($letter.is(":last-child") && $("html").hasClass("no-csstransitions")) {
|
|
2545
|
-
var nextWord = self.takeNext($word);
|
|
2546
|
-
self.switchWord($word, nextWord);
|
|
2547
|
-
}
|
|
2548
|
-
};
|
|
2549
|
-
|
|
2550
|
-
Flash.prototype.showLetter = function($letter, $word, $bool, $duration) {
|
|
2551
|
-
var self = this;
|
|
2552
|
-
$letter.addClass("in").removeClass("out");
|
|
2553
|
-
|
|
2554
|
-
if(!$letter.is(":last-child")) {
|
|
2555
|
-
setTimeout(function(){ self.showLetter($letter.next(), $word, $bool, $duration); }, $duration);
|
|
2556
|
-
} else {
|
|
2557
|
-
if($word.parents(self.options.selector).hasClass("type")) { setTimeout(function(){ $word.parents("span").addClass("waiting"); }, 200);}
|
|
2558
|
-
if(!$bool) { setTimeout(function(){ self.hideWord($word) }, self.options.animationDelay) }
|
|
2559
|
-
}
|
|
2560
|
-
};
|
|
2561
|
-
|
|
2562
|
-
Flash.prototype.takeNext = function($word) {
|
|
2563
|
-
return (!$word.is(":last-child")) ? $word.next() : $word.parent().children().eq(0);
|
|
2564
|
-
};
|
|
2565
|
-
|
|
2566
|
-
Flash.prototype.takePrev = function($word) {
|
|
2567
|
-
return (!$word.is(":first-child")) ? $word.prev() : $word.parent().children().last();
|
|
2568
|
-
};
|
|
2569
|
-
|
|
2570
|
-
Flash.prototype.switchWord = function($oldWord, $newWord) {
|
|
2571
|
-
$oldWord.removeClass("is-visible").addClass("is-hidden");
|
|
2572
|
-
$newWord.removeClass("is-hidden").addClass("is-visible");
|
|
2573
|
-
};
|
|
2574
|
-
|
|
2575
|
-
$.fn.flash = function(option) {
|
|
2576
|
-
var selector = this.selector;
|
|
2577
|
-
return this.each(function (i, t) {
|
|
2578
|
-
var $this = $(this);
|
|
2579
|
-
|
|
2580
|
-
var data = $this.data("be.flash");
|
|
2581
|
-
var options = $.extend({selector: selector}, Flash.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
2582
|
-
|
|
2583
|
-
if (!data)
|
|
2584
|
-
$this.data("be.flash", (data = new Flash(this, options)));
|
|
2585
|
-
});
|
|
2586
|
-
};
|
|
2587
|
-
|
|
2588
|
-
}(jQuery);
|
|
2589
|
-
|
|
2590
|
-
/* ========================================================================
|
|
2591
|
-
* 21. 局部loading动画
|
|
2592
|
-
* 2023年8月5日 10:55:51
|
|
2593
|
-
* ========================================================================
|
|
2594
|
-
|
|
2595
|
-
<p data-ae-load>需要使用loading动画的页面标签</p>
|
|
2596
|
-
|
|
2597
|
-
var al = new AeLoader();
|
|
2598
|
-
al.init();
|
|
2599
|
-
|
|
2600
|
-
//不需要加载数据,完整的loading动画
|
|
2601
|
-
$("#ae-load-start").click(function() {
|
|
2602
|
-
//全部触发
|
|
2603
|
-
al.start();
|
|
2604
|
-
//指定触发
|
|
2605
|
-
//al.start(".ae-test-target");
|
|
2606
|
-
});
|
|
2607
|
-
//显示loading动画
|
|
2608
|
-
$("#ae-load-loading").click(function() {
|
|
2609
|
-
//全部触发
|
|
2610
|
-
al.loading();
|
|
2611
|
-
//指定触发
|
|
2612
|
-
//al.loading(".ae-test-target");
|
|
2613
|
-
});
|
|
2614
|
-
//loading动画完成,显示数据
|
|
2615
|
-
$("#ae-load-done").click(function() {
|
|
2616
|
-
//全部触发
|
|
2617
|
-
al.done();
|
|
2618
|
-
//指定触发
|
|
2619
|
-
//al.done(".ae-test-target");
|
|
2620
|
-
});
|
|
2621
|
-
|
|
2622
|
-
* ======================================================================== */
|
|
2623
|
-
(function() {
|
|
2624
|
-
var u, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
|
2625
|
-
|
|
2626
|
-
u = (function() {
|
|
2627
|
-
function u() {}
|
|
2628
|
-
u.prototype.extend = function(custom, defaults) {
|
|
2629
|
-
var key, value;
|
|
2630
|
-
for (key in defaults) {
|
|
2631
|
-
value = defaults[key];
|
|
2632
|
-
if (custom[key] == null) {
|
|
2633
|
-
custom[key] = value;
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
return custom;
|
|
2637
|
-
};
|
|
2638
|
-
return u;
|
|
2639
|
-
})();
|
|
2640
|
-
|
|
2641
|
-
window.AeLoader = (function() {
|
|
2642
|
-
AeLoader.prototype.defaults = {};
|
|
2643
|
-
|
|
2644
|
-
function AeLoader(options) {
|
|
2645
|
-
if (options == null) {
|
|
2646
|
-
options = {};
|
|
2647
|
-
}
|
|
2648
|
-
this.config = this.util().extend(options, this.defaults);
|
|
2649
|
-
this.start = bind(this.start, this);
|
|
2650
|
-
this.loading = bind(this.loading, this);
|
|
2651
|
-
this.done = bind(this.done, this);
|
|
2652
|
-
}
|
|
2653
|
-
|
|
2654
|
-
AeLoader.prototype.init = function() {
|
|
2655
|
-
$("[data-ae-load]").addClass("ae-load");
|
|
2656
|
-
return this.finished = [];
|
|
2657
|
-
};
|
|
2658
|
-
|
|
2659
|
-
//不需要加载数据,完整的loading动画
|
|
2660
|
-
AeLoader.prototype.start = function(target) {
|
|
2661
|
-
if (target) {
|
|
2662
|
-
console.log(this);
|
|
2663
|
-
} else {
|
|
2664
|
-
target = "";
|
|
2665
|
-
}
|
|
2666
|
-
$(target + "[data-ae-load]").addClass("ae-load");
|
|
2667
|
-
$(target + "[data-ae-load]").removeClass("ae-tt-complete ae-tt-done ae-tt-loading");
|
|
2668
|
-
setTimeout(function() {
|
|
2669
|
-
$(target + "[data-ae-load]").addClass("ae-tt-complete");
|
|
2670
|
-
setTimeout(function() {$(target + "[data-ae-load]").removeClass("ae-load ae-tt-complete");}, 1000);
|
|
2671
|
-
}, 100);
|
|
2672
|
-
};
|
|
2673
|
-
|
|
2674
|
-
//显示loading动画
|
|
2675
|
-
AeLoader.prototype.loading = function(target) {
|
|
2676
|
-
if (!target) target = "";
|
|
2677
|
-
|
|
2678
|
-
$("[data-ae-load]").addClass("ae-load");
|
|
2679
|
-
$(target + "[data-ae-load]").each(function(index, currentTarget) {
|
|
2680
|
-
var minWidth = $(currentTarget).data("al-mw");
|
|
2681
|
-
var minHeight = $(currentTarget).data("al-mh");
|
|
2682
|
-
if (minWidth) $(currentTarget).css("min-width", minWidth);
|
|
2683
|
-
if (minHeight) $(currentTarget).css("min-height", minHeight);
|
|
2684
|
-
|
|
2685
|
-
$(currentTarget).removeClass("ae-tt-complete ae-tt-done ae-tt-loading");
|
|
2686
|
-
setTimeout(function() {
|
|
2687
|
-
$(currentTarget).addClass("ae-tt-loading");
|
|
2688
|
-
}, 1);
|
|
2689
|
-
})
|
|
2690
|
-
};
|
|
2691
|
-
|
|
2692
|
-
//loading动画完成,显示数据
|
|
2693
|
-
AeLoader.prototype.done = function(target) {
|
|
2694
|
-
if (!target) target = "";
|
|
2695
|
-
$(target + "[data-ae-load]").removeClass("ae-tt-done");
|
|
2696
|
-
setTimeout(function() {
|
|
2697
|
-
$(target + "[data-ae-load]").addClass("ae-tt-done");
|
|
2698
|
-
setTimeout(function() {$(target + "[data-ae-load]").removeClass("ae-load ae-tt-loading ae-tt-done");}, 1000);
|
|
2699
|
-
}, 1);
|
|
2700
|
-
};
|
|
2701
|
-
|
|
2702
|
-
AeLoader.prototype.util = function() {
|
|
2703
|
-
return this._util != null ? this._util : this._util = new u();
|
|
2704
|
-
};
|
|
2705
|
-
|
|
2706
|
-
return AeLoader;
|
|
2707
|
-
})();
|
|
2708
|
-
|
|
2709
|
-
}).call(this);
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
/* ========================================================================
|
|
2713
|
-
* 22. 按钮动画
|
|
2714
|
-
* 2023年8月30日 10:41:03
|
|
2715
|
-
* ========================================================================
|
|
2716
|
-
|
|
2717
|
-
<a href="#" class="ce-btn-5">
|
|
2718
|
-
<span>了解更多</span>
|
|
2719
|
-
</a>
|
|
2720
|
-
|
|
2721
|
-
$(".ce-btn-5").btnEf();
|
|
2722
|
-
|
|
2723
|
-
* ======================================================================== */
|
|
2724
|
-
+function ($) {
|
|
2725
|
-
|
|
2726
|
-
var BtnEf = function (element, options) {
|
|
2727
|
-
this.options = $.extend({}, this.DEFAULTS, options);
|
|
2728
|
-
|
|
2729
|
-
this.init(element, this.options);
|
|
2730
|
-
};
|
|
2731
|
-
|
|
2732
|
-
BtnEf.DEFAULTS = {};
|
|
2733
|
-
|
|
2734
|
-
BtnEf.prototype.init = function (element, options) {
|
|
2735
|
-
$('<b></b>').appendTo(element);
|
|
2736
|
-
$(element)
|
|
2737
|
-
.on('mouseenter', function (e) {
|
|
2738
|
-
var parentOffset = $(this).offset(),
|
|
2739
|
-
relX = e.pageX - parentOffset.left,
|
|
2740
|
-
relY = e.pageY - parentOffset.top;
|
|
2741
|
-
$(this).find('b').css({
|
|
2742
|
-
top: relY,
|
|
2743
|
-
left: relX
|
|
2744
|
-
});
|
|
2745
|
-
})
|
|
2746
|
-
.on('mouseout', function (e) {
|
|
2747
|
-
var parentOffset = $(this).offset(),
|
|
2748
|
-
relX = e.pageX - parentOffset.left,
|
|
2749
|
-
relY = e.pageY - parentOffset.top;
|
|
2750
|
-
$(this).find('b').css({
|
|
2751
|
-
top: relY,
|
|
2752
|
-
left: relX
|
|
2753
|
-
});
|
|
2754
|
-
});
|
|
2755
|
-
$($(element).attr('class') + "[href='#']").click(function () {
|
|
2756
|
-
return false;
|
|
2757
|
-
});
|
|
2758
|
-
};
|
|
2759
|
-
|
|
2760
|
-
$.fn.btnEf = function (option) {
|
|
2761
|
-
var $this = $(this);
|
|
2762
|
-
return this.each(function () {
|
|
2763
|
-
var data = $this.data("be.btnef");
|
|
2764
|
-
var options = $.extend({}, BtnEf.DEFAULTS, $this.data(), typeof option == "object" && option);
|
|
2765
|
-
|
|
2766
|
-
if (!data)
|
|
2767
|
-
$this.data("be.btnef", (data = new BtnEf(this, options)));
|
|
2768
|
-
else
|
|
2769
|
-
data["init"](options);
|
|
2770
|
-
});
|
|
2771
|
-
};
|
|
2772
|
-
}(jQuery);
|
|
2773
|
-
|
|
2774
|
-
|