",
+ ];
+
+ if (options["header"]) {
+ var closeButton = "";
+ if (
+ typeof options["headerCloseButton"] == "undefined" ||
+ options["headerCloseButton"]
+ ) {
+ closeButton =
+ "
×";
+ }
+
+ parts.push(
+ ""
+ );
+ }
+
+ // push an empty body into which we'll inject the proper content later
+ parts.push("
");
+
+ if (buttons) {
+ parts.push("");
+ }
+
+ parts.push("
");
+
+ var div = $(parts.join("\n"));
+
+ // check whether we should fade in/out
+ var shouldFade =
+ typeof options.animate === "undefined" ? _animate : options.animate;
+
+ if (shouldFade) {
+ div.addClass("fade");
+ }
+
+ var optionalClasses =
+ typeof options.classes === "undefined" ? _classes : options.classes;
+ if (optionalClasses) {
+ div.addClass(optionalClasses);
+ }
+
+ // now we've built up the div properly we can inject the content whether it was a string or a jQuery object
+ div.find(".modal-body").html(str);
+
+ function onCancel(source) {
+ // for now source is unused, but it will be in future
+ var hideModal = null;
+ if (typeof options.onEscape === "function") {
+ // @see https://github.com/makeusabrew/bootbox/issues/91
+ hideModal = options.onEscape();
+ }
+
+ if (hideModal !== false) {
+ div.modal("hide");
+ }
+ }
+
+ // hook into the modal's keyup trigger to check for the escape key
+ div.on("keyup.dismiss.modal", function (e) {
+ // any truthy value passed to onEscape will dismiss the dialog
+ // as long as the onEscape function (if defined) doesn't prevent it
+ if (e.which === 27 && options.onEscape !== false) {
+ onCancel("escape");
+ }
+ });
+
+ // handle close buttons too
+ div.on("click", "a.close", function (e) {
+ e.preventDefault();
+ onCancel("close");
+ });
+
+ // well, *if* we have a primary - give the first dom element focus
+ div.on("shown.bs.modal", function () {
+ div.find("a.btn-primary:first").focus();
+ });
+
+ div.on("hidden.bs.modal", function () {
+ div.remove();
+ });
+
+ // wire up button handlers
+ div.on("click", ".modal-footer a", function (e) {
+ var self = this;
+ Ember.run(function () {
+ var handler = $(self).data("handler"),
+ cb = callbacks[handler],
+ hideModal = null;
+
+ // sort of @see https://github.com/makeusabrew/bootbox/pull/68 - heavily adapted
+ // if we've got a custom href attribute, all bets are off
+ if (
+ typeof handler !== "undefined" &&
+ typeof handlers[handler]["href"] !== "undefined"
+ ) {
+ return;
+ }
+
+ e.preventDefault();
+
+ if (typeof cb === "function") {
+ hideModal = cb(e);
+ }
+
+ // the only way hideModal *will* be false is if a callback exists and
+ // returns it as a value. in those situations, don't hide the dialog
+ // @see https://github.com/makeusabrew/bootbox/pull/25
+ if (hideModal !== false) {
+ div.modal("hide");
+ }
});
+ });
- // ... the reason the prompt needs to be hidden is because we need
- // to bind our own "shown" handler, after creating the modal but
- // before any show(n) events are triggered
- // @see https://github.com/makeusabrew/bootbox/issues/69
+ // stick the modal right at the bottom of the main body out of the way
+ (that.$body || $("body")).append(div);
- div.on("shown", function() {
- form.find("input[type=text]").focus();
+ div.modal({
+ // unless explicitly overridden take whatever our default backdrop value is
+ backdrop:
+ typeof options.backdrop === "undefined"
+ ? _backdrop
+ : options.backdrop,
+ // ignore bootstrap's keyboard options; we'll handle this ourselves (more fine-grained control)
+ keyboard: false,
+ // @ see https://github.com/makeusabrew/bootbox/issues/69
+ // we *never* want the modal to be shown before we can bind stuff to it
+ // this method can also take a 'show' option, but we'll only use that
+ // later if we need to
+ show: false,
+ });
- // ensure that submitting the form (e.g. with the enter key)
- // replicates the behaviour of a normal prompt()
- form.on("submit", function(e) {
- e.preventDefault();
- div.find(".btn-primary").click();
- });
- });
+ // @see https://github.com/makeusabrew/bootbox/issues/64
+ // @see https://github.com/makeusabrew/bootbox/issues/60
+ // ...caused by...
+ // @see https://github.com/twitter/bootstrap/issues/4781
+ div.on("show", function (e) {
+ $(document).off("focusin.modal");
+ });
+ if (typeof options.show === "undefined" || options.show === true) {
div.modal("show");
+ }
- return div;
- };
-
- that.dialog = function(str, handlers, options) {
- var buttons = "",
- callbacks = [];
-
- if (!options) {
- options = {};
- }
-
- // check for single object and convert to array if necessary
- if (typeof handlers === 'undefined') {
- handlers = [];
- } else if (typeof handlers.length == 'undefined') {
- handlers = [handlers];
- }
-
- var i = handlers.length;
- while (i--) {
- var label = null,
- href = null,
- _class = 'btn-default',
- icon = '',
- callback = null;
-
- if (typeof handlers[i]['label'] == 'undefined' &&
- typeof handlers[i]['class'] == 'undefined' &&
- typeof handlers[i]['callback'] == 'undefined') {
- // if we've got nothing we expect, check for condensed format
-
- var propCount = 0, // condensed will only match if this == 1
- property = null; // save the last property we found
-
- // be nicer to count the properties without this, but don't think it's possible...
- for (var j in handlers[i]) {
- property = j;
- if (++propCount > 1) {
- // forget it, too many properties
- break;
- }
- }
-
- if (propCount == 1 && typeof handlers[i][j] == 'function') {
- // matches condensed format of label -> function
- handlers[i]['label'] = property;
- handlers[i]['callback'] = handlers[i][j];
- }
- }
-
- if (typeof handlers[i]['callback']== 'function') {
- callback = handlers[i]['callback'];
- }
-
- if (handlers[i]['class']) {
- _class = handlers[i]['class'];
- } else if (i == handlers.length -1 && handlers.length <= 2) {
- // always add a primary to the main option in a two-button dialog
- _class = 'btn-primary';
- }
-
- // See: https://github.com/makeusabrew/bootbox/pull/114
- // Upgrade to official bootbox release when it gets merged.
- if (handlers[i]['link'] !== true) {
- _class = 'btn ' + _class;
- }
-
- if (handlers[i]['label']) {
- label = handlers[i]['label'];
- } else {
- label = "Option "+(i+1);
- }
-
- if (handlers[i]['icon']) {
- icon = handlers[i]['icon'];
- }
-
- if (handlers[i]['href']) {
- href = handlers[i]['href'];
- }
- else {
- href = _defaultHref;
- }
-
- buttons = buttons + ""];
-
- if (options['header']) {
- var closeButton = '';
- if (typeof options['headerCloseButton'] == 'undefined' || options['headerCloseButton']) {
- closeButton = "
×";
- }
-
- parts.push("");
- }
-
- // push an empty body into which we'll inject the proper content later
- parts.push("
");
-
- if (buttons) {
- parts.push("");
- }
-
- parts.push("
");
-
- var div = $(parts.join("\n"));
-
- // check whether we should fade in/out
- var shouldFade = (typeof options.animate === 'undefined') ? _animate : options.animate;
-
- if (shouldFade) {
- div.addClass("fade");
- }
-
- var optionalClasses = (typeof options.classes === 'undefined') ? _classes : options.classes;
- if (optionalClasses) {
- div.addClass(optionalClasses);
- }
-
- // now we've built up the div properly we can inject the content whether it was a string or a jQuery object
- div.find(".modal-body").html(str);
-
- function onCancel(source) {
- // for now source is unused, but it will be in future
- var hideModal = null;
- if (typeof options.onEscape === 'function') {
- // @see https://github.com/makeusabrew/bootbox/issues/91
- hideModal = options.onEscape();
- }
-
- if (hideModal !== false) {
- div.modal('hide');
- }
- }
-
- // hook into the modal's keyup trigger to check for the escape key
- div.on('keyup.dismiss.modal', function(e) {
- // any truthy value passed to onEscape will dismiss the dialog
- // as long as the onEscape function (if defined) doesn't prevent it
- if (e.which === 27 && options.onEscape !== false) {
- onCancel('escape');
- }
- });
-
- // handle close buttons too
- div.on('click', 'a.close', function(e) {
- e.preventDefault();
- onCancel('close');
- });
-
- // well, *if* we have a primary - give the first dom element focus
- div.on('shown.bs.modal', function() {
- div.find("a.btn-primary:first").focus();
- });
-
- div.on('hidden.bs.modal', function() {
- div.remove();
- });
-
- // wire up button handlers
- div.on('click', '.modal-footer a', function(e) {
- var self = this;
- Ember.run(function() {
-
- var handler = $(self).data("handler"),
- cb = callbacks[handler],
- hideModal = null;
-
- // sort of @see https://github.com/makeusabrew/bootbox/pull/68 - heavily adapted
- // if we've got a custom href attribute, all bets are off
- if (typeof handler !== 'undefined' &&
- typeof handlers[handler]['href'] !== 'undefined') {
-
- return;
- }
-
- e.preventDefault();
-
- if (typeof cb === 'function') {
- hideModal = cb(e);
- }
-
- // the only way hideModal *will* be false is if a callback exists and
- // returns it as a value. in those situations, don't hide the dialog
- // @see https://github.com/makeusabrew/bootbox/pull/25
- if (hideModal !== false) {
- div.modal("hide");
- }
- });
- });
-
- // stick the modal right at the bottom of the main body out of the way
- (that.$body || $("body")).append(div);
-
- div.modal({
- // unless explicitly overridden take whatever our default backdrop value is
- backdrop : (typeof options.backdrop === 'undefined') ? _backdrop : options.backdrop,
- // ignore bootstrap's keyboard options; we'll handle this ourselves (more fine-grained control)
- keyboard : false,
- // @ see https://github.com/makeusabrew/bootbox/issues/69
- // we *never* want the modal to be shown before we can bind stuff to it
- // this method can also take a 'show' option, but we'll only use that
- // later if we need to
- show : false
- });
-
- // @see https://github.com/makeusabrew/bootbox/issues/64
- // @see https://github.com/makeusabrew/bootbox/issues/60
- // ...caused by...
- // @see https://github.com/twitter/bootstrap/issues/4781
- div.on("show", function(e) {
- $(document).off("focusin.modal");
- });
-
- if (typeof options.show === 'undefined' || options.show === true) {
- div.modal("show");
- }
-
- return div;
+ return div;
};
/**
@@ -502,64 +555,63 @@ var bootbox = window.bootbox || (function(document, $) {
* made - have never been truly convinced of its merit but perhaps just
* needs a tidyup and some TLC
*/
- that.modal = function(/*str, label, options*/) {
- var str;
- var label;
- var options;
+ that.modal = function (/*str, label, options*/) {
+ var str;
+ var label;
+ var options;
- var defaultOptions = {
- "onEscape": null,
- "keyboard": true,
- "backdrop": _backdrop
- };
+ var defaultOptions = {
+ onEscape: null,
+ keyboard: true,
+ backdrop: _backdrop,
+ };
- switch (arguments.length) {
- case 1:
- str = arguments[0];
- break;
- case 2:
- str = arguments[0];
- if (typeof arguments[1] == 'object') {
- options = arguments[1];
- } else {
- label = arguments[1];
- }
- break;
- case 3:
- str = arguments[0];
- label = arguments[1];
- options = arguments[2];
- break;
- default:
- throw new Error("Incorrect number of arguments: expected 1-3");
- }
+ switch (arguments.length) {
+ case 1:
+ str = arguments[0];
+ break;
+ case 2:
+ str = arguments[0];
+ if (typeof arguments[1] == "object") {
+ options = arguments[1];
+ } else {
+ label = arguments[1];
+ }
+ break;
+ case 3:
+ str = arguments[0];
+ label = arguments[1];
+ options = arguments[2];
+ break;
+ default:
+ throw new Error("Incorrect number of arguments: expected 1-3");
+ }
- defaultOptions['header'] = label;
+ defaultOptions["header"] = label;
- if (typeof options == 'object') {
- options = $.extend(defaultOptions, options);
- } else {
- options = defaultOptions;
- }
+ if (typeof options == "object") {
+ options = $.extend(defaultOptions, options);
+ } else {
+ options = defaultOptions;
+ }
- return that.dialog(str, [], options);
+ return that.dialog(str, [], options);
};
-
- that.hideAll = function() {
- $(".bootbox").modal("hide");
+ that.hideAll = function () {
+ $(".bootbox").modal("hide");
};
- that.animate = function(animate) {
- _animate = animate;
+ that.animate = function (animate) {
+ _animate = animate;
};
- that.backdrop = function(backdrop) {
- _backdrop = backdrop;
+ that.backdrop = function (backdrop) {
+ _backdrop = backdrop;
};
- that.classes = function(classes) {
- _classes = classes;
+ that.classes = function (classes) {
+ _classes = classes;
};
/**
@@ -571,90 +623,93 @@ var bootbox = window.bootbox || (function(document, $) {
* unlikely to be required. If this gets too large it can be split out into separate JS files.
*/
var _locales = {
- 'br' : {
- OK : 'OK',
- CANCEL : 'Cancelar',
- CONFIRM : 'Sim'
- },
- 'da' : {
- OK : 'OK',
- CANCEL : 'Annuller',
- CONFIRM : 'Accepter'
- },
- 'de' : {
- OK : 'OK',
- CANCEL : 'Abbrechen',
- CONFIRM : 'Akzeptieren'
- },
- 'en' : {
- OK : 'OK',
- CANCEL : 'Cancel',
- CONFIRM : 'OK'
- },
- 'es' : {
- OK : 'OK',
- CANCEL : 'Cancelar',
- CONFIRM : 'Aceptar'
- },
- 'fr' : {
- OK : 'OK',
- CANCEL : 'Annuler',
- CONFIRM : 'D\'accord'
- },
- 'it' : {
- OK : 'OK',
- CANCEL : 'Annulla',
- CONFIRM : 'Conferma'
- },
- 'nl' : {
- OK : 'OK',
- CANCEL : 'Annuleren',
- CONFIRM : 'Accepteren'
- },
- 'pl' : {
- OK : 'OK',
- CANCEL : 'Anuluj',
- CONFIRM : 'Potwierdź'
- },
- 'ru' : {
- OK : 'OK',
- CANCEL : 'Отмена',
- CONFIRM : 'Применить'
- },
- 'zh_CN' : {
- OK : 'OK',
- CANCEL : '取消',
- CONFIRM : '确认'
- },
- 'zh_TW' : {
- OK : 'OK',
- CANCEL : '取消',
- CONFIRM : '確認'
- }
+ br: {
+ OK: "OK",
+ CANCEL: "Cancelar",
+ CONFIRM: "Sim",
+ },
+ da: {
+ OK: "OK",
+ CANCEL: "Annuller",
+ CONFIRM: "Accepter",
+ },
+ de: {
+ OK: "OK",
+ CANCEL: "Abbrechen",
+ CONFIRM: "Akzeptieren",
+ },
+ en: {
+ OK: "OK",
+ CANCEL: "Cancel",
+ CONFIRM: "OK",
+ },
+ es: {
+ OK: "OK",
+ CANCEL: "Cancelar",
+ CONFIRM: "Aceptar",
+ },
+ fr: {
+ OK: "OK",
+ CANCEL: "Annuler",
+ CONFIRM: "D'accord",
+ },
+ it: {
+ OK: "OK",
+ CANCEL: "Annulla",
+ CONFIRM: "Conferma",
+ },
+ nl: {
+ OK: "OK",
+ CANCEL: "Annuleren",
+ CONFIRM: "Accepteren",
+ },
+ pl: {
+ OK: "OK",
+ CANCEL: "Anuluj",
+ CONFIRM: "Potwierdź",
+ },
+ ru: {
+ OK: "OK",
+ CANCEL: "Отмена",
+ CONFIRM: "Применить",
+ },
+ zh_CN: {
+ OK: "OK",
+ CANCEL: "取消",
+ CONFIRM: "确认",
+ },
+ zh_TW: {
+ OK: "OK",
+ CANCEL: "取消",
+ CONFIRM: "確認",
+ },
};
function _translate(str, locale) {
- // we assume if no target locale is probided then we should take it from current setting
- if (typeof locale === 'undefined') {
- locale = _locale;
- }
- if (typeof _locales[locale][str] === 'string') {
- return _locales[locale][str];
- }
+ // we assume if no target locale is probided then we should take it from current setting
+ if (typeof locale === "undefined") {
+ locale = _locale;
+ }
+ if (typeof _locales[locale][str] === "string") {
+ return _locales[locale][str];
+ }
- // if we couldn't find a lookup then try and fallback to a default translation
+ // if we couldn't find a lookup then try and fallback to a default translation
- if (locale != _defaultLocale) {
- return _translate(str, _defaultLocale);
- }
+ if (locale != _defaultLocale) {
+ return _translate(str, _defaultLocale);
+ }
- // if we can't do anything then bail out with whatever string was passed in - last resort
- return str;
+ // if we can't do anything then bail out with whatever string was passed in - last resort
+ return str;
}
return that;
-
-}(document, window.jQuery));
+ })(document, window.jQuery);
// @see https://github.com/makeusabrew/bootbox/issues/71
window.bootbox = bootbox;
+
+define("bootbox", ["exports"], function (__exports__) {
+ __exports__.default = window.bootbox;
+});
diff --git a/yarn.lock b/yarn.lock
index fb0409e786a..f2c2b01117d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2494,12 +2494,7 @@ pretender@^1.6:
fake-xml-http-request "^1.6.0"
route-recognizer "^0.3.3"
-prettier@2.2.1:
- version "2.2.1"
- resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
- integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
-
-prettier@^2.0.4:
+prettier@2.2.1, prettier@^2.0.4:
version "2.2.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==