Skip to content

Added support for font-awesome icons by using fa-icon as icon class a… #399

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

Merged
merged 1 commit into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified dist/font/context-menu-icons.eot
Binary file not shown.
Binary file modified dist/font/context-menu-icons.ttf
Binary file not shown.
Binary file modified dist/font/context-menu-icons.woff
Binary file not shown.
Binary file modified dist/font/context-menu-icons.woff2
Binary file not shown.
82 changes: 58 additions & 24 deletions dist/jquery.contextMenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,15 @@
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
* Date: 2016-04-25T15:40:40.026Z
* Date: 2016-05-24T13:08:41.760Z
*/
@font-face {
font-family: "context-menu-icons";
font-style: normal;
font-weight: normal;

src: url("font/context-menu-icons.eot?ilzz");
src: url("font/context-menu-icons.eot?ilzz#iefix") format("embedded-opentype"), url("font/context-menu-icons.woff2?ilzz") format("woff2"), url("font/context-menu-icons.woff?ilzz") format("woff"), url("font/context-menu-icons.ttf?ilzz") format("truetype");
}

.context-menu-icon:before {
position: absolute;
top: 50%;
left: 0;
width: 2em;
font-family: "context-menu-icons";
font-size: 1em;
font-style: normal;
font-weight: normal;
line-height: 1;
color: #2980b9;
text-align: center;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
src: url("font/context-menu-icons.eot?1rzc4");
src: url("font/context-menu-icons.eot?1rzc4#iefix") format("embedded-opentype"), url("font/context-menu-icons.woff2?1rzc4") format("woff2"), url("font/context-menu-icons.woff?1rzc4") format("woff"), url("font/context-menu-icons.ttf?1rzc4") format("truetype");
}

.context-menu-icon-add:before {
Expand Down Expand Up @@ -72,6 +51,27 @@
content: "\EA07";
}

.context-menu-icon::before {
position: absolute;
top: 50%;
left: 0;
width: 2em;
font-family: "context-menu-icons";
font-size: 1em;
font-style: normal;
font-weight: normal;
line-height: 1;
color: #2980b9;
text-align: center;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.context-menu-icon.context-menu-hover:before {
color: #fff;
}
Expand All @@ -80,6 +80,40 @@
color: #bbb;
}

.context-menu-icon.context-menu-icon--fa {
display: list-item;
}
.context-menu-icon.context-menu-icon--fa::before {
position: absolute;
top: 50%;
left: 0;
width: 2em;
font-family: FontAwesome;
font-size: 1em;
font-style: normal;
font-weight: normal;
line-height: 1;
color: #2980b9;
text-align: center;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.context-menu-icon.context-menu-icon--fa.context-menu-hover:before {
color: #fff;
}
.context-menu-icon.context-menu-icon--fa.context-menu-disabled::before {
color: #bbb;
}

.context-menu-icon.context-menu-icon--fa span {
font-family: sans-serif;
}

.context-menu-list {
position: absolute;
display: inline-block;
Expand Down
19 changes: 16 additions & 3 deletions dist/jquery.contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* MIT License http://www.opensource.org/licenses/mit-license
* GPL v3 http://opensource.org/licenses/GPL-3.0
*
* Date: 2016-05-24T08:12:16.165Z
* Date: 2016-05-24T13:09:41.117Z
*/

(function (factory) {
Expand Down Expand Up @@ -1087,7 +1087,15 @@
$name.append(document.createTextNode(item._afterAccesskey));
}
} else {
$name.text(item.name);
if (item.isHtmlName) {
// restrict use with access keys
if (typeof item.accesskey !== 'undefined') {
throw new Error('accesskeys are not compatible with HTML names and cannot be used together in the same item');
}
$name.html(item.name);
} else {
$name.text(item.name);
}
}
return $name;
}
Expand Down Expand Up @@ -1252,7 +1260,12 @@
if ($.isFunction(item.icon)) {
item._icon = item.icon.call(this, this, $t, key, item);
} else {
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
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);
}
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.contextMenu.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading