diff --git a/blocks/recentlyaccesseditems/amd/build/main.min.js b/blocks/recentlyaccesseditems/amd/build/main.min.js index e190556185a..6d8746be498 100644 --- a/blocks/recentlyaccesseditems/amd/build/main.min.js +++ b/blocks/recentlyaccesseditems/amd/build/main.min.js @@ -5,6 +5,6 @@ * @copyright 2018 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("block_recentlyaccesseditems/main",["jquery","block_recentlyaccesseditems/repository","core/templates","core/notification"],(function($,Repository,Templates,Notification){var SELECTORS_CARDDECK_CONTAINER='[data-region="recentlyaccesseditems-view"]',SELECTORS_CARDDECK='[data-region="recentlyaccesseditems-view-content"]',SELECTORS_SHOWMORE_LINK='[data-region="recentlyaccesseditems-view"] [data-action="more-items"]';return{init:function(root){var limit,itemsContainer=(root=$(root)).find(SELECTORS_CARDDECK_CONTAINER),itemsContent=root.find(SELECTORS_CARDDECK);(limit=9,Repository.getRecentItems(limit)).then((function(items){var pageContentPromise=function(root,items){if(items.length>0){let hasmoreitems=!1;return items.length>3&&(hasmoreitems=!0),Templates.render("block_recentlyaccesseditems/view-cards",{items:items,hasmoreitems:hasmoreitems})}var noitemsimgurl=root.attr("data-noitemsimgurl");return Templates.render("block_recentlyaccesseditems/no-items",{noitemsimgurl:noitemsimgurl})}(itemsContainer,items);pageContentPromise.then((function(html,js){return Templates.replaceNodeContents(itemsContent,html,js),items.length>3&&(()=>{const showmoreLink=document.querySelector(SELECTORS_SHOWMORE_LINK);showmoreLink.addEventListener("click",(()=>{showmoreLink.classList.add("d-none"),document.querySelector('[data-region="items-list"]').children.forEach((function(hiddenItem){hiddenItem.style="display: block"}))}))})(),null})).catch(Notification.exception)})).catch(Notification.exception)}}})); +define("block_recentlyaccesseditems/main",["jquery","block_recentlyaccesseditems/repository","core/templates","core/notification"],(function($,Repository,Templates,Notification){var SELECTORS_CARDDECK_CONTAINER='[data-region="recentlyaccesseditems-view"]',SELECTORS_CARDDECK='[data-region="recentlyaccesseditems-view-content"]',SELECTORS_SHOWMORE_LINK='[data-region="recentlyaccesseditems-view"] [data-action="more-items"]';return{init:function(root){var limit,itemsContainer=(root=$(root)).find(SELECTORS_CARDDECK_CONTAINER),itemsContent=root.find(SELECTORS_CARDDECK);(limit=9,Repository.getRecentItems(limit)).then((function(items){var pageContentPromise=function(root,items){if(items.length>0){let hasmoreitems=!1;return items.length>3&&(hasmoreitems=!0),Templates.render("block_recentlyaccesseditems/view-cards",{items:items,hasmoreitems:hasmoreitems})}var noitemsimgurl=root.attr("data-noitemsimgurl");return Templates.render("block_recentlyaccesseditems/no-items",{noitemsimgurl:noitemsimgurl})}(itemsContainer,items);pageContentPromise.then((function(html,js){return Templates.replaceNodeContents(itemsContent,html,js),items.length>3&&(()=>{const showmoreLink=document.querySelector(SELECTORS_SHOWMORE_LINK);showmoreLink.addEventListener("click",(()=>{showmoreLink.classList.add("d-none");const hiddenItems=document.querySelector('[data-region="items-list"]').children;for(const hiddenItem of hiddenItems)hiddenItem.style="display: block"}))})(),null})).catch(Notification.exception)})).catch(Notification.exception)}}})); //# sourceMappingURL=main.min.js.map \ No newline at end of file diff --git a/blocks/recentlyaccesseditems/amd/build/main.min.js.map b/blocks/recentlyaccesseditems/amd/build/main.min.js.map index e1cd3bc1fc1..f51dcab927e 100644 --- a/blocks/recentlyaccesseditems/amd/build/main.min.js.map +++ b/blocks/recentlyaccesseditems/amd/build/main.min.js.map @@ -1 +1 @@ -{"version":3,"file":"main.min.js","sources":["../src/main.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 .\n\n/**\n * Javascript to initialise the Recently accessed items block.\n *\n * @module block_recentlyaccesseditems/main\n * @copyright 2018 Victor Deniz \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n [\n 'jquery',\n 'block_recentlyaccesseditems/repository',\n 'core/templates',\n 'core/notification'\n ],\n function(\n $,\n Repository,\n Templates,\n Notification\n ) {\n\n var NUM_ITEMS = 9;\n // Maximum number of elements to display in the block initially.\n var NUM_ITEMS_INIT = 3;\n\n var SELECTORS = {\n CARDDECK_CONTAINER: '[data-region=\"recentlyaccesseditems-view\"]',\n CARDDECK: '[data-region=\"recentlyaccesseditems-view-content\"]',\n SHOWMORE_LINK: '[data-region=\"recentlyaccesseditems-view\"] [data-action=\"more-items\"]',\n };\n\n /**\n * Register event listeners.\n */\n const registerEventListeners = () => {\n const showmoreLink = document.querySelector(SELECTORS.SHOWMORE_LINK);\n\n // Hide \"Show more\" link and show additional items.\n showmoreLink.addEventListener('click', () => {\n showmoreLink.classList.add('d-none');\n\n const hiddenItems = document.querySelector('[data-region=\"items-list\"]').children;\n hiddenItems.forEach(function(hiddenItem) {\n hiddenItem.style = \"display: block\";\n });\n });\n };\n\n /**\n * Get recent items from backend.\n *\n * @method getRecentItems\n * @param {int} limit Only return this many results\n * @return {array} Items user most recently has accessed\n */\n var getRecentItems = function(limit) {\n return Repository.getRecentItems(limit);\n };\n\n /**\n * Render the block content.\n *\n * @method renderItems\n * @param {object} root The root element for the items view.\n * @param {array} items containing array of returned items.\n * @return {promise} Resolved with HTML and JS strings\n */\n var renderItems = function(root, items) {\n if (items.length > 0) {\n let hasmoreitems = false;\n if (items.length > NUM_ITEMS_INIT) {\n hasmoreitems = true;\n }\n return Templates.render('block_recentlyaccesseditems/view-cards', {\n items: items,\n hasmoreitems: hasmoreitems\n });\n } else {\n var noitemsimgurl = root.attr('data-noitemsimgurl');\n return Templates.render('block_recentlyaccesseditems/no-items', {\n noitemsimgurl: noitemsimgurl\n });\n }\n };\n\n /**\n * Get and show the recent items into the block.\n *\n * @param {object} root The root element for the items block.\n */\n var init = function(root) {\n root = $(root);\n\n var itemsContainer = root.find(SELECTORS.CARDDECK_CONTAINER);\n var itemsContent = root.find(SELECTORS.CARDDECK);\n\n var itemsPromise = getRecentItems(NUM_ITEMS);\n\n itemsPromise.then(function(items) {\n var pageContentPromise = renderItems(itemsContainer, items);\n\n pageContentPromise.then(function(html, js) {\n Templates.replaceNodeContents(itemsContent, html, js);\n if (items.length > 3) {\n registerEventListeners();\n }\n return null;\n }).catch(Notification.exception);\n }).catch(Notification.exception);\n };\n\n return {\n init: init\n };\n });"],"names":["define","$","Repository","Templates","Notification","SELECTORS","init","root","limit","itemsContainer","find","itemsContent","getRecentItems","then","items","pageContentPromise","length","hasmoreitems","render","noitemsimgurl","attr","renderItems","html","js","replaceNodeContents","showmoreLink","document","querySelector","addEventListener","classList","add","children","forEach","hiddenItem","style","registerEventListeners","catch","exception"],"mappings":";;;;;;;AAwBAA,0CACI,CACI,SACA,yCACA,iBACA,sBAEJ,SACIC,EACAC,WACAC,UACAC,kBAOIC,6BACoB,6CADpBA,mBAEU,qDAFVA,wBAGe,8EAmFZ,CACHC,KAtBO,SAASC,UAnCUC,MAsCtBC,gBAFJF,KAAON,EAAEM,OAEiBG,KAAKL,8BAC3BM,aAAeJ,KAAKG,KAAKL,qBAvCHG,MAlCd,EAmCLN,WAAWU,eAAeJ,QA0CpBK,MAAK,SAASC,WACnBC,mBAhCM,SAASR,KAAMO,UACzBA,MAAME,OAAS,EAAG,KACdC,cAAe,SACfH,MAAME,OA/CG,IAgDTC,cAAe,GAEZd,UAAUe,OAAO,yCAA0C,CAC9DJ,MAAOA,MACPG,aAAcA,mBAGdE,cAAgBZ,KAAKa,KAAK,6BACvBjB,UAAUe,OAAO,uCAAwC,CAC5DC,cAAeA,gBAmBME,CAAYZ,eAAgBK,OAErDC,mBAAmBF,MAAK,SAASS,KAAMC,WACnCpB,UAAUqB,oBAAoBb,aAAcW,KAAMC,IAC9CT,MAAME,OAAS,GArEA,YACrBS,aAAeC,SAASC,cAActB,yBAG5CoB,aAAaG,iBAAiB,SAAS,KACnCH,aAAaI,UAAUC,IAAI,UAEPJ,SAASC,cAAc,8BAA8BI,SAC7DC,SAAQ,SAASC,YACzBA,WAAWC,MAAQ,wBA6DfC,GAEG,QACRC,MAAMhC,aAAaiC,cACvBD,MAAMhC,aAAaiC"} \ No newline at end of file +{"version":3,"file":"main.min.js","sources":["../src/main.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 .\n\n/**\n * Javascript to initialise the Recently accessed items block.\n *\n * @module block_recentlyaccesseditems/main\n * @copyright 2018 Victor Deniz \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n [\n 'jquery',\n 'block_recentlyaccesseditems/repository',\n 'core/templates',\n 'core/notification'\n ],\n function(\n $,\n Repository,\n Templates,\n Notification\n ) {\n\n var NUM_ITEMS = 9;\n // Maximum number of elements to display in the block initially.\n var NUM_ITEMS_INIT = 3;\n\n var SELECTORS = {\n CARDDECK_CONTAINER: '[data-region=\"recentlyaccesseditems-view\"]',\n CARDDECK: '[data-region=\"recentlyaccesseditems-view-content\"]',\n SHOWMORE_LINK: '[data-region=\"recentlyaccesseditems-view\"] [data-action=\"more-items\"]',\n };\n\n /**\n * Register event listeners.\n */\n const registerEventListeners = () => {\n const showmoreLink = document.querySelector(SELECTORS.SHOWMORE_LINK);\n\n // Hide \"Show more\" link and show additional items.\n showmoreLink.addEventListener('click', () => {\n showmoreLink.classList.add('d-none');\n\n const hiddenItems = document.querySelector('[data-region=\"items-list\"]').children;\n for (const hiddenItem of hiddenItems) {\n hiddenItem.style = \"display: block\";\n }\n });\n };\n\n /**\n * Get recent items from backend.\n *\n * @method getRecentItems\n * @param {int} limit Only return this many results\n * @return {array} Items user most recently has accessed\n */\n var getRecentItems = function(limit) {\n return Repository.getRecentItems(limit);\n };\n\n /**\n * Render the block content.\n *\n * @method renderItems\n * @param {object} root The root element for the items view.\n * @param {array} items containing array of returned items.\n * @return {promise} Resolved with HTML and JS strings\n */\n var renderItems = function(root, items) {\n if (items.length > 0) {\n let hasmoreitems = false;\n if (items.length > NUM_ITEMS_INIT) {\n hasmoreitems = true;\n }\n return Templates.render('block_recentlyaccesseditems/view-cards', {\n items: items,\n hasmoreitems: hasmoreitems\n });\n } else {\n var noitemsimgurl = root.attr('data-noitemsimgurl');\n return Templates.render('block_recentlyaccesseditems/no-items', {\n noitemsimgurl: noitemsimgurl\n });\n }\n };\n\n /**\n * Get and show the recent items into the block.\n *\n * @param {object} root The root element for the items block.\n */\n var init = function(root) {\n root = $(root);\n\n var itemsContainer = root.find(SELECTORS.CARDDECK_CONTAINER);\n var itemsContent = root.find(SELECTORS.CARDDECK);\n\n var itemsPromise = getRecentItems(NUM_ITEMS);\n\n itemsPromise.then(function(items) {\n var pageContentPromise = renderItems(itemsContainer, items);\n\n pageContentPromise.then(function(html, js) {\n Templates.replaceNodeContents(itemsContent, html, js);\n if (items.length > 3) {\n registerEventListeners();\n }\n return null;\n }).catch(Notification.exception);\n }).catch(Notification.exception);\n };\n\n return {\n init: init\n };\n });"],"names":["define","$","Repository","Templates","Notification","SELECTORS","init","root","limit","itemsContainer","find","itemsContent","getRecentItems","then","items","pageContentPromise","length","hasmoreitems","render","noitemsimgurl","attr","renderItems","html","js","replaceNodeContents","showmoreLink","document","querySelector","addEventListener","classList","add","hiddenItems","children","hiddenItem","style","registerEventListeners","catch","exception"],"mappings":";;;;;;;AAwBAA,0CACI,CACI,SACA,yCACA,iBACA,sBAEJ,SACIC,EACAC,WACAC,UACAC,kBAOIC,6BACoB,6CADpBA,mBAEU,qDAFVA,wBAGe,8EAmFZ,CACHC,KAtBO,SAASC,UAnCUC,MAsCtBC,gBAFJF,KAAON,EAAEM,OAEiBG,KAAKL,8BAC3BM,aAAeJ,KAAKG,KAAKL,qBAvCHG,MAlCd,EAmCLN,WAAWU,eAAeJ,QA0CpBK,MAAK,SAASC,WACnBC,mBAhCM,SAASR,KAAMO,UACzBA,MAAME,OAAS,EAAG,KACdC,cAAe,SACfH,MAAME,OA/CG,IAgDTC,cAAe,GAEZd,UAAUe,OAAO,yCAA0C,CAC9DJ,MAAOA,MACPG,aAAcA,mBAGdE,cAAgBZ,KAAKa,KAAK,6BACvBjB,UAAUe,OAAO,uCAAwC,CAC5DC,cAAeA,gBAmBME,CAAYZ,eAAgBK,OAErDC,mBAAmBF,MAAK,SAASS,KAAMC,WACnCpB,UAAUqB,oBAAoBb,aAAcW,KAAMC,IAC9CT,MAAME,OAAS,GArEA,YACrBS,aAAeC,SAASC,cAActB,yBAG5CoB,aAAaG,iBAAiB,SAAS,KACnCH,aAAaI,UAAUC,IAAI,gBAErBC,YAAcL,SAASC,cAAc,8BAA8BK,aACpE,MAAMC,cAAcF,YACrBE,WAAWC,MAAQ,qBA6DfC,GAEG,QACRC,MAAMhC,aAAaiC,cACvBD,MAAMhC,aAAaiC"} \ No newline at end of file diff --git a/blocks/recentlyaccesseditems/amd/src/main.js b/blocks/recentlyaccesseditems/amd/src/main.js index 7b00125845f..94fcda4cccc 100644 --- a/blocks/recentlyaccesseditems/amd/src/main.js +++ b/blocks/recentlyaccesseditems/amd/src/main.js @@ -57,9 +57,9 @@ define( showmoreLink.classList.add('d-none'); const hiddenItems = document.querySelector('[data-region="items-list"]').children; - hiddenItems.forEach(function(hiddenItem) { + for (const hiddenItem of hiddenItems) { hiddenItem.style = "display: block"; - }); + } }); };