mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-35590 block_navigation: fix remaining issues
This commit is contained in:
parent
10ac8baf6e
commit
6759dc35fe
15 changed files with 101 additions and 75 deletions
1
blocks/navigation/amd/build/ajax_response_renderer.min.js
vendored
Normal file
1
blocks/navigation/amd/build/ajax_response_renderer.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
define(["jquery"],function(a){function b(d,e){var f=a("<ul></ul>");f.attr("role","group"),a.each(e,function(d,e){if("object"==typeof e){var g=a("<li></li>"),h=a("<p></p>"),i=null,j=e.expandable||e.haschildren?!0:!1;if(h.addClass("tree_item"),h.attr("id",e.id),g.attr("role","treeitem"),e.requiresajaxloading&&(g.attr("data-requires-ajax",!0),g.attr("data-node-id",e.id),g.attr("data-node-key",e.key),g.attr("data-node-type",e.type)),j&&(g.addClass("collapsed contains_branch"),g.attr("aria-expanded",!1),h.addClass("branch")),!e.icon||j&&e.type!==c.ACTIVITY&&e.type!==c.RESOURCE||(g.addClass("item_with_icon"),h.addClass("hasicon"),i=a("<img/>"),i.attr("alt",e.icon.alt),i.attr("title",e.icon.title),i.attr("src",M.util.image_url(e.icon.pix,e.icon.component)),a.each(e.icon.classes,function(a,b){i.addClass(b)})),e.link){var k=a("<a></a>");k.attr("title",e.title),k.attr("href",e.link),i?(k.append(i),k.append('<span class="item-content-wrap">'+e.name+"</span>")):k.text(e.name),e.hidden&&k.addClass("dimmed"),h.append(k)}else{var l=a("<span></span>");i?(l.append(i),l.append('<span class="item-content-wrap">'+e.name+"</span>")):l.text(e.name),e.hidden&&l.addClass("dimmed"),h.append(l)}g.append(h),f.append(g),e.children&&e.children.length?b(g,e.children):j&&!e.requiresajaxloading&&(g.removeClass("contains_branch"),g.addClass("emptybranch"))}}),d.append(f)}var c={ROOTNODE:0,SYSTEM:1,CATEGORY:10,MYCATEGORY:11,COURSE:20,SECTION:30,ACTIVITY:40,RESOURCE:50,CUSTOM:60,SETTING:70,SITEADMIN:71,USER:80,CONTAINER:90};return{render:function(a,c){c.children&&c.children.length?b(a,c.children):a.hasClass("contains_branch")&&a.removeClass("contains_branch").addClass("emptybranch")}}});
|
1
blocks/navigation/amd/build/nav_loader.min.js
vendored
Normal file
1
blocks/navigation/amd/build/nav_loader.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
define(["jquery","core/ajax","core/config","block_navigation/ajax_response_renderer"],function(a,b,c,d){function e(a){return a.closest("[data-block]").attr("data-instanceid")}var f=c.wwwroot+"/lib/ajax/getnavbranch.php";return{load:function(b){b=a(b);var g=a.Deferred(),h={elementid:b.attr("data-node-id"),id:b.attr("data-node-key"),type:b.attr("data-node-type"),sesskey:c.sesskey,instance:e(b)},i={type:"POST",dataType:"json",data:h};return a.ajax(f,i).done(function(a){d.render(b,a),g.resolve()}),g}}});
|
1
blocks/navigation/amd/build/navblock.min.js
vendored
Normal file
1
blocks/navigation/amd/build/navblock.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
define(["jquery","core/tree"],function(a,b){return{init:function(){new b(".block_navigation .block_tree")}}});
|
1
blocks/navigation/amd/build/site_admin_loader.min.js
vendored
Normal file
1
blocks/navigation/amd/build/site_admin_loader.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
define(["jquery","core/ajax","core/config","block_navigation/ajax_response_renderer"],function(a,b,c,d){var e=71,f=c.wwwroot+"/lib/ajax/getsiteadminbranch.php";return{load:function(b){b=a(b);var g=a.Deferred(),h={type:e,sesskey:c.sesskey},i={type:"POST",dataType:"json",data:h};return a.ajax(f,i).done(function(a){d.render(b,a),g.resolve()}),g}}});
|
|
@ -27,34 +27,42 @@ define(['jquery'], function($) {
|
|||
// Mappings for the different types of nodes coming from the navigation.
|
||||
// Copied from lib/navigationlib.php navigation_node constants.
|
||||
var NODETYPE = {
|
||||
// @type int Root node = 0
|
||||
// @type int Root node = 0.
|
||||
ROOTNODE : 0,
|
||||
// @type int System context = 1
|
||||
// @type int System context = 1.
|
||||
SYSTEM : 1,
|
||||
// @type int Course category = 10
|
||||
// @type int Course category = 10.
|
||||
CATEGORY : 10,
|
||||
// @type int MYCATEGORY = 11
|
||||
// @type int MYCATEGORY = 11.
|
||||
MYCATEGORY : 11,
|
||||
// @type int Course = 20
|
||||
// @type int Course = 20.
|
||||
COURSE : 20,
|
||||
// @type int Course section = 30
|
||||
// @type int Course section = 30.
|
||||
SECTION : 30,
|
||||
// @type int Activity (course module) = 40
|
||||
// @type int Activity (course module) = 40.
|
||||
ACTIVITY : 40,
|
||||
// @type int Resource (course module = 50
|
||||
// @type int Resource (course module = 50.
|
||||
RESOURCE : 50,
|
||||
// @type int Custom node (could be anything) = 60
|
||||
// @type int Custom node (could be anything) = 60.
|
||||
CUSTOM : 60,
|
||||
// @type int Setting = 70
|
||||
// @type int Setting = 70.
|
||||
SETTING : 70,
|
||||
// @type int site administration = 71
|
||||
// @type int site administration = 71.
|
||||
SITEADMIN : 71,
|
||||
// @type int User context = 80
|
||||
// @type int User context = 80.
|
||||
USER : 80,
|
||||
// @type int Container = 90
|
||||
// @type int Container = 90.
|
||||
CONTAINER : 90
|
||||
};
|
||||
|
||||
/**
|
||||
* Build DOM.
|
||||
*
|
||||
* @method buildDOM
|
||||
* @param {Object} rootElement the root element of DOM.
|
||||
* @param {object} nodes jquery object representing the nodes to be build.
|
||||
* @return
|
||||
*/
|
||||
function buildDOM(rootElement, nodes) {
|
||||
var ul = $('<ul></ul>');
|
||||
ul.attr('role', 'group');
|
||||
|
@ -149,8 +157,7 @@ define(['jquery'], function($) {
|
|||
|
||||
return {
|
||||
render: function(element, nodes) {
|
||||
// The first element of the response is the existing node
|
||||
// so we start with processing the children.
|
||||
// The first element of the response is the existing node so we start with processing the children.
|
||||
if (nodes.children && nodes.children.length) {
|
||||
buildDOM(element, nodes.children);
|
||||
} else {
|
||||
|
|
|
@ -22,13 +22,19 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/ajax', 'core/config', 'block_navigation/ajax_response_renderer'],
|
||||
function($, ajax, config, renderer) {
|
||||
function($, ajax, config, renderer) {
|
||||
var URL = config.wwwroot + '/lib/ajax/getnavbranch.php';
|
||||
|
||||
var URL = config.wwwroot + '/lib/ajax/getnavbranch.php';
|
||||
|
||||
function getBlockInstanceId(element) {
|
||||
return element.closest('[data-block]').attr('data-instanceid');
|
||||
}
|
||||
/**
|
||||
* Get the block instance id.
|
||||
*
|
||||
* @function getBlockInstanceId
|
||||
* @param element
|
||||
* @returns {*}
|
||||
*/
|
||||
function getBlockInstanceId(element) {
|
||||
return element.closest('[data-block]').attr('data-instanceid');
|
||||
}
|
||||
|
||||
return {
|
||||
load: function(element) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Load the navtree javscript
|
||||
* Load the navigation tree javascript.
|
||||
*
|
||||
* @module block_navigation/navblock
|
||||
* @package core
|
||||
|
|
|
@ -33,7 +33,7 @@ define(['jquery', 'core/ajax', 'core/config', 'block_navigation/ajax_response_re
|
|||
var promise = $.Deferred();
|
||||
var data = {
|
||||
type: SITE_ADMIN_NODE_TYPE,
|
||||
sesskey: config.sesskey,
|
||||
sesskey: config.sesskey
|
||||
};
|
||||
var settings = {
|
||||
type: 'POST',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue