1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830 |
- /**
- * Code for the minimal UI theme.
- */
- EditorUi.initMinimalTheme = function()
- {
- // Disabled in lightbox and chromeless mode
- if (urlParams['lightbox'] == '1' || urlParams['chrome'] == '0' || typeof window.Format === 'undefined' || typeof window.Menus === 'undefined')
- {
- window.uiTheme = null;
-
- return;
- }
-
- var iw = 0;
- try
- {
- iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
- }
- catch (e)
- {
- // ignore
- }
- /**
- *
- */
- var WrapperWindow = function(editorUi, title, x, y, w, h, fn)
- {
- var graph = editorUi.editor.graph;
-
- var div = document.createElement('div');
- div.className = 'geSidebarContainer';
- div.style.position = 'absolute';
- div.style.width = '100%';
- div.style.height = '100%';
- div.style.border = '1px solid whiteSmoke';
- div.style.overflowX = 'hidden';
- div.style.overflowY = 'auto';
-
- fn(div);
- this.window = new mxWindow(title, div, x, y, w, h, true, true);
- this.window.destroyOnClose = false;
- this.window.setMaximizable(false);
- this.window.setResizable(true);
- this.window.setClosable(true);
- this.window.setVisible(true);
-
- this.window.setLocation = function(x, y)
- {
- var iiw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
- var ih = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
-
- x = Math.max(0, Math.min(x, iiw - this.table.clientWidth));
- y = Math.max(0, Math.min(y, ih - this.table.clientHeight -
- ((urlParams['sketch'] == '1') ? 3 : 48)));
-
- if (this.getX() != x || this.getY() != y)
- {
- mxWindow.prototype.setLocation.apply(this, arguments);
- }
- };
-
- // Workaround for text selection starting in Safari
- // when dragging shapes outside of window
- if (mxClient.IS_SF)
- {
- this.window.div.onselectstart = mxUtils.bind(this, function(evt)
- {
- if (evt == null)
- {
- evt = window.event;
- }
-
- return (evt != null && editorUi.isSelectionAllowed(evt));
- });
- }
- };
- function toggleFormat(ui, visible)
- {
- var graph = ui.editor.graph;
- graph.popupMenuHandler.hideMenu();
-
- if (ui.formatWindow == null)
- {
- ui.formatWindow = new WrapperWindow(ui, mxResources.get('format'),
- (urlParams['sketch'] == '1') ? Math.max(10, ui.diagramContainer.clientWidth - 241) :
- Math.max(10, ui.diagramContainer.clientWidth - 248),
- EditorUi.isElectronApp && urlParams['sketch'] == '1'? 80 : 60,
- 240, Math.min(566, graph.container.clientHeight - 10), function(container)
- {
- var format = ui.createFormat(container);
- format.init();
-
- ui.addListener('darkModeChanged', mxUtils.bind(this, function()
- {
- format.refresh();
- }));
- return format;
- });
-
- ui.formatWindow.window.minimumSize = new mxRectangle(0, 0, 240, 80);
- ui.formatWindow.window.setVisible(true);
- }
- else
- {
- ui.formatWindow.window.setVisible((visible != null) ?
- visible : !ui.formatWindow.window.isVisible());
- }
- if (ui.formatWindow.window.isVisible() && urlParams['sketch'] != '1')
- {
- ui.formatWindow.window.fit();
- }
- };
- function toggleShapes(ui, visible)
- {
- var graph = ui.editor.graph;
- graph.popupMenuHandler.hideMenu();
- var rect = new mxRectangle();
- if (ui.sidebarWindow == null)
- {
- var w = Math.min(graph.container.clientWidth - 10, 218);
-
- ui.sidebarWindow = new WrapperWindow(ui, mxResources.get('shapes'), 10,
- (urlParams['sketch'] == '1' && urlParams['embedInline'] != '1') ? 15 : 56,
- w - 6, Math.min(650, graph.container.clientHeight - 30),
- function(container)
- {
- var div = document.createElement('div');
- div.style.cssText = 'position:absolute;left:0;right:0;border-top:1px solid lightgray;' +
- 'height:24px;bottom:31px;text-align:center;cursor:pointer;padding:6px 0 0 0;';
- div.className = 'geTitle';
- var span = document.createElement('span');
- span.style.fontSize = '18px';
- span.style.marginRight = '5px';
- span.innerHTML = '+';
- div.appendChild(span);
- mxUtils.write(div, mxResources.get('moreShapes'));
- container.appendChild(div);
-
- mxEvent.addListener(div, 'click', function()
- {
- ui.actions.get('shapes').funct();
- });
- var menuObj = new Menubar(ui, container);
-
- function addMenu(id, label)
- {
- var menu = ui.menus.get(id);
-
- var elt = menuObj.addMenu(label, mxUtils.bind(this, function()
- {
- // Allows extensions of menu.functid
- menu.funct.apply(this, arguments);
- }));
-
- elt.style.cssText = 'position:absolute;border-top:1px solid lightgray;width:50%;' +
- 'height:24px;bottom:0px;text-align:center;cursor:pointer;padding:6px 0 0 0;cusor:pointer;';
- elt.className = 'geTitle';
- container.appendChild(elt);
-
- return elt;
- }
-
- if (Editor.enableCustomLibraries && (urlParams['embed'] != '1' || urlParams['libraries'] == '1'))
- {
- // Defined in native apps together with openLibrary
- if (ui.actions.get('newLibrary') != null)
- {
- var div = document.createElement('div');
- div.style.cssText = 'position:absolute;left:0px;width:50%;border-top:1px solid lightgray;' +
- 'height:30px;bottom:0px;text-align:center;cursor:pointer;padding:0px;';
- div.className = 'geTitle';
- var span = document.createElement('span');
- span.style.cssText = 'position:relative;top:6px;';
- mxUtils.write(span, mxResources.get('newLibrary'));
- div.appendChild(span);
- container.appendChild(div);
-
- mxEvent.addListener(div, 'click', ui.actions.get('newLibrary').funct);
-
- var div = document.createElement('div');
- div.style.cssText = 'position:absolute;left:50%;width:50%;border-top:1px solid lightgray;' +
- 'height:30px;bottom:0px;text-align:center;cursor:pointer;padding:0px;border-left: 1px solid lightgray;';
- div.className = 'geTitle';
- var span = document.createElement('span');
- span.style.cssText = 'position:relative;top:6px;';
- mxUtils.write(span, mxResources.get('openLibrary'));
- div.appendChild(span);
- container.appendChild(div);
-
- mxEvent.addListener(div, 'click', ui.actions.get('openLibrary').funct);
- }
- else
- {
- var elt = addMenu('newLibrary', mxResources.get('newLibrary'));
- elt.style.boxSizing = 'border-box';
- elt.style.paddingRight = '6px';
- elt.style.paddingLeft = '6px';
- elt.style.height = '32px';
- elt.style.left = '0';
-
- var elt = addMenu('openLibraryFrom', mxResources.get('openLibraryFrom'));
- elt.style.borderLeft = '1px solid lightgray';
- elt.style.boxSizing = 'border-box';
- elt.style.paddingRight = '6px';
- elt.style.paddingLeft = '6px';
- elt.style.height = '32px';
- elt.style.left = '50%';
- }
- }
- else
- {
- div.style.bottom = '0';
- }
- container.appendChild(ui.sidebar.container);
- container.style.overflow = 'hidden';
-
- return container;
- });
-
- ui.sidebarWindow.window.minimumSize = new mxRectangle(0, 0, 90, 90);
- ui.sidebarWindow.window.setVisible(true);
-
- ui.getLocalData('sidebar', function(value)
- {
- ui.sidebar.showEntries(value, null, true);
- });
-
- ui.restoreLibraries();
- }
- else
- {
- ui.sidebarWindow.window.setVisible((visible != null) ?
- visible : !ui.sidebarWindow.window.isVisible());
- }
-
- if (ui.sidebarWindow.window.isVisible())
- {
- ui.sidebarWindow.window.fit();
- }
- };
-
- // Changes colors for some UI elements
- var fill = '#29b6f2';
- var stroke = '#ffffff';
-
- 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;
- 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;
- mxWindow.prototype.minimizeImage = Graph.createSvgImage(14, 10, '<path d="M 3 7 L 7 3 L 11 7" stroke="#C0C0C0" stroke-width="2" fill="none"/>').src;
- mxWindow.prototype.normalizeImage = Graph.createSvgImage(14, 10, '<path d="M 3 3 L 7 7 L 11 3" stroke="#C0C0C0" stroke-width="2" fill="none"/>').src;
- mxConstraintHandler.prototype.pointImage = Graph.createSvgImage(5, 5,
- '<path d="m 0 0 L 5 5 M 0 5 L 5 0" stroke-width="2" style="stroke-opacity:0.4" stroke="#ffffff"/>' +
- '<path d="m 0 0 L 5 5 M 0 5 L 5 0" stroke="' + fill + '"/>');
- mxOutline.prototype.sizerImage = null;
-
- mxConstants.VERTEX_SELECTION_COLOR = '#C0C0C0';
- mxConstants.EDGE_SELECTION_COLOR = '#C0C0C0';
- mxConstants.CONNECT_HANDLE_FILLCOLOR = '#cee7ff';
-
- mxConstants.DEFAULT_VALID_COLOR = fill;
- mxConstants.GUIDE_COLOR = '#C0C0C0';
- mxConstants.HIGHLIGHT_STROKEWIDTH = 5;
- mxConstants.HIGHLIGHT_OPACITY = 35;
- mxConstants.OUTLINE_COLOR = '#29b6f2';
- mxConstants.OUTLINE_HANDLE_FILLCOLOR = '#29b6f2';
- mxConstants.OUTLINE_HANDLE_STROKECOLOR = '#fff';
- Graph.prototype.svgShadowColor = '#3D4574';
- Graph.prototype.svgShadowOpacity = '0.4';
- Graph.prototype.svgShadowSize = '0.6';
- Graph.prototype.svgShadowBlur = '1.2';
- Format.inactiveTabBackgroundColor = '#f0f0f0';
- mxGraphHandler.prototype.previewColor = '#C0C0C0';
- mxRubberband.prototype.defaultOpacity = 50;
- HoverIcons.prototype.inactiveOpacity = 25;
- Format.prototype.showCloseButton = false;
- EditorUi.prototype.closableScratchpad = false;
- EditorUi.prototype.toolbarHeight = (urlParams['sketch'] == '1') ? 1 : 46;
- EditorUi.prototype.footerHeight = 0;
- Graph.prototype.editAfterInsert = urlParams['sketch'] != '1' &&
- !mxClient.IS_IOS && !mxClient.IS_ANDROID;
- /**
- * Dynamic change of dark mode.
- */
- EditorUi.prototype.setDarkMode = function(value)
- {
- if (this.spinner.spin(document.body, mxResources.get('working') + '...'))
- {
- window.setTimeout(mxUtils.bind(this, function()
- {
- this.spinner.stop();
- this.doSetDarkMode(value);
-
- // Persist setting
- if (urlParams['dark'] == null)
- {
- mxSettings.settings.darkMode = value;
- mxSettings.save();
- }
- this.fireEvent(new mxEventObject('darkModeChanged'));
- }), 0);
- }
- };
-
- /**
- * Links to dark.css
- */
- var darkStyle = document.createElement('link');
- darkStyle.setAttribute('rel', 'stylesheet');
- darkStyle.setAttribute('href', STYLE_PATH + '/dark.css');
- darkStyle.setAttribute('charset', 'UTF-8');
- darkStyle.setAttribute('type', 'text/css');
- /**
- * Dynamic change of dark mode.
- */
- EditorUi.prototype.doSetDarkMode = function(value)
- {
- if (Editor.darkMode != value)
- {
- var graph = this.editor.graph;
- Editor.darkMode = value;
- // Sets instance vars and graph stylesheet
- this.spinner.opts.color = Editor.isDarkMode() ? '#c0c0c0' : '#000';
- this.setGridColor(Editor.isDarkMode() ? graph.view.defaultDarkGridColor : graph.view.defaultGridColor);
- graph.defaultPageBackgroundColor = (urlParams['embedInline'] == '1') ? 'transparent' :
- Editor.isDarkMode() ? Editor.darkColor : '#ffffff';
- graph.defaultPageBorderColor = Editor.isDarkMode() ? '#505759' : '#ffffff';
- graph.shapeBackgroundColor = Editor.isDarkMode() ? Editor.darkColor : '#ffffff';
- graph.shapeForegroundColor = Editor.isDarkMode() ? Editor.lightColor : '#000000';
- graph.defaultThemeName = Editor.isDarkMode() ? 'darkTheme' : 'default-style2';
- graph.graphHandler.previewColor = Editor.isDarkMode() ? '#cccccc' : 'black';
- document.body.style.backgroundColor = (urlParams['embedInline'] == '1') ? 'transparent' :
- (Editor.isDarkMode() ? Editor.darkColor : '#ffffff');
- graph.loadStylesheet();
- // Destroys windows with code for dark mode
- if (this.actions.layersWindow != null)
- {
- var wasVisible = this.actions.layersWindow.window.isVisible();
-
- this.actions.layersWindow.window.setVisible(false);
- this.actions.layersWindow.destroy();
- this.actions.layersWindow = null;
- if (wasVisible)
- {
- window.setTimeout(this.actions.get('layers').funct, 0);
- }
- }
- if (this.menus.commentsWindow != null)
- {
- this.menus.commentsWindow.window.setVisible(false);
- this.menus.commentsWindow.destroy();
- this.menus.commentsWindow = null;
- }
-
- if (this.ruler != null)
- {
- this.ruler.updateStyle();
- }
- // Sets global vars
- Graph.prototype.defaultPageBackgroundColor = graph.defaultPageBackgroundColor;
- Graph.prototype.defaultPageBorderColor = graph.defaultPageBorderColor;
- Graph.prototype.shapeBackgroundColor = graph.shapeBackgroundColor;
- Graph.prototype.shapeForegroundColor = graph.shapeForegroundColor;
- Graph.prototype.defaultThemeName = graph.defaultThemeName;
- StyleFormatPanel.prototype.defaultStrokeColor = Editor.isDarkMode() ? '#cccccc' : 'black';
- BaseFormatPanel.prototype.buttonBackgroundColor = Editor.isDarkMode() ? Editor.darkColor : 'white';
- Format.inactiveTabBackgroundColor = Editor.isDarkMode() ? 'black' : '#f0f0f0';
- Dialog.backdropColor = Editor.isDarkMode() ? Editor.darkColor : 'white';
- mxConstants.DROP_TARGET_COLOR = Editor.isDarkMode() ? '#00ff00' : '#0000FF';
- Editor.helpImage = (Editor.isDarkMode() && mxClient.IS_SVG) ?
- Editor.darkHelpImage : Editor.lightHelpImage;
- Editor.checkmarkImage = (Editor.isDarkMode() && mxClient.IS_SVG) ?
- Editor.darkCheckmarkImage : Editor.lightCheckmarkImage;
-
- // Updates CSS
- styleElt.innerHTML = Editor.createMinimalCss();
-
- // Adds or removes link to CSS
- if (Editor.darkMode)
- {
- if (darkStyle.parentNode == null)
- {
- var head = document.getElementsByTagName('head')[0];
- head.appendChild(darkStyle);
- }
- }
- else if (darkStyle.parentNode != null)
- {
- darkStyle.parentNode.removeChild(darkStyle);
- }
- }
- };
- /**
- * Dynamic change of dark mode.
- */
- Editor.createMinimalCss = function()
- {
- return '* { -webkit-font-smoothing: antialiased; }' +
- 'html body td.mxWindowTitle > div > img { padding: 8px 4px; }' +
- // Dark mode styles
- (Editor.isDarkMode() ?
- 'html body td.mxWindowTitle > div > img { margin: -4px; }' +
- 'html body .geToolbarContainer .geMenuItem, html body .geToolbarContainer .geToolbarButton, ' +
- 'html body .geMenubarContainer .geMenuItem .geMenuItem, html body .geMenubarContainer a.geMenuItem,' +
- 'html body .geMenubarContainer .geToolbarButton { filter: invert(1); }' +
- 'html body div.geToolbarContainer a.geInverted { filter: none; }' +
- 'html body .geMenubarContainer .geMenuItem .geMenuItem, html body .geMenubarContainer a.geMenuItem { color: #353535; }' +
- 'html > body > div > .geToolbarContainer { border: 1px solid #c0c0c0 !important; box-shadow: none !important; }' +
- 'html > body.geEditor > div > a.geItem { background-color: #2a2a2a; color: #cccccc; border-color: #505759; }' +
- 'html body .geTabContainer, html body .geTabContainer div, html body .geMenubarContainer { border-color: #505759 !important; }' +
- 'html body .mxCellEditor { color: #f0f0f0; }'
- :
- // Non-dark mode styles
- 'html body div.geToolbarContainer a.geInverted { filter: invert(1); }' +
- 'html body.geEditor .geTabContainer div { border-color: #e5e5e5 !important; }'
- ) +
- // End of custom styles
- 'html > body > div > a.geItem { background-color: #ffffff; color: #707070; border-top: 1px solid lightgray; border-left: 1px solid lightgray; }' +
- 'html body .geMenubarContainer { border-bottom:1px solid lightgray;background-color:#ffffff; }' +
- 'html body .mxWindow button.geBtn { font-size:12px !important; margin-left: 0; }' +
- 'html body table.mxWindow td.mxWindowPane div.mxWindowPane *:not(svg *) { font-size:9pt; }' +
- 'table.mxWindow * :not(svg *) { font-size:13px; }' +
- 'html body .mxWindow { z-index: 3; }' +
- 'html body div.diagramContainer button, html body button.geBtn { font-size:14px; font-weight:700; border-radius: 5px; }' +
- 'html body button.geBtn:active { opacity: 0.6; }' +
- 'html body a.geMenuItem { opacity: 0.75; cursor: pointer; user-select: none; }' +
- 'html body a.geMenuItem[disabled] { opacity: 0.2; }' +
- 'html body a.geMenuItem[disabled]:active { opacity: 0.2; }' +
- 'html body div.geActivePage { opacity: 0.7; }' +
- 'html body a.geMenuItem:active { opacity: 0.2; }' +
- 'html body .geToolbarButton { opacity: 0.3; }' +
- 'html body .geToolbarButton:active { opacity: 0.15; }' +
- 'html body .geStatus:active { opacity: 0.5; }' +
- 'html body .geStatus { padding-top:3px !important; }' +
- 'html body .geMenubarContainer .geStatus { margin-top: 0px !important; }' +
- 'html table.mxPopupMenu tr.mxPopupMenuItemHover:active { opacity: 0.7; }' +
- 'html body .geDialog input, html body .geToolbarContainer input, html body .mxWindow input {padding: 2px; display: inline-block; }' +
- 'html body .mxWindow input[type="checkbox"] {padding: 0px; }' +
- 'div.geDialog { border-radius: 5px; }' +
- 'html body div.geDialog button.geBigButton { color: ' + (Editor.isDarkMode() ? Editor.darkColor : '#fff') + ' !important; border: none !important; }' +
- '.mxWindow button, .geDialog select, .mxWindow select { display:inline-block; }' +
- 'html body .mxWindow .geColorBtn, html body .geDialog .geColorBtn { background: none; }' +
- 'html body div.diagramContainer button, html body .mxWindow button, html body .geDialog button { min-width: 0px; border-radius: 5px; color: ' + (Editor.isDarkMode() ? '#cccccc' : '#353535') + ' !important; border-style: solid; border-width: 1px; border-color: rgb(216, 216, 216); }' +
- 'html body div.diagramContainer button:hover, html body .mxWindow button:hover, html body .geDialog button:hover { border-color: rgb(177, 177, 177); }' +
- 'html body div.diagramContainer button:active, html body .mxWindow button:active, html body .geDialog button:active { opacity: 0.6; }' +
- 'div.diagramContainer button.geBtn, .mxWindow button.geBtn, .geDialog button.geBtn { min-width:72px; font-weight: 600; background: none; }' +
- 'div.diagramContainer button.gePrimaryBtn, .mxWindow button.gePrimaryBtn, .geDialog button.gePrimaryBtn, html body .gePrimaryBtn { background: #29b6f2; color: #fff !important; border: none; box-shadow: none; }' +
- 'html body .gePrimaryBtn:hover { background: #29b6f2; border: none; box-shadow: inherit; }' +
- 'html body button.gePrimaryBtn:hover { background: #29b6f2; border: none; }' +
- '.geBtn button { min-width:72px !important; }' +
- 'div.geToolbarContainer a.geButton { margin:0px; padding: 0 2px 4px 2px; } ' +
- 'html body div.geToolbarContainer a.geColorBtn { margin: 2px; } ' +
- 'html body .mxWindow td.mxWindowPane input, html body .mxWindow td.mxWindowPane select, html body .mxWindow td.mxWindowPane textarea, html body .mxWindow td.mxWindowPane radio { padding: 0px; box-sizing: border-box; }' +
- '.geDialog, .mxWindow td.mxWindowPane *, div.geSprite, td.mxWindowTitle, .geDiagramContainer { box-sizing:content-box; }' +
- '.mxWindow div button.geStyleButton { box-sizing: border-box; }' +
- 'table.mxWindow td.mxWindowPane button.geColorBtn { padding:0px; box-sizing: border-box; }' +
- 'td.mxWindowPane .geSidebarContainer button { padding:2px; box-sizing: border-box; }' +
- '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); }' +
- // Styling for Minimal
- '.geTabContainer { border-bottom:1px solid lightgray; border-top:1px solid lightgray; background: ' + (Editor.isDarkMode() ? Editor.darkColor : '#fff') + ' !important; }' +
- '.geToolbarContainer { background: ' + (Editor.isDarkMode() ? Editor.darkColor : '#fff') + '; }' +
- 'div.geSidebarContainer { background-color: ' + (Editor.isDarkMode() ? Editor.darkColor : '#fff') + '; }' +
- 'div.geSidebarContainer .geTitle { background-color: ' + (Editor.isDarkMode() ? Editor.darkColor : '#fdfdfd') + '; }' +
- 'div.mxWindow td.mxWindowPane button { background-image: none; float: none; }' +
- 'td.mxWindowTitle { height: 22px !important; background: none !important; font-size: 13px !important; text-align:center !important; border-bottom:1px solid lightgray; }' +
- 'div.mxWindow, div.mxWindowTitle { background-image: none !important; background-color:' + (Editor.isDarkMode() ? Editor.darkColor : '#fff') + ' !important; }' +
- 'div.mxWindow { border-radius:5px; box-shadow: 0px 0px 2px #C0C0C0 !important;}' +
- 'div.mxWindow *:not(svg *) { font-family: inherit !important; }' +
- // Minimal Style UI
- '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); }' +
- 'html div.geInactivePage { background: ' + (Editor.isDarkMode() ? Editor.darkColor : 'rgb(249, 249, 249)') + ' !important; color: #A0A0A0 !important; } ' +
- 'html div.geActivePage { background: ' + (Editor.isDarkMode() ? Editor.darkColor : '#fff') + ' !important; ' + (Editor.isDarkMode() ? '' : 'color: #353535 !important; } ') +
- 'html div.mxRubberband { border:1px solid; border-color: #29b6f2 !important; background:rgba(41,182,242,0.4) !important; } ' +
- '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); } ' +
- 'html table.mxPopupMenu td.mxPopupMenuItem { color: ' + (Editor.isDarkMode() ? '#cccccc' : '#353535') + '; font-size: 14px; padding-top: 4px; padding-bottom: 4px; }' +
- 'html table.mxPopupMenu tr.mxPopupMenuItemHover { background-color: ' + (Editor.isDarkMode() ? '#000000' : '#29b6f2') + '; }' +
- 'html tr.mxPopupMenuItemHover td.mxPopupMenuItem, html tr.mxPopupMenuItemHover td.mxPopupMenuItem span { color: ' + (Editor.isDarkMode() ? '#cccccc' : '#ffffff') + ' !important; }' +
- 'html tr.mxPopupMenuItem, html td.mxPopupMenuItem { transition-property: none !important; }' +
- 'html table.mxPopupMenu hr { height: 2px; background-color: rgba(0,0,0,.07); margin: 5px 0; }' +
- 'html body td.mxWindowTitle { padding-right: 14px; }' +
- 'html td.mxWindowTitle div { top: 0px !important; }' +
- // Fixes checkbox and radio size on iOS
- ((mxClient.IS_IOS) ? 'html input[type=checkbox], html input[type=radio] { height:12px; }' : '') +
- ((urlParams['sketch'] == '1') ? 'a.geStatus > div { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }' : '');
- };
-
- var styleElt = document.createElement('style')
- styleElt.type = 'text/css';
- styleElt.innerHTML = Editor.createMinimalCss();
- document.getElementsByTagName('head')[0].appendChild(styleElt);
- /**
- * Sets the XML node for the current diagram.
- */
- Editor.prototype.isChromelessView = function()
- {
- return false;
- };
- /**
- * Sets the XML node for the current diagram.
- */
- Graph.prototype.isLightboxView = function()
- {
- return false;
- };
-
- // Overridden to ignore tabContainer height for diagramContainer
- var editorUiUpdateTabContainer = EditorUi.prototype.updateTabContainer;
-
- EditorUi.prototype.updateTabContainer = function()
- {
- if (this.tabContainer != null)
- {
- // Makes room for view zoom menu
- this.tabContainer.style.right = '70px';
- this.diagramContainer.style.bottom = (urlParams['sketch'] == '1') ?
- '0px' : this.tabContainerHeight + 'px';
- }
-
- editorUiUpdateTabContainer.apply(this, arguments);
- };
- // Overridden to update save menu state
- /**
- * Updates action states depending on the selection.
- */
- var editorUiUpdateActionStates = EditorUi.prototype.updateActionStates;
-
- EditorUi.prototype.updateActionStates = function()
- {
- editorUiUpdateActionStates.apply(this, arguments);
- this.menus.get('save').setEnabled(this.getCurrentFile() != null || urlParams['embed'] == '1');
- };
- // Hides keyboard shortcuts in menus
- var menusAddShortcut = Menus.prototype.addShortcut;
-
- Menus.prototype.addShortcut = function(item, action)
- {
- if (action.shortcut != null && iw < 900 && !mxClient.IS_IOS)
- {
- var td = item.firstChild.nextSibling;
- td.setAttribute('title', action.shortcut);
- }
- else
- {
- menusAddShortcut.apply(this, arguments);
- }
- };
- var appUpdateUserElement = App.prototype.updateUserElement;
-
- App.prototype.updateUserElement = function()
- {
- appUpdateUserElement.apply(this, arguments);
-
- if (this.userElement != null)
- {
- var elt = this.userElement;
- elt.style.cssText = 'position:relative;margin-right:4px;cursor:pointer;display:' + elt.style.display;
- elt.className = 'geToolbarButton';
- elt.innerHTML = '';
- elt.style.backgroundImage = 'url(' + Editor.userImage + ')';
- elt.style.backgroundPosition = 'center center';
- elt.style.backgroundRepeat = 'no-repeat';
- elt.style.backgroundSize = '24px 24px';
- elt.style.height = '24px';
- elt.style.width = '24px';
- elt.style.cssFloat = 'right';
- elt.setAttribute('title', mxResources.get('changeUser'));
-
- if (elt.style.display != 'none')
- {
- elt.style.display = 'inline-block';
- }
- }
- };
-
- var appUpdateButtonContainer = App.prototype.updateButtonContainer;
-
- App.prototype.updateButtonContainer = function()
- {
- appUpdateButtonContainer.apply(this, arguments);
-
- if (this.shareButton != null)
- {
- var elt = this.shareButton;
- elt.style.cssText = 'display:inline-block;position:relative;box-sizing:border-box;margin-right:4px;cursor:pointer;';
- elt.className = 'geToolbarButton';
- elt.innerHTML = '';
- elt.style.backgroundImage = 'url(' + Editor.shareImage + ')';
- elt.style.backgroundPosition = 'center center';
- elt.style.backgroundRepeat = 'no-repeat';
- elt.style.backgroundSize = '24px 24px';
- elt.style.height = '24px';
- elt.style.width = '24px';
- // Share button hidden via CSS to enable notifications button
- if (urlParams['sketch'] == '1')
- {
- this.shareButton.style.display = 'none';
- }
- }
-
- if (this.buttonContainer != null)
- {
- this.buttonContainer.style.marginTop = '-2px';
- this.buttonContainer.style.paddingTop = '4px';
- }
- };
- EditorUi.prototype.addEmbedButtons = function()
- {
- if (this.buttonContainer != null && urlParams['embedInline'] != '1')
- {
- var div = document.createElement('div');
- div.style.display = 'inline-block';
- div.style.position = 'relative';
- div.style.marginTop = '6px';
- div.style.marginRight = '4px';
-
- var button = document.createElement('a');
- button.className = 'geMenuItem gePrimaryBtn';
- button.style.marginLeft = '8px';
- button.style.padding = '6px';
-
- if (urlParams['noSaveBtn'] == '1')
- {
- if (urlParams['saveAndExit'] != '0')
- {
- var saveAndExitTitle = urlParams['publishClose'] == '1' ? mxResources.get('publish') : mxResources.get('saveAndExit');
- mxUtils.write(button, saveAndExitTitle);
- button.setAttribute('title', saveAndExitTitle);
-
- mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
- {
- this.actions.get('saveAndExit').funct();
- }));
-
- div.appendChild(button);
- }
- }
- else
- {
- mxUtils.write(button, mxResources.get('save'));
- button.setAttribute('title', mxResources.get('save') + ' (' + Editor.ctrlKey + '+S)');
-
- mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
- {
- this.actions.get('save').funct();
- }));
-
- div.appendChild(button);
-
- if (urlParams['saveAndExit'] == '1')
- {
- button = document.createElement('a');
- mxUtils.write(button, mxResources.get('saveAndExit'));
- button.setAttribute('title', mxResources.get('saveAndExit'));
- button.className = 'geMenuItem';
- button.style.marginLeft = '6px';
- button.style.padding = '6px';
-
- mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
- {
- this.actions.get('saveAndExit').funct();
- }));
-
- div.appendChild(button);
- }
- }
- if (urlParams['noExitBtn'] != '1')
- {
- button = document.createElement('a');
- var exitTitle = urlParams['publishClose'] == '1' ? mxResources.get('close') : mxResources.get('exit');
- mxUtils.write(button, exitTitle);
- button.setAttribute('title', exitTitle);
- button.className = 'geMenuItem';
- button.style.marginLeft = '6px';
- button.style.padding = '6px';
-
- mxEvent.addListener(button, 'click', mxUtils.bind(this, function()
- {
- this.actions.get('exit').funct();
- }));
-
- div.appendChild(button);
- }
-
- this.buttonContainer.appendChild(div);
- this.buttonContainer.style.top = '6px';
- this.editor.fireEvent(new mxEventObject('statusChanged'));
- }
- };
-
- // Fixes sidebar tooltips (previews)
- var sidebarGetTooltipOffset = Sidebar.prototype.getTooltipOffset;
-
- Sidebar.prototype.getTooltipOffset = function(elt, bounds)
- {
- if (this.editorUi.sidebarWindow == null ||
- mxUtils.isAncestorNode(this.editorUi.picker, elt))
- {
- var off = mxUtils.getOffset(this.editorUi.picker);
-
- off.x += this.editorUi.picker.offsetWidth + 4;
- off.y += elt.offsetTop - bounds.height / 2 + 16;
-
- return off;
- }
- else
- {
- var result = sidebarGetTooltipOffset.apply(this, arguments);
- var off = mxUtils.getOffset(this.editorUi.sidebarWindow.window.div);
-
- result.x += off.x - 16;
- result.y += off.y;
-
- return result;
- }
- };
-
- // Adds context menu items
- var menuCreatePopupMenu = Menus.prototype.createPopupMenu;
-
- Menus.prototype.createPopupMenu = function(menu, cell, evt)
- {
- var graph = this.editorUi.editor.graph;
- menu.smartSeparators = true;
- menuCreatePopupMenu.apply(this, arguments);
-
- if (urlParams['sketch'] == '1')
- {
- if (graph.isEnabled())
- {
- menu.addSeparator();
-
- if (graph.getSelectionCount() == 1)
- {
- this.addMenuItems(menu, ['-', 'lockUnlock'], null, evt);
- }
- }
- }
- else
- {
- if (graph.getSelectionCount() == 1)
- {
- if (graph.isCellFoldable(graph.getSelectionCell()))
- {
- this.addMenuItems(menu, (graph.isCellCollapsed(cell)) ? ['expand'] : ['collapse'], null, evt);
- }
-
- this.addMenuItems(menu, ['collapsible', '-', 'lockUnlock', 'enterGroup'], null, evt);
- menu.addSeparator();
- this.addSubmenu('layout', menu);
- }
- else if (graph.isSelectionEmpty() && graph.isEnabled())
- {
- menu.addSeparator();
- this.addMenuItems(menu, ['editData'], null, evt);
- menu.addSeparator();
- this.addSubmenu('layout', menu);
- this.addSubmenu('insert', menu);
- this.addMenuItems(menu, ['-', 'exitGroup'], null, evt);
- }
- else if (graph.isEnabled())
- {
- this.addMenuItems(menu, ['-', 'lockUnlock'], null, evt);
- }
- }
-
- if (graph.isEnabled() && graph.isSelectionEmpty())
- {
- this.addMenuItems(menu, ['-', 'fullscreen']);
- if (urlParams['embedInline'] != '1' && (Editor.isDarkMode() ||
- (!mxClient.IS_IE && !mxClient.IS_IE11)))
- {
- this.addMenuItems(menu, ['toggleDarkMode']);
- }
- }
- };
- // Adds copy as image after paste for empty selection
- var menuAddPopupMenuEditItems = Menus.prototype.addPopupMenuEditItems;
-
- /**
- * Creates the keyboard event handler for the current graph and history.
- */
- Menus.prototype.addPopupMenuEditItems = function(menu, cell, evt)
- {
- menuAddPopupMenuEditItems.apply(this, arguments);
-
- if (this.editorUi.editor.graph.isSelectionEmpty())
- {
- this.addMenuItems(menu, ['copyAsImage'], null, evt);
- }
- };
-
- // Overridden to toggle window instead
- EditorUi.prototype.toggleFormatPanel = function(visible)
- {
- if (this.formatWindow != null)
- {
- this.formatWindow.window.setVisible((visible != null) ?
- visible : !this.formatWindow.window.isVisible());
- }
- else
- {
- toggleFormat(this);
- }
- };
- DiagramFormatPanel.prototype.isMathOptionVisible = function()
- {
- return true;
- };
-
- // Initializes the user interface
- var editorUiDestroy = EditorUi.prototype.destroy;
- EditorUi.prototype.destroy = function()
- {
- if (this.sidebarWindow != null)
- {
- this.sidebarWindow.window.setVisible(false);
- this.sidebarWindow.window.destroy();
- this.sidebarWindow = null;
- }
-
- if (this.formatWindow != null)
- {
- this.formatWindow.window.setVisible(false);
- this.formatWindow.window.destroy();
- this.formatWindow = null;
- }
- if (this.actions.outlineWindow != null)
- {
- this.actions.outlineWindow.window.setVisible(false);
- this.actions.outlineWindow.window.destroy();
- this.actions.outlineWindow = null;
- }
- if (this.actions.layersWindow != null)
- {
- this.actions.layersWindow.window.setVisible(false);
- this.actions.layersWindow.destroy();
- this.actions.layersWindow = null;
- }
- if (this.menus.tagsWindow != null)
- {
- this.menus.tagsWindow.window.setVisible(false);
- this.menus.tagsWindow.window.destroy();
- this.menus.tagsWindow = null;
- }
- if (this.menus.findWindow != null)
- {
- this.menus.findWindow.window.setVisible(false);
- this.menus.findWindow.window.destroy();
- this.menus.findWindow = null;
- }
- if (this.menus.findReplaceWindow != null)
- {
- this.menus.findReplaceWindow.window.setVisible(false);
- this.menus.findReplaceWindow.window.destroy();
- this.menus.findReplaceWindow = null;
- }
- editorUiDestroy.apply(this, arguments);
- };
-
- // Hides windows when a file is closed
- var editorUiSetGraphEnabled = EditorUi.prototype.setGraphEnabled;
-
- EditorUi.prototype.setGraphEnabled = function(enabled)
- {
- editorUiSetGraphEnabled.apply(this, arguments);
-
- if (!enabled)
- {
- if (this.sidebarWindow != null)
- {
- this.sidebarWindow.window.setVisible(false);
- }
- if (this.formatWindow != null)
- {
- this.formatWindow.window.setVisible(false);
- }
- }
- else
- {
- var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
- if (iw >= 1000 && this.sidebarWindow != null && urlParams['sketch'] != '1')
- {
- this.sidebarWindow.window.setVisible(true);
- }
-
- if (this.formatWindow != null && (iw >= 1000 || urlParams['sketch'] == '1'))
- {
- this.formatWindow.window.setVisible(true);
- }
- }
- };
-
- // Disables centering of graph after iframe resize
- EditorUi.prototype.chromelessWindowResize = function() {};
-
- // Adds actions and menus
- var menusInit = Menus.prototype.init;
- Menus.prototype.init = function()
- {
- menusInit.apply(this, arguments);
-
- var ui = this.editorUi;
- var graph = ui.editor.graph;
- ui.actions.get('editDiagram').label = mxResources.get('formatXml') + '...';
- ui.actions.get('createShape').label = mxResources.get('shape') + '...';
- ui.actions.get('outline').label = mxResources.get('outline') + '...';
- ui.actions.get('layers').label = mxResources.get('layers') + '...';
- ui.actions.get('tags').label = mxResources.get('tags') + '...';
- ui.actions.get('forkme').visible = urlParams['sketch'] != '1';
- ui.actions.get('downloadDesktop').visible = urlParams['sketch'] != '1';
- var toggleDarkModeAction = ui.actions.put('toggleDarkMode', new Action(mxResources.get('dark'), function(e)
- {
- ui.setDarkMode(!Editor.darkMode);
- }));
- toggleDarkModeAction.setToggleAction(true);
- toggleDarkModeAction.setSelectedCallback(function() { return Editor.isDarkMode(); });
-
- var toggleSketchModeAction = ui.actions.put('toggleSketchMode', new Action(mxResources.get('sketch'), function(e)
- {
- ui.setSketchMode(!Editor.sketchMode);
- }));
- toggleSketchModeAction.setToggleAction(true);
- toggleSketchModeAction.setSelectedCallback(function() { return Editor.sketchMode; });
-
- var togglePagesAction = ui.actions.put('togglePagesVisible', new Action(mxResources.get('pages'), function(e)
- {
- ui.setPagesVisible(!Editor.pagesVisible);
- }));
- togglePagesAction.setToggleAction(true);
- togglePagesAction.setSelectedCallback(function() { return Editor.pagesVisible; });
-
- ui.actions.put('importCsv', new Action(mxResources.get('csv') + '...', function()
- {
- graph.popupMenuHandler.hideMenu();
- ui.showImportCsvDialog();
- }));
- ui.actions.put('importText', new Action(mxResources.get('text') + '...', function()
- {
- var dlg = new ParseDialog(ui, 'Insert from Text');
- ui.showDialog(dlg.container, 620, 420, true, false);
- dlg.init();
- }));
- ui.actions.put('formatSql', new Action(mxResources.get('formatSql') + '...', function()
- {
- var dlg = new ParseDialog(ui, 'Insert from Text', 'formatSql');
- ui.showDialog(dlg.container, 620, 420, true, false);
- dlg.init();
- }));
- ui.actions.put('toggleShapes', new Action(mxResources.get((urlParams['sketch'] == '1') ?
- 'moreShapes' : 'shapes') + '...', function()
- {
- toggleShapes(ui);
- }, null, null, Editor.ctrlKey + '+Shift+K'));
- var action = ui.actions.put('toggleFormat', new Action(mxResources.get('format') + '...', function()
- {
- toggleFormat(ui);
- }));
- action.shortcut = ui.actions.get('formatPanel').shortcut;
- if (EditorUi.enablePlantUml && !ui.isOffline())
- {
- ui.actions.put('plantUml', new Action(mxResources.get('plantUml') + '...', function()
- {
- var dlg = new ParseDialog(ui, mxResources.get('plantUml') + '...', 'plantUml');
- ui.showDialog(dlg.container, 620, 420, true, false);
- dlg.init();
- }));
- }
-
- ui.actions.put('mermaid', new Action(mxResources.get('mermaid') + '...', function()
- {
- var dlg = new ParseDialog(ui, mxResources.get('mermaid') + '...', 'mermaid');
- ui.showDialog(dlg.container, 620, 420, true, false);
- dlg.init();
- }));
- // Adds submenu for edit items
- var addPopupMenuCellEditItems = this.addPopupMenuCellEditItems;
- this.put('editCell', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- var graph = this.editorUi.editor.graph;
- var cell = graph.getSelectionCell();
- addPopupMenuCellEditItems.call(this, menu, cell, null, parent);
- this.addMenuItems(menu, ['editTooltip'], parent);
- if (graph.model.isVertex(cell))
- {
- this.addMenuItems(menu, ['editGeometry'], parent);
- }
- this.addMenuItems(menu, ['-', 'edit'], parent);
- })));
- this.addPopupMenuCellEditItems = function(menu, cell, evt, parent)
- {
- // LATER: Pass-through for evt from context menu to submenu item
- menu.addSeparator();
- this.addSubmenu('editCell', menu, parent, mxResources.get('edit'));
- };
- this.put('diagram', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- var file = ui.getCurrentFile();
- ui.menus.addSubmenu('extras', menu, parent, mxResources.get('preferences'));
- menu.addSeparator(parent);
-
- if (mxClient.IS_CHROMEAPP || EditorUi.isElectronApp)
- {
- ui.menus.addMenuItems(menu, ['new', 'open', '-', 'synchronize',
- '-', 'save', 'saveAs', '-'], parent);
- }
- else if (urlParams['embed'] == '1')
- {
- if (urlParams['noSaveBtn'] != '1' &&
- urlParams['embedInline'] != '1')
- {
- ui.menus.addMenuItems(menu, ['-', 'save'], parent);
- }
-
- if (urlParams['saveAndExit'] == '1' ||
- (urlParams['noSaveBtn'] == '1' &&
- urlParams['saveAndExit'] != '0'))
- {
- ui.menus.addMenuItems(menu, ['saveAndExit'], parent);
- }
-
- menu.addSeparator(parent);
- }
- else if (ui.mode == App.MODE_ATLAS)
- {
- ui.menus.addMenuItems(menu, ['save', 'synchronize', '-'], parent);
- }
- else if (urlParams['noFileMenu'] != '1')
- {
- ui.menus.addMenuItems(menu, ['new'], parent);
- ui.menus.addSubmenu('openFrom', menu, parent);
- if (isLocalStorage)
- {
- this.addSubmenu('openRecent', menu, parent);
- }
-
- if (urlParams['sketch'] != '1')
- {
- menu.addSeparator(parent);
-
- if (file != null && file.constructor == DriveFile)
- {
- ui.menus.addMenuItems(menu, ['share'], parent);
- }
-
- if (!mxClient.IS_CHROMEAPP && !EditorUi.isElectronApp &&
- file != null && file.constructor != LocalFile)
- {
- ui.menus.addMenuItems(menu, ['synchronize'], parent);
- }
- }
-
- menu.addSeparator(parent);
- ui.menus.addSubmenu('save', menu, parent);
- }
-
- ui.menus.addSubmenu('exportAs', menu, parent);
-
- if (mxClient.IS_CHROMEAPP || EditorUi.isElectronApp)
- {
- ui.menus.addMenuItems(menu, ['import'], parent);
- }
- else if (urlParams['noFileMenu'] != '1')
- {
- ui.menus.addSubmenu('importFrom', menu, parent);
- }
- if (urlParams['sketch'] != '1')
- {
- ui.menus.addMenuItems(menu, ['-', 'outline'], parent);
-
- if (ui.commentsSupported())
- {
- ui.menus.addMenuItems(menu, ['comments'], parent);
- }
- }
-
- ui.menus.addMenuItems(menu, ['-', 'findReplace', 'layers', 'tags'], parent);
- ui.menus.addMenuItems(menu, ['-', 'pageSetup', 'pageScale'], parent);
- // Cannot use print in standalone mode on iOS as we cannot open new windows
- if (urlParams['noFileMenu'] != '1' && (!mxClient.IS_IOS || !navigator.standalone))
- {
- ui.menus.addMenuItems(menu, ['print'], parent);
- }
- if (file != null && ui.fileNode != null && urlParams['embedInline'] != '1')
- {
- var filename = (file.getTitle() != null) ?
- file.getTitle() : ui.defaultFilename;
-
- if (!/(\.html)$/i.test(filename) &&
- !/(\.svg)$/i.test(filename))
- {
- this.addMenuItems(menu, ['-', 'properties']);
- }
- }
- menu.addSeparator(parent);
- ui.menus.addSubmenu('help', menu, parent);
- if (urlParams['embed'] == '1')
- {
- if (urlParams['noExitBtn'] != '1')
- {
- ui.menus.addMenuItems(menu, ['-', 'exit'], parent);
- }
- }
- else if (urlParams['noFileMenu'] != '1')
- {
- ui.menus.addMenuItems(menu, ['-', 'close']);
- }
- })));
- this.put('save', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- var file = ui.getCurrentFile();
-
- if (file != null && file.constructor == DriveFile)
- {
- ui.menus.addMenuItems(menu, ['save', 'makeCopy', '-', 'rename', 'moveToFolder'], parent);
- }
- else
- {
- ui.menus.addMenuItems(menu, ['save', 'saveAs', '-', 'rename'], parent);
-
- if (ui.isOfflineApp())
- {
- if (navigator.onLine && urlParams['stealth'] != '1' && urlParams['lockdown'] != '1')
- {
- this.addMenuItems(menu, ['upload'], parent);
- }
- }
- else
- {
- ui.menus.addMenuItems(menu, ['makeCopy'], parent);
- }
- }
-
- if (urlParams['sketch'] == '1' && !mxClient.IS_CHROMEAPP &&
- !EditorUi.isElectronApp && file != null &&
- file.constructor != LocalFile)
- {
- ui.menus.addMenuItems(menu, ['-', 'synchronize'], parent);
- }
-
- ui.menus.addMenuItems(menu, ['-', 'autosave'], parent);
- if (file != null && file.isRevisionHistorySupported())
- {
- ui.menus.addMenuItems(menu, ['-', 'revisionHistory'], parent);
- }
- })));
-
- // Augments the existing export menu
- var exportAsMenu = this.get('exportAs');
-
- this.put('exportAs', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- exportAsMenu.funct(menu, parent);
- if (!mxClient.IS_CHROMEAPP && !EditorUi.isElectronApp)
- {
- // Publish menu contains only one element by default...
- //ui.menus.addSubmenu('publish', menu, parent);
- ui.menus.addMenuItems(menu, ['publishLink'], parent);
- }
-
- if (ui.mode != App.MODE_ATLAS && urlParams['extAuth'] != '1')
- {
- menu.addSeparator(parent);
- ui.menus.addSubmenu('embed', menu, parent);
- }
- })));
- var langMenu = this.get('language');
-
- this.put('table', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- ui.menus.addInsertTableCellItem(menu, parent);
- })));
-
- // Adds XML option to import menu
- var importMenu = this.get('importFrom');
-
- this.put('importFrom', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- importMenu.funct(menu, parent);
-
- this.addMenuItems(menu, ['editDiagram'], parent);
-
- if (urlParams['sketch'] == '1')
- {
- menu.addSeparator(parent);
-
- menu.addItem(mxResources.get('csv') + '...', null, function()
- {
- ui.showImportCsvDialog();
- }, parent, null, mxUtils.bind(graph, graph.isEnabled));
-
- ui.addInsertMenuItems(menu, parent, ['formatSql', '-',
- 'fromText', 'plantUml', 'mermaid']);
- }
- })));
-
- // Extras menu is labelled preferences but keeps ID for extensions
- this.put('extras', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- if (urlParams['embed'] != '1' && urlParams['extAuth'] != '1')
- {
- ui.menus.addSubmenu('theme', menu, parent);
- }
-
- if (langMenu != null)
- {
- ui.menus.addSubmenu('language', menu, parent);
- }
-
- ui.menus.addSubmenu('units', menu, parent);
- menu.addSeparator(parent);
- ui.menus.addMenuItems(menu, ['scrollbars', 'tooltips', 'ruler', '-', 'copyConnect', 'collapseExpand', '-'], parent);
- if (urlParams['sketch'] == '1')
- {
- this.addMenuItems(menu, ['toggleSketchMode'], parent);
- }
- if (urlParams['embedInline'] != '1')
- {
- if (Editor.isDarkMode() || (!mxClient.IS_IE && !mxClient.IS_IE11))
- {
- this.addMenuItems(menu, ['toggleDarkMode'], parent);
- }
- if (urlParams['embed'] != '1' && (isLocalStorage || mxClient.IS_CHROMEAPP))
- {
- ui.menus.addMenuItems(menu, ['-', 'showStartScreen', 'search', 'scratchpad'], parent);
- }
- if (urlParams['sketch'] == '1' && urlParams['pages'] == null)
- {
- this.addMenuItems(menu, ['togglePagesVisible'], parent);
- }
- }
- menu.addSeparator(parent);
- ui.menus.addMenuItem(menu, 'configuration', parent);
- if (!ui.isOfflineApp() && isLocalStorage)
- {
- ui.menus.addMenuItem(menu, 'plugins', parent);
- }
- this.addMenuItems(menu, ['-', 'fullscreen'], parent);
- // Adds trailing separator in case new plugin entries are added
- menu.addSeparator(parent);
- })));
-
- this.put('insertAdvanced', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- ui.menus.addMenuItems(menu, ['importText', 'plantUml', 'mermaid', '-', 'formatSql', 'importCsv', '-', 'createShape', 'editDiagram'], parent);
- })));
-
- (mxUtils.bind(this, function()
- {
- var insertMenu = this.get('insert');
- var insertMenuFunct = insertMenu.funct;
-
- insertMenu.funct = function(menu, parent)
- {
- if (urlParams['sketch'] == '1')
- {
- ui.menus.addMenuItems(menu, ['insertFreehand'], parent);
-
- if (ui.insertTemplateEnabled && !ui.isOffline())
- {
- ui.menus.addMenuItems(menu, ['insertTemplate'], parent);
- }
- }
- else
- {
- insertMenuFunct.apply(this, arguments);
- ui.menus.addSubmenu('table', menu, parent);
- menu.addSeparator(parent);
- }
-
- ui.menus.addMenuItems(menu, ['-', 'toggleShapes'], parent);
- };
- }))();
-
- var methods = ['horizontalFlow', 'verticalFlow', '-', 'horizontalTree', 'verticalTree',
- 'radialTree', '-', 'organic', 'circle'];
- var addInsertItem = function(menu, parent, title, method)
- {
- menu.addItem(title, null, mxUtils.bind(this, function()
- {
- var dlg = new CreateGraphDialog(ui, title, method);
- ui.showDialog(dlg.container, 620, 420, true, false);
- // Executed after dialog is added to dom
- dlg.init();
- }), parent);
- };
- this.put('insertLayout', new Menu(mxUtils.bind(this, function(menu, parent)
- {
- for (var i = 0; i < methods.length; i++)
- {
- if (methods[i] == '-')
- {
- menu.addSeparator(parent);
- }
- else
- {
- addInsertItem(menu, parent, mxResources.get(methods[i]) + '...', methods[i]);
- }
- }
- })));
- };
-
- // Installs the format toolbar
- EditorUi.prototype.installFormatToolbar = function(container)
- {
- var graph = this.editor.graph;
- var div = document.createElement('div');
-
- div.style.cssText = 'position:absolute;top:10px;z-index:1;border-radius:4px;' +
- 'box-shadow:0px 0px 3px 1px #d1d1d1;padding:6px;white-space:nowrap;background-color:#fff;' +
- 'transform:translate(-50%, 0);left:50%;';
-
- graph.getSelectionModel().addListener(mxEvent.CHANGE, mxUtils.bind(this, function(sender, evt)
- {
- if (graph.getSelectionCount() > 0)
- {
- container.appendChild(div);
- div.innerHTML = 'Selected: ' + graph.getSelectionCount();
- }
- else if (div.parentNode != null)
- {
- div.parentNode.removeChild(div);
- }
- }));
- };
- var formatWindowInitialized = false;
- EditorUi.prototype.initFormatWindow = function()
- {
- if (!formatWindowInitialized)
- {
- formatWindowInitialized = true;
- this.formatWindow.window.setClosable(false);
- var toggleMinimized = this.formatWindow.window.toggleMinimized;
-
- this.formatWindow.window.toggleMinimized = function()
- {
- toggleMinimized.apply(this, arguments);
-
- if (this.minimized)
- {
- this.div.style.width = '90px';
- this.table.style.width = '90px';
- this.div.style.left = parseInt(this.div.style.left) + 150 + 'px';
- }
- else
- {
-
- this.div.style.width = '240px';
- this.table.style.width = '240px';
- this.div.style.left = Math.max(0, parseInt(this.div.style.left) - 150) + 'px';
- }
-
- this.fit();
- };
-
- mxEvent.addListener(this.formatWindow.window.title, 'dblclick', mxUtils.bind(this, function(evt)
- {
- if (mxEvent.getSource(evt) == this.formatWindow.window.title)
- {
- this.formatWindow.window.toggleMinimized();
- }
- }));
- }
- };
-
- // Initializes the user interface
- var editorUiInit = EditorUi.prototype.init;
- EditorUi.prototype.init = function()
- {
- editorUiInit.apply(this, arguments);
- if (urlParams['embedInline'] != '1')
- {
- this.doSetDarkMode((urlParams['dark'] != null) ?
- urlParams['dark'] == 1 && !mxClient.IS_IE &&
- !mxClient.IS_IE11 : ((mxSettings.settings.darkMode != null) ?
- mxSettings.settings.darkMode : (window.matchMedia &&
- window.matchMedia('(prefers-color-scheme: dark)').matches)));
- }
- var div = document.createElement('div');
- div.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;overflow-y:auto;overflow-x:hidden;';
- div.style.bottom = (urlParams['embed'] != '1' || urlParams['libraries'] == '1') ? '63px' : '32px';
- this.sidebar = this.createSidebar(div);
-
- if (urlParams['sketch'] == '1')
- {
- this.toggleScratchpad();
- }
- if ((urlParams['sketch'] != '1' && iw >= 1000) || urlParams['clibs'] != null ||
- urlParams['libs'] != null || urlParams['search-shapes'] != null)
- {
- toggleShapes(this, true);
-
- if (this.sidebar != null && urlParams['search-shapes'] != null && this.sidebar.searchShapes != null)
- {
- this.sidebar.searchShapes(urlParams['search-shapes']);
- this.sidebar.showEntries('search');
- }
- }
- // Overrides mxWindow.fit to allow for embedViewport
- var ui = this;
- mxWindow.prototype.fit = function()
- {
- if (!Editor.inlineFullscreen && ui.embedViewport != null)
- {
- var left = parseInt(this.div.offsetLeft);
- var width = parseInt(this.div.offsetWidth);
- var right = ui.embedViewport.x + ui.embedViewport.width;
- this.div.style.left = Math.max(ui.embedViewport.x, Math.min(left, right - width)) + 'px';
-
- var top = parseInt(this.div.offsetTop);
- var height = parseInt(this.div.offsetHeight);
- var bottom = ui.embedViewport.y + ui.embedViewport.height;
-
- this.div.style.top = Math.max(ui.embedViewport.y, Math.min(top, bottom - height)) + 'px';
- }
- else
- {
- mxUtils.fit(this.div);
- }
- };
- // Overrides insert ellipse shortcut
- this.keyHandler.bindAction(75, true, 'toggleShapes', true); // Ctrl+Shift+K
- if (urlParams['sketch'] == '1' || iw >= 1000)
- {
- if (urlParams['embedInline'] != '1')
- {
- toggleFormat(this, true);
- if (urlParams['sketch'] == '1')
- {
- this.initFormatWindow();
- this.formatWindow.window.toggleMinimized();
- }
- }
- }
-
- // Needed for creating elements in Format panel
- var ui = this;
- var graph = ui.editor.graph;
- ui.toolbar = this.createToolbar(ui.createDiv('geToolbar'));
- ui.defaultLibraryName = mxResources.get('untitledLibrary');
- var menubar = document.createElement('div');
- menubar.className = 'geMenubarContainer';
- var before = null;
- var menuObj = new Menubar(ui, menubar);
- function addMenu(id, small, img)
- {
- var menu = ui.menus.get(id);
- var elt = menuObj.addMenu(mxResources.get(id), mxUtils.bind(this, function()
- {
- // Allows extensions of menu.functid
- menu.funct.apply(this, arguments);
- }), before);
-
- elt.className = (urlParams['sketch'] == '1') ? 'geToolbarButton' : 'geMenuItem';
- elt.style.display = 'inline-block';
- elt.style.boxSizing = 'border-box';
- elt.style.top = '6px';
- elt.style.marginRight = '6px';
- elt.style.height = '30px';
- elt.style.paddingTop = '6px';
- elt.style.paddingBottom = '6px';
- elt.style.cursor = 'pointer';
- elt.setAttribute('title', mxResources.get(id));
- ui.menus.menuCreated(menu, elt, 'geMenuItem');
-
- if (img != null)
- {
- elt.style.backgroundImage = 'url(' + img + ')';
- elt.style.backgroundPosition = 'center center';
- elt.style.backgroundRepeat = 'no-repeat';
- elt.style.backgroundSize = '24px 24px';
- elt.style.width = '34px';
- elt.innerHTML = '';
- }
- else if (!small)
- {
- elt.style.backgroundImage = 'url(' + mxWindow.prototype.normalizeImage + ')';
- elt.style.backgroundPosition = 'right 6px center';
- elt.style.backgroundRepeat = 'no-repeat';
- elt.style.paddingRight = '22px';
- }
- return elt;
- };
-
- function addMenuItem(label, fn, small, tooltip, action, img)
- {
- var btn = document.createElement('a');
- btn.className = (urlParams['sketch'] == '1') ? 'geToolbarButton' : 'geMenuItem';
- btn.style.display = 'inline-block';
- btn.style.boxSizing = 'border-box';
- btn.style.height = '30px';
- btn.style.padding = '6px';
- btn.style.position = 'relative';
- btn.style.verticalAlign = 'top';
- btn.style.top = '0px';
-
- if (urlParams['sketch'] == '1')
- {
- btn.style.borderStyle = 'none';
- btn.style.boxShadow = 'none';
- btn.style.padding = '6px';
- btn.style.margin = '0px';
- }
- if (ui.statusContainer != null)
- {
- menubar.insertBefore(btn, ui.statusContainer);
- }
- else
- {
- menubar.appendChild(btn);
- }
-
- if (img != null)
- {
- btn.style.backgroundImage = 'url(' + img + ')';
- btn.style.backgroundPosition = 'center center';
- btn.style.backgroundRepeat = 'no-repeat';
- btn.style.backgroundSize = '24px 24px';
- btn.style.width = '34px';
- }
- else
- {
- mxUtils.write(btn, label);
- }
-
- // Prevents focus
- mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown',
- mxUtils.bind(this, function(evt)
- {
- evt.preventDefault();
- }));
- mxEvent.addListener(btn, 'click', function(evt)
- {
- if (btn.getAttribute('disabled') != 'disabled')
- {
- fn(evt);
- }
-
- mxEvent.consume(evt);
- });
-
- if (small == null)
- {
- btn.style.marginRight = '4px';
- }
-
- if (tooltip != null)
- {
- btn.setAttribute('title', tooltip);
- }
- if (action != null)
- {
- function updateState()
- {
- if (action.isEnabled())
- {
- btn.removeAttribute('disabled');
- btn.style.cursor = 'pointer';
- }
- else
- {
- btn.setAttribute('disabled', 'disabled');
- btn.style.cursor = 'default';
- }
- };
-
- action.addListener('stateChanged', updateState);
- graph.addListener('enabledChanged', updateState);
- updateState();
- }
-
- return btn;
- };
-
- function createGroup(btns, op, container)
- {
- var btnGroup = document.createElement('div');
- btnGroup.className = 'geMenuItem';
- btnGroup.style.display = 'inline-block';
- btnGroup.style.verticalAlign = 'top';
- btnGroup.style.marginRight = '6px';
- btnGroup.style.padding = '0 4px 0 4px';
- btnGroup.style.height = '30px';
- btnGroup.style.position = 'relative';
- btnGroup.style.top = '0px';
- if (urlParams['sketch'] == '1')
- {
- btnGroup.style.boxShadow = 'none';
- }
-
- for (var i = 0; i < btns.length; i++)
- {
- if (btns[i] != null)
- {
- if (urlParams['sketch'] == '1')
- {
- btns[i].style.padding = '10px 8px';
- btns[i].style.width = '30px';
- }
-
- btns[i].style.margin = '0px';
- btns[i].style.boxShadow = 'none';
- btnGroup.appendChild(btns[i]);
- }
- }
-
- if (op != null)
- {
- mxUtils.setOpacity(btnGroup, op);
- }
- if (ui.statusContainer != null && urlParams['sketch'] != '1')
- {
- menubar.insertBefore(btnGroup, ui.statusContainer);
- }
- else
- {
- menubar.appendChild(btnGroup);
- }
-
- return btnGroup;
- };
- ui.statusContainer = ui.createStatusContainer();
- ui.statusContainer.style.position = 'relative';
- ui.statusContainer.style.maxWidth = '';
- ui.statusContainer.style.marginTop = '7px';
- ui.statusContainer.style.marginLeft = '6px';
- ui.statusContainer.style.color = 'gray';
- ui.statusContainer.style.cursor = 'default';
-
- function updateTitle()
- {
- var file = ui.getCurrentFile();
-
- if (file != null && file.getTitle() != null)
- {
- var mode = file.getMode();
-
- if (mode == 'google')
- {
- mode = 'googleDrive';
- }
- else if (mode == 'github')
- {
- mode = 'gitHub';
- }
- else if (mode == 'gitlab')
- {
- mode = 'gitLab';
- }
- else if (mode == 'onedrive')
- {
- mode = 'oneDrive';
- }
-
- mode = mxResources.get(mode);
- menubar.setAttribute('title', file.getTitle() + ((mode != null) ? ' (' + mode + ')' : ''));
- }
- else
- {
- menubar.removeAttribute('title');
- }
- };
-
- // Hides popup menus
- var uiHideCurrentMenu = ui.hideCurrentMenu;
-
- ui.hideCurrentMenu = function()
- {
- uiHideCurrentMenu.apply(this, arguments);
- this.editor.graph.popupMenuHandler.hideMenu();
- };
- // Connects the status bar to the editor status
- var uiDescriptorChanged = ui.descriptorChanged;
-
- ui.descriptorChanged = function()
- {
- uiDescriptorChanged.apply(this, arguments);
- updateTitle();
- };
-
- ui.setStatusText(ui.editor.getStatus());
- menubar.appendChild(ui.statusContainer);
- ui.buttonContainer = document.createElement('div');
- ui.buttonContainer.style.cssText = 'position:absolute;right:0px;padding-right:34px;top:10px;' +
- 'white-space:nowrap;padding-top:2px;background-color:inherit;';
- menubar.appendChild(ui.buttonContainer);
-
- // Container for the user element
- ui.menubarContainer = ui.buttonContainer;
- ui.tabContainer = document.createElement('div');
- ui.tabContainer.className = 'geTabContainer';
- ui.tabContainer.style.cssText = 'position:absolute;left:0px;right:0px;bottom:0px;height:30px;white-space:nowrap;' +
- 'margin-bottom:-2px;visibility:hidden;';
- var previousParent = ui.diagramContainer.parentNode;
- var wrapper = document.createElement('div');
- wrapper.style.cssText = 'position:absolute;top:0px;left:0px;right:0px;bottom:0px;overflow:hidden;';
- ui.diagramContainer.style.top = (urlParams['sketch'] == '1') ? '0px' : '47px';
- //Create draggable titlebar
- if (EditorUi.isElectronApp && urlParams['sketch'] == '1')
- {
- wrapper.style.top = '20px';
- ui.titlebar = document.createElement('div');
- ui.titlebar.style.cssText = 'position:absolute;top:0px;left:0px;right:0px;height:20px;overflow:hidden;box-shadow: 0px 0px 2px #c0c0c0;';
- var title = document.createElement('div');
- title.style.cssText = 'max-width: calc(100% - 100px);text-overflow: ellipsis;user-select:none;height:20px;margin: 2px 10px;font-size: 12px;white-space: nowrap;overflow: hidden;';
- ui.titlebar.appendChild(title);
- previousParent.appendChild(ui.titlebar);
- }
-
- var viewZoomMenu = ui.menus.get('viewZoom');
- var insertImage = (urlParams['sketch'] != '1') ? Editor.plusImage : Editor.shapesImage;
- var footer = (urlParams['sketch'] == '1') ? document.createElement('div') : null;
- var picker = (urlParams['sketch'] == '1') ? document.createElement('div') : null;
- var toolbar = (urlParams['sketch'] == '1') ? document.createElement('div') : null;
- var refreshSidebar = mxUtils.bind(this, function()
- {
- if (this.sidebar != null)
- {
- this.sidebar.graph.stylesheet.styles =
- mxUtils.clone(graph.stylesheet.styles);
- this.sidebar.container.innerHTML = '';
- this.sidebar.palettes = new Object();
- this.sidebar.init();
-
- if (urlParams['sketch'] == '1')
- {
- this.scratchpad = null;
- this.toggleScratchpad();
- }
- }
- graph.refresh();
- graph.view.validateBackground();
- });
-
- ui.addListener('darkModeChanged', refreshSidebar);
- ui.addListener('sketchModeChanged', refreshSidebar);
- var inlineSizeChanged = mxUtils.bind(this, function()
- {
- if (Editor.inlineFullscreen)
- {
- toolbar.style.left = '10px';
- toolbar.style.top = '10px';
-
- picker.style.left = '10px';
- picker.style.top = '60px';
- footer.style.top = '10px';
- footer.style.right = '12px';
- footer.style.left = '';
- ui.diagramContainer.setAttribute('data-bounds', ui.diagramContainer.style.top + ' ' +
- ui.diagramContainer.style.left + ' ' + ui.diagramContainer.style.width + ' ' +
- ui.diagramContainer.style.height);
- ui.diagramContainer.style.top = '0px';
- ui.diagramContainer.style.left = '0px';
- ui.diagramContainer.style.bottom = '0px';
- ui.diagramContainer.style.right = '0px';
- ui.diagramContainer.style.width = '';
- ui.diagramContainer.style.height = '';
- }
- else
- {
- var bounds = ui.diagramContainer.getAttribute('data-bounds');
- if (bounds != null)
- {
- ui.diagramContainer.style.background = 'transparent';
- ui.diagramContainer.removeAttribute('data-bounds');
- var gb = graph.getGraphBounds();
- var tokens = bounds.split(' ');
- ui.diagramContainer.style.top = tokens[0];
- ui.diagramContainer.style.left = tokens[1];
- ui.diagramContainer.style.width = (gb.width + 50) + 'px';
- ui.diagramContainer.style.height = (gb.height + 46) + 'px';
- ui.diagramContainer.style.bottom = '';
- ui.diagramContainer.style.right = '';
- var parent = window.opener || window.parent;
- parent.postMessage(JSON.stringify({
- event: 'resize',
- rect: ui.diagramContainer.getBoundingClientRect()
- }), '*');
- ui.refresh();
- }
- toolbar.style.left = ui.diagramContainer.offsetLeft + 'px';
- toolbar.style.top = (ui.diagramContainer.offsetTop -
- toolbar.offsetHeight - 4) + 'px';
-
- picker.style.display = '';
- picker.style.left = (ui.diagramContainer.offsetLeft -
- picker.offsetWidth - 4) + 'px';
- picker.style.top = ui.diagramContainer.offsetTop + 'px';
- footer.style.left = (ui.diagramContainer.offsetLeft +
- ui.diagramContainer.offsetWidth -
- footer.offsetWidth) + 'px';
- footer.style.top = toolbar.style.top;
- footer.style.right = '';
- ui.bottomResizer.style.left = (ui.diagramContainer.offsetLeft +
- (ui.diagramContainer.offsetWidth -
- ui.bottomResizer.offsetWidth) / 2) + 'px';
- ui.bottomResizer.style.top = (ui.diagramContainer.offsetTop +
- ui.diagramContainer.offsetHeight -
- ui.bottomResizer.offsetHeight / 2 - 1) + 'px';
- ui.rightResizer.style.left = (ui.diagramContainer.offsetLeft +
- ui.diagramContainer.offsetWidth -
- ui.rightResizer.offsetWidth / 2 - 1) + 'px';
- ui.rightResizer.style.top = (ui.diagramContainer.offsetTop +
- (ui.diagramContainer.offsetHeight -
- ui.bottomResizer.offsetHeight) / 2) + 'px';
- }
- ui.bottomResizer.style.visibility = (Editor.inlineFullscreen) ? 'hidden' : '';
- ui.rightResizer.style.visibility = ui.bottomResizer.style.visibility;
- menubar.style.display = 'none';
- toolbar.style.visibility = '';
- footer.style.visibility = '';
- });
- var inlineFullscreenChanged = mxUtils.bind(this, function()
- {
- fullscreenElt.style.backgroundImage = 'url(' + ((!Editor.inlineFullscreen) ?
- Editor.fullscreenImage : Editor.fullscreenExitImage) + ')';
- this.diagramContainer.style.background = (Editor.inlineFullscreen) ?
- (Editor.isDarkMode() ? Editor.darkColor : '#ffffff') : 'transparent';
- inlineSizeChanged();
- });
- var editInlineStart = mxUtils.bind(this, function()
- {
- inlineFullscreenChanged();
- toggleFormat(ui, true);
- ui.initFormatWindow();
- var r = this.diagramContainer.getBoundingClientRect();
- this.formatWindow.window.setLocation(r.x + r.width + 4, r.y);
- });
- ui.addListener('inlineFullscreenChanged', inlineFullscreenChanged);
- ui.addListener('editInlineStart', editInlineStart);
- if (urlParams['embedInline'] == '1')
- {
- ui.addListener('darkModeChanged', editInlineStart);
- }
- ui.addListener('editInlineStop', mxUtils.bind(this, function(evt)
- {
- ui.diagramContainer.style.width = '10px';
- ui.diagramContainer.style.height = '10px';
- ui.diagramContainer.style.border = '';
- ui.bottomResizer.style.visibility = 'hidden';
- ui.rightResizer.style.visibility = 'hidden';
- toolbar.style.visibility = 'hidden';
- footer.style.visibility = 'hidden';
- picker.style.display = 'none';
- }));
- // Stops panning while freehand is active
- if (Graph.touchStyle)
- {
- graph.panningHandler.isPanningTrigger = function(me)
- {
- var evt = me.getEvent();
-
- return (me.getState() == null && (!mxEvent.isMouseEvent(evt) &&
- !graph.freehand.isDrawing())) ||
- (mxEvent.isPopupTrigger(evt) && (me.getState() == null ||
- mxEvent.isControlDown(evt) || mxEvent.isShiftDown(evt)));
- };
- }
- // Hides hover icons if freehand is active
- if (ui.hoverIcons != null)
- {
- var hoverIconsUpdate = ui.hoverIcons.update;
-
- ui.hoverIcons.update = function()
- {
- if (!graph.freehand.isDrawing())
- {
- hoverIconsUpdate.apply(this, arguments);
- }
- };
- }
-
- // Removes sketch style from freehand shapes
- if (graph.freehand != null)
- {
- var freehandCreateStyle = graph.freehand.createStyle;
-
- graph.freehand.createStyle = function(stencil)
- {
- return freehandCreateStyle.apply(this, arguments) + 'sketch=0;';
- };
- }
-
- if (urlParams['sketch'] == '1')
- {
- picker.className = 'geToolbarContainer';
- footer.className = 'geToolbarContainer';
- toolbar.className = 'geToolbarContainer';
- menubar.className = 'geToolbarContainer';
-
- ui.picker = picker;
- var statusVisible = false;
- mxEvent.addListener(menubar, 'mouseenter', function()
- {
- ui.statusContainer.style.display = 'inline-block';
- });
-
- mxEvent.addListener(menubar, 'mouseleave', function()
- {
- if (!statusVisible)
- {
- ui.statusContainer.style.display = 'none';
- }
- });
-
- var setNotificationTitle = mxUtils.bind(this, function(title)
- {
- if (ui.notificationBtn != null)
- {
- if (title != null)
- {
- ui.notificationBtn.setAttribute('title', title);
- }
- else
- {
- ui.notificationBtn.removeAttribute('title');
- }
- }
- });
-
- // Connects the status bar to the editor status and
- // moves status to bell icon tooltip for trivial messages
- if (urlParams['embed'] != '1')
- {
- menubar.style.visibility = (menubar.clientWidth < 14) ? 'hidden' : '';
- ui.editor.addListener('statusChanged', mxUtils.bind(this, function()
- {
- ui.setStatusText(ui.editor.getStatus());
-
- if (ui.statusContainer.children.length == 0 ||
- (ui.statusContainer.children.length == 1 &&
- typeof ui.statusContainer.firstChild.getAttribute === 'function' &&
- ui.statusContainer.firstChild.getAttribute('class') == null))
- {
- var title = (ui.statusContainer.firstChild != null &&
- typeof ui.statusContainer.firstChild.getAttribute === 'function') ?
- ui.statusContainer.firstChild.getAttribute('title') :
- ui.editor.getStatus();
- setNotificationTitle(title);
- var file = ui.getCurrentFile();
- var key = (file != null) ? file.savingStatusKey : DrawioFile.prototype.savingStatusKey;
-
- if (title == mxResources.get(key) + '...')
- {
- ui.statusContainer.innerHTML = '<img title="' + mxUtils.htmlEntities(
- mxResources.get(key)) + '...' + '"src="' + Editor.tailSpin + '">';
- ui.statusContainer.style.display = 'inline-block';
- statusVisible = true;
- }
- else if (ui.buttonContainer.clientWidth > 6)
- {
- ui.statusContainer.style.display = 'none';
- statusVisible = false;
- }
- }
- else
- {
- ui.statusContainer.style.display = 'inline-block';
- setNotificationTitle(null);
-
- statusVisible = true;
- }
- menubar.style.visibility = (menubar.clientWidth > 12) ? '' : 'hidden';
- }));
- }
- else
- {
- ui.editor.addListener('statusChanged', mxUtils.bind(this, function()
- {
- menubar.style.visibility = (menubar.clientWidth > 16) ? '' : 'hidden';
- }));
- }
-
- elt = addMenu('diagram', null, Editor.menuImage);
- elt.style.boxShadow = 'none';
- elt.style.padding = '6px';
- elt.style.margin = '0px';
- toolbar.appendChild(elt);
- mxEvent.disableContextMenu(elt);
- mxEvent.addGestureListeners(elt, mxUtils.bind(this, function(evt)
- {
- if (mxEvent.isShiftDown(evt) || mxEvent.isAltDown(evt) ||
- mxEvent.isMetaDown(evt) || mxEvent.isControlDown(evt) ||
- mxEvent.isPopupTrigger(evt))
- {
- this.appIconClicked(evt);
- }
- }), null, null);
- ui.statusContainer.style.position = '';
- ui.statusContainer.style.display = 'none';
- ui.statusContainer.style.margin = '0px';
- ui.statusContainer.style.padding = '6px 0px';
- ui.statusContainer.style.maxWidth = Math.min(iw - 240, 280) + 'px';
- ui.statusContainer.style.display = 'inline-block';
- ui.statusContainer.style.textOverflow = 'ellipsis';
-
- ui.buttonContainer.style.position = '';
- ui.buttonContainer.style.paddingRight = '0px';
- ui.buttonContainer.style.display = 'inline-block';
-
- var foldImg = document.createElement('a');
- foldImg.style.padding = '0px';
- foldImg.style.boxShadow = 'none';
- foldImg.className = 'geMenuItem';
- foldImg.style.display = 'inline-block';
- foldImg.style.width = '40px';
- foldImg.style.height = '12px';
- foldImg.style.marginBottom = '-2px';
- foldImg.style.backgroundImage = 'url(' + mxWindow.prototype.normalizeImage + ')';
- foldImg.style.backgroundPosition = 'top center';
- foldImg.style.backgroundRepeat = 'no-repeat';
- foldImg.setAttribute('title', 'Minimize'/*TODO:mxResources.get('minimize')*/);
-
- var collapsed = false;
- var initPicker = mxUtils.bind(this, function()
- {
- picker.innerHTML = '';
-
- if (!collapsed)
- {
- function addElt(elt, title, cursor)
- {
- if (title != null)
- {
- elt.setAttribute('title', title);
- }
-
- elt.style.cursor = (cursor != null) ? cursor : 'default';
- elt.style.margin = '2px 0px';
- picker.appendChild(elt);
- mxUtils.br(picker);
-
- return elt;
- };
- // Append sidebar elements
- addElt(ui.sidebar.createVertexTemplate('text;strokeColor=none;fillColor=none;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;',
- 60, 30, 'Text', mxResources.get('text'), true, false, null, true, true), mxResources.get('text') +
- ' (' + Editor.ctrlKey + '+Shift+X' + ')');
- addElt(ui.sidebar.createVertexTemplate('shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;' +
- 'fontColor=#000000;darkOpacity=0.05;fillColor=#FFF9B2;strokeColor=none;fillStyle=solid;' +
- 'direction=west;gradientDirection=north;gradientColor=#FFF2A1;shadow=1;size=20;pointerEvents=1;',
- 140, 160, '', mxResources.get('note'), true, false, null, true), mxResources.get('note'));
- addElt(ui.sidebar.createVertexTemplate('rounded=0;whiteSpace=wrap;html=1;', 160, 80,
- '', mxResources.get('rectangle'), true, false, null, true), mxResources.get('rectangle') +
- ' (' + Editor.ctrlKey + '+K' + ')');
- addElt(ui.sidebar.createVertexTemplate('ellipse;whiteSpace=wrap;html=1;', 160, 100,
- '', mxResources.get('ellipse'), true, false, null, true), mxResources.get('ellipse'));
-
- (function()
- {
- var edgeStyle = 'edgeStyle=none;orthogonalLoop=1;jettySize=auto;html=1;';
- var cell = new mxCell('', new mxGeometry(0, 0, graph.defaultEdgeLength, 0), edgeStyle);
- cell.geometry.setTerminalPoint(new mxPoint(0, 0), true);
- cell.geometry.setTerminalPoint(new mxPoint(cell.geometry.width, 0), false);
- cell.geometry.points = [];
- cell.geometry.relative = true;
- cell.edge = true;
-
- addElt(ui.sidebar.createEdgeTemplateFromCells([cell],
- cell.geometry.width, cell.geometry.height,
- mxResources.get('line'), true, null, true, false),
- mxResources.get('line'));
-
- cell = cell.clone();
- cell.style = edgeStyle + 'shape=flexArrow;rounded=1;startSize=8;endSize=8;';
- cell.geometry.width = graph.defaultEdgeLength + 20;
- cell.geometry.setTerminalPoint(new mxPoint(0, 20), true);
- cell.geometry.setTerminalPoint(new mxPoint(cell.geometry.width, 20), false);
-
- var elt = addElt(ui.sidebar.createEdgeTemplateFromCells([cell],
- cell.geometry.width, 40, mxResources.get('arrow'),
- true, null, true, false), mxResources.get('arrow'));
- elt.style.borderBottom = '1px solid ' + (Editor.isDarkMode() ? '#505050' : 'lightgray');
- elt.style.paddingBottom = '14px';
- elt.style.marginBottom = '14px';
- })();
-
- function addAction(action, label, image)
- {
- var elt = addMenuItem('', action.funct, null, label, action, image);
- elt.style.width = '40px';
- elt.style.opacity = '0.7';
-
- return addElt(elt, null, 'pointer');
- };
-
- addAction(ui.actions.get('insertFreehand'), mxResources.get('freehand'), Editor.freehandImage);
- var toggleShapesAction = ui.actions.get('toggleShapes');
- addAction(toggleShapesAction, mxResources.get('shapes') + ' (' + toggleShapesAction.shortcut + ')', insertImage);
- elt = addMenu('table', null, Editor.tableImage);
- elt.style.boxShadow = 'none';
- elt.style.opacity = '0.7';
- elt.style.padding = '6px';
- elt.style.margin = '0px';
- elt.style.width = '37px';
- addElt(elt, null, 'pointer');
- addAction(ui.actions.get('insertTemplate'), mxResources.get('template'), Editor.templateImage);
- }
- if (urlParams['embedInline'] != '1')
- {
- picker.appendChild(foldImg);
- }
- });
-
- mxEvent.addListener(foldImg, 'click', mxUtils.bind(this, function()
- {
- if (collapsed)
- {
- mxUtils.setPrefixedStyle(picker.style, 'transform', 'translate(0, -50%)');
- picker.style.padding = '8px 6px 4px';
- picker.style.top = '50%';
- picker.style.bottom = '';
- picker.style.height = '';
- foldImg.style.backgroundImage = 'url(' + mxWindow.prototype.normalizeImage + ')';
- foldImg.style.width = '40px';
- foldImg.style.height = '12px';
- foldImg.setAttribute('title', 'Minimize'/*TODO:mxResources.get('minimize')*/);
- collapsed = false;
- initPicker();
- }
- else
- {
- picker.innerHTML = '';
- picker.appendChild(foldImg);
- mxUtils.setPrefixedStyle(picker.style, 'transform', 'translate(0, 0)');
- picker.style.top = '';
- picker.style.bottom = '12px';
- picker.style.padding = '0px';
- picker.style.height = '24px';
- foldImg.style.height = '24px';
- foldImg.style.backgroundImage = 'url(' + Editor.plusImage + ')';
- foldImg.setAttribute('title', mxResources.get('insert'));
- foldImg.style.width = '24px';
- collapsed = true;
- }
- }));
-
- initPicker();
-
- ui.addListener('darkModeChanged', initPicker);
- ui.addListener('sketchModeChanged', initPicker);
- }
- else
- {
- // Connects the status bar to the editor status
- ui.editor.addListener('statusChanged', mxUtils.bind(this, function()
- {
- ui.setStatusText(ui.editor.getStatus());
- }));
- }
- if (viewZoomMenu != null)
- {
- var fitFunction = function(evt)
- {
- graph.popupMenuHandler.hideMenu();
- if (mxEvent.isAltDown(evt))
- {
- ui.actions.get('customZoom').funct();
- }
- else
- {
- ui.actions.get('smartFit').funct();
- }
- };
- var zoomInAction = ui.actions.get('zoomIn');
- var zoomOutAction = ui.actions.get('zoomOut');
- var resetViewAction = ui.actions.get('resetView');
- var fullscreenAction = ui.actions.get('fullscreen');
- var toggleDarkAction = ui.actions.get('toggleDarkMode');
- var undoAction = ui.actions.get('undo');
- var redoAction = ui.actions.get('redo');
- var undoElt = addMenuItem('', undoAction.funct, null, mxResources.get('undo') + ' (' + undoAction.shortcut + ')', undoAction, Editor.undoImage);
- var redoElt = addMenuItem('', redoAction.funct, null, mxResources.get('redo') + ' (' + redoAction.shortcut + ')', redoAction, Editor.redoImage);
- var fullscreenElt = addMenuItem('', fullscreenAction.funct, null, mxResources.get('fullscreen'), fullscreenAction, Editor.fullscreenImage);
- if (footer != null)
- {
- fullscreenElt.parentNode.removeChild(fullscreenElt);
- var deleteAction = ui.actions.get('delete');
- var deleteElt = addMenuItem('', deleteAction.funct, null, mxResources.get('delete'), deleteAction, Editor.trashImage);
- deleteElt.style.opacity = '0.1';
- toolbar.appendChild(deleteElt);
- deleteAction.addListener('stateChanged', function()
- {
- deleteElt.style.opacity = (deleteAction.enabled) ? '' : '0.1';
- });
-
- var undoListener = function()
- {
- undoElt.style.display = (ui.editor.undoManager.history.length > 0 ||
- graph.isEditing()) ? 'inline-block' : 'none';
- redoElt.style.display = undoElt.style.display;
-
- undoElt.style.opacity = (undoAction.enabled) ? '' : '0.1';
- redoElt.style.opacity = (redoAction.enabled) ? '' : '0.1';
- };
-
- toolbar.appendChild(undoElt);
- toolbar.appendChild(redoElt);
-
- undoAction.addListener('stateChanged', undoListener);
- redoAction.addListener('stateChanged', undoListener);
- undoListener();
- if (urlParams['layers'] != null)
- {
- var layersAction = ui.actions.get('layers');
- var layersElt = addMenuItem('', layersAction.funct, null, mxResources.get('layers'), layersAction, Editor.layersImage);
- layersElt.style.opacity = '0.4';
- footer.appendChild(layersElt);
- }
-
- if (urlParams['tags'] != null)
- {
- var tagsAction = ui.actions.get('tags');
- var tagsElt = addMenuItem('', tagsAction.funct, null, mxResources.get('tags'), tagsAction, Editor.tagsImage);
- tagsElt.style.opacity = '0.4';
- footer.appendChild(tagsElt);
- }
-
- var outlineAction = ui.actions.get('outline');
- var outlineElt = addMenuItem('', outlineAction.funct, null, mxResources.get('outline'), outlineAction, Editor.outlineImage);
- footer.appendChild(outlineElt);
-
- var zoomOutElt = addMenuItem('', zoomOutAction.funct, true, mxResources.get('zoomOut') +
- ' (' + Editor.ctrlKey + ' -/Alt+Mousewheel)', zoomOutAction, Editor.zoomOutImage);
- footer.appendChild(zoomOutElt);
- var elt = document.createElement('div');
- elt.innerHTML = '100%';
- elt.setAttribute('title', mxResources.get('fitWindow') + '/' + mxResources.get('resetView') + ' (Enter)');
- elt.style.display = 'inline-block';
- elt.style.cursor = 'pointer';
- elt.style.textAlign = 'center';
- elt.style.whiteSpace = 'nowrap';
- elt.style.paddingRight = '10px';
- elt.style.textDecoration = 'none';
- elt.style.verticalAlign = 'top';
- elt.style.padding = '6px 0';
- elt.style.fontSize = '14px';
- elt.style.width = '40px';
- elt.style.opacity = '0.4';
- footer.appendChild(elt);
-
- mxEvent.addListener(elt, 'click', fitFunction);
- var zoomInElt = addMenuItem('', zoomInAction.funct, true, mxResources.get('zoomIn') +
- ' (' + Editor.ctrlKey + ' +/Alt+Mousewheel)', zoomInAction, Editor.zoomInImage);
- footer.appendChild(zoomInElt);
- if (urlParams['embedInline'] == '1')
- {
- footer.appendChild(fullscreenElt);
- var exitAction = ui.actions.get('exit');
- footer.appendChild(addMenuItem('', exitAction.funct, null, mxResources.get('exit'), exitAction, Editor.closeImage));
- }
- var pageMenu = this.createPageMenuTab(false);
- pageMenu.style.display = 'none';
- pageMenu.style.position = '';
- pageMenu.style.marginLeft = '';
- pageMenu.style.top = '';
- pageMenu.style.left = '';
- pageMenu.style.height = '100%';
- pageMenu.style.lineHeight = '';
- pageMenu.style.borderStyle = 'none';
- pageMenu.style.padding = '3px 0';
- pageMenu.style.margin = '0px';
- pageMenu.style.background = '';
- pageMenu.style.border = '';
- pageMenu.style.boxShadow = 'none';
- pageMenu.style.verticalAlign = 'top';
- pageMenu.firstChild.style.height = '100%';
- pageMenu.firstChild.style.opacity = '0.6';
- pageMenu.firstChild.style.margin = '0px';
- footer.appendChild(pageMenu);
- function pagesVisibleChanged()
- {
- pageMenu.style.display = ui.pages != null &&
- (urlParams['pages'] == '1' || ui.pages.length > 1 ||
- Editor.pagesVisible) ? 'inline-block' : 'none';
- };
- // Page menu only visible for multiple pages
- ui.addListener('fileDescriptorChanged', pagesVisibleChanged);
- ui.addListener('pagesVisibleChanged', pagesVisibleChanged);
- pagesVisibleChanged();
-
- ui.tabContainer.style.visibility = 'hidden';
- menubar.style.cssText = 'position:absolute;right:12px;top:10px;height:30px;z-index:1;border-radius:4px;' +
- 'box-shadow:0px 0px 3px 1px #d1d1d1;padding:6px 0px 6px 6px;border-bottom:1px solid lightgray;' +
- 'text-align:right;white-space:nowrap;overflow:hidden;user-select:none;';
- toolbar.style.cssText = 'position:absolute;left:10px;top:10px;height:30px;z-index:1;border-radius:4px;' +
- 'box-shadow:0px 0px 3px 1px #d1d1d1;padding:6px;border-bottom:1px solid lightgray;' +
- 'text-align:right;white-space:nowrap;overflow:hidden;user-select:none;';
- footer.style.cssText = 'position:absolute;right:12px;bottom:12px;height:28px;z-index:1;border-radius:4px;' +
- 'box-shadow:0px 0px 3px 1px #d1d1d1;padding:8px;white-space:nowrap;user-select:none;';
- wrapper.appendChild(toolbar);
- wrapper.appendChild(footer);
-
- picker.style.cssText = 'position:absolute;left:10px;z-index:1;border-radius:4px;' +
- 'box-shadow:0px 0px 3px 1px #d1d1d1;padding:8px 6px 4px 6px;white-space:nowrap;' +
- 'transform:translate(0, -50%);top:50%;user-select:none;';
- wrapper.appendChild(picker);
-
- window.setTimeout(function()
- {
- mxUtils.setPrefixedStyle(picker.style, 'transition', 'transform .3s ease-out');
- }, 0);
-
- if (urlParams['format-toolbar'] == '1')
- {
- this.installFormatToolbar(wrapper);
- }
- }
- else
- {
- var fitElt = addMenuItem('', fitFunction, true, mxResources.get('fit') + ' (' + Editor.ctrlKey + '+H)', resetViewAction, Editor.zoomFitImage);
-
- menubar.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;height:30px;padding:8px;' +
- 'text-align:left;white-space:nowrap;';
- this.tabContainer.style.right = '70px';
- var elt = menuObj.addMenu('100%', viewZoomMenu.funct);
- elt.setAttribute('title', mxResources.get('zoom') + ' (Alt+Mousewheel)');
- elt.style.whiteSpace = 'nowrap';
- elt.style.paddingRight = '10px';
- elt.style.textDecoration = 'none';
- elt.style.textDecoration = 'none';
- elt.style.overflow = 'hidden';
- elt.style.visibility = 'hidden';
- elt.style.textAlign = 'center';
- elt.style.cursor = 'pointer';
- elt.style.height = (parseInt(ui.tabContainerHeight) - 1) + 'px';
- elt.style.lineHeight = (parseInt(ui.tabContainerHeight) + 1) + 'px';
- elt.style.position = 'absolute';
- elt.style.display = 'block';
- elt.style.fontSize = '12px';
- elt.style.width = '59px';
- elt.style.right = '0px';
- elt.style.bottom = '0px';
- elt.style.backgroundImage = 'url(' + mxWindow.prototype.minimizeImage + ')';
- elt.style.backgroundPosition = 'right 6px center';
- elt.style.backgroundRepeat = 'no-repeat';
- wrapper.appendChild(elt);
- }
-
- // Updates the label if the scale changes
- (function(elt)
- {
- var updateZoom = mxUtils.bind(this, function()
- {
- elt.innerHTML = Math.round(ui.editor.graph.view.scale * 100) + '%';
- });
- ui.editor.graph.view.addListener(mxEvent.EVENT_SCALE, updateZoom);
- ui.editor.addListener('resetGraphView', updateZoom);
- ui.editor.addListener('pageSelected', updateZoom);
- })(elt);
-
- // Augments setGraphEnabled to update visible state
- var uiSetGraphEnabled = ui.setGraphEnabled;
-
- ui.setGraphEnabled = function()
- {
- uiSetGraphEnabled.apply(this, arguments);
-
- if (this.tabContainer != null)
- {
- elt.style.visibility = this.tabContainer.style.visibility;
- this.diagramContainer.style.bottom = (this.tabContainer.style.visibility != 'hidden' &&
- footer == null) ? this.tabContainerHeight + 'px' : '0px';
- }
- };
- }
-
- wrapper.appendChild(menubar);
- wrapper.appendChild(ui.diagramContainer);
- previousParent.appendChild(wrapper);
- ui.updateTabContainer();
-
- if (footer == null)
- {
- wrapper.appendChild(ui.tabContainer);
- }
-
- var langMenuElt = null;
-
- function refreshMenu()
- {
- if (urlParams['sketch'] == '1')
- {
- if (urlParams['embedInline'] != '1')
- {
- toolbar.style.left = (picker.offsetTop - picker.offsetHeight / 2 < 58) ? '70px' : '10px';
- }
- }
- else
- {
- // Removes all existing menu items
- var node = menubar.firstChild;
-
- while (node != null)
- {
- var temp = node.nextSibling;
-
- if (node.className == 'geMenuItem' || node.className == 'geItem')
- {
- node.parentNode.removeChild(node);
- }
-
- node = temp;
- }
-
- before = menubar.firstChild;
- iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
- var small = iw < 1000 || urlParams['sketch'] == '1';
- var appElt = null;
-
- if (!small)
- {
- appElt = addMenu('diagram');
- }
- var temp = (small) ? addMenu('diagram', null, Editor.drawLogoImage) : null;
- if (temp != null)
- {
- appElt = temp;
- }
- createGroup([appElt, addMenuItem(mxResources.get('shapes'), ui.actions.get('toggleShapes').funct, null,
- mxResources.get('shapes'), ui.actions.get('image'), (small) ? Editor.shapesImage : null),
- addMenuItem(mxResources.get('format'), ui.actions.get('toggleFormat').funct, null,
- mxResources.get('format') + ' (' + ui.actions.get('formatPanel').shortcut + ')', ui.actions.get('image'),
- (small) ? Editor.formatImage : null)],
- (small) ? 60 : null);
-
- var elt = addMenu('insert', true, (small) ? insertImage : null);
- createGroup([elt, addMenuItem(mxResources.get('delete'), ui.actions.get('delete').funct,
- null, mxResources.get('delete'), ui.actions.get('delete'),
- (small) ? Editor.trashImage : null)], (small) ? 60 : null);
-
- if (iw >= 411)
- {
- createGroup([undoElt, redoElt], 60);
-
- if (iw >= 520)
- {
- createGroup([fitElt,
- (iw >= 640) ? addMenuItem('', zoomInAction.funct, true, mxResources.get('zoomIn') + ' (' + Editor.ctrlKey + ' +)',
- zoomInAction, Editor.zoomInImage) : null,
- (iw >= 640) ? addMenuItem('', zoomOutAction.funct, true, mxResources.get('zoomOut') + ' (' + Editor.ctrlKey + ' -)',
- zoomOutAction, Editor.zoomOutImage) : null], 60);
- }
- }
- }
-
- if (appElt != null)
- {
- mxEvent.disableContextMenu(appElt);
- mxEvent.addGestureListeners(appElt, mxUtils.bind(this, function(evt)
- {
- if (mxEvent.isShiftDown(evt) || mxEvent.isAltDown(evt) ||
- mxEvent.isMetaDown(evt) || mxEvent.isControlDown(evt) ||
- mxEvent.isPopupTrigger(evt))
- {
- ui.appIconClicked(evt);
- }
- }), null, null);
- }
-
- var langMenu = ui.menus.get('language');
- if (langMenu != null && !mxClient.IS_CHROMEAPP &&
- !EditorUi.isElectronApp && iw >= 600 &&
- urlParams['sketch'] != '1')
- {
- if (langMenuElt == null)
- {
- var elt = menuObj.addMenu('', langMenu.funct);
- elt.setAttribute('title', mxResources.get('language'));
- elt.className = 'geToolbarButton';
- elt.style.backgroundImage = 'url(' + Editor.globeImage + ')';
- elt.style.backgroundPosition = 'center center';
- elt.style.backgroundRepeat = 'no-repeat';
- elt.style.backgroundSize = '24px 24px';
- elt.style.position = 'absolute';
- elt.style.height = '24px';
- elt.style.width = '24px';
- elt.style.zIndex = '1';
- elt.style.right = '8px';
- elt.style.cursor = 'pointer';
- elt.style.top = (urlParams['embed'] == '1') ? '12px' : '11px';
- menubar.appendChild(elt);
- langMenuElt = elt;
- }
-
- ui.buttonContainer.style.paddingRight = '34px';
- }
- else
- {
- ui.buttonContainer.style.paddingRight = '4px';
-
- if (langMenuElt != null)
- {
- langMenuElt.parentNode.removeChild(langMenuElt);
- langMenuElt = null;
- }
- }
- };
-
- refreshMenu();
-
- mxEvent.addListener(window, 'resize', function()
- {
- refreshMenu();
-
- if (ui.sidebarWindow != null)
- {
- ui.sidebarWindow.window.fit();
- }
-
- if (ui.formatWindow != null)
- {
- ui.formatWindow.window.fit();
- }
- if (ui.actions.outlineWindow != null)
- {
- ui.actions.outlineWindow.window.fit();
- }
- if (ui.actions.layersWindow != null)
- {
- ui.actions.layersWindow.window.fit();
- }
- if (ui.menus.tagsWindow != null)
- {
- ui.menus.tagsWindow.window.fit();
- }
- if (ui.menus.findWindow != null)
- {
- ui.menus.findWindow.window.fit();
- }
- if (ui.menus.findReplaceWindow != null)
- {
- ui.menus.findReplaceWindow.window.fit();
- }
- });
- if (urlParams['embedInline'] == '1')
- {
- document.body.style.cursor = 'text';
- picker.style.transform = '';
- mxEvent.addGestureListeners(ui.diagramContainer.parentNode, function(evt)
- {
- if (mxEvent.getSource(evt) ==
- ui.diagramContainer.parentNode)
- {
- ui.embedExitPoint = new mxPoint(mxEvent.getClientX(evt), mxEvent.getClientY(evt));
- ui.sendEmbeddedSvgExport();
- }
- });
- var div = document.createElement('div');
- div.style.position = 'absolute';
- div.style.width = '10px';
- div.style.height = '10px';
- div.style.borderRadius = '5px';
- div.style.border = '1px solid gray';
- div.style.background = '#ffffff';
- div.style.cursor = 'row-resize';
- ui.diagramContainer.parentNode.appendChild(div);
- ui.bottomResizer = div;
- var x0 = null;
- var y0 = null;
- var w0 = null;
- var h0 = null;
- mxEvent.addGestureListeners(div, function(evt)
- {
- h0 = parseInt(ui.diagramContainer.style.height);
- y0 = mxEvent.getClientY(evt);
- graph.popupMenuHandler.hideMenu();
- mxEvent.consume(evt);
- });
- div = div.cloneNode(false);
- div.style.cursor = 'col-resize';
- ui.diagramContainer.parentNode.appendChild(div);
- ui.rightResizer = div;
- mxEvent.addGestureListeners(div, function(evt)
- {
- w0 = parseInt(ui.diagramContainer.style.width);
- x0 = mxEvent.getClientX(evt);
- graph.popupMenuHandler.hideMenu();
- mxEvent.consume(evt);
- });
- mxEvent.addGestureListeners(document.body, null, function(evt)
- {
- var changed = false;
- if (x0 != null)
- {
- ui.diagramContainer.style.width = Math.max(20,
- w0 + mxEvent.getClientX(evt) - x0) + 'px';
- changed = true;
- }
- if (y0 != null)
- {
- ui.diagramContainer.style.height = Math.max(20,
- h0 + mxEvent.getClientY(evt) - y0) + 'px';
- changed = true;
- }
- if (changed)
- {
- var parent = window.opener || window.parent;
- parent.postMessage(JSON.stringify({
- event: 'resize',
- fullscreen: Editor.inlineFullscreen,
- rect: ui.diagramContainer.getBoundingClientRect()
- }), '*');
- inlineSizeChanged();
- ui.refresh();
- }
- }, function(evt)
- {
- if (x0 != null || y0 != null)
- {
- mxEvent.consume(evt);
- }
- x0 = null;
- y0 = null;
- });
- this.diagramContainer.style.borderRadius = '4px';
- document.body.style.backgroundColor = 'transparent';
- ui.bottomResizer.style.visibility = 'hidden';
- ui.rightResizer.style.visibility = 'hidden';
- toolbar.style.visibility = 'hidden';
- footer.style.visibility = 'hidden';
- picker.style.display = 'none';
- }
-
- if (urlParams['prefetchFonts'] == '1')
- {
- ui.editor.loadFonts();
- }
- };
- };
- (function()
- {
- var initialized = false;
-
- // ChromeApp has async local storage
- if (uiTheme == 'min' && !initialized && !mxClient.IS_CHROMEAPP)
- {
- EditorUi.initMinimalTheme();
- initialized = true;
- }
-
- var uiInitTheme = EditorUi.initTheme;
-
- // For async startup like chromeos
- EditorUi.initTheme = function()
- {
- uiInitTheme.apply(this, arguments);
-
- if (uiTheme == 'min' && !initialized)
- {
- this.initMinimalTheme();
- initialized = true;
- }
- };
- })();
|