sweet alert lib implemented. added confirmation to password generator edit

This commit is contained in:
Kyle Spearrin 2016-09-19 23:56:27 -04:00
parent 68337d6523
commit 81dd1ff0f2
6 changed files with 97 additions and 5 deletions

View File

@ -104,6 +104,10 @@ gulp.task('lib', ['clean:lib'], function () {
{
src: paths.npmDir + 'q/q.js',
dest: paths.libDir + 'q'
},
{
src: [paths.npmDir + 'sweetalert/dist/sweetalert.css', paths.npmDir + 'sweetalert/dist/sweetalert.min.js', paths.npmDir + 'angular-sweetalert/SweetAlert.js'],
dest: paths.libDir + 'sweetalert'
}
];

View File

@ -25,6 +25,8 @@
"merge-stream": "1.0.0",
"angular-toastr": "2.1.1",
"q": "1.4.1",
"angularjs-slider": "5.5.0"
"angularjs-slider": "5.5.0",
"sweetalert": "1.1.3",
"angular-sweetalert": "1.1.1"
}
}

View File

@ -1,7 +1,7 @@
angular
.module('bit.vault')
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr) {
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr, SweetAlert) {
var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText;
var siteId = $stateParams.siteId;
@ -61,10 +61,29 @@ angular
};
$scope.generatePassword = function () {
var confirmed = true;
if ($scope.site.password) {
// TODO: confirmation
SweetAlert.swal({
title: 'Warning',
text: 'Are you sure you want to overwrite the current password?',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No'
},
function (confirm) {
if (confirm) {
goPasswordGenerator();
}
});
}
else {
goPasswordGenerator();
}
};
function goPasswordGenerator() {
$state.go('passwordGenerator', {
animation: 'in-slide-up',
editState: {
@ -75,5 +94,5 @@ angular
returnSearchText: returnSearchText
}
});
};
}
});

View File

@ -1,2 +1,2 @@
angular
.module('bit.vault', ['ngAnimate', 'toastr', 'ngclipboard']);
.module('bit.vault', ['ngAnimate', 'toastr', 'ngclipboard', 'oitozero.ngSweetAlert']);

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../lib/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="../lib/angular-toastr/angular-toastr.css">
<link rel="stylesheet" href="../lib/sweetalert/sweetalert.css">
<link rel="stylesheet" href="css/popup.css">
<script src="../lib/jquery/jquery.js"></script>
@ -22,6 +23,8 @@
<script src="../lib/angular-jwt/angular-jwt.js"></script>
<script src="../lib/angular-toastr/angular-toastr.tpls.js"></script>
<script src="../lib/ngclipboard/ngclipboard.js"></script>
<script src="../lib/sweetalert/SweetAlert.js"></script>
<script src="../lib/sweetalert/sweetalert.min.js"></script>
<script src="../lib/angularjs-slider/rzslider.js"></script>
<script src="app/app.js"></script>

View File

@ -35,6 +35,7 @@
&.toast-danger, &.toast-error {
background-image: none !important;
background-color: @brand-danger;
&:before {
content: "\f0e7";
}
@ -43,6 +44,7 @@
&.toast-warning {
background-image: none !important;
background-color: @brand-warning;
&:before {
content: "\f071";
}
@ -51,6 +53,7 @@
&.toast-info {
background-image: none !important;
background-color: @brand-info;
&:before {
content: "\f005";
}
@ -59,6 +62,7 @@
&.toast-success {
background-image: none !important;
background-color: @brand-success;
&:before {
content: "\f00C";
}
@ -76,3 +80,63 @@
}
}
}
/* Sweet alert */
.sweet-alert {
p {
color: @text-color;
font-weight: normal;
}
h2 {
line-height: 30px;
font-size: 25px;
}
.sa-icon.sa-error {
border-color: @brand-danger;
}
.pulseErrorIns {
background-color: @brand-danger !important;
}
.sa-icon.sa-info {
border-color: @brand-info;
}
.pulseInfoIns {
background-color: @brand-info !important;
}
.sa-icon.sa-success {
border-color: @brand-success;
}
.pulseSuccessIns {
background-color: @brand-success !important;
}
.sa-icon.sa-warning {
border-color: @brand-warning;
}
.pulseWarningIns {
background-color: @brand-warning !important;
}
button {
border-radius: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
&.confirm, &.confirm:hover {
background-color: @brand-primary !important;
}
&.cancel, &.cancel:hover {
background-color: @gray-light;
}
}
}