From e2e7e109d813b7ecc548879e36981390df16ff7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Balc=C4=B1?= Date: Tue, 10 Sep 2019 14:53:18 +0300 Subject: [PATCH] Partially fix #84 --- cytoscape-expand-collapse.js | 9 +++++++-- src/undoRedoUtilities.js | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cytoscape-expand-collapse.js b/cytoscape-expand-collapse.js index 264ac4b..c8a001d 100644 --- a/cytoscape-expand-collapse.js +++ b/cytoscape-expand-collapse.js @@ -1806,7 +1806,12 @@ module.exports = function (cy, api) { var actions = ["collapse", "collapseRecursively", "collapseAll", "expand", "expandRecursively", "expandAll"]; for (var i = 0; i < actions.length; i++) { - ur.action(actions[i], doIt(actions[i]), doIt(actions[(i + 3) % 6])); + if(i == 2) + ur.action("collapseAll", doIt("collapseAll"), doIt("expandRecursively")); + else if(i == 5) + ur.action("expandAll", doIt("expandAll"), doIt("collapseRecursively")); + else + ur.action(actions[i], doIt(actions[i]), doIt(actions[(i + 3) % 6])); } }; @@ -1814,4 +1819,4 @@ module.exports = function (cy, api) { },{}]},{},[6])(6) }); -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvYm91bmRpbmdCb3hVdGlsaXRpZXMuanMiLCJzcmMvY3VlVXRpbGl0aWVzLmpzIiwic3JjL2RlYm91bmNlLmpzIiwic3JjL2VsZW1lbnRVdGlsaXRpZXMuanMiLCJzcmMvZXhwYW5kQ29sbGFwc2VVdGlsaXRpZXMuanMiLCJzcmMvaW5kZXguanMiLCJzcmMvdW5kb1JlZG9VdGlsaXRpZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QU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gICAgZGF0YS5oYXNFdmVudEZpZWxkcyA9IHRydWU7XG4gICAgICBzZXREYXRhKCBkYXRhICk7XG4gICAgfSxcbiAgICB1bmJpbmQ6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgLy8gdmFyICRjb250YWluZXIgPSB0aGlzO1xuICAgICAgICB2YXIgZGF0YSA9IGdldERhdGEoKTtcblxuICAgICAgICBpZiAoIWRhdGEuaGFzRXZlbnRGaWVsZHMpIHtcbiAgICAgICAgICBjb25zb2xlLmxvZyggJ2V2ZW50cyB0byB1bmJpbmQgZG9lcyBub3QgZXhpc3QnICk7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgY3kudHJpZ2dlcignZXhwYW5kY29sbGFwc2UuY2xlYXJ2aXN1YWxjdWUnKTtcblxuICAgICAgICBjeS5vZmYoJ21vdXNlb3ZlcicsICdub2RlJywgZGF0YS5lTW91c2VPdmVyKVxuICAgICAgICAgIC5vZmYoJ21vdXNlbW92ZScsICdub2RlJywgZGF0YS5lTW91c2VNb3ZlKVxuICAgICAgICAgIC5vZmYoJ21vdXNlZG93bicsICdub2RlJywgZGF0YS5lTW91c2VEb3duKVxuICAgICAgICAgIC5vZmYoJ21vdXNldXAnLCAnbm9kZScsIGRhdGEuZU1vdXNlVXApXG4gICAgICAgICAgLm9mZignZnJlZScsICdub2RlJywgZGF0YS5lRnJlZSlcbiAgICAgICAgICAub2ZmKCdncmFiJywgJ25vZGUnLCBkYXRhLmVHcmFiKVxuICAgICAgICAgIC5vZmYoJ3Bvc2l0aW9uJywgJ25vZGUnLCBkYXRhLmVQb3NpdGlvbilcbiAgICAgICAgICAub2ZmKCdyZW1vdmUnLCAnbm9kZScsIGRhdGEuZVJlbW92ZSlcbiAgICAgICAgICAub2ZmKCd0YXAnLCAnbm9kZScsIGRhdGEuZVRhcClcbiAgICAgICAgICAub2ZmKCdhZGQnLCAnbm9kZScsIGRhdGEuZUFkZClcbiAgICAgICAgICAub2ZmKCdzZWxlY3QnLCAnbm9kZScsIGRhdGEuZVNlbGVjdClcbiAgICAgICAgICAub2ZmKCdmcmVlJywgJ25vZGUnLCBkYXRhLmVGcmVlKVxuICAgICAgICAgIC5vZmYoJ3pvb20gcGFuJywgZGF0YS5lWm9vbSk7XG5cbiAgICAgIHdpbmRvdy5yZW1vdmVFdmVudExpc3RlbmVyKCdyZXNpemUnLCBkYXRhLmVXaW5kb3dSZXNpemUpO1xuICAgIH0sXG4gICAgcmViaW5kOiBmdW5jdGlvbiAoKSB7XG4gICAgICB2YXIgZGF0YSA9IGdldERhdGEoKTtcblxuICAgICAgaWYgKCFkYXRhLmhhc0V2ZW50RmllbGRzKSB7XG4gICAgICAgIGNvbnNvbGUubG9nKCAnZXZlbnRzIHRvIHJlYmluZCBkb2VzIG5vdCBleGlzdCcgKTtcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuXG4gICAgICBjeS5vbignbW91c2VvdmVyJywgJ25vZGUnLCBkYXRhLmVNb3VzZU92ZXIpXG4gICAgICAgIC5vbignbW91c2Vtb3ZlJywgJ25vZGUnLCBkYXRhLmVNb3VzZU1vdmUpXG4gICAgICAgIC5vbignbW91c2Vkb3duJywgJ25vZGUnLCBkYXRhLmVNb3VzZURvd24pXG4gICAgICAgIC5vbignbW91c2V1cCcsICdub2RlJywgZGF0YS5lTW91c2VVcClcbiAgICAgICAgLm9uKCdmcmVlJywgJ25vZGUnLCBkYXRhLmVGcmVlKVxuICAgICAgICAub24oJ2dyYWInLCAnbm9kZScsIGRhdGEuZUdyYWIpXG4gICAgICAgIC5vbigncG9zaXRpb24nLCAnbm9kZScsIGRhdGEuZVBvc2l0aW9uKVxuICAgICAgICAub24oJ3JlbW92ZScsICdub2RlJywgZGF0YS5lUmVtb3ZlKVxuICAgICAgICAub24oJ3RhcCcsICdub2RlJywgZGF0YS5lVGFwKVxuICAgICAgICAub24oJ2FkZCcsICdub2RlJywgZGF0YS5lQWRkKVxuICAgICAgICAub24oJ3NlbGVjdCc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wLFxuICAgICAgICAgICAgbGVmdDogcmVjdC5sZWZ0ICsgZG9jdW1lbnQuZG9jdW1lbnRFbGVtZW50LnNjcm9sbExlZnRcbiAgICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIHZhciBfc2l6ZUNhbnZhcyA9IGRlYm91bmNlKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgJGNhbnZhcy5oZWlnaHQgPSBjeS5oZWlnaHQoKTtcbiAgICAgICAgJGNhbnZhcy53aWR0aCA9IGN5LndpZHRoKCk7XG4gICAgICAgICRjYW52YXMuc3R5bGUucG9zaXRpb24gPSAnYWJzb2x1dGUnO1xuICAgICAgICAkY2FudmFzLnN0eWxlLnRvcCA9IDA7XG4gICAgICAgICRjYW52YXMuc3R5bGUubGVmdCA9IDA7XG4gICAgICAgICRjYW52YXMuc3R5bGUuekluZGV4ID0gb3B0aW9ucygpLnpJbmRleDtcblxuICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICB2YXIgY2FudmFzQmIgPSBvZmZzZXQoJGNhbnZhcyk7XG4gICAgICAgICAgdmFyIGNvbnRhaW5lckJiID0gb2Zmc2V0KCRjb250YWluZXIpO1xuICAgICAgICAgICRjYW52YXMuc3R5bGUudG9wID0gLShjYW52YXNCYi50b3AgLSBjb250YWluZXJCYi50b3ApO1xuICAgICAgICAgICRjYW52YXMuc3R5bGUubGVmdCA9IC0oY2FudmFzQmIubGVmdCAtIGNvbnRhaW5lckJiLmxlZnQpO1xuXG4gICAgICAgICAgLy8gcmVmcmVzaCB0aGUgY3VlcyBvbiBjYW52YXMgcmVzaXplXG4gICAgICAgICAgaWYoY3kpe1xuICAgICAgICAgICAgY2xlYXJEcmF3cyh0cnVlKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0sIDApO1xuXG4gICAgICB9LCAyNTApO1xuXG4gICAgICBmdW5jdGlvbiBzaXplQ2FudmFzKCkge1xuICAgICAgICBfc2l6ZUNhbnZhcygpO1xuICAg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G9zaXRpb24pXG4gICAgICAgICAgLm9mZigncmVtb3ZlJywgJ25vZGUnLCBkYXRhLmVSZW1vdmUpXG4gICAgICAgICAgLm9mZigndGFwJywgJ25vZGUnLCBkYXRhLmVUYXApXG4gICAgICAgICAgLm9mZignYWRkJywgJ25vZGUnLCBkYXRhLmVBZGQpXG4gICAgICAgICAgLm9mZignc2VsZWN0JywgJ25vZGUnLCBkYXRhLmVTZWxlY3QpXG4gICAgICAgICAgLm9mZignZnJlZScsICdub2RlJywgZGF0YS5lRnJlZSlcbiAgICAgICAgICAub2ZmKCd6b29tIHBhbicsIGRhdGEuZVpvb20pO1xuXG4gICAgICB3aW5kb3cucmVtb3ZlRXZlbnRMaXN0ZW5lcigncmVzaXplJywgZGF0YS5lV2luZG93UmVzaXplKTtcbiAgICB9LFxuICAgIHJlYmluZDogZnVuY3Rpb24gKCkge1xuICAgICAgdmFyIGRhdGEgPSBnZXREYXRhKCk7XG5cbiAgICAgIGlmICghZGF0YS5oYXNFdmVudEZpZWxkcykge1xuICAgICAgICBjb25zb2xlLmxvZyggJ2V2ZW50cyB0byByZWJpbmQgZG9lcyBub3QgZXhpc3QnICk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgY3kub24oJ21vdXNlb3ZlcicsICdub2RlJywgZGF0YS5lTW91c2VPdmVyKVxuICAgICAgICAub24oJ21vdXNlbW92ZScsICdub2RlJywgZGF0YS5lTW91c2VNb3ZlKVxuICAgICAgICAub24oJ21vdXNlZG93bicsICdub2RlJywgZGF0YS5lTW91c2VEb3duKVxuICAgICAgICAub24oJ21vdXNldXAnLCAnbm9kZScsIGRhdGEuZU1vdXNlVXApXG4gICAgICAgIC5vbignZnJlZScsICdub2RlJywgZGF0YS5lRnJlZSlcbiAgICAgICAgLm9uKCdncmFiJywgJ25vZGUnLCBkYXRhLmVHcmFiKVxuICAgICAgICAub24oJ3Bvc2l0aW9uJywgJ25vZGUnLCBkYXRhLmVQb3NpdGlvbilcbiAgICAg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gYW5pbWF0ZTsgLy8gU2lnbmFsIHRoYXQgdGhlcmUgaXMgYW4gYW5pbWF0aW9uIG5vdyBhbmQgY29tbW9uRXhwYW5kT3BlcmF0aW9uIHdpbGwgYmUgY2FsbGVkIGFmdGVyIGFuaW1hdGlvblxuICAgICAgICAgIC8vIENoZWNrIGlmIHdlIG5lZWQgdG8gYW5pbWF0ZSBkdXJpbmcgcGFuIGFuZCB6b29tXG4gICAgICAgICAgaWYgKGFuaW1hdGUpIHtcbiAgICAgICAgICAgIGN5LmFuaW1hdGUoe1xuICAgICAgICAgICAgICBwYW46IHZpZXdQb3J0LnBhbixcbiAgICAgICAgICAgICAgem9vbTogdmlld1BvcnQuem9vbSxcbiAgICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBjb21tb25FeHBhbmRPcGVyYXRpb24obm9kZSwgYXBwbHlGaXNoRXllVmlldywgc2luZ2xlLCBhbmltYXRlLCBsYXlvdXRCeSwgYW5pbWF0aW9uRHVyYXRpb24pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgIGR1cmF0aW9uOiBhbmltYXRpb25EdXJhdGlvbiB8fCAxMDAwXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBjeS56b29tKHZpZXdQb3J0Lnpvb20pO1xuICAgICAgICAgICAgY3kucGFuKHZpZXdQb3J0LnBhbik7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBcbiAgICAgIC8vIElmIGFuaW1hdGluZyBpcyBub3QgdHJ1ZSB3ZSBuZWVkIHRvIGNhbGwgY29tbW9uRXhwYW5kT3BlcmF0aW9uIGhlcmVcbiAgICAgIGlmICghYW5pbWF0aW5nKSB7XG4gICAgICAgIGNvbW1vbkV4cGFuZE9wZXJhdGlvbihub2RlLCBhcHBseUZpc2hFeWVWaWV3LC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CJleHBhbmRBbGxcIiwgZG9JdChcImV4cGFuZEFsbFwiKSwgZG9JdChcImNvbGxhcHNlUmVjdXJzaXZlbHlcIikpO1xuICAgIGVsc2VcbiAgICAgIHVyLmFjdGlvbihhY3Rpb25zW2ldLCBkb0l0KGFjdGlvbnNbaV0pLCBkb0l0KGFjdGlvbnNbKGkgKyAzKSAlIDZdKSk7XG4gIH1cblxufTtcbiJdfQ== diff --git a/src/undoRedoUtilities.js b/src/undoRedoUtilities.js index 33deb75..f625711 100644 --- a/src/undoRedoUtilities.js +++ b/src/undoRedoUtilities.js @@ -69,7 +69,12 @@ module.exports = function (cy, api) { var actions = ["collapse", "collapseRecursively", "collapseAll", "expand", "expandRecursively", "expandAll"]; for (var i = 0; i < actions.length; i++) { - ur.action(actions[i], doIt(actions[i]), doIt(actions[(i + 3) % 6])); + if(i == 2) + ur.action("collapseAll", doIt("collapseAll"), doIt("expandRecursively")); + else if(i == 5) + ur.action("expandAll", doIt("expandAll"), doIt("collapseRecursively")); + else + ur.action(actions[i], doIt(actions[i]), doIt(actions[(i + 3) % 6])); } };