Skip to content

Commit 703f2f9

Browse files
committed
Merge remote-tracking branch 'origin/feature-2.x-font-awesome-5'
# Conflicts: # CHANGELOG.md # dist/font/context-menu-icons.eot # dist/font/context-menu-icons.ttf # dist/font/context-menu-icons.woff # dist/font/context-menu-icons.woff2 # dist/jquery.contextMenu.css # dist/jquery.contextMenu.js # dist/jquery.contextMenu.min.css # dist/jquery.contextMenu.min.css.map # dist/jquery.contextMenu.min.js # dist/jquery.contextMenu.min.js.map # src/sass/icons/_variables.scss
2 parents 1742a80 + a8b95d0 commit 703f2f9

17 files changed

+126
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
* Fixed typo in documentation which breaks the `callback` demo.
99
* Fixed typo `promis` => `promise` ([Issue #633](https://github.com/swisnl/jQuery-contextMenu/issues/633)).
1010

11+
#### Added
12+
13+
* Added support for Font Awesome 5 ([Issue #593](https://github.com/swisnl/jQuery-contextMenu/issues/593)), ([Issue #593](https://github.com/swisnl/jQuery-contextMenu/issues/593))
14+
1115
### 2.6.4
1216

1317
#### Fixed

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

32 Bytes
Binary file not shown.

dist/jquery.contextMenu.css

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Licensed under
1313
* MIT License http://www.opensource.org/licenses/mit-license
1414
*
15-
* Date: 2018-07-10T11:22:08.713Z
15+
* Date: 2018-07-11T17:37:50.000Z
1616
*/
1717
@-webkit-keyframes cm-spin {
1818
0% {
@@ -54,8 +54,8 @@
5454
font-style: normal;
5555
font-weight: normal;
5656

57-
src: url("font/context-menu-icons.eot?2zb9c");
58-
src: url("font/context-menu-icons.eot?2zb9c#iefix") format("embedded-opentype"), url("font/context-menu-icons.woff2?2zb9c") format("woff2"), url("font/context-menu-icons.woff?2zb9c") format("woff"), url("font/context-menu-icons.ttf?2zb9c") format("truetype");
57+
src: url("font/context-menu-icons.eot?22n6c");
58+
src: url("font/context-menu-icons.eot?22n6c#iefix") format("embedded-opentype"), url("font/context-menu-icons.woff2?22n6c") format("woff2"), url("font/context-menu-icons.woff?22n6c") format("woff"), url("font/context-menu-icons.ttf?22n6c") format("truetype");
5959
}
6060

6161
.context-menu-icon-add:before {
@@ -157,6 +157,24 @@
157157
color: #bbb;
158158
}
159159

160+
.context-menu-icon.context-menu-icon--fa5 {
161+
display: list-item;
162+
font-family: inherit;
163+
line-height: inherit;
164+
}
165+
.context-menu-icon.context-menu-icon--fa5 i, .context-menu-icon.context-menu-icon--fa5 svg {
166+
position: absolute;
167+
top: .3em;
168+
left: .5em;
169+
color: #2980b9;
170+
}
171+
.context-menu-icon.context-menu-icon--fa5.context-menu-hover i, .context-menu-icon.context-menu-icon--fa5.context-menu-hover svg {
172+
color: #fff;
173+
}
174+
.context-menu-icon.context-menu-icon--fa5.context-menu-disabled i, .context-menu-icon.context-menu-icon--fa5.context-menu-disabled svg {
175+
color: #bbb;
176+
}
177+
160178
.context-menu-list {
161179
position: absolute;
162180
display: inline-block;

dist/jquery.contextMenu.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Licensed under
1212
* MIT License http://www.opensource.org/licenses/mit-license
1313
*
14-
* Date: 2018-07-10T11:22:08.665Z
14+
* Date: 2018-07-10T10:24:25.826Z
1515
*/
1616

1717
// jscs:disable
@@ -116,7 +116,7 @@
116116
// flag denoting if a second trigger should simply move (true) or rebuild (false) an open menu
117117
// as long as the trigger happened on one of the trigger-element's child nodes
118118
reposition: true,
119-
// Flag denoting if a second trigger should close the menu, as long as
119+
// Flag denoting if a second trigger should close the menu, as long as
120120
// the trigger happened on one of the trigger-element's child nodes.
121121
// This overrides the reposition option.
122122
hideOnSecondTrigger: false,
@@ -466,12 +466,12 @@
466466
$(target).trigger(e);
467467
root.$layer.show();
468468
}
469-
469+
470470
if (root.hideOnSecondTrigger && triggerAction && root.$menu !== null && typeof root.$menu !== 'undefined') {
471471
root.$menu.trigger('contextmenu:hide');
472472
return;
473473
}
474-
474+
475475
if (root.reposition && triggerAction) {
476476
if (document.elementFromPoint) {
477477
if (root.$trigger.is(target)) {
@@ -1001,7 +1001,7 @@
10011001
// position and show context menu
10021002
opt.$menu.css(css)[opt.animation.show](opt.animation.duration, function () {
10031003
$trigger.trigger('contextmenu:visible');
1004-
1004+
10051005
op.activated(opt);
10061006
opt.events.activated(opt);
10071007
});
@@ -1213,9 +1213,7 @@
12131213
$t.addClass('context-menu-separator ' + root.classNames.notSelectable);
12141214
} else if (item.type === 'html') {
12151215
$t.addClass('context-menu-html ' + root.classNames.notSelectable);
1216-
} else if (item.type === 'sub') {
1217-
// We don't want to execute the next else-if if it is a sub.
1218-
} else if (item.type) {
1216+
} else if (item.type !== 'sub' && item.type) {
12191217
$label = $('<label></label>').appendTo($t);
12201218
createNameNode(item).appendTo($label);
12211219

@@ -1330,14 +1328,27 @@
13301328
if ($.isFunction(item.icon)) {
13311329
item._icon = item.icon.call(this, this, $t, key, item);
13321330
} else {
1333-
if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
1331+
if (typeof(item.icon) === 'string' && (
1332+
item.icon.substring(0, 4) === 'fab '
1333+
|| item.icon.substring(0, 4) === 'fas '
1334+
|| item.icon.substring(0, 4) === 'far '
1335+
|| item.icon.substring(0, 4) === 'fal ')
1336+
) {
13341337
// to enable font awesome
1338+
$t.addClass(root.classNames.icon + ' ' + root.classNames.icon + '--fa5');
1339+
item._icon = $('<i class="' + item.icon + '"></i>');
1340+
} else if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
13351341
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
13361342
} else {
13371343
item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
13381344
}
13391345
}
1340-
$t.addClass(item._icon);
1346+
1347+
if(typeof(item._icon) === "string"){
1348+
$t.addClass(item._icon);
1349+
} else {
1350+
$t.prepend(item._icon);
1351+
}
13411352
}
13421353
}
13431354

@@ -1433,8 +1444,12 @@
14331444

14341445
if ($.isFunction(item.icon)) {
14351446
$item.removeClass(item._icon);
1436-
item._icon = item.icon.call(this, $trigger, $item, key, item);
1437-
$item.addClass(item._icon);
1447+
var iconResult = item.icon.call(this, $trigger, $item, key, item);
1448+
if(typeof(iconResult) === "string"){
1449+
$item.addClass(iconResult);
1450+
} else {
1451+
$item.prepend(iconResult);
1452+
}
14381453
}
14391454

14401455
if (item.type) {
@@ -1565,7 +1580,7 @@
15651580
$menu.css({
15661581
'top': '0px'
15671582
});
1568-
}
1583+
}
15691584
}
15701585
};
15711586

dist/jquery.contextMenu.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)