Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/message/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/message/amd/build/message_drawer_view_contacts_section_contacts.min.js.map

{"version":3,"sources":["../src/message_drawer_view_contacts_section_contacts.js"],"names":["define","$","Notification","PubSub","Templates","MessageRepository","Events","LazyLoadList","SELECTORS","BLOCK_ICON_CONTAINER","CONTACT","CONTENT_CONTAINER","TEMPLATES","CONTACTS_LIST","findContact","body","userId","find","render","contentContainer","contacts","formattedContacts","map","contact","extend","id","userid","then","html","append","catch","exception","getLoadFunction","offset","listRoot","getContacts","result","length","pop","setLoadedAll","removeContact","remove","showContactBlocked","removeClass","showContactUnblocked","addClass","registerEventListeners","root","subscribe","CONTACT_ADDED","profile","listContentContainer","getContentContainer","hideEmptyMessage","showContent","CONTACT_REMOVED","hideContent","showEmptyMessage","CONTACT_BLOCKED","CONTACT_UNBLOCKED","show","attr"],"mappings":"AAuBAA,OAAM,8DACN,CACI,QADJ,CAEI,mBAFJ,CAGI,aAHJ,CAII,gBAJJ,CAKI,iCALJ,CAMI,oCANJ,CAOI,4CAPJ,CADM,CAUN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQE,IAKMC,CAAAA,CAAS,CAAG,CACZC,oBAAoB,CAAE,wCADV,CAEZC,OAAO,CAAE,2BAFG,CAGZC,iBAAiB,CAAE,8CAHP,CALlB,CAWMC,CAAS,CAAG,CACZC,aAAa,CAAE,2CADH,CAXlB,CAsBMC,CAAW,CAAG,SAASC,CAAT,CAAeC,CAAf,CAAuB,CACrC,MAAOD,CAAAA,CAAI,CAACE,IAAL,CAAU,2BAA4BD,CAA5B,CAAqC,KAA/C,CACV,CAxBH,CAiCME,CAAM,CAAG,SAASC,CAAT,CAA2BC,CAA3B,CAAqC,CAC9C,GAAIC,CAAAA,CAAiB,CAAGD,CAAQ,CAACE,GAAT,CAAa,SAASC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AACoD,eAAxB,CAAyC,SAAS1C,CAAT,CAAiB,CACtD0B,CAAkB,CAACK,CAAD,CAAO/B,CAAP,CACrB,CAFD,EAIAb,CAAM,CAAC6C,SAAP,CAAiB1C,CAAM,CAACqD,iBAAxB,CAA2C,SAAS3C,CAAT,CAAiB,CACxD4B,CAAoB,CAACG,CAAD,CAAO/B,CAAP,CACvB,CAFD,CAGH,CA3IH,CA4JE,MAAO,CACH4C,IAAI,CAXG,QAAPA,CAAAA,IAAO,CAASb,CAAT,CAAe,CACtB,GAAI,CAACA,CAAI,CAACc,IAAL,CAAU,oBAAV,CAAL,CAAsC,CAClCf,CAAsB,CAACC,CAAD,CAAtB,CACAA,CAAI,CAACc,IAAL,CAAU,oBAAV,IACH,CAGDtD,CAAY,CAACqD,IAAb,CAAkBb,CAAlB,CAAwBf,CAAe,CAtJvB,CAsJuB,CAAvC,CAAwDd,CAAxD,CACH,CAEM,CAGV,CAjLK,CAAN","sourcesContent":["// 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/**\n * Controls the contacts section of the contacts page.\n *\n * @module     core_message/message_drawer_view_contacts_section_contacts\n * @package    message\n * @copyright  2018 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n    'jquery',\n    'core/notification',\n    'core/pubsub',\n    'core/templates',\n    'core_message/message_repository',\n    'core_message/message_drawer_events',\n    'core_message/message_drawer_lazy_load_list'\n],\nfunction(\n    $,\n    Notification,\n    PubSub,\n    Templates,\n    MessageRepository,\n    Events,\n    LazyLoadList\n) {\n\n    var limit = 100;\n    var initialOffset = 0;\n\n    var SELECTORS = {\n        BLOCK_ICON_CONTAINER: '[data-region=\"block-icon-container\"]',\n        CONTACT: '[data-region=\"contact\"]',\n        CONTENT_CONTAINER: '[data-region=\"contacts-content-container\"]'\n    };\n\n    var TEMPLATES = {\n        CONTACTS_LIST: 'core_message/message_drawer_contacts_list'\n    };\n\n    /**\n     * Find a contact element.\n     *\n     * @param {Object} body Contacts body container element.\n     * @param {Number} userId User id of contact.\n     * @return {Object} contact element.\n     */\n    var findContact = function(body, userId) {\n        return body.find('[data-contact-user-id=\"' + userId + '\"]');\n    };\n\n    /**\n     * Render the contacts in the content container.\n     *\n     * @param {Object} contentContainer Content container element.\n     * @param {Array} contacts List of contacts.\n     * @return {Object} jQuery promise\n     */\n    var render = function(contentContainer, contacts) {\n        var formattedContacts = contacts.map(function(contact) {\n            return $.extend(contact, {id: contact.userid});\n        });\n        return Templates.render(TEMPLATES.CONTACTS_LIST, {contacts: formattedContacts})\n            .then(function(html) {\n                contentContainer.append(html);\n                return html;\n            })\n            .catch(Notification.exception);\n    };\n\n    /**\n     * Load the user contacts and call the renderer.\n     *\n     * @param {Number} offset The offset to use for loading contacts\n     * @return {Function} the callback.\n     */\n    var getLoadFunction = function(offset) {\n        return function(listRoot, userId) {\n            return MessageRepository.getContacts(userId, (limit + 1), offset)\n                .then(function(result) {\n                    return result;\n                })\n                .then(function(contacts) {\n                    if (contacts.length > limit) {\n                        contacts.pop();\n                    } else {\n                        LazyLoadList.setLoadedAll(listRoot, true);\n                    }\n                    return contacts;\n                })\n                .then(function(contacts) {\n                    offset = offset + limit;\n                    return contacts;\n                })\n                .catch(Notification.exception);\n        };\n    };\n\n    /**\n     * Remove contact from view.\n     *\n     * @param {Object} body Contacts body container element.\n     * @param {Number} userId Contact userid.\n     */\n    var removeContact = function(body, userId) {\n        findContact(body, userId).remove();\n    };\n\n    /**\n     * Show the contact has been blocked.\n     *\n     * @param {Object} body Contacts body container element.\n     * @param {Number} userId Contact userid.\n     */\n    var showContactBlocked = function(body, userId) {\n        var contact = findContact(body, userId);\n        if (contact.length) {\n            contact.find(SELECTORS.BLOCK_ICON_CONTAINER).removeClass('hidden');\n        }\n    };\n\n    /**\n     * Show the contact has been unblocked.\n     *\n     * @param {Object} body Contacts body container element.\n     * @param {Number} userId Contact userid.\n     */\n    var showContactUnblocked = function(body, userId) {\n        var contact = findContact(body, userId);\n        if (contact.length) {\n            contact.find(SELECTORS.BLOCK_ICON_CONTAINER).addClass('hidden');\n        }\n    };\n\n    /**\n     * Listen to and handle events for contacts.\n     *\n     * @param {Object} root Contacts section container element.\n     */\n    var registerEventListeners = function(root) {\n        PubSub.subscribe(Events.CONTACT_ADDED, function(profile) {\n            var listContentContainer = LazyLoadList.getContentContainer(root);\n            render(listContentContainer, [profile]);\n            LazyLoadList.hideEmptyMessage(root);\n            LazyLoadList.showContent(root);\n        });\n\n        PubSub.subscribe(Events.CONTACT_REMOVED, function(userId) {\n            removeContact(root, userId);\n            var contacts = root.find(SELECTORS.CONTACT);\n\n            if (!contacts.length) {\n                LazyLoadList.hideContent(root);\n                LazyLoadList.showEmptyMessage(root);\n            }\n        });\n\n        PubSub.subscribe(Events.CONTACT_BLOCKED, function(userId) {\n            showContactBlocked(root, userId);\n        });\n\n        PubSub.subscribe(Events.CONTACT_UNBLOCKED, function(userId) {\n            showContactUnblocked(root, userId);\n        });\n    };\n\n    /**\n     * Setup the contacts section.\n     *\n     * @param {Object} root Contacts section container.\n     */\n    var show = function(root) {\n        if (!root.attr('data-contacts-init')) {\n            registerEventListeners(root);\n            root.attr('data-contacts-init', true);\n        }\n\n        // The root element is already the lazy loaded list root.\n        LazyLoadList.show(root, getLoadFunction(initialOffset), render);\n    };\n\n    return {\n        show: show,\n    };\n});\n"],"file":"message_drawer_view_contacts_section_contacts.min.js"}