|
11 | 11 | * Licensed under
|
12 | 12 | * MIT License http://www.opensource.org/licenses/mit-license
|
13 | 13 | *
|
14 |
| - * Date: 2018-03-16T11:13:45.992Z |
| 14 | + * Date: 2018-07-10T10:17:15.594Z |
15 | 15 | */
|
16 | 16 |
|
17 | 17 | // jscs:disable
|
|
116 | 116 | // flag denoting if a second trigger should simply move (true) or rebuild (false) an open menu
|
117 | 117 | // as long as the trigger happened on one of the trigger-element's child nodes
|
118 | 118 | 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 |
120 | 120 | // the trigger happened on one of the trigger-element's child nodes.
|
121 | 121 | // This overrides the reposition option.
|
122 | 122 | hideOnSecondTrigger: false,
|
|
466 | 466 | $(target).trigger(e);
|
467 | 467 | root.$layer.show();
|
468 | 468 | }
|
469 |
| - |
| 469 | + |
470 | 470 | if (root.hideOnSecondTrigger && triggerAction && root.$menu !== null && typeof root.$menu !== 'undefined') {
|
471 | 471 | root.$menu.trigger('contextmenu:hide');
|
472 | 472 | return;
|
473 | 473 | }
|
474 |
| - |
| 474 | + |
475 | 475 | if (root.reposition && triggerAction) {
|
476 | 476 | if (document.elementFromPoint) {
|
477 | 477 | if (root.$trigger.is(target)) {
|
|
1001 | 1001 | // position and show context menu
|
1002 | 1002 | opt.$menu.css(css)[opt.animation.show](opt.animation.duration, function () {
|
1003 | 1003 | $trigger.trigger('contextmenu:visible');
|
1004 |
| - |
| 1004 | + |
1005 | 1005 | op.activated(opt);
|
1006 | 1006 | opt.events.activated(opt);
|
1007 | 1007 | });
|
|
1213 | 1213 | $t.addClass('context-menu-separator ' + root.classNames.notSelectable);
|
1214 | 1214 | } else if (item.type === 'html') {
|
1215 | 1215 | $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) { |
1219 | 1217 | $label = $('<label></label>').appendTo($t);
|
1220 | 1218 | createNameNode(item).appendTo($label);
|
1221 | 1219 |
|
|
1330 | 1328 | if ($.isFunction(item.icon)) {
|
1331 | 1329 | item._icon = item.icon.call(this, this, $t, key, item);
|
1332 | 1330 | } 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 | + ) { |
1334 | 1337 | // 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-') { |
1335 | 1341 | item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
|
1336 | 1342 | } else {
|
1337 | 1343 | item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
|
1338 | 1344 | }
|
1339 | 1345 | }
|
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 | + } |
1341 | 1352 | }
|
1342 | 1353 | }
|
1343 | 1354 |
|
|
1433 | 1444 |
|
1434 | 1445 | if ($.isFunction(item.icon)) {
|
1435 | 1446 | $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 | + } |
| 1453 | + delete iconResult; |
1438 | 1454 | }
|
1439 | 1455 |
|
1440 | 1456 | if (item.type) {
|
|
1565 | 1581 | $menu.css({
|
1566 | 1582 | 'top': '0px'
|
1567 | 1583 | });
|
1568 |
| - } |
| 1584 | + } |
1569 | 1585 | }
|
1570 | 1586 | };
|
1571 | 1587 |
|
|
0 commit comments