/***
* jquery blockUI Dialog plugin
* v1.1
* @createDate -- 2012-1-4
* @author hoojo
* @email hoojo_@126.com
* @requires jQuery v1.2.3 or later, jquery.blockUI-2.3.8
* Copyright (c) 2012 M. hoo
* Dual licensed under the MIT and GPL licenses:
* http://hoojo.cnblogs.com
* http://blog.csdn.net/IBM_hoojo
**/
;(function ($) {
var _dialog = $.blockUI.dialog = {};
// dialog 默认配置
var defaultOptions = {
css: {
padding: '8px',
opacity: .7,
color: '#ffffff',
border: 'none',
'border-radius': '10px',
backgroundColor: '#000000'
},
// 默认回调函数 取消或隐藏 dialog
emptyHandler: function () {
$.unblockUI();
},
// 用户回调函数
callbackHandler: function (fn) {
return function () {
fn();
defaultOptions.emptyHandler();
};
},
// confirm 提示 html元素
confirmElement: function (settings) {
settings = settings || {};
var message = settings.message || "default confirm message!";
var okText = settings.okText || "ok";
var cancelText = settings.cancelText || "cancel";
if (typeof settings.onOk !== "function") {
settings.onOk = this.emptyHandler;
}
if (typeof settings.onCancel !== "function") {
settings.onCancel = this.emptyHandler;
}
var okCallback = this.callbackHandler(settings.onOk) || this.emptyHandler;
var cancelCallback = this.callbackHandler(settings.onCancel) || this.emptyHandler;
var html = [
'<div class="dialog confirm">',
'<p>',
message,
'</p>',
'<input type="button" value="',
okText,
'" class="btn ok-btn"/>',
'<input type="button" value="',
cancelText,
'" class="btn cancel-btn"/>'