Skip to content

Commit

Permalink
Merge branch 'master' into canary
Browse files Browse the repository at this point in the history
  • Loading branch information
zenflow committed Jan 23, 2018
2 parents 6a4f65b + 234cbf2 commit 1dc3353
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 285 deletions.
Binary file removed assets/swal2-error.png
Binary file not shown.
Binary file removed assets/swal2-info.png
Binary file not shown.
Binary file removed assets/swal2-question.png
Binary file not shown.
Binary file removed assets/swal2-success.png
Binary file not shown.
Binary file removed assets/swal2-warning.png
Binary file not shown.
95 changes: 25 additions & 70 deletions dist/sweetalert2.all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sweetalert2.all.min.js

Large diffs are not rendered by default.

93 changes: 24 additions & 69 deletions dist/sweetalert2.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* sweetalert2 v7.6.2
* sweetalert2 v7.6.3
* Released under the MIT License.
*/
'use strict';
Expand All @@ -23,11 +23,11 @@ var defaultParams = {
preConfirm: null,
confirmButtonText: 'OK',
confirmButtonAriaLabel: '',
confirmButtonColor: '#3085d6',
confirmButtonColor: null,
confirmButtonClass: null,
cancelButtonText: 'Cancel',
cancelButtonAriaLabel: '',
cancelButtonColor: '#aaa',
cancelButtonColor: null,
cancelButtonClass: null,
buttonsStyling: true,
reverseButtons: false,
Expand All @@ -44,7 +44,7 @@ var defaultParams = {
timer: null,
width: null,
padding: null,
background: '#fff',
background: null,
input: null,
inputPlaceholder: '',
inputValue: '',
Expand Down Expand Up @@ -83,28 +83,6 @@ var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);

var consolePrefix = 'SweetAlert2:';

/*
* Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
*/
var colorLuminance = function colorLuminance(hex, lum) {
// Validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
lum = lum || 0;

// Convert to decimal and change luminosity
var rgb = '#';
for (var i = 0; i < 3; i++) {
var c = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
rgb += ('00' + c).substr(c.length);
}

return rgb;
};

/**
* Filter the unique values into a new array
* @param arr
Expand Down Expand Up @@ -571,10 +549,14 @@ var setParameters = function setParameters(params) {
popup.style.padding = typeof params.padding === 'number' ? params.padding + 'px' : params.padding;
}

popup.style.background = params.background;
// Set popup background
if (params.background) {
popup.style.background = params.background;
}
var popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
var successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
for (var i = 0; i < successIconParts.length; i++) {
successIconParts[i].style.background = params.background;
successIconParts[i].style.backgroundColor = popupBackgroundColor;
}

var container = getContainer();
Expand Down Expand Up @@ -776,12 +758,6 @@ var setParameters = function setParameters(params) {
confirmButton.setAttribute('aria-label', params.confirmButtonAriaLabel);
cancelButton.setAttribute('aria-label', params.cancelButtonAriaLabel);

// Set buttons to selected background colors
if (params.buttonsStyling) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
cancelButton.style.backgroundColor = params.cancelButtonColor;
}

// Add buttons custom classes
confirmButton.className = swalClasses.confirm;
addClass(confirmButton, params.confirmButtonClass);
Expand All @@ -791,6 +767,19 @@ var setParameters = function setParameters(params) {
// Buttons styling
if (params.buttonsStyling) {
addClass([confirmButton, cancelButton], swalClasses.styled);

// Buttons background colors
if (params.confirmButtonColor) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
}
if (params.cancelButtonColor) {
cancelButton.style.backgroundColor = params.cancelButtonColor;
}

// Loading state
var confirmButtonBackgroundColor = window.getComputedStyle(confirmButton).getPropertyValue('background-color');
confirmButton.style.borderLeftColor = confirmButtonBackgroundColor;
confirmButton.style.borderRightColor = confirmButtonBackgroundColor;
} else {
removeClass([confirmButton, cancelButton], swalClasses.styled);

Expand Down Expand Up @@ -1094,34 +1083,6 @@ var sweetAlert = function sweetAlert() {
var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));

switch (e.type) {
case 'mouseover':
case 'mouseup':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
}
}
break;
case 'mouseout':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
} else if (targetedCancel) {
cancelButton.style.backgroundColor = params.cancelButtonColor;
}
}
break;
case 'mousedown':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
}
}
break;
case 'click':
// Clicked 'confirm'
if (targetedConfirm && sweetAlert.isVisible()) {
Expand Down Expand Up @@ -1343,12 +1304,6 @@ var sweetAlert = function sweetAlert() {
window.onkeydown = handleKeyDown;
}

// Loading state
if (params.buttonsStyling) {
confirmButton.style.borderLeftColor = params.confirmButtonColor;
confirmButton.style.borderRightColor = params.confirmButtonColor;
}

/**
* Show spinner instead of Confirm button and disable Cancel button
*/
Expand Down Expand Up @@ -1887,7 +1842,7 @@ sweetAlert.adaptInputValidator = function (legacyValidator) {

sweetAlert.noop = function () {};

sweetAlert.version = '7.6.2';
sweetAlert.version = '7.6.3';

sweetAlert.default = sweetAlert;

Expand Down
16 changes: 12 additions & 4 deletions dist/sweetalert2.css
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,20 @@ body.swal2-no-backdrop .swal2-shown {
display: block;
word-wrap: break-word; }
.swal2-popup .swal2-actions {
height: 4em;
-webkit-box-align: end;
-ms-flex-align: end;
align-items: flex-end;
margin-top: 1.25em;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center; }
.swal2-popup .swal2-actions:not(.swal2-loading) .swal2-styled[disabled] {
opacity: .4;
cursor: no-drop; }
.swal2-popup .swal2-actions:not(.swal2-loading) .swal2-styled:hover {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNikAQAACIAHF/uBd8AAAAASUVORK5CYII="); }
.swal2-popup .swal2-actions:not(.swal2-loading) .swal2-styled:active {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNiMAYAADwANpiOMBYAAAAASUVORK5CYII="); }
.swal2-popup .swal2-actions.swal2-loading .swal2-styled.swal2-confirm {
-webkit-box-sizing: border-box;
box-sizing: border-box;
Expand Down Expand Up @@ -641,6 +645,10 @@ body.swal2-no-backdrop .swal2-shown {
font-weight: 500;
margin: 0 .3125em;
padding: .625em 2em; }
.swal2-popup .swal2-styled.swal2-confirm {
background-color: #3085d6; }
.swal2-popup .swal2-styled.swal2-cancel {
background-color: #aaa; }
.swal2-popup .swal2-styled:focus {
outline: none;
-webkit-box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(50, 100, 150, 0.4);
Expand Down
93 changes: 24 additions & 69 deletions dist/sweetalert2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* sweetalert2 v7.6.2
* sweetalert2 v7.6.3
* Released under the MIT License.
*/
(function (global, factory) {
Expand Down Expand Up @@ -27,11 +27,11 @@ var defaultParams = {
preConfirm: null,
confirmButtonText: 'OK',
confirmButtonAriaLabel: '',
confirmButtonColor: '#3085d6',
confirmButtonColor: null,
confirmButtonClass: null,
cancelButtonText: 'Cancel',
cancelButtonAriaLabel: '',
cancelButtonColor: '#aaa',
cancelButtonColor: null,
cancelButtonClass: null,
buttonsStyling: true,
reverseButtons: false,
Expand All @@ -48,7 +48,7 @@ var defaultParams = {
timer: null,
width: null,
padding: null,
background: '#fff',
background: null,
input: null,
inputPlaceholder: '',
inputValue: '',
Expand Down Expand Up @@ -87,28 +87,6 @@ var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);

var consolePrefix = 'SweetAlert2:';

/*
* Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
*/
var colorLuminance = function colorLuminance(hex, lum) {
// Validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
lum = lum || 0;

// Convert to decimal and change luminosity
var rgb = '#';
for (var i = 0; i < 3; i++) {
var c = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
rgb += ('00' + c).substr(c.length);
}

return rgb;
};

/**
* Filter the unique values into a new array
* @param arr
Expand Down Expand Up @@ -575,10 +553,14 @@ var setParameters = function setParameters(params) {
popup.style.padding = typeof params.padding === 'number' ? params.padding + 'px' : params.padding;
}

popup.style.background = params.background;
// Set popup background
if (params.background) {
popup.style.background = params.background;
}
var popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
var successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
for (var i = 0; i < successIconParts.length; i++) {
successIconParts[i].style.background = params.background;
successIconParts[i].style.backgroundColor = popupBackgroundColor;
}

var container = getContainer();
Expand Down Expand Up @@ -780,12 +762,6 @@ var setParameters = function setParameters(params) {
confirmButton.setAttribute('aria-label', params.confirmButtonAriaLabel);
cancelButton.setAttribute('aria-label', params.cancelButtonAriaLabel);

// Set buttons to selected background colors
if (params.buttonsStyling) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
cancelButton.style.backgroundColor = params.cancelButtonColor;
}

// Add buttons custom classes
confirmButton.className = swalClasses.confirm;
addClass(confirmButton, params.confirmButtonClass);
Expand All @@ -795,6 +771,19 @@ var setParameters = function setParameters(params) {
// Buttons styling
if (params.buttonsStyling) {
addClass([confirmButton, cancelButton], swalClasses.styled);

// Buttons background colors
if (params.confirmButtonColor) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
}
if (params.cancelButtonColor) {
cancelButton.style.backgroundColor = params.cancelButtonColor;
}

// Loading state
var confirmButtonBackgroundColor = window.getComputedStyle(confirmButton).getPropertyValue('background-color');
confirmButton.style.borderLeftColor = confirmButtonBackgroundColor;
confirmButton.style.borderRightColor = confirmButtonBackgroundColor;
} else {
removeClass([confirmButton, cancelButton], swalClasses.styled);

Expand Down Expand Up @@ -1098,34 +1087,6 @@ var sweetAlert = function sweetAlert() {
var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));

switch (e.type) {
case 'mouseover':
case 'mouseup':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
}
}
break;
case 'mouseout':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
} else if (targetedCancel) {
cancelButton.style.backgroundColor = params.cancelButtonColor;
}
}
break;
case 'mousedown':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
}
}
break;
case 'click':
// Clicked 'confirm'
if (targetedConfirm && sweetAlert.isVisible()) {
Expand Down Expand Up @@ -1347,12 +1308,6 @@ var sweetAlert = function sweetAlert() {
window.onkeydown = handleKeyDown;
}

// Loading state
if (params.buttonsStyling) {
confirmButton.style.borderLeftColor = params.confirmButtonColor;
confirmButton.style.borderRightColor = params.confirmButtonColor;
}

/**
* Show spinner instead of Confirm button and disable Cancel button
*/
Expand Down Expand Up @@ -1891,7 +1846,7 @@ sweetAlert.adaptInputValidator = function (legacyValidator) {

sweetAlert.noop = function () {};

sweetAlert.version = '7.6.2';
sweetAlert.version = '7.6.3';

sweetAlert.default = sweetAlert;

Expand Down
2 changes: 1 addition & 1 deletion dist/sweetalert2.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sweetalert2.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sweetalert2",
"version": "7.6.2",
"version": "7.6.3",
"repository": "sweetalert2/sweetalert2",
"homepage": "https://sweetalert2.github.io/",
"description": "A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert",
Expand Down
Loading

0 comments on commit 1dc3353

Please sign in to comment.