/** * * Expomeeting - MeetingWE Responsive Admin Theme * Additional and custom styles * version 0.1 * */ (function () { angular.module('rb-app-login', [ 'ui.bootstrap', 'pascalprecht.translate', // Angular Translate 'ngSanitize', 'datePicker' ]); })(); function loginCtrl($rootScope, $scope, $sce, $timeout, $filter, $window, $translate, mweAjaxRequest, mweAlert, $uibModal) { $timeout(function () { $(".rb-login-wrapper").fadeIn(500); console.log('return_to'); }, 200) console.log($rootScope.mweGlobalData); $scope.options = { language: 'it-it' }; $scope.languageChanged = function () { $translate.use($scope.options.language); }; $scope.action = 'login'; if ($rootScope.mweGlobalData.pass_set == 'yes') { if ($rootScope.mweGlobalData.key_error == 'yes') { $timeout(function () { mweAlert.error($filter('translate')('INVALID_KEY'), $filter('translate')('INVALID_KEY_TEXT')); }, 0); } else { if ($rootScope.mweGlobalData.new_user == 'yes') $scope.action = 'new_user'; else $scope.action = 'pass_reset'; } } $scope.usernameConfirmation = { active: false }; if ($rootScope.mweGlobalData.username_confirm == 'success' || $rootScope.mweGlobalData.username_confirm == 'error') { $scope.usernameConfirmation = { active: true, class: "alert-" + $rootScope.mweGlobalData.username_confirm, message: "USERNAME_CONFIRMATION_" + $rootScope.mweGlobalData.username_confirm.toUpperCase() }; if ($scope.usernameConfirmation.class == "alert-error") $scope.usernameConfirmation.class = "alert-danger"; } // $scope.loginData = { // username: '', // password: '', // keep_me_logged: false, // }; $scope.getQueryString = function (field, url) { var href = url ? url : window.location.href; var reg = new RegExp('[?&]' + field + '=([^]*)', 'i'); var string = reg.exec(href); return string ? string[1] : null; }; $scope.loginObj = { login_error: '', login: function () { $(".rb-username-input, .rb-password-input").parent().removeClass("has-error"); $scope.loginObj.login_error = ''; $scope.loginData.return_to = window.location.hash.substr(1); mweAjaxRequest( 'mwe-login', $scope.loginData, function (response) { if (response.result === 'success') { $window.location.href = response.dashboard; } else { switch (response) { case 'incorrect_password': $(".rb-password-input").parent().addClass("has-error"); $scope.loginObj.login_error = 'INVALID_PASSWORD'; break; case 'invalid_username': $(".rb-username-input").parent().addClass("has-error"); $scope.loginObj.login_error = 'INVALID_USERNAME'; break; default: $(".rb-username-input, .rb-password-input").parent().addClass("has-error"); $scope.loginObj.login_error = 'INVALID_USERNAME_OR_PASSWORD'; } } }, function (error) { } ); } } $scope.go_to_login = function () { $scope.action = ''; $timeout(function () { $scope.action = 'login'; }, 600); }; $scope.go_to_recover = function () { $scope.action = ''; $timeout(function () { $scope.action = 'send_pass_recover'; }, 600); }; $scope.go_to_register = function () { $scope.action = ''; $timeout(function () { $scope.action = 'register'; }, 600); }; $scope.sendPassRecover = { username: '', send: function () { mweAjaxRequest( 'mwe-send-password-recover', { username: $scope.sendPassRecover.username }, function (response) { if (response.result === 'success') { $scope.go_to_login(); mweAlert.success($filter('translate')('EMAIL_SENT'), $filter('translate')('CHECK_YOUR_EMAIL')); } else { switch (response) { case 'unknown-user': mweAlert.error($filter('translate')('UNKNOWN_USER'), $filter('translate')('UNKNOWN_USER_TEXT')); break; default: mweAlert.serverError(); } } }, function (error) { mweAlert.serverError(); } ); } } $scope.register = { email: '', first_name: '', last_name: '', tax_code: '', countries_states: $rootScope.mweGlobalData.countries, get_countries_states: function () { return $rootScope.mweGlobalData.countries; }, get_countries_keys: function () { return Object.keys($rootScope.mweGlobalData.countries); }, get_state_keys: function () { if ($scope.register.get_countries_states()[$scope.register.mwe_birth_country] && $scope.register.get_countries_states()[$scope.register.mwe_birth_country].states) { return Object.keys($scope.register.get_countries_states()[$scope.register.mwe_birth_country].states); } else { return []; } }, get_lr_state_keys: function () { if ($scope.register.get_countries_states()[$scope.register.mwe_lr_country] && $scope.register.get_countries_states()[$scope.register.mwe_lr_country].states) { return Object.keys($scope.register.get_countries_states()[$scope.register.mwe_lr_country].states); } else { return []; } }, get_professions: function () { return $rootScope.mweGlobalData.professions.profession; }, pro_has_discipline: function () { return ($rootScope.mweGlobalData.professions.profession[$scope.register.mwe_profession] && !!$rootScope.mweGlobalData.professions[$scope.register.mwe_profession]) }, get_professions_keys: function () { return Object.keys($rootScope.mweGlobalData.professions.profession); }, get_discipline_keys: function () { if ($scope.register.pro_has_discipline()) { return Object.keys($rootScope.mweGlobalData.professions[$scope.register.mwe_profession]); } return []; }, get_disciplines: function () { if ($scope.register.pro_has_discipline()) { return $rootScope.mweGlobalData.professions[$scope.register.mwe_profession]; } return []; }, get_pro_profiles_keys: function () { return Object.keys($rootScope.mweGlobalData.professions.employment_profile); }, get_pro_profiles: function () { return $rootScope.mweGlobalData.professions.employment_profile; }, get_italian_provinces_keys: function () { return Object.keys($rootScope.mweGlobalData.italian_provinces); }, get_italian_provinces: function () { return $rootScope.mweGlobalData.italian_provinces; }, updateDate: function (who) { if (who == 'manual') { if ($scope.register.mwe_birth_date == '') { $scope.register.mwe_birth_rdate = ''; return true; } var tmpMoment = moment($scope.register.mwe_birth_date, 'DD/MM/YYYY', true); if (tmpMoment.isValid()) { $scope.register.mwe_birth_rdate = tmpMoment.format("YYYY-MM-DD"); $('*[ng-model="register.mwe_birth_date"]').parent().removeClass("has-error"); } else { $('*[ng-model="register.mwe_birth_date"]').parent().addClass("has-error"); } } else { var tmpMoment = moment($scope.register.mwe_birth_rdate); if (tmpMoment.isValid()) { $scope.register.mwe_birth_date = tmpMoment.format('L'); $('*[ng-model="register.mwe_birth_date"]').parent().removeClass("has-error"); } else { $scope.register.mwe_birth_date = ''; $('*[ng-model="register.mwe_birth_date"]').parent().addClass("has-error"); } } }, check: function (who) { $('*[ng-model="register.' + who + '"]').each(function () { if ($(this).attr("required")) { var field = $(this).attr("ng-model").split(".")[1]; if ($.trim($scope.register[field]) == '') { $(this).parent().addClass("has-error"); } else $(this).parent().removeClass("has-error"); } }); if (who == 'tax_code') { if (!CodiceFiscale.check($.trim(this.tax_code))) { error = true; $(".reg-tcode").parent().addClass("has-error"); } else $(".reg-tcode").parent().removeClass("has-error"); } if (who == 'email') { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if ($.trim(this.email) != '' && re.test(this.email)) { $(".reg-email").parent().removeClass("has-error"); } else { error = true; $(".reg-email").parent().addClass("has-error"); } } }, send: function () { $scope.register.error = false; var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; $(".ac-reg-form [required]").each(function () { var field = $(this).attr("ng-model").split(".")[1]; if ($.trim($scope.register[field]) == '') { $scope.register.error = true; $(this).parent().addClass("has-error"); } else $(this).parent().removeClass("has-error"); }); if (!CodiceFiscale.check($.trim(this.tax_code))) { $scope.register.error = true; $(".reg-tcode").parent().addClass("has-error"); } else $(".reg-tcode").parent().removeClass("has-error"); if ($.trim(this.email) != '' && re.test(this.email)) { $(".reg-email").parent().removeClass("has-error"); } else { $scope.register.error = true; $(".reg-email").parent().addClass("has-error"); } // var tmpMoment = moment($scope.register.mwe_birth_date, 'DD/MM/YYYY', true); // if (tmpMoment.isValid()) { // $scope.register.mwe_birth_rdate = tmpMoment.format("YYYY-MM-DD"); // $('*[ng-model="register.mwe_birth_date"]').parent().removeClass("has-error"); // } else { // $scope.register.error = true; // $('*[ng-model="register.mwe_birth_date"]').parent().addClass("has-error"); // } if ($scope.register.error) return false; mweAjaxRequest( 'mwe-register', { username: $scope.register.email, first_name: $scope.register.first_name, last_name: $scope.register.last_name, tax_code: $scope.register.tax_code, mwe_phone: $scope.register.phone, // mwe_birth_date: tmpMoment.format('YYYY-MM-DD'), // mwe_birth_country: $scope.register.mwe_birth_country, // mwe_birth_state: $scope.register.mwe_birth_state, // mwe_birth_city: $scope.register.mwe_birth_city, mwe_profession: $scope.register.mwe_profession, mwe_discipline: $scope.register.mwe_discipline, mwe_professional_profile: $scope.register.mwe_professional_profile, // mwe_lr_country: $scope.register.mwe_lr_country, // mwe_lr_state: $scope.register.mwe_lr_state, // mwe_lr_addr_first_line: $scope.register.mwe_lr_addr_first_line, // mwe_lr_postcode: $scope.register.mwe_lr_postcode, // mwe_lr_city: $scope.register.mwe_lr_city, // mwe_affiliation: $scope.register.mwe_affiliation, // mwe_register_number: $scope.register.mwe_register_number, // mwe_register_of: $scope.register.mwe_register_of, // mwe_gender: $scope.register.mwe_gender, }, function (response) { if (response.result === 'success') { $scope.go_to_login(); mweAlert.success($filter('translate')('EMAIL_SENT'), $filter('translate')('REGISTRATION_CHECK_YOUR_EMAIL')); } else { switch (response) { case 'empty name': mweAlert.error($filter('translate')('EMPTY_NAME'), $filter('translate')('EMPTY_NAME_TEXT')); break; case 'invalid email': mweAlert.error($filter('translate')('INVALID_EMAIL'), $filter('translate')('INVALID_EMAIL_TEXT')); break; case 'existing user': mweAlert.error($filter('translate')('EXISTING_USER'), $filter('translate')('EXISTING_USER_TEXT')); break; default: mweAlert.serverError(); } } }, function (error) { mweAlert.serverError(); } ); } } $scope.newUserData = { username: $rootScope.mweGlobalData.username, nicename: $rootScope.mweGlobalData.nicename, key: $rootScope.mweGlobalData.key, f_name: $rootScope.mweGlobalData.f_name, l_name: $rootScope.mweGlobalData.l_name, password: '', c_password: '', }; $timeout(function () { $scope.newUserData.password = ''; $scope.newUserData.c_password = ''; }, 200); $scope.passResetData = { username: $rootScope.mweGlobalData.username, nicename: $rootScope.mweGlobalData.nicename, key: $rootScope.mweGlobalData.key, f_name: $rootScope.mweGlobalData.f_name, l_name: $rootScope.mweGlobalData.l_name, password: '', c_password: '', }; $timeout(function () { $scope.passResetData.password = ''; $scope.passResetData.c_password = ''; }, 200); $scope.p_type = 'password'; $scope.p_type_toggle = function () { if ($scope.p_type == 'password') $scope.p_type = 'text'; else $scope.p_type = 'password'; } $scope.generatePassword = function () { var iteration = 0; var password = ""; var randomNumber; if (special == undefined) { var special = false; } while (iteration < 16) { randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33; if (randomNumber == 34) { continue; } if ((randomNumber >= 36) && (randomNumber <= 47)) { continue; } if ((randomNumber >= 58) && (randomNumber <= 62)) { continue; } if ((randomNumber >= 91) && (randomNumber <= 96)) { continue; } if ((randomNumber >= 123) && (randomNumber <= 126)) { continue; } iteration++; password += String.fromCharCode(randomNumber); } if ($scope.action == 'pass_reset') { $scope.passResetData.password = $scope.passResetData.c_password = password; } else { $scope.newUserData.password = $scope.newUserData.c_password = password; } $scope.checkPasswordStrength(); return password; }; $scope.passwordStrength = -1; $scope.mapPasswordStrengthProgress = function () { switch ($scope.passwordStrength) { case 0: case 1: case 2: case 3: case 4: return Math.ceil($scope.passwordStrength / 4 * 100); break; default: return 0; } }; $scope.mapPasswordStrengthClass = function () { switch ($scope.passwordStrength) { case -1: return 'label-danger'; break; case 0: case 1: case 2: case 3: return 'label-warning'; break; case 4: return 'label-primary'; break; case 5: return 'label-danger'; break; default: return 'label-danger'; } }; $scope.mapPasswordStrengthString = function () { switch ($scope.passwordStrength) { case -1: return 'TOO_SHORT'; break; case 0: case 1: case 2: case 3: return 'BAD_PASSWORD'; break; case 4: return 'STRONG_PASSWORD'; break; case 5: return 'PASSWORD_MISMATCH'; break; default: return 'BAD_PASSWORD'; } }; $scope.checkPasswordStrength = function () { var witch = 'new_user'; var witchObj = 'newUserData'; if ($scope.action == 'pass_reset') { var witch = 'pass_reset'; var witchObj = 'passResetData'; } if ($scope[witchObj].password.length < 6) { $scope.passwordStrength = -1; return false; } var banned = [$scope[witchObj].username, $scope[witchObj].f_name, $scope[witchObj].l_name]; $scope.passwordStrength = passwordStrength($scope[witchObj].password, banned, $scope[witchObj].c_password); }; $scope.save_new_user = function () { if ($scope.saving === true) return false; $scope.saving = true; $scope.checkPasswordStrength(); if ($scope.passwordStrength < 0 || $scope.passwordStrength > 4) return false; mweAjaxRequest( 'mwe-set-new-user-data', $scope.newUserData, function (response) { $scope.saving = false; if (response.result === 'success') { $scope.action = ''; $timeout(function () { $scope.action = 'login'; }, 600); } else { mweAlert.serverError(); } }, function (error) { $scope.saving = false; mweAlert.serverError(); } ); }; $scope.reset_password = function () { if ($scope.saving === true) return false; $scope.saving = true; $scope.checkPasswordStrength(); if ($scope.passwordStrength < 0 || $scope.passwordStrength > 4) return false; mweAjaxRequest( 'mwe-reset-password', $scope.passResetData, function (response) { $scope.saving = false; if (response.result === 'success') { $scope.action = ''; $timeout(function () { $scope.action = 'login'; }, 600); } else { $mdToast.show( $mdToast.simple() .textContent('SERVER_ERROR') .position('top left') .hideDelay(3000) ); } }, function (error) { $scope.saving = false; $mdToast.show( $mdToast.simple() .textContent($filter('translate')('SERVER_ERROR')) .position('top left') .hideDelay(3000) ); } ); }; $scope.showTerms = function () { $scope.termModalInstance = $uibModal.open({ templateUrl: "https://siti.myquadra.it/wp-content/plugins/meetingwe/assets/views/common/terms.html?ver=2", scope: $scope, windowClass: "animated flipInY" }); }; $scope.termsAgree = function () { $scope.termModalInstance.close(); } } angular.module('rb-app-login').controller('LoginCtrl', ['$rootScope', '$scope', '$sce', '$timeout', '$filter', '$window', '$translate', 'mweAjaxRequest', 'mweAlert', '$uibModal', loginCtrl]); function tConfig($translateProvider) { $translateProvider .translations('en-us', { LOGIN: 'Login', USERNAME: 'Username (e-mail)', PASSWORD: "Password", CONFIRM_PASSWORD: "Confirm password", STAY_LOGGED_IN: 'Keep me logged', LANGUAGE: 'Language', ITALIAN: "Italiano", ENGLISH: "English", INVALID_PASSWORD: "Invalid password", INVALID_USERNAME: "Unknown user", INVALID_USERNAME_OR_PASSWORD: "Unknown user or invalid password", NEW_USER: "New user", WELCOME_TEXT: "Welcome! To complete the registration please fill the form below", SAVE: "Save", FIRST_NAME: "First name", LAST_NAME: "Last name", EMAIL: "e-mail", TOO_SHORT: "The password is too short", BAD_PASSWORD: "Weak password", STRONG_PASSWORD: "Strong password", PASSWORD_MISMATCH: "Passwords do not match", SHOW: "Show", HIDE: "Hide", GENERATE: "Generate", THIS_FIELD_IS_REQUIRED: 'This field is required', SERVER_ERROR: "A server error occured, please try again later", INVALID_KEY: "Invalid key", INVALID_KEY_TEXT: "Your key is no longer valid. To get a new key you can follow the password recovery procedure.", OK: 'Ok', FORGOT_PASSWORD: "Forgot password?", PASSWORD_RECOVER: "Password recovery", PASSWORD_RECOVER_TEXT: "Type your email address in the form below. You will receive an email with the instructions to reset your password.", PASSWORD_RECOVER_TEXT_HELP: "If you don't receive the email, please check the spam folder of your mailbox.", BACK: "Back", SEND: "Send", EMAIL_SENT: "Email sent", CHECK_YOUR_EMAIL: "Check your email, you will receive the message with the instructions to reset your password.", UNKNOWN_USER: "Unknown user", UNKNOWN_USER_TEXT: "The email address you typed is not related to any user. Are you sure you are registered with that email address?", PASSWORD_RESET_TEXT: "Now you can set a new password", NEW_PASSWORD: "New password", DO_NOT_HAVE_AN_ACCOUNT: "Do not have an account?", CREATE_AN_ACCOUNT: "Register", REGISTER_TEXT: "Type your data in the form below. You will receive an email with the instructions to complete your registration.", REGISTER_TEXT_HELP: "If you don't receive the email, please check the spam folder of your mailbox.", AGREE_THE_TERMS: "By registering, you declare that you have read and fully accept our Privacy Policy.", TERMS_AND_CONDITIONS: "Privacy Policy", EMPTY_NAME: "Missing data", EMPTY_NAME_TEXT: "You have to type your first and last names.", INVALID_EMAIL: "Invalid email", INVALID_EMAIL_TEXT: "The email address you typed is not valid.", EXISTING_USER: "Existing user", EXISTING_USER_TEXT: "A user with this email address already exists. If you are tryng to recover your account data, you need to use the password recovery.", REGISTRATION_CHECK_YOUR_EMAIL: "Check your email, you will receive the message with the instructions to complete the registration.", SERVER_ERROR_TITLE: 'Sorry, an error occurred...', SERVER_ERROR_MESSAGE: 'Something went wrong. Please try again (refreshing the page) or contact the system administrator.', USERNAME_CONFIRMATION_ERROR: "The confirmation link is incorrect or has expired. No changes took place in your account.", USERNAME_CONFIRMATION_SUCCESS: "Your new email address is confirmed, you can use it as username for the login." }) .translations('it-it', { LOGIN: 'Login', USERNAME: 'Nome utente (e-mail)', PASSWORD: "Password", CONFIRM_PASSWORD: "Conferma password", STAY_LOGGED_IN: 'Resta collegato', LANGUAGE: 'Lingua', ITALIAN: "Italiano", ENGLISH: "English", INVALID_PASSWORD: "Password non valida", INVALID_USERNAME: "Utente sconosciuto", INVALID_USERNAME_OR_PASSWORD: "Utente sconosciuto o password non valida", NEW_USER: "Nuovo utente", WELCOME_TEXT: "Benvenuta/o! Per completare la registrazione, riempi il seguente form", SAVE: "Salva", FIRST_NAME: "Nome", LAST_NAME: "Cognome", EMAIL: "e-mail", TOO_SHORT: "La password è troppo corta", BAD_PASSWORD: "Password debole", STRONG_PASSWORD: "Password forte", PASSWORD_MISMATCH: "Le password non coincidono", SHOW: "Mostra", HIDE: "Nascondi", GENERATE: "Genera", THIS_FIELD_IS_REQUIRED: 'È necessario compilare questo campo', SERVER_ERROR: "Si è verificato un errore nel server, si prega di riprovare più tardi", INVALID_KEY: "Chiave non valida", INVALID_KEY_TEXT: "La tua chiave non è più valida. Per ottenere una nuova chiave puoi seguire la procedura di recupero della password.", OK: 'Ok', FORGOT_PASSWORD: "Hai dimenticato la password?", PASSWORD_RECOVER: "Recupero della password", PASSWORD_RECOVER_TEXT: "Scrivi il tuo indirizzo email nel modulo sottostante. Riceverai un'e-mail con le istruzioni per reimpostare la tua password.", PASSWORD_RECOVER_TEXT_HELP: "Se non ricevi l'email, controlla nella cartella spam della tua casella mail.", BACK: "Indietro", SEND: "Invia", EMAIL_SENT: "Email inviata", CHECK_YOUR_EMAIL: "Controlla la tua email, riceverai il messaggio con le istruzioni per reimpostare la tua password.", UNKNOWN_USER: "Utente sconosciuto", UNKNOWN_USER_TEXT: "L'indirizzo email che hai digitato non appartiene a nessun utente. Sei sicuro di essere registrato con quell'indirizzo email?", PASSWORD_RESET_TEXT: "Ora puoi impostare una nuova password", NEW_PASSWORD: "Nuova password", DO_NOT_HAVE_AN_ACCOUNT: "Non hai un account?", CREATE_AN_ACCOUNT: "Registrati", REGISTER_TEXT: "Scrivi i tuoi dati nel modulo sottostante. Riceverai un'e-mail con le istruzioni per completare la registrazione", REGISTER_TEXT_HELP: "Se non ricevi l'email, controlla nella cartella spam della tua casella mail.", AGREE_THE_TERMS: "Registrandoti dichiari di aver letto e accetti integralmente la nostra informativa sulla privacy.", TERMS_AND_CONDITIONS: "Informativa sulla privacy", EMPTY_NAME: "Dati mancanti", EMPTY_NAME_TEXT: "Devi inserire nome e cognome.", INVALID_EMAIL: "Indirizzo mail non valido", INVALID_EMAIL_TEXT: "L\'indirizzo mail che hai digitato non è corretto.", EXISTING_USER: "Utente esistente", EXISTING_USER_TEXT: "Un utente con questo indirizzo mail esiste già. Se stai cercando di recuperare i dati del tuo account, devi usare il recupero password.", REGISTRATION_CHECK_YOUR_EMAIL: "Controlla la tua email, riceverai il messaggio con le istruzioni per completare la registrazione.", SERVER_ERROR_TITLE: 'Spiacenti, si è verificato un errore...', SERVER_ERROR_MESSAGE: 'Qualcosa è andato storto. Si prega di riprovare (ricaricando la pagina) o di contattare l\'amministratore di sistema.', USERNAME_CONFIRMATION_ERROR: "Il link di conferma non è corretto o è scaduto. Non sono state apportate modifiche al tuo account.", USERNAME_CONFIRMATION_SUCCESS: "Il tuo nuovo indirizzo email è confermato, puoi usarlo come username per il login." }); $translateProvider.preferredLanguage('it-it'); } angular .module('rb-app-login') .config(tConfig); function mweAlert($rootScope, $filter) { var swal = window.swal; return { alert: function (arg1, arg2, arg3) { $(".sweet-alert, .sweet-overlay").remove(); $rootScope.$evalAsync(function () { if (typeof (arg2) === 'function') { swal(arg1, function (isConfirm) { $rootScope.$evalAsync(function () { arg2(isConfirm); }); }, arg3); } else { swal(arg1, arg2, arg3); } }); }, areYouSure: function (title, message, onConfirm, confirmTxt, cancelTxt) { $(".sweet-alert, .sweet-overlay").remove(); $rootScope.$evalAsync(function () { if (typeof (onConfirm) === 'function') { if (confirmTxt === undefined) confirmTxt = $filter('translate')('YES'); if (cancelTxt === undefined) cancelTxt = $filter('translate')('NO'); swal({ "title": title, "text": message, html: true, type: "warning", showCancelButton: true, confirmButtonColor: "#f7a54a", confirmButtonText: confirmTxt, cancelButtonText: cancelTxt, closeOnConfirm: true, closeOnCancel: true }, function (isConfirm) { if (isConfirm) { $rootScope.$evalAsync(function () { onConfirm(); }); } }); } else { throw "parameter 3 must be a function"; } }); }, success: function (title, message, confirmTxt) { $(".sweet-alert, .sweet-overlay").remove(); if (confirmTxt === undefined) confirmTxt = $filter('translate')('OK'); $rootScope.$evalAsync(function () { swal({ "title": title, "text": message, html: true, type: "success", confirmButtonColor: "#18a689", confirmButtonText: confirmTxt, closeOnConfirm: true }); }); }, error: function (title, message, confirmTxt) { $(".sweet-alert, .sweet-overlay").remove(); if (confirmTxt === undefined) confirmTxt = $filter('translate')('OK'); $rootScope.$evalAsync(function () { swal({ "title": title, "text": message, html: true, type: "error", confirmButtonColor: "#ec4758", confirmButtonText: confirmTxt, closeOnConfirm: true }); }); }, serverError: function (messageToAppend, confirmTxt) { $(".sweet-alert, .sweet-overlay").remove(); if (confirmTxt === undefined) confirmTxt = $filter('translate')('OK'); var message = '
' + $filter('translate')('SERVER_ERROR_MESSAGE') + '
'; if (messageToAppend !== undefined) { message += '