/**
* bootbox.js v4.0.0
*
* http://bootboxjs.com/license.txt
*/
var BOOTBOX_ZINDEX = 10000;
window.bootbox = window.bootbox || function a(b, c) {
"use strict";
function d(a) {
var b = s[q.locale];
return b ? b[a] : s.en[a]
}
function e(a, c, d) {
a.preventDefault();
var e = b.isFunction(d) && d(a) === !1;
e || c.modal("hide")
}
function f(a) {
var b, c = 0;
for (b in a)c++;
return c
}
function g(a, c) {
var d = 0;
b.each(a, function (a, b) {
c(a, b, d++)
})
}
function h(a) {
var c, d;
if ("object" != typeof a)throw new Error("Please supply an object of options");
if (!a.message)throw new Error("Please specify a message");
return a = b.extend({}, q, a), a.buttons || (a.buttons = {}), a.backdrop = a.backdrop ? "static" : !1, c = a.buttons, d = f(c), g(c, function (a, e, f) {
if (b.isFunction(e) && (e = c[a] = {callback: e}), "object" !== b.type(e))throw new Error("button with key " + a + " must be an object");
e.label || (e.label = a), e.className || (e.className = 2 >= d && f === d - 1 ? "btn-success" : "btn-default")
}), a
}
function i(a, b) {
var c = a.length, d = {};
if (1 > c || c > 2)throw new Error("Invalid argument length");
return 2 === c || "string" == typeof a[0] ? (d[b[0]] = a[0], d[b[1]] = a[1]) : d = a[0], d
}
function j(a, c, d) {
return b.extend(!0, {}, a, i(c, d))
}
function k(a, b, c) {
return n(j(m.apply(null, a), b, c), a)
}
function l() {
for (var a = {}, b = 0, c = arguments.length; c > b; b++) {
var e = arguments[b], f = e.toLowerCase(), g = e.toUpperCase();
a[f] = {label: d(g)}
}
return a
}
function m() {
return {buttons: l.apply(null, arguments)}
}
function n(a, b) {
var d = {};
return g(b, function (a, b) {
d[b] = !0
}), g(a.buttons, function (a) {
if (d[a] === c)throw new Error("button key " + a + " is not allowed (options are " + b.join("\n") + ")")
}), a
}
function w(c, a) {
if (a.width || a.height || a.draggable) {
var _d = c.children('.modal-dialog');
if (a.width) _d.width(a.width);
if (a.height) _d.height(a.height);
if (a.draggable) {
_d.draggable({handle: _d.find('.modal-header')}).css({
position: 'absolute',
'left': Math.floor(($(document).width() - _d.width()) / 2)
});
}
}
if (a.center) {
_d.removeClass('in').addClass('modal-dialog-center');
}
}
var o = {
dialog: "
",
header: "
",
footer: "",
closeButton: "",
form: "",
inputs: {text: ""}
}, p = b("body"), q = {locale: "zh_CN", backdrop: !0, animate: !0, className: null, closeButton: !0, show: !0},
r = {};
r.alert = function () {
var a;
if (a = k(["ok"], arguments, ["message", "callback"]), a.callback && !b.isFunction(a.callback))throw new Error("alert requires callback property to be a function when provided");
return a.buttons.ok.callback = a.onEscape = function () {
return b.isFunction(a.callback) ? a.callback() : !0
}, r.dialog(a).addClass('bootbox-alert')
}, r.confirm = function () {
var a;
if (a = k(["cancel", "confirm"], arguments, ["message", "callback"]), a.buttons.cancel.callback = a.onEscape = function () {
return a.callback(!1)
}, a.buttons.confirm.callback = function () {
return a.callback(!0)
}, !b.isFunction(a.callback))throw new Error("confirm requires a callback");
a.width = a.width || 480;
a.className = a.className || 'dialog-confirm';
return r.dialog(a)
}, r.prompt = function () {
var a, d, e, f, g, h;
if (f = b(o.form), d = {
buttons: l("cancel", "confirm"),
value: ""
}, a = n(j(d, arguments, ["title", "callback"]), ["cancel", "confirm"]), h = a.show === c ? !0 : a.show, a.message = f, a.buttons.cancel.callback = a.onEscape = function () {
return a.callback(null)
}, a.buttons.confirm.callback = function () {
return a.callback(g.val())
}, a.show = !1, !a.title)throw new Error("prompt requires a title");
if (!b.isFunction(a.callback))throw new Error("prompt requires a callback");
return g = b(o.inputs.text), g.val(a.value), f.append(g), f.on("submit", function (a) {
a.preventDefault(), e.find(".btn-success").click()
}), e = r.dialog(a), e.off("shown.bs.modal"), e.on("shown.bs.modal", function () {
g.focus()
}), h === !0 && e.modal("show"), e
}, r.dialog = function (a) {
a = h(a);
var c = b(o.dialog), d = c.find(".modal-body"), f = a.buttons, i = "", j = {onEscape: a.onEscape};
if (g(f, function (a, b) {
i += "", j[a] = b.callback
}), d.find(".bootbox-body").html(a.message), a.animate === !0 && c.addClass("fade"), a.className && c.addClass(a.className), a.title && d.before(o.header), a.closeButton) {
var k = b(o.closeButton);
a.title ? c.find(".modal-header").prepend(k) : k.css("margin-top", "-10px").prependTo(d)
}
a.width = a.width || 680;
w(c, a);
return a.title && c.find(".modal-title").html(a.title), i.length && (d.after(o.footer), c.find(".modal-footer").html(i)), c.on("hidden.bs.modal", function (e) {
e.target === this && !a.hideMode && c.remove()
if ($.isFunction(a.isClose)) a.isClose();
}), c.on("show.bs.modal", function () {
c.addClass('modal-show');
}), c.on("shown.bs.modal", function () {
var zIndex = a.zIndex || BOOTBOX_ZINDEX;
a.backdrop && c.data('bs.modal')['$backdrop'].css('z-index', zIndex);
c.css('z-index', ++zIndex).removeClass('modal-show').find(".btn-success:first").focus();
++BOOTBOX_ZINDEX;
if ($.isFunction(a.onShow)) a.onShow();
}), c.on("escape.close.bb", function (a) {
j.onEscape && e(a, c, j.onEscape)
}), c.on("click", ".modal-footer button", function (a) {
var d = b(this).data("bb-handler");
e(a, c, j[d])
}), c.on("click", ".bootbox-close-button", function (a) {
e(a, c, j.onEscape)
}), c.on("keyup", function (a) {
27 === a.which && c.trigger("escape.close.bb")
}), p.append(c), c.modal({
backdrop: a.backdrop,
keyboard: a.keyboard || true,
show: !1
}), a.show && c.modal("show") && $('body').addClass('modal-open'), c
}, r.setDefaults = function (a) {
b.extend(q, a)
}, r.hideAll = function () {
b(".bootbox").modal("hide")
}, r.getDialog = function (s) {
return top.bootbox._getDialog(s);
}, r._getDialog = function (s) {
return s = top.$(s), s.length ? s : null;
};
var s = {
en: {OK: "确认", CANCEL: "取消", CONFIRM: "确认"},
zh_CN: {OK: "确认", CANCEL: "取消", CONFIRM: "确认"},
};
return r.init = function (c) {
window.bootbox = a(c || b)
}, r
}(window.jQuery);