Sindbad~EG File Manager
{"version":3,"file":"conversation_badge_count-lazy.min.js","sources":["../src/conversation_badge_count-lazy.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 David Castro <david.castro@openlms.net>\n * @copyright Copyright (c) 2017 Open LMS\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module theme_snap/conversation_badge_count-lazy\n */\ndefine(['jquery', 'core/ajax','core/str'],\n function($, Ajax, Str) {\n var self = this;\n\n /**\n * Initialising function.\n * @param {int} userid The user id\n * @param {int} conversationId The conversation to mark as read\n */\n self.init = function(userid, conversationId) {\n self.userid = userid;\n // Container.\n self.containerEl = $('.conversation_badge_count');\n // Check if the request comes from a conversation element.\n if (conversationId) {\n $(document).ajaxComplete(function(event, xhr, settings) {\n if (settings.url.includes('core_message_mark_all_conversation_messages_as_read')) {\n self.queryCount();\n $(document).off('ajaxComplete');\n }\n });\n } else {\n self.queryCount();\n }\n };\n\n /**\n * Count the number of unread conversations (one or more messages from a user)\n * for a given user.\n *\n * @param {object} args The request arguments:\n * @return {object} jQuery promise\n */\n self.countUnreadConversations = function(args) {\n var request = {\n methodname: 'core_message_get_unread_conversations_count',\n args: args\n };\n\n var promise = Ajax.call([request])[0];\n\n promise.fail(self.resetCount);\n\n return promise;\n };\n\n /**\n * Query message repository for conversation count.\n */\n self.queryCount = function() {\n self.countUnreadConversations({useridto: self.userid}).then(self.updateCount);\n };\n\n /**\n * Updates the badge conversation count.\n * @param {int} count\n */\n self.updateCount = function(count) {\n if (count > 0) {\n self.containerEl.text(count);\n self.containerEl.removeClass(\"hidden\");\n } else {\n self.containerEl.text('');\n self.containerEl.addClass(\"hidden\");\n }\n var text = $('.snap-message-count');\n Str.get_string('openmessagedrawer', 'theme_snap').done(function(openstring) {\n Str.get_string('unreadconversations', 'core_message', count)\n .done(function(unreadstring) {\n text.attr('title', openstring+unreadstring);\n text.attr('aria-label', openstring+unreadstring);\n });\n });\n };\n\n /**\n * Resets the count to 0\n */\n self.resetCount = function() {\n self.updateCount(0);\n };\n\n return {\n init: self.init\n };\n }\n);\n"],"names":["define","$","Ajax","Str","self","this","init","userid","conversationId","containerEl","document","ajaxComplete","event","xhr","settings","url","includes","queryCount","off","countUnreadConversations","args","request","methodname","promise","call","fail","resetCount","useridto","then","updateCount","count","text","removeClass","addClass","get_string","done","openstring","unreadstring","attr"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBAA,kDAAO,CAAC,SAAU,YAAY,aAC1B,SAASC,EAAGC,KAAMC,SACVC,KAAOC,YAOXD,KAAKE,KAAO,SAASC,OAAQC,gBACzBJ,KAAKG,OAASA,OAEdH,KAAKK,YAAcR,EAAE,6BAEjBO,eACAP,EAAES,UAAUC,cAAa,SAASC,MAAOC,IAAKC,UACtCA,SAASC,IAAIC,SAAS,yDACtBZ,KAAKa,aACLhB,EAAES,UAAUQ,IAAI,oBAIxBd,KAAKa,cAWbb,KAAKe,yBAA2B,SAASC,UACjCC,QAAU,CACVC,WAAY,8CACZF,KAAMA,MAGNG,QAAUrB,KAAKsB,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKrB,KAAKsB,YAEXH,SAMXnB,KAAKa,WAAa,WACdb,KAAKe,yBAAyB,CAACQ,SAAUvB,KAAKG,SAASqB,KAAKxB,KAAKyB,cAOrEzB,KAAKyB,YAAc,SAASC,OACpBA,MAAQ,GACR1B,KAAKK,YAAYsB,KAAKD,OACtB1B,KAAKK,YAAYuB,YAAY,YAE7B5B,KAAKK,YAAYsB,KAAK,IACtB3B,KAAKK,YAAYwB,SAAS,eAE1BF,KAAO9B,EAAE,uBACbE,IAAI+B,WAAW,oBAAqB,cAAcC,MAAK,SAASC,YAC5DjC,IAAI+B,WAAW,sBAAuB,eAAgBJ,OACjDK,MAAK,SAASE,cACXN,KAAKO,KAAK,QAASF,WAAWC,cAC9BN,KAAKO,KAAK,aAAcF,WAAWC,qBAQnDjC,KAAKsB,WAAa,WACdtB,KAAKyB,YAAY,IAGd,CACHvB,KAAMF,KAAKE"}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists