From 2cdad88101a41302f3a36a53260233ace1dfdf13 Mon Sep 17 00:00:00 2001 From: Aarni Date: Mon, 15 Aug 2016 20:36:35 +0300 Subject: [PATCH] Noty pop-ups made good-looking and got rid of window.alerts --- members/static/js/members_controllers.js | 70 +++++++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/members/static/js/members_controllers.js b/members/static/js/members_controllers.js index ca6fd09..896a408 100644 --- a/members/static/js/members_controllers.js +++ b/members/static/js/members_controllers.js @@ -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"); }); }