// ================================Dialog===================================//
|
Dialog = {};
|
|
$.fm.DialogClass = Control.subClass({
|
template: [
|
'<div class="win_mask"></div>',
|
'<div class="dialog_mask" style="display: none; z-index: 1001;" align="center">',
|
'<div class="dialog">',
|
'<div class="dialog_header" id="title">',
|
'信息提示',
|
'</div>',
|
'<div class="dialog_body" id="dialog_body">',
|
'<div class="dialog_content" id="dialog_content">',
|
'<div class="dialog_image" id="image"></div>',
|
'<span id="body_title"></span>',
|
'<div class="dialog_text" id="text"></div>',
|
'</div>',
|
'</div>',
|
'<div class="dialog_footer" id="dialog_footer">',
|
'<button class="button btn_light" id="btn_cancel">取消</button>',
|
'<button class="button btn_blue" id="btn_ok" style="margin-left:8px">确定</button>',
|
'</div>',
|
'</div>',
|
'</div>'
|
],
|
|
init: function(options) {
|
options = options ? options : {};
|
Control.call(this, options);
|
|
this.createEl();
|
},
|
|
createEl: function() {
|
var me = this;
|
var el = this.el = $(this.template.join(""));
|
|
this.title = $("#title", el);
|
this.body = $("#dialog_body", el);
|
this.body_title = $("#body_title", el);
|
this.dialog_content = $("#dialog_content", el);
|
this.dialog_footer = $("#dialog_footer", el);
|
|
this.image = $("#image", el);
|
this.text = $("#text", el);
|
this.btn_cancel = $("#btn_cancel", el);
|
this.btn_ok = $("#btn_ok", el);
|
|
this.btn_cancel.click(function() {
|
me.el.hide();
|
if (me.callback) {
|
me.callback(false);
|
}
|
});
|
|
this.btn_ok.click(function() {
|
me.el.hide();
|
if (me.callback) {
|
me.callback(true);
|
}
|
});
|
|
this.canvas.append(this.el);
|
},
|
|
databox: function(title, callback, config) {
|
var input = config.input || "";
|
var body_title = config.body_title || "";
|
|
if (config.onShow) {
|
onShow();
|
}
|
|
this.title.html(title);
|
this.body.removeAttr("class");
|
this.dialog_content.removeAttr("class");
|
this.image.removeAttr("class");
|
this.text.removeAttr("class");
|
this.dialog_footer.removeAttr("class");
|
this.body.addClass("databox_body");
|
this.dialog_content.addClass("databox_content");
|
this.image.addClass("databox_image");
|
this.text.addClass("databox_text");
|
this.dialog_footer.addClass("databox_footer");
|
|
this.body_title.html(body_title);
|
this.text.html(input);
|
this.btn_cancel.show();
|
|
this.callback = callback;
|
|
this.el.show();
|
},
|
|
confirm: function (title, text, callback) {
|
this.title.html(title);
|
this.text.html(text);
|
this.image.removeClass("icon_alert");
|
this.image.addClass("icon_confirm");
|
this.btn_cancel.show();
|
|
this.callback = callback;
|
|
this.el.show();
|
},
|
|
alert: function (title, text1, text2, callback) {
|
this.title.html(title);
|
|
if (text2) {
|
this.text.html(text1 + "<br>" + text2);
|
this.text.css("line-height", "23px");
|
}
|
else {
|
this.text.html(text1);
|
this.text.css("line-height", "36px");
|
}
|
|
this.image.removeClass("icon_confirm");
|
this.image.addClass("icon_alert");
|
this.btn_cancel.hide();
|
|
this.callback = callback ? callback : null;
|
|
this.el.show();
|
}
|
});
|
|
Dialog.databox = function(title, callback, config) {
|
config = config || {};
|
|
if (!this.instance) {
|
this.instance = new $.fm.DialogClass();
|
}
|
this.instance.databox(title, callback, config);
|
};
|
|
Dialog.confirm = function(title, text, callback) {
|
if (!this.instance) {
|
this.instance = new $.fm.DialogClass();
|
}
|
this.instance.confirm(title, text, callback);
|
};
|
|
Dialog.alert = function(text1, text2, callback) {
|
if (!this.instance) {
|
this.instance = new $.fm.DialogClass();
|
}
|
this.instance.alert("提醒", text1, text2, callback);
|
};
|
|
Dialog.wait = function(text) {
|
if (!this.instance) {
|
this.instance = new $.fm.DialogClass();
|
}
|
this.instance.wait("提醒", text1, text2);
|
};
|