...
|
...
|
@@ -9,7 +9,8 @@ var $ = require('yoho-jquery'), |
|
|
|
|
|
var defaultOptions = {
|
|
|
mask: true,
|
|
|
closeIcon: true
|
|
|
closeIcon: true,
|
|
|
refreshOnClose: false
|
|
|
};
|
|
|
|
|
|
var tpl =
|
...
|
...
|
@@ -53,6 +54,15 @@ function createDialog(data) { |
|
|
return $('.yoho-dialog');
|
|
|
}
|
|
|
|
|
|
function cerateSubContent(text) {
|
|
|
var $yohoDialog = $('.yoho-dialog'),
|
|
|
subContent = '<p class="sub-content">' + text + '</p>';
|
|
|
|
|
|
if ($yohoDialog && $yohoDialog.length > 0) {
|
|
|
$yohoDialog.find('.content').after(subContent);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function Dialog(options) {
|
|
|
var opt = $.extend({}, defaultOptions, options);
|
|
|
var that = this,
|
...
|
...
|
@@ -66,11 +76,31 @@ function Dialog(options) { |
|
|
if (opt.mask) {
|
|
|
that.$mask = createMask();
|
|
|
}
|
|
|
|
|
|
that.$el = createDialog(opt);
|
|
|
|
|
|
|
|
|
if (opt.subContent) {
|
|
|
cerateSubContent(opt.subContent);
|
|
|
}
|
|
|
|
|
|
if (opt.subContents) {
|
|
|
for (i = opt.subContents.length - 1; i >= 0; i--) {
|
|
|
cerateSubContent(opt.subContents[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 绑定x关闭事件
|
|
|
that.$el.find('.close').click(function() {
|
|
|
that.close();
|
|
|
if (options.refreshOnClose) {
|
|
|
window.location.reload();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 绑定btn关闭事件
|
|
|
that.$el.find('.btn-close').click(function() {
|
|
|
that.close();
|
|
|
});
|
|
|
|
|
|
function bindBtnEvt(index) {
|
...
|
...
|
|