diff --git a/CHANGELOG.md b/CHANGELOG.md index ae04f02f..c5fbb516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -## 6.0.3 (Latest Release) +## 6.0.4 (Latest Release) + +- Updates `step` to allow setting value for date inputs + +### 6.0.3 -Updates `min` and `max` validation for the `number` input type to allow min and max to be equal diff --git a/README.md b/README.md index ccabaad6..e19464d8 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ 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.3 (Latest Release) +## 6.0.4 (Latest Release) -- Updates `min` and `max` validation for the `number` input type to allow min and max to be equal +- Updates `step` to allow setting value for date inputs For a full list of releases and changes please see [the changelog](https://github.com/bootboxjs/bootbox/blob/master/CHANGELOG.md). diff --git a/bootbox.js b/bootbox.js index 8dca279f..062610f2 100644 --- a/bootbox.js +++ b/bootbox.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ @@ -22,7 +22,7 @@ let exports = {}; - let VERSION = '6.0.3'; + let VERSION = '6.0.4'; exports.VERSION = VERSION; let locales = { @@ -93,7 +93,7 @@ relatedTarget: null, // The size of the modal to generate size: null, - // A unique indentifier for this modal + // A unique identifier for this modal id: null }; @@ -214,7 +214,7 @@ exports.dialog = function (options) { if ($.fn.modal === undefined) { throw new Error( - '"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.1/getting-started/introduction/ for more details.' + '"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.3/getting-started/introduction/ for more details.' ); } @@ -696,17 +696,12 @@ input.prop({ 'required': true }); } - // These input types have extra attributes which affect their input validation. - // Warning: For most browsers, date inputs are buggy in their implementation of 'step', so this attribute will have no effect. Therefore, we don't set the attribute for date inputs. - // @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Setting_maximum_and_minimum_dates - if (options.inputType !== 'date') { - if (options.step) { - if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) { - input.attr('step', options.step); - } - else { - throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); - } + if (options.step) { + if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) { + input.attr('step', options.step); + } + else { + throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); } } @@ -883,7 +878,7 @@ // ...and replace it with one focusing our input, if possible promptDialog.on('shown.bs.modal', function () { - // Need the closure here since input isn'tcan object otherwise + // Need the closure here since input isn't an object otherwise input.focus(); }); diff --git a/dist/bootbox.all.js b/dist/bootbox.all.js index 58642abf..c691c7c7 100644 --- a/dist/bootbox.all.js +++ b/dist/bootbox.all.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ @@ -22,7 +22,7 @@ let exports = {}; - let VERSION = '6.0.3'; + let VERSION = '6.0.4'; exports.VERSION = VERSION; let locales = { @@ -93,7 +93,7 @@ relatedTarget: null, // The size of the modal to generate size: null, - // A unique indentifier for this modal + // A unique identifier for this modal id: null }; @@ -213,7 +213,7 @@ exports.dialog = function(options) { if ($.fn.modal === undefined) { throw new Error( - '"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.1/getting-started/introduction/ for more details.' + '"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.3/getting-started/introduction/ for more details.' ); } @@ -702,16 +702,11 @@ }); } - // These input types have extra attributes which affect their input validation. - // Warning: For most browsers, date inputs are buggy in their implementation of 'step', so this attribute will have no effect. Therefore, we don't set the attribute for date inputs. - // @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Setting_maximum_and_minimum_dates - if (options.inputType !== 'date') { - if (options.step) { - if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) { - input.attr('step', options.step); - } else { - throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); - } + if (options.step) { + if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) { + input.attr('step', options.step); + } else { + throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); } } @@ -891,7 +886,7 @@ // ...and replace it with one focusing our input, if possible promptDialog.on('shown.bs.modal', function() { - // Need the closure here since input isn'tcan object otherwise + // Need the closure here since input isn't an object otherwise input.focus(); }); @@ -1209,7 +1204,7 @@ /*! @preserve * bootbox.locales.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/dist/bootbox.all.min.js b/dist/bootbox.all.min.js index 7cd340f3..10b38270 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.3 + * @version: 6.0.4 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ -((e,t)=>{'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){let r={};r.VERSION='6.0.3';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:''}},p={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,((e,t)=>{var o=e.length;let a={};if(o<1||2{var r={};for(let e=0,t=o.length;e((t=i[t])||i.en)[e])(n,a)}}return r})(t=r&&r[0]&&(o=r[0].locale||p.locale,r[0].swapButtonOrder||p.swapButtonOrder)?t.reverse():t,o)};{e=l(e,r,a);var n=t;let o={};return f(n,function(e,t){o[t]=!0}),f(e.buttons,function(e){if(o[e]===c)throw new Error('button key "'+e+'" is not allowed (options are '+n.join(' ')+')')}),e}}function b(e){return Object.keys(e).length}function f(e,o){let a=0;s.each(e,function(e,t){o(e,t,a++)})}function m(e){e.data.dialog.find('.bootbox-accept').first().trigger('focus')}function h(e){e.target===e.data.dialog[0]&&e.data.dialog.remove()}function C(e){e.target===e.data.dialog[0]&&(e.data.dialog.off('escape.close.bb'),e.data.dialog.off('click'))}function O(e,t,o){e.stopPropagation(),e.preventDefault(),'function'==typeof o&&!1===o.call(t,e)||t.modal('hide')}function w(e){return/([01][0-9]|2[0-3]):[0-5][0-9]?:[0-5][0-9]/.test(e)}function g(e){return/(\d{4})-(\d{2})-(\d{2})/.test(e)}return r.locales=function(e){return e?i[e]:i},r.addLocale=function(e,o){return s.each(['OK','CANCEL','CONFIRM'],function(e,t){if(!o[t])throw new Error('Please supply a translation for "'+t+'"')}),i[e]={OK:o.OK,CANCEL:o.CANCEL,CONFIRM:o.CONFIRM},r},r.removeLocale=function(e){if('en'===e)throw new Error('"en" is used as the default and fallback locale and cannot be removed.');return delete i[e],r},r.setLocale=function(e){return r.setDefaults('locale',e)},r.setDefaults=function(){let e={};return 2===arguments.length?e[arguments[0]]=arguments[1]:e=arguments[0],s.extend(p,e),r},r.hideAll=function(){return s('.bootbox').modal('hide'),r},r.init=function(e){return t(e||s)},r.dialog=function(e){if(s.fn.modal===c)throw new Error('"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.1/getting-started/introduction/ for more details.');e=(a=>{let r,n;if('object'!=typeof a)throw new Error('Please supply an object of options');if(a.message)return(a=s.extend({},p,a)).backdrop?a.backdrop='string'!=typeof a.backdrop||'static'!==a.backdrop.toLowerCase()||'static':a.backdrop=!1!==a.backdrop&&0!==a.backdrop&&'static',a.buttons||(a.buttons={}),r=a.buttons,n=b(r),f(r,function(e,t,o){if('object'!=typeof(t='function'==typeof t?r[e]={callback:t}:t))throw new Error('button with key "'+e+'" must be an object');if(t.label||(t.label=e),!t.className){let e=!1;e=a.swapButtonOrder?0===o:o===n-1,n<=2&&e?t.className='btn-primary':t.className='btn-secondary btn-default'}}),a;throw new Error('"message" option must not be null or an empty string.')})(e),s.fn.modal.Constructor.VERSION?(e.fullBootstrapVersion=s.fn.modal.Constructor.VERSION,a=e.fullBootstrapVersion.indexOf('.'),e.bootstrap=e.fullBootstrapVersion.substring(0,a)):(e.bootstrap='2',e.fullBootstrapVersion='2.3.2',console.warn('Bootbox will *mostly* work with Bootstrap 2, but we do not officially support it. Please upgrade, if possible.'));let o=s(d.dialog);var t=o.find('.modal-dialog'),a=o.find('.modal-body'),r=s(d.header);let n=s(d.footer);var l=e.buttons;let i={onEscape:e.onEscape};if(a.find('.bootbox-body').html(e.message),0{let a=!1,r=!0,n=!0;if('date'===e)t===c||(r=g(t))?o===c||(n=g(o))||console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your max value may not be enforced by this browser.'):console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your min value may not be enforced by this browser.');else if('time'===e){if(t!==c&&!(r=w(t)))throw new Error('"min" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.');if(o!==c&&!(n=w(o)))throw new Error('"max" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.')}else{if(t!==c&&isNaN(t))throw r=!1,new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');if(o!==c&&isNaN(o))throw n=!1,new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.')}if(r&&n){if(o').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}),((e,t)=>{'function'==typeof define&&define.amd?define(['bootbox'],t):'object'==typeof module&&module.exports?t(require('./bootbox')):t(e.bootbox)})(this,function(e){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:'OK'}),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 +((e,t)=>{'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){let r={};r.VERSION='6.0.4';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:''}},p={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,((e,t)=>{var o=e.length;let a={};if(o<1||2{var r={};for(let e=0,t=o.length;e((t=i[t])||i.en)[e])(n,a)}}return r})(t=r&&r[0]&&(o=r[0].locale||p.locale,r[0].swapButtonOrder||p.swapButtonOrder)?t.reverse():t,o)};{e=l(e,r,a);var n=t;let o={};return f(n,function(e,t){o[t]=!0}),f(e.buttons,function(e){if(o[e]===c)throw new Error('button key "'+e+'" is not allowed (options are '+n.join(' ')+')')}),e}}function b(e){return Object.keys(e).length}function f(e,o){let a=0;s.each(e,function(e,t){o(e,t,a++)})}function m(e){e.data.dialog.find('.bootbox-accept').first().trigger('focus')}function h(e){e.target===e.data.dialog[0]&&e.data.dialog.remove()}function C(e){e.target===e.data.dialog[0]&&(e.data.dialog.off('escape.close.bb'),e.data.dialog.off('click'))}function O(e,t,o){e.stopPropagation(),e.preventDefault(),'function'==typeof o&&!1===o.call(t,e)||t.modal('hide')}function w(e){return/([01][0-9]|2[0-3]):[0-5][0-9]?:[0-5][0-9]/.test(e)}function g(e){return/(\d{4})-(\d{2})-(\d{2})/.test(e)}return r.locales=function(e){return e?i[e]:i},r.addLocale=function(e,o){return s.each(['OK','CANCEL','CONFIRM'],function(e,t){if(!o[t])throw new Error('Please supply a translation for "'+t+'"')}),i[e]={OK:o.OK,CANCEL:o.CANCEL,CONFIRM:o.CONFIRM},r},r.removeLocale=function(e){if('en'===e)throw new Error('"en" is used as the default and fallback locale and cannot be removed.');return delete i[e],r},r.setLocale=function(e){return r.setDefaults('locale',e)},r.setDefaults=function(){let e={};return 2===arguments.length?e[arguments[0]]=arguments[1]:e=arguments[0],s.extend(p,e),r},r.hideAll=function(){return s('.bootbox').modal('hide'),r},r.init=function(e){return t(e||s)},r.dialog=function(e){if(s.fn.modal===c)throw new Error('"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.3/getting-started/introduction/ for more details.');e=(a=>{let r,n;if('object'!=typeof a)throw new Error('Please supply an object of options');if(a.message)return(a=s.extend({},p,a)).backdrop?a.backdrop='string'!=typeof a.backdrop||'static'!==a.backdrop.toLowerCase()||'static':a.backdrop=!1!==a.backdrop&&0!==a.backdrop&&'static',a.buttons||(a.buttons={}),r=a.buttons,n=b(r),f(r,function(e,t,o){if('object'!=typeof(t='function'==typeof t?r[e]={callback:t}:t))throw new Error('button with key "'+e+'" must be an object');if(t.label||(t.label=e),!t.className){let e=!1;e=a.swapButtonOrder?0===o:o===n-1,n<=2&&e?t.className='btn-primary':t.className='btn-secondary btn-default'}}),a;throw new Error('"message" option must not be null or an empty string.')})(e),s.fn.modal.Constructor.VERSION?(e.fullBootstrapVersion=s.fn.modal.Constructor.VERSION,a=e.fullBootstrapVersion.indexOf('.'),e.bootstrap=e.fullBootstrapVersion.substring(0,a)):(e.bootstrap='2',e.fullBootstrapVersion='2.3.2',console.warn('Bootbox will *mostly* work with Bootstrap 2, but we do not officially support it. Please upgrade, if possible.'));let o=s(d.dialog);var t=o.find('.modal-dialog'),a=o.find('.modal-body'),r=s(d.header);let n=s(d.footer);var l=e.buttons;let i={onEscape:e.onEscape};if(a.find('.bootbox-body').html(e.message),0{let a=!1,r=!0,n=!0;if('date'===e)t===c||(r=g(t))?o===c||(n=g(o))||console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your max value may not be enforced by this browser.'):console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your min value may not be enforced by this browser.');else if('time'===e){if(t!==c&&!(r=w(t)))throw new Error('"min" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.');if(o!==c&&!(n=w(o)))throw new Error('"max" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.')}else{if(t!==c&&isNaN(t))throw r=!1,new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');if(o!==c&&isNaN(o))throw n=!1,new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.')}if(r&&n){if(o').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}),((e,t)=>{'function'==typeof define&&define.amd?define(['bootbox'],t):'object'==typeof module&&module.exports?t(require('./bootbox')):t(e.bootbox)})(this,function(e){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:'OK'}),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 8dca279f..062610f2 100644 --- a/dist/bootbox.js +++ b/dist/bootbox.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ @@ -22,7 +22,7 @@ let exports = {}; - let VERSION = '6.0.3'; + let VERSION = '6.0.4'; exports.VERSION = VERSION; let locales = { @@ -93,7 +93,7 @@ relatedTarget: null, // The size of the modal to generate size: null, - // A unique indentifier for this modal + // A unique identifier for this modal id: null }; @@ -214,7 +214,7 @@ exports.dialog = function (options) { if ($.fn.modal === undefined) { throw new Error( - '"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.1/getting-started/introduction/ for more details.' + '"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.3/getting-started/introduction/ for more details.' ); } @@ -696,17 +696,12 @@ input.prop({ 'required': true }); } - // These input types have extra attributes which affect their input validation. - // Warning: For most browsers, date inputs are buggy in their implementation of 'step', so this attribute will have no effect. Therefore, we don't set the attribute for date inputs. - // @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Setting_maximum_and_minimum_dates - if (options.inputType !== 'date') { - if (options.step) { - if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) { - input.attr('step', options.step); - } - else { - throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); - } + if (options.step) { + if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) { + input.attr('step', options.step); + } + else { + throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); } } @@ -883,7 +878,7 @@ // ...and replace it with one focusing our input, if possible promptDialog.on('shown.bs.modal', function () { - // Need the closure here since input isn'tcan object otherwise + // Need the closure here since input isn't an object otherwise input.focus(); }); diff --git a/dist/bootbox.locales.js b/dist/bootbox.locales.js index b8c69bf6..a6b5ca07 100644 --- a/dist/bootbox.locales.js +++ b/dist/bootbox.locales.js @@ -1,6 +1,6 @@ /*! @preserve * bootbox.locales.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/dist/bootbox.locales.min.js b/dist/bootbox.locales.min.js index 9407a397..f154139f 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.3 + * @version: 6.0.4 * @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 dd9fc181..b62cdec8 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.3 + * @version: 6.0.4 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ -((t,e)=>{'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,p){let r={};r.VERSION='6.0.3';let l={en:{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}},c={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,((t,e)=>{var o=t.length;let a={};if(o<1||2{var r={};for(let t=0,e=o.length;t((e=l[e])||l.en)[t])(n,a)}}return r})(e=r&&r[0]&&(o=r[0].locale||u.locale,r[0].swapButtonOrder||u.swapButtonOrder)?e.reverse():e,o)};{t=i(t,r,a);var n=e;let o={};return f(n,function(t,e){o[e]=!0}),f(t.buttons,function(t){if(o[t]===p)throw new Error('button key "'+t+'" is not allowed (options are '+n.join(' ')+')')}),t}}function b(t){return Object.keys(t).length}function f(t,o){let a=0;s.each(t,function(t,e){o(t,e,a++)})}function m(t){t.data.dialog.find('.bootbox-accept').first().trigger('focus')}function h(t){t.target===t.data.dialog[0]&&t.data.dialog.remove()}function w(t){t.target===t.data.dialog[0]&&(t.data.dialog.off('escape.close.bb'),t.data.dialog.off('click'))}function g(t,e,o){t.stopPropagation(),t.preventDefault(),'function'==typeof o&&!1===o.call(e,t)||e.modal('hide')}function y(t){return/([01][0-9]|2[0-3]):[0-5][0-9]?:[0-5][0-9]/.test(t)}function v(t){return/(\d{4})-(\d{2})-(\d{2})/.test(t)}return r.locales=function(t){return t?l[t]:l},r.addLocale=function(t,o){return s.each(['OK','CANCEL','CONFIRM'],function(t,e){if(!o[e])throw new Error('Please supply a translation for "'+e+'"')}),l[t]={OK:o.OK,CANCEL:o.CANCEL,CONFIRM:o.CONFIRM},r},r.removeLocale=function(t){if('en'===t)throw new Error('"en" is used as the default and fallback locale and cannot be removed.');return delete l[t],r},r.setLocale=function(t){return r.setDefaults('locale',t)},r.setDefaults=function(){let t={};return 2===arguments.length?t[arguments[0]]=arguments[1]:t=arguments[0],s.extend(u,t),r},r.hideAll=function(){return s('.bootbox').modal('hide'),r},r.init=function(t){return e(t||s)},r.dialog=function(t){if(s.fn.modal===p)throw new Error('"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.1/getting-started/introduction/ for more details.');t=(a=>{let r,n;if('object'!=typeof a)throw new Error('Please supply an object of options');if(a.message)return(a=s.extend({},u,a)).backdrop?a.backdrop='string'!=typeof a.backdrop||'static'!==a.backdrop.toLowerCase()||'static':a.backdrop=!1!==a.backdrop&&0!==a.backdrop&&'static',a.buttons||(a.buttons={}),r=a.buttons,n=b(r),f(r,function(t,e,o){if('object'!=typeof(e='function'==typeof e?r[t]={callback:e}:e))throw new Error('button with key "'+t+'" must be an object');if(e.label||(e.label=t),!e.className){let t=!1;t=a.swapButtonOrder?0===o:o===n-1,n<=2&&t?e.className='btn-primary':e.className='btn-secondary btn-default'}}),a;throw new Error('"message" option must not be null or an empty string.')})(t),s.fn.modal.Constructor.VERSION?(t.fullBootstrapVersion=s.fn.modal.Constructor.VERSION,a=t.fullBootstrapVersion.indexOf('.'),t.bootstrap=t.fullBootstrapVersion.substring(0,a)):(t.bootstrap='2',t.fullBootstrapVersion='2.3.2',console.warn('Bootbox will *mostly* work with Bootstrap 2, but we do not officially support it. Please upgrade, if possible.'));let o=s(c.dialog);var e=o.find('.modal-dialog'),a=o.find('.modal-body'),r=s(c.header);let n=s(c.footer);var i=t.buttons;let l={onEscape:t.onEscape};if(a.find('.bootbox-body').html(t.message),0{let a=!1,r=!0,n=!0;if('date'===t)e===p||(r=v(e))?o===p||(n=v(o))||console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your max value may not be enforced by this browser.'):console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your min value may not be enforced by this browser.');else if('time'===t){if(e!==p&&!(r=y(e)))throw new Error('"min" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.');if(o!==p&&!(n=y(o)))throw new Error('"max" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.')}else{if(e!==p&&isNaN(e))throw r=!1,new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');if(o!==p&&isNaN(o))throw n=!1,new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.')}if(r&&n){if(o').attr('label',e.group)),o=r[e.group]);var a=s(c.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===p||o.text===p)throw new Error('each option needs a "value" property and a "text" property');let a=s(c.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!==p&&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===p||e.text===p)throw new Error('each option needs a "value" property and a "text" property');var o=s(c.inputs[n.inputType]);o.find('input').attr('value',e.value),o.find('label').append('\n'+e.text),n.value!==p&&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(c.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 +((t,e)=>{'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,p){let r={};r.VERSION='6.0.4';let l={en:{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}},c={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,((t,e)=>{var o=t.length;let a={};if(o<1||2{var r={};for(let t=0,e=o.length;t((e=l[e])||l.en)[t])(n,a)}}return r})(e=r&&r[0]&&(o=r[0].locale||u.locale,r[0].swapButtonOrder||u.swapButtonOrder)?e.reverse():e,o)};{t=i(t,r,a);var n=e;let o={};return f(n,function(t,e){o[e]=!0}),f(t.buttons,function(t){if(o[t]===p)throw new Error('button key "'+t+'" is not allowed (options are '+n.join(' ')+')')}),t}}function b(t){return Object.keys(t).length}function f(t,o){let a=0;s.each(t,function(t,e){o(t,e,a++)})}function m(t){t.data.dialog.find('.bootbox-accept').first().trigger('focus')}function h(t){t.target===t.data.dialog[0]&&t.data.dialog.remove()}function w(t){t.target===t.data.dialog[0]&&(t.data.dialog.off('escape.close.bb'),t.data.dialog.off('click'))}function g(t,e,o){t.stopPropagation(),t.preventDefault(),'function'==typeof o&&!1===o.call(e,t)||e.modal('hide')}function y(t){return/([01][0-9]|2[0-3]):[0-5][0-9]?:[0-5][0-9]/.test(t)}function v(t){return/(\d{4})-(\d{2})-(\d{2})/.test(t)}return r.locales=function(t){return t?l[t]:l},r.addLocale=function(t,o){return s.each(['OK','CANCEL','CONFIRM'],function(t,e){if(!o[e])throw new Error('Please supply a translation for "'+e+'"')}),l[t]={OK:o.OK,CANCEL:o.CANCEL,CONFIRM:o.CONFIRM},r},r.removeLocale=function(t){if('en'===t)throw new Error('"en" is used as the default and fallback locale and cannot be removed.');return delete l[t],r},r.setLocale=function(t){return r.setDefaults('locale',t)},r.setDefaults=function(){let t={};return 2===arguments.length?t[arguments[0]]=arguments[1]:t=arguments[0],s.extend(u,t),r},r.hideAll=function(){return s('.bootbox').modal('hide'),r},r.init=function(t){return e(t||s)},r.dialog=function(t){if(s.fn.modal===p)throw new Error('"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/5.3/getting-started/introduction/ for more details.');t=(a=>{let r,n;if('object'!=typeof a)throw new Error('Please supply an object of options');if(a.message)return(a=s.extend({},u,a)).backdrop?a.backdrop='string'!=typeof a.backdrop||'static'!==a.backdrop.toLowerCase()||'static':a.backdrop=!1!==a.backdrop&&0!==a.backdrop&&'static',a.buttons||(a.buttons={}),r=a.buttons,n=b(r),f(r,function(t,e,o){if('object'!=typeof(e='function'==typeof e?r[t]={callback:e}:e))throw new Error('button with key "'+t+'" must be an object');if(e.label||(e.label=t),!e.className){let t=!1;t=a.swapButtonOrder?0===o:o===n-1,n<=2&&t?e.className='btn-primary':e.className='btn-secondary btn-default'}}),a;throw new Error('"message" option must not be null or an empty string.')})(t),s.fn.modal.Constructor.VERSION?(t.fullBootstrapVersion=s.fn.modal.Constructor.VERSION,a=t.fullBootstrapVersion.indexOf('.'),t.bootstrap=t.fullBootstrapVersion.substring(0,a)):(t.bootstrap='2',t.fullBootstrapVersion='2.3.2',console.warn('Bootbox will *mostly* work with Bootstrap 2, but we do not officially support it. Please upgrade, if possible.'));let o=s(c.dialog);var e=o.find('.modal-dialog'),a=o.find('.modal-body'),r=s(c.header);let n=s(c.footer);var i=t.buttons;let l={onEscape:t.onEscape};if(a.find('.bootbox-body').html(t.message),0{let a=!1,r=!0,n=!0;if('date'===t)e===p||(r=v(e))?o===p||(n=v(o))||console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your max value may not be enforced by this browser.'):console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your min value may not be enforced by this browser.');else if('time'===t){if(e!==p&&!(r=y(e)))throw new Error('"min" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.');if(o!==p&&!(n=y(o)))throw new Error('"max" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.')}else{if(e!==p&&isNaN(e))throw r=!1,new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');if(o!==p&&isNaN(o))throw n=!1,new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.')}if(r&&n){if(o').attr('label',e.group)),o=r[e.group]);var a=s(c.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===p||o.text===p)throw new Error('each option needs a "value" property and a "text" property');let a=s(c.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!==p&&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===p||e.text===p)throw new Error('each option needs a "value" property and a "text" property');var o=s(c.inputs[n.inputType]);o.find('input').attr('value',e.value),o.find('label').append('\n'+e.text),n.value!==p&&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(c.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 495f991b..67e638c1 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.3 + * @version: 6.0.4 * @project: https://github.com/bootboxjs/bootbox * @license: MIT http://bootboxjs.com/license.txt */ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 58436a4e..c4a4e497 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bootbox", - "version": "6.0.1", + "version": "6.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bootbox", - "version": "6.0.1", + "version": "6.0.4", "license": "MIT", "devDependencies": { "@popperjs/core": "^2.11.8", diff --git a/package.json b/package.json index 660911b6..b98f2925 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootbox", - "version": "6.0.3", + "version": "6.0.4", "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 9da9b31d..fe3e0a36 100644 --- a/templates/umd-header-locales.txt +++ b/templates/umd-header-locales.txt @@ -1,6 +1,6 @@ /*! @preserve * bootbox.locales.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/templates/umd-header.txt b/templates/umd-header.txt index e207b5bd..6ab8417c 100644 --- a/templates/umd-header.txt +++ b/templates/umd-header.txt @@ -1,6 +1,6 @@ /*! @preserve * bootbox.js - * version: 6.0.3 + * version: 6.0.4 * author: Nick Payne * license: MIT * http://bootboxjs.com/ diff --git a/tests/prompt.test.js b/tests/prompt.test.js index d5dc4a45..472071f9 100644 --- a/tests/prompt.test.js +++ b/tests/prompt.test.js @@ -810,6 +810,41 @@ describe('bootbox.prompt', function () { return expect(this.find('input[type="date"]').attr('pattern')).to.equal('\d{1,2}/\d{1,2}/\d{4}'); }); }); + describe('with min value', function () { + beforeEach(function () { + this.options.min = '2015-08-17';// This must be an ISO-8601 date + return this.create(); + }); + return it('has correct min value', function () { + return expect(this.find('input[type="date"]').attr('min')).to.equal('2015-08-17'); + }); + }); + describe('with max value', function () { + beforeEach(function () { + this.options.max = '2015-08-17';// This must be an ISO-8601 date + return this.create(); + }); + return it('has correct max value', function () { + return expect(this.find('input[type="date"]').attr('max')).to.equal('2015-08-17'); + }); + }); + describe('with step value', function () { + beforeEach(function () { + this.options.step = 7;// This must be a number + return this.create(); + }); + return it('has correct step value', function () { + return expect(this.find('input[type="date"]').attr('step')).to.equal('7'); + }); + }); + describe('with an invalid step value', function () { + beforeEach(function () { + this.options.step = 'a'; + }); + return it('throws an error', function () { + return expect(this.create).to.throw('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); + }); + }); }); // time