p1.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Sample plugin.
  3. */
  4. Draw.loadPlugin(function(ui) {
  5. // Adds custom sidebar entry
  6. ui.sidebar.addPalette('esolia', 'eSolia', true, function(content) {
  7. // content.appendChild(ui.sidebar.createVertexTemplate(null, 120, 60));
  8. content.appendChild(ui.sidebar.createVertexTemplate('shape=image;image=http://download.esolia.net.s3.amazonaws.com/img/eSolia-Logo-Color.svg;resizable=0;movable=0;rotatable=0', 100, 100));
  9. content.appendChild(ui.sidebar.createVertexTemplate('text;spacingTop=-5;fontFamily=Courier New;fontSize=8;fontColor=#999999;resizable=0;movable=0;rotatable=0', 100, 100));
  10. content.appendChild(ui.sidebar.createVertexTemplate('rounded=1;whiteSpace=wrap;gradientColor=none;fillColor=#004C99;shadow=1;strokeColor=#FFFFFF;align=center;fontColor=#FFFFFF;strokeWidth=3;fontFamily=Courier New;verticalAlign=middle', 100, 100));
  11. content.appendChild(ui.sidebar.createVertexTemplate('curved=1;strokeColor=#004C99;endArrow=oval;endFill=0;strokeWidth=3;shadow=1;dashed=1', 100, 100));
  12. });
  13. // Collapses default sidebar entry and inserts this before
  14. var c = ui.sidebar.container;
  15. c.firstChild.click();
  16. c.insertBefore(c.lastChild, c.firstChild);
  17. c.insertBefore(c.lastChild, c.firstChild);
  18. // Adds logo to footer
  19. ui.footerContainer.innerHTML = '<img width=50px height=17px align="right" style="margin-top:14px;margin-right:12px;" ' + 'src="http://download.esolia.net.s3.amazonaws.com/img/eSolia-Logo-Color.svg"/>';
  20. // Adds variables in labels (%today, %filename%)
  21. var superGetLabel = ui.editor.graph.getLabel;
  22. ui.editor.graph.getLabel = function(cell)
  23. {
  24. var result = superGetLabel.apply(this, arguments);
  25. if (result != null)
  26. {
  27. var today = new Date().toLocaleString();
  28. var file = ui.getCurrentFile();
  29. var filename = (file != null && file.getTitle() != null) ? file.getTitle() : '';
  30. result = result.replace('%today%', today).replace('%filename%', filename);
  31. }
  32. return result;
  33. };
  34. // // Adds resource for action
  35. // mxResources.parse('helloWorldAction=Hello, World!');
  36. //
  37. // // Adds action
  38. // ui.actions.addAction('helloWorldAction', function() {
  39. // var ran = Math.floor((Math.random() * 100) + 1);
  40. // mxUtils.alert('A random number is ' + ran);
  41. // });
  42. //
  43. // // Adds menu
  44. // ui.menubar.addMenu('Hello, World Menu', function(menu, parent) {
  45. // ui.menus.addMenuItem(menu, 'helloWorldAction');
  46. // });
  47. //
  48. // // Reorders menubar
  49. // ui.menubar.container.insertBefore(ui.menubar.container.lastChild,
  50. // ui.menubar.container.lastChild.previousSibling.previousSibling);
  51. //
  52. // // Adds toolbar button
  53. // ui.toolbar.addSeparator();
  54. // var elt = ui.toolbar.addItem('', 'helloWorldAction');
  55. //
  56. // // Cannot use built-in sprites
  57. // elt.firstChild.style.backgroundImage = 'url(https://www.draw.io/images/logo-small.gif)';
  58. // elt.firstChild.style.backgroundPosition = '2px 3px';
  59. });