-
Notifications
You must be signed in to change notification settings - Fork 741
Font Awesome not supported #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for this, i'll have a look how we can integrate this. The reasoning using a custom font was mostly to enable users to use their owns icons easily. When we do development we usually need custom icons and this way by including the sass in your application you can add custom icons without a problem. I do understand that some people prefer just to use the font-awesome set and go from there. Just need to look how to clean up the CSS. Also think i need to reintroduce the So basically something like: if (item.icon) {
if ($.isFunction(item.icon)) {
item._icon = item.icon.call(this, this, $t, key, item);
} else {
if ( typeof(item.icon) === 'string' && item.icon.substring(0,3) == 'fa-' ) {
// to enable font awesome
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
} else {
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
}
}
$t.addClass(item._icon);
} If the CSS that is currently in the list of icons is moved to .contextmenu-icon--fa {
font-family: FontAwesome;
}
.contextmenu-icon--fa span {
font-family: sans-serif;
} I see a Anyways, thanks for this. I'll look into it some more soon. |
+1 |
1 similar comment
+1 |
For the others trying to use font-awesome icon's, this is a little CSS trick that works for me. Unfortunately, you have to look up the content for e.g. bluetooth in the font-awesome.css.
|
Thanks for this fix, rootuser, it works great! |
Oh, nice @frankhommers I just did the same in #392 . Hahaha... I could save some minutes if I checked this before. 😅 |
Hello,
I recently needed a context menu for one of my projects and stumbled upon your plugin. I do like it very much; it is just what I needed.
There was one major drawback though: it did not support font awesome. (Actually, I don't understand why you create your own font for the icons. I would be glad to learn the reason for this.)
In the meantime, I created a quick fix to support font awesome, and I am about to share it right here :)
First, we need some additions to the jquery.contextMenu.css file:
Just add
Then, in jquery.contextMenu.js, find the following code block:
In release 2.0.1, you will find it beginning at line 1199. Change the else clause:
This will assign the CSS classes above to the menu items with icon names beginning with 'fa-'. And that is all we need to do here.
The usage is very simple:
Firstly, you must of course reference Font Awesome in your HMTL file. Like this for example:
In your Javascript $contextMenu() call, you can now simply use Font Awesome icon names in the items block, like 'fa-arrow-right' or ' fa-cut'. Example:
Have fun!
The text was updated successfully, but these errors were encountered: