Minimal.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  1. /**
  2. * Code for the minimal UI theme.
  3. */
  4. EditorUi.initMinimalTheme = function()
  5. {
  6. // Disabled in lightbox mode
  7. if (urlParams['lightbox'] == '1' || urlParams['chrome'] == '0')
  8. {
  9. return;
  10. }
  11. var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  12. try
  13. {
  14. var style = document.createElement('style')
  15. style.type = 'text/css';
  16. style.innerHTML = '* { -webkit-font-smoothing: antialiased; }' +
  17. 'html body .mxWindow button.geBtn { font-size:12px !important; margin-left: 0;}' +
  18. 'html body div.diagramContainer button, html body button.geBtn { font-size:14px; font-weight:700;border-radius: 5px; }' +
  19. 'html body button.geBtn:active { opacity: 0.6; }' +
  20. '.geDialog input, .geToolbarContainer input, .mxWindow input {padding:2px !important;display:inline-block !important; }' +
  21. 'div.geDialog { border-radius: 5px; }' +
  22. 'html body div.geDialog button.geBigButton { color: #fff !important; }' +
  23. '.mxWindow button, .geDialog select, .mxWindow select { display:inline-block; }' +
  24. '.mxWindow .geColorBtn, .geDialog .geColorBtn { background: none !important; }' +
  25. 'html body div.diagramContainer button, html body .mxWindow button, html body .geDialog button { min-width: 0px; border-radius: 5px; color: #353535 !important; border-color: rgb(216, 216, 216); }' +
  26. 'div.diagramContainer button.geBtn, .mxWindow button.geBtn, .geDialog button.geBtn { min-width:72px; font-weight: 600; background: none; }' +
  27. 'div.diagramContainer button.geBtn:hover, .mxWindow button.geBtn:hover, .geDialog button.geBtn:hover { box-shadow: none; border-color: rgb(216, 216, 216); }' +
  28. 'div.diagramContainer button.gePrimaryBtn, .mxWindow button.gePrimaryBtn, .geDialog button.gePrimaryBtn, html body .gePrimaryBtn { background: #29b6f2; color: #fff !important; border: none; box-shadow: none; }' +
  29. 'html body .gePrimaryBtn:hover { background: #29b6f2; border: none; box-shadow: inherit; }' +
  30. 'html body button.gePrimaryBtn:hover { background: #29b6f2; border: none; }' +
  31. '.geBtn button { min-width:72px !important; }' +
  32. 'div.geToolbarContainer a.geButton { margin:2px; padding: 0 2px 4px 2px; } ' +
  33. '.geDialog, .mxWindow td.mxWindowPane *, div.geSprite, td.mxWindowTitle, .geDiagramContainer { box-sizing:content-box; }' +
  34. '.mxWindow div button.geStyleButton { box-sizing: border-box; }' +
  35. 'table.mxWindow td.mxWindowPane button.geColorBtn { padding:0px; box-sizing: border-box; }' +
  36. 'td.mxWindowPane .geSidebarContainer button { padding:2px 0 2px 0; box-sizing: border-box; }' +
  37. // Make geItem look like a button
  38. 'html body .geMenuItem { font-size:14px; text-decoration: none; font-weight: normal; padding: 6px 10px 6px 10px; border: none; border-radius: 5px; color: #353535; box-shadow: inset 0 0 0 1px rgba(0,0,0,.11), inset 0 -1px 0 0 rgba(0,0,0,.08), 0 1px 2px 0 rgba(0,0,0,.04); }' +
  39. 'a.geMenuItem:active { opacity: 0.4; }' +
  40. // Styling for Minimal
  41. '.geToolbarContainer { background:#fff !important; }' +
  42. 'div.mxWindow .geSidebarContainer .geTitle { background-color:#fdfdfd; }' +
  43. 'div.mxWindow .geSidebarContainer .geTitle:hover { background-color:#fafafa; }' +
  44. 'div.geSidebar { background-color: #fff !important;}' +
  45. 'div.mxWindow td.mxWindowPane button { background-image: none; float: none; }' +
  46. 'td.mxWindowTitle { height: 22px !important; background: none !important; font-size: 13px !important; text-align:center !important; border-bottom:1px solid lightgray; }' +
  47. 'div.mxWindow, div.mxWindowTitle { background-image: none !important; background-color:#fff !important; }' +
  48. 'div.mxWindow { border-radius:5px; box-shadow: 0px 0px 2px #C0C0C0 !important;}' +
  49. 'div.mxWindow * { font-family: inherit !important; }' +
  50. // Minimal Style UI
  51. 'html div.geVerticalHandle { position:absolute;bottom:0px;left:50%;cursor:row-resize;width:11px;height:11px;background:white;margin-bottom:-6px; margin-left:-6px; border: none; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.11), inset 0 -1px 0 0 rgba(0,0,0,.08), 0 1px 2px 0 rgba(0,0,0,.04); }' +
  52. 'html div.geInactivePage { background: rgb(249, 249, 249) !important; color:lightgray !important; } ' +
  53. 'html div.geActivePage { background: white !important;color: #353535 !important; } ' +
  54. 'html div.mxRubberband { border:1px solid; border-color: #29b6f2 !important; background:rgba(41,182,242,0.5) !important; } ' +
  55. 'html body div.mxPopupMenu { border-radius:5px; border:1px solid #c0c0c0; padding:5px 0 5px 0; box-shadow: 0px 4px 17px -4px rgba(96,96,96,1); } ' +
  56. 'html table.mxPopupMenu td.mxPopupMenuItem { color: #353535; font-size: 14px; padding-top: 4px; padding-bottom: 4px; }' +
  57. 'html table.mxPopupMenu tr.mxPopupMenuItemHover { background-color: #29b6f2; }' +
  58. 'html tr.mxPopupMenuItemHover td.mxPopupMenuItem, html tr.mxPopupMenuItemHover td.mxPopupMenuItem span { color: #fff !important; }' +
  59. 'html tr.mxPopupMenuItem, html td.mxPopupMenuItem { transition-property: none !important; }' +
  60. 'html table.mxPopupMenu hr { height: 2px; background-color: rgba(0,0,0,.07); margin: 5px 0; }';
  61. document.getElementsByTagName('head')[0].appendChild(style);
  62. }
  63. catch (e)
  64. {
  65. // ignore
  66. }
  67. /**
  68. *
  69. */
  70. var WrapperWindow = function(editorUi, title, x, y, w, h, fn)
  71. {
  72. var graph = editorUi.editor.graph;
  73. var div = document.createElement('div');
  74. div.className = 'geSidebarContainer';
  75. div.style.position = 'absolute';
  76. div.style.width = '100%';
  77. div.style.height = '100%';
  78. div.style.border = '1px solid whiteSmoke';
  79. div.style.overflowX = 'hidden';
  80. div.style.overflowY = 'auto';
  81. fn(div);
  82. this.window = new mxWindow(title, div, x, y, w, h, true, true);
  83. this.window.destroyOnClose = false;
  84. this.window.setMaximizable(false);
  85. this.window.setResizable(true);
  86. this.window.setClosable(true);
  87. this.window.setVisible(true);
  88. this.window.setLocation = function(x, y)
  89. {
  90. var iiw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  91. var ih = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  92. x = Math.max(0, Math.min(x, iiw - this.table.clientWidth));
  93. y = Math.max(0, Math.min(y, ih - this.table.clientHeight - 48));
  94. if (this.getX() != x || this.getY() != y)
  95. {
  96. mxWindow.prototype.setLocation.apply(this, arguments);
  97. }
  98. };
  99. };
  100. function toggleFormat(ui)
  101. {
  102. var graph = ui.editor.graph;
  103. graph.popupMenuHandler.hideMenu();
  104. if (ui.formatWindow == null)
  105. {
  106. ui.formatWindow = new WrapperWindow(ui, mxResources.get('format'),
  107. Math.max(20, ui.diagramContainer.clientWidth - 240 - 12), 56,
  108. 240, Math.min(546, graph.container.clientHeight - 10), function(container)
  109. {
  110. var format = ui.createFormat(container);
  111. format.init();
  112. return format;
  113. });
  114. ui.formatWindow.window.minimumSize = new mxRectangle(0, 0, 240, 80);
  115. ui.formatWindow.window.setVisible(true);
  116. }
  117. else
  118. {
  119. ui.formatWindow.window.setVisible(!ui.formatWindow.window.isVisible());
  120. }
  121. if (ui.formatWindow.window.isVisible())
  122. {
  123. ui.formatWindow.window.fit();
  124. }
  125. };
  126. function toggleShapes(ui)
  127. {
  128. var graph = ui.editor.graph;
  129. graph.popupMenuHandler.hideMenu();
  130. var rect = new mxRectangle();
  131. if (ui.sidebarWindow == null)
  132. {
  133. var w = Math.min(graph.container.clientWidth - 10, 266);
  134. ui.sidebarWindow = new WrapperWindow(ui, mxResources.get('shapes'), 10, 56,
  135. w - 6, Math.min(650, graph.container.clientHeight - 30),
  136. function(container)
  137. {
  138. var div = document.createElement('div');
  139. div.style.cssText = 'position:absolute;left:0;right:0;border-top:1px solid lightgray;' +
  140. 'height:24px;bottom:31px;text-align:center;cursor:pointer;padding:6px 0 0 0;';
  141. div.className = 'geTitle';
  142. mxUtils.write(div, mxResources.get('moreShapes'));
  143. container.appendChild(div);
  144. mxEvent.addListener(div, 'click', function()
  145. {
  146. ui.actions.get('shapes').funct();
  147. });
  148. var menuObj = new Menubar(ui, container);
  149. function addMenu(id, label)
  150. {
  151. var menu = ui.menus.get(id);
  152. var elt = menuObj.addMenu(label, mxUtils.bind(this, function()
  153. {
  154. // Allows extensions of menu.functid
  155. menu.funct.apply(this, arguments);
  156. }));
  157. elt.style.cssText = 'position:absolute;border-top:1px solid lightgray;width:50%;' +
  158. 'height:24px;bottom:0px;text-align:center;cursor:pointer;padding:6px 0 0 0;';
  159. elt.className = 'geTitle';
  160. container.appendChild(elt);
  161. return elt;
  162. }
  163. if (Editor.enableCustomLibraries && (urlParams['embed'] != '1' || urlParams['libraries'] == '1'))
  164. {
  165. // Defined in native apps together with openLibrary
  166. if (ui.actions.get('newLibrary') != null)
  167. {
  168. var div = document.createElement('div');
  169. div.style.cssText = 'position:absolute;left:0px;width:50%;border-top:1px solid lightgray;' +
  170. 'height:30px;bottom:0px;text-align:center;cursor:pointer;padding:0px;';
  171. div.className = 'geTitle';
  172. var span = document.createElement('span');
  173. span.style.cssText = 'position:relative;top:6px;';
  174. mxUtils.write(span, mxResources.get('newLibrary'));
  175. div.appendChild(span);
  176. container.appendChild(div);
  177. mxEvent.addListener(div, 'click', ui.actions.get('newLibrary').funct);
  178. var div = document.createElement('div');
  179. div.style.cssText = 'position:absolute;left:50%;width:50%;border-top:1px solid lightgray;' +
  180. 'height:30px;bottom:0px;text-align:center;cursor:pointer;padding:0px;border-left: 1px solid lightgray;';
  181. div.className = 'geTitle';
  182. var span = document.createElement('span');
  183. span.style.cssText = 'position:relative;top:6px;';
  184. mxUtils.write(span, mxResources.get('openLibrary'));
  185. div.appendChild(span);
  186. container.appendChild(div);
  187. mxEvent.addListener(div, 'click', ui.actions.get('openLibrary').funct);
  188. }
  189. else
  190. {
  191. var elt = addMenu('newLibrary', mxResources.get('newLibrary'));
  192. elt.style.left = '0';
  193. var elt = addMenu('openLibraryFrom', mxResources.get('openLibraryFrom'));
  194. elt.style.borderLeft = '1px solid lightgray';
  195. elt.style.left = '50%';
  196. }
  197. }
  198. else
  199. {
  200. div.style.bottom = '0';
  201. }
  202. container.appendChild(ui.sidebar.container);
  203. container.style.overflow = 'hidden';
  204. return container;
  205. });
  206. ui.sidebarWindow.window.minimumSize = new mxRectangle(0, 0, 90, 90);
  207. ui.sidebarWindow.window.setVisible(true);
  208. ui.getLocalData('sidebar', function(value)
  209. {
  210. ui.sidebar.showEntries(value, null, true);
  211. });
  212. ui.restoreLibraries();
  213. }
  214. else
  215. {
  216. ui.sidebarWindow.window.setVisible(!ui.sidebarWindow.window.isVisible());
  217. }
  218. if (ui.sidebarWindow.window.isVisible())
  219. {
  220. ui.sidebarWindow.window.fit();
  221. }
  222. };
  223. // Changes colors for some UI elements
  224. var fill = '#29b6f2';
  225. var stroke = '#ffffff';
  226. Editor.checkmarkImage = Graph.createSvgImage(22, 18, '<path transform="translate(4 0)" d="M7.181,15.007a1,1,0,0,1-.793-0.391L3.222,10.5A1,1,0,1,1,4.808,9.274L7.132,12.3l6.044-8.86A1,1,0,1,1,14.83,4.569l-6.823,10a1,1,0,0,1-.8.437H7.181Z" fill="' + fill + '"/>').src;
  227. mxWindow.prototype.closeImage = Graph.createSvgImage(18, 10, '<path d="M 5 1 L 13 9 M 13 1 L 5 9" stroke="#C0C0C0" stroke-width="2"/>').src;
  228. mxWindow.prototype.minimizeImage = Graph.createSvgImage(14, 10, '<path d="M 3 7 L 7 3 L 11 7" stroke="#C0C0C0" stroke-width="2" fill="#ffffff"/>').src;
  229. mxWindow.prototype.normalizeImage = Graph.createSvgImage(14, 10, '<path d="M 3 3 L 7 7 L 11 3" stroke="#C0C0C0" stroke-width="2" fill="#ffffff"/>').src;
  230. mxVertexHandler.prototype.handleImage = Graph.createSvgImage(16, 16, '<circle cx="8" cy="8" r="5" stroke="' + stroke + '" fill="' + fill + '"/>');
  231. mxEdgeHandler.prototype.handleImage = mxVertexHandler.prototype.handleImage;
  232. mxEdgeHandler.prototype.terminalHandleImage = Graph.createSvgImage(16, 16, '<circle cx="8" cy="8" r="5" stroke="' + stroke + '" fill="' + fill + '"/><circle cx="8" cy="8" r="3" stroke="' + stroke + '" fill="' + fill + '"/>');
  233. mxEdgeHandler.prototype.fixedHandleImage = Graph.createSvgImage(16, 16, '<circle cx="8" cy="8" r="5" stroke="' + stroke + '" fill="' + fill + '"/><path d="m 6 6 L 10 10 M 6 10 L 10 6" stroke="' + stroke + '"/>');
  234. mxConstraintHandler.prototype.pointImage = Graph.createSvgImage(5, 5, '<path d="m 0 0 L 5 5 M 0 5 L 5 0" stroke="' + fill + '"/>');
  235. HoverIcons.prototype.triangleUp = Graph.createSvgImage(18, 38, '<path d="m 6 36 L 12 36 L 12 12 L 18 12 L 9 1 L 1 12 L 6 12 z" stroke="#fff" fill="' + fill + '"/>');
  236. HoverIcons.prototype.triangleRight = Graph.createSvgImage(36, 18, '<path d="m 1 6 L 24 6 L 24 1 L 36 9 L 24 18 L 24 12 L 1 12 z" stroke="#fff" fill="' + fill + '"/>');
  237. HoverIcons.prototype.triangleDown = Graph.createSvgImage(18, 36, '<path d="m 6 1 L 6 24 L 1 24 L 9 36 L 18 24 L 12 24 L 12 1 z" stroke="#fff" fill="' + fill + '"/>');
  238. HoverIcons.prototype.triangleLeft = Graph.createSvgImage(38, 18, '<path d="m 1 9 L 12 1 L 12 6 L 36 6 L 36 12 L 12 12 L 12 18 z" stroke="#fff" fill="' + fill + '"/>');
  239. HoverIcons.prototype.roundDrop = Graph.createSvgImage(26, 26, '<circle cx="13" cy="13" r="12" stroke="#fff" fill="' + fill + '"/>');
  240. HoverIcons.prototype.arrowSpacing = 0;
  241. mxOutline.prototype.sizerImage = null;
  242. if (window.Sidebar != null)
  243. {
  244. Sidebar.prototype.triangleUp = HoverIcons.prototype.triangleUp;
  245. Sidebar.prototype.triangleRight = HoverIcons.prototype.triangleRight;
  246. Sidebar.prototype.triangleDown = HoverIcons.prototype.triangleDown;
  247. Sidebar.prototype.triangleLeft = HoverIcons.prototype.triangleLeft;
  248. Sidebar.prototype.refreshTarget = HoverIcons.prototype.refreshTarget;
  249. Sidebar.prototype.roundDrop = HoverIcons.prototype.roundDrop;
  250. }
  251. mxConstants.VERTEX_SELECTION_COLOR = '#C0C0C0';
  252. mxConstants.EDGE_SELECTION_COLOR = '#C0C0C0';
  253. mxConstants.CONNECT_HANDLE_FILLCOLOR = '#cee7ff';
  254. mxConstants.DEFAULT_VALID_COLOR = fill;
  255. mxConstants.GUIDE_COLOR = '#C0C0C0';
  256. mxConstants.HIGHLIGHT_STROKEWIDTH = 5;
  257. mxConstants.HIGHLIGHT_OPACITY = 35;
  258. mxConstants.HIGHLIGHT_SIZE = 5;
  259. mxConstants.OUTLINE_COLOR = '#29b6f2';
  260. mxConstants.OUTLINE_HANDLE_FILLCOLOR = '#29b6f2';
  261. mxConstants.OUTLINE_HANDLE_STROKECOLOR = '#fff';
  262. Graph.prototype.svgShadowColor = '#3D4574';
  263. Graph.prototype.svgShadowOpacity = '0.4';
  264. Graph.prototype.svgShadowSize = '0.6';
  265. Graph.prototype.svgShadowBlur = '1.2';
  266. Format.prototype.inactiveTabBackgroundColor = '#f0f0f0';
  267. mxGraphHandler.prototype.previewColor = '#C0C0C0';
  268. mxRubberband.prototype.defaultOpacity = 50;
  269. HoverIcons.prototype.inactiveOpacity = 25;
  270. Format.prototype.showCloseButton = false;
  271. EditorUi.prototype.closableScratchpad = false;
  272. EditorUi.prototype.toolbarHeight = 46;
  273. EditorUi.prototype.footerHeight = 0;
  274. Graph.prototype.editAfterInsert = true;
  275. /**
  276. * Sets the XML node for the current diagram.
  277. */
  278. Editor.prototype.isChromelessView = function()
  279. {
  280. return false;
  281. };
  282. /**
  283. * Sets the XML node for the current diagram.
  284. */
  285. Graph.prototype.isLightboxView = function()
  286. {
  287. return false;
  288. };
  289. // Overridden to ignore tabContainer height for diagramContainer
  290. var editorUiRefresh = EditorUi.prototype.refresh;
  291. EditorUi.prototype.refresh = function(sizeDidChange)
  292. {
  293. editorUiRefresh.apply(this, arguments);
  294. if (this.tabContainer != null)
  295. {
  296. // Makes room for view zoom menu
  297. this.tabContainer.style.right = '70px';
  298. }
  299. };
  300. // Overridden to update save menu state
  301. /**
  302. * Updates action states depending on the selection.
  303. */
  304. var editorUiUpdateActionStates = EditorUi.prototype.updateActionStates;
  305. EditorUi.prototype.updateActionStates = function()
  306. {
  307. editorUiUpdateActionStates.apply(this, arguments);
  308. this.menus.get('save').setEnabled(this.getCurrentFile() != null || urlParams['embed'] == '1');
  309. };
  310. // Hides keyboard shortcuts in menus
  311. var menusAddShortcut = Menus.prototype.addShortcut;
  312. Menus.prototype.addShortcut = function(item, action)
  313. {
  314. if (action.shortcut != null && iw < 900 && !mxClient.IS_IOS)
  315. {
  316. var td = item.firstChild.nextSibling;
  317. td.setAttribute('title', action.shortcut);
  318. }
  319. else
  320. {
  321. menusAddShortcut.apply(this, arguments);
  322. }
  323. };
  324. var appUpdateUserElement = App.prototype.updateUserElement;
  325. App.prototype.updateUserElement = function()
  326. {
  327. appUpdateUserElement.apply(this, arguments);
  328. if (this.userElement != null)
  329. {
  330. var elt = this.userElement;
  331. elt.style.cssText = 'display:inline-block;position:relative;margin-right:4px;';
  332. elt.className = '';
  333. elt.innerHTML = '';
  334. elt.style.backgroundImage = 'url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgMTJjMi4yMSAwIDQtMS43OSA0LTRzLTEuNzktNC00LTQtNCAxLjc5LTQgNCAxLjc5IDQgNCA0em0wIDJjLTIuNjcgMC04IDEuMzQtOCA0djJoMTZ2LTJjMC0yLjY2LTUuMzMtNC04LTR6Ii8+PC9zdmc+)';
  335. elt.style.backgroundPosition = 'center center';
  336. elt.style.backgroundRepeat = 'no-repeat';
  337. elt.style.backgroundSize = '24px 24px';
  338. elt.style.height = '24px';
  339. elt.style.width = '24px';
  340. mxUtils.setOpacity(elt, 30);
  341. elt.setAttribute('title', mxResources.get('changeUser'));
  342. }
  343. };
  344. var appUpdateButtonContainer = App.prototype.updateButtonContainer;
  345. App.prototype.updateButtonContainer = function()
  346. {
  347. appUpdateButtonContainer.apply(this, arguments);
  348. if (this.shareButton != null)
  349. {
  350. var elt = this.shareButton;
  351. elt.style.cssText = 'display:inline-block;position:relative;box-sizing:border-box;margin-right:4px;cursor:pointer;';
  352. elt.className = '';
  353. elt.innerHTML = '';
  354. elt.style.backgroundImage = 'url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTggMTYuMDhjLS43NiAwLTEuNDQuMy0xLjk2Ljc3TDguOTEgMTIuN2MuMDUtLjIzLjA5LS40Ni4wOS0uN3MtLjA0LS40Ny0uMDktLjdsNy4wNS00LjExYy41NC41IDEuMjUuODEgMi4wNC44MSAxLjY2IDAgMy0xLjM0IDMtM3MtMS4zNC0zLTMtMy0zIDEuMzQtMyAzYzAgLjI0LjA0LjQ3LjA5LjdMOC4wNCA5LjgxQzcuNSA5LjMxIDYuNzkgOSA2IDljLTEuNjYgMC0zIDEuMzQtMyAzczEuMzQgMyAzIDNjLjc5IDAgMS41LS4zMSAyLjA0LS44MWw3LjEyIDQuMTZjLS4wNS4yMS0uMDguNDMtLjA4LjY1IDAgMS42MSAxLjMxIDIuOTIgMi45MiAyLjkyIDEuNjEgMCAyLjkyLTEuMzEgMi45Mi0yLjkycy0xLjMxLTIuOTItMi45Mi0yLjkyeiIvPjwvc3ZnPg==)';
  355. elt.style.backgroundPosition = 'center center';
  356. elt.style.backgroundRepeat = 'no-repeat';
  357. elt.style.backgroundSize = '24px 24px';
  358. elt.style.height = '24px';
  359. elt.style.width = '24px';
  360. mxUtils.setOpacity(elt, 30);
  361. elt.setAttribute('title', mxResources.get('share'));
  362. }
  363. };
  364. EditorUi.prototype.addEmbedButtons = function()
  365. {
  366. if (this.buttonContainer != null)
  367. {
  368. var div = document.createElement('div');
  369. div.style.display = 'inline-block';
  370. div.style.position = 'relative';
  371. div.style.marginTop = '2px';
  372. var button = document.createElement('button');
  373. mxUtils.write(button, mxResources.get('save'));
  374. button.setAttribute('title', mxResources.get('save') + ' (' + Editor.ctrlKey + '+S)');
  375. button.className = (urlParams['saveAndExit'] == '1') ? 'geMenuItem' : 'geMenuItem gePrimaryBtn';
  376. button.style.fontSize = '14px';
  377. button.style.padding = '6px';
  378. button.style.borderRadius = '3px';
  379. button.style.marginLeft = '8px';
  380. button.style.cursor = 'pointer';
  381. mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
  382. {
  383. this.actions.get('save').funct();
  384. }));
  385. div.appendChild(button);
  386. if (urlParams['saveAndExit'] == '1')
  387. {
  388. button = document.createElement('a');
  389. mxUtils.write(button, mxResources.get('saveAndExit'));
  390. button.setAttribute('title', mxResources.get('saveAndExit'));
  391. button.className = 'geMenuItem gePrimaryBtn';
  392. button.style.fontSize = '14px';
  393. button.style.marginLeft = '6px';
  394. button.style.padding = '6px';
  395. button.style.cursor = 'pointer';
  396. mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
  397. {
  398. this.actions.get('saveAndExit').funct();
  399. }));
  400. div.appendChild(button);
  401. }
  402. button = document.createElement('a');
  403. mxUtils.write(button, mxResources.get('exit'));
  404. button.setAttribute('title', mxResources.get('exit'));
  405. button.className = 'geMenuItem';
  406. button.style.fontSize = '14px';
  407. button.style.marginLeft = '6px';
  408. button.style.padding = '6px';
  409. button.style.cursor = 'pointer';
  410. mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
  411. {
  412. this.actions.get('exit').funct();
  413. }));
  414. div.appendChild(button);
  415. this.buttonContainer.appendChild(div);
  416. this.buttonContainer.style.top = '6px';
  417. }
  418. };
  419. // Fixes sidebar tooltips (previews)
  420. Sidebar.prototype.getTooltipOffset = function()
  421. {
  422. var off = mxUtils.getOffset(this.editorUi.sidebarWindow.window.div);
  423. off.y += 40;
  424. return off;
  425. };
  426. // Adds context menu items
  427. var menuCreatePopupMenu = Menus.prototype.createPopupMenu;
  428. Menus.prototype.createPopupMenu = function(menu, cell, evt)
  429. {
  430. var graph = this.editorUi.editor.graph;
  431. menu.smartSeparators = true;
  432. menuCreatePopupMenu.apply(this, arguments);
  433. var promptSpacing = mxUtils.bind(this, function(defaultValue, fn)
  434. {
  435. var dlg = new FilenameDialog(this.editorUi, defaultValue, mxResources.get('apply'), function(newValue)
  436. {
  437. fn(parseFloat(newValue));
  438. }, mxResources.get('spacing'));
  439. this.editorUi.showDialog(dlg.container, 300, 80, true, true);
  440. dlg.init();
  441. });
  442. if (graph.getSelectionCount() == 1)
  443. {
  444. this.addMenuItems(menu, ['editTooltip', '-'], null, evt);
  445. if (graph.isCellFoldable(graph.getSelectionCell()))
  446. {
  447. this.addMenuItems(menu, (graph.isCellCollapsed(cell)) ? ['expand'] : ['collapse'], null, evt);
  448. }
  449. this.addMenuItems(menu, ['lockUnlock', 'enterGroup'], null, evt);
  450. menu.addSeparator();
  451. this.addSubmenu('layout', menu);
  452. }
  453. else if (graph.isSelectionEmpty() && graph.isEnabled())
  454. {
  455. menu.addSeparator();
  456. this.addMenuItems(menu, ['editData'], null, evt);
  457. menu.addSeparator();
  458. this.addSubmenu('insert', menu);
  459. this.addSubmenu('layout', menu);
  460. menu.addSeparator();
  461. this.addSubmenu('view', menu, null, mxResources.get('options'));
  462. this.addMenuItems(menu, ['-', 'exitGroup'], null, evt);
  463. }
  464. else if (graph.isEnabled())
  465. {
  466. this.addMenuItems(menu, ['-', 'lockUnlock'], null, evt);
  467. }
  468. };
  469. // Overridden to toggle window instead
  470. EditorUi.prototype.toggleFormatPanel = function(forceHide)
  471. {
  472. if (this.formatWindow != null)
  473. {
  474. this.formatWindow.window.setVisible((forceHide) ?
  475. false : !this.formatWindow.window.isVisible());
  476. }
  477. };
  478. DiagramFormatPanel.prototype.isMathOptionVisible = function()
  479. {
  480. return true;
  481. };
  482. // Initializes the user interface
  483. var editorUiDestroy = EditorUi.prototype.destroy;
  484. EditorUi.prototype.destroy = function()
  485. {
  486. if (this.sidebarWindow != null)
  487. {
  488. this.sidebarWindow.window.setVisible(false);
  489. this.sidebarWindow.window.destroy();
  490. this.sidebarWindow = null;
  491. }
  492. if (this.formatWindow != null)
  493. {
  494. this.formatWindow.window.setVisible(false);
  495. this.formatWindow.window.destroy();
  496. this.formatWindow = null;
  497. }
  498. if (this.actions.outlineWindow != null)
  499. {
  500. this.actions.outlineWindow.window.setVisible(false);
  501. this.actions.outlineWindow.window.destroy();
  502. this.actions.outlineWindow = null;
  503. }
  504. if (this.actions.layersWindow != null)
  505. {
  506. this.actions.layersWindow.window.setVisible(false);
  507. this.actions.layersWindow.window.destroy();
  508. this.actions.layersWindow = null;
  509. }
  510. if (this.menus.tagsWindow != null)
  511. {
  512. this.menus.tagsWindow.window.setVisible(false);
  513. this.menus.tagsWindow.window.destroy();
  514. this.menus.tagsWindow = null;
  515. }
  516. if (this.menus.findWindow != null)
  517. {
  518. this.menus.findWindow.window.setVisible(false);
  519. this.menus.findWindow.window.destroy();
  520. this.menus.findWindow = null;
  521. }
  522. editorUiDestroy.apply(this, arguments);
  523. };
  524. // Hides windows when a file is closed
  525. var editorUiSetGraphEnabled = EditorUi.prototype.setGraphEnabled;
  526. EditorUi.prototype.setGraphEnabled = function(enabled)
  527. {
  528. editorUiSetGraphEnabled.apply(this, arguments);
  529. if (!enabled)
  530. {
  531. if (this.sidebarWindow != null)
  532. {
  533. this.sidebarWindow.window.setVisible(false);
  534. }
  535. if (this.formatWindow != null)
  536. {
  537. this.formatWindow.window.setVisible(false);
  538. }
  539. }
  540. };
  541. // Disables centering of graph after iframe resize
  542. EditorUi.prototype.chromelessWindowResize = function() {};
  543. // Adds actions and menus
  544. var menusInit = Menus.prototype.init;
  545. Menus.prototype.init = function()
  546. {
  547. menusInit.apply(this, arguments);
  548. var ui = this.editorUi;
  549. var graph = ui.editor.graph;
  550. ui.actions.get('insertText').label = mxResources.get('text');
  551. ui.actions.get('insertText').label = mxResources.get('text');
  552. ui.actions.get('editDiagram').label = mxResources.get('formatXml') + '...';
  553. ui.actions.get('insertRectangle').label = mxResources.get('rectangle');
  554. ui.actions.get('insertEllipse').label = mxResources.get('ellipse');
  555. ui.actions.get('insertRhombus').label = mxResources.get('rhombus');
  556. ui.actions.get('insertImage').label = mxResources.get('image') + '...';
  557. ui.actions.get('insertLink').label = mxResources.get('link') + '...';
  558. ui.actions.get('createShape').label = mxResources.get('shape') + '...';
  559. ui.actions.get('outline').label = mxResources.get('outline') + '...';
  560. ui.actions.get('layers').label = mxResources.get('layers') + '...';
  561. ui.actions.put('importFile', new Action('File...', function()
  562. {
  563. graph.popupMenuHandler.hideMenu();
  564. var input = document.createElement('input');
  565. input.setAttribute('type', 'file');
  566. mxEvent.addListener(input, 'change', function()
  567. {
  568. if (input.files != null)
  569. {
  570. // Using null for position will disable crop of input file
  571. ui.importFiles(input.files, null, null, ui.maxImageSize);
  572. }
  573. });
  574. input.click();
  575. }));
  576. ui.actions.put('importCsv', new Action(mxResources.get('csv') + '...', function()
  577. {
  578. graph.popupMenuHandler.hideMenu();
  579. ui.showImportCsvDialog();
  580. }));
  581. ui.actions.put('importText', new Action(mxResources.get('text') + '...', function()
  582. {
  583. var dlg = new ParseDialog(ui, 'Insert from Text');
  584. ui.showDialog(dlg.container, 620, 420, true, false);
  585. dlg.init();
  586. }));
  587. ui.actions.put('formatSql', new Action(mxResources.get('formatSql') + '...', function()
  588. {
  589. var dlg = new ParseDialog(ui, 'Insert from Text', 'formatSql');
  590. ui.showDialog(dlg.container, 620, 420, true, false);
  591. dlg.init();
  592. }));
  593. ui.actions.put('toggleShapes', new Action(mxResources.get('shapes') + '...', function()
  594. {
  595. toggleShapes(ui);
  596. }));
  597. ui.actions.put('toggleFormat', new Action(mxResources.get('format') + '...', function()
  598. {
  599. toggleFormat(ui);
  600. }));
  601. if (EditorUi.enablePlantUml)
  602. {
  603. ui.actions.put('plantUml', new Action(mxResources.get('plantUml') + '...', function()
  604. {
  605. var dlg = new ParseDialog(ui, 'Insert from Text', 'plantUml');
  606. ui.showDialog(dlg.container, 620, 420, true, false);
  607. dlg.init();
  608. }));
  609. }
  610. this.put('diagram', new Menu(mxUtils.bind(this, function(menu, parent)
  611. {
  612. ui.menus.addSubmenu('extras', menu, parent, mxResources.get('preferences'));
  613. menu.addSeparator(parent);
  614. if (mxClient.IS_CHROMEAPP || EditorUi.isElectronApp)
  615. {
  616. ui.menus.addMenuItems(menu, ['new', 'open', '-', 'save', 'saveAs', '-'], parent);
  617. }
  618. else if (urlParams['embed'] == '1')
  619. {
  620. ui.menus.addMenuItems(menu, ['-', 'save'], parent);
  621. if (urlParams['saveAndExit'] == '1')
  622. {
  623. ui.menus.addMenuItems(menu, ['saveAndExit'], parent);
  624. }
  625. menu.addSeparator(parent);
  626. }
  627. else
  628. {
  629. ui.menus.addMenuItems(menu, ['new'], parent);
  630. ui.menus.addSubmenu('openFrom', menu, parent);
  631. menu.addSeparator(parent);
  632. ui.menus.addSubmenu('save', menu, parent);
  633. }
  634. ui.menus.addSubmenu('exportAs', menu, parent);
  635. var file = ui.getCurrentFile();
  636. if (file != null && file.constructor == DriveFile)
  637. {
  638. ui.menus.addMenuItems(menu, ['-', 'share'], parent);
  639. if (file.realtime != null)
  640. {
  641. ui.menus.addMenuItems(menu, ['chatWindowTitle'], parent);
  642. }
  643. menu.addSeparator(parent);
  644. }
  645. ui.menus.addMenuItems(menu, ['-', 'outline', 'layers', '-', 'find', 'tags', '-'], parent);
  646. // Cannot use print in standalone mode on iOS as we cannot open new windows
  647. if (!mxClient.IS_IOS || !navigator.standalone)
  648. {
  649. ui.menus.addMenuItems(menu, ['-', 'print', '-'], parent);
  650. }
  651. ui.menus.addSubmenu('help', menu, parent);
  652. if (urlParams['embed'] == '1')
  653. {
  654. ui.menus.addMenuItems(menu, ['-', 'exit'], parent);
  655. }
  656. else
  657. {
  658. ui.menus.addMenuItems(menu, ['-', 'close']);
  659. }
  660. })));
  661. if (isLocalStorage)
  662. {
  663. var openFromMenu = this.get('openFrom');
  664. var oldFunct = openFromMenu.funct;
  665. openFromMenu.funct = function(menu, parent)
  666. {
  667. oldFunct.apply(this, arguments);
  668. menu.addSeparator(parent);
  669. ui.menus.addSubmenu('openRecent', menu, parent);
  670. };
  671. }
  672. this.put('save', new Menu(mxUtils.bind(this, function(menu, parent)
  673. {
  674. var file = ui.getCurrentFile();
  675. if (file != null && file.constructor == DriveFile)
  676. {
  677. ui.menus.addMenuItems(menu, ['createRevision', 'makeCopy', '-', 'rename', 'moveToFolder'], parent);
  678. }
  679. else
  680. {
  681. ui.menus.addMenuItems(menu, ['save', 'saveAs', '-', 'rename', 'makeCopy'], parent);
  682. }
  683. if (file != null && (file.constructor == DriveFile || file.constructor == DropboxFile))
  684. {
  685. ui.menus.addMenuItems(menu, ['-', 'revisionHistory'], parent);
  686. }
  687. ui.menus.addMenuItems(menu, ['-', 'autosave'], parent);
  688. })));
  689. // Augments the existing export menu
  690. var exportAsMenu = this.get('exportAs');
  691. this.put('exportAs', new Menu(mxUtils.bind(this, function(menu, parent)
  692. {
  693. exportAsMenu.funct(menu, parent);
  694. menu.addSeparator(parent);
  695. ui.menus.addSubmenu('embed', menu, parent);
  696. // Publish menu contains only one element by default...
  697. //ui.menus.addSubmenu('publish', menu, parent);
  698. ui.menus.addMenuItems(menu, ['publishLink'], parent);
  699. })));
  700. var langMenu = this.get('language');
  701. // Overrides extras for plugins but label it preferences
  702. this.put('extras', new Menu(mxUtils.bind(this, function(menu, parent)
  703. {
  704. if (urlParams['embed'] != '1')
  705. {
  706. ui.menus.addSubmenu('theme', menu, parent);
  707. }
  708. if (langMenu != null)
  709. {
  710. ui.menus.addSubmenu('language', menu, parent);
  711. }
  712. menu.addSeparator(parent);
  713. ui.menus.addMenuItems(menu, ['scrollbars', 'tooltips', 'pageScale'], parent);
  714. if (urlParams['embed'] != '1' && isLocalStorage)
  715. {
  716. ui.menus.addMenuItems(menu, ['-', 'search', 'scratchpad', '-', 'showStartScreen'], parent);
  717. }
  718. if (!ui.isOfflineApp() && urlParams['embed'] != '1')
  719. {
  720. ui.menus.addMenuItems(menu, ['-', 'plugins'], parent);
  721. }
  722. })));
  723. this.put('insertAdvanced', new Menu(mxUtils.bind(this, function(menu, parent)
  724. {
  725. ui.menus.addMenuItems(menu, ['importText', 'createShape', 'plantUml', '-', 'importCsv', 'formatSql', 'editDiagram'], parent);
  726. })));
  727. mxResources.parse('insertLayout=' + mxResources.get('layout'));
  728. mxResources.parse('insertAdvanced=' + mxResources.get('advanced'));
  729. this.put('insert', new Menu(mxUtils.bind(this, function(menu, parent)
  730. {
  731. ui.menus.addMenuItems(menu, ['insertRectangle', 'insertEllipse', 'insertRhombus', '-', 'insertText',
  732. 'insertLink', '-', 'insertImage'], parent);
  733. ui.menus.addSubmenu('importFrom', menu, parent);
  734. menu.addSeparator(parent);
  735. ui.menus.addSubmenu('insertLayout', menu, parent);
  736. ui.menus.addSubmenu('insertAdvanced', menu, parent);
  737. })));
  738. var methods = ['horizontalFlow', 'verticalFlow', '-', 'horizontalTree', 'verticalTree',
  739. 'radialTree', '-', 'organic', 'circle'];
  740. var addInsertItem = function(menu, parent, title, method)
  741. {
  742. menu.addItem(title, null, mxUtils.bind(this, function()
  743. {
  744. var dlg = new CreateGraphDialog(ui, title, method);
  745. ui.showDialog(dlg.container, 620, 420, true, false);
  746. // Executed after dialog is added to dom
  747. dlg.init();
  748. }), parent);
  749. };
  750. this.put('insertLayout', new Menu(mxUtils.bind(this, function(menu, parent)
  751. {
  752. for (var i = 0; i < methods.length; i++)
  753. {
  754. if (methods[i] == '-')
  755. {
  756. menu.addSeparator(parent);
  757. }
  758. else
  759. {
  760. addInsertItem(menu, parent, mxResources.get(methods[i]) + '...', methods[i]);
  761. }
  762. }
  763. })));
  764. // Overrides view for plugins but label it options
  765. this.put('view', new Menu(mxUtils.bind(this, function(menu, parent)
  766. {
  767. ui.menus.addMenuItems(menu, ['grid', 'guides', '-', 'connectionArrows', 'connectionPoints', '-',
  768. 'copyConnect', 'collapseExpand', '-', 'mathematicalTypesetting'], parent);
  769. })));
  770. };
  771. // Initializes the user interface
  772. var editorUiInit = EditorUi.prototype.init;
  773. EditorUi.prototype.init = function()
  774. {
  775. editorUiInit.apply(this, arguments);
  776. var div = document.createElement('div');
  777. div.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;overflow-y:auto;overflow-x:hidden;';
  778. div.style.bottom = (urlParams['embed'] != '1' || urlParams['libraries'] == '1') ? '63px' : '32px';
  779. this.sidebar = this.createSidebar(div);
  780. // Needed for creating elements in Format panel
  781. var ui = this;
  782. var graph = ui.editor.graph;
  783. ui.toolbar = this.createToolbar(ui.createDiv('geToolbar'));
  784. ui.defaultLibraryName = mxResources.get('untitledLibrary');
  785. var menubar = document.createElement('div');
  786. menubar.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;height:30px;padding:8px;border-bottom:1px solid lightgray;background-color:#ffffff;text-align:left;white-space:nowrap;';
  787. var menuObj = new Menubar(ui, menubar);
  788. function addMenu(id, small, img, opacity)
  789. {
  790. var menu = ui.menus.get(id);
  791. var elt = menuObj.addMenu(mxResources.get(id), mxUtils.bind(this, function()
  792. {
  793. // Allows extensions of menu.functid
  794. menu.funct.apply(this, arguments);
  795. }));
  796. elt.className = 'geMenuItem';
  797. elt.style.display = 'inline-block';
  798. elt.style.boxSizing = 'border-box';
  799. elt.style.top = '6px';
  800. elt.style.marginRight = '6px';
  801. elt.style.height = '30px';
  802. elt.style.paddingTop = '6px';
  803. elt.style.paddingBottom = '6px';
  804. elt.setAttribute('title', mxResources.get(id));
  805. ui.menus.menuCreated(menu, elt, 'geMenuItem');
  806. if (img != null)
  807. {
  808. elt.style.backgroundImage = 'url(' + img + ')';
  809. elt.style.backgroundPosition = 'center center';
  810. elt.style.backgroundRepeat = 'no-repeat';
  811. elt.style.backgroundSize = '24px 24px';
  812. elt.style.width = '34px';
  813. elt.innerHTML = '';
  814. mxUtils.setOpacity(elt, opacity || 40);
  815. }
  816. else if (!small)
  817. {
  818. elt.style.backgroundImage = 'url(' + mxWindow.prototype.normalizeImage + ')';
  819. elt.style.backgroundPosition = 'right 6px center';
  820. elt.style.backgroundRepeat = 'no-repeat';
  821. elt.style.paddingRight = '22px';
  822. }
  823. return elt;
  824. };
  825. function addMenuItem(label, fn, small, tooltip, action, img)
  826. {
  827. var btn = document.createElement('a');
  828. btn.setAttribute('href', 'javascript:void(0)');
  829. btn.className = 'geMenuItem';
  830. btn.style.display = 'inline-block';
  831. btn.style.boxSizing = 'border-box';
  832. btn.style.height = '30px';
  833. btn.style.padding = '6px';
  834. btn.style.position = 'relative';
  835. btn.style.verticalAlign = 'top';
  836. btn.style.top = '0px';
  837. menubar.appendChild(btn);
  838. if (img != null)
  839. {
  840. btn.style.backgroundImage = 'url(' + img + ')';
  841. btn.style.backgroundPosition = 'center center';
  842. btn.style.backgroundRepeat = 'no-repeat';
  843. btn.style.backgroundSize = '24px 24px';
  844. btn.style.width = '34px';
  845. }
  846. else
  847. {
  848. mxUtils.write(btn, label);
  849. }
  850. mxEvent.addListener(btn, 'click', function(evt)
  851. {
  852. if (btn.getAttribute('disabled') != 'disabled')
  853. {
  854. fn(evt);
  855. }
  856. mxEvent.consume(evt);
  857. });
  858. if (small == null)
  859. {
  860. btn.style.marginRight = '4px';
  861. }
  862. if (tooltip != null)
  863. {
  864. btn.setAttribute('title', tooltip);
  865. }
  866. mxUtils.setOpacity(btn, (img != null) ? 40 : 100);
  867. if (action != null)
  868. {
  869. function updateState()
  870. {
  871. if (action.isEnabled())
  872. {
  873. btn.removeAttribute('disabled');
  874. mxUtils.setOpacity(btn, (img != null) ? 40 : 100);
  875. btn.style.cursor = '';
  876. }
  877. else
  878. {
  879. btn.setAttribute('disabled', 'disabled');
  880. mxUtils.setOpacity(btn, (img != null) ? 10 : 20);
  881. btn.style.cursor = 'default';
  882. }
  883. };
  884. action.addListener('stateChanged', updateState);
  885. updateState();
  886. }
  887. return btn;
  888. };
  889. function createGroup(btns)
  890. {
  891. var btnGroup = document.createElement('div');
  892. btnGroup.className = 'geMenuItem';
  893. btnGroup.style.display = 'inline-block';
  894. btnGroup.style.verticalAlign = 'top';
  895. btnGroup.style.marginRight = '6px';
  896. btnGroup.style.padding = '0 4px 0 4px';
  897. btnGroup.style.height = '30px';
  898. btnGroup.style.position = 'relative';
  899. btnGroup.style.top = '0px';
  900. for (var i = 0; i < btns.length; i++)
  901. {
  902. if (btns[i] != null)
  903. {
  904. btns[i].style.margin = '0px';
  905. btns[i].style.boxShadow = 'none';
  906. btnGroup.appendChild(btns[i]);
  907. }
  908. }
  909. menubar.appendChild(btnGroup);
  910. return btnGroup;
  911. };
  912. var small = iw < 900;
  913. if (!small)
  914. {
  915. addMenu('diagram');
  916. }
  917. createGroup([((small) ? addMenu('diagram', null, IMAGE_PATH + '/drawlogo-gray.svg', 100) : null),
  918. addMenuItem(mxResources.get('shapes'), ui.actions.get('toggleShapes').funct, null, mxResources.get('shapes'), ui.actions.get('image'),
  919. (small) ? 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTMgMTN2OGg4di04aC04ek0zIDIxaDh2LThIM3Y4ek0zIDN2OGg4VjNIM3ptMTMuNjYtMS4zMUwxMSA3LjM0IDE2LjY2IDEzbDUuNjYtNS42Ni01LjY2LTUuNjV6Ii8+PC9zdmc+' : null),
  920. addMenuItem(mxResources.get('format'), ui.actions.get('toggleFormat').funct, null,
  921. mxResources.get('format') + ' (' + ui.actions.get('formatPanel').shortcut + ')', ui.actions.get('image'),
  922. (small) ? 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgM2MtNC45NyAwLTkgNC4wMy05IDlzNC4wMyA5IDkgOWMuODMgMCAxLjUtLjY3IDEuNS0xLjUgMC0uMzktLjE1LS43NC0uMzktMS4wMS0uMjMtLjI2LS4zOC0uNjEtLjM4LS45OSAwLS44My42Ny0xLjUgMS41LTEuNUgxNmMyLjc2IDAgNS0yLjI0IDUtNSAwLTQuNDItNC4wMy04LTktOHptLTUuNSA5Yy0uODMgMC0xLjUtLjY3LTEuNS0xLjVTNS42NyA5IDYuNSA5IDggOS42NyA4IDEwLjUgNy4zMyAxMiA2LjUgMTJ6bTMtNEM4LjY3IDggOCA3LjMzIDggNi41UzguNjcgNSA5LjUgNXMxLjUuNjcgMS41IDEuNVMxMC4zMyA4IDkuNSA4em01IDBjLS44MyAwLTEuNS0uNjctMS41LTEuNVMxMy42NyA1IDE0LjUgNXMxLjUuNjcgMS41IDEuNVMxNS4zMyA4IDE0LjUgOHptMyA0Yy0uODMgMC0xLjUtLjY3LTEuNS0xLjVTMTYuNjcgOSAxNy41IDlzMS41LjY3IDEuNSAxLjUtLjY3IDEuNS0xLjUgMS41eiIvPjwvc3ZnPg==' : null)]);
  923. var elt = addMenu('insert', true, (small) ? 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTkgMTNoLTZ2NmgtMnYtNkg1di0yaDZWNWgydjZoNnYyeiIvPjwvc3ZnPg==' : null, 40);
  924. createGroup([elt, addMenuItem(mxResources.get('delete'), ui.actions.get('delete').funct, null, mxResources.get('delete'), ui.actions.get('delete'),
  925. (small) ? 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNiAxOWMwIDEuMS45IDIgMiAyaDhjMS4xIDAgMi0uOSAyLTJWN0g2djEyek0xOSA0aC0zLjVsLTEtMWgtNWwtMSAxSDV2MmgxNFY0eiIvPjwvc3ZnPg==' : null)]);
  926. if (iw >= 480)
  927. {
  928. var undoAction = ui.actions.get('undo');
  929. var redoAction = ui.actions.get('redo');
  930. var undoElt = addMenuItem('', undoAction.funct, null, mxResources.get('undo') + ' (' + undoAction.shortcut + ')', undoAction,
  931. 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIuNSA4Yy0yLjY1IDAtNS4wNS45OS02LjkgMi42TDIgN3Y5aDlsLTMuNjItMy42MmMxLjM5LTEuMTYgMy4xNi0xLjg4IDUuMTItMS44OCAzLjU0IDAgNi41NSAyLjMxIDcuNiA1LjVsMi4zNy0uNzhDMjEuMDggMTEuMDMgMTcuMTUgOCAxMi41IDh6Ii8+PC9zdmc+');
  932. var redoElt = addMenuItem('', redoAction.funct, null, mxResources.get('redo') + ' (' + redoAction.shortcut + ')', redoAction,
  933. 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTguNCAxMC42QzE2LjU1IDguOTkgMTQuMTUgOCAxMS41IDhjLTQuNjUgMC04LjU4IDMuMDMtOS45NiA3LjIyTDMuOSAxNmMxLjA1LTMuMTkgNC4wNS01LjUgNy42LTUuNSAxLjk1IDAgMy43My43MiA1LjEyIDEuODhMMTMgMTZoOVY3bC0zLjYgMy42eiIvPjwvc3ZnPg==');
  934. createGroup([undoElt, redoElt]);
  935. if (iw >= 560)
  936. {
  937. var zoomInAction = ui.actions.get('zoomIn');
  938. var zoomOutAction = ui.actions.get('zoomOut');
  939. var resetViewAction = ui.actions.get('resetView');
  940. createGroup([addMenuItem('', function()
  941. {
  942. graph.popupMenuHandler.hideMenu();
  943. var scale = graph.view.scale;
  944. var tx = graph.view.translate.x;
  945. var ty = graph.view.translate.y;
  946. ui.actions.get('resetView').funct();
  947. // Toggle scale if nothing has changed
  948. if (Math.abs(scale - graph.view.scale) < 0.00001 && tx == graph.view.translate.x && ty == graph.view.translate.y)
  949. {
  950. ui.actions.get((graph.pageVisible) ? 'fitPage' : 'fitWindow').funct();
  951. }
  952. }, true, mxResources.get('fit') + ' (' + Editor.ctrlKey + '+H)', resetViewAction,
  953. 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMyA1djRoMlY1aDRWM0g1Yy0xLjEgMC0yIC45LTIgMnptMiAxMEgzdjRjMCAxLjEuOSAyIDIgMmg0di0ySDV2LTR6bTE0IDRoLTR2Mmg0YzEuMSAwIDItLjkgMi0ydi00aC0ydjR6bTAtMTZoLTR2Mmg0djRoMlY1YzAtMS4xLS45LTItMi0yeiIvPjwvc3ZnPg=='),
  954. (iw >= 640) ? addMenuItem('', zoomInAction.funct, true, mxResources.get('zoomIn') + ' (' + Editor.ctrlKey + ' +)', zoomInAction,
  955. 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTUuNSAxNGgtLjc5bC0uMjgtLjI3QzE1LjQxIDEyLjU5IDE2IDExLjExIDE2IDkuNSAxNiA1LjkxIDEzLjA5IDMgOS41IDNTMyA1LjkxIDMgOS41IDUuOTEgMTYgOS41IDE2YzEuNjEgMCAzLjA5LS41OSA0LjIzLTEuNTdsLjI3LjI4di43OWw1IDQuOTlMMjAuNDkgMTlsLTQuOTktNXptLTYgMEM3LjAxIDE0IDUgMTEuOTkgNSA5LjVTNy4wMSA1IDkuNSA1IDE0IDcuMDEgMTQgOS41IDExLjk5IDE0IDkuNSAxNHptMi41LTRoLTJ2Mkg5di0ySDdWOWgyVjdoMXYyaDJ2MXoiLz48L3N2Zz4=') : null,
  956. (iw >= 640) ? addMenuItem('', zoomOutAction.funct, true, mxResources.get('zoomOut') + ' (' + Editor.ctrlKey + ' -)', zoomOutAction,
  957. 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTUuNSAxNGgtLjc5bC0uMjgtLjI3QzE1LjQxIDEyLjU5IDE2IDExLjExIDE2IDkuNSAxNiA1LjkxIDEzLjA5IDMgOS41IDNTMyA1LjkxIDMgOS41IDUuOTEgMTYgOS41IDE2YzEuNjEgMCAzLjA5LS41OSA0LjIzLTEuNTdsLjI3LjI4di43OWw1IDQuOTlMMjAuNDkgMTlsLTQuOTktNXptLTYgMEM3LjAxIDE0IDUgMTEuOTkgNSA5LjVTNy4wMSA1IDkuNSA1IDE0IDcuMDEgMTQgOS41IDExLjk5IDE0IDkuNSAxNHpNNyA5aDV2MUg3eiIvPjwvc3ZnPg==') : null]);
  958. }
  959. }
  960. ui.statusContainer = ui.createStatusContainer();
  961. ui.statusContainer.style.position = 'relative';
  962. ui.statusContainer.style.maxWidth = '';
  963. ui.statusContainer.style.marginTop = '7px';
  964. ui.statusContainer.style.marginLeft = '6px';
  965. ui.statusContainer.style.color = 'gray';
  966. ui.statusContainer.style.cursor = 'default';
  967. function updateTitle()
  968. {
  969. var file = ui.getCurrentFile();
  970. if (file != null && file.getTitle() != null)
  971. {
  972. var mode = file.getMode();
  973. if (mode == 'google')
  974. {
  975. mode = 'googleDrive';
  976. }
  977. else if (mode == 'github')
  978. {
  979. mode = 'gitHub';
  980. }
  981. else if (mode == 'onedrive')
  982. {
  983. mode = 'oneDrive';
  984. }
  985. mode = mxResources.get(mode);
  986. menubar.setAttribute('title', file.getTitle() + ((mode != null) ? ' (' + mode + ')' : ''));
  987. }
  988. else
  989. {
  990. menubar.removeAttribute('title');
  991. }
  992. };
  993. // Connects the status bar to the editor status
  994. ui.editor.addListener('statusChanged', mxUtils.bind(this, function()
  995. {
  996. ui.setStatusText(ui.editor.getStatus());
  997. }));
  998. // Connects the status bar to the editor status
  999. var uiDescriptorChanged = ui.descriptorChanged;
  1000. ui.descriptorChanged = function()
  1001. {
  1002. uiDescriptorChanged.apply(this, arguments);
  1003. updateTitle();
  1004. };
  1005. ui.setStatusText(ui.editor.getStatus());
  1006. menubar.appendChild(ui.statusContainer);
  1007. ui.buttonContainer = document.createElement('div');
  1008. ui.buttonContainer.style.cssText = 'position:absolute;right:40px;top:12px;white-space:nowrap;';
  1009. menubar.appendChild(ui.buttonContainer);
  1010. // Container for the user element
  1011. ui.menubarContainer = ui.buttonContainer;
  1012. var langMenu = this.menus.get('language');
  1013. if (langMenu != null && !mxClient.IS_CHROMEAPP && !EditorUi.isElectronApp && iw >= 480)
  1014. {
  1015. var elt = menuObj.addMenu('', langMenu.funct);
  1016. elt.setAttribute('title', mxResources.get('language'));
  1017. elt.style.backgroundImage = 'url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTEuOTkgMkM2LjQ3IDIgMiA2LjQ4IDIgMTJzNC40NyAxMCA5Ljk5IDEwQzE3LjUyIDIyIDIyIDE3LjUyIDIyIDEyUzE3LjUyIDIgMTEuOTkgMnptNi45MyA2aC0yLjk1Yy0uMzItMS4yNS0uNzgtMi40NS0xLjM4LTMuNTYgMS44NC42MyAzLjM3IDEuOTEgNC4zMyAzLjU2ek0xMiA0LjA0Yy44MyAxLjIgMS40OCAyLjUzIDEuOTEgMy45NmgtMy44MmMuNDMtMS40MyAxLjA4LTIuNzYgMS45MS0zLjk2ek00LjI2IDE0QzQuMSAxMy4zNiA0IDEyLjY5IDQgMTJzLjEtMS4zNi4yNi0yaDMuMzhjLS4wOC42Ni0uMTQgMS4zMi0uMTQgMiAwIC42OC4wNiAxLjM0LjE0IDJINC4yNnptLjgyIDJoMi45NWMuMzIgMS4yNS43OCAyLjQ1IDEuMzggMy41Ni0xLjg0LS42My0zLjM3LTEuOS00LjMzLTMuNTZ6bTIuOTUtOEg1LjA4Yy45Ni0xLjY2IDIuNDktMi45MyA0LjMzLTMuNTZDOC44MSA1LjU1IDguMzUgNi43NSA4LjAzIDh6TTEyIDE5Ljk2Yy0uODMtMS4yLTEuNDgtMi41My0xLjkxLTMuOTZoMy44MmMtLjQzIDEuNDMtMS4wOCAyLjc2LTEuOTEgMy45NnpNMTQuMzQgMTRIOS42NmMtLjA5LS42Ni0uMTYtMS4zMi0uMTYtMiAwLS42OC4wNy0xLjM1LjE2LTJoNC42OGMuMDkuNjUuMTYgMS4zMi4xNiAyIDAgLjY4LS4wNyAxLjM0LS4xNiAyem0uMjUgNS41NmMuNi0xLjExIDEuMDYtMi4zMSAxLjM4LTMuNTZoMi45NWMtLjk2IDEuNjUtMi40OSAyLjkzLTQuMzMgMy41NnpNMTYuMzYgMTRjLjA4LS42Ni4xNC0xLjMyLjE0LTIgMC0uNjgtLjA2LTEuMzQtLjE0LTJoMy4zOGMuMTYuNjQuMjYgMS4zMS4yNiAycy0uMSAxLjM2LS4yNiAyaC0zLjM4eiIvPjwvc3ZnPg==)';
  1018. elt.style.backgroundPosition = 'center center';
  1019. elt.style.backgroundRepeat = 'no-repeat';
  1020. elt.style.backgroundSize = '24px 24px';
  1021. elt.style.position = 'absolute';
  1022. elt.style.height = '24px';
  1023. elt.style.width = '24px';
  1024. elt.style.zIndex = '1';
  1025. elt.style.top = '11px';
  1026. elt.style.right = '14px';
  1027. mxUtils.setOpacity(elt, 30);
  1028. menubar.appendChild(elt);
  1029. }
  1030. ui.tabContainer = document.createElement('div');
  1031. ui.tabContainer.style.cssText = 'position:absolute;left:0px;right:0px;bottom:0px;height:30px;white-space:nowrap;' +
  1032. 'border-bottom:1px solid lightgray;background-color:#ffffff;border-top:1px solid lightgray;margin-bottom:-2px;';
  1033. var previousParent = ui.diagramContainer.parentNode;
  1034. var wrapper = document.createElement('div');
  1035. wrapper.style.cssText = 'position:absolute;top:0px;left:0px;right:0px;bottom:0px;overflow:hidden;';
  1036. ui.diagramContainer.style.top = '47px';
  1037. ui.diagramContainer.style.bottom = '30px';
  1038. var viewZoomMenu = ui.menus.get('viewZoom');
  1039. if (viewZoomMenu != null)
  1040. {
  1041. this.tabContainer.style.right = '70px';
  1042. var elt = menuObj.addMenu('100%', viewZoomMenu.funct);
  1043. elt.setAttribute('title', mxResources.get('zoom') + ' (Alt+Mousewheel)');
  1044. elt.style.whiteSpace = 'nowrap';
  1045. elt.style.backgroundImage = 'url(' + mxWindow.prototype.minimizeImage + ')';
  1046. elt.style.backgroundPosition = 'right 6px center';
  1047. elt.style.backgroundRepeat = 'no-repeat';
  1048. elt.style.paddingRight = '10px';
  1049. elt.style.display = 'block';
  1050. elt.style.position = 'absolute';
  1051. elt.style.textDecoration = 'none';
  1052. elt.style.textDecoration = 'none';
  1053. elt.style.right = '0px';
  1054. elt.style.bottom = '0px';
  1055. elt.style.overflow = 'hidden';
  1056. elt.style.textAlign = 'center';
  1057. elt.style.color = '#000';
  1058. elt.style.fontSize = '12px';
  1059. elt.style.color = '#707070';
  1060. elt.style.width = '59px';
  1061. elt.style.borderTop = '1px solid lightgray';
  1062. elt.style.borderLeft = '1px solid lightgray';
  1063. elt.style.height = (parseInt(ui.tabContainer.style.height) - 1) + 'px';
  1064. elt.style.lineHeight = (parseInt(ui.tabContainer.style.height) + 1) + 'px';
  1065. wrapper.appendChild(elt);
  1066. // Updates the label if the scale changes
  1067. var updateZoom = mxUtils.bind(this, function()
  1068. {
  1069. elt.innerHTML = Math.round(ui.editor.graph.view.scale * 100) + '%';
  1070. });
  1071. ui.editor.graph.view.addListener(mxEvent.EVENT_SCALE, updateZoom);
  1072. ui.editor.addListener('resetGraphView', updateZoom);
  1073. ui.editor.addListener('pageSelected', updateZoom);
  1074. // Augments setGraphEnabled to update visible state
  1075. var uiSetGraphEnabled = ui.setGraphEnabled;
  1076. ui.setGraphEnabled = function()
  1077. {
  1078. uiSetGraphEnabled.apply(this, arguments);
  1079. if (this.tabContainer != null)
  1080. {
  1081. elt.style.visibility = this.tabContainer.style.visibility;
  1082. }
  1083. };
  1084. }
  1085. wrapper.appendChild(ui.tabContainer);
  1086. wrapper.appendChild(menubar);
  1087. wrapper.appendChild(ui.diagramContainer);
  1088. previousParent.appendChild(wrapper);
  1089. ui.updateTabContainer();
  1090. mxEvent.addListener(window, 'resize', function()
  1091. {
  1092. if (ui.sidebarWindow != null)
  1093. {
  1094. ui.sidebarWindow.window.fit();
  1095. }
  1096. if (ui.formatWindow != null)
  1097. {
  1098. ui.formatWindow.window.fit();
  1099. }
  1100. if (ui.actions.outlineWindow != null)
  1101. {
  1102. ui.actions.outlineWindow.window.fit();
  1103. }
  1104. if (ui.actions.layersWindow != null)
  1105. {
  1106. ui.actions.layersWindow.window.fit();
  1107. }
  1108. if (ui.menus.tagsWindow != null)
  1109. {
  1110. ui.menus.tagsWindow.window.fit();
  1111. }
  1112. if (ui.menus.findWindow != null)
  1113. {
  1114. ui.menus.findWindow.window.fit();
  1115. }
  1116. });
  1117. };
  1118. };
  1119. (function()
  1120. {
  1121. var initialized = false;
  1122. // ChromeApp has async local storage
  1123. if (uiTheme == 'min' && !initialized && !mxClient.IS_CHROMEAPP)
  1124. {
  1125. EditorUi.initMinimalTheme();
  1126. initialized = true;
  1127. }
  1128. var uiInitTheme = EditorUi.initTheme;
  1129. // For async startup like chromeos
  1130. EditorUi.initTheme = function()
  1131. {
  1132. uiInitTheme.apply(this, arguments);
  1133. if (uiTheme == 'min' && !initialized)
  1134. {
  1135. this.initMinimalTheme();
  1136. initialized = true;
  1137. }
  1138. };
  1139. })();