{"version":3,"file":"tabs.min.js","sources":["https:\/\/hoecol.co.uk\/theme\/dynamic\/amd\/src\/tabs.js"],"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 .\n\n\/**\n * Creates dropdown layout for the profile tabs when the screen is smaller than the list.\n *\n * @module theme_dynamic\/dynamic\n * @copyright 2022 dynamic\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nexport const init = (moretext, tablist, additionalclass) => {\n\n\/**\n * Creates the moving logic.\n *\n * @param {string} moretext\n * @returns {object} Provide list to the more button.\n *\/\nlet navigationLogicSetup = {\n moreButtonWidth: 125,\n containerWidth: null,\n tabList: document.getElementById(tablist),\n tabListNodes: null,\n listWidth: 0,\n inActiveHTMLNode: document.createDocumentFragment(),\n linkstoRemove: [],\n dropdownList: document.createElement('li'),\n dropdownListAnchor: document.createElement('a'),\n setup: function(moretext) {\n this.containerWidth = document.getElementById('topofscroll').offsetWidth - (this.moreButtonWidth + 45);\n this.tabListNodes = this.tabList.getElementsByTagName('li');\n for (let i = 0; i < this.tabListNodes.length; i++) {\n this.listWidth = this.listWidth + this.tabListNodes[i].offsetWidth;\n\n if (this.listWidth > this.containerWidth) {\n this.dropdownList.classList.add('nav-item');\n \/\/ The additional class is to allow the script to work on learning history coursepage.\n \/\/ It should be reworked to not require this.\n this.dropdownList.classList.add('tab-page-button');\n if (this.tabListNodes[i].getElementsByClassName('nav-link')[0].text) {\n this.dropdownListAnchor.textContent = this.tabListNodes[i].getElementsByClassName('nav-link')[0].text;\n }\n this.dropdownListAnchor.href = this.tabListNodes[i].getElementsByClassName('nav-link')[0].getAttribute(\"href\");\n this.dropdownListAnchor.classList.add('dropdown-item');\n this.dropdownList.appendChild(this.dropdownListAnchor.cloneNode(true));\n this.inActiveHTMLNode.appendChild(this.dropdownList);\n this.linkstoRemove.push(i);\n }\n }\n \/\/ Sorts highest to lowest.\n this.linkstoRemove.sort(function(a, b) {\n return b - a;\n });\n\n for (let i = 0; i < this.linkstoRemove.length; i++) {\n this.tabListNodes[this.linkstoRemove[i]].remove();\n }\n\n if (this.listWidth > this.containerWidth) {\n this.tabList.appendChild(buttonSetup.createButton(this.inActiveHTMLNode, moretext));\n }\n }\n\n};\n\n\/**\n * Creates the more button.\n * @param {object} inActiveHTMLNode The list of links to go into dropdown.\n * @param {string} moreLanguageString is the Language string for more\n * @returns {object} Send prepared list of item to a more tab.\n *\/\nlet buttonSetup = {\n moreButton: document.createElement('li'),\n moreAnchor: document.createElement('a'),\n nestedUl: document.createElement('ul'),\n nestedLi:document.createElement('li'),\n createButton: function(inActiveHTMLNode, moreLanguageString) {\n\n this.moreButton.classList.add('nav-item', 'dropdown', 'dropdownmoremenu');\n this.moreAnchor.classList.add('dropdown-toggle', 'nav-link');\n this.moreAnchor.href = '#';\n this.moreAnchor.text = moreLanguageString;\n this.moreAnchor.ariaExpanded = \"false\";\n this.moreAnchor.setAttribute('data-toggle','dropdown');\n\n this.nestedUl.classList.add('dropdown-menu', 'dropdown-menu-left');\n\n this.nestedLi.classList.add('nav-item');\n\n this.nestedUl.append(this.nestedLi);\n this.nestedUl.append(inActiveHTMLNode);\n\n this.moreButton.append(this.moreAnchor);\n this.moreButton.append(this.nestedUl);\n\n\n return this.moreButton;\n }\n};\n\n\n navigationLogicSetup.setup(moretext);\n\n};\n\n\n\n\n"],"names":["moretext","tablist","additionalclass","navigationLogicSetup","moreButtonWidth","containerWidth","tabList","document","getElementById","tabListNodes","listWidth","inActiveHTMLNode","createDocumentFragment","linkstoRemove","dropdownList","createElement","dropdownListAnchor","setup","offsetWidth","this","getElementsByTagName","i","length","classList","add","getElementsByClassName","text","textContent","href","getAttribute","appendChild","cloneNode","push","sort","a","b","remove","buttonSetup","createButton","moreButton","moreAnchor","nestedUl","nestedLi","moreLanguageString","ariaExpanded","setAttribute","append"],"mappings":"uJAuBoB,CAACA,SAAUC,QAASC,uBAQpCC,qBAAuB,CACvBC,gBAAiB,IACjBC,eAAgB,KAChBC,QAASC,SAASC,eAAeP,SACjCQ,aAAc,KACdC,UAAW,EACXC,iBAAkBJ,SAASK,yBAC3BC,cAAe,GACfC,aAAcP,SAASQ,cAAc,MACrCC,mBAAoBT,SAASQ,cAAc,KAC3CE,MAAO,SAASjB,eACTK,eAAiBE,SAASC,eAAe,eAAeU,aAAeC,KAAKf,gBAAkB,SAC9FK,aAAeU,KAAKb,QAAQc,qBAAqB,UACjD,IAAIC,EAAI,EAAGA,EAAIF,KAAKV,aAAaa,OAAQD,SACvCX,UAAYS,KAAKT,UAAYS,KAAKV,aAAaY,GAAGH,YAEnDC,KAAKT,UAAYS,KAAKd,sBACnBS,aAAaS,UAAUC,IAAI,iBAG3BV,aAAaS,UAAUC,IAAI,mBAC5BL,KAAKV,aAAaY,GAAGI,uBAAuB,YAAY,GAAGC,YACxDV,mBAAmBW,YAAcR,KAAKV,aAAaY,GAAGI,uBAAuB,YAAY,GAAGC,WAE9FV,mBAAmBY,KAAOT,KAAKV,aAAaY,GAAGI,uBAAuB,YAAY,GAAGI,aAAa,aAClGb,mBAAmBO,UAAUC,IAAI,sBACjCV,aAAagB,YAAYX,KAAKH,mBAAmBe,WAAU,SAC3DpB,iBAAiBmB,YAAYX,KAAKL,mBAClCD,cAAcmB,KAAKX,SAIvBR,cAAcoB,MAAK,SAASC,EAAGC,UAC3BA,EAAID,SAGR,IAAIb,EAAI,EAAGA,EAAIF,KAAKN,cAAcS,OAAQD,SACxCZ,aAAaU,K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