a service to display notifications using the angular-notify library and have a better alert and confirm methods
A method config where you can set
parentTagIdClass: the tag/id/class of the element you want to append to, for when you are using a namespaced distribution of lucca-ui, default: "body"prefix: the prefix or your distribution, default "lui"startTop: the margin in px between the top of the screen and the first notification, to prevent it to go over an horizontal menu, default 40okLabel: the label you want for the button ok in the modal used by methods alert and confirm, default "Ok"cancelLabel: the label you want for the button cancel in the modal used by methods alert and confirm, default "Cancel"canDismissConfim: if set to true, the user will be able to close the confirmation modal by clicking outside of it, when set to false the user will have to click either Ok or Cancel to cose the modal, default false
Methods success, warning anderror taking message and details as arguments. the message will be displayed in the popup while both message and details will be logged in the browser console using $log
A method loading taking a ng.IPromise<string>, a message and a cancel function as arguments. Will display a notification with a spinner and the provided message.
cancel function, the won't be present while the promise isn't resolved/rejectedcancel function, clicking while the promise isn't resolved/rejected will cal said function before closing the notification
Methods alert, andconfirm taking message, okLabel and cancelLabel as arguments. returns a ng.IPromise<boolean> that resolves with true if user clicked Ok and false if user clicked cancel, rejects if user clicked outside of the modal
// to configure, needs to be done just once
angular.module("myApp").config(fumction(luisConfigProvider){
luisConfigProvider.setConfig({
parentTagIdClass: "demo",
startTop: 60,
prefix: "lui",
canDismissConfim: true
});
});
// to use in your controller
angular.controller("myCtrl", function(luisNotify) {
luisNotify.error("your message", "some details");
luisNotify.confirm("This action is irreversible, are you really sure you want to do it?", "Yes I am", "No i'm not")
.then(function(isSure) {
if (isSure) {
var loadingDfd = $q.defer();
luisNotify.loading(loadingDfd.promise, "doing the stuff");
doTheStuff()
.then( function() {
loadingDfd.resolve("the stuff is done");
}, function() {
loadingDfd.reject("an error happened :'(");
});
}
});
});
{{confirmationMessage}}