forked from otale/tale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,148 @@ | ||
var _swal = { | ||
alert_del: function (data) { | ||
swal({ | ||
title: data.title || '警告信息', | ||
text: data.text || "确定删除吗?", | ||
type: 'warning', | ||
showCancelButton: true, | ||
confirmButtonColor: '#3085d6', | ||
cancelButtonColor: '#d33', | ||
confirmButtonText: '确定', | ||
cancelButtonText: '取消' | ||
}).then(function () { | ||
$.post(data.url, data.parame, function (result) { | ||
if (result && result.success) { | ||
swal('提示信息', '删除成功', 'success'); | ||
setTimeout(function () { | ||
window.location.reload(); | ||
}, 2000); | ||
} else { | ||
swal("提示消息", result.msg, 'error'); | ||
} | ||
}); | ||
}).catch(swal.noop); | ||
} | ||
}; | ||
|
||
/** | ||
* Tale全局函数对象 | ||
* @type {{}} | ||
* Tale全局函数对象 var tale = new $.tale(); | ||
*/ | ||
var tale = {}; | ||
$.extend({ | ||
tale: function () {} | ||
}); | ||
|
||
/** | ||
* 弹出成功对话框 | ||
* tale alert删除 // todo: 减少耦合度,链式操作替代 2017-02-27 | ||
* @param options | ||
*/ | ||
tale.alertOk = function (options) { | ||
options = options || {}; | ||
options.title = options.title || '操作成功'; | ||
options.text = options.text; | ||
options.showCancelButton = false; | ||
options.showCloseButton = false; | ||
options.type = 'success'; | ||
this.alertBox(options); | ||
$.tale.prototype.alert_del = function (options) { | ||
swal({ | ||
title: options.title || '警告信息', | ||
text: options.text || "确定删除吗?", | ||
type: 'warning', | ||
showCancelButton: true, | ||
confirmButtonColor: '#3085d6', | ||
cancelButtonColor: '#d33', | ||
confirmButtonText: '确定', | ||
cancelButtonText: '取消' | ||
}).then(function () { | ||
$.post(options.url, options.parame, function (result) { | ||
if (result && result.success) { | ||
swal('提示信息', '删除成功', 'success'); | ||
setTimeout(function () { | ||
window.location.reload(); | ||
}, 2000); | ||
} else { | ||
swal("提示消息", result.msg, 'error'); | ||
} | ||
}); | ||
}).catch(swal.noop); | ||
}; | ||
|
||
/** | ||
* 弹出错误对话框 | ||
* | ||
* @param options | ||
*/ | ||
tale.alertError = function (options) { | ||
options = options || {}; | ||
options.title = options.title || '错误信息'; | ||
options.text = options.text; | ||
options.type = 'error'; | ||
this.alertBox(options); | ||
$.tale.prototype.alert_ok = function (options){ | ||
swal(option.title || '提示信息', options.text, 'success'); | ||
}; | ||
|
||
/** | ||
* 弹出确认对话框 | ||
* @param options | ||
*/ | ||
tale.alertQA = function (options) { | ||
options = options || {}; | ||
options.title = options.title || '确定要删除吗?'; | ||
options.text = options.text; | ||
options.showCancelButton = true; | ||
options.type = 'question'; | ||
this.alertBox(options); | ||
$.tale.prototype.alert_error = function(options){ | ||
swal(option.title || '提示信息', options.text, 'error'); | ||
}; | ||
|
||
/** | ||
* 弹出警告对话框 | ||
* @param options | ||
*/ | ||
tale.alertWarn = function (options) { | ||
options = options || {}; | ||
options.title = options.title || '警告信息'; | ||
options.text = options.text; | ||
options.type = 'warning'; | ||
this.alertBox(options); | ||
}; | ||
/** | ||
* 公共对话框 | ||
* @param options | ||
*/ | ||
tale.alertBox = function (options) { | ||
swal({ | ||
title: options.title, | ||
text: options.text, | ||
type: options.type, | ||
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(e); | ||
}).catch(swal.noop); | ||
$.tale.prototype.post = function(option, callback){ | ||
$.post(option.url, option.params, function (result) { | ||
if (result && result.success) { | ||
callback(true); | ||
|
||
} else { | ||
swal("提示消息", result.msg, 'error'); | ||
} | ||
//return this; | ||
}); | ||
}; | ||
|
||
/** | ||
* 显示loading动画 | ||
* 显示动画 | ||
*/ | ||
tale.showLoading = function () { | ||
if($('#tale-loading').length == 0){ | ||
$.tale.prototype.showLoading = function(){ | ||
if ($('#tale-loading').length == 0) { | ||
$('body').append('<div id="tale-loading"></div>'); | ||
} | ||
$('#tale-loading').show(); | ||
}; | ||
|
||
/** | ||
* 隐藏loading动画 | ||
* 隐藏动画 | ||
*/ | ||
tale.hideLoading = function () { | ||
$.tale.prototype.hideLoading = function(){ | ||
$('#tale-loading').hide(); | ||
}; | ||
}; | ||
|
||
// | ||
///** | ||
// * Tale全局函数对象 | ||
// * @type {{}} | ||
// */ | ||
//var tale = {}; | ||
// | ||
|
||
// | ||
///** | ||
// * 弹出确认对话框 | ||
// * @param options | ||
// */ | ||
//tale.alertQA = function (options) { | ||
// options = options || {}; | ||
// options.title = options.title || '确定要删除吗?'; | ||
// options.text = options.text; | ||
// options.showCancelButton = true; | ||
// options.type = 'question'; | ||
// this.alertBox(options); | ||
//}; | ||
|
||
///** | ||
// * 弹出警告对话框 | ||
// * @param options | ||
// */ | ||
//tale.alertWarn = function (options) { | ||
// options = options || {}; | ||
// options.title = options.title || '警告信息'; | ||
// options.text = options.text; | ||
// options.type = 'warning'; | ||
// this.alertBox(options); | ||
//}; | ||
///** | ||
// * 公共对话框 | ||
// * @param options | ||
// */ | ||
//tale.alertBox = function (options) { | ||
// swal({ | ||
// title: options.title, | ||
// text: options.text, | ||
// type: options.type, | ||
// 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(e); | ||
// }).catch(swal.noop); | ||
//}; | ||
|
||
///** | ||
// * 显示loading动画 | ||
// */ | ||
//tale.showLoading = function () { | ||
// if ($('#tale-loading').length == 0) { | ||
// $('body').append('<div id="tale-loading"></div>'); | ||
// } | ||
// $('#tale-loading').show(); | ||
//}; | ||
///** | ||
// * 隐藏loading动画 | ||
// */ | ||
//tale.hideLoading = function () { | ||
// $('#tale-loading').hide(); | ||
//}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters