MDL-72688 contentbank: Add and maintain appropriate aria roles
[moodle.git] / contentbank / amd / build / sort.min.js.map
blobf5c1aa4015a2bcd29b49b089a26d0a766c042263
1 {"version":3,"sources":["../src/sort.js"],"names":["init","contentBank","document","querySelector","selectors","regions","contentbank","Prefetch","prefetchStrings","registerListenerEvents","addEventListener","e","viewList","actions","viewlist","viewGrid","viewgrid","fileArea","filearea","shownItems","querySelectorAll","elements","listitem","target","closest","classList","remove","add","setAttribute","forEach","listItem","cell","removeAttribute","heading","setViewListPreference","sortByName","sortname","ascending","updateSortButtons","updateSortOrder","sortByUses","sortuses","sortByDate","sortdate","sortBySize","sortsize","sortByType","sorttype","sortByAuthor","sortauthor","request","methodname","args","preferences","type","value","Ajax","call","catch","Notification","exception","sortButton","sortButtons","sortbutton","button","updateButtonTitle","contains","sortString","dataset","string","then","columnName","sortByString","itemList","attribute","sortList","slice","sort","a","b","aa","getAttribute","bb","isNaN","parseInt","appendChild"],"mappings":"uNAuBA,OAEA,OACA,OACA,O,mDAOO,GAAMA,CAAAA,CAAI,CAAG,UAAM,CACtB,GAAMC,CAAAA,CAAW,CAAGC,QAAQ,CAACC,aAAT,CAAuBC,UAAUC,OAAV,CAAkBC,WAAzC,CAApB,CACAC,UAASC,eAAT,CAAyB,aAAzB,CAAwC,CAAC,aAAD,CAAgB,MAAhB,CAAwB,cAAxB,CAAwC,MAAxC,CAAgD,MAAhD,CAAwD,QAAxD,CAAxC,EACAD,UAASC,eAAT,CAAyB,QAAzB,CAAmC,CAAC,SAAD,CAAY,gBAAZ,CAAnC,EACAC,CAAsB,CAACR,CAAD,CACzB,CALM,C,YAaDQ,CAAAA,CAAsB,CAAG,SAACR,CAAD,CAAiB,CAE5CA,CAAW,CAACS,gBAAZ,CAA6B,OAA7B,CAAsC,SAAAC,CAAC,CAAI,IACjCC,CAAAA,CAAQ,CAAGX,CAAW,CAACE,aAAZ,CAA0BC,UAAUS,OAAV,CAAkBC,QAA5C,CADsB,CAEjCC,CAAQ,CAAGd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6B4C,CAA7B,EACA,MAAOA,CAAAA,CACV,CAPM,EAQNd,KARM,EASV,C,CAWKnB,CAAe,CAAG,SAACtB,CAAD,CAAWwD,CAAX,CAAqBC,CAArB,CAAgCrC,CAAhC,CAA8C,CAClE,GAAMsC,CAAAA,CAAQ,CAAG,GAAGC,KAAH,CAASnB,IAAT,CAAcgB,CAAd,EAAwBI,IAAxB,CAA6B,SAASC,CAAT,CAAYC,CAAZ,CAAe,IAErDC,CAAAA,CAAE,CAAGF,CAAC,CAACG,YAAF,CAAeP,CAAf,CAFgD,CAGrDQ,CAAE,CAAGH,CAAC,CAACE,YAAF,CAAeP,CAAf,CAHgD,CAIzD,GAAI,CAACS,KAAK,CAACH,CAAD,CAAV,CAAgB,CACbA,CAAE,CAAGI,QAAQ,CAACJ,CAAD,CAAb,CACAE,CAAE,CAAGE,QAAQ,CAACF,CAAD,CACf,CAED,GAAI7C,CAAJ,CAAe,CACX,MAAO2C,CAAAA,CAAE,CAAGE,CAAL,CAAU,CAAV,CAAc,CAAC,CACzB,CAFD,IAEO,CACH,MAAOF,CAAAA,CAAE,CAAGE,CAAL,CAAU,CAAV,CAAc,CAAC,CACzB,CACJ,CAdgB,CAAjB,CAeAP,CAAQ,CAAC9C,OAAT,CAAiB,SAAAC,CAAQ,QAAIb,CAAAA,CAAQ,CAACoE,WAAT,CAAqBvD,CAArB,CAAJ,CAAzB,CACH,C","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 * Content bank UI actions.\n *\n * @module     core_contentbank/sort\n * @copyright  2020 Bas Brands <bas@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport selectors from './selectors';\nimport {get_string as getString} from 'core/str';\nimport Prefetch from 'core/prefetch';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Set up the contentbank views.\n *\n * @method init\n */\nexport const init = () => {\n    const contentBank = document.querySelector(selectors.regions.contentbank);\n    Prefetch.prefetchStrings('contentbank', ['contentname', 'uses', 'lastmodified', 'size', 'type', 'author']);\n    Prefetch.prefetchStrings('moodle', ['sortbyx', 'sortbyxreverse']);\n    registerListenerEvents(contentBank);\n};\n\n/**\n * Register contentbank related event listeners.\n *\n * @method registerListenerEvents\n * @param {HTMLElement} contentBank The DOM node of the content bank\n */\nconst registerListenerEvents = (contentBank) => {\n\n    contentBank.addEventListener('click', e => {\n        const viewList = contentBank.querySelector(selectors.actions.viewlist);\n        const viewGrid = contentBank.querySelector(selectors.actions.viewgrid);\n        const fileArea = contentBank.querySelector(selectors.regions.filearea);\n        const shownItems = fileArea.querySelectorAll(selectors.elements.listitem);\n\n        // View as Grid button.\n        if (e.target.closest(selectors.actions.viewgrid)) {\n            contentBank.classList.remove('view-list');\n            contentBank.classList.add('view-grid');\n            if (fileArea && shownItems) {\n                fileArea.setAttribute('role', 'list');\n                shownItems.forEach(listItem => {\n                    listItem.setAttribute('role', 'listitem');\n                    listItem.querySelectorAll(selectors.elements.cell).forEach(cell => cell.removeAttribute('role'));\n                });\n\n                const heading = fileArea.querySelector(selectors.elements.heading);\n                heading.removeAttribute('role');\n                heading.querySelectorAll(selectors.elements.cell).forEach(cell => cell.removeAttribute('role'));\n            }\n            viewGrid.classList.add('active');\n            viewList.classList.remove('active');\n            setViewListPreference(false);\n\n            return;\n        }\n\n        // View as List button.\n        if (e.target.closest(selectors.actions.viewlist)) {\n            contentBank.classList.remove('view-grid');\n            contentBank.classList.add('view-list');\n            if (fileArea && shownItems) {\n                fileArea.setAttribute('role', 'table');\n                shownItems.forEach(listItem => {\n                    listItem.setAttribute('role', 'row');\n                    listItem.querySelectorAll(selectors.elements.cell).forEach(cell => cell.setAttribute('role', 'cell'));\n                });\n\n                const heading = fileArea.querySelector(selectors.elements.heading);\n                heading.setAttribute('role', 'row');\n                heading.querySelectorAll(selectors.elements.cell).forEach(cell => cell.setAttribute('role', 'columnheader'));\n            }\n            viewList.classList.add('active');\n            viewGrid.classList.remove('active');\n            setViewListPreference(true);\n\n            return;\n        }\n\n        if (fileArea && shownItems) {\n\n            // Sort by file name alphabetical\n            const sortByName = e.target.closest(selectors.actions.sortname);\n            if (sortByName) {\n                const ascending = updateSortButtons(contentBank, sortByName);\n                updateSortOrder(fileArea, shownItems, 'data-file', ascending);\n                return;\n            }\n\n            // Sort by uses.\n            const sortByUses = e.target.closest(selectors.actions.sortuses);\n            if (sortByUses) {\n                const ascending = updateSortButtons(contentBank, sortByUses);\n                updateSortOrder(fileArea, shownItems, 'data-uses', ascending);\n                return;\n            }\n\n            // Sort by date.\n            const sortByDate = e.target.closest(selectors.actions.sortdate);\n            if (sortByDate) {\n                const ascending = updateSortButtons(contentBank, sortByDate);\n                updateSortOrder(fileArea, shownItems, 'data-timemodified', ascending);\n                return;\n            }\n\n            // Sort by size.\n            const sortBySize = e.target.closest(selectors.actions.sortsize);\n            if (sortBySize) {\n                const ascending = updateSortButtons(contentBank, sortBySize);\n                updateSortOrder(fileArea, shownItems, 'data-bytes', ascending);\n                return;\n            }\n\n            // Sort by type.\n            const sortByType = e.target.closest(selectors.actions.sorttype);\n            if (sortByType) {\n                const ascending = updateSortButtons(contentBank, sortByType);\n                updateSortOrder(fileArea, shownItems, 'data-type', ascending);\n                return;\n            }\n\n            // Sort by author.\n            const sortByAuthor = e.target.closest(selectors.actions.sortauthor);\n            if (sortByAuthor) {\n                const ascending = updateSortButtons(contentBank, sortByAuthor);\n                updateSortOrder(fileArea, shownItems, 'data-author', ascending);\n            }\n            return;\n        }\n    });\n};\n\n\n/**\n * Set the contentbank user preference in list view\n *\n * @param  {Bool} viewList view ContentBank as list.\n * @return {Promise} Repository promise.\n */\nconst setViewListPreference = function(viewList) {\n\n    // If the given status is not hidden, the preference has to be deleted with a null value.\n    if (viewList === false) {\n        viewList = null;\n    }\n\n    const request = {\n        methodname: 'core_user_update_user_preferences',\n        args: {\n            preferences: [\n                {\n                    type: 'core_contentbank_view_list',\n                    value: viewList\n                }\n            ]\n        }\n    };\n\n    return Ajax.call([request])[0].catch(Notification.exception);\n};\n\n/**\n * Update the sort button view.\n *\n * @method updateSortButtons\n * @param {HTMLElement} contentBank The DOM node of the contentbank button\n * @param {HTMLElement} sortButton The DOM node of the sort button\n * @return {Bool} sort ascending\n */\nconst updateSortButtons = (contentBank, sortButton) => {\n    const sortButtons = contentBank.querySelectorAll(selectors.elements.sortbutton);\n\n    sortButtons.forEach((button) => {\n        if (button !== sortButton) {\n            button.classList.remove('dir-asc');\n            button.classList.remove('dir-desc');\n            button.classList.add('dir-none');\n\n            updateButtonTitle(button, false);\n        }\n    });\n\n    let ascending = true;\n\n    if (sortButton.classList.contains('dir-none')) {\n        sortButton.classList.remove('dir-none');\n        sortButton.classList.add('dir-asc');\n    } else if (sortButton.classList.contains('dir-asc')) {\n        sortButton.classList.remove('dir-asc');\n        sortButton.classList.add('dir-desc');\n        ascending = false;\n    } else if (sortButton.classList.contains('dir-desc')) {\n        sortButton.classList.remove('dir-desc');\n        sortButton.classList.add('dir-asc');\n    }\n\n    updateButtonTitle(sortButton, ascending);\n\n    return ascending;\n};\n\n/**\n * Update the button title.\n *\n * @method updateButtonTitle\n * @param {HTMLElement} button Button to update\n * @param {Bool} ascending Sort direction\n * @return {Promise} string promise\n */\nconst updateButtonTitle = (button, ascending) => {\n\n    const sortString = (ascending ? 'sortbyxreverse' : 'sortbyx');\n\n    return getString(button.dataset.string, 'contentbank')\n    .then(columnName => {\n        return getString(sortString, 'core', columnName);\n    })\n    .then(sortByString => {\n        button.setAttribute('title', sortByString);\n        return sortByString;\n    })\n    .catch();\n};\n\n/**\n * Update the sort order of the itemlist and update the DOM\n *\n * @method updateSortOrder\n * @param {HTMLElement} fileArea the Dom container for the itemlist\n * @param {Array} itemList Nodelist of Dom elements\n * @param {String} attribute the attribut to sort on\n * @param {Bool} ascending Sort Ascending\n */\nconst updateSortOrder = (fileArea, itemList, attribute, ascending) => {\n    const sortList = [].slice.call(itemList).sort(function(a, b) {\n\n        let aa = a.getAttribute(attribute);\n        let bb = b.getAttribute(attribute);\n        if (!isNaN(aa)) {\n           aa = parseInt(aa);\n           bb = parseInt(bb);\n        }\n\n        if (ascending) {\n            return aa > bb ? 1 : -1;\n        } else {\n            return aa < bb ? 1 : -1;\n        }\n    });\n    sortList.forEach(listItem => fileArea.appendChild(listItem));\n};\n"],"file":"sort.min.js"}