Skip to content

Commit

Permalink
Merge pull request #27 from hfingler/patch-2
Browse files Browse the repository at this point in the history
Adding option to hide the confirm button
  • Loading branch information
lipis committed Jun 18, 2015
2 parents d28725d + 9f692c8 commit 59a28b6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/sweet-alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
type: null,
allowOutsideClick: false,
showCancelButton: false,
showConfirmButton: true,
closeOnConfirm: true,
closeOnCancel: true,
confirmButtonText: 'OK',
Expand Down Expand Up @@ -230,6 +231,7 @@
params.type = arguments[0].type || defaultParams.type;
params.allowOutsideClick = arguments[0].allowOutsideClick || defaultParams.allowOutsideClick;
params.showCancelButton = arguments[0].showCancelButton !== undefined ? arguments[0].showCancelButton : defaultParams.showCancelButton;
params.showConfirmButton = arguments[0].showConfirmButton !== undefined ? arguments[0].showConfirmButton : defaultParams.showConfirmButton;
params.closeOnConfirm = arguments[0].closeOnConfirm !== undefined ? arguments[0].closeOnConfirm : defaultParams.closeOnConfirm;
params.closeOnCancel = arguments[0].closeOnCancel !== undefined ? arguments[0].closeOnCancel : defaultParams.closeOnCancel;
params.timer = arguments[0].timer || defaultParams.timer;
Expand Down Expand Up @@ -549,6 +551,15 @@
} else {
hide($cancelBtn);
}

//Confirm button
modal.setAttribute('data-has-confirm-button', params.showConfirmButton);
if (params.showConfirmButton) {
$confirmBtn.style.display = 'inline-block';
} else {
hide($confirmBtn);
}


// Edit text on cancel and confirm buttons
if (params.cancelButtonText) {
Expand All @@ -559,7 +570,7 @@
}

// Reset confirm buttons to default class (Ugly fix)
$confirmBtn.className = 'confirm btn btn-lg'
$confirmBtn.className = 'confirm btn btn-lg';

// Attach selected class to the sweet alert modal
addClass(modal, params.containerClass);
Expand Down

0 comments on commit 59a28b6

Please sign in to comment.