Current Path : /var/www/ljmtc/cbt/blocks/recentlyaccesseditems/amd/build/ |
Current File : /var/www/ljmtc/cbt/blocks/recentlyaccesseditems/amd/build/main.min.js.map |
{"version":3,"sources":["../src/main.js"],"names":["define","$","Repository","Templates","Notification","SELECTORS","CARDDECK_CONTAINER","CARDDECK","getRecentItems","limit","renderItems","root","items","length","render","noitemsimgurl","attr","init","itemsContainer","find","itemsContent","itemsPromise","then","pageContentPromise","html","js","replaceNodeContents","catch","exception"],"mappings":"AAyBAA,OAAM,oCACF,CACI,QADJ,CAEI,wCAFJ,CAGI,gBAHJ,CAII,mBAJJ,CADE,CAOF,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKE,IAIMC,CAAAA,CAAS,CAAG,CACZC,kBAAkB,CAAE,8CADR,CAEZC,QAAQ,CAAE,sDAFE,CAJlB,CAgBMC,CAAc,CAAG,SAASC,CAAT,CAAgB,CACjC,MAAOP,CAAAA,CAAU,CAACM,cAAX,CAA0BC,CAA1B,CACV,CAlBH,CA4BMC,CAAW,CAAG,SAASC,CAAT,CAAeC,CAAf,CAAsB,CACpC,GAAmB,CAAf,CAAAA,CAAK,CAACC,MAAV,CAAsB,CAClB,MAAOV,CAAAA,CAAS,CAACW,MAAV,CAAiB,wCAAjB,CAA2D,CAC9DF,KAAK,CAAEA,CADuD,CAA3D,CAGV,CAJD,IAIO,CACH,GAAIG,CAAAA,CAAa,CAAGJ,CAAI,CAACK,IAAL,CAAU,oBAAV,CAApB,CACA,MAAOb,CAAAA,CAAS,CAACW,MAAV,CAAiB,sCAAjB,CAAyD,CAC5DC,aAAa,CAAEA,CAD6C,CAAzD,CAGV,CACJ,CAvCH,CAgEE,MAAO,CACHE,IAAI,CAnBG,QAAPA,CAAAA,IAAO,CAASN,CAAT,CAAe,CACtBA,CAAI,CAAGV,CAAC,CAACU,CAAD,CAAR,CADsB,GAGlBO,CAAAA,CAAc,CAAGP,CAAI,CAACQ,IAAL,CAAUd,CAAS,CAACC,kBAApB,CAHC,CAIlBc,CAAY,CAAGT,CAAI,CAACQ,IAAL,CAAUd,CAAS,CAACE,QAApB,CAJG,CAMlBc,CAAY,CAAGb,CAAc,GANX,CAQtBa,CAAY,CAACC,IAAb,CAAkB,SAASV,CAAT,CAAgB,CAC9B,GAAIW,CAAAA,CAAkB,CAAGb,CAAW,CAACQ,CAAD,CAAiBN,CAAjB,CAApC,CAEAW,CAAkB,CAACD,IAAnB,CAAwB,SAASE,CAAT,CAAeC,CAAf,CAAmB,CACvC,MAAOtB,CAAAA,CAAS,CAACuB,mBAAV,CAA8BN,CAA9B,CAA4CI,CAA5C,CAAkDC,CAAlD,CACV,CAFD,EAEGE,KAFH,CAESvB,CAAY,CAACwB,SAFtB,EAGA,MAAOP,CAAAA,CACV,CAPD,EAOGM,KAPH,CAOSvB,CAAY,CAACwB,SAPtB,CAQH,CAEM,CAGV,CA/EC,CAAN","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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript to initialise the Recently accessed items block.\n *\n * @module block_recentlyaccesseditems/main\n * @package block_recentlyaccesseditems\n * @copyright 2018 Victor Deniz <victor@moodle.com>\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\n var SELECTORS = {\n CARDDECK_CONTAINER: '[data-region=\"recentlyaccesseditems-view\"]',\n CARDDECK: '[data-region=\"recentlyaccesseditems-view-content\"]',\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 return Templates.render('block_recentlyaccesseditems/view-cards', {\n items: items\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 return Templates.replaceNodeContents(itemsContent, html, js);\n }).catch(Notification.exception);\n return itemsPromise;\n }).catch(Notification.exception);\n };\n\n return {\n init: init\n };\n });"],"file":"main.min.js"}