mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
Merge branch 'MDL-58808-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
78013a17c7
@ -1 +1 @@
|
||||
define(["jquery"],function(a){function b(d,e){var f=a("<ul></ul>");f.attr("role","group"),f.attr("aria-hidden",!0),a.each(e,function(d,e){if("object"==typeof e){var g=a("<li></li>"),h=a("<p></p>"),i=e.id||e.key+"_tree_item",j=null,k=!(!e.expandable&&!e.haschildren);if(h.addClass("tree_item"),h.attr("id",i),h.attr("role","treeitem"),h.attr("tabindex","-1"),e.requiresajaxloading&&(h.attr("data-requires-ajax",!0),h.attr("data-node-id",e.id),h.attr("data-node-key",e.key),h.attr("data-node-type",e.type)),k&&(g.addClass("collapsed contains_branch"),h.attr("aria-expanded",!1),h.addClass("branch")),!e.icon||k&&e.type!==c.ACTIVITY&&e.type!==c.RESOURCE||(g.addClass("item_with_icon"),h.addClass("hasicon"),j=a("<img/>"),j.attr("alt",e.icon.alt),j.attr("title",e.icon.title),j.attr("src",M.util.image_url(e.icon.pix,e.icon.component)),a.each(e.icon.classes,function(a,b){j.addClass(b)})),e.link){var l=a('<a title="'+e.title+'" href="'+e.link+'"></a>');j?(l.append(j),l.append('<span class="item-content-wrap">'+e.name+"</span>")):l.append(e.name),e.hidden&&l.addClass("dimmed"),h.append(l)}else{var m=a("<span></span>");j?(m.append(j),m.append('<span class="item-content-wrap">'+e.name+"</span>")):m.append(e.name),e.hidden&&m.addClass("dimmed"),h.append(m)}g.append(h),f.append(g),e.children&&e.children.length?b(h,e.children):k&&!e.requiresajaxloading&&(g.removeClass("contains_branch"),h.addClass("emptybranch"))}}),d.parent().append(f);var g=d.attr("id")+"_group";f.attr("id",g),d.attr("aria-owns",g),d.attr("role","treeitem")}var c={ACTIVITY:40,RESOURCE:50};return{render:function(a,c){if(c.children&&c.children.length){b(a,c.children);var d=a.children("[role='treeitem']").first(),e=a.find("#"+d.attr("aria-owns"));d.attr("aria-expanded",!0),e.attr("aria-hidden",!1)}else a.parent().hasClass("contains_branch")&&(a.parent().removeClass("contains_branch"),a.addClass("emptybranch"))}}});
|
||||
define(["jquery","core/templates","core/notification","core/url"],function(a,b,c,d){function e(g,h){var i=a("<ul></ul>");i.attr("role","group"),i.attr("aria-hidden",!0),a.each(h,function(g,h){if("object"==typeof h){var j=a("<li></li>"),k=a("<p></p>"),l=h.id||h.key+"_tree_item",m=null,n=!(!h.expandable&&!h.haschildren);k.addClass("tree_item"),k.attr("id",l),k.attr("role","treeitem"),k.attr("tabindex","-1"),h.requiresajaxloading&&(k.attr("data-requires-ajax",!0),k.attr("data-node-id",h.id),k.attr("data-node-key",h.key),k.attr("data-node-type",h.type)),n&&(j.addClass("collapsed contains_branch"),k.attr("aria-expanded",!1),k.addClass("branch"));var o=null;if(h.link){var p=a('<a title="'+h.title+'" href="'+h.link+'"></a>');o=p,p.append('<span class="item-content-wrap">'+h.name+"</span>"),h.hidden&&p.addClass("dimmed"),k.append(p)}else{var q=a("<span></span>");o=q,q.append('<span class="item-content-wrap">'+h.name+"</span>"),h.hidden&&q.addClass("dimmed"),k.append(q)}!h.icon||n&&h.type!==f.ACTIVITY&&h.type!==f.RESOURCE||(j.addClass("item_with_icon"),k.addClass("hasicon"),h.type===f.ACTIVITY||h.type===f.RESOURCE?(m=a("<img/>"),m.attr("alt",h.icon.alt),m.attr("title",h.icon.title),m.attr("src",d.imageUrl(h.icon.pix,h.icon.component)),a.each(h.icon.classes,function(a,b){m.addClass(b)}),o.prepend(m)):("moodle"==h.icon.component&&(h.icon.component="core"),b.renderPix(h.icon.pix,h.icon.component,h.icon.title).then(function(a){o.prepend(a)})["catch"](c.exception))),j.append(k),i.append(j),h.children&&h.children.length?e(k,h.children):n&&!h.requiresajaxloading&&(j.removeClass("contains_branch"),k.addClass("emptybranch"))}}),g.parent().append(i);var j=g.attr("id")+"_group";i.attr("id",j),g.attr("aria-owns",j),g.attr("role","treeitem")}var f={ACTIVITY:40,RESOURCE:50};return{render:function(a,b){if(b.children&&b.children.length){e(a,b.children);var c=a.children("[role='treeitem']").first(),d=a.find("#"+c.attr("aria-owns"));c.attr("aria-expanded",!0),d.attr("aria-hidden",!1)}else a.parent().hasClass("contains_branch")&&(a.parent().removeClass("contains_branch"),a.addClass("emptybranch"))}}});
|
@ -22,7 +22,7 @@
|
||||
* @copyright 2015 John Okely <john@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery'], function($) {
|
||||
define(['jquery', 'core/templates', 'core/notification', 'core/url'], function($, Templates, Notification, Url) {
|
||||
|
||||
// Mappings for the different types of nodes coming from the navigation.
|
||||
// Copied from lib/navigationlib.php navigation_node constants.
|
||||
@ -75,28 +75,12 @@ define(['jquery'], function($) {
|
||||
p.addClass('branch');
|
||||
}
|
||||
|
||||
if (node.icon && (!isBranch || node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE)) {
|
||||
li.addClass('item_with_icon');
|
||||
p.addClass('hasicon');
|
||||
|
||||
icon = $('<img/>');
|
||||
icon.attr('alt', node.icon.alt);
|
||||
icon.attr('title', node.icon.title);
|
||||
icon.attr('src', M.util.image_url(node.icon.pix, node.icon.component));
|
||||
$.each(node.icon.classes, function(index, className) {
|
||||
icon.addClass(className);
|
||||
});
|
||||
}
|
||||
|
||||
var eleToAddIcon = null;
|
||||
if (node.link) {
|
||||
var link = $('<a title="' + node.title + '" href="' + node.link + '"></a>');
|
||||
|
||||
if (icon) {
|
||||
link.append(icon);
|
||||
link.append('<span class="item-content-wrap">' + node.name + '</span>');
|
||||
} else {
|
||||
link.append(node.name);
|
||||
}
|
||||
eleToAddIcon = link;
|
||||
link.append('<span class="item-content-wrap">' + node.name + '</span>');
|
||||
|
||||
if (node.hidden) {
|
||||
link.addClass('dimmed');
|
||||
@ -106,12 +90,8 @@ define(['jquery'], function($) {
|
||||
} else {
|
||||
var span = $('<span></span>');
|
||||
|
||||
if (icon) {
|
||||
span.append(icon);
|
||||
span.append('<span class="item-content-wrap">' + node.name + '</span>');
|
||||
} else {
|
||||
span.append(node.name);
|
||||
}
|
||||
eleToAddIcon = span;
|
||||
span.append('<span class="item-content-wrap">' + node.name + '</span>');
|
||||
|
||||
if (node.hidden) {
|
||||
span.addClass('dimmed');
|
||||
@ -120,6 +100,31 @@ define(['jquery'], function($) {
|
||||
p.append(span);
|
||||
}
|
||||
|
||||
if (node.icon && (!isBranch || node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE)) {
|
||||
li.addClass('item_with_icon');
|
||||
p.addClass('hasicon');
|
||||
|
||||
if (node.type === NODETYPE.ACTIVITY || node.type === NODETYPE.RESOURCE) {
|
||||
icon = $('<img/>');
|
||||
icon.attr('alt', node.icon.alt);
|
||||
icon.attr('title', node.icon.title);
|
||||
icon.attr('src', Url.imageUrl(node.icon.pix, node.icon.component));
|
||||
$.each(node.icon.classes, function(index, className) {
|
||||
icon.addClass(className);
|
||||
});
|
||||
eleToAddIcon.prepend(icon);
|
||||
} else {
|
||||
if (node.icon.component == 'moodle') {
|
||||
node.icon.component = 'core';
|
||||
}
|
||||
Templates.renderPix(node.icon.pix, node.icon.component, node.icon.title).then(function(html) {
|
||||
// Prepend.
|
||||
eleToAddIcon.prepend(html);
|
||||
return;
|
||||
}).catch(Notification.exception);
|
||||
}
|
||||
}
|
||||
|
||||
li.append(p);
|
||||
ul.append(li);
|
||||
|
||||
|
@ -71,6 +71,6 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.block_navigation .block_tree [aria-hidden="true"] {
|
||||
.block_navigation .block_tree [aria-hidden="true"]:not(.icon) {
|
||||
display: none;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.block_settings .block_tree [aria-hidden="true"] {
|
||||
.block_settings .block_tree [aria-hidden="true"]:not(.icon) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ class icon_system_fontawesome extends icon_system_font {
|
||||
'core:i/mnethost' => 'fa-external-link',
|
||||
'core:i/moodle_host' => 'fa-graduation-cap',
|
||||
'core:i/move_2d' => 'fa-arrows',
|
||||
'core:i/navigationitem' => 'fa-angle-right',
|
||||
'core:i/navigationitem' => 'fa-fw',
|
||||
'core:i/ne_red_mark' => 'fa-remove',
|
||||
'core:i/new' => 'fa-plus',
|
||||
'core:i/news' => 'fa-newspaper-o',
|
||||
@ -280,7 +280,7 @@ class icon_system_fontawesome extends icon_system_font {
|
||||
'core:i/scales' => 'fa-balance-scale',
|
||||
'core:i/scheduled' => 'fa-calendar-check-o',
|
||||
'core:i/search' => 'fa-search',
|
||||
'core:i/settings' => 'fa-cogs',
|
||||
'core:i/settings' => 'fa-cog',
|
||||
'core:i/show' => 'fa-eye-slash',
|
||||
'core:i/siteevent' => 'fa-share-alt',
|
||||
'core:i/star-rating' => 'fa-star',
|
||||
|
@ -206,3 +206,45 @@ $doughnut-fill-colour: $brand-warning;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show expand collapse with font-awesome.
|
||||
.block_settings .block_tree [aria-expanded="true"],
|
||||
.block_settings .block_tree [aria-expanded="true"].emptybranch,
|
||||
.block_settings .block_tree [aria-expanded="false"],
|
||||
.block_navigation .block_tree [aria-expanded="true"],
|
||||
.block_navigation .block_tree [aria-expanded="true"].emptybranch,
|
||||
.block_navigation .block_tree [aria-expanded="false"] {
|
||||
background-image: none;
|
||||
}
|
||||
.block_settings .block_tree [aria-expanded="true"]:before,
|
||||
.block_navigation .block_tree [aria-expanded="true"]:before {
|
||||
content: $fa-var-angle-down;
|
||||
margin-right: 0;
|
||||
font-size: 16px;
|
||||
@extend .fa;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.block_settings .block_tree [aria-expanded="false"]:before,
|
||||
.block_navigation .block_tree [aria-expanded="false"]:before {
|
||||
content: $fa-var-angle-right;
|
||||
font-size: 16px;
|
||||
margin-right: 0;
|
||||
@extend .fa;
|
||||
width: 16px;
|
||||
}
|
||||
.dir-rtl {
|
||||
.block_settings .block_tree [aria-expanded="false"]:before,
|
||||
.block_navigation .block_tree [aria-expanded="false"]:before {
|
||||
content: $fa-var-angle-left;
|
||||
}
|
||||
}
|
||||
|
||||
.block_navigation .block_tree p.hasicon,
|
||||
.block_settings .block_tree p.hasicon {
|
||||
text-indent: -3px;
|
||||
|
||||
.icon {
|
||||
margin-right: 2px;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user