diff --git a/CHANGELOG.md b/CHANGELOG.md index 08ab05d8..f049d9f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -## 6.0.0 (Latest Release) +## 6.0.1 (Latest Release) + +- Updates prompt callback to return false from callback if `inputType` is 'checkbox', `required` option is `true`, and no checkbox has been checked +- Updates unit tests + - Adds tests for required option + - Cleanup up pattern tests + - Adds HTML output runner + +### 6.0.0 - Removes various IE polyfills - Replaces `var` with `let` diff --git a/LICENSE.md b/LICENSE.md index 511b82e3..1e7afa23 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,7 +2,7 @@ (The MIT License) -Copyright (C) 2011-2023 by Nick Payne +Copyright (C) 2011-2024 by Nick Payne Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9945f36d..cc0d76bb 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,6 @@ Please see http://bootboxjs.com for full usage instructions, or head over to http://paynedigital.com/bootbox for the original writeup about the project. -## Contact - -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/makeusabrew/bootbox?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - -The easiest thing is to [find me on twitter @makeusabrew](http://twitter.com/makeusabrew). - ## Contributing Please see the [CONTRIBUTING](https://github.com/bootboxjs/bootbox/blob/master/CONTRIBUTING.md) file for guidelines. @@ -42,19 +36,13 @@ Bootbox **3.3.0** is the *last* release to support Bootstrap 2.2.x. Much more dependency information can be found [on the Bootbox website](http://bootboxjs.com/getting-started.html#bootbox-dependencies). -## 6.0.0 (Latest Release) +## 6.0.1 (Latest Release) -- Removes various IE polyfills -- Replaces `var` with `let` -- JSDoc cleanup -- Adds code to handle cases when click starts on the modal body and ends on the backdrop and `backdrop` is set to `true` -- `bootbox.locale.js` and `bootbox.all.js` are now generated files and will be found in the `/dist` directory -- Simplify locale file structure -- Changed a few locale identifiers to match IANA specifications: - - `bg_BG` -> `bg-BG` - - `pt-br` -> `pt-BR` - - `zh_CN` -> `zh-CN` - - `zh_TW` -> `zh-CW` +- Updates prompt callback to return false from callback if `inputType` is 'checkbox', `required` option is `true`, and no checkbox has been checked +- Updates unit tests + - Adds tests for required option + - Cleanup up pattern tests + - Adds HTML output runner For a full list of releases and changes please see [the changelog](https://github.com/bootboxjs/bootbox/blob/master/CHANGELOG.md). @@ -62,7 +50,7 @@ For a full list of releases and changes please see [the changelog](https://githu (The MIT License) -Copyright (C) 2011-2023 by Nick Payne +Copyright (C) 2011-2024 by Nick Payne Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bootbox.js b/bootbox.js index f2de77b9..ee017c5c 100644 --- a/bootbox.js +++ b/bootbox.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ @@ -22,7 +22,7 @@ let exports = {}; - let VERSION = '6.0.0'; + let VERSION = '6.0.1'; exports.VERSION = VERSION; let locales = { diff --git a/dist/bootbox.all.js b/dist/bootbox.all.js index a7bc7a26..fc0a58b6 100644 --- a/dist/bootbox.all.js +++ b/dist/bootbox.all.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ @@ -22,7 +22,7 @@ let exports = {}; - let VERSION = '6.0.0'; + let VERSION = '6.0.1'; exports.VERSION = VERSION; let locales = { @@ -1216,7 +1216,7 @@ /*! @preserve * bootbox.locales.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/dist/bootbox.all.min.js b/dist/bootbox.all.min.js index 16d21574..af60e4e7 100644 --- a/dist/bootbox.all.min.js +++ b/dist/bootbox.all.min.js @@ -1,7 +1,7 @@ /** * Bootbox.js — alert, confirm, prompt, and flexible dialogs for the Bootstrap framework - * @version: 6.0.0 + * @version: 6.0.1 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ -!function(e,t){'use strict';'function'==typeof define&&define.amd?define(['jquery'],t):'object'==typeof exports?module.exports=t(require('jquery')):e.bootbox=t(e.jQuery)}(this,function t(s,c){'use strict';let r={};r.VERSION='6.0.0';let i={en:{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}},d={dialog:'',header:'',footer:'',closeButton:'',form:'
',button:'',option:'',promptMessage:'
',inputs:{text:'',textarea:'',email:'',select:'',checkbox:'
',radio:'
',date:'',time:'',number:'',password:'',range:''}},u={locale:'en',backdrop:'static',animate:!0,className:null,closeButton:!0,show:!0,container:'body',value:'',inputType:'text',errorMessage:null,swapButtonOrder:!1,centerVertical:!1,multiple:!1,scrollable:!1,reusable:!1,relatedTarget:null,size:null,id:null};function l(e,t,o){return s.extend(!0,{},e,function(e,t){var o=e.length;let a={};if(o<1||2').attr('label',t.group)),o=r[t.group]);var a=s(d.option);a.attr('value',t.value).text(t.text),o.append(a)}),f(r,function(e,t){l.append(t)}),l.val(n.value),n.bootstrap<5&&l.removeClass('form-select').addClass('form-control');break;case'checkbox':let t=Array.isArray(n.value)?n.value:[n.value];if(!(i=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "checkbox" requires at least one option');l=s('
'),f(i,function(e,o){if(o.value===c||o.text===c)throw new Error('each option needs a "value" property and a "text" property');let a=s(d.inputs[n.inputType]);a.find('input').attr('value',o.value),a.find('label').append('\n'+o.text),f(t,function(e,t){t===o.value&&a.find('input').prop('checked',!0)}),l.append(a)});break;case'radio':if(n.value!==c&&Array.isArray(n.value))throw new Error('prompt with "inputType" set to "radio" requires a single, non-array value for "value"');if(!(i=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "radio" requires at least one option');l=s('
');let a=!0;f(i,function(e,t){if(t.value===c||t.text===c)throw new Error('each option needs a "value" property and a "text" property');var o=s(d.inputs[n.inputType]);o.find('input').attr('value',t.value),o.find('label').append('\n'+t.text),n.value!==c&&t.value===n.value&&(o.find('input').prop('checked',!0),a=!1),l.append(o)}),a&&l.find('input[type="radio"]').first().prop('checked',!0)}return e.append(l),e.on('submit',function(e){e.preventDefault(),e.stopPropagation(),t.find('.bootbox-accept').trigger('click')}),n.message&&''!==n.message.trim()&&(a=s(d.promptMessage).html(n.message),e.prepend(a)),n.message=e,(t=r.dialog(n)).off('shown.bs.modal',m),t.on('shown.bs.modal',function(){l.focus()}),!0===o&&t.modal('show'),t},r}),function(e,t){'use strict';'function'==typeof define&&define.amd?define(['bootbox'],t):'object'==typeof module&&module.exports?t(require('./bootbox')):t(e.bootbox)}(this,function(e){'use strict';e.addLocale('ar',{OK:'موافق',CANCEL:'الغاء',CONFIRM:'تأكيد'}),e.addLocale('az',{OK:'OK',CANCEL:'İmtina et',CONFIRM:'Təsdiq et'}),e.addLocale('bg-BG',{OK:'Ок',CANCEL:'Отказ',CONFIRM:'Потвърждавам'}),e.addLocale('cs',{OK:'OK',CANCEL:'Zrušit',CONFIRM:'Potvrdit'}),e.addLocale('da',{OK:'OK',CANCEL:'Annuller',CONFIRM:'Accepter'}),e.addLocale('de',{OK:'OK',CANCEL:'Abbrechen',CONFIRM:'Akzeptieren'}),e.addLocale('el',{OK:'Εντάξει',CANCEL:'Ακύρωση',CONFIRM:'Επιβεβαίωση'}),e.addLocale('en',{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}),e.addLocale('es',{OK:'OK',CANCEL:'Cancelar',CONFIRM:'Aceptar'}),e.addLocale('et',{OK:'OK',CANCEL:'Katkesta',CONFIRM:'OK'}),e.addLocale('eu',{OK:'OK',CANCEL:'Ezeztatu',CONFIRM:'Onartu'}),e.addLocale('fa',{OK:'قبول',CANCEL:'لغو',CONFIRM:'تایید'}),e.addLocale('fi',{OK:'OK',CANCEL:'Peruuta',CONFIRM:'OK'}),e.addLocale('fr',{OK:'OK',CANCEL:'Annuler',CONFIRM:'Confirmer'}),e.addLocale('he',{OK:'אישור',CANCEL:'ביטול',CONFIRM:'אישור'}),e.addLocale('hr',{OK:'OK',CANCEL:'Odustani',CONFIRM:'Potvrdi'}),e.addLocale('hu',{OK:'OK',CANCEL:'Mégsem',CONFIRM:'Megerősít'}),e.addLocale('id',{OK:'OK',CANCEL:'Batal',CONFIRM:'OK'}),e.addLocale('it',{OK:'OK',CANCEL:'Annulla',CONFIRM:'Conferma'}),e.addLocale('ja',{OK:'OK',CANCEL:'キャンセル',CONFIRM:'確認'}),e.addLocale('ka',{OK:'OK',CANCEL:'გაუქმება',CONFIRM:'დადასტურება'}),e.addLocale('ko',{OK:'OK',CANCEL:'취소',CONFIRM:'확인'}),e.addLocale('lt',{OK:'Gerai',CANCEL:'Atšaukti',CONFIRM:'Patvirtinti'}),e.addLocale('lv',{OK:'Labi',CANCEL:'Atcelt',CONFIRM:'Apstiprināt'}),e.addLocale('nl',{OK:'OK',CANCEL:'Annuleren',CONFIRM:'Accepteren'}),e.addLocale('no',{OK:'OK',CANCEL:'Avbryt',CONFIRM:'OK'}),e.addLocale('pl',{OK:'OK',CANCEL:'Anuluj',CONFIRM:'Potwierdź'}),e.addLocale('pt-BR',{OK:'OK',CANCEL:'Cancelar',CONFIRM:'Sim'}),e.addLocale('pt',{OK:'OK',CANCEL:'Cancelar',CONFIRM:'Confirmar'}),e.addLocale('ru',{OK:'OK',CANCEL:'Отмена',CONFIRM:'Применить'}),e.addLocale('sk',{OK:'OK',CANCEL:'Zrušiť',CONFIRM:'Potvrdiť'}),e.addLocale('sl',{OK:'OK',CANCEL:'Prekliči',CONFIRM:'Potrdi'}),e.addLocale('sq',{OK:'OK',CANCEL:'Anulo',CONFIRM:'Prano'}),e.addLocale('sv',{OK:'OK',CANCEL:'Avbryt',CONFIRM:'OK'}),e.addLocale('sw',{OK:'Sawa',CANCEL:'Ghairi',CONFIRM:'Thibitisha'}),e.addLocale('ta',{OK:'சரி',CANCEL:'ரத்து செய்',CONFIRM:'உறுதி செய்'}),e.addLocale('th',{OK:'ตกลง',CANCEL:'ยกเลิก',CONFIRM:'ยืนยัน'}),e.addLocale('tr',{OK:'Tamam',CANCEL:'İptal',CONFIRM:'Onayla'}),e.addLocale('uk',{OK:'OK',CANCEL:'Відміна',CONFIRM:'Прийняти'}),e.addLocale('vi',{OK:'OK',CANCEL:'Hủy bỏ',CONFIRM:'Xác nhận'}),e.addLocale('zh-CN',{OK:'OK',CANCEL:'取消',CONFIRM:'确认'}),e.addLocale('zh-TW',{OK:'OK',CANCEL:'取消',CONFIRM:'確認'})}); \ No newline at end of file +!function(e,t){'use strict';'function'==typeof define&&define.amd?define(['jquery'],t):'object'==typeof exports?module.exports=t(require('jquery')):e.bootbox=t(e.jQuery)}(this,function t(s,c){'use strict';let r={};r.VERSION='6.0.1';let i={en:{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}},d={dialog:'',header:'',footer:'',closeButton:'',form:'
',button:'',option:'',promptMessage:'
',inputs:{text:'',textarea:'',email:'',select:'',checkbox:'
',radio:'
',date:'',time:'',number:'',password:'',range:''}},u={locale:'en',backdrop:'static',animate:!0,className:null,closeButton:!0,show:!0,container:'body',value:'',inputType:'text',errorMessage:null,swapButtonOrder:!1,centerVertical:!1,multiple:!1,scrollable:!1,reusable:!1,relatedTarget:null,size:null,id:null};function l(e,t,o){return s.extend(!0,{},e,function(e,t){var o=e.length;let a={};if(o<1||2').attr('label',t.group)),o=r[t.group]);var a=s(d.option);a.attr('value',t.value).text(t.text),o.append(a)}),f(r,function(e,t){l.append(t)}),l.val(n.value),n.bootstrap<5&&l.removeClass('form-select').addClass('form-control');break;case'checkbox':let t=Array.isArray(n.value)?n.value:[n.value];if(!(i=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "checkbox" requires at least one option');l=s('
'),f(i,function(e,o){if(o.value===c||o.text===c)throw new Error('each option needs a "value" property and a "text" property');let a=s(d.inputs[n.inputType]);a.find('input').attr('value',o.value),a.find('label').append('\n'+o.text),f(t,function(e,t){t===o.value&&a.find('input').prop('checked',!0)}),l.append(a)});break;case'radio':if(n.value!==c&&Array.isArray(n.value))throw new Error('prompt with "inputType" set to "radio" requires a single, non-array value for "value"');if(!(i=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "radio" requires at least one option');l=s('
');let a=!0;f(i,function(e,t){if(t.value===c||t.text===c)throw new Error('each option needs a "value" property and a "text" property');var o=s(d.inputs[n.inputType]);o.find('input').attr('value',t.value),o.find('label').append('\n'+t.text),n.value!==c&&t.value===n.value&&(o.find('input').prop('checked',!0),a=!1),l.append(o)}),a&&l.find('input[type="radio"]').first().prop('checked',!0)}return e.append(l),e.on('submit',function(e){e.preventDefault(),e.stopPropagation(),t.find('.bootbox-accept').trigger('click')}),n.message&&''!==n.message.trim()&&(a=s(d.promptMessage).html(n.message),e.prepend(a)),n.message=e,(t=r.dialog(n)).off('shown.bs.modal',m),t.on('shown.bs.modal',function(){l.focus()}),!0===o&&t.modal('show'),t},r}),function(e,t){'use strict';'function'==typeof define&&define.amd?define(['bootbox'],t):'object'==typeof module&&module.exports?t(require('./bootbox')):t(e.bootbox)}(this,function(e){'use strict';e.addLocale('ar',{OK:'موافق',CANCEL:'الغاء',CONFIRM:'تأكيد'}),e.addLocale('az',{OK:'OK',CANCEL:'İmtina et',CONFIRM:'Təsdiq et'}),e.addLocale('bg-BG',{OK:'Ок',CANCEL:'Отказ',CONFIRM:'Потвърждавам'}),e.addLocale('cs',{OK:'OK',CANCEL:'Zrušit',CONFIRM:'Potvrdit'}),e.addLocale('da',{OK:'OK',CANCEL:'Annuller',CONFIRM:'Accepter'}),e.addLocale('de',{OK:'OK',CANCEL:'Abbrechen',CONFIRM:'Akzeptieren'}),e.addLocale('el',{OK:'Εντάξει',CANCEL:'Ακύρωση',CONFIRM:'Επιβεβαίωση'}),e.addLocale('en',{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}),e.addLocale('es',{OK:'OK',CANCEL:'Cancelar',CONFIRM:'Aceptar'}),e.addLocale('et',{OK:'OK',CANCEL:'Katkesta',CONFIRM:'OK'}),e.addLocale('eu',{OK:'OK',CANCEL:'Ezeztatu',CONFIRM:'Onartu'}),e.addLocale('fa',{OK:'قبول',CANCEL:'لغو',CONFIRM:'تایید'}),e.addLocale('fi',{OK:'OK',CANCEL:'Peruuta',CONFIRM:'OK'}),e.addLocale('fr',{OK:'OK',CANCEL:'Annuler',CONFIRM:'Confirmer'}),e.addLocale('he',{OK:'אישור',CANCEL:'ביטול',CONFIRM:'אישור'}),e.addLocale('hr',{OK:'OK',CANCEL:'Odustani',CONFIRM:'Potvrdi'}),e.addLocale('hu',{OK:'OK',CANCEL:'Mégsem',CONFIRM:'Megerősít'}),e.addLocale('id',{OK:'OK',CANCEL:'Batal',CONFIRM:'OK'}),e.addLocale('it',{OK:'OK',CANCEL:'Annulla',CONFIRM:'Conferma'}),e.addLocale('ja',{OK:'OK',CANCEL:'キャンセル',CONFIRM:'確認'}),e.addLocale('ka',{OK:'OK',CANCEL:'გაუქმება',CONFIRM:'დადასტურება'}),e.addLocale('ko',{OK:'OK',CANCEL:'취소',CONFIRM:'확인'}),e.addLocale('lt',{OK:'Gerai',CANCEL:'Atšaukti',CONFIRM:'Patvirtinti'}),e.addLocale('lv',{OK:'Labi',CANCEL:'Atcelt',CONFIRM:'Apstiprināt'}),e.addLocale('nl',{OK:'OK',CANCEL:'Annuleren',CONFIRM:'Accepteren'}),e.addLocale('no',{OK:'OK',CANCEL:'Avbryt',CONFIRM:'OK'}),e.addLocale('pl',{OK:'OK',CANCEL:'Anuluj',CONFIRM:'Potwierdź'}),e.addLocale('pt-BR',{OK:'OK',CANCEL:'Cancelar',CONFIRM:'Sim'}),e.addLocale('pt',{OK:'OK',CANCEL:'Cancelar',CONFIRM:'Confirmar'}),e.addLocale('ru',{OK:'OK',CANCEL:'Отмена',CONFIRM:'Применить'}),e.addLocale('sk',{OK:'OK',CANCEL:'Zrušiť',CONFIRM:'Potvrdiť'}),e.addLocale('sl',{OK:'OK',CANCEL:'Prekliči',CONFIRM:'Potrdi'}),e.addLocale('sq',{OK:'OK',CANCEL:'Anulo',CONFIRM:'Prano'}),e.addLocale('sv',{OK:'OK',CANCEL:'Avbryt',CONFIRM:'OK'}),e.addLocale('sw',{OK:'Sawa',CANCEL:'Ghairi',CONFIRM:'Thibitisha'}),e.addLocale('ta',{OK:'சரி',CANCEL:'ரத்து செய்',CONFIRM:'உறுதி செய்'}),e.addLocale('th',{OK:'ตกลง',CANCEL:'ยกเลิก',CONFIRM:'ยืนยัน'}),e.addLocale('tr',{OK:'Tamam',CANCEL:'İptal',CONFIRM:'Onayla'}),e.addLocale('uk',{OK:'OK',CANCEL:'Відміна',CONFIRM:'Прийняти'}),e.addLocale('vi',{OK:'OK',CANCEL:'Hủy bỏ',CONFIRM:'Xác nhận'}),e.addLocale('zh-CN',{OK:'OK',CANCEL:'取消',CONFIRM:'确认'}),e.addLocale('zh-TW',{OK:'OK',CANCEL:'取消',CONFIRM:'確認'})}); \ No newline at end of file diff --git a/dist/bootbox.js b/dist/bootbox.js index f2de77b9..ee017c5c 100644 --- a/dist/bootbox.js +++ b/dist/bootbox.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ @@ -22,7 +22,7 @@ let exports = {}; - let VERSION = '6.0.0'; + let VERSION = '6.0.1'; exports.VERSION = VERSION; let locales = { diff --git a/dist/bootbox.locales.js b/dist/bootbox.locales.js index 66f6f4be..b4f93479 100644 --- a/dist/bootbox.locales.js +++ b/dist/bootbox.locales.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.locales.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/dist/bootbox.locales.min.js b/dist/bootbox.locales.min.js index ae53c905..fb27e745 100644 --- a/dist/bootbox.locales.min.js +++ b/dist/bootbox.locales.min.js @@ -1,6 +1,6 @@ /** * Bootbox.js — alert, confirm, prompt, and flexible dialogs for the Bootstrap framework - * @version: 6.0.0 + * @version: 6.0.1 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ diff --git a/dist/bootbox.min.js b/dist/bootbox.min.js index 17825c2c..7776b8db 100644 --- a/dist/bootbox.min.js +++ b/dist/bootbox.min.js @@ -1,7 +1,7 @@ /** * Bootbox.js — alert, confirm, prompt, and flexible dialogs for the Bootstrap framework - * @version: 6.0.0 + * @version: 6.0.1 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ -!function(t,e){'use strict';'function'==typeof define&&define.amd?define(['jquery'],e):'object'==typeof exports?module.exports=e(require('jquery')):t.bootbox=e(t.jQuery)}(this,function e(s,c){'use strict';let r={};r.VERSION='6.0.0';let l={en:{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}},p={dialog:'',header:'',footer:'',closeButton:'',form:'
',button:'',option:'',promptMessage:'
',inputs:{text:'',textarea:'',email:'',select:'',checkbox:'
',radio:'
',date:'',time:'',number:'',password:'',range:''}},u={locale:'en',backdrop:'static',animate:!0,className:null,closeButton:!0,show:!0,container:'body',value:'',inputType:'text',errorMessage:null,swapButtonOrder:!1,centerVertical:!1,multiple:!1,scrollable:!1,reusable:!1,relatedTarget:null,size:null,id:null};function i(t,e,o){return s.extend(!0,{},t,function(t,e){var o=t.length;let a={};if(o<1||2').attr('label',e.group)),o=r[e.group]);var a=s(p.option);a.attr('value',e.value).text(e.text),o.append(a)}),f(r,function(t,e){i.append(e)}),i.val(n.value),n.bootstrap<5&&i.removeClass('form-select').addClass('form-control');break;case'checkbox':let e=Array.isArray(n.value)?n.value:[n.value];if(!(l=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "checkbox" requires at least one option');i=s('
'),f(l,function(t,o){if(o.value===c||o.text===c)throw new Error('each option needs a "value" property and a "text" property');let a=s(p.inputs[n.inputType]);a.find('input').attr('value',o.value),a.find('label').append('\n'+o.text),f(e,function(t,e){e===o.value&&a.find('input').prop('checked',!0)}),i.append(a)});break;case'radio':if(n.value!==c&&Array.isArray(n.value))throw new Error('prompt with "inputType" set to "radio" requires a single, non-array value for "value"');if(!(l=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "radio" requires at least one option');i=s('
');let a=!0;f(l,function(t,e){if(e.value===c||e.text===c)throw new Error('each option needs a "value" property and a "text" property');var o=s(p.inputs[n.inputType]);o.find('input').attr('value',e.value),o.find('label').append('\n'+e.text),n.value!==c&&e.value===n.value&&(o.find('input').prop('checked',!0),a=!1),i.append(o)}),a&&i.find('input[type="radio"]').first().prop('checked',!0)}return t.append(i),t.on('submit',function(t){t.preventDefault(),t.stopPropagation(),e.find('.bootbox-accept').trigger('click')}),n.message&&''!==n.message.trim()&&(a=s(p.promptMessage).html(n.message),t.prepend(a)),n.message=t,(e=r.dialog(n)).off('shown.bs.modal',m),e.on('shown.bs.modal',function(){i.focus()}),!0===o&&e.modal('show'),e},r}); \ No newline at end of file +!function(t,e){'use strict';'function'==typeof define&&define.amd?define(['jquery'],e):'object'==typeof exports?module.exports=e(require('jquery')):t.bootbox=e(t.jQuery)}(this,function e(s,c){'use strict';let r={};r.VERSION='6.0.1';let l={en:{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}},p={dialog:'',header:'',footer:'',closeButton:'',form:'
',button:'',option:'',promptMessage:'
',inputs:{text:'',textarea:'',email:'',select:'',checkbox:'
',radio:'
',date:'',time:'',number:'',password:'',range:''}},u={locale:'en',backdrop:'static',animate:!0,className:null,closeButton:!0,show:!0,container:'body',value:'',inputType:'text',errorMessage:null,swapButtonOrder:!1,centerVertical:!1,multiple:!1,scrollable:!1,reusable:!1,relatedTarget:null,size:null,id:null};function i(t,e,o){return s.extend(!0,{},t,function(t,e){var o=t.length;let a={};if(o<1||2').attr('label',e.group)),o=r[e.group]);var a=s(p.option);a.attr('value',e.value).text(e.text),o.append(a)}),f(r,function(t,e){i.append(e)}),i.val(n.value),n.bootstrap<5&&i.removeClass('form-select').addClass('form-control');break;case'checkbox':let e=Array.isArray(n.value)?n.value:[n.value];if(!(l=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "checkbox" requires at least one option');i=s('
'),f(l,function(t,o){if(o.value===c||o.text===c)throw new Error('each option needs a "value" property and a "text" property');let a=s(p.inputs[n.inputType]);a.find('input').attr('value',o.value),a.find('label').append('\n'+o.text),f(e,function(t,e){e===o.value&&a.find('input').prop('checked',!0)}),i.append(a)});break;case'radio':if(n.value!==c&&Array.isArray(n.value))throw new Error('prompt with "inputType" set to "radio" requires a single, non-array value for "value"');if(!(l=n.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "radio" requires at least one option');i=s('
');let a=!0;f(l,function(t,e){if(e.value===c||e.text===c)throw new Error('each option needs a "value" property and a "text" property');var o=s(p.inputs[n.inputType]);o.find('input').attr('value',e.value),o.find('label').append('\n'+e.text),n.value!==c&&e.value===n.value&&(o.find('input').prop('checked',!0),a=!1),i.append(o)}),a&&i.find('input[type="radio"]').first().prop('checked',!0)}return t.append(i),t.on('submit',function(t){t.preventDefault(),t.stopPropagation(),e.find('.bootbox-accept').trigger('click')}),n.message&&''!==n.message.trim()&&(a=s(p.promptMessage).html(n.message),t.prepend(a)),n.message=t,(e=r.dialog(n)).off('shown.bs.modal',m),e.on('shown.bs.modal',function(){i.focus()}),!0===o&&e.modal('show'),e},r}); \ No newline at end of file diff --git a/header.txt b/header.txt index f52f585c..f61b0769 100644 --- a/header.txt +++ b/header.txt @@ -1,6 +1,6 @@ /** * Bootbox.js — alert, confirm, prompt, and flexible dialogs for the Bootstrap framework - * @version: 6.0.0 + * @version: 6.0.1 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ \ No newline at end of file diff --git a/package.json b/package.json index c5cdd81a..1c648412 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootbox", - "version": "6.0.0", + "version": "6.0.1", "description": "Wrappers for JavaScript alert(), confirm(), prompt(), and other flexible dialogs using the Bootstrap framework", "directories": { "test": "tests" diff --git a/templates/umd-header-locales.txt b/templates/umd-header-locales.txt index d664a306..0299482f 100644 --- a/templates/umd-header-locales.txt +++ b/templates/umd-header-locales.txt @@ -1,6 +1,6 @@ /*! @preserve * bootbox.locales.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/templates/umd-header.txt b/templates/umd-header.txt index f0145111..f878209e 100644 --- a/templates/umd-header.txt +++ b/templates/umd-header.txt @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.0 + * version: 6.0.1 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/tests/units.html b/tests/units.html index 77539174..0253317e 100644 --- a/tests/units.html +++ b/tests/units.html @@ -11,13 +11,13 @@

Unit test results, Grouped

Browser: Chrome Headless 128.0.0.0 (Windows 10)
-
Timestamp: 11/7/2024, 6:15:14 PM
+
Timestamp: 11/7/2024, 6:28:22 PM

648 tests / 0 errors / 0 failures / 0 skipped / - runtime: 0.066s + runtime: 0.063s

@@ -56,7 +56,7 @@

basic usage tests » with one argument » where the argument is a string

shows an OK button

-
Passed in 0.002s
+
Passed in 0.001s
@@ -146,7 +146,7 @@

callback tests » with no callback » when dismissing the dialog by clicking OK

should hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -191,7 +191,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking OK

should hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -272,7 +272,7 @@

callback tests » with a callback which returns false » when dismissing the dialog by clicking OK

should not hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -290,7 +290,7 @@

callback tests » with a callback which returns false » when clicking the close button

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -338,7 +338,7 @@

is attached to the window object

-
Passed in 0.001s
+
Passed in 0s
@@ -437,7 +437,7 @@

If $.fn.modal is undefined » When invoking a dialog

throws the correct error

-
Passed in 0s
+
Passed in 0.001s
@@ -593,7 +593,7 @@

basic usage tests » with one argument » where the argument is not an object

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -656,7 +656,7 @@

basic usage tests » with one argument » where the argument is an object » with a message and a callback

adds the correct button classes

-
Passed in 0s
+
Passed in 0.001s
@@ -674,7 +674,7 @@

basic usage tests » with two arguments » where the second argument is a function

does not throw an error

-
Passed in 0.002s
+
Passed in 0.001s
@@ -692,7 +692,7 @@

basic usage tests » with two arguments » where the second argument is a function

applies the bootbox-confirm class to the dialog

-
Passed in 0.001s
+
Passed in 0s
@@ -728,7 +728,7 @@

configuration options tests » with a custom cancel button

adds the correct cancel button

-
Passed in 0s
+
Passed in 0.001s
@@ -773,7 +773,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -827,7 +827,7 @@

callback tests » with a simple callback » when triggering the escape event

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -854,7 +854,7 @@

callback tests » with a simple callback » when triggering the escape event

should hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -917,7 +917,7 @@

callback tests » with a callback which returns false » when dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -1028,7 +1028,7 @@

size » when set to xl

adds the extra-large class to the innerDialog

-
Passed in 0.001s
+
Passed in 0s
@@ -1037,7 +1037,7 @@

size » when set to extra-large

adds the extra-large class to the innerDialog

-
Passed in 0s
+
Passed in 0.001s
@@ -1157,7 +1157,7 @@

invalid usage tests » with no arguments

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -1166,7 +1166,7 @@

invalid usage tests » with one argument » where the argument is not an object

throws an error

-
Passed in 0.002s
+
Passed in 0s
@@ -1175,7 +1175,7 @@

invalid usage tests » with one argument » where the argument has no message property

throws an error

-
Passed in 0.001s
+
Passed in 0s
@@ -1202,7 +1202,7 @@

when creating a minimal dialog

adds the bootstrap modal class to the dialog

-
Passed in 0s
+
Passed in 0.001s
@@ -1247,7 +1247,7 @@

when creating a minimal dialog

does not have a footer

-
Passed in 0s
+
Passed in 0.001s
@@ -1418,7 +1418,7 @@

when creating a dialog with a button » when the button has no explicit label » when its value is an object

adds the custom class to the button

-
Passed in 0.001s
+
Passed in 0s
@@ -1637,7 +1637,7 @@

Invalid locale

shows the default OK translation

-
Passed in 0s
+
Passed in 0.001s
@@ -1718,7 +1718,7 @@

English

shows the correct OK translation

-
Passed in 0s
+
Passed in 0.001s
@@ -1772,7 +1772,7 @@

German

shows the correct OK translation

-
Passed in 0s
+
Passed in 0.001s
@@ -1817,7 +1817,7 @@

Spanish

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -1835,7 +1835,7 @@

Basque

shows the correct CANCEL translation

-
Passed in 0s
+
Passed in 0.001s
@@ -1880,7 +1880,7 @@

Portuguese (Brasil)

shows the correct OK translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2060,7 +2060,7 @@

Danish

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2078,7 +2078,7 @@

Chinese » Taiwan

shows the correct CANCEL translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2132,7 +2132,7 @@

Norwegian

shows the correct CANCEL translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2222,7 +2222,7 @@

Lithuanian

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2528,7 +2528,7 @@

Slovenian

shows the correct OK translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2555,7 +2555,7 @@

Slovak

shows the correct OK translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2573,7 +2573,7 @@

Slovak

shows the correct CONFIRM translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2774,7 +2774,7 @@

basic usage tests » with two arguments » where the second argument is not a function

throws an error requiring a callback

-
Passed in 0.001s
+
Passed in 0s
@@ -2783,7 +2783,7 @@

basic usage tests » with two arguments » where the second argument is a function

does not throw an error

-
Passed in 0.001s
+
Passed in 0.002s
@@ -2819,7 +2819,7 @@

basic usage tests » with two arguments » where the second argument is a function

adds the expected dialog title

-
Passed in 0s
+
Passed in 0.001s
@@ -2873,7 +2873,7 @@

configuration options tests » with `centerVertical` set to `false`

does not add the modal-dialog-centered class to the innerDialog of the prompt

-
Passed in 0.001s
+
Passed in 0s
@@ -2936,7 +2936,7 @@

configuration options tests » setting inputType text » without default value

has proper class

-
Passed in 0.001s
+
Passed in 0s
@@ -2945,7 +2945,7 @@

configuration options tests » setting inputType text » with default value

has correct default value

-
Passed in 0.001s
+
Passed in 0s
@@ -3125,7 +3125,7 @@

configuration options tests » setting inputType select » with options in the wrong format

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -3215,7 +3215,7 @@

configuration options tests » setting inputType select » with option groups

with two option group

-
Passed in 0.001s
+
Passed in 0s
@@ -3233,7 +3233,7 @@

configuration options tests » setting inputType checkbox » without options

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -3395,7 +3395,7 @@

configuration options tests » setting inputType time » with default value

has correct default value

-
Passed in 0.001s
+
Passed in 0s
@@ -3422,7 +3422,7 @@

configuration options tests » setting inputType time » with min value

has correct min value

-
Passed in 0s
+
Passed in 0.001s
@@ -3458,7 +3458,7 @@

configuration options tests » setting inputType time » with an invalid max value

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -3476,7 +3476,7 @@

configuration options tests » setting inputType time » with an invalid step value

throws an error

-
Passed in 0.001s
+
Passed in 0s
@@ -3521,7 +3521,7 @@

configuration options tests » setting inputType number » with min int value

has correct min value

-
Passed in 0.001s
+
Passed in 0s
@@ -3530,7 +3530,7 @@

configuration options tests » setting inputType number » with min decimal value

has correct min value

-
Passed in 0s
+
Passed in 0.001s
@@ -3539,7 +3539,7 @@

configuration options tests » setting inputType number » with max int value

has correct max value

-
Passed in 0s
+
Passed in 0.001s
@@ -3548,7 +3548,7 @@

configuration options tests » setting inputType number » with max decimal value

has correct max value

-
Passed in 0s
+
Passed in 0.001s
@@ -3566,7 +3566,7 @@

configuration options tests » setting inputType number » with step decimal value

has correct step value

-
Passed in 0.001s
+
Passed in 0s
@@ -3593,7 +3593,7 @@

configuration options tests » setting inputType number » with min value greater than max value

throws an error

-
Passed in 0.001s
+
Passed in 0s
@@ -3647,7 +3647,7 @@

configuration options tests » setting inputType range » with min value

has correct min value

-
Passed in 0.001s
+
Passed in 0s
@@ -3665,7 +3665,7 @@

configuration options tests » setting inputType range » with step value

has correct step value

-
Passed in 0s
+
Passed in 0.001s
@@ -3683,7 +3683,7 @@

configuration options tests » setting inputType range » with an invalid max value

throws an error

-
Passed in 0.001s
+
Passed in 0s
@@ -3764,7 +3764,7 @@

callback tests » with a simple callback » when entering no value in the text input » when submitting the form

should hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -3791,7 +3791,7 @@

callback tests » with a simple callback » when entering a value in the text input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -3827,7 +3827,7 @@

callback tests » with a simple callback » when entering a value in the text input » when submitting the form

should hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -3854,7 +3854,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -4007,7 +4007,7 @@

callback tests » with a callback which returns false » when entering a value in the text input » when dismissing the dialog by clicking OK

should not hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -4052,7 +4052,7 @@

callback tests » with a callback which returns false » when triggering the escape event

should invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -4088,7 +4088,7 @@

callback tests » with a callback which returns false » when dismissing the dialog by clicking the close button

should invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -4106,7 +4106,7 @@

callback tests » with a callback which returns false » when dismissing the dialog by clicking the close button

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -4124,7 +4124,7 @@

callback tests » with a default value

populates the input with the default value

-
Passed in 0.001s
+
Passed in 0s
@@ -4151,7 +4151,7 @@

callback tests » with a default value » when entering no value in the text input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -4160,7 +4160,7 @@

callback tests » with a default value » when entering no value in the text input » when dismissing the dialog by clicking Cancel

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -4313,7 +4313,7 @@

callback tests » with required: true and default input type » when entering a value in the text input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -4331,7 +4331,7 @@

callback tests » with required: true and default input type » when entering a value in the text input » when dismissing the dialog by clicking Cancel

should pass the dialog as "this"

-
Passed in 0s
+
Passed in 0.001s
@@ -4565,7 +4565,7 @@

callback tests » with required: true and `number` input type » when entering no value in the text input » when dismissing the dialog by clicking Cancel

should invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -4745,7 +4745,7 @@

callback tests » with required: true and `time` input type

populates the input with the required property

-
Passed in 0s
+
Passed in 0.001s
@@ -4853,7 +4853,7 @@

callback tests » with required: true and `textarea` input type » when entering no value in the text input » when dismissing the dialog by clicking OK

should not invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -4880,7 +4880,7 @@

callback tests » with required: true and `textarea` input type » when entering no value in the text input » when dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -4970,7 +4970,7 @@

callback tests » with inputType select » without a default value » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -5051,7 +5051,7 @@

callback tests » with inputType select » with a default value » when dismissing the dialog by clicking Cancel

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -5087,7 +5087,7 @@

callback tests » with inputType select » with required: true and option selected

specified option is selected

-
Passed in 0s
+
Passed in 0.001s
@@ -5105,7 +5105,7 @@

callback tests » with inputType select » with required: true and option selected » when dismissing the dialog by clicking OK

should pass the dialog as "this"

-
Passed in 0s
+
Passed in 0.001s
@@ -5168,7 +5168,7 @@

callback tests » with inputType select » with required: true and no option selected

no option is selected

-
Passed in 0.001s
+
Passed in 0s
@@ -5195,7 +5195,7 @@

callback tests » with inputType select » with required: true and no option selected » when dismissing the dialog by clicking Cancel

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -5231,7 +5231,7 @@

callback tests » with inputType email » without a default value » when dismissing the dialog by clicking OK

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -5240,7 +5240,7 @@

callback tests » with inputType email » without a default value » when dismissing the dialog by clicking OK

should pass the dialog as "this"

-
Passed in 0s
+
Passed in 0.001s
@@ -5258,7 +5258,7 @@

callback tests » with inputType email » without a default value » when dismissing the dialog by clicking OK

should hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -5384,7 +5384,7 @@

callback tests » with inputType email » with a default value » when changing a value in the email input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -5420,7 +5420,7 @@

callback tests » with inputType email » with required: true and a default value » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -5591,7 +5591,7 @@

callback tests » with input type checkbox » with default value » one value checked

specified checkbox is checked

-
Passed in 0s
+
Passed in 0.001s
@@ -5627,7 +5627,7 @@

callback tests » with input type checkbox » with default value » one value checked » when dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -5726,7 +5726,7 @@

callback tests » with input type checkbox » with default value » multiple value checked » when changing the checked options and dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0.001s
+
Passed in 0s