Commit 57ea73d0 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-58808 fontawesome: nav and settings blocks

parent 6bb80a19
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment