Repository navigation
Expand file tree
/
Copy pathbase.js
More file actions
135 lines (126 loc) · 3.34 KB
/
Copy pathbase.js
File metadata and controls
135 lines (126 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* JavaChina全局函数对象 var jc = new $.jc();
*/
$.extend({
jc: function () {
},
constant: function () { //常量池
return {
///-------文件常量----------
MAX_FILES: 10,//一次队列最大文件数
}
}
});
/**
* 成功弹框
* @param options
*/
$.jc.prototype.alertOk = function (options) {
options = options.length ? {text: options} : ( options || {} );
options.title = options.title || '操作成功';
options.text = options.text;
options.showCancelButton = false;
options.showCloseButton = false;
options.type = 'success';
this.alertBox(options);
};
/**
* 弹出成功,并在500毫秒后刷新页面
* @param text
*/
$.jc.prototype.alertOkAndReload = function (text) {
this.alertOk({
text: text, then: function () {
setTimeout(function () {
window.location.reload();
}, 800);
}
});
};
/**
* 警告弹框
* @param options
*/
$.jc.prototype.alertWarn = function (options) {
options = options.length ? {text: options} : ( options || {} );
options.title = options.title || '警告信息';
options.text = options.text;
options.timer = 3000;
options.type = 'warning';
this.alertBox(options);
};
/**
* 询问确认弹框,这里会传入then函数进来
* @param options
*/
$.jc.prototype.alertConfirm = function (options) {
options = options || {};
options.title = options.title || '确定要删除吗?';
options.text = options.text;
options.showCancelButton = true;
options.type = 'question';
this.alertBox(options);
};
/**
* 错误提示
* @param options
*/
$.jc.prototype.alertError = function (options) {
options = options.length ? {text: options} : ( options || {} );
options.title = options.title || '错误信息';
options.text = options.text;
options.type = 'error';
this.alertBox(options);
};
/**
* 公共弹框
* @param options
*/
$.jc.prototype.alertBox = function (options) {
swal({
title: options.title,
text: options.text,
type: options.type,
timer: options.timer || 9999,
showCloseButton: options.showCloseButton,
showCancelButton: options.showCancelButton,
showLoaderOnConfirm: options.showLoaderOnConfirm || false,
confirmButtonColor: options.confirmButtonColor || '#3085d6',
cancelButtonColor: options.cancelButtonColor || '#d33',
confirmButtonText: options.confirmButtonText || '确定',
cancelButtonText: options.cancelButtonText || '取消'
}).then(function (e) {
options.then && options.then(e);
}).catch(swal.noop);
};
/**
* 全局post函数
*
* @param options 参数
*/
$.jc.prototype.post = function (options) {
var self = this;
$.ajax({
type: 'POST',
url: options.url,
data: options.data || {},
async: options.async || false,
dataType: 'json',
success: function (result) {
options.success && options.success(result);
},
error: function () {
//
}
});
};
/**
* 在页面显示一个错误提示框
*
* @param selector 提示框元素
* @param msg 消息内容
*/
$.jc.prototype.showError = function (selector, msg) {
$(selector).removeClass('hidden');
$(selector).find('label').text(msg);
};