Skip to content

Instantly share code, notes, and snippets.

@robert-carroll
Created October 5, 2018 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robert-carroll/a2a681bc1966b0e4e92d3e4c2ae72d45 to your computer and use it in GitHub Desktop.
Save robert-carroll/a2a681bc1966b0e4e92d3e4c2ae72d45 to your computer and use it in GitHub Desktop.
nav icon
var addMenuButton = function(title, url, img) {
var id_title = 'global_nav_custom_' + title.replace(/\s/, '_').toLowerCase();
var button = $('<li class="custom-menu ic-app-header__menu-list-item" id="'+id_title+'_menu">' +
'<a id="'+id_title+'" href="'+url+'" class="ic-app-header__menu-list-link">' +
'<div class="menu-item-icon-container" aria-hidden="true"><span class="menu-item__badge" style="display: none">'+title+'</span><span class="svg-holder"></span></div>' +
'<div class="menu-item__text">' + title + '</div>' +
'</a>' +
'</li>');
button.find('.svg-holder').load(img, function(){
var svg = $(this).find('svg')[0];
try {
svg.classList.add('ic-icon-svg', 'ic-icon-svg--apps ic-icon-svg-ccsd');
}
catch (e) {
svg.setAttribute('class', 'ic-icon-svg ic-icon-svg--apps ic-icon-svg-ccsd');
}
$('#'+id_title+'_menu').remove();
$('#menu .menu-item:last').after(button);
});
};
addMenuButton(
"Nav Icon",
"#",
"https://raw.githubusercontent.com/robert-carroll/ccsd-canvas/master/global-nav-custom-tray/pin-gregor-cresnar.svg"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment