forked from jeffreypolk/bootstrap-wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwizard.min.js
1 lines (1 loc) · 7.27 KB
/
wizard.min.js
1
!function (a) { var b = "wizardsettings", c = function (a) { var c = a.data(b); a.find(".wizard-step").hide().first().show(), a.find("button").show(), c.prevButton.prop("disabled", !0), 1 === c.stepCount ? (c.nextButton.html(c.submitText), c.prevButton.hide()) : c.nextButton.html(c.nextText), c.okButton.hide(), c.stepIndex = 1, o(a), q(c.progress, 1, c.stepCount), c.titleElement.html(m(a, c)) }, d = function (b, c) { var d = a(b.find(".wizard-step")[c.stepIndex - 1]), e = d.find("form"); if (e.length) { if (a.isFunction(e.valid) && e.valid() === !1) return !1; if (a.isFunction(e.validate) && e.validate() === !1) return !1 } if (c.validators) for (var f = 0; f < c.validators.length; f++) { var g = c.validators[f]; if ((0 === g.step || g.step === c.stepIndex) && a.isFunction(g.validate) && g.validate.call(b) === !1) return !1 } return !0 }, e = function (c, e) { var g = c.data(b); if (e === !0) { if (d(c, g) === !1) return; if (g.stepIndex === g.stepCount) return void (a.isFunction(g.onSubmit) ? g.onSubmit.call(c) : f(c)) } var h = g.stepIndex, i = e ? g.stepIndex + 1 : g.stepIndex - 1; if (g.stepIndex = i, i > g.stepCount || i < 1); else { var j = c.find(".wizard-step"); a(j[h - 1]).hide(), g.titleElement.html(m(c, g)), a(j[i - 1]).show(), o(c), q(g.progress, g.stepIndex, g.stepCount), 1 === i ? (g.prevButton.prop("disabled", !0), g.nextButton.html(g.nextText)) : i === g.stepCount ? (g.nextButton.html(g.submitText), g.prevButton.prop("disabled", !1)) : (g.prevButton.prop("disabled", !1), g.nextButton.html(g.nextText)) } }, f = function (d) { var e = d.data(b); e.isModal === !0 && d.modal("hide"), c(d), a.isFunction(e.onReset) && e.onReset.call(d), a.isFunction(e.onClose) && e.onClose.call(d), e.isModal === !1 && d.hide() }, g = function (c) { var d = c.data(b); a.isFunction(d.onSubmit) ? d.onSubmit.call(c) : f(c) }, h = function (c) { var d = c.data(b), e = !0; a.isFunction(d.onCancel) && d.onCancel.call(c) === !1 && (e = !1), e && f(c) }, i = function (c) { var d = c.data(b); d.isModal ? c.modal({ backdrop: "static", keyboard: d.showCancel }) : c.show(), a.isFunction(d.onOpen) && d.onOpen.call(c) }, j = function (a, b) { var c = []; return b.isModal && c.push('<div class="modal-dialog">'), c.push(' <div class="modal-content', b.isModal ? "" : " wizard-nomodal", '">'), c.push(' <div class="modal-header">'), b.isModal && b.showCancel === !0 && (c.push(' <button type="button" class="close wizard-cancel-header">'), c.push(' <span aria-hidden="true">×</span>'), c.push(' <span class="sr-only">Close</span>'), c.push(" </button>")), c.push(' <h4 class="modal-title wizard-title">', m(a, b), "</h4>"), c.push(" </div>"), c.push(' <div class="modal-body wizard-body">'), b.showProgress && c.push(l(b)), c.push(' <div class="wizard-info alert alert-info" style="display:none"></div>'), c.push(' <div class="wizard-success alert alert-success" style="display:none"></div>'), c.push(' <div class="wizard-warning alert alert-warning" style="display:none"></div>'), c.push(' <div class="wizard-error alert alert-danger" style="display:none"></div>'), c.push(" </div>"), c.push(' <div class="modal-footer wizard-footer">'), c.push(k(b)), c.push(" </div>"), c.push(" </div>"), b.isModal && c.push("</div>"), c.join("") }, k = function (a) { var b = []; return a.showPrevious === !0 && b.push('<button type="button" class="btn btn-default wizard-prev">', a.previousText, "</button>"), b.push('<button type="button" class="btn btn-primary wizard-next">', a.nextText, "</button>"), a.showCancel === !0 && b.push('<button type="button" class="btn btn-default wizard-cancel">' + a.cancelText + "</button>"), b.push('<button type="button" class="btn btn-primary wizard-ok">OK</button>'), b.join("") }, l = function (a) { var b = []; return b.push('<div class="progress">'), b.push(' <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="1" aria-valuemin="1" aria-valuemax="10" style="width: 0%;">Progress</div>'), b.push("</div>"), b.join("") }, m = function (b, c) { var d = c.stepIndex ? c.stepIndex : 1, e = a(b.find(".wizard-step")[d - 1]); return e.data("title") ? e.data("title") : c.title }, n = function (a, b, c) { a.find("div.wizard-" + b).html(c).show() }, o = function (a) { a.find(".alert").html("").hide() }, p = function (a, b, c) { a.find(".wizard-step").hide(), a.find(".progress").hide(), o(a), c.info && n(a, "info", c.info), c.warning && n(a, "warning", c.warning), c.success && n(a, "success", c.success), c.error && n(a, "error", c.error), b.titleElement.html(b.title), b.prevButton.hide(), b.nextButton.hide(), b.cancelButton.hide(), b.okButton.show(); var d = 0; c.autoClose === !0 ? d = 2e3 : c.autoClose > 0 && (d = c.autoClose), d > 0 && window.setTimeout(function () { f(a) }, d) }, q = function (a, b, c) { var d = parseInt(b / c * 100); a.css("width", d + "%"), a.html("Step " + b + " of " + c), a.parent().show() }, r = { init: function (d) { var g = a.extend({ title: "", validators: null, onSubmit: null, onReset: null, onCancel: null, onClose: null, onOpen: null, previousText: "<< Back", nextText: "Next >>", submitText: "Submit", cancelText: "Cancel", showCancel: !0, showPrevious: !0, showProgress: !1, isModal: !0, autoOpen: !1 }, d); return this.each(function () { var d = a(this); a(j(d, g)).appendTo(d), d.parent().is("body") || d.appendTo(a("body")), g.isModal && (d.addClass("modal"), d.attr("tabindex", "-1")), d.hide(), g.prevButton = d.find(".wizard-prev"), g.nextButton = d.find(".wizard-next"), g.cancelButton = d.find(".wizard-cancel"), g.okButton = d.find(".wizard-ok"), g.progress = d.find(".progress-bar"), g.titleElement = d.find(".wizard-title"), g.bodyHeight && a(this).find(".wizard-body").height(g.bodyHeight), g.stepCount = d.find(".wizard-step").length, q(g.progress, 1, g.stepCount), g.prevButton.click(function () { e(a(this).parents(".wizard").first(), !1) }), g.nextButton.click(function () { e(a(this).parents(".wizard").first(), !0) }), g.cancelButton.click(function () { h(a(this).parents(".wizard").first(), !0) }), g.okButton.click(function () { f(a(this).parents(".wizard").first(), !0) }), d.find(".wizard-cancel-header").click(function () { h(a(this).parents(".wizard").first()) }), 1 === g.stepCount && (g.nextButton.html(g.submitText), g.prevButton.hide()), d.find(".wizard-step").appendTo(d.find(".wizard-body")), d.data(b, g), c(d), g.autoOpen === !0 && i(d) }) }, open: function () { return this.each(function () { i(a(this)) }) }, close: function () { return this.each(function () { f(a(this)) }) }, submit: function () { return this.each(function () { g(a(this)) }) }, info: function (b) { return this.each(function () { n(a(this), "info", b) }) }, warning: function (b) { return this.each(function () { n(a(this), "warning", b) }) }, success: function (b) { return this.each(function () { n(a(this), "success", b) }) }, error: function (b) { return this.each(function () { n(a(this), "error", b) }) }, end: function (c) { var d = a.extend({ info: null, warning: null, success: null, error: null, autoClose: !1 }, c); return this.each(function () { p(a(this), a(this).data(b), d) }) } }; a.fn.wizard = function (b) { return r[b] ? r[b].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof b && b ? void a.error("Method " + b + " does not exist on jQuery.tooltip") : r.init.apply(this, arguments) } }(jQuery);