Authored by wenjiekong

更新dialog和PHP的文件同步

... ... @@ -9,7 +9,8 @@ var $ = require('yoho-jquery'),
var defaultOptions = {
mask: true,
closeIcon: true
closeIcon: true,
refreshOnClose: false
};
var tpl =
... ... @@ -53,12 +54,21 @@ 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,
i;
// 实现继承时,只返回实例,不生成html
//实现继承时,只返回实例,不生成html
if (opt.inherit) {
return this;
}
... ... @@ -66,11 +76,31 @@ function Dialog(options) {
if (opt.mask) {
that.$mask = createMask();
}
that.$el = createDialog(opt);
// 绑定x关闭事件
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) {
... ... @@ -79,8 +109,8 @@ function Dialog(options) {
});
}
// 绑定按钮事件
if (opt.btns) {
//绑定按钮事件
if (!!opt.btns) {
for (i = 0; i < opt.btns.length; i++) {
bindBtnEvt(i);
}
... ...