Skip to content

Commit ac3db1b

Browse files
committed
Added support for font-awesome icons by using fa-icon as icon class and manually including font-awesome css.
See issues: #338 #328 #249
1 parent d685eea commit ac3db1b

14 files changed

+108
-39
lines changed

dist/font/context-menu-icons.eot

0 Bytes
Binary file not shown.

dist/font/context-menu-icons.ttf

0 Bytes
Binary file not shown.

dist/font/context-menu-icons.woff

0 Bytes
Binary file not shown.

dist/font/context-menu-icons.woff2

4 Bytes
Binary file not shown.

dist/jquery.contextMenu.css

+58-24
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,15 @@
1212
* Licensed under
1313
* MIT License http://www.opensource.org/licenses/mit-license
1414
*
15-
* Date: 2016-04-25T15:40:40.026Z
15+
* Date: 2016-05-24T13:08:41.760Z
1616
*/
1717
@font-face {
1818
font-family: "context-menu-icons";
1919
font-style: normal;
2020
font-weight: normal;
2121

22-
src: url("font/context-menu-icons.eot?ilzz");
23-
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");
24-
}
25-
26-
.context-menu-icon:before {
27-
position: absolute;
28-
top: 50%;
29-
left: 0;
30-
width: 2em;
31-
font-family: "context-menu-icons";
32-
font-size: 1em;
33-
font-style: normal;
34-
font-weight: normal;
35-
line-height: 1;
36-
color: #2980b9;
37-
text-align: center;
38-
-webkit-transform: translateY(-50%);
39-
-ms-transform: translateY(-50%);
40-
-o-transform: translateY(-50%);
41-
transform: translateY(-50%);
42-
43-
-webkit-font-smoothing: antialiased;
44-
-moz-osx-font-smoothing: grayscale;
22+
src: url("font/context-menu-icons.eot?1rzc4");
23+
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");
4524
}
4625

4726
.context-menu-icon-add:before {
@@ -72,6 +51,27 @@
7251
content: "\EA07";
7352
}
7453

54+
.context-menu-icon::before {
55+
position: absolute;
56+
top: 50%;
57+
left: 0;
58+
width: 2em;
59+
font-family: "context-menu-icons";
60+
font-size: 1em;
61+
font-style: normal;
62+
font-weight: normal;
63+
line-height: 1;
64+
color: #2980b9;
65+
text-align: center;
66+
-webkit-transform: translateY(-50%);
67+
-ms-transform: translateY(-50%);
68+
-o-transform: translateY(-50%);
69+
transform: translateY(-50%);
70+
71+
-webkit-font-smoothing: antialiased;
72+
-moz-osx-font-smoothing: grayscale;
73+
}
74+
7575
.context-menu-icon.context-menu-hover:before {
7676
color: #fff;
7777
}
@@ -80,6 +80,40 @@
8080
color: #bbb;
8181
}
8282

83+
.context-menu-icon.context-menu-icon--fa {
84+
display: list-item;
85+
}
86+
.context-menu-icon.context-menu-icon--fa::before {
87+
position: absolute;
88+
top: 50%;
89+
left: 0;
90+
width: 2em;
91+
font-family: FontAwesome;
92+
font-size: 1em;
93+
font-style: normal;
94+
font-weight: normal;
95+
line-height: 1;
96+
color: #2980b9;
97+
text-align: center;
98+
-webkit-transform: translateY(-50%);
99+
-ms-transform: translateY(-50%);
100+
-o-transform: translateY(-50%);
101+
transform: translateY(-50%);
102+
103+
-webkit-font-smoothing: antialiased;
104+
-moz-osx-font-smoothing: grayscale;
105+
}
106+
.context-menu-icon.context-menu-icon--fa.context-menu-hover:before {
107+
color: #fff;
108+
}
109+
.context-menu-icon.context-menu-icon--fa.context-menu-disabled::before {
110+
color: #bbb;
111+
}
112+
113+
.context-menu-icon.context-menu-icon--fa span {
114+
font-family: sans-serif;
115+
}
116+
83117
.context-menu-list {
84118
position: absolute;
85119
display: inline-block;

dist/jquery.contextMenu.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* MIT License http://www.opensource.org/licenses/mit-license
1313
* GPL v3 http://opensource.org/licenses/GPL-3.0
1414
*
15-
* Date: 2016-05-24T08:12:16.165Z
15+
* Date: 2016-05-24T13:09:41.117Z
1616
*/
1717

1818
(function (factory) {
@@ -1087,7 +1087,15 @@
10871087
$name.append(document.createTextNode(item._afterAccesskey));
10881088
}
10891089
} else {
1090-
$name.text(item.name);
1090+
if (item.isHtmlName) {
1091+
// restrict use with access keys
1092+
if (typeof item.accesskey !== 'undefined') {
1093+
throw new Error('accesskeys are not compatible with HTML names and cannot be used together in the same item');
1094+
}
1095+
$name.html(item.name);
1096+
} else {
1097+
$name.text(item.name);
1098+
}
10911099
}
10921100
return $name;
10931101
}
@@ -1252,7 +1260,12 @@
12521260
if ($.isFunction(item.icon)) {
12531261
item._icon = item.icon.call(this, this, $t, key, item);
12541262
} else {
1255-
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
1263+
if ( typeof(item.icon) === 'string' && item.icon.substring(0,3) == 'fa-' ) {
1264+
// to enable font awesome
1265+
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
1266+
} else {
1267+
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
1268+
}
12561269
}
12571270
$t.addClass(item._icon);
12581271
}

dist/jquery.contextMenu.min.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)