lib/assets/javascripts/rails-sweetalert2-confirm.js in rails-sweetalert2-confirm-0.9.1 vs lib/assets/javascripts/rails-sweetalert2-confirm.js in rails-sweetalert2-confirm-0.9.2

- old
+ new

@@ -1,30 +1,40 @@ var sweetAlertConfirmDefaults = sweetAlertConfirmDefaults || {}; sweetAlertConfirmDefaults.sweetSelector = sweetAlertConfirmDefaults.sweetSelector || '[data-swal]'; var sweetAlertConfirm = function(event) { + debugger; var $linkToConfirm = $(this); var swalOptions = { - animation: sweetAlertConfirmDefaults.animation || true, - allowOutsideClick: sweetAlertConfirmDefaults.allowOutsideClick || true, - allowEscapeKey: sweetAlertConfirmDefaults.allowEscapeKey || true, - showConfirmButton: sweetAlertConfirmDefaults.showConfirmButton || true, - showCancelButton: sweetAlertConfirmDefaults.showCancelButton || true, confirmButtonText: sweetAlertConfirmDefaults.confirmButtonText || "OK", cancelButtonText: sweetAlertConfirmDefaults.cancelButtonText || "Cancel", confirmButtonColor: sweetAlertConfirmDefaults.confirmButtonColor || "#3085d6", cancelButtonColor: sweetAlertConfirmDefaults.cancelButtonColor || "#aaa", - buttonsStyling: sweetAlertConfirmDefaults.buttonsStyling || true, - reverseButtons: sweetAlertConfirmDefaults.reverseButtons || false, - showCloseButton: sweetAlertConfirmDefaults.showCloseButton || false, - showLoaderOnConfirm: sweetAlertConfirmDefaults.showLoaderOnConfirm || false, - preConfirm: sweetAlertConfirmDefaults.preConfirm || false, width: sweetAlertConfirmDefaults.width || 500, padding: sweetAlertConfirmDefaults.padding || 20, - background: sweetAlertConfirmDefaults.background || '#fff', - inputAutoTrim: sweetAlertConfirmDefaults.inputAutoTrim || true, + background: sweetAlertConfirmDefaults.background || '#fff' }; + + var truthyOptions = [ + 'animation', + 'allowOutsideClick', + 'allowEscapeKey', + 'showConfirmButton', + 'showCancelButton', + 'buttonsStyling', + 'reverseButtons', + 'showCloseButton', + 'showLoaderOnConfirm', + 'preConfirm', + 'inputAutoTrim' + ] + + $.each(truthyOptions, function(index, option) { + if(sweetAlertConfirmDefaults[option] != undefined) { + swalOptions[option] = sweetAlertConfirmDefaults[option] + }; + }); var canBeNullOptions = [ 'title', 'text', 'html',