Current Path : /var/www/ljmtc/cbt/message/amd/build/ |
Current File : /var/www/ljmtc/cbt/message/amd/build/message_drawer_view_contacts.min.js.map |
{"version":3,"sources":["../src/message_drawer_view_contacts.js"],"names":["define","$","PubSub","Str","MessageDrawerEvents","ContactsSection","RequestsSection","SELECTORS","ACTION_SHOW_CONTACTS_SECTION","ACTION_SHOW_REQUESTS_SECTION","CONTACT_REQUEST_COUNT","CONTACTS_SECTION_CONTAINER","REQUESTS_SECTION_CONTAINER","getContactsSectionContainer","body","find","getRequestsSectionContainer","getShowContactsAction","getShowRequestsAction","isSectionVisible","sectionRoot","hasClass","decrementContactRequestCount","countContainer","count","parseInt","text","isNaN","addClass","registerEventListeners","contactsSection","requestsSection","showContactsAction","showRequestsAction","on","show","subscribe","CONTACT_REQUEST_ACCEPTED","CONTACT_REQUEST_DECLINED","namespace","header","footer","tab","attr","removeClass","Deferred","resolve","promise","description","get_string"],"mappings":"AAsBAA,OAAM,6CACN,CACI,QADJ,CAEI,aAFJ,CAGI,UAHJ,CAII,oCAJJ,CAKI,4DALJ,CAMI,4DANJ,CADM,CASN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOE,IAEMC,CAAAA,CAAS,CAAG,CACZC,4BAA4B,CAAE,yCADlB,CAEZC,4BAA4B,CAAE,yCAFlB,CAGZC,qBAAqB,CAAE,yCAHX,CAIZC,0BAA0B,CAAE,6BAJhB,CAKZC,0BAA0B,CAAE,6BALhB,CAFlB,CAgBMC,CAA2B,CAAG,SAASC,CAAT,CAAe,CAC7C,MAAOA,CAAAA,CAAI,CAACC,IAAL,CAAUR,CAAS,CAACI,0BAApB,CACV,CAlBH,CA0BMK,CAA2B,CAAG,SAASF,CAAT,CAAe,CAC7C,MAAOA,CAAAA,CAAI,CAACC,IAAL,CAAUR,CAAS,CAACK,0BAApB,CACV,CA5BH,CAoCMK,CAAqB,CAAG,SAASH,CAAT,CAAe,CACvC,M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CACH,CAFD,IAEO,CACHxB,CAAe,CAAC6B,IAAhB,CAAqBJ,CAArB,CACH,CAED,MAAO9B,CAAAA,CAAC,CAAC4C,QAAF,GAAaC,OAAb,GAAuBC,OAAvB,EACV,CAWM,CAEHC,WAAW,CANG,QAAdA,CAAAA,WAAc,EAAW,CACzB,MAAO7C,CAAAA,CAAG,CAAC8C,UAAJ,CAAe,2BAAf,CAA4C,cAA5C,CACV,CAEM,CAIV,CAxLK,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 page of the message drawer.\n *\n * @module core_message/message_drawer_view_contacts\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/pubsub',\n 'core/str',\n 'core_message/message_drawer_events',\n 'core_message/message_drawer_view_contacts_section_contacts',\n 'core_message/message_drawer_view_contacts_section_requests'\n],\nfunction(\n $,\n PubSub,\n Str,\n MessageDrawerEvents,\n ContactsSection,\n RequestsSection\n) {\n\n var SELECTORS = {\n ACTION_SHOW_CONTACTS_SECTION: '[data-action=\"show-contacts-section\"]',\n ACTION_SHOW_REQUESTS_SECTION: '[data-action=\"show-requests-section\"]',\n CONTACT_REQUEST_COUNT: '[data-region=\"contact-request-count\"]',\n CONTACTS_SECTION_CONTAINER: '[data-section=\"contacts\"]',\n REQUESTS_SECTION_CONTAINER: '[data-section=\"requests\"]',\n };\n\n /**\n * Get the container element for the contacts section.\n *\n * @param {Object} body Contacts page body element.\n * @return {Object}\n */\n var getContactsSectionContainer = function(body) {\n return body.find(SELECTORS.CONTACTS_SECTION_CONTAINER);\n };\n\n /**\n * Get the container element for the requests section.\n *\n * @param {Object} body Contacts page body element.\n * @return {Object}\n */\n var getRequestsSectionContainer = function(body) {\n return body.find(SELECTORS.REQUESTS_SECTION_CONTAINER);\n };\n\n /**\n * Get the element that triggers showing the contacts section.\n *\n * @param {Object} body Contacts page body element.\n * @return {Object}\n */\n var getShowContactsAction = function(body) {\n return body.find(SELECTORS.ACTION_SHOW_CONTACTS_SECTION);\n };\n\n /**\n * Get the element that triggers showing the requests section.\n *\n * @param {Object} body Contacts page body element.\n * @return {Object}\n */\n var getShowRequestsAction = function(body) {\n return body.find(SELECTORS.ACTION_SHOW_REQUESTS_SECTION);\n };\n\n /**\n * Check if the given section is visible.\n *\n * @param {Object} sectionRoot The root element for the section\n * @return {Bool}\n */\n var isSectionVisible = function(sectionRoot) {\n return sectionRoot.hasClass('active');\n };\n\n /**\n * Decrement the contact request count. If the count is zero or below then\n * hide the count.\n *\n * @param {Object} body Conversation body container element.\n * @return {Function} A function to handle decrementing the count.\n */\n var decrementContactRequestCount = function(body) {\n return function() {\n var countContainer = body.find(SELECTORS.CONTACT_REQUEST_COUNT);\n var count = parseInt(countContainer.text(), 10);\n count = isNaN(count) ? 0 : count - 1;\n\n if (count <= 0) {\n countContainer.addClass('hidden');\n } else {\n countContainer.text(count);\n }\n };\n };\n\n /**\n * Listen to and handle events for contacts.\n *\n * @param {Object} body Contacts body container element.\n */\n var registerEventListeners = function(body) {\n var contactsSection = getContactsSectionContainer(body);\n var requestsSection = getRequestsSectionContainer(body);\n var showContactsAction = getShowContactsAction(body);\n var showRequestsAction = getShowRequestsAction(body);\n\n showContactsAction.on('show.bs.tab', function() {\n ContactsSection.show(contactsSection);\n });\n\n showRequestsAction.on('show.bs.tab', function() {\n RequestsSection.show(requestsSection);\n });\n\n PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED, decrementContactRequestCount(body));\n PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED, decrementContactRequestCount(body));\n };\n\n /**\n * Setup the contact page.\n *\n * @param {string} namespace The route namespace.\n * @param {Object} header Contacts header container element.\n * @param {Object} body Contacts body container element.\n * @param {Object} footer Contacts footer container element.\n * @param {String|null} tab Tab to show, either 'requests' or 'contacts', if any.\n * @return {Object} jQuery promise\n */\n var show = function(namespace, header, body, footer, tab) {\n body = $(body);\n\n if (!body.attr('data-contacts-init')) {\n registerEventListeners(body);\n body.attr('data-contacts-init', true);\n }\n\n var contactsSection = getContactsSectionContainer(body);\n var requestsSection = getRequestsSectionContainer(body);\n\n if (tab) {\n var showContactsAction = getShowContactsAction(body);\n var showRequestsAction = getShowRequestsAction(body);\n\n // Unfortunately we need to hardcode the class changes here rather than trigger\n // the bootstrap tab functionality because the bootstrap JS doesn't appear to be\n // loaded by this point which means the tab plugin isn't added and the event listeners\n // haven't been set up so we can't just trigger a click either.\n if (tab == 'requests') {\n showContactsAction.removeClass('active');\n contactsSection.removeClass('show active');\n showRequestsAction.addClass('active');\n requestsSection.addClass('show active');\n } else {\n showRequestsAction.removeClass('active');\n requestsSection.removeClass('show active');\n showContactsAction.addClass('active');\n contactsSection.addClass('show active');\n }\n }\n\n if (isSectionVisible(contactsSection)) {\n ContactsSection.show(contactsSection);\n } else {\n RequestsSection.show(requestsSection);\n }\n\n return $.Deferred().resolve().promise();\n };\n\n /**\n * String describing this page used for aria-labels.\n *\n * @return {Object} jQuery promise\n */\n var description = function() {\n return Str.get_string('messagedrawerviewcontacts', 'core_message');\n };\n\n return {\n show: show,\n description: description\n };\n});\n"],"file":"message_drawer_view_contacts.min.js"}