Sindbad~EG File Manager
{"version":3,"file":"ajax_notification.min.js","sources":["../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 <http://www.gnu.org/licenses/>.\n *\n * @package\n * @author Guy Thomas\n * @copyright Copyright (c) 2016 Open LMS\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/ajax', 'core/templates', 'core/str', 'theme_snap/util'],\n\n function($, notification, ajax, templates, str, util) {\n\n // Module level variables.\n var loginErrorShown = false;\n var loggingOut = false;\n var redirectInProgress = false;\n\n // Module level code.\n $(document).ready(function() {\n $('#snap-pm-logout').click(function() {\n loggingOut = true;\n });\n });\n\n /**\n * This feature is simply to work around this issue - MDL-54551.\n * If the core moodle issue is ever fixed we might not require this module.\n */\n return {\n\n /**\n * If there is an error in this response then show the best error message for the user.\n *\n * @param {object} response\n * @param {string} failAction\n * @param {string} failMsg\n * @returns {function} promise - resolves with a boolean (true if error shown)\n */\n ifErrorShowBestMsg: function(response, failAction, failMsg) {\n\n var dfd = $.Deferred();\n\n /**\n * Error notification function for non logged out issues.\n * @param {object} response\n * @returns {function} promise\n */\n var errorNotification = function(response) {\n var endfd = $.Deferred();\n if (failMsg) {\n notification.alert(M.util.get_string('error', 'moodle'),\n failMsg, M.util.get_string('ok', 'moodle'));\n } else {\n if (response.backtrace) {\n notification.exception(response);\n } else {\n var errorstr;\n if (response.error) {\n errorstr = response.error;\n if (response.stacktrace) {\n errorstr = '<div>' + errorstr + '<pre>' + 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('<br />' + 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 $('<style>' +\n '.confirmation-dialogue .confirmation-buttons input:nth-of-type(2), ' +\n '.moodle-dialogue-base.moodle-dialogue-confirm button.yui3-button.closebutton' +\n '{ display : none }' +\n '</style>'\n ).appendTo('head');\n notification.confirm(\n thisResp.loggedouttitle,\n thisResp.loggedoutmsg,\n thisResp.loggedoutcontinue,\n ' ',\n function() {\n window.location = M.cfg.wwwroot + '/login/index.php';\n }\n );\n loginErrorShown = true;\n dfd.resolve(true);\n return dfd.promise();\n } else {\n // This is not a login issue, show original error message.\n return errorNotification(response); // Returns promise which is resolved when dialog shown.\n }\n });\n }\n\n dfd.resolve(false);\n return dfd.promise();\n }\n };\n }\n);\n"],"names":["define","$","notification","ajax","templates","str","util","loginErrorShown","loggingOut","redirectInProgress","document","ready","click","ifErrorShowBestMsg","response","failAction","failMsg","dfd","Deferred","resolve","promise","jsonObj","JSON","parse","e","errorcode","redirect","M","cfg","wwwroot","window","location","is","error","snapTheme","forcePassChange","pwdChangeUrl","length","get_string","then","forcePwdWarning","alertMsg","render","result","html","type","async","data","sesskey","url","thisResp","loggedin","endfd","alert","backtrace","exception","errorstr","stacktrace","message","whenTrue","errorNotification","appendTo","confirm","loggedouttitle","loggedoutmsg","loggedoutcontinue"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBAA,sCAAO,CAAC,SAAU,oBAAqB,YAAa,iBAAkB,WAAY,oBAE9E,SAASC,EAAGC,aAAcC,KAAMC,UAAWC,IAAKC,UAGxCC,iBAAkB,EAClBC,YAAa,EACbC,oBAAqB,SAGzBR,EAAES,UAAUC,OAAM,WACdV,EAAE,mBAAmBW,OAAM,WACvBJ,YAAa,QAQd,CAUHK,mBAAoB,SAASC,SAAUC,WAAYC,aAE3CC,IAAMhB,EAAEiB,cA4CRX,uBAEAU,IAAIE,SAAQ,GACLF,IAAIG,aAGXZ,kBAEAS,IAAIE,SAAQ,GACLF,IAAIG,aAGS,iBAAbN,iBAECO,QAAUC,KAAKC,MAAMT,UACzBA,SAAWO,QACb,MAAOG,YAKW,IAAbV,gBAEA,KAGPA,SAASW,WAAoC,wBAAvBX,SAASW,UAAqC,KAChEC,SAAWC,EAAEC,IAAIC,QAAU,0BAC3BC,OAAOC,UAAYL,WAAajB,oBAAsBR,EAAE,gBAAgB+B,GAAG,aAC3EF,OAAOC,SAAWL,SAElBjB,oBAAqB,EACrBF,iBAAkB,EAClBU,IAAIE,SAAQ,IAEZF,IAAIE,SAAQ,GAETF,IAAIG,aAGXN,SAASmB,OAASnB,SAASW,UAAW,IAElCE,EAAEO,UAAUC,gBAAiB,KACzBC,aAAeT,EAAEC,IAAIC,QAAU,oCAG/B5B,EAAE,oBAAoBoC,SACtBhC,IAAIiC,WAAW,8BAA+B,aAAcF,cAAcG,MACtE,SAASC,qBACDC,SAAW,SAAYD,6BAAiC,4BACrDpC,UAAUsC,OAAO,4BAA6BD,aAE3DF,MACE,SAASI,QACL1C,EAAE,oBAAoB2C,KAAK,SAAWD,QACtC1B,IAAIE,SAAQ,M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