webcola.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * WebCola layout plugin.
  3. */
  4. Draw.loadPlugin(function(ui)
  5. {
  6. mxscript("plugins/webcola/cola.min.js", null, null, null, true);
  7. mxscript("plugins/webcola/mxWebColaAdaptor.js", null, null, null, true);
  8. mxscript("plugins/webcola/mxWebColaLayout.js", null, null, null, true);
  9. // Adds resource for action
  10. mxResources.parse('webColaLayout=WebCola Layout...');
  11. // Adds action
  12. ui.actions.addAction('webColaLayout', function()
  13. {
  14. // TODO: set mxWebColaAdaptor's doAnimations to the value of editorUi.allowAnimation
  15. // TODO: don't record all animation steps as undo states
  16. var graph = ui.editor.graph;
  17. var layout = new mxWebColaLayout(graph);
  18. var parent = graph.getDefaultParent();
  19. layout.execute(parent);
  20. });
  21. var menu = ui.menus.get('layout');
  22. if (menu != null)
  23. {
  24. var oldFunct = menu.funct;
  25. menu.funct = function(menu, parent)
  26. {
  27. oldFunct.apply(this, arguments);
  28. if (typeof window.mxWebColaLayout === 'function')
  29. {
  30. ui.menus.addMenuItems(menu, ['-', 'webColaLayout'], parent);
  31. }
  32. };
  33. }
  34. });