Noty pop-ups made good-looking and got rid of window.alerts

This commit is contained in:
Aarni
2016-08-15 20:36:35 +03:00
parent 5f9af6e3f1
commit 2cdad88101
+62 -8
View File
@@ -11,11 +11,31 @@ app.controller("getController", function($scope, $http, $window, $location){
$scope.delete_member = function(id) {
$http.delete("/members/api/member/" + id).then(
function(response) {
noty({ text: "Onnistui! Hyvä Harry!"});
noty({
text: "Poistaminen onnistui!",
layout: "bottomRight",
type: "success",
timeout: 10000
// ,
// buttons: [
// {
// addClass: 'btn btn-primary', text: 'Undo', onClick: function() {
// }
// }
// ]
// http://ned.im/noty/#/about
});
$location.path("#/list");
},
function(response) {
noty({ text: "Epäonnistui. Yritä uudelleen."});
noty({
text: "Epäonnistui. Yritä uudelleen.",
layout: "bottomRight",
type: "error",
timeout: 10000
});
$location.path("#/list");
}
);
@@ -28,14 +48,38 @@ function()
{ return {
link: function (scope, element, attr)
{
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.confirmedClick;
element.bind('click',function (event)
{
if ( window.confirm(msg) ) {
scope.$eval(clickAction)
}
noty({
text: 'Haluatko varmasti poistaa?',
layout: 'bottomRight',
buttons: [
{
addClass: 'btn btn-danger', text: 'Kyllä', onClick: function($noty) {
// this = button element
// $noty = $noty element
$noty.close();
scope.$eval(clickAction)
}
},
{
addClass: 'btn btn-primary', text: 'Ei', onClick: function($noty) {
$noty.close();
}
}
]
});
});
// var msg = attr.ngConfirmClick || "Are you sure?";
// var clickAction = attr.confirmedClick;
// element.bind('click',function (event)
// {
// if ( window.confirm(msg) ) {
// scope.$eval(clickAction)
// }
// });
}
}}]);
@@ -48,7 +92,12 @@ app.controller("postController", function($scope, $http, $location) {
$scope.POR = "";
$scope.send = function() {
$http.post("/members/api/member/", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR}).then(function(data){
noty({ text: "Jäsenhakemus lähetetty"});
noty({
text: "Jäsenhakemus lähetetty",
layout: "bottomRight",
type: "success",
timeout: 10000
});
$location.path("#/list");
});
}
@@ -61,7 +110,12 @@ app.controller("editController", function($scope, $http, $route, $routeParams, $
$scope.send = function() {
$http.put("/members/api/member/"+$scope.member.id, $scope.member).then(function(data){
noty({ text: "Jäsentiedot tallennettu"});
noty({
text: "Jäsentiedot tallennettu",
layout: "bottomRight",
type: "success",
timeout: 10000
});
$location.path("#/list");
});
}