Minimal.js 58 KB

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