{"version":3,"file":"ajax_notification.min.js","sources":["https:\/\/e-learning.fra.europa.eu\/theme\/snap\/amd\/src\/ajax_notification.js"],"sourcesContent":["\/**\n * This file is part of Moodle - http:\/\/moodle.org\/\n *\n * Moodle is free software: you can redistribute it and\/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * Moodle is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with Moodle. If not, see
' + response.stacktrace + '<\/pre><\/div>';\n }\n } else {\n if (response.errorcode && response.message) {\n errorstr = response.message;\n } else {\n \/\/ Don't display any error messages as we don't know what the error is.\n endfd.resolve(false);\n return endfd.promise();\n }\n }\n notification.alert(M.util.get_string('error', 'moodle'),\n errorstr, M.util.get_string('ok', 'moodle'));\n }\n }\n util.whenTrue(function() {\n var isvisible = $('.moodle-dialogue-base').is(':visible');\n return isvisible;\n }, function() {\n endfd.resolve(true);\n }, true);\n return endfd.promise();\n };\n\n if (loginErrorShown) {\n \/\/ We already have a login error message.\n dfd.resolve(true);\n return dfd.promise();\n }\n\n if (loggingOut) {\n \/\/ No point in showing error messages if we are logging out.\n dfd.resolve(true);\n return dfd.promise();\n }\n\n if (typeof response !== 'object') {\n try {\n var jsonObj = JSON.parse(response);\n response = jsonObj;\n } catch (e) {\n \/\/ Not caring about exceptions.\n }\n }\n\n if (typeof response === 'undefined') {\n \/\/ We don't know what the error was so don't show a useless unknown error dialog.\n return false;\n }\n\n if (response.errorcode && response.errorcode === \"sitepolicynotagreed\") {\n var redirect = M.cfg.wwwroot + '\/user\/policy.php';\n if (window.location != redirect && !redirectInProgress && $('#primary-nav').is(':visible')) {\n window.location = redirect;\n \/\/ Prevent further error messages from showing as a redirect is in progress.\n redirectInProgress = true;\n loginErrorShown = true;\n dfd.resolve(true);\n } else {\n dfd.resolve(false);\n }\n return dfd.promise();\n }\n\n if (response.error || response.errorcode) {\n\n if (M.snapTheme.forcePassChange) {\n var pwdChangeUrl = M.cfg.wwwroot + '\/login\/change_password.php';\n \/\/ When a force password change is in effect, warn user in personal menu and redirect to\n \/\/ password change page if appropriate.\n if ($('#snap-pm-content').length) {\n str.get_string('forcepwdwarningpersonalmenu', 'theme_snap', pwdChangeUrl).then(\n function(forcePwdWarning) {\n var alertMsg = {\"message\": forcePwdWarning, \"extraclasses\": \"force-pwd-warning\"};\n return templates.render('core\/notification_warning', alertMsg);\n }\n ).then(\n function(result) {\n $('#snap-pm-content').html('
' + result);\n dfd.resolve(true);\n }\n );\n if ($('#snap-pm-content').is(':visible')) {\n \/\/ If the personal menu is open then it should have a message in it informing the user\n \/\/ that they need to change their password to proceed.\n loginErrorShown = true;\n return dfd.promise();\n }\n }\n\n if (window.location != pwdChangeUrl) {\n window.location = pwdChangeUrl;\n }\n \/\/ Regardless of if error was shown, we only want this redirect to happen once so set\n \/\/ loginErrorShown to true.\n loginErrorShown = true;\n dfd.resolve(true);\n return dfd.promise();\n }\n\n \/\/ Ajax call login status function to see if we are logged in or not.\n \/\/ Note, we can't use a moodle web service for this ajax call because it will not provide\n \/\/ an error response that we can rely on - see MDL-54551.\n failAction = failAction ? failAction : '';\n return $.ajax({\n type: \"POST\",\n async: true,\n data: {\n \"sesskey\": M.cfg.sesskey,\n \"failedactionmsg\": failAction\n },\n url: M.cfg.wwwroot + '\/theme\/snap\/rest.php?action=get_loginstatus'\n }).then(function(thisResp) {\n if (loginErrorShown) {\n dfd.resolve(true);\n return dfd.promise();\n }\n \/\/ Show login error message or original error message.\n if (!thisResp.loggedin) {\n \/\/ Hide ALL confirmation dialog 2nd buttons and close buttons.\n \/\/ Note - this is not ideal but at this point we need to log in anyway, so not\n \/\/ an issue.\n $('