/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ function bsalert(title, message, okbtn, cancelbtn, callback) { var html = ''; $("body").append(html); $("#bsalert-title").text(title); $("#bsalert-message").text(message); if (typeof okbtn != "string") { okbtn = "OK"; } $("#bsalert-ok").text(okbtn); if (typeof cancelbtn != "string") { cancelbtn = "Cancel"; } $("#bsalert-cancel").text(cancelbtn); $("#bsalert-ok").on("click", function () { if (typeof callback != 'undefined') { callback(); } $("#bsalert").modal("hide"); }); $("#bsalert").on("hidden.bs.modal", function () { $("#bsalert").remove(); }); $("#bsalert").modal("show"); } function bsprompt(title, message, okbtn, cancelbtn, type, callback) { var html = ''; $("body").append(html); $("#bsprompt-title").text(title); $("#bsprompt-message").text(message); $("#bsprompt-ok").text(okbtn); $("#bsprompt-cancel").text(cancelbtn); $("#bsprompt-input").attr("type", type); $("#bsprompt-input").on("keypress", function (e) { if (e.which === 13) { callback($("#bsprompt-input").val()); $("#bsprompt").modal("hide"); } }); $("#bsprompt-ok").on("click", function () { callback($("#bsprompt-input").val()); $("#bsprompt").modal("hide"); }); $("#bsprompt").on("shown.bs.modal", function () { $("#bsprompt-input").focus(); }); $("#bsprompt").on("hidden.bs.modal", function () { $("#bsprompt").remove(); }); $("#bsprompt").modal("show"); } function bschoices(title, message, options, cancelbtn, callback) { var html = ''; $("body").append(html); $("#bschoices-title").text(title); $("#bschoices-message").text(message); $("#bschoices-cancel").text(cancelbtn); for (var i = 0; i < options.length; i++) { var text = options[i]["text"]; var val = options[i]["val"]; $("#bschoices-list").append('
' + text + '
'); } $(".bschoices-option").css("cursor", "pointer"); $(".bschoices-option").on("click", function () { callback($(this).data("value")); $("#bschoices").modal("hide"); }); $("#bschoices").on("hidden.bs.modal", function () { $("#bschoices").remove(); }); $("#bschoices").modal("show"); }