mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-35590 block_navigation: Set attribute on node creation
Otherwise we would need to unescape href and title.
This commit is contained in:
parent
a057ba5924
commit
ed654d4aa8
@ -1 +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")}}});
|
||||
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 title="'+e.title+'" href="'+e.link+'"></a>');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={ACTIVITY:40,RESOURCE:50};return{render:function(a,c){c.children&&c.children.length?b(a,c.children):a.hasClass("contains_branch")&&a.removeClass("contains_branch").addClass("emptybranch")}}});
|
@ -86,9 +86,7 @@ define(['jquery'], function($) {
|
||||
}
|
||||
|
||||
if (node.link) {
|
||||
var link = $('<a></a>');
|
||||
link.attr('title', node.title);
|
||||
link.attr('href', node.link);
|
||||
var link = $('<a title="' + node.title + '" href="' + node.link + '"></a>');
|
||||
|
||||
if (icon) {
|
||||
link.append(icon);
|
||||
|
@ -1 +1 @@
|
||||
define(["jquery","core/tree"],function(a,b){return{init:function(){new b(".block_settings .block_tree")}}});
|
||||
define(["jquery","core/tree"],function(a,b){return{init:function(a){var c=new b(".block_settings .block_tree");if(a){var d=c.treeRoot.find("#"+a),e=d.children("a").first();e.replaceWith('<span tabindex="0">'+e.html()+"</span>")}}}});
|
@ -26,7 +26,7 @@ define(['jquery', 'core/tree'], function($, Tree) {
|
||||
init: function(siteAdminNodeId) {
|
||||
var adminTree = new Tree(".block_settings .block_tree");
|
||||
if (siteAdminNodeId) {
|
||||
var siteAdminNode = adminTree.treeRoot.find('#' + siteAdminNodeId)
|
||||
var siteAdminNode = adminTree.treeRoot.find('#' + siteAdminNodeId);
|
||||
var siteAdminLink = siteAdminNode.children('a').first();
|
||||
siteAdminLink.replaceWith('<span tabindex="0">' + siteAdminLink.html() + '</span>');
|
||||
}
|
||||
|
2
lib/amd/build/tree.min.js
vendored
2
lib/amd/build/tree.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user