Current Path : C:/xampp/htdocs/moodle/blocks/navigation/amd/build/ |
Current File : C:/xampp/htdocs/moodle/blocks/navigation/amd/build/ajax_response_renderer.min.js.map |
{"version":3,"sources":["../src/ajax_response_renderer.js"],"names":["define","$","Templates","Notification","Url","NODETYPE","ACTIVITY","RESOURCE","buildDOM","rootElement","nodes","ul","attr","each","index","node","li","p","id","key","icon","isBranch","expandable","haschildren","addClass","requiresajaxloading","type","eleToAddIcon","link","title","append","name","hidden","span","alt","imageUrl","pix","component","classes","className","prepend","renderPix","then","html","catch","exception","children","length","removeClass","parent","render","element","item","first","group","find","hasClass"],"mappings":"mSAwBAA,OAAM,2CAAC,CAAC,QAAD,CAAW,gBAAX,CAA6B,mBAA7B,CAAkD,UAAlD,CAAD,CAAgE,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqCC,CAArC,CAA0C,CAI5G,GAAIC,CAAAA,CAAQ,CAAG,CAEXC,QAAQ,CAAE,EAFC,CAIXC,QAAQ,CAAE,EAJC,CAAf,CAcA,QAASC,CAAAA,CAAT,CAAkBC,CAAlB,CAA+BC,CAA/B,CAAsC,CAClC,GAAIC,CAAAA,CAAE,CAAGV,CAAC,CAAC,WAAD,CAAV,CACAU,CAAE,CAACC,IAAH,CAAQ,MAAR,CAAgB,OAAhB,EACAD,CAAE,CAACC,IAAH,CAAQ,aAAR,KAEAX,CAAC,CAACY,IAAF,CAAOH,CAAP,CAAc,SAASI,CAAT,CAAgBC,CAAhB,CAAsB,CAChC,GAAoB,QAAhB,WAAOA,CAAP,CAAJ,CAA8B,CAC1B,MACH,CAH+B,GAK5BC,CAAAA,CAAE,CAAGf,CAAC,CAAC,WAAD,CALsB,CAM5BgB,CAAC,CAAGhB,CAAC,CAAC,SAAD,CANuB,CAO5BiB,CAAE,CAAGH,CAAI,CAACG,EAAL,EAAWH,CAAI,CAACI,GAAL,CAAW,YAPC,CAQ5BC,CAAI,CAAG,IARqB,CAS5BC,CAAQ,CAAIN,CAAI,CAACO,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,CAACL,QAAR,CAAiB,mBAAjB,EAAsCO,KAAtC,EAH8B,CAIrCC,CAAK,CAAGH,CAAO,CAACI,IAAR,CAAa,IAAMH,CAAI,CAACxC,IAAL,CAAU,WAAV,CAAnB,CAJ6B,CAMzCwC,CAAI,CAACxC,IAAL,CAAU,eAAV,KACA0C,CAAK,CAAC1C,IAAN,CAAW,aAAX,IACH,CARD,IAQO,CACH,GAAIuC,CAAO,CAACF,MAAR,GAAiBO,QAAjB,CAA0B,iBAA1B,CAAJ,CAAkD,CAC9CL,CAAO,CAACF,MAAR,GAAiBD,WAAjB,CAA6B,iBAA7B,EACAG,CAAO,CAAC3B,QAAR,CAAiB,aAAjB,CACH,CACJ,CACJ,CAjBE,CAmBV,CA5IK,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 * Parse the response from the navblock ajax page and render the correct DOM\n * structure for the tree from it.\n *\n * @module block_navigation/ajax_response_renderer\n * @package core\n * @copyright 2015 John Okely <john@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/templates', 'core/notification', 'core/url'], function($, Templates, Notification, Url) {\n\n // Mappings for the different types of nodes coming from the navigation.\n // Copied from lib/navigationlib.php navigation_node constants.\n var NODETYPE = {\n // @type int Activity (course module) = 40.\n ACTIVITY: 40,\n // @type int Resource (course module = 50.\n RESOURCE: 50,\n };\n\n /**\n * Build DOM.\n *\n * @method buildDOM\n * @param {Object} rootElement the root element of DOM.\n * @param {object} nodes jquery object representing the nodes to be build.\n */\n function buildDOM(rootElement, nodes) {\n var ul = $('<ul></ul>');\n ul.attr('role', 'group');\n ul.attr('aria-hidden', true);\n\n $.each(nodes, function(index, node) {\n if (typeof node !== 'object') {\n return;\n }\n\n var li = $('<li></li>');\n var p = $('<p></p>');\n var id = node.id || node.key + '_tree_item';\n var icon = null;\n var isBranch = (node.expandable || node.haschildren) ? true : false;\n\n p.addClass('tree_item');\n p.attr('id', id);\n p.attr('role', 'treeitem');\n // Negative tab index to allow it to receive focus.\n p.attr('tabindex', '-1');\n\n if (node.requiresajaxloading) {\n p.attr('data-requires-ajax', true);\n p.attr('data-node-id', node.id);\n p.attr('data-node-key', node.key);\n p.attr('data-node-type', node.type);\n }\n\n if (isBranch) {\n li.addClass('collapsed contains_branch');\n p.attr('aria-expanded', false);\n p.addClass('branch');\n }\n\n var eleToAddIcon = null;\n if (node.link) {\n var link = $('<a title=\"' + node.title + '\" href=\"' + node.link + '\"></a>');\n\n eleToAddIcon = link;\n link.append('<span class=\"item-content-wrap\">' + node.name + '</span>');\n\n if (node.hidden) {\n link.addClass('dimmed');\n }\n\n p.append(link);\n } else {\n var span = $('<span></span>');\n\n eleToAddIcon = span;\n span.append('<span class=\"item-content-wrap\">' + node.name + '</span>');\n\n if (node.hidden) {\n span.addClass('dimmed');\n }\n\n p.append(span);\n }\n\n if (node.icon && (!isBranch || node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE)) {\n li.addClass('item_with_icon');\n p.addClass('hasicon');\n\n if (node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE) {\n icon = $('<img/>');\n icon.attr('alt', node.icon.alt);\n icon.attr('title', node.icon.title);\n icon.attr('src', Url.imageUrl(node.icon.pix, node.icon.component));\n $.each(node.icon.classes, function(index, className) {\n icon.addClass(className);\n });\n eleToAddIcon.prepend(icon);\n } else {\n if (node.icon.component == 'moodle') {\n node.icon.component = 'core';\n }\n Templates.renderPix(node.icon.pix, node.icon.component, node.icon.title).then(function(html) {\n // Prepend.\n eleToAddIcon.prepend(html);\n return;\n }).catch(Notification.exception);\n }\n }\n\n li.append(p);\n ul.append(li);\n\n if (node.children && node.children.length) {\n buildDOM(p, node.children);\n } else if (isBranch && !node.requiresajaxloading) {\n li.removeClass('contains_branch');\n p.addClass('emptybranch');\n }\n });\n\n rootElement.parent().append(ul);\n var id = rootElement.attr('id') + '_group';\n ul.attr('id', id);\n rootElement.attr('aria-owns', id);\n rootElement.attr('role', 'treeitem');\n }\n\n return {\n render: function(element, nodes) {\n // The first element of the response is the existing node so we start with processing the children.\n if (nodes.children && nodes.children.length) {\n buildDOM(element, nodes.children);\n\n var item = element.children(\"[role='treeitem']\").first();\n var group = element.find('#' + item.attr('aria-owns'));\n\n item.attr('aria-expanded', true);\n group.attr('aria-hidden', false);\n } else {\n if (element.parent().hasClass('contains_branch')) {\n element.parent().removeClass('contains_branch');\n element.addClass('emptybranch');\n }\n }\n }\n };\n});\n"],"file":"ajax_response_renderer.min.js"}