{"version":3,"file":"messages.min.js","sources":["https:\/\/e-learning.fra.europa.eu\/theme\/snap\/amd\/src\/messages.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 .\n *\n * @package\n * @author Juan Ibarra juan.ibarra@openlms.net\n * @copyright Copyright (c) 2019 Open LMS (https:\/\/www.openlms.net)\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\n\/**\n * JS code to manage hide\/show of full width messages drawer.\n *\/\ndefine(['jquery', 'core\/pubsub'],\n function($, PubSub) {\n \/\/ Array to control which popovers are open.\n var openedpopovers = [];\n \/\/ Maximum size in pixels to consider a mobile screen\n var maxWidth = 560;\n\n return {\n init: function() {\n \/\/ Listener for the admin block.\n if ($('.preferences-page-container').length === 0 && $('.message-app.main').length === 0 &&\n ($('#page-message-edit').length != 0 || $('#page-message-index').length != 0)) {\n var drawermessage = $('.drawer .message-app');\n drawermessage.css('visibility', 'visible');\n drawermessage.animate({width: '100%'}, 0);\n document.addEventListener(\"messages-drawer:toggle\", function () {\n if ($('#page-message-edit').length || $('#page-message-index').length) {\n if ($('.block_settings').hasClass('state-visible')) {\n if ($(window).width() < maxWidth) {\n $('.drawer .message-app').hide();\n } else {\n $('.drawer .message-app').animate({width: '50%'}, 0);\n }\n } else {\n if ($(window).width() < maxWidth) {\n $('.drawer .message-app').show();\n } else {\n $('.drawer .message-app').animate({width: '100%'}, 0);\n }\n }\n }\n });\n \/\/ Listener for the personal menu.\n document.addEventListener(\"messages-drawer:pm-toggle\", function () {\n if ($('#page-message-edit').length || $('#page-message-index').length) {\n if ($('.snap-pm-open').length) {\n $('.drawer .message-app').hide();\n } else {\n $('.drawer .message-app').show();\n }\n }\n });\n \/\/ Listeners for popovers.\n var popover = $('div.popover-region');\n popover.on('popoverregion:menuopened', function () {\n if ($('#page-message-edit').length || $('#page-message-index').length) {\n var popovername = $(this).attr(\"id\");\n if (openedpopovers.indexOf(popovername) == -1) {\n openedpopovers.push(popovername);\n }\n \/\/ If there are open popovers, hide message-drawer.\n if (openedpopovers.length > 0) {\n if ($(window).width() < maxWidth) {\n $('.drawer .message-app').hide();\n } else {\n $('.drawer .message-app').animate({width: '50%'}, 0);\n }\n }\n }\n }).bind();\n popover.on('popoverregion:menuclosed', function () {\n if ($('#page-message-edit').length || $('#page-message-index').length) {\n var popovername = $(this).attr(\"id\");\n var index = openedpopovers.indexOf(popovername);\n openedpopovers.splice(index, 1);\n \/\/ Only open drawer when there are no opened popovers.\n if (openedpopovers.length == 0) {\n if ($(window).width() < maxWidth) {\n $('.drawer .message-app').show();\n } else {\n $('.drawer .message-app').animate({width: '100%'}, 0);\n }\n }\n }\n }).bind();\n \/\/ Listener for the page user profile to load messages URL.\n } else if ($('#page-user-profile').length != 0 || $('.userprofile #message-user-button').length != 0\n || $('#page-grade-report-user-index').length != 0) {\n $('#page-grade-report-user-index [id^=\"drawer-\"].drawer[role=\"region\"]').css('display', 'none');\n PubSub.subscribe(\"message-drawer-create-conversation-with-user\", function (args) {\n redirectToMessage(args);\n });\n \/\/ The drawer in snap will always open in a new window\n PubSub.subscribe(\"message-drawer-show-conversation\", function (args) {\n redirectToMessage(args);\n });\n }\n var redirectToMessage = function(args) {\n let processedId = '';\n if (typeof args === 'object' && args.userid) {\n processedId = parseInt(args.userid);\n } else {\n processedId = parseInt(args);\n }\n const moodleurl = M.cfg.wwwroot;\n window.location = moodleurl.concat('\/message\/index.php?id=', processedId);\n };\n },\n };\n }\n);\n"],"names":["define","$","PubSub","openedpopovers","init","length","css","subscribe","args","redirectToMessage","drawermessage","animate","width","document","addEventListener","hasClass","window","hide","show","popover","on","popovername","this","attr","indexOf","push","bind","index","splice","processedId","userid","parseInt","moodleurl","M","cfg","wwwroot","location","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBAA,6BAAO,CAAC,SAAU,gBACd,SAASC,EAAGC,YAEJC,eAAiB,SAId,CACHC,KAAM,cAE8C,IAA5CH,EAAE,+BAA+BI,QAAkD,IAAlCJ,EAAE,qBAAqBI,QACjC,GAAlCJ,EAAE,sBAAsBI,QAAkD,GAAnCJ,EAAE,uBAAuBI,OAiE5B,GAAlCJ,EAAE,sBAAsBI,QAAgE,GAAjDJ,EAAE,qCAAqCI,QACrC,GAA7CJ,EAAE,iCAAiCI,SACtCJ,EAAE,uEAAuEK,IAAI,UAAW,QACxFJ,OAAOK,UAAU,gDAAgD,SAAUC,MACvEC,kBAAkBD,SAGtBN,OAAOK,UAAU,oCAAoC,SAAUC,MAC3DC,kBAAkBD,cAzE6D,KAC\/EE,cAAgBT,EAAE,wBACtBS,cAAcJ,IAAI,aAAc,WAChCI,cAAcC,QAAQ,CAACC,MAAO,QAAS,GACvCC,SAASC,iBAAiB,0BAA0B,YAC5Cb,EAAE,sBAAsBI,QAAUJ,EAAE,uBAAuBI,UACvDJ,EAAE,mBAAmBc,SAAS,iBAC1Bd,EAAEe,QAAQJ,QAbvB,IAcaX,EAAE,wBAAwBgB,OAE1BhB,EAAE,wBAAwBU,QAAQ,CAACC,MAAO,OAAQ,GAGlDX,EAAEe,QAAQJ,QAnBvB,IAoBaX,EAAE,wBAAwBiB,OAE1BjB,EAAE,wBAAwBU,QAAQ,CAACC,MAAO,QAAS,OAMnEC,SAASC,iBAAiB,6BAA6B,YAC\/Cb,EAAE,sBAAsBI,QAAUJ,EAAE,uBAAuBI,UACvDJ,EAAE,iBAAiBI,OACnBJ,EAAE,wBAAwBgB,OAE1BhB,EAAE,wBAAwBiB,eAKlCC,QAAUlB,EAAE,sBAChBkB,QAAQC,GAA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