Editor.js 137 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144
  1. /**
  2. * Copyright (c) 2006-2017, JGraph Ltd
  3. * Copyright (c) 2006-2017, Gaudenz Alder
  4. */
  5. (function()
  6. {
  7. /**
  8. * Specifies the app name. Default is document.title.
  9. */
  10. Editor.prototype.appName = 'draw.io';
  11. /**
  12. * Used in the GraphViewer lightbox.
  13. */
  14. Editor.closeImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/delete.png' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAApVBMVEUAAAD////k5OT///8AAAB1dXXMzMz9/f39/f37+/v5+fn+/v7///9iYmJaWlqFhYWnp6ejo6OHh4f////////////////7+/v5+fnx8fH///8AAAD///8bGxv7+/v5+fkoKCghISFDQ0MYGBjh4eHY2Njb29tQUFBvb29HR0c/Pz82NjYrKyu/v78SEhLu7u7s7OzV1dVVVVU7OzsVFRXAv78QEBBzqehMAAAAG3RSTlMAA/7p/vz5xZlrTiPL/v78+/v7+OXd2TYQDs8L70ZbAAABKUlEQVQoz3VS13LCMBBUXHChd8iukDslQChJ/v/TchaG4cXS+OSb1c7trU7V60OpdRz2ZtNZL4zXNlcN8BEtSG6+NxIXkeRPoBuQ1cjvZ31/VJFB10ISli6diYfH8iYO3WUNCcNlB0gTrXOtkxTo0O1aKKiBBMhhv2MNBQKoiA5wxlZo0JDzD3AYKbWacyj3fs01wxey0pyEP+R8pWKWXoqtIZ0DDg5pbki9krEKOa6LVDQsdoXEsi46Zqh69KFz7B1u7Hb2yDV8firXDKBlZ4UFiswKGRhXTS93/ECK7yxnJ3+S3y/ThpO+cfSD017nqa18aasabU0/t7d+tk0/1oMEJ1NaD67iwdF68OabFSLn+eHb0+vjy+uk8br9fdrftH0O2menfd7+AQfYM/lNjoDHAAAAAElFTkSuQmCC';
  15. /**
  16. *
  17. */
  18. Editor.plusImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/plus.png' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDdCMTdENjVCOEM4MTFFNDlCRjVBNDdCODU5NjNBNUMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDdCMTdENjZCOEM4MTFFNDlCRjVBNDdCODU5NjNBNUMiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowN0IxN0Q2M0I4QzgxMUU0OUJGNUE0N0I4NTk2M0E1QyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowN0IxN0Q2NEI4QzgxMUU0OUJGNUE0N0I4NTk2M0E1QyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PtjrjmgAAAAtSURBVHjaYvz//z8DMigvLwcLdHZ2MiKLMzEQCaivkLGsrOw/dU0cAr4GCDAARQsQbTFrv10AAAAASUVORK5CYII=';
  19. /**
  20. *
  21. */
  22. Editor.spinImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/spin.gif' : 'data:image/gif;base64,R0lGODlhDAAMAPUxAEVriVp7lmCAmmGBm2OCnGmHn3OPpneSqYKbr4OcsIScsI2kto6kt46lt5KnuZmtvpquvpuvv56ywaCzwqK1xKu7yay9yq+/zLHAzbfF0bjG0bzJ1LzK1MDN18jT28nT3M3X3tHa4dTc49Xd5Njf5dng5t3k6d/l6uDm6uru8e7x8/Dz9fT29/b4+Pj5+fj5+vr6+v///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkKADEAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAADAAMAAAGR8CYcEgsOgYAIax4CCQuQldrCBEsiK8VS2hoFGOrlJDA+cZQwkLnqyoJFZKviSS0ICrE0ec0jDAwIiUeGyBFGhMPFBkhZo1BACH5BAkKAC4ALAAAAAAMAAwAhVB0kFR3k1V4k2CAmmWEnW6Lo3KOpXeSqH2XrIOcsISdsImhtIqhtJCmuJGnuZuwv52wwJ+ywZ+ywqm6yLHBzbLCzrXEz7fF0LnH0rrI0r7L1b/M1sXR2cfT28rV3czW3s/Z4Nfe5Nvi6ODm6uLn6+Ln7OLo7OXq7efs7+zw8u/y9PDy9PX3+Pr7+////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZDQJdwSCxGDAIAoVFkFBwYSyIwGE4OkCJxIdG6WkJEx8sSKj7elfBB0a5SQg1EQ0SVVMPKhDM6iUIkRR4ZFxsgJl6JQQAh+QQJCgAxACwAAAAADAAMAIVGa4lcfZdjgpxkg51nhp5ui6N3kqh5lKqFnbGHn7KIoLOQp7iRp7mSqLmTqbqarr6br7+fssGitcOitcSuvsuuv8uwwMyzw861xNC5x9K6x9K/zNbDztjE0NnG0drJ1NzQ2eDS2+LT2+LV3ePZ4Oba4ebb4ufc4+jm6+7t8PLt8PPt8fPx8/Xx9PX09vf19/j3+Pn///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQ8CYcEgsUhQFggFSjCQmnE1jcBhqGBXiIuAQSi7FGEIgfIzCFoCXFCZiPO0hKBMiwl7ET6eUYqlWLkUnISImKC1xbUEAIfkECQoAMgAsAAAAAAwADACFTnKPT3KPVHaTYoKcb4yjcY6leZSpf5mtgZuvh5+yiqG0i6K1jqW3kae5nrHBnrLBn7LCoLPCobTDqbrIqrvIs8LOtMPPtcPPtcTPuMbRucfSvcrUvsvVwMzWxdHaydTcytXdzNbezdff0drh2ODl2+Ln3eTp4Obq4ujs5Ont5uvu6O3w6u7w6u7x7/L09vj5+vr7+vv7////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkdAmXBILHIcicOCUqxELKKPxKAYgiYd4oMAEWo8RVmjIMScwhmBcJMKXwLCECmMGAhPI1QRwBiaSixCMDFhLSorLi8wYYxCQQAh+QQJCgAxACwAAAAADAAMAIVZepVggJphgZtnhp5vjKN2kah3kqmBmq+KobSLorWNpLaRp7mWq7ybr7+gs8KitcSktsWnuManucexwM2ywc63xtG6yNO9ytS+ytW/zNbDz9jH0tvL1d3N197S2+LU3OPU3ePV3eTX3+Xa4efb4ufd5Onl6u7r7vHs7/Lt8PLw8/Xy9Pby9fb09ff2+Pn3+Pn6+vr///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGSMCYcEgseiwSR+RS7GA4JFGF8RiWNiEiJTERgkjFGAQh/KTCGoJwpApnBkITKrwoCFWnFlEhaAxXLC9CBwAGRS4wQgELYY1CQQAh+QQJCgAzACwAAAAADAAMAIVMcI5SdZFhgZtti6JwjaR4k6mAma6Cm6+KobSLorWLo7WNo7aPpredsMCescGitMOitcSmuMaqu8ixwc2zws63xdC4xtG5x9K9ytXAzdfCztjF0NnF0drK1d3M1t7P2N/P2eDT2+LX3+Xe5Onh5+vi5+vj6Ozk6e3n7O/o7O/q7vHs7/Lt8PPu8fPx8/X3+Pn6+vv7+/v8/Pz///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGRcCZcEgsmkIbTOZTLIlGqZNnchm2SCgiJ6IRqljFmQUiXIVnoITQde4chC9Y+LEQxmTFRkFSNFAqDAMIRQoCAAEEDmeLQQAh+QQJCgAwACwAAAAADAAMAIVXeZRefplff5lhgZtph59yjqV2kaeAmq6FnbGFnrGLorWNpLaQp7mRqLmYrb2essGgs8Klt8apusitvcquv8u2xNC7yNO8ydS8ytTAzdfBzdfM1t7N197Q2eDU3OPX3+XZ4ObZ4ebc4+jf5erg5erg5uvp7fDu8fPv8vTz9fb09vf19/j3+Pn4+fn5+vr6+/v///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGRUCYcEgspkwjEKhUVJ1QsBNp0xm2VixiSOMRvlxFGAcTJook5eEHIhQcwpWIkAFQECkNy9AQWFwyEAkPRQ4FAwQIE2llQQAh+QQJCgAvACwAAAAADAAMAIVNcY5SdZFigptph6BvjKN0kKd8lquAmq+EnbGGn7KHn7ONpLaOpbearr+csMCdscCescGhtMOnuMauvsuzws60w862xdC9ytW/y9a/zNbCztjG0drH0tvK1N3M1t7N19/U3ePb4uff5urj6Ozk6e3l6u7m6u7o7PDq7vDt8PPv8vTw8vTw8/X19vf6+vv///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQ8CXcEgsvlytVUplJLJIpSEDUESFTELBwSgCCQEV42kjDFiMo4uQsDB2MkLHoEHUTD7DRAHC8VAiZ0QSCgYIDxhNiUEAOw==';
  23. /**
  24. *
  25. */
  26. Editor.globeImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTEuOTkgMkM2LjQ3IDIgMiA2LjQ4IDIgMTJzNC40NyAxMCA5Ljk5IDEwQzE3LjUyIDIyIDIyIDE3LjUyIDIyIDEyUzE3LjUyIDIgMTEuOTkgMnptNi45MyA2aC0yLjk1Yy0uMzItMS4yNS0uNzgtMi40NS0xLjM4LTMuNTYgMS44NC42MyAzLjM3IDEuOTEgNC4zMyAzLjU2ek0xMiA0LjA0Yy44MyAxLjIgMS40OCAyLjUzIDEuOTEgMy45NmgtMy44MmMuNDMtMS40MyAxLjA4LTIuNzYgMS45MS0zLjk2ek00LjI2IDE0QzQuMSAxMy4zNiA0IDEyLjY5IDQgMTJzLjEtMS4zNi4yNi0yaDMuMzhjLS4wOC42Ni0uMTQgMS4zMi0uMTQgMiAwIC42OC4wNiAxLjM0LjE0IDJINC4yNnptLjgyIDJoMi45NWMuMzIgMS4yNS43OCAyLjQ1IDEuMzggMy41Ni0xLjg0LS42My0zLjM3LTEuOS00LjMzLTMuNTZ6bTIuOTUtOEg1LjA4Yy45Ni0xLjY2IDIuNDktMi45MyA0LjMzLTMuNTZDOC44MSA1LjU1IDguMzUgNi43NSA4LjAzIDh6TTEyIDE5Ljk2Yy0uODMtMS4yLTEuNDgtMi41My0xLjkxLTMuOTZoMy44MmMtLjQzIDEuNDMtMS4wOCAyLjc2LTEuOTEgMy45NnpNMTQuMzQgMTRIOS42NmMtLjA5LS42Ni0uMTYtMS4zMi0uMTYtMiAwLS42OC4wNy0xLjM1LjE2LTJoNC42OGMuMDkuNjUuMTYgMS4zMi4xNiAyIDAgLjY4LS4wNyAxLjM0LS4xNiAyem0uMjUgNS41NmMuNi0xLjExIDEuMDYtMi4zMSAxLjM4LTMuNTZoMi45NWMtLjk2IDEuNjUtMi40OSAyLjkzLTQuMzMgMy41NnpNMTYuMzYgMTRjLjA4LS42Ni4xNC0xLjMyLjE0LTIgMC0uNjgtLjA2LTEuMzQtLjE0LTJoMy4zOGMuMTYuNjQuMjYgMS4zMS4yNiAycy0uMSAxLjM2LS4yNiAyaC0zLjM4eiIvPjwvc3ZnPg==';
  27. /**
  28. *
  29. */
  30. Editor.userImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgMTJjMi4yMSAwIDQtMS43OSA0LTRzLTEuNzktNC00LTQtNCAxLjc5LTQgNCAxLjc5IDQgNCA0em0wIDJjLTIuNjcgMC04IDEuMzQtOCA0djJoMTZ2LTJjMC0yLjY2LTUuMzMtNC04LTR6Ii8+PC9zdmc+';
  31. /**
  32. *
  33. */
  34. Editor.shareImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTggMTYuMDhjLS43NiAwLTEuNDQuMy0xLjk2Ljc3TDguOTEgMTIuN2MuMDUtLjIzLjA5LS40Ni4wOS0uN3MtLjA0LS40Ny0uMDktLjdsNy4wNS00LjExYy41NC41IDEuMjUuODEgMi4wNC44MSAxLjY2IDAgMy0xLjM0IDMtM3MtMS4zNC0zLTMtMy0zIDEuMzQtMyAzYzAgLjI0LjA0LjQ3LjA5LjdMOC4wNCA5LjgxQzcuNSA5LjMxIDYuNzkgOSA2IDljLTEuNjYgMC0zIDEuMzQtMyAzczEuMzQgMyAzIDNjLjc5IDAgMS41LS4zMSAyLjA0LS44MWw3LjEyIDQuMTZjLS4wNS4yMS0uMDguNDMtLjA4LjY1IDAgMS42MSAxLjMxIDIuOTIgMi45MiAyLjkyIDEuNjEgMCAyLjkyLTEuMzEgMi45Mi0yLjkycy0xLjMxLTIuOTItMi45Mi0yLjkyeiIvPjwvc3ZnPg==';
  35. /**
  36. *
  37. */
  38. Editor.syncImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTIgNFYxTDggNWw0IDRWNmMzLjMxIDAgNiAyLjY5IDYgNiAwIDEuMDEtLjI1IDEuOTctLjcgMi44bDEuNDYgMS40NkMxOS41NCAxNS4wMyAyMCAxMy41NyAyMCAxMmMwLTQuNDItMy41OC04LTgtOHptMCAxNGMtMy4zMSAwLTYtMi42OS02LTYgMC0xLjAxLjI1LTEuOTcuNy0yLjhMNS4yNCA3Ljc0QzQuNDYgOC45NyA0IDEwLjQzIDQgMTJjMCA0LjQyIDMuNTggOCA4IDh2M2w0LTQtNC00djN6Ii8+PC9zdmc+';
  39. /**
  40. *
  41. */
  42. Editor.syncDisabledImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTAgNi4zNVY0LjI2Yy0uOC4yMS0xLjU1LjU0LTIuMjMuOTZsMS40NiAxLjQ2Yy4yNS0uMTIuNS0uMjQuNzctLjMzem0tNy4xNC0uOTRsMi4zNiAyLjM2QzQuNDUgOC45OSA0IDEwLjQ0IDQgMTJjMCAyLjIxLjkxIDQuMiAyLjM2IDUuNjRMNCAyMGg2di02bC0yLjI0IDIuMjRDNi42OCAxNS4xNSA2IDEzLjY2IDYgMTJjMC0xIC4yNS0xLjk0LjY4LTIuNzdsOC4wOCA4LjA4Yy0uMjUuMTMtLjUuMjUtLjc3LjM0djIuMDljLjgtLjIxIDEuNTUtLjU0IDIuMjMtLjk2bDIuMzYgMi4zNiAxLjI3LTEuMjdMNC4xNCA0LjE0IDIuODYgNS40MXpNMjAgNGgtNnY2bDIuMjQtMi4yNEMxNy4zMiA4Ljg1IDE4IDEwLjM0IDE4IDEyYzAgMS0uMjUgMS45NC0uNjggMi43N2wxLjQ2IDEuNDZDMTkuNTUgMTUuMDEgMjAgMTMuNTYgMjAgMTJjMC0yLjIxLS45MS00LjItMi4zNi01LjY0TDIwIDR6Ii8+PC9zdmc+';
  43. /**
  44. *
  45. */
  46. Editor.syncProblemImage = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMyAxMmMwIDIuMjEuOTEgNC4yIDIuMzYgNS42NEwzIDIwaDZ2LTZsLTIuMjQgMi4yNEM1LjY4IDE1LjE1IDUgMTMuNjYgNSAxMmMwLTIuNjEgMS42Ny00LjgzIDQtNS42NVY0LjI2QzUuNTUgNS4xNSAzIDguMjcgMyAxMnptOCA1aDJ2LTJoLTJ2MnpNMjEgNGgtNnY2bDIuMjQtMi4yNEMxOC4zMiA4Ljg1IDE5IDEwLjM0IDE5IDEyYzAgMi42MS0xLjY3IDQuODMtNCA1LjY1djIuMDljMy40NS0uODkgNi00LjAxIDYtNy43NCAwLTIuMjEtLjkxLTQuMi0yLjM2LTUuNjRMMjEgNHptLTEwIDloMlY3aC0ydjZ6Ii8+PC9zdmc+';
  47. /**
  48. * Used in the GraphViewer lightbox.
  49. */
  50. Editor.tweetImage = IMAGE_PATH + '/tweet.png';
  51. /**
  52. * Used in the GraphViewer lightbox.
  53. */
  54. Editor.facebookImage = IMAGE_PATH + '/facebook.png';
  55. /**
  56. * Blank 1x1 pixel transparent PNG image.
  57. */
  58. Editor.blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==';
  59. /**
  60. * Blank 1x1 pixel transparent PNG image.
  61. */
  62. Editor.hiResImage = (mxClient.IS_SVG) ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAA+CAMAAACLMWy1AAAAh1BMVEUAAABMTExERERBQUFBQUFFRUVAQEBCQkJAQEA6OjpDQ0NKSkpBQUFBQUFERERERERBQUFCQkJCQkJCQkJJSUlBQUFCQkJDQ0NDQ0NCQkJDQ0NBQUFBQUFCQkJBQUFCQkJCQkJDQ0NCQkJHR0dBQUFCQkJCQkJAQEBCQkJDQ0NAQEBERERCQkIk1hS2AAAAKnRSTlMAAjj96BL7PgQFRwfu3TYazKuVjRXl1V1DPCn1uLGjnWNVIgy9hU40eGqPkM38AAACG0lEQVRYw+2X63KbMBCFzwZblgGDceN74muatpLe//m6MHV3gHGFAv2RjM94MAbxzdnVsQbBDKwH8AH8MDAyafzjqYeyOG04XE7RS8nIRDXg6BlT+rA0nmtAPh+NQRDxIASIMG44rAMrGunBgHwy3uUldxggIStGKp2f+DQc2O4h4eQsX3O2IFB/oEbsjOKbStnjAEA+zJ0ylZTbgvoDn8xNyn6Dbj5Kd4GsNpABa6duQPfSdEj88TgMAhKuCWjAkgmFXPLnsD0pWd3OFGdrMugQII/eOMPEiGOzqPMIeWrcSoMCg71W1pXBPvCP+gS/OdXqQ3uW23+93XGWLl/OaBb805bNcBPoEIcVJsnHzcxpZH86u5KZ9gDby5dQCcnKqdbke4ItI4Tzd7IW9hZQt4EO6GG9b9sYuuK9Wwn8TIr2xKbF2+3Nhr+qxChJ/AI6pIfCu4z4Zowp4ZUNihz79vewzctnHDwTvQO/hCdFBzrUGDOPn2Y/F8YKT4oOATLvlhOznzmBSdFBJWtc58y7r+UVFOCQczy3wpN6pegDqHtsCPTGvH9JuTO0Dyg8icldYPk+RB6g8Aofj4m2EKBvtTmUPD9xDd1pPcSReV2U5iD/ik2yrngtvvqBfPzOvKiDTKTsCdoHZJ7pLLffgTwlJ5vJdtJV2/jiAYaLvLGhMAEDO5QcDg2M/jOw/8Zn+K3ZwJvHT7ZffgC/NvA3zcybTeIfE4EAAAAASUVORK5CYII=' : IMAGE_PATH + '/img-hi-res.png';
  63. /**
  64. * Blank 1x1 pixel transparent PNG image.
  65. */
  66. Editor.loResImage = (mxClient.IS_SVG) ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAA+CAMAAACLMWy1AAAAS1BMVEVAQEAAAAA1NTVBQUFDQ0NDQ0NFRUVERERBQUFBQUFBQUFAQEBBQUFBQUFCQkJCQkJCQkJBQUFCQkJDQ0NDQ0NCQkJCQkJCQkJGRkb5/XqTAAAAGXRSTlP+AAWODlASCsesX+Lc2LyWe3pwa1tCPjohjSJfoAAAAI1JREFUWMPt1MkKhTAMRuG0anvneXr/J71nUypKcdqI/N8yhLMKMZE1CahnClDQzMPB44ED3EgeCubgDWnWQMHpwTtKwTe+UHD4sJ94wbUEHHFGhILlYDeSnsQeabeCgsPBgB0MOZZ9oGA5GJFiJSfUULAfjLjARrhCwX7wh2YCDwVbwZkUBKqFFJRN+wOcwSgR2sREcgAAAABJRU5ErkJggg==' : IMAGE_PATH + '/img-lo-res.png';
  67. /**
  68. * Only needed in browsers with SVG support for export via lightbox toolbar.
  69. */
  70. Editor.cameraLargeImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAA/BJREFUWAnFl0uIjWEYx885buPSuGwmSYwtwsY1ikKSNYNclmQnadgrZSPlsnBLSlaGBdNYKY0Vdi4L4zYzIqxGxmXG//d+7//0+uY7nWMiT/2/53mf+3v7vnNKpf9M5UbrDw8Pj4m+wzmeT1FBUS6Xf+YNox6reMONukijMXUTM3NmI75PyXcJPwRWg5kS7xysDLNmfEUxpx2rceNE50IlYjyRklcLf0prY+x4BTqfmx3ZUHQaO9ISGngYq38V/1EH+ECPa+QaK1u1kVBQirDMChiS3CTeIkwWvghtwhKBpZ8g1CO2B99FynVU/KowSRgQ3mlrBsVZ1awmQlS0SGbfXglfBPbdRGMm5O8RXg2P835pDCvzWjghTHETcLpZLHwS8kTCtBEK1SN83Egam8YxyVZqc+Do5qkwS+gT9grNwkUBG6cbsG/gs3BTuC/0ChCxq4QtwgzBMdwUZBPyN4Ftfi4sYPZHktbOSRlIuutRP5jYj0ueZp88xyYcS/zZoiLyQT1IA/cTj7eSlwnrhI+JnkQbCwo2Sx/2M7VJt17wdhVtgxvrpoFnAuSAbJQ97biZAlKxBfD9wgOhV+BgIR/AZtJ4kwD5PGSj7OmmekjWEy0oAQHAS3+KpBpzXqYK3UItopHpSRMno2N+cm7gDYnfRCcr3QBqriMHLJDkeyhFfiG5aVbK+8rhtP9M6QcIEJHX5Fp9NMAyQlYiu+OOJNlODCIXyka/P23bncTdiC7OydC1+v1Bsb+5r84DK8S3Rdmf5cRUFW3bXtWUSt1Rdk6G4SyJV2o1YId+vNUxr+x5yCJiapFtcxQzLjrxboGcMxvFJwEOKnLwjIbkx/sdSmeSaUY++SwTAxV+4DJT7RVwkbk46gNCsifIItuy0e9PF33Cb4homhN5YRyzL5q5V2VNkv98kqgoGTo3YF9CnMM5Y5rItFfvBSi9JulVXOgI+VwIntkt+SaZ6weQfcovJf7zpTfl86P/wAF7Fz18NeKwmvAWCaX0Z/uMHQr42ZxvR/Rxcw5xM+9J/CJq8w2gduDhmDgso/QrBH47dEXQ1IqczyHpIOfIRtnTtV7SwO1oKXKkU3fbToFGSDHtMWcaH1WBuVYnDbRFi99iqSMySdzxXckrazUh23KBVYGIcfNBkTxca0e4ATJ0KukGYVBgr/MnlhPOtQq/ksUfCbzh+EFCjtnCUoHfjhA/OsiTv2HcEvJMELp0VakZDliTmriTdPivxU4VmEhtPrGV+KJhO7ZKt0doFZh1fgZSBWIW2AGEHwg3BUWOnKtH+suqdw07tYMfglCrWPD5mw9qVYuniaXkT0OtWaSuo5LJTY1RBf+roF9X5+y/5qU+DAAAAABJRU5ErkJggg==';
  71. /**
  72. * Default value for custom libraries in mxSettings.
  73. */
  74. Editor.defaultCustomLibraries = [];
  75. /**
  76. * Default value for custom libraries in mxSettings.
  77. */
  78. Editor.enableCustomLibraries = true;
  79. /**
  80. * Specifies if custom properties should be enabled.
  81. */
  82. Editor.enableCustomProperties = true;
  83. /**
  84. * Common properties for all edges.
  85. */
  86. Editor.commonEdgeProperties = [
  87. {type: 'separator'},
  88. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  89. {name: 'targetPortConstraint', dispName: 'Target Port Constraint', type: 'enum', defVal: 'none',
  90. enumList: [{val: 'none', dispName: 'None'}, {val: 'east', dispName: 'East'}, {val: 'north', dispName: 'North'}, {val: 'south', dispName: 'South'}, {val: 'west', dispName: 'West'}]
  91. },
  92. {name: 'sourcePortConstraint', dispName: 'Source Port Constraint', type: 'enum', defVal: 'none',
  93. enumList: [{val: 'none', dispName: 'None'}, {val: 'east', dispName: 'East'}, {val: 'north', dispName: 'North'}, {val: 'south', dispName: 'South'}, {val: 'west', dispName: 'West'}]
  94. },
  95. {name: 'fillOpacity', dispName: 'Fill Opacity', type: 'int', min: 0, max: 100, defVal: 100},
  96. {name: 'strokeOpacity', dispName: 'Stroke Opacity', type: 'int', min: 0, max: 100, defVal: 100},
  97. {name: 'startFill', dispName: 'Start Fill', type: 'bool', defVal: true},
  98. {name: 'endFill', dispName: 'End Fill', type: 'bool', defVal: true},
  99. {name: 'sourcePerimeterSpacing', dispName: 'Source Perimeter Spacing', type: 'float', defVal: 0},
  100. {name: 'targetPerimeterSpacing', dispName: 'Target Perimeter Spacing', type: 'float', defVal: 0},
  101. {name: 'perimeterSpacing', dispName: 'Perimeter Spacing', type: 'float', defVal: 0},
  102. {name: 'anchorPointDirection', dispName: 'Anchor Point Direction', type: 'bool', defVal: true},
  103. {name: 'snapToPoint', dispName: 'Snap to Point', type: 'bool', defVal: false},
  104. {name: 'fixDash', dispName: 'Fixed Dash', type: 'bool', defVal: false},
  105. {name: 'jiggle', dispName: 'Jiggle', type: 'float', min: 0, defVal: 1.5, isVisible: function(state)
  106. {
  107. return mxUtils.getValue(state.style, 'comic', '0') == '1';
  108. }},
  109. {name: 'editable', dispName: 'Editable', type: 'bool', defVal: true},
  110. {name: 'backgroundOutline', dispName: 'Background Outline', type: 'bool', defVal: false},
  111. {name: 'bendable', dispName: 'Bendable', type: 'bool', defVal: true},
  112. {name: 'movable', dispName: 'Movable', type: 'bool', defVal: true},
  113. {name: 'cloneable', dispName: 'Cloneable', type: 'bool', defVal: true},
  114. {name: 'deletable', dispName: 'Deletable', type: 'bool', defVal: true},
  115. {name: 'loopStyle', dispName: 'Loop Style', type: 'bool', defVal: true}
  116. ];
  117. /**
  118. * Common properties for all vertices.
  119. */
  120. Editor.commonVertexProperties = [
  121. {type: 'separator'},
  122. {name: 'fillOpacity', dispName: 'Fill Opacity', type: 'int', min: 0, max: 100, defVal: 100},
  123. {name: 'strokeOpacity', dispName: 'Stroke Opacity', type: 'int', min: 0, max: 100, defVal: 100},
  124. {name: 'overflow', dispName: 'Text Overflow', defVal: 'visible', type: 'enum',
  125. enumList: [{val: 'visible', dispName: 'Visible'}, {val: 'hidden', dispName: 'Hidden'}, {val: 'fill', dispName: 'Fill'}, {val: 'width', dispName: 'Width'}]
  126. },
  127. {name: 'noLabel', dispName: 'Hide Label', type: 'bool', defVal: false},
  128. {name: 'labelPadding', dispName: 'Label Padding', type: 'float', defVal: 0},
  129. {name: 'direction', dispName: 'Direction', type: 'enum', defVal: 'east',
  130. enumList: [{val: 'east', dispName: 'East'}, {val: 'north', dispName: 'North'}, {val: 'south', dispName: 'South'}, {val: 'west', dispName: 'West'}]
  131. },
  132. {name: 'portConstraint', dispName: 'Port Constraint', type: 'enum', defVal: 'none',
  133. enumList: [{val: 'none', dispName: 'None'}, {val: 'east', dispName: 'East'}, {val: 'north', dispName: 'North'}, {val: 'south', dispName: 'South'}, {val: 'west', dispName: 'West'}]
  134. },
  135. {name: 'portConstraintRotation', dispName: 'Port Const. Rot.', type: 'bool', defVal: false},
  136. {name: 'snapToPoint', dispName: 'Snap to Point', type: 'bool', defVal: false},
  137. {name: 'perimeter', dispName: 'Perimeter', defVal: 'none', type: 'enum',
  138. enumList: [{val: 'none', dispName: 'None'},
  139. {val: 'rectanglePerimeter', dispName: 'Rectangle'}, {val: 'ellipsePerimeter', dispName: 'Ellipse'},
  140. {val: 'rhombusPerimeter', dispName: 'Rhombus'}, {val: 'trianglePerimeter', dispName: 'Triangle'},
  141. {val: 'hexagonPerimeter2', dispName: 'Hexagon'}, {val: 'lifelinePerimeter', dispName: 'Lifeline'},
  142. {val: 'orthogonalPerimeter', dispName: 'Orthogonal'}, {val: 'backbonePerimeter', dispName: 'Backbone'},
  143. {val: 'calloutPerimeter', dispName: 'Callout'}, {val: 'parallelogramPerimeter', dispName: 'Parallelogram'},
  144. {val: 'trapezoidPerimeter', dispName: 'Trapezoid'}, {val: 'stepPerimeter', dispName: 'Step'}]
  145. },
  146. {name: 'fixDash', dispName: 'Fixed Dash', type: 'bool', defVal: false},
  147. {name: 'jiggle', dispName: 'Jiggle', type: 'float', min: 0, defVal: 1.5, isVisible: function(state)
  148. {
  149. return mxUtils.getValue(state.style, 'comic', '0') == '1';
  150. }},
  151. {name: 'autosize', dispName: 'Autosize', type: 'bool', defVal: false},
  152. {name: 'collapsible', dispName: 'Collapsible', type: 'bool', defVal: false},
  153. {name: 'container', dispName: 'Container', type: 'bool', defVal: false},
  154. {name: 'recursiveResize', dispName: 'Resize Children', type: 'bool', defVal: true},
  155. {name: 'part', dispName: 'Part', type: 'bool', defVal: false},
  156. {name: 'editable', dispName: 'Editable', type: 'bool', defVal: true},
  157. {name: 'backgroundOutline', dispName: 'Background Outline', type: 'bool', defVal: false},
  158. {name: 'movable', dispName: 'Movable', type: 'bool', defVal: true},
  159. {name: 'resizable', dispName: 'Resizable', type: 'bool', defVal: true},
  160. {name: 'resizeWidth', dispName: 'Resize Width', type: 'bool', defVal: false},
  161. {name: 'resizeHeight', dispName: 'Resize Height', type: 'bool', defVal: false},
  162. {name: 'rotatable', dispName: 'Rotatable', type: 'bool', defVal: true},
  163. {name: 'cloneable', dispName: 'Cloneable', type: 'bool', defVal: true},
  164. {name: 'deletable', dispName: 'Deletable', type: 'bool', defVal: true}
  165. ];
  166. /**
  167. * Default value for the CSV import dialog.
  168. */
  169. Editor.defaultCsvValue = '##\n' +
  170. '## Example CSV import. Use ## for comments and # for configuration. Paste CSV below.\n' +
  171. '## The following names are reserved and should not be used (or ignored):\n' +
  172. '## id, tooltip, placeholder(s), link and label (see below)\n' +
  173. '##\n' +
  174. '#\n' +
  175. '## Node label with placeholders and HTML.\n' +
  176. '## Default is \'%name_of_first_column%\'.\n' +
  177. '#\n' +
  178. '# label: %name%<br><i style="color:gray;">%position%</i><br><a href="mailto:%email%">Email</a>\n' +
  179. '#\n' +
  180. '## Node style (placeholders are replaced once).\n' +
  181. '## Default is the current style for nodes.\n' +
  182. '#\n' +
  183. '# style: label;image=%image%;whiteSpace=wrap;html=1;rounded=1;fillColor=%fill%;strokeColor=%stroke%;\n' +
  184. '#\n' +
  185. '## Parent style for nodes with child nodes (placeholders are replaced once).\n' +
  186. '#\n' +
  187. '# parentstyle: swimlane;whiteSpace=wrap;html=1;childLayout=stackLayout;horizontal=1;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;\n' +
  188. '#\n' +
  189. '## Uses the given column name as the identity for cells (updates existing cells).\n' +
  190. '## Default is no identity (empty value or -).\n' +
  191. '#\n' +
  192. '# identity: -\n' +
  193. '#\n' +
  194. '## Uses the given column name as the parent reference for cells. Default is no parent (empty or -).\n' +
  195. '## The identity above is used for resolving the reference so it must be specified.\n' +
  196. '#\n' +
  197. '# parent: -\n' +
  198. '#\n' +
  199. '## Adds a prefix to the identity of cells to make sure they do not collide with existing cells (whose\n' +
  200. '## IDs are numbers from 0..n, sometimes with a GUID prefix in the context of realtime collaboration).\n' +
  201. '## Default is csvimport-.\n' +
  202. '#\n' +
  203. '# namespace: csvimport-\n' +
  204. '#\n' +
  205. '## Connections between rows ("from": source colum, "to": target column).\n' +
  206. '## Label, style and invert are optional. Defaults are \'\', current style and false.\n' +
  207. '## In addition to label, an optional fromlabel and tolabel can be used to name the column\n' +
  208. '## that contains the text for the label in the edges source or target (invert ignored).\n' +
  209. '## The label is concatenated in the form fromlabel + label + tolabel if all are defined.\n' +
  210. '## The target column may contain a comma-separated list of values.\n' +
  211. '## Multiple connect entries are allowed.\n' +
  212. '#\n' +
  213. '# connect: {"from": "manager", "to": "name", "invert": true, "label": "manages", \\\n' +
  214. '# "style": "curved=1;endArrow=blockThin;endFill=1;fontSize=11;"}\n' +
  215. '# connect: {"from": "refs", "to": "id", "style": "curved=1;fontSize=11;"}\n' +
  216. '#\n' +
  217. '## Node x-coordinate. Possible value is a column name. Default is empty. Layouts will\n' +
  218. '## override this value.\n' +
  219. '#\n' +
  220. '# left: \n' +
  221. '#\n' +
  222. '## Node y-coordinate. Possible value is a column name. Default is empty. Layouts will\n' +
  223. '## override this value.\n' +
  224. '#\n' +
  225. '# top: \n' +
  226. '#\n' +
  227. '## Node width. Possible value is a number (in px), auto or an @ sign followed by a column\n' +
  228. '## name that contains the value for the width. Default is auto.\n' +
  229. '#\n' +
  230. '# width: auto\n' +
  231. '#\n' +
  232. '## Node height. Possible value is a number (in px), auto or an @ sign followed by a column\n' +
  233. '## name that contains the value for the height. Default is auto.\n' +
  234. '#\n' +
  235. '# height: auto\n' +
  236. '#\n' +
  237. '## Padding for autosize. Default is 0.\n' +
  238. '#\n' +
  239. '# padding: -12\n' +
  240. '#\n' +
  241. '## Comma-separated list of ignored columns for metadata. (These can be\n' +
  242. '## used for connections and styles but will not be added as metadata.)\n' +
  243. '#\n' +
  244. '# ignore: id,image,fill,stroke\n' +
  245. '#\n' +
  246. '## Column to be renamed to link attribute (used as link).\n' +
  247. '#\n' +
  248. '# link: url\n' +
  249. '#\n' +
  250. '## Spacing between nodes. Default is 40.\n' +
  251. '#\n' +
  252. '# nodespacing: 40\n' +
  253. '#\n' +
  254. '## Spacing between levels of hierarchical layouts. Default is 100.\n' +
  255. '#\n' +
  256. '# levelspacing: 100\n' +
  257. '#\n' +
  258. '## Spacing between parallel edges. Default is 40.\n' +
  259. '#\n' +
  260. '# edgespacing: 40\n' +
  261. '#\n' +
  262. '## Name of layout. Possible values are auto, none, verticaltree, horizontaltree,\n' +
  263. '## verticalflow, horizontalflow, organic, circle. Default is auto.\n' +
  264. '#\n' +
  265. '# layout: auto\n' +
  266. '#\n' +
  267. '## ---- CSV below this line. First line are column names. ----\n' +
  268. 'name,position,id,location,manager,email,fill,stroke,refs,url,image\n' +
  269. 'Evan Miller,CFO,emi,Office 1,,me@example.com,#dae8fc,#6c8ebf,,https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-9-2-128.png\n' +
  270. 'Edward Morrison,Brand Manager,emo,Office 2,Evan Miller,me@example.com,#d5e8d4,#82b366,,https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-10-3-128.png\n' +
  271. 'Ron Donovan,System Admin,rdo,Office 3,Evan Miller,me@example.com,#d5e8d4,#82b366,"emo,tva",https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-2-128.png\n' +
  272. 'Tessa Valet,HR Director,tva,Office 4,Evan Miller,me@example.com,#d5e8d4,#82b366,,https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-3-128.png\n';
  273. /**
  274. * Disables the shadow option in the format panel.
  275. */
  276. Editor.shadowOptionEnabled = true;
  277. /**
  278. * Reference to the config object passed to <configure>.
  279. */
  280. Editor.config = null;
  281. /**
  282. * Reference to the version of the last config object in
  283. * <configure>. If this is different to the last version in
  284. * mxSettings.parse, then the settings are reset.
  285. */
  286. Editor.configVersion = null;
  287. /**
  288. * Global configuration of the Editor
  289. * see https://desk.draw.io/solution/articles/16000058316
  290. *
  291. * For defaultVertexStyle, defaultEdgeStyle and defaultLibraries, this must be called before
  292. * mxSettings.load via global config variable window.mxLoadSettings = false.
  293. */
  294. Editor.configure = function(config, untrusted)
  295. {
  296. if (config != null)
  297. {
  298. Editor.config = config;
  299. Editor.configVersion = config.version;
  300. Menus.prototype.defaultFonts = config.defaultFonts || Menus.prototype.defaultFonts;
  301. ColorDialog.prototype.presetColors = config.presetColors || ColorDialog.prototype.presetColors;
  302. ColorDialog.prototype.defaultColors = config.defaultColors || ColorDialog.prototype.defaultColors;
  303. StyleFormatPanel.prototype.defaultColorSchemes = config.defaultColorSchemes || StyleFormatPanel.prototype.defaultColorSchemes;
  304. Graph.prototype.defaultEdgeLength = config.defaultEdgeLength || Graph.prototype.defaultEdgeLength;
  305. if (config.templateFile != null)
  306. {
  307. EditorUi.templateFile = config.templateFile;
  308. }
  309. if (config.customFonts)
  310. {
  311. Menus.prototype.defaultFonts = config.customFonts.
  312. concat(Menus.prototype.defaultFonts);
  313. }
  314. if (config.customPresetColors)
  315. {
  316. ColorDialog.prototype.presetColors = config.customPresetColors.
  317. concat(ColorDialog.prototype.presetColors);
  318. }
  319. if (config.customColorSchemes != null)
  320. {
  321. StyleFormatPanel.prototype.defaultColorSchemes = config.customColorSchemes.
  322. concat(StyleFormatPanel.prototype.defaultColorSchemes);
  323. }
  324. // Custom CSS injected directly into the page
  325. if (config.css != null)
  326. {
  327. var s = document.createElement('style');
  328. s.setAttribute('type', 'text/css');
  329. s.appendChild(document.createTextNode(config.css));
  330. var t = document.getElementsByTagName('script')[0];
  331. t.parentNode.insertBefore(s, t);
  332. }
  333. // Configures the custom libraries
  334. if (config.libraries != null)
  335. {
  336. Sidebar.prototype.customEntries = config.libraries;
  337. }
  338. // Defines the enabled built-in libraries.
  339. if (config.enabledLibraries != null)
  340. {
  341. Sidebar.prototype.enabledLibraries = config.enabledLibraries;
  342. }
  343. // Overrides default libraries
  344. if (config.defaultLibraries != null)
  345. {
  346. Sidebar.prototype.defaultEntries = config.defaultLibraries;
  347. }
  348. // Overrides default custom libraries
  349. if (config.defaultCustomLibraries != null)
  350. {
  351. Editor.defaultCustomLibraries = config.defaultCustomLibraries;
  352. }
  353. // Disables custom libraries
  354. if (config.enableCustomLibraries != null)
  355. {
  356. Editor.enableCustomLibraries = config.enableCustomLibraries;
  357. }
  358. // Overrides default vertex style
  359. if (config.defaultVertexStyle != null)
  360. {
  361. Graph.prototype.defaultVertexStyle = config.defaultVertexStyle;
  362. }
  363. // Overrides default edge style
  364. if (config.defaultEdgeStyle != null)
  365. {
  366. Graph.prototype.defaultEdgeStyle = config.defaultEdgeStyle;
  367. }
  368. if (config.emptyDiagramXml)
  369. {
  370. EditorUi.prototype.emptyDiagramXml = config.emptyDiagramXml;
  371. }
  372. if (config.thumbWidth)
  373. {
  374. Sidebar.prototype.thumbWidth = config.thumbWidth;
  375. }
  376. if (config.thumbHeight)
  377. {
  378. Sidebar.prototype.thumbHeight = config.thumbHeight;
  379. }
  380. if (config.emptyLibraryXml)
  381. {
  382. EditorUi.prototype.emptyLibraryXml = config.emptyLibraryXml;
  383. }
  384. if (config.sidebarWidth)
  385. {
  386. EditorUi.prototype.hsplitPosition = config.sidebarWidth;
  387. }
  388. if (config.fontCss)
  389. {
  390. var s = document.createElement('style');
  391. s.setAttribute('type', 'text/css');
  392. s.appendChild(document.createTextNode(config.fontCss));
  393. var t = document.getElementsByTagName('script')[0];
  394. t.parentNode.insertBefore(s, t);
  395. Editor.prototype.fontCss = config.fontCss;
  396. }
  397. if (config.plugins != null && !untrusted)
  398. {
  399. // Required for callback
  400. App.initPluginCallback();
  401. for (var i = 0; i < config.plugins.length; i++)
  402. {
  403. mxscript(config.plugins[i]);
  404. }
  405. }
  406. }
  407. };
  408. /**
  409. * Generates a unique ID of the given length
  410. */
  411. Editor.GUID_ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_';
  412. /**
  413. * Generates a unique ID of the given length
  414. */
  415. Editor.GUID_LENGTH = 20;
  416. /**
  417. * Generates a unique ID of the given length
  418. */
  419. Editor.guid = function(length)
  420. {
  421. var len = (length != null) ? length : Editor.GUID_LENGTH;
  422. var rtn = [];
  423. for (var i = 0; i < len; i++)
  424. {
  425. rtn.push(Editor.GUID_ALPHABET.charAt(Math.floor(Math.random() * Editor.GUID_ALPHABET.length)));
  426. }
  427. return rtn.join('');
  428. };
  429. /**
  430. * This should not be enabled if reflows are required for math rendering.
  431. */
  432. Editor.prototype.useForeignObjectForMath = false;
  433. /**
  434. * Executes the first step for connecting to Google Drive.
  435. */
  436. Editor.prototype.editButtonLink = (urlParams['edit'] != null) ? decodeURIComponent(urlParams['edit']) : null;
  437. /**
  438. * Adds support for old stylesheets and compressed files
  439. */
  440. var editorSetGraphXml = Editor.prototype.setGraphXml;
  441. Editor.prototype.setGraphXml = function(node)
  442. {
  443. node = (node != null && node.nodeName != 'mxlibrary') ? this.extractGraphModel(node) : null;
  444. if (node != null)
  445. {
  446. // Checks input for parser errors
  447. var errs = node.getElementsByTagName('parsererror');
  448. if (errs != null && errs.length > 0)
  449. {
  450. var elt = errs[0];
  451. var divs = elt.getElementsByTagName('div');
  452. if (divs != null && divs.length > 0)
  453. {
  454. elt = divs[0];
  455. }
  456. throw {message: mxUtils.getTextContent(elt)};
  457. }
  458. else if (node.nodeName == 'mxGraphModel')
  459. {
  460. var style = node.getAttribute('style') || 'default-style2';
  461. // Decodes the style if required
  462. if (urlParams['embed'] != '1' && (style == null || style == ''))
  463. {
  464. var node2 = (this.graph.themes != null) ?
  465. this.graph.themes['default-old'] :
  466. mxUtils.load(STYLE_PATH + '/default-old.xml').getDocumentElement();
  467. if (node2 != null)
  468. {
  469. var dec2 = new mxCodec(node2.ownerDocument);
  470. dec2.decode(node2, this.graph.getStylesheet());
  471. }
  472. }
  473. else if (style != this.graph.currentStyle)
  474. {
  475. var node2 = (this.graph.themes != null) ?
  476. this.graph.themes[style] :
  477. mxUtils.load(STYLE_PATH + '/' + style + '.xml').getDocumentElement()
  478. if (node2 != null)
  479. {
  480. var dec2 = new mxCodec(node2.ownerDocument);
  481. dec2.decode(node2, this.graph.getStylesheet());
  482. }
  483. }
  484. this.graph.currentStyle = style;
  485. this.graph.mathEnabled = (urlParams['math'] == '1' || node.getAttribute('math') == '1');
  486. var bgImg = node.getAttribute('backgroundImage');
  487. if (bgImg != null)
  488. {
  489. bgImg = JSON.parse(bgImg);
  490. this.graph.setBackgroundImage(new mxImage(bgImg.src, bgImg.width, bgImg.height));
  491. }
  492. else
  493. {
  494. this.graph.setBackgroundImage(null);
  495. }
  496. mxClient.NO_FO = ((this.graph.mathEnabled && !this.useForeignObjectForMath)) ?
  497. true : this.originalNoForeignObject;
  498. this.graph.useCssTransforms = !mxClient.NO_FO &&
  499. this.isChromelessView() &&
  500. this.graph.isCssTransformsSupported();
  501. this.graph.updateCssTransform();
  502. this.graph.setShadowVisible(node.getAttribute('shadow') == '1', false);
  503. }
  504. // Calls updateGraphComponents
  505. editorSetGraphXml.apply(this, arguments);
  506. }
  507. else
  508. {
  509. throw {
  510. message: mxResources.get('notADiagramFile') || 'Invalid data',
  511. toString: function() { return this.message; }
  512. };
  513. }
  514. };
  515. /**
  516. * Adds persistent style to file
  517. */
  518. var editorGetGraphXml = Editor.prototype.getGraphXml;
  519. Editor.prototype.getGraphXml = function(ignoreSelection)
  520. {
  521. ignoreSelection = (ignoreSelection != null) ? ignoreSelection : true;
  522. var node = editorGetGraphXml.apply(this, arguments);
  523. // Adds the current style
  524. if (this.graph.currentStyle != null && this.graph.currentStyle != 'default-style2')
  525. {
  526. node.setAttribute('style', this.graph.currentStyle);
  527. }
  528. // Adds the background image
  529. if (this.graph.backgroundImage != null)
  530. {
  531. node.setAttribute('backgroundImage', JSON.stringify(this.graph.backgroundImage));
  532. }
  533. node.setAttribute('math', (this.graph.mathEnabled) ? '1' : '0');
  534. node.setAttribute('shadow', (this.graph.shadowVisible) ? '1' : '0');
  535. return node;
  536. };
  537. /**
  538. * Helper function to extract the graph model XML node.
  539. */
  540. Editor.prototype.isDataSvg = function(svg)
  541. {
  542. try
  543. {
  544. var svgRoot = mxUtils.parseXml(svg).documentElement;
  545. var tmp = svgRoot.getAttribute('content');
  546. if (tmp != null)
  547. {
  548. if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
  549. {
  550. tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
  551. }
  552. if (tmp != null && tmp.charAt(0) == '%')
  553. {
  554. tmp = decodeURIComponent(tmp);
  555. }
  556. if (tmp != null && tmp.length > 0)
  557. {
  558. var node = mxUtils.parseXml(tmp).documentElement;
  559. return node.nodeName == 'mxfile' || node.nodeName == 'mxGraphModel';
  560. }
  561. }
  562. }
  563. catch (e)
  564. {
  565. // ignore
  566. }
  567. return false;
  568. };
  569. /**
  570. * Helper function to extract the graph model XML node.
  571. */
  572. Editor.prototype.extractGraphModel = function(node, allowMxFile)
  573. {
  574. if (node != null && typeof(pako) !== 'undefined')
  575. {
  576. var tmp = node.ownerDocument.getElementsByTagName('div');
  577. var divs = [];
  578. if (tmp != null && tmp.length > 0)
  579. {
  580. for (var i = 0; i < tmp.length; i++)
  581. {
  582. if (tmp[i].getAttribute('class') == 'mxgraph')
  583. {
  584. divs.push(tmp[i]);
  585. break;
  586. }
  587. }
  588. }
  589. if (divs.length > 0)
  590. {
  591. var data = divs[0].getAttribute('data-mxgraph');
  592. if (data != null)
  593. {
  594. var config = JSON.parse(data);
  595. if (config != null && config.xml != null)
  596. {
  597. var doc2 = mxUtils.parseXml(config.xml);
  598. node = doc2.documentElement;
  599. }
  600. }
  601. else
  602. {
  603. var divs2 = divs[0].getElementsByTagName('div');
  604. if (divs2.length > 0)
  605. {
  606. var data = mxUtils.getTextContent(divs2[0]);
  607. data = this.graph.decompress(data);
  608. if (data.length > 0)
  609. {
  610. var doc2 = mxUtils.parseXml(data);
  611. node = doc2.documentElement;
  612. }
  613. }
  614. }
  615. }
  616. }
  617. if (node != null && node.nodeName == 'svg')
  618. {
  619. var tmp = node.getAttribute('content');
  620. if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
  621. {
  622. tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
  623. }
  624. if (tmp != null && tmp.charAt(0) == '%')
  625. {
  626. tmp = decodeURIComponent(tmp);
  627. }
  628. if (tmp != null && tmp.length > 0)
  629. {
  630. node = mxUtils.parseXml(tmp).documentElement;
  631. }
  632. else
  633. {
  634. throw {message: mxResources.get('notADiagramFile')};
  635. }
  636. }
  637. if (node != null && !allowMxFile)
  638. {
  639. var diagramNode = null;
  640. if (node.nodeName == 'diagram')
  641. {
  642. diagramNode = node;
  643. }
  644. else if (node.nodeName == 'mxfile')
  645. {
  646. var diagrams = node.getElementsByTagName('diagram');
  647. if (diagrams.length > 0)
  648. {
  649. diagramNode = diagrams[Math.max(0, Math.min(diagrams.length - 1, urlParams['page'] || 0))];
  650. }
  651. }
  652. if (diagramNode != null)
  653. {
  654. var tmp = this.graph.decompress(mxUtils.getTextContent(diagramNode));
  655. if (tmp != null && tmp.length > 0)
  656. {
  657. node = mxUtils.parseXml(tmp).documentElement;
  658. }
  659. }
  660. }
  661. if (node != null && node.nodeName != 'mxGraphModel' && (!allowMxFile || node.nodeName != 'mxfile'))
  662. {
  663. node = null;
  664. }
  665. return node;
  666. };
  667. /**
  668. * Overrides reset graph.
  669. */
  670. var editorResetGraph = Editor.prototype.resetGraph;
  671. Editor.prototype.resetGraph = function()
  672. {
  673. this.graph.mathEnabled = (urlParams['math'] == '1');
  674. this.graph.view.x0 = null;
  675. this.graph.view.y0 = null;
  676. mxClient.NO_FO = ((this.graph.mathEnabled && !this.useForeignObjectForMath)) ?
  677. true : this.originalNoForeignObject;
  678. this.graph.useCssTransforms = !mxClient.NO_FO &&
  679. this.isChromelessView() &&
  680. this.graph.isCssTransformsSupported();
  681. this.graph.updateCssTransform();
  682. editorResetGraph.apply(this, arguments);
  683. };
  684. /**
  685. * Math support.
  686. */
  687. var editorUpdateGraphComponents = Editor.prototype.updateGraphComponents;
  688. Editor.prototype.updateGraphComponents = function()
  689. {
  690. editorUpdateGraphComponents.apply(this, arguments);
  691. mxClient.NO_FO = ((this.graph.mathEnabled && !this.useForeignObjectForMath) &&
  692. Editor.MathJaxRender != null) ? true : this.originalNoForeignObject;
  693. this.graph.useCssTransforms = !mxClient.NO_FO &&
  694. this.isChromelessView() &&
  695. this.graph.isCssTransformsSupported();
  696. this.graph.updateCssTransform();
  697. };
  698. /**
  699. * Initializes math typesetting and loads respective code.
  700. */
  701. Editor.initMath = function(src, config)
  702. {
  703. src = (src != null) ? src : 'https://math.draw.io/current/MathJax.js?config=TeX-MML-AM_HTMLorMML';
  704. Editor.mathJaxQueue = [];
  705. Editor.doMathJaxRender = function(container)
  706. {
  707. window.setTimeout(function()
  708. {
  709. if (container.style.visibility != 'hidden')
  710. {
  711. MathJax.Hub.Queue(['Typeset', MathJax.Hub, container]);
  712. }
  713. }, 0);
  714. };
  715. // Disables global typesetting and messages on startup, adds queue for
  716. // asynchronous rendering while MathJax is loading
  717. window.MathJax =
  718. {
  719. skipStartupTypeset: true,
  720. showMathMenu: false,
  721. messageStyle: 'none',
  722. AuthorInit: function ()
  723. {
  724. // Specification recommends using SVG over HTML-CSS if browser is known
  725. // Check if too inconsistent with image export and print output
  726. MathJax.Hub.Config(config || {
  727. jax: ['input/TeX', 'input/MathML', 'input/AsciiMath', 'output/HTML-CSS'],
  728. extensions: ['tex2jax.js', 'mml2jax.js', 'asciimath2jax.js'],
  729. 'HTML-CSS': {
  730. imageFont: null
  731. },
  732. TeX: {
  733. extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
  734. },
  735. // Ignores math in in-place editor
  736. tex2jax: {
  737. ignoreClass: 'mxCellEditor'
  738. },
  739. asciimath2jax: {
  740. ignoreClass: 'mxCellEditor'
  741. }
  742. });
  743. MathJax.Hub.Register.StartupHook('Begin', function()
  744. {
  745. for (var i = 0; i < Editor.mathJaxQueue.length; i++)
  746. {
  747. Editor.doMathJaxRender(Editor.mathJaxQueue[i]);
  748. }
  749. });
  750. }
  751. };
  752. // Adds global enqueue method for async rendering
  753. Editor.MathJaxRender = function(container)
  754. {
  755. // Initial rendering when MathJax finished loading
  756. if (typeof(MathJax) !== 'undefined' && typeof(MathJax.Hub) !== 'undefined')
  757. {
  758. Editor.doMathJaxRender(container);
  759. }
  760. else
  761. {
  762. Editor.mathJaxQueue.push(container);
  763. }
  764. };
  765. // Adds global clear queue method
  766. Editor.MathJaxClear = function()
  767. {
  768. Editor.mathJaxQueue = [];
  769. };
  770. // Updates typeset after changes
  771. var editorInit = Editor.prototype.init;
  772. Editor.prototype.init = function()
  773. {
  774. editorInit.apply(this, arguments);
  775. this.graph.addListener(mxEvent.SIZE, mxUtils.bind(this, function(sender, evt)
  776. {
  777. if (this.graph.container != null && this.graph.mathEnabled)
  778. {
  779. Editor.MathJaxRender(this.graph.container);
  780. }
  781. }));
  782. };
  783. var tags = document.getElementsByTagName('script');
  784. if (tags != null && tags.length > 0)
  785. {
  786. var script = document.createElement('script');
  787. script.type = 'text/javascript';
  788. script.src = src;
  789. tags[0].parentNode.appendChild(script);
  790. }
  791. };
  792. /**
  793. * Return array of string values, or NULL if CSV string not well formed.
  794. */
  795. Editor.prototype.csvToArray = function(text)
  796. {
  797. var re_valid = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/;
  798. var re_value = /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g;
  799. // Return NULL if input string is not well formed CSV string.
  800. if (!re_valid.test(text)) return null;
  801. var a = []; // Initialize array to receive values.
  802. text.replace(re_value, // "Walk" the string using replace with callback.
  803. function(m0, m1, m2, m3) {
  804. // Remove backslash from \' in single quoted values.
  805. if (m1 !== undefined) a.push(m1.replace(/\\'/g, "'"));
  806. // Remove backslash from \" in double quoted values.
  807. else if (m2 !== undefined) a.push(m2.replace(/\\"/g, '"'));
  808. else if (m3 !== undefined) a.push(m3);
  809. return ''; // Return empty string.
  810. });
  811. // Handle special case of empty last value.
  812. if (/,\s*$/.test(text)) a.push('');
  813. return a;
  814. };
  815. /**
  816. * Adds persistence for recent colors
  817. */
  818. if (window.ColorDialog)
  819. {
  820. var colorDialogAddRecentColor = ColorDialog.addRecentColor;
  821. ColorDialog.addRecentColor = function(color, max)
  822. {
  823. colorDialogAddRecentColor.apply(this, arguments);
  824. mxSettings.setRecentColors(ColorDialog.recentColors);
  825. mxSettings.save();
  826. };
  827. var colorDialogResetRecentColors = ColorDialog.resetRecentColors;
  828. ColorDialog.resetRecentColors = function()
  829. {
  830. colorDialogResetRecentColors.apply(this, arguments);
  831. mxSettings.setRecentColors(ColorDialog.recentColors);
  832. mxSettings.save();
  833. };
  834. }
  835. // Overrides ID for pages
  836. if (window.EditDataDialog)
  837. {
  838. EditDataDialog.getDisplayIdForCell = function(ui, cell)
  839. {
  840. var id = null;
  841. if (ui.editor.graph.getModel().getParent(cell) != null)
  842. {
  843. id = cell.getId();
  844. }
  845. else if (ui.currentPage != null)
  846. {
  847. id = ui.currentPage.getId();
  848. }
  849. return id;
  850. };
  851. }
  852. var AddCustomPropertyDialog = function(editorUi, callback)
  853. {
  854. var row, td;
  855. var table = document.createElement('table');
  856. var tbody = document.createElement('tbody');
  857. table.setAttribute('cellpadding', (mxClient.IS_SF) ? '0' : '2');
  858. row = document.createElement('tr');
  859. td = document.createElement('td');
  860. td.style.fontSize = '10pt';
  861. td.style.width = '100px';
  862. mxUtils.write(td, mxResources.get('name', null, 'Name') + ':');
  863. row.appendChild(td);
  864. var nameInput = document.createElement('input');
  865. nameInput.style.width = '180px';
  866. td = document.createElement('td');
  867. td.appendChild(nameInput);
  868. row.appendChild(td);
  869. tbody.appendChild(row);
  870. row = document.createElement('tr');
  871. td = document.createElement('td');
  872. td.style.fontSize = '10pt';
  873. mxUtils.write(td, mxResources.get('type', null, 'Type') + ':');
  874. row.appendChild(td);
  875. var typeSelect = document.createElement('select');
  876. typeSelect.style.width = '180px';
  877. var boolOption = document.createElement('option');
  878. boolOption.setAttribute('value', 'bool');
  879. mxUtils.write(boolOption, mxResources.get('bool', null, 'Boolean'));
  880. typeSelect.appendChild(boolOption);
  881. var clrOption = document.createElement('option');
  882. clrOption.setAttribute('value', 'color');
  883. mxUtils.write(clrOption, mxResources.get('color', null, 'Color'));
  884. typeSelect.appendChild(clrOption);
  885. var enumOption = document.createElement('option');
  886. enumOption.setAttribute('value', 'enum');
  887. mxUtils.write(enumOption, mxResources.get('enum', null, 'Enumeration'));
  888. typeSelect.appendChild(enumOption);
  889. var floatOption = document.createElement('option');
  890. floatOption.setAttribute('value', 'float');
  891. mxUtils.write(floatOption, mxResources.get('float', null, 'Float'));
  892. typeSelect.appendChild(floatOption);
  893. var intOption = document.createElement('option');
  894. intOption.setAttribute('value', 'int');
  895. mxUtils.write(intOption, mxResources.get('int', null, 'Int'));
  896. typeSelect.appendChild(intOption);
  897. var strOption = document.createElement('option');
  898. strOption.setAttribute('value', 'string');
  899. mxUtils.write(strOption, mxResources.get('string', null, 'String'));
  900. typeSelect.appendChild(strOption);
  901. td = document.createElement('td');
  902. td.appendChild(typeSelect);
  903. row.appendChild(td);
  904. tbody.appendChild(row);
  905. row = document.createElement('tr');
  906. td = document.createElement('td');
  907. td.style.fontSize = '10pt';
  908. mxUtils.write(td, mxResources.get('dispName', null, 'Display Name') + ':');
  909. row.appendChild(td);
  910. var dispNameInput = document.createElement('input');
  911. dispNameInput.style.width = '180px';
  912. td = document.createElement('td');
  913. td.appendChild(dispNameInput);
  914. row.appendChild(td);
  915. tbody.appendChild(row);
  916. var listRow = document.createElement('tr');
  917. td = document.createElement('td');
  918. td.style.fontSize = '10pt';
  919. mxUtils.write(td, mxResources.get('enumList', null, 'Enum List') + ' (csv):');
  920. listRow.appendChild(td);
  921. var enumListInput = document.createElement('input');
  922. enumListInput.style.width = '180px';
  923. td = document.createElement('td');
  924. td.appendChild(enumListInput);
  925. listRow.appendChild(td);
  926. listRow.style.display = 'none';
  927. tbody.appendChild(listRow);
  928. table.appendChild(tbody);
  929. function typeChanged()
  930. {
  931. if (typeSelect.value === 'enum')
  932. {
  933. listRow.style.display = '';
  934. this.container.parentNode.style.height = "150px";
  935. }
  936. else
  937. {
  938. listRow.style.display = 'none';
  939. this.container.parentNode.style.height = "130px";
  940. }
  941. };
  942. mxEvent.addListener(typeSelect, 'change', mxUtils.bind(this, typeChanged));
  943. row = document.createElement('tr');
  944. td = document.createElement('td');
  945. td.setAttribute('align', 'right');
  946. td.style.paddingTop = '22px';
  947. td.colSpan = 2;
  948. var addBtn = mxUtils.button(mxResources.get('add', null, 'Add'), mxUtils.bind(this, function()
  949. {
  950. var name = nameInput.value;
  951. if (name == "")
  952. {
  953. nameInput.style.border = "1px solid red";
  954. return;
  955. }
  956. var type = typeSelect.value;
  957. var dispName = dispNameInput.value;
  958. if (dispName == "")
  959. {
  960. dispNameInput.style.border = "1px solid red";
  961. return;
  962. }
  963. var enumList = enumListInput.value;
  964. if (enumList == "" && type == "enum")
  965. {
  966. enumListInput.style.border = "1px solid red";
  967. return;
  968. }
  969. if (enumList != null)
  970. {
  971. enumList = enumList.split(',');
  972. for (var i = 0; i < enumList.length; i++)
  973. {
  974. enumList[i] = enumList[i].trim();
  975. }
  976. }
  977. if (callback)
  978. {
  979. callback(editorUi, name, type, dispName, enumList);
  980. editorUi.hideDialog();
  981. }
  982. }));
  983. addBtn.className = 'geBtn gePrimaryBtn';
  984. var cancelBtn = mxUtils.button(mxResources.get('cancel'), function()
  985. {
  986. editorUi.hideDialog();
  987. });
  988. cancelBtn.className = 'geBtn';
  989. if (editorUi.editor.cancelFirst)
  990. {
  991. td.appendChild(cancelBtn);
  992. td.appendChild(addBtn);
  993. }
  994. else
  995. {
  996. td.appendChild(addBtn);
  997. td.appendChild(cancelBtn);
  998. }
  999. row.appendChild(td);
  1000. tbody.appendChild(row);
  1001. table.appendChild(tbody);
  1002. this.container = table;
  1003. };
  1004. if (window.StyleFormatPanel != null)
  1005. {
  1006. var formatInit = Format.prototype.init;
  1007. Format.prototype.init = function()
  1008. {
  1009. formatInit.apply(this, arguments);
  1010. this.editorUi.editor.addListener('fileLoaded', this.update);
  1011. };
  1012. var formatRefresh = Format.prototype.refresh;
  1013. Format.prototype.refresh = function()
  1014. {
  1015. if (this.editorUi.getCurrentFile() != null || urlParams['embed'] == '1' ||
  1016. this.editorUi.editor.chromeless)
  1017. {
  1018. formatRefresh.apply(this, arguments);
  1019. }
  1020. else
  1021. {
  1022. this.clear();
  1023. }
  1024. };
  1025. /**
  1026. * Hook for subclassers.
  1027. */
  1028. DiagramFormatPanel.prototype.isShadowOptionVisible = function()
  1029. {
  1030. var file = this.editorUi.getCurrentFile();
  1031. return urlParams['embed'] == '1' || (file != null && file.isEditable());
  1032. };
  1033. /**
  1034. * Option is not visible in default theme.
  1035. */
  1036. DiagramFormatPanel.prototype.isMathOptionVisible = function(div)
  1037. {
  1038. return false;
  1039. };
  1040. /**
  1041. * Add global shadow option.
  1042. */
  1043. var diagramFormatPanelAddView = DiagramFormatPanel.prototype.addView;
  1044. DiagramFormatPanel.prototype.addView = function(div)
  1045. {
  1046. var div = diagramFormatPanelAddView.apply(this, arguments);
  1047. var file = this.editorUi.getCurrentFile();
  1048. if (mxClient.IS_SVG && this.isShadowOptionVisible())
  1049. {
  1050. var ui = this.editorUi;
  1051. var editor = ui.editor;
  1052. var graph = editor.graph;
  1053. var option = this.createOption(mxResources.get('shadow'), function()
  1054. {
  1055. return graph.shadowVisible;
  1056. }, function(checked)
  1057. {
  1058. var change = new ChangePageSetup(ui);
  1059. change.ignoreColor = true;
  1060. change.ignoreImage = true;
  1061. change.shadowVisible = checked;
  1062. graph.model.execute(change);
  1063. },
  1064. {
  1065. install: function(apply)
  1066. {
  1067. this.listener = function()
  1068. {
  1069. apply(graph.shadowVisible);
  1070. };
  1071. ui.addListener('shadowVisibleChanged', this.listener);
  1072. },
  1073. destroy: function()
  1074. {
  1075. ui.removeListener(this.listener);
  1076. }
  1077. });
  1078. if (!Editor.shadowOptionEnabled)
  1079. {
  1080. option.getElementsByTagName('input')[0].setAttribute('disabled', 'disabled');
  1081. mxUtils.setOpacity(option, 60);
  1082. }
  1083. div.appendChild(option);
  1084. }
  1085. return div;
  1086. };
  1087. /**
  1088. * Adds autosave and math typesetting options.
  1089. */
  1090. var diagramFormatPanelAddOptions = DiagramFormatPanel.prototype.addOptions;
  1091. DiagramFormatPanel.prototype.addOptions = function(div)
  1092. {
  1093. div = diagramFormatPanelAddOptions.apply(this, arguments);
  1094. var ui = this.editorUi;
  1095. var editor = ui.editor;
  1096. var graph = editor.graph;
  1097. if (graph.isEnabled())
  1098. {
  1099. var file = ui.getCurrentFile();
  1100. if (file != null && file.isAutosaveOptional())
  1101. {
  1102. var opt = this.createOption(mxResources.get('autosave'), function()
  1103. {
  1104. return ui.editor.autosave;
  1105. }, function(checked)
  1106. {
  1107. ui.editor.setAutosave(checked);
  1108. },
  1109. {
  1110. install: function(apply)
  1111. {
  1112. this.listener = function()
  1113. {
  1114. apply(ui.editor.autosave);
  1115. };
  1116. ui.editor.addListener('autosaveChanged', this.listener);
  1117. },
  1118. destroy: function()
  1119. {
  1120. ui.editor.removeListener(this.listener);
  1121. }
  1122. });
  1123. div.appendChild(opt);
  1124. }
  1125. }
  1126. if (this.isMathOptionVisible() && graph.isEnabled() && typeof(MathJax) !== 'undefined')
  1127. {
  1128. // Math
  1129. var option = this.createOption(mxResources.get('mathematicalTypesetting'), function()
  1130. {
  1131. return graph.mathEnabled;
  1132. }, function(checked)
  1133. {
  1134. ui.actions.get('mathematicalTypesetting').funct();
  1135. },
  1136. {
  1137. install: function(apply)
  1138. {
  1139. this.listener = function()
  1140. {
  1141. apply(graph.mathEnabled);
  1142. };
  1143. ui.addListener('mathEnabledChanged', this.listener);
  1144. },
  1145. destroy: function()
  1146. {
  1147. ui.removeListener(this.listener);
  1148. }
  1149. });
  1150. option.style.paddingTop = '5px';
  1151. div.appendChild(option);
  1152. var help = ui.menus.createHelpLink('https://desk.draw.io/support/solutions/articles/16000032875');
  1153. help.style.position = 'relative';
  1154. help.style.marginLeft = '6px';
  1155. help.style.top = '2px';
  1156. option.appendChild(help);
  1157. }
  1158. return div;
  1159. };
  1160. mxCellRenderer.prototype.defaultVertexShape.prototype.customProperties = [
  1161. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1162. {name: 'absoluteArcSize', dispName: 'Abs. Arc Size', type: 'bool', defVal: false}
  1163. ];
  1164. mxCellRenderer.defaultShapes['link'].prototype.customProperties = [
  1165. {name: 'width', dispName: 'Width', type: 'float', min:0, defVal: 4}
  1166. ];
  1167. mxCellRenderer.defaultShapes['flexArrow'].prototype.customProperties = [
  1168. {name: 'width', dispName: 'Width', type: 'float', min:0, defVal: 10},
  1169. {name: 'startWidth', dispName: 'Start Width', type: 'float', min:0, defVal: 20},
  1170. {name: 'endWidth', dispName: 'End Width', type: 'float', min:0, defVal: 20}
  1171. ];
  1172. mxCellRenderer.defaultShapes['process'].prototype.customProperties = [
  1173. {name: 'size', dispName: 'Indent', type: 'float', min: 0, max: 0.5, defVal: 0.1}
  1174. ];
  1175. mxCellRenderer.defaultShapes['rhombus'].prototype.customProperties = [
  1176. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, max: 50, defVal: mxConstants.LINE_ARCSIZE},
  1177. {name: 'double', dispName: 'Double', type: 'bool', defVal: false}
  1178. ];
  1179. mxCellRenderer.defaultShapes['partialRectangle'].prototype.customProperties = [
  1180. {name: 'top', dispName: 'Top Line', type: 'bool', defVal: true},
  1181. {name: 'bottom', dispName: 'Bottom Line', type: 'bool', defVal: true},
  1182. {name: 'left', dispName: 'Left Line', type: 'bool', defVal: true},
  1183. {name: 'right', dispName: 'Right Line', type: 'bool', defVal: true}
  1184. ];
  1185. mxCellRenderer.defaultShapes['parallelogram'].prototype.customProperties = [
  1186. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1187. {name: 'size', dispName: 'Slope Angle', type: 'float', min:0, max: 1, defVal: 0.2}
  1188. ];
  1189. mxCellRenderer.defaultShapes['hexagon'].prototype.customProperties = [
  1190. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1191. {name: 'size', dispName: 'Slope Angle', type: 'float', min:0, max: 1, defVal: 0.25}
  1192. ];
  1193. mxCellRenderer.defaultShapes['triangle'].prototype.customProperties = [
  1194. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE}
  1195. ];
  1196. mxCellRenderer.defaultShapes['document'].prototype.customProperties = [
  1197. {name: 'size', dispName: 'Size', type: 'float', defVal: 0.3, min:0, max:1}
  1198. ];
  1199. mxCellRenderer.defaultShapes['internalStorage'].prototype.customProperties = [
  1200. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1201. {name: 'dx', dispName: 'Left Line', type: 'float', min:0, defVal: 20},
  1202. {name: 'dy', dispName: 'Top Line', type: 'float', min:0, defVal: 20}
  1203. ];
  1204. mxCellRenderer.defaultShapes['cube'].prototype.customProperties = [
  1205. {name: 'size', dispName: 'Size', type: 'float', min:0, defVal:20 },
  1206. {name: 'darkOpacity', dispName: 'Dark Opacity', type: 'float', min:-1, max:1, defVal:0 },
  1207. {name: 'darkOpacity2', dispName: 'Dark Opacity 2', type: 'float', min:-1, max:1, defVal:0 }
  1208. ];
  1209. mxCellRenderer.defaultShapes['step'].prototype.customProperties = [
  1210. {name: 'size', dispName: 'Notch Size', type: 'float', min:0, defVal:20},
  1211. {name: 'fixedSize', dispName: 'Fixed Size', type: 'bool', defVal:true}
  1212. ];
  1213. mxCellRenderer.defaultShapes['trapezoid'].prototype.customProperties = [
  1214. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1215. {name: 'size', dispName: 'Slope Angle', type: 'float', min:0, max: 1, defVal: 0.2}
  1216. ];
  1217. mxCellRenderer.defaultShapes['tape'].prototype.customProperties = [
  1218. {name: 'size', dispName: 'Size', type: 'float', min:0, max:1, defVal:0.4 }
  1219. ];
  1220. mxCellRenderer.defaultShapes['note'].prototype.customProperties = [
  1221. {name: 'size', dispName: 'Fold Size', type: 'float', min:0, defVal: 30},
  1222. {name: 'darkOpacity', dispName: 'Dark Opacity', type: 'float', min:-1, max:1, defVal:0 },
  1223. ];
  1224. mxCellRenderer.defaultShapes['card'].prototype.customProperties = [
  1225. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1226. {name: 'size', dispName: 'Cutoff Size', type: 'float', min:0, defVal: 30}
  1227. ];
  1228. mxCellRenderer.defaultShapes['callout'].prototype.customProperties = [
  1229. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: mxConstants.LINE_ARCSIZE},
  1230. {name: 'base', dispName: 'Callout Width', type: 'float', min:0, defVal: 20},
  1231. {name: 'size', dispName: 'Callout Length', type: 'float', min:0, defVal: 30},
  1232. {name: 'position', dispName: 'Callout Position', type: 'float', min:0, max:1, defVal: 0.5},
  1233. {name: 'position2', dispName: 'Callout Tip Position', type: 'float', min:0, max:1, defVal: 0.5}
  1234. ];
  1235. mxCellRenderer.defaultShapes['folder'].prototype.customProperties = [
  1236. {name: 'tabWidth', dispName: 'Tab Width', type: 'float'},
  1237. {name: 'tabHeight', dispName: 'Tab Height', type: 'float'},
  1238. {name: 'tabPosition', dispName: 'Tap Position', type: 'enum',
  1239. enumList: [{val: 'left', dispName: 'Left'}, {val: 'right', dispName: 'Right'}]
  1240. }
  1241. ];
  1242. mxCellRenderer.defaultShapes['swimlane'].prototype.customProperties = [
  1243. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: 15},
  1244. {name: 'startSize', dispName: 'Header Size', type: 'float'},
  1245. {name: 'horizontal', dispName: 'Horizontal', type: 'bool', defVal: true}
  1246. ];
  1247. mxCellRenderer.defaultShapes['doubleEllipse'].prototype.customProperties = [
  1248. {name: 'margin', dispName: 'Indent', type: 'float', min:0, defVal:4}
  1249. ];
  1250. mxCellRenderer.defaultShapes['ext'].prototype.customProperties = [
  1251. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: 15},
  1252. {name: 'double', dispName: 'Double', type: 'bool', defVal: false},
  1253. {name: 'margin', dispName: 'Indent', type: 'float', min: 0, defVal:0}
  1254. ];
  1255. mxCellRenderer.defaultShapes['curlyBracket'].prototype.customProperties = [
  1256. {name: 'rounded', dispName: 'Rounded', type: 'bool', defVal: true},
  1257. {name: 'size', dispName: 'Size', type: 'float', min:0, max: 1, defVal: 0.5}
  1258. ];
  1259. mxCellRenderer.defaultShapes['image'].prototype.customProperties = [
  1260. {name: 'imageAspect', dispName: 'Fixed Image Aspect', type: 'bool', defVal:true}
  1261. ];
  1262. mxCellRenderer.defaultShapes['label'].prototype.customProperties = [
  1263. {name: 'imageAspect', dispName: 'Fixed Image Aspect', type: 'bool', defVal:true},
  1264. {name: 'imageAlign', dispName: 'Image Align', type: 'enum',
  1265. enumList: [{val: 'left', dispName: 'Left'},
  1266. {val: 'center', dispName: 'Center'},
  1267. {val: 'right', dispName: 'Right'}], defVal: 'left'},
  1268. {name: 'imageVerticalAlign', dispName: 'Image Vertical Align', type: 'enum',
  1269. enumList: [{val: 'top', dispName: 'Top'},
  1270. {val: 'middle', dispName: 'Middle'},
  1271. {val: 'bottom', dispName: 'Bottom'}], defVal: 'middle'},
  1272. {name: 'imageWidth', dispName: 'Image Width', type: 'float', min:0, defVal: 24},
  1273. {name: 'imageHeight', dispName: 'Image Height', type: 'float', min:0, defVal: 24},
  1274. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: 12},
  1275. {name: 'absoluteArcSize', dispName: 'Abs. Arc Size', type: 'bool', defVal: false}
  1276. ];
  1277. mxCellRenderer.defaultShapes['dataStorage'].prototype.customProperties = [
  1278. {name: 'size', dispName: 'Size', type: 'float', min:0, max:1, defVal:0.1 }
  1279. ];
  1280. mxCellRenderer.defaultShapes['manualInput'].prototype.customProperties = [
  1281. {name: 'size', dispName: 'Size', type: 'float', min:0, defVal:30 },
  1282. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: 20}
  1283. ];
  1284. mxCellRenderer.defaultShapes['loopLimit'].prototype.customProperties = [
  1285. {name: 'size', dispName: 'Size', type: 'float', min:0, defVal:20 },
  1286. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: 20}
  1287. ];
  1288. mxCellRenderer.defaultShapes['offPageConnector'].prototype.customProperties = [
  1289. {name: 'size', dispName: 'Size', type: 'float', min:0, defVal:38 },
  1290. {name: 'arcSize', dispName: 'Arc Size', type: 'float', min:0, defVal: 20}
  1291. ];
  1292. mxCellRenderer.defaultShapes['display'].prototype.customProperties = [
  1293. {name: 'size', dispName: 'Size', type: 'float', min: 0, max: 1, defVal: 0.25 }
  1294. ];
  1295. mxCellRenderer.defaultShapes['singleArrow'].prototype.customProperties = [
  1296. {name: 'arrowWidth', dispName: 'Arrow Width', type: 'float', min: 0, max: 1, defVal: 0.3 },
  1297. {name: 'arrowSize', dispName: 'Arrowhead Length', type: 'float', min: 0, max: 1, defVal: 0.2 }
  1298. ];
  1299. mxCellRenderer.defaultShapes['doubleArrow'].prototype.customProperties = [
  1300. {name: 'arrowWidth', dispName: 'Arrow Width', type: 'float', min: 0, max: 1, defVal: 0.3 },
  1301. {name: 'arrowSize', dispName: 'Arrowhead Length', type: 'float', min: 0, max: 1, defVal: 0.2 }
  1302. ];
  1303. mxCellRenderer.defaultShapes['cross'].prototype.customProperties = [
  1304. {name: 'size', dispName: 'Size', type: 'float', min: 0, max: 1, defVal: 0.2 }
  1305. ];
  1306. mxCellRenderer.defaultShapes['corner'].prototype.customProperties = [
  1307. {name: 'dx', dispName: 'Width1', type: 'float', min: 0, defVal: 20 },
  1308. {name: 'dy', dispName: 'Width2', type: 'float', min: 0, defVal: 20 }
  1309. ];
  1310. mxCellRenderer.defaultShapes['tee'].prototype.customProperties = [
  1311. {name: 'dx', dispName: 'Width1', type: 'float', min: 0, defVal: 20 },
  1312. {name: 'dy', dispName: 'Width2', type: 'float', min: 0, defVal: 20 }
  1313. ];
  1314. mxCellRenderer.defaultShapes['umlLifeline'].prototype.customProperties = [
  1315. {name: 'participant', dispName:'Participant', type:'enum', defVal:'none', enumList:[
  1316. {val:'none', dispName: 'Default'},
  1317. {val:'umlActor', dispName: 'Actor'},
  1318. {val:'umlBoundary', dispName: 'Boundary'},
  1319. {val:'umlEntity', dispName: 'Entity'},
  1320. {val:'umlControl', dispName: 'Control'},
  1321. ]},
  1322. {name: 'size', dispName:'Height', type:'float', defVal:40, min:0}
  1323. ];
  1324. mxCellRenderer.defaultShapes['umlFrame'].prototype.customProperties = [
  1325. {name: 'width', dispName:'Title Width', type:'float', defVal:60, min:0},
  1326. {name: 'height', dispName:'Title Height', type:'float', defVal:30, min:0}
  1327. ];
  1328. /**
  1329. * Configures global color schemes.
  1330. */
  1331. StyleFormatPanel.prototype.defaultColorSchemes = [[null, {fill: '#f5f5f5', stroke: '#666666', font: '#333333'},
  1332. {fill: '#dae8fc', stroke: '#6c8ebf'}, {fill: '#d5e8d4', stroke: '#82b366'},
  1333. {fill: '#ffe6cc', stroke: '#d79b00'}, {fill: '#fff2cc', stroke: '#d6b656'},
  1334. {fill: '#f8cecc', stroke: '#b85450'}, {fill: '#e1d5e7', stroke: '#9673a6'}],
  1335. [{fill: '#60a917', stroke: '#2D7600', font: '#ffffff'}, {fill: '#008a00', stroke: '#005700', font: '#ffffff'},
  1336. {fill: '#1ba1e2', stroke: '#006EAF', font: '#ffffff'}, {fill: '#0050ef', stroke: '#001DBC', font: '#ffffff'},
  1337. {fill: '#6a00ff', stroke: '#3700CC', font: '#ffffff'}, {fill: '#aa00ff', stroke: '#7700CC', font: '#ffffff'},
  1338. {fill: '#d80073', stroke: '#A50040', font: '#ffffff'}, {fill: '#a20025', stroke: '#6F0000', font: '#ffffff'}],
  1339. [{fill: '#e51400', stroke: '#B20000', font: '#ffffff'}, {fill: '#fa6800', stroke: '#C73500', font: '#ffffff'},
  1340. {fill: '#f0a30a', stroke: '#BD7000', font: '#ffffff'}, {fill: '#e3c800', stroke: '#B09500', font: '#ffffff'},
  1341. {fill: '#6d8764', stroke: '#3A5431', font: '#ffffff'}, {fill: '#647687', stroke: '#314354', font: '#ffffff'},
  1342. {fill: '#76608a', stroke: '#432D57', font: '#ffffff'}, {fill: '#a0522d', stroke: '#6D1F00', font: '#ffffff'}],
  1343. [null, {fill: mxConstants.NONE, stroke: '#36393d'},
  1344. {fill: '#fad7ac', stroke: '#b46504'}, {fill: '#fad9d5', stroke: '#ae4132'},
  1345. {fill: '#b0e3e6', stroke: '#0e8088'}, {fill: '#b1ddf0', stroke: '#10739e'},
  1346. {fill: '#d0cee2', stroke: '#56517e'}, {fill: '#bac8d3', stroke: '#23445d'}],
  1347. [null,
  1348. {fill: '#f5f5f5', stroke: '#666666', gradient: '#b3b3b3'},
  1349. {fill: '#dae8fc', stroke: '#6c8ebf', gradient: '#7ea6e0'},
  1350. {fill: '#d5e8d4', stroke: '#82b366', gradient: '#97d077'},
  1351. {fill: '#ffcd28', stroke: '#d79b00', gradient: '#ffa500'},
  1352. {fill: '#fff2cc', stroke: '#d6b656', gradient: '#ffd966'},
  1353. {fill: '#f8cecc', stroke: '#b85450', gradient: '#ea6b66'},
  1354. {fill: '#e6d0de', stroke: '#996185', gradient: '#d5739d'}],
  1355. [null, {fill: '#eeeeee', stroke: '#36393d'},
  1356. {fill: '#f9f7ed', stroke: '#36393d'}, {fill: '#ffcc99', stroke: '#36393d'},
  1357. {fill: '#cce5ff', stroke: '#36393d'}, {fill: '#ffff88', stroke: '#36393d'},
  1358. {fill: '#cdeb8b', stroke: '#36393d'}, {fill: '#ffcccc', stroke: '#36393d'}]];
  1359. /**
  1360. * Configures custom color schemes.
  1361. */
  1362. StyleFormatPanel.prototype.customColorSchemes = null;
  1363. StyleFormatPanel.prototype.findCommonProperties = function(cell, properties, addAll)
  1364. {
  1365. if (properties == null) return;
  1366. var handleCustomProp = function(custProperties)
  1367. {
  1368. if (custProperties != null)
  1369. {
  1370. if (addAll)
  1371. {
  1372. for (var i = 0; i < custProperties.length; i++)
  1373. {
  1374. properties[custProperties[i].name] = custProperties[i];
  1375. }
  1376. }
  1377. else
  1378. {
  1379. for (var key in properties)
  1380. {
  1381. var found = false;
  1382. for (var i = 0; i < custProperties.length; i++)
  1383. {
  1384. if (custProperties[i].name == key && custProperties[i].type == properties[key].type)
  1385. {
  1386. found = true;
  1387. break;
  1388. }
  1389. }
  1390. if (!found)
  1391. {
  1392. delete properties[key];
  1393. }
  1394. }
  1395. }
  1396. }
  1397. };
  1398. var view = this.editorUi.editor.graph.view;
  1399. var state = view.getState(cell);
  1400. if (state != null && state.shape != null)
  1401. {
  1402. //Add common properties to all shapes
  1403. if (!state.shape.commonCustomPropAdded)
  1404. {
  1405. state.shape.commonCustomPropAdded = true;
  1406. state.shape.customProperties = state.shape.customProperties || [];
  1407. if (state.cell.vertex)
  1408. {
  1409. Array.prototype.push.apply(state.shape.customProperties, Editor.commonVertexProperties);
  1410. }
  1411. else
  1412. {
  1413. Array.prototype.push.apply(state.shape.customProperties, Editor.commonEdgeProperties);
  1414. }
  1415. }
  1416. handleCustomProp(state.shape.customProperties);
  1417. }
  1418. //This currently is not needed but let's keep it in case we needed in the future
  1419. var userCustomProp = cell.getAttribute('customProperties');
  1420. if (userCustomProp != null)
  1421. {
  1422. try
  1423. {
  1424. handleCustomProp(JSON.parse(userCustomProp));
  1425. }
  1426. catch(e){}
  1427. }
  1428. };
  1429. /**
  1430. * Adds predefiend styles.
  1431. */
  1432. var styleFormatPanelInit = StyleFormatPanel.prototype.init;
  1433. StyleFormatPanel.prototype.init = function()
  1434. {
  1435. // TODO: Update sstate in Format
  1436. var sstate = this.format.createSelectionState();
  1437. if (sstate.style.shape != 'image')
  1438. {
  1439. this.container.appendChild(this.addStyles(this.createPanel()));
  1440. }
  1441. styleFormatPanelInit.apply(this, arguments);
  1442. if (Editor.enableCustomProperties)
  1443. {
  1444. var properties = {};
  1445. var vertices = sstate.vertices;
  1446. var edges = sstate.edges;
  1447. for (var i = 0; i < vertices.length; i++)
  1448. {
  1449. this.findCommonProperties(vertices[i], properties, i == 0);
  1450. }
  1451. for (var i = 0; i < edges.length; i++)
  1452. {
  1453. this.findCommonProperties(edges[i], properties, vertices.length == 0 && i == 0);
  1454. }
  1455. if (Object.getOwnPropertyNames(properties).length > 0)
  1456. this.container.appendChild(this.addProperties(this.createPanel(), properties, sstate));
  1457. }
  1458. };
  1459. /**
  1460. * Overridden to add copy and paste style.
  1461. */
  1462. var styleFormatPanelAddStyleOps = StyleFormatPanel.prototype.addStyleOps;
  1463. StyleFormatPanel.prototype.addStyleOps = function(div)
  1464. {
  1465. var graph = this.editorUi.editor.graph;
  1466. var btn = mxUtils.button(mxResources.get('copyStyle'), mxUtils.bind(this, function(evt)
  1467. {
  1468. this.editorUi.actions.get('copyStyle').funct();
  1469. }));
  1470. btn.setAttribute('title', mxResources.get('copyStyle') + ' (' + this.editorUi.actions.get('copyStyle').shortcut + ')');
  1471. btn.style.marginBottom = '2px';
  1472. btn.style.width = '100px';
  1473. btn.style.marginRight = '2px';
  1474. div.appendChild(btn);
  1475. var btn = mxUtils.button(mxResources.get('pasteStyle'), mxUtils.bind(this, function(evt)
  1476. {
  1477. this.editorUi.actions.get('pasteStyle').funct();
  1478. }));
  1479. btn.setAttribute('title', mxResources.get('pasteStyle') + ' (' + this.editorUi.actions.get('pasteStyle').shortcut + ')');
  1480. btn.style.marginBottom = '2px';
  1481. btn.style.width = '100px';
  1482. div.appendChild(btn);
  1483. mxUtils.br(div);
  1484. return styleFormatPanelAddStyleOps.apply(this, arguments);
  1485. };
  1486. /**
  1487. * Initial collapsed state of the properties panel.
  1488. */
  1489. EditorUi.prototype.propertiesCollapsed = true;
  1490. /**
  1491. * Create Properties Panel
  1492. */
  1493. StyleFormatPanel.prototype.addProperties = function(div, properties, state)
  1494. {
  1495. var that = this;
  1496. var graph = this.editorUi.editor.graph;
  1497. var secondLevel = [];
  1498. function insertAfter(newElem, curElem)
  1499. {
  1500. curElem.parentNode.insertBefore(newElem, curElem.nextSibling);
  1501. };
  1502. function applyStyleVal(pName, newVal, prop, delIndex)
  1503. {
  1504. graph.getModel().beginUpdate();
  1505. try
  1506. {
  1507. var changedProps = [];
  1508. var changedVals = [];
  1509. if (prop.index != null)
  1510. {
  1511. var allVals = [];
  1512. var curVal = prop.parentRow.nextSibling;
  1513. while(curVal && curVal.getAttribute('data-pName') == pName)
  1514. {
  1515. allVals.push(curVal.getAttribute('data-pValue'));
  1516. curVal = curVal.nextSibling;
  1517. }
  1518. if (prop.index < allVals.length)
  1519. {
  1520. if (delIndex != null)
  1521. {
  1522. allVals.splice(delIndex, 1);
  1523. }
  1524. else
  1525. {
  1526. allVals[prop.index] = newVal;
  1527. }
  1528. }
  1529. else
  1530. {
  1531. allVals.push(newVal);
  1532. }
  1533. if (prop.size != null && allVals.length > prop.size) //trim the array to the specifies size
  1534. {
  1535. allVals = allVals.slice(0, prop.size);
  1536. }
  1537. newVal = allVals.join(',');
  1538. if (prop.countProperty != null)
  1539. {
  1540. graph.setCellStyles(prop.countProperty, allVals.length, graph.getSelectionCells());
  1541. changedProps.push(prop.countProperty);
  1542. changedVals.push(allVals.length);
  1543. }
  1544. }
  1545. graph.setCellStyles(pName, newVal, graph.getSelectionCells());
  1546. changedProps.push(pName);
  1547. changedVals.push(newVal);
  1548. if (prop.dependentProps != null)
  1549. {
  1550. for (var i = 0; i < prop.dependentProps.length; i++)
  1551. {
  1552. var defVal = prop.dependentPropsDefVal[i];
  1553. var vals = prop.dependentPropsVals[i];
  1554. if (vals.length > newVal)
  1555. {
  1556. vals = vals.slice(0, newVal);
  1557. }
  1558. else
  1559. {
  1560. for (var j = vals.length; j < newVal; j++)
  1561. {
  1562. vals.push(defVal);
  1563. }
  1564. }
  1565. vals = vals.join(',');
  1566. graph.setCellStyles(prop.dependentProps[i], vals, graph.getSelectionCells());
  1567. changedProps.push(prop.dependentProps[i]);
  1568. changedVals.push(vals);
  1569. }
  1570. }
  1571. that.editorUi.fireEvent(new mxEventObject('styleChanged', 'keys', changedProps,
  1572. 'values', changedVals, 'cells', graph.getSelectionCells()));
  1573. }
  1574. finally
  1575. {
  1576. graph.getModel().endUpdate();
  1577. }
  1578. }
  1579. function setElementPos(td, elem, adjustHeight)
  1580. {
  1581. var divPos = mxUtils.getOffset(div, true);
  1582. var pos = mxUtils.getOffset(td, true);
  1583. elem.style.position = 'absolute';
  1584. elem.style.left = (pos.x - divPos.x) + 'px';
  1585. elem.style.top = (pos.y - divPos.y) + 'px';
  1586. elem.style.width = td.offsetWidth + 'px';
  1587. elem.style.height = (td.offsetHeight - (adjustHeight? 4 : 0)) + 'px';
  1588. elem.style.zIndex = 5;
  1589. };
  1590. function createColorBtn(pName, pValue, prop)
  1591. {
  1592. var clrDiv = document.createElement('div');
  1593. clrDiv.style.width = '32px';
  1594. clrDiv.style.height = '4px';
  1595. clrDiv.style.margin = '2px';
  1596. clrDiv.style.border = '1px solid black';
  1597. clrDiv.style.background = !pValue || pValue == 'none'? 'url(\'' + Dialog.prototype.noColorImage + '\')' : pValue;
  1598. btn = mxUtils.button('', mxUtils.bind(that, function(evt)
  1599. {
  1600. this.editorUi.pickColor(pValue, function(color)
  1601. {
  1602. clrDiv.style.background = color == 'none'? 'url(\'' + Dialog.prototype.noColorImage + '\')' : color;
  1603. applyStyleVal(pName, color, prop);
  1604. });
  1605. mxEvent.consume(evt);
  1606. }));
  1607. btn.style.height = '12px';
  1608. btn.style.width = '40px';
  1609. btn.className = 'geColorBtn';
  1610. btn.appendChild(clrDiv);
  1611. return btn;
  1612. };
  1613. function createDynArrList(pName, pValue, subType, defVal, countProperty, myRow, flipBkg)
  1614. {
  1615. if (pValue != null)
  1616. {
  1617. var vals = pValue.split(',');
  1618. secondLevel.push({name: pName, values: vals, type: subType, defVal: defVal, countProperty: countProperty, parentRow: myRow, isDeletable: true, flipBkg: flipBkg});
  1619. }
  1620. btn = mxUtils.button('+', mxUtils.bind(that, function(evt)
  1621. {
  1622. var beforeElem = myRow;
  1623. var index = 0;
  1624. while (beforeElem.nextSibling != null)
  1625. {
  1626. var cur = beforeElem.nextSibling;
  1627. var elemPName = cur.getAttribute('data-pName');
  1628. if (elemPName == pName)
  1629. {
  1630. beforeElem = beforeElem.nextSibling;
  1631. index++;
  1632. }
  1633. else
  1634. {
  1635. break;
  1636. }
  1637. }
  1638. var newProp = {type: subType, parentRow: myRow, index: index, isDeletable: true, defVal: defVal, countProperty: countProperty};
  1639. var arrItem = createPropertyRow(pName, '', newProp, index % 2 == 0, flipBkg);
  1640. applyStyleVal(pName, defVal, newProp);
  1641. insertAfter(arrItem, beforeElem);
  1642. mxEvent.consume(evt);
  1643. }));
  1644. btn.style.height = '16px';
  1645. btn.style.width = '25px';
  1646. btn.className = 'geColorBtn';
  1647. return btn;
  1648. };
  1649. function createStaticArrList(pName, pValue, subType, defVal, size, myRow, flipBkg)
  1650. {
  1651. if (size > 0)
  1652. {
  1653. var vals = new Array(size);
  1654. var curVals = pValue != null? pValue.split(',') : [];
  1655. for (var i = 0; i < size; i++)
  1656. {
  1657. vals[i] = curVals[i] != null? curVals[i] : (defVal != null? defVal : '');
  1658. }
  1659. secondLevel.push({name: pName, values: vals, type: subType, defVal: defVal, parentRow: myRow, flipBkg: flipBkg, size: size});
  1660. }
  1661. return document.createElement('div'); //empty cell
  1662. };
  1663. function createCheckbox(pName, pValue, prop)
  1664. {
  1665. var input = document.createElement('input');
  1666. input.type = 'checkbox';
  1667. input.checked = pValue == '1';
  1668. mxEvent.addListener(input, 'change', function()
  1669. {
  1670. applyStyleVal(pName, input.checked? '1' : '0', prop);
  1671. });
  1672. return input;
  1673. };
  1674. function createPropertyRow(pName, pValue, prop, isOdd, flipBkg)
  1675. {
  1676. var pDiplayName = prop.dispName;
  1677. var pType = prop.type;
  1678. var row = document.createElement('tr');
  1679. row.className = 'gePropRow' + (flipBkg? 'Dark' : '') + (isOdd? 'Alt' : '') + ' gePropNonHeaderRow';
  1680. row.setAttribute('data-pName', pName);
  1681. row.setAttribute('data-pValue', pValue);
  1682. var rightAlig = false;
  1683. if (prop.index != null)
  1684. {
  1685. row.setAttribute('data-index', prop.index);
  1686. pDiplayName = (pDiplayName != null? pDiplayName : '') + '[' + prop.index + ']';
  1687. rightAlig = true;
  1688. }
  1689. var td = document.createElement('td');
  1690. td.className = 'gePropRowCell';
  1691. td.innerHTML = mxUtils.htmlEntities(mxResources.get(pDiplayName, null, pDiplayName));
  1692. if (rightAlig)
  1693. {
  1694. td.style.textAlign = 'right';
  1695. }
  1696. row.appendChild(td);
  1697. td = document.createElement('td');
  1698. td.className = 'gePropRowCell';
  1699. if (pType == 'color')
  1700. {
  1701. td.appendChild(createColorBtn(pName, pValue, prop));
  1702. }
  1703. else if (pType == 'bool' || pType == 'boolean')
  1704. {
  1705. td.appendChild(createCheckbox(pName, pValue, prop));
  1706. }
  1707. else if (pType == 'enum')
  1708. {
  1709. var pEnumList = prop.enumList;
  1710. for (var i = 0; i < pEnumList.length; i++)
  1711. {
  1712. var op = pEnumList[i];
  1713. if (op.val == pValue)
  1714. {
  1715. td.innerHTML = mxUtils.htmlEntities(mxResources.get(op.dispName, null, op.dispName));
  1716. break;
  1717. }
  1718. }
  1719. mxEvent.addListener(td, 'click', mxUtils.bind(that, function()
  1720. {
  1721. var select = document.createElement('select');
  1722. setElementPos(td, select);
  1723. for (var i = 0; i < pEnumList.length; i++)
  1724. {
  1725. var op = pEnumList[i];
  1726. var opElem = document.createElement('option');
  1727. opElem.value = mxUtils.htmlEntities(op.val);
  1728. opElem.innerHTML = mxUtils.htmlEntities(mxResources.get(op.dispName, null, op.dispName));
  1729. select.appendChild(opElem);
  1730. }
  1731. select.value = pValue;
  1732. div.appendChild(select);
  1733. mxEvent.addListener(select, 'change', function()
  1734. {
  1735. var newVal = mxUtils.htmlEntities(select.value);
  1736. applyStyleVal(pName, newVal, prop);
  1737. //set value triggers a redraw of the panel which removes the select and updates the row
  1738. });
  1739. select.focus();
  1740. //FF calls blur on focus! so set the event after focusing (not with selects but to be safe)
  1741. mxEvent.addListener(select, 'blur', function()
  1742. {
  1743. div.removeChild(select);
  1744. });
  1745. }));
  1746. }
  1747. else if (pType == 'dynamicArr')
  1748. {
  1749. td.appendChild(createDynArrList(pName, pValue, prop.subType, prop.subDefVal, prop.countProperty, row, flipBkg));
  1750. }
  1751. else if (pType == 'staticArr')
  1752. {
  1753. td.appendChild(createStaticArrList(pName, pValue, prop.subType, prop.subDefVal, prop.size, row, flipBkg));
  1754. }
  1755. else
  1756. {
  1757. td.innerHTML = pValue;
  1758. mxEvent.addListener(td, 'click', mxUtils.bind(that, function()
  1759. {
  1760. var input = document.createElement('input');
  1761. setElementPos(td, input, true);
  1762. input.value = pValue;
  1763. input.className = 'gePropEditor';
  1764. if ((pType == 'int' || pType == 'float') && !prop.allowAuto)
  1765. {
  1766. input.type = 'number';
  1767. input.step = pType == 'int'? '1' : 'any';
  1768. if (prop.min != null)
  1769. {
  1770. input.min = parseFloat(prop.min);
  1771. }
  1772. if (prop.max != null)
  1773. {
  1774. input.max = parseFloat(prop.max);
  1775. }
  1776. }
  1777. div.appendChild(input);
  1778. function setInputVal()
  1779. {
  1780. var inputVal = input.value;
  1781. inputVal = inputVal.length == 0 && pType != 'string'? 0 : inputVal;
  1782. if (prop.allowAuto)
  1783. {
  1784. if (inputVal.trim().toLowerCase() == 'auto')
  1785. {
  1786. inputVal = 'auto';
  1787. pType = 'string';
  1788. }
  1789. else
  1790. {
  1791. inputVal = parseFloat(inputVal);
  1792. inputVal = isNaN(inputVal)? 0 : inputVal;
  1793. }
  1794. }
  1795. if (prop.min != null && inputVal < prop.min)
  1796. {
  1797. inputVal = prop.min;
  1798. }
  1799. else if (prop.max != null && inputVal > prop.max)
  1800. {
  1801. inputVal = prop.max;
  1802. }
  1803. var newVal = mxUtils.htmlEntities((pType == 'int'? parseInt(inputVal) : inputVal) + '');
  1804. applyStyleVal(pName, newVal, prop);
  1805. }
  1806. mxEvent.addListener(input, 'keypress', function(e)
  1807. {
  1808. if (e.keyCode == 13)
  1809. {
  1810. setInputVal();
  1811. //set value triggers a redraw of the panel which removes the input
  1812. }
  1813. });
  1814. input.focus();
  1815. //FF calls blur on focus! so set the event after focusing
  1816. mxEvent.addListener(input, 'blur', function()
  1817. {
  1818. setInputVal();
  1819. });
  1820. }));
  1821. }
  1822. if (prop.isDeletable)
  1823. {
  1824. var delBtn = mxUtils.button('-', mxUtils.bind(that, function(evt)
  1825. {
  1826. //delete the node by refreshing the properties
  1827. applyStyleVal(pName, '', prop, prop.index);
  1828. mxEvent.consume(evt);
  1829. }));
  1830. delBtn.style.height = '16px';
  1831. delBtn.style.width = '25px';
  1832. delBtn.style.float = 'right';
  1833. delBtn.className = 'geColorBtn';
  1834. td.appendChild(delBtn);
  1835. }
  1836. row.appendChild(td);
  1837. return row;
  1838. };
  1839. div.style.position = 'relative';
  1840. div.style.padding = '0';
  1841. var grid = document.createElement('table');
  1842. grid.style.whiteSpace = 'nowrap';
  1843. grid.style.width = '100%';
  1844. //create header row
  1845. var hrow = document.createElement('tr');
  1846. hrow.className = 'gePropHeader';
  1847. var th = document.createElement('th');
  1848. th.className = 'gePropHeaderCell';
  1849. var collapseImg = document.createElement('img');
  1850. collapseImg.src = Sidebar.prototype.expandedImage;
  1851. th.appendChild(collapseImg);
  1852. mxUtils.write(th, mxResources.get('property'));
  1853. hrow.style.cursor = 'pointer';
  1854. var onFold = function()
  1855. {
  1856. var rows = grid.querySelectorAll('.gePropNonHeaderRow');
  1857. var display;
  1858. if (!that.editorUi.propertiesCollapsed)
  1859. {
  1860. collapseImg.src = Sidebar.prototype.expandedImage;
  1861. display = '';
  1862. }
  1863. else
  1864. {
  1865. collapseImg.src = Sidebar.prototype.collapsedImage;
  1866. display = 'none';
  1867. for (var e = div.childNodes.length - 1; e >= 0 ; e--)
  1868. {
  1869. //Blur can be executed concurrently with this method and the element is removed before removing it here
  1870. try
  1871. {
  1872. var child = div.childNodes[e];
  1873. var nodeName = child.nodeName.toUpperCase();
  1874. if (nodeName == 'INPUT' || nodeName == 'SELECT')
  1875. {
  1876. div.removeChild(child);
  1877. }
  1878. }
  1879. catch(ex){}
  1880. }
  1881. }
  1882. for (var r = 0; r < rows.length; r++)
  1883. {
  1884. rows[r].style.display = display;
  1885. }
  1886. };
  1887. mxEvent.addListener(hrow, 'click', function()
  1888. {
  1889. that.editorUi.propertiesCollapsed = !that.editorUi.propertiesCollapsed;
  1890. onFold();
  1891. });
  1892. hrow.appendChild(th);
  1893. th = document.createElement('th');
  1894. th.className = 'gePropHeaderCell';
  1895. th.innerHTML = mxResources.get('value');
  1896. hrow.appendChild(th);
  1897. grid.appendChild(hrow);
  1898. var isOdd = false;
  1899. var flipBkg = false;
  1900. for (var key in properties)
  1901. {
  1902. var prop = properties[key];
  1903. if (typeof(prop.isVisible) == 'function')
  1904. {
  1905. if (!prop.isVisible(state)) continue;
  1906. }
  1907. var pValue = state.style[key] != null? mxUtils.htmlEntities(state.style[key] + '') : prop.defVal; //or undefined if defVal is undefined
  1908. if (prop.type == 'separator')
  1909. {
  1910. flipBkg = !flipBkg;
  1911. continue;
  1912. }
  1913. else if (prop.type == 'staticArr') //if dynamic values are needed, a more elegant technique is needed to replace such values
  1914. {
  1915. prop.size = parseInt(state.style[prop.sizeProperty] || properties[prop.sizeProperty].defVal) || 0;
  1916. }
  1917. else if (prop.dependentProps != null)
  1918. {
  1919. var dependentProps = prop.dependentProps;
  1920. var dependentPropsVals = [];
  1921. var dependentPropsDefVal = [];
  1922. for (var i = 0; i < dependentProps.length; i++)
  1923. {
  1924. var propVal = state.style[dependentProps[i]];
  1925. dependentPropsDefVal.push(properties[dependentProps[i]].subDefVal);
  1926. dependentPropsVals.push(propVal != null? propVal.split(',') : []);
  1927. }
  1928. prop.dependentPropsDefVal = dependentPropsDefVal;
  1929. prop.dependentPropsVals = dependentPropsVals;
  1930. }
  1931. grid.appendChild(createPropertyRow(key, pValue, prop, isOdd, flipBkg));
  1932. isOdd = !isOdd;
  1933. }
  1934. for (var i = 0; i < secondLevel.length; i++)
  1935. {
  1936. var prop = secondLevel[i];
  1937. var insertElem = prop.parentRow;
  1938. for (var j = 0; j < prop.values.length; j++)
  1939. {
  1940. //mxUtils.clone failed because of the HTM element, so manual cloning is used
  1941. var iProp = {type: prop.type, parentRow: prop.parentRow, isDeletable: prop.isDeletable, index: j, defVal: prop.defVal, countProperty: prop.countProperty, size: prop.size};
  1942. var arrItem = createPropertyRow(prop.name, prop.values[j], iProp, j % 2 == 0, prop.flipBkg);
  1943. insertAfter(arrItem, insertElem);
  1944. insertElem = arrItem;
  1945. }
  1946. }
  1947. div.appendChild(grid);
  1948. onFold();
  1949. return div;
  1950. };
  1951. /**
  1952. * Creates the buttons for the predefined styles.
  1953. */
  1954. StyleFormatPanel.prototype.addStyles = function(div)
  1955. {
  1956. var graph = this.editorUi.editor.graph;
  1957. var picker = document.createElement('div');
  1958. picker.style.whiteSpace = 'nowrap';
  1959. picker.style.paddingLeft = '24px';
  1960. picker.style.paddingRight = '20px';
  1961. div.style.paddingLeft = '16px';
  1962. div.style.paddingBottom = '6px';
  1963. div.style.position = 'relative';
  1964. div.appendChild(picker);
  1965. var stylenames = ['plain-gray', 'plain-blue', 'plain-green', 'plain-turquoise',
  1966. 'plain-orange', 'plain-yellow', 'plain-red', 'plain-pink', 'plain-purple', 'gray',
  1967. 'blue', 'green', 'turquoise', 'orange', 'yellow', 'red', 'pink', 'purple'];
  1968. function updateScheme(colorsets)
  1969. {
  1970. function addButton(colorset)
  1971. {
  1972. var btn = mxUtils.button('', function(evt)
  1973. {
  1974. graph.getModel().beginUpdate();
  1975. try
  1976. {
  1977. var cells = graph.getSelectionCells();
  1978. for (var i = 0; i < cells.length; i++)
  1979. {
  1980. var style = graph.getModel().getStyle(cells[i]);
  1981. for (var j = 0; j < stylenames.length; j++)
  1982. {
  1983. style = mxUtils.removeStylename(style, stylenames[j]);
  1984. }
  1985. var defaults = (graph.getModel().isVertex(cells[i])) ? graph.defaultVertexStyle : graph.defaultEdgeStyle;
  1986. if (colorset != null)
  1987. {
  1988. style = mxUtils.setStyle(style, mxConstants.STYLE_FILLCOLOR, colorset['fill'] ||
  1989. mxUtils.getValue(defaults, mxConstants.STYLE_FILLCOLOR, null));
  1990. style = mxUtils.setStyle(style, mxConstants.STYLE_STROKECOLOR, colorset['stroke'] ||
  1991. mxUtils.getValue(defaults, mxConstants.STYLE_STROKECOLOR, null));
  1992. style = mxUtils.setStyle(style, mxConstants.STYLE_GRADIENTCOLOR, colorset['gradient'] ||
  1993. mxUtils.getValue(defaults, mxConstants.STYLE_GRADIENTCOLOR, null));
  1994. if (graph.getModel().isVertex(cells[i]))
  1995. {
  1996. style = mxUtils.setStyle(style, mxConstants.STYLE_FONTCOLOR, colorset['font'] ||
  1997. mxUtils.getValue(defaults, mxConstants.STYLE_FONTCOLOR, null));
  1998. }
  1999. }
  2000. else
  2001. {
  2002. style = mxUtils.setStyle(style, mxConstants.STYLE_FILLCOLOR,
  2003. mxUtils.getValue(defaults, mxConstants.STYLE_FILLCOLOR, '#ffffff'));
  2004. style = mxUtils.setStyle(style, mxConstants.STYLE_STROKECOLOR,
  2005. mxUtils.getValue(defaults, mxConstants.STYLE_STROKECOLOR, '#000000'));
  2006. style = mxUtils.setStyle(style, mxConstants.STYLE_GRADIENTCOLOR,
  2007. mxUtils.getValue(defaults, mxConstants.STYLE_GRADIENTCOLOR, null));
  2008. if (graph.getModel().isVertex(cells[i]))
  2009. {
  2010. style = mxUtils.setStyle(style, mxConstants.STYLE_FONTCOLOR,
  2011. mxUtils.getValue(defaults, mxConstants.STYLE_FONTCOLOR, null));
  2012. }
  2013. }
  2014. graph.getModel().setStyle(cells[i], style);
  2015. }
  2016. }
  2017. finally
  2018. {
  2019. graph.getModel().endUpdate();
  2020. }
  2021. })
  2022. btn.className = 'geStyleButton';
  2023. btn.style.width = '36px';
  2024. btn.style.height = '30px';
  2025. btn.style.margin = '0px 6px 6px 0px';
  2026. if (colorset != null)
  2027. {
  2028. if (colorset['gradient'] != null)
  2029. {
  2030. if (mxClient.IS_IE && (mxClient.IS_QUIRKS || document.documentMode < 10))
  2031. {
  2032. btn.style.filter = 'progid:DXImageTransform.Microsoft.Gradient('+
  2033. 'StartColorStr=\'' + colorset['fill'] +
  2034. '\', EndColorStr=\'' + colorset['gradient'] + '\', GradientType=0)';
  2035. }
  2036. else
  2037. {
  2038. btn.style.backgroundImage = 'linear-gradient(' + colorset['fill'] + ' 0px,' +
  2039. colorset['gradient'] + ' 100%)';
  2040. }
  2041. }
  2042. else if (colorset['fill'] == mxConstants.NONE)
  2043. {
  2044. btn.style.background = 'url(\'' + Dialog.prototype.noColorImage + '\')';
  2045. }
  2046. else
  2047. {
  2048. btn.style.backgroundColor = colorset['fill'] || mxUtils.getValue(graph.defaultVertexStyle,
  2049. mxConstants.STYLE_FILLCOLOR, '#ffffff');
  2050. }
  2051. btn.style.border = '1px solid ' + (colorset['stroke'] || mxUtils.getValue(graph.defaultVertexStyle,
  2052. mxConstants.STYLE_STROKECOLOR, '#000000'));
  2053. }
  2054. else
  2055. {
  2056. var bg = mxUtils.getValue(graph.defaultVertexStyle, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  2057. var bd = mxUtils.getValue(graph.defaultVertexStyle, mxConstants.STYLE_STROKECOLOR, '#000000');
  2058. btn.style.backgroundColor = bg;
  2059. btn.style.border = '1px solid ' + bd;
  2060. }
  2061. picker.appendChild(btn);
  2062. };
  2063. picker.innerHTML = '';
  2064. for (var i = 0; i < colorsets.length; i++)
  2065. {
  2066. if (i > 0 && mxUtils.mod(i, 4) == 0)
  2067. {
  2068. mxUtils.br(picker);
  2069. }
  2070. addButton(colorsets[i]);
  2071. }
  2072. };
  2073. if (this.editorUi.currentScheme == null)
  2074. {
  2075. this.editorUi.currentScheme = 0;
  2076. }
  2077. var left = document.createElement('div');
  2078. left.style.cssText = 'position:absolute;left:10px;top:8px;bottom:8px;width:20px;margin:4px;opacity:0.5;' +
  2079. 'background-repeat:no-repeat;background-position:center center;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAAIVBMVEUAAAB2dnZ4eHh3d3d1dXVxcXF2dnZ2dnZ2dnZxcXF2dnYmb3w1AAAACnRSTlMAfCTkhhvb7cQSPH2JPgAAADRJREFUCNdjwACMAmBKaiGYs2oJmLPKAZ3DabU8AMRTXpUKopislqFyVzCAuUZgikkBZjoAcMYLnp53P/UAAAAASUVORK5CYII=);';
  2080. mxEvent.addListener(left, 'click', mxUtils.bind(this, function()
  2081. {
  2082. this.editorUi.currentScheme = mxUtils.mod(this.editorUi.currentScheme - 1, this.defaultColorSchemes.length);
  2083. updateScheme(this.defaultColorSchemes[this.editorUi.currentScheme]);
  2084. }));
  2085. var right = document.createElement('div');
  2086. right.style.cssText = 'position:absolute;left:202px;top:8px;bottom:8px;width:20px;margin:4px;opacity:0.5;' +
  2087. 'background-repeat:no-repeat;background-position:center center;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQBAMAAADQT4M0AAAAIVBMVEUAAAB2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnYBuwCcAAAACnRSTlMAfCTkhhvb7cQSPH2JPgAAADZJREFUCNdjQAOMAmBKaiGY8loF5rKswsZlrVo8AUiFrTICcbIWK8A5DF1gDoMymMPApIAwHwCS0Qx/U7qCBQAAAABJRU5ErkJggg==);';
  2088. if (this.defaultColorSchemes.length > 1)
  2089. {
  2090. div.appendChild(left);
  2091. div.appendChild(right);
  2092. }
  2093. mxEvent.addListener(right, 'click', mxUtils.bind(this, function()
  2094. {
  2095. this.editorUi.currentScheme = mxUtils.mod(this.editorUi.currentScheme + 1, this.defaultColorSchemes.length);
  2096. updateScheme(this.defaultColorSchemes[this.editorUi.currentScheme]);
  2097. }));
  2098. // Hover state
  2099. function addHoverState(elt)
  2100. {
  2101. mxEvent.addListener(elt, 'mouseenter', function()
  2102. {
  2103. elt.style.opacity = '1';
  2104. });
  2105. mxEvent.addListener(elt, 'mouseleave', function()
  2106. {
  2107. elt.style.opacity = '0.5';
  2108. });
  2109. };
  2110. addHoverState(left);
  2111. addHoverState(right);
  2112. updateScheme(this.defaultColorSchemes[this.editorUi.currentScheme]);
  2113. return div;
  2114. };
  2115. StyleFormatPanel.prototype.addEditOps = function(div)
  2116. {
  2117. var ss = this.format.getSelectionState();
  2118. var btn = null;
  2119. if (this.editorUi.editor.graph.getSelectionCount() == 1)
  2120. {
  2121. btn = mxUtils.button(mxResources.get('editStyle'), mxUtils.bind(this, function(evt)
  2122. {
  2123. this.editorUi.actions.get('editStyle').funct();
  2124. }));
  2125. btn.setAttribute('title', mxResources.get('editStyle') + ' (' + this.editorUi.actions.get('editStyle').shortcut + ')');
  2126. btn.style.width = '202px';
  2127. btn.style.marginBottom = '2px';
  2128. div.appendChild(btn);
  2129. }
  2130. var graph = this.editorUi.editor.graph;
  2131. var state = graph.view.getState(graph.getSelectionCell());
  2132. if (graph.getSelectionCount() == 1 && state != null && state.shape != null && state.shape.stencil != null)
  2133. {
  2134. var btn2 = mxUtils.button(mxResources.get('editShape'), mxUtils.bind(this, function(evt)
  2135. {
  2136. this.editorUi.actions.get('editShape').funct();
  2137. }));
  2138. btn2.setAttribute('title', mxResources.get('editShape'));
  2139. btn2.style.marginBottom = '2px';
  2140. if (btn == null)
  2141. {
  2142. btn2.style.width = '202px';
  2143. }
  2144. else
  2145. {
  2146. btn.style.width = '100px';
  2147. btn2.style.width = '100px';
  2148. btn2.style.marginLeft = '2px';
  2149. }
  2150. div.appendChild(btn2);
  2151. }
  2152. else if (ss.image)
  2153. {
  2154. var btn2 = mxUtils.button(mxResources.get('editImage'), mxUtils.bind(this, function(evt)
  2155. {
  2156. this.editorUi.actions.get('image').funct();
  2157. }));
  2158. btn2.setAttribute('title', mxResources.get('editImage'));
  2159. btn2.style.marginBottom = '2px';
  2160. if (btn == null)
  2161. {
  2162. btn2.style.width = '202px';
  2163. }
  2164. else
  2165. {
  2166. btn.style.width = '100px';
  2167. btn2.style.width = '100px';
  2168. btn2.style.marginLeft = '2px';
  2169. }
  2170. div.appendChild(btn2);
  2171. }
  2172. return div;
  2173. };
  2174. }
  2175. /**
  2176. * Changes the default stylename so that it matches the old named style
  2177. * if one was specified in the XML.
  2178. */
  2179. Graph.prototype.defaultThemeName = 'default-style2';
  2180. /**
  2181. * Contains the last XML that was pasted.
  2182. */
  2183. Graph.prototype.lastPasteXml = null;
  2184. /**
  2185. * Contains the number of times the last XML was pasted.
  2186. */
  2187. Graph.prototype.pasteCounter = 0;
  2188. /**
  2189. * Graph Overrides
  2190. */
  2191. Graph.prototype.defaultScrollbars = urlParams['sb'] != '0';
  2192. /**
  2193. * Specifies if the page should be visible for new files. Default is true.
  2194. */
  2195. Graph.prototype.defaultPageVisible = urlParams['pv'] != '0';
  2196. /**
  2197. * Specifies if the page should be visible for new files. Default is true.
  2198. */
  2199. Graph.prototype.shadowId = 'dropShadow';
  2200. /**
  2201. * Properties for the SVG shadow effect.
  2202. */
  2203. Graph.prototype.svgShadowColor = '#3D4574';
  2204. /**
  2205. * Properties for the SVG shadow effect.
  2206. */
  2207. Graph.prototype.svgShadowOpacity = '0.4';
  2208. /**
  2209. * Properties for the SVG shadow effect.
  2210. */
  2211. Graph.prototype.svgShadowBlur = '1.7';
  2212. /**
  2213. * Properties for the SVG shadow effect.
  2214. */
  2215. Graph.prototype.svgShadowSize = '3';
  2216. /**
  2217. * Enables move of bends/segments without selecting.
  2218. */
  2219. Graph.prototype.edgeMode = urlParams['edge'] != 'move';
  2220. /**
  2221. * Adds rack child layout style.
  2222. */
  2223. var graphInit = Graph.prototype.init;
  2224. Graph.prototype.init = function()
  2225. {
  2226. graphInit.apply(this, arguments);
  2227. // Override insert location for current mouse point
  2228. var mouseEvent = null;
  2229. function setMouseEvent(evt)
  2230. {
  2231. mouseEvent = evt;
  2232. // Workaround for member not found in IE8-
  2233. if (mxClient.IS_QUIRKS || document.documentMode == 7 || document.documentMode == 8)
  2234. {
  2235. mouseEvent = mxUtils.clone(evt);
  2236. }
  2237. };
  2238. mxEvent.addListener(this.container, 'mouseenter', setMouseEvent);
  2239. mxEvent.addListener(this.container, 'mousemove', setMouseEvent);
  2240. mxEvent.addListener(this.container, 'mouseleave', function(evt)
  2241. {
  2242. mouseEvent = null;
  2243. });
  2244. // Extends getInsertPoint to use the current mouse location
  2245. this.isMouseInsertPoint = function()
  2246. {
  2247. return mouseEvent != null;
  2248. };
  2249. var getInsertPoint = this.getInsertPoint;
  2250. this.getInsertPoint = function()
  2251. {
  2252. if (mouseEvent != null)
  2253. {
  2254. return this.getPointForEvent(mouseEvent);
  2255. }
  2256. return getInsertPoint.apply(this, arguments);
  2257. };
  2258. var layoutManagerGetLayout = this.layoutManager.getLayout;
  2259. this.layoutManager.getLayout = function(cell)
  2260. {
  2261. var state = this.graph.view.getState(cell);
  2262. var style = (state != null) ? state.style : this.graph.getCellStyle(cell);
  2263. // mxRackContainer may be undefined as it is dynamically loaded at render time
  2264. if (style != null)
  2265. {
  2266. if (typeof(mxRackContainer) != 'undefined' && style['childLayout'] == 'rack')
  2267. {
  2268. var rackLayout = new mxStackLayout(this.graph, false);
  2269. rackLayout.setChildGeometry = function(child, geo)
  2270. {
  2271. var unitSize = 20;
  2272. geo.height = Math.max(geo.height, unitSize);
  2273. if (geo.height / unitSize > 1)
  2274. {
  2275. var mod = geo.height % unitSize;
  2276. geo.height += mod > unitSize / 2 ? (unitSize - mod) : -mod;
  2277. }
  2278. this.graph.getModel().setGeometry(child, geo);
  2279. };
  2280. rackLayout.fill = true;
  2281. rackLayout.unitSize = mxRackContainer.unitSize | 20;
  2282. rackLayout.marginLeft = style['marginLeft'] || 0;
  2283. rackLayout.marginRight = style['marginRight'] || 0;
  2284. rackLayout.marginTop = style['marginTop'] || 0;
  2285. rackLayout.marginBottom = style['marginBottom'] || 0;
  2286. rackLayout.resizeParent = false;
  2287. return rackLayout;
  2288. }
  2289. else if (typeof(mxTableLayout) != 'undefined' && style['childLayout'] == 'tableLayout')
  2290. {
  2291. var tableLayout = new mxTableLayout(this.graph);
  2292. tableLayout.rows = style['tableRows'] || 2;
  2293. tableLayout.columns = style['tableColumns'] || 2;
  2294. tableLayout.colPercentages = style['colPercentages'];
  2295. tableLayout.rowPercentages = style['rowPercentages'];
  2296. tableLayout.equalColumns = mxUtils.getValue(style, 'equalColumns', tableLayout.colPercentages? '0' : '1') == '1';
  2297. tableLayout.equalRows = mxUtils.getValue(style, 'equalRows', tableLayout.rowPercentages? '0' : '1') == '1';
  2298. tableLayout.resizeParent = mxUtils.getValue(style, 'resizeParent', '1') == '1';
  2299. tableLayout.border = style['tableBorder'] || tableLayout.border;
  2300. tableLayout.marginLeft = style['marginLeft'] || 0;
  2301. tableLayout.marginRight = style['marginRight'] || 0;
  2302. tableLayout.marginTop = style['marginTop'] || 0;
  2303. tableLayout.marginBottom = style['marginBottom'] || 0;
  2304. tableLayout.autoAddCol = mxUtils.getValue(style, 'autoAddCol', '0') == '1';
  2305. tableLayout.autoAddRow = mxUtils.getValue(style, 'autoAddRow', tableLayout.autoAddCol? '0' : '1') == '1';
  2306. tableLayout.colWidths = style['colWidths'] || "100";
  2307. tableLayout.rowHeights = style['rowHeights'] || "50";
  2308. return tableLayout;
  2309. }
  2310. }
  2311. return layoutManagerGetLayout.apply(this, arguments);
  2312. }
  2313. };
  2314. /**
  2315. * Safari has problems with math typesetting inside foreignObjects.
  2316. */
  2317. var graphIsCssTransformsSupported = Graph.prototype.isCssTransformsSupported;
  2318. Graph.prototype.isCssTransformsSupported = function()
  2319. {
  2320. // FIXME: Safari only disabled due to mathjax rendering errors
  2321. return graphIsCssTransformsSupported.apply(this, arguments) && !mxClient.IS_SF;
  2322. };
  2323. /**
  2324. * Adds support for vars URL parameter.
  2325. */
  2326. var graphGetGlobalVariable = Graph.prototype.getGlobalVariable;
  2327. Graph.prototype.getGlobalVariable = function(name)
  2328. {
  2329. var val = graphGetGlobalVariable.apply(this, arguments);
  2330. if (val == null)
  2331. {
  2332. if (this.globalUrlVars == null && urlParams['vars'] != null)
  2333. {
  2334. try
  2335. {
  2336. this.globalUrlVars = JSON.parse(decodeURIComponent(urlParams['vars']));
  2337. }
  2338. catch (e)
  2339. {
  2340. if (window.console != null)
  2341. {
  2342. console.log('Error in vars URL parameter: ' + e);
  2343. }
  2344. }
  2345. }
  2346. if (this.globalUrlVars != null)
  2347. {
  2348. val = this.globalUrlVars[name];
  2349. }
  2350. }
  2351. return val;
  2352. };
  2353. /**
  2354. * Adds workaround for math rendering in Chrome.
  2355. *
  2356. * Workaround for https://bugs.webkit.org/show_bug.cgi?id=93358 in WebKit
  2357. *
  2358. * Adding an absolute position DIV before the SVG seems to mitigate the problem.
  2359. */
  2360. var graphViewValidateBackgroundPage = mxGraphView.prototype.validateBackgroundPage;
  2361. mxGraphView.prototype.validateBackgroundPage = function()
  2362. {
  2363. graphViewValidateBackgroundPage.apply(this, arguments);
  2364. if (mxClient.IS_GC && this.getDrawPane() != null)
  2365. {
  2366. var g = this.getDrawPane().parentNode;
  2367. if (this.graph.mathEnabled && !mxClient.NO_FO &&
  2368. (this.webKitForceRepaintNode == null ||
  2369. this.webKitForceRepaintNode.parentNode == null) &&
  2370. this.graph.container.firstChild.nodeName == 'svg')
  2371. {
  2372. this.webKitForceRepaintNode = document.createElement('div');
  2373. this.webKitForceRepaintNode.style.cssText = 'position:absolute;';
  2374. g.ownerSVGElement.parentNode.insertBefore(this.webKitForceRepaintNode, g.ownerSVGElement);
  2375. }
  2376. else if (this.webKitForceRepaintNode != null && (!this.graph.mathEnabled ||
  2377. (this.graph.container.firstChild.nodeName != 'svg' &&
  2378. this.graph.container.firstChild != this.webKitForceRepaintNode)))
  2379. {
  2380. if (this.webKitForceRepaintNode.parentNode != null)
  2381. {
  2382. this.webKitForceRepaintNode.parentNode.removeChild(this.webKitForceRepaintNode);
  2383. }
  2384. this.webKitForceRepaintNode = null;
  2385. }
  2386. }
  2387. };
  2388. /**
  2389. * Sets default style (used in editor.get/setGraphXml below)
  2390. */
  2391. var graphLoadStylesheet = Graph.prototype.loadStylesheet;
  2392. Graph.prototype.loadStylesheet = function()
  2393. {
  2394. graphLoadStylesheet.apply(this, arguments);
  2395. this.currentStyle = 'default-style2';
  2396. };
  2397. /**
  2398. * Adds support for data:action/json,{"actions":[actions]} where actions is
  2399. * a comma-separated list of JSON objects with the following possible keys:
  2400. *
  2401. * "open": string - opens a standard or custom link (including page links)
  2402. * "toggle"/"show"/"hide"/"highlight": cellset - toggles, shows, hides or
  2403. * highlights the given cells
  2404. * "select": cellset - selects the given cells if the graph is editable
  2405. * "scroll": cellset - scrolls to the first cell in the given celllset
  2406. * If no scroll action is specified, then the first cell of the select
  2407. * or highlight action is scrolled to visible (select has precedence).
  2408. * A cellset is an array of cell IDs or tags or both, eg.
  2409. * {"cells": ["id1", "id2"], "tags": ["tag1", "tag2"]}
  2410. * To specify all cells, use "cells": ["*"], to specify all cells with
  2411. * a tag, use "tags": [] (empty array).
  2412. *
  2413. * An example action is:
  2414. *
  2415. * data:action/json,{"actions":[{"toggle": {"cells": ["3", "4"]}}]}
  2416. *
  2417. * This toggles the visible state of the cells with ID 3 and 4.
  2418. */
  2419. Graph.prototype.handleCustomLink = function(href)
  2420. {
  2421. if (href.substring(0, 17) == 'data:action/json,')
  2422. {
  2423. // Some actions are stateless and must be handled before the transaction
  2424. var action = JSON.parse(href.substring(17));
  2425. if (action.actions != null)
  2426. {
  2427. // Executes open actions before starting transaction
  2428. for (var i = 0; i < action.actions.length; i++)
  2429. {
  2430. if (action.actions[i].open != null)
  2431. {
  2432. if (this.isCustomLink(action.actions[i].open))
  2433. {
  2434. if (!this.customLinkClicked(action.actions[i].open))
  2435. {
  2436. return;
  2437. }
  2438. }
  2439. else
  2440. {
  2441. this.openLink(action.actions[i].open);
  2442. }
  2443. }
  2444. }
  2445. this.model.beginUpdate();
  2446. try
  2447. {
  2448. for (var i = 0; i < action.actions.length; i++)
  2449. {
  2450. this.handleLinkAction(action.actions[i]);
  2451. }
  2452. }
  2453. finally
  2454. {
  2455. this.model.endUpdate();
  2456. }
  2457. }
  2458. }
  2459. };
  2460. /**
  2461. * Executes the given action if it must be executed inside of a transaction.
  2462. */
  2463. Graph.prototype.handleLinkAction = function(action)
  2464. {
  2465. var cells = [];
  2466. if (action.select != null && this.isEnabled())
  2467. {
  2468. cells = this.getCellsForAction(action.select);
  2469. this.setSelectionCells(cells);
  2470. }
  2471. if (action.highlight != null)
  2472. {
  2473. cells = this.getCellsForAction(action.highlight);
  2474. this.highlightCells(cells, action.highlight.color,
  2475. action.highlight.duration, action.highlight.opacity);
  2476. }
  2477. if (action.toggle != null)
  2478. {
  2479. this.toggleCells(this.getCellsForAction(action.toggle));
  2480. }
  2481. if (action.show != null)
  2482. {
  2483. this.setCellsVisible(this.getCellsForAction(action.show), true);
  2484. }
  2485. if (action.hide != null)
  2486. {
  2487. this.setCellsVisible(this.getCellsForAction(action.hide), false);
  2488. }
  2489. if (action.scroll != null)
  2490. {
  2491. cells = this.getCellsForAction(action.scroll);
  2492. }
  2493. if (cells.length > 0)
  2494. {
  2495. this.scrollCellToVisible(cells[0]);
  2496. }
  2497. };
  2498. /**
  2499. * Handles each action in the action array of a custom link. This code
  2500. * handles toggle actions for cell IDs.
  2501. */
  2502. Graph.prototype.getCellsForAction = function(action)
  2503. {
  2504. return this.getCellsById(action.cells).concat(
  2505. this.getCellsForTags(action.tags));
  2506. };
  2507. /**
  2508. * Returns the cells in the model (or given array) that have all of the
  2509. * given tags in their tags property.
  2510. */
  2511. Graph.prototype.getCellsById = function(ids)
  2512. {
  2513. var result = [];
  2514. if (ids != null)
  2515. {
  2516. for (var i = 0; i < ids.length; i++)
  2517. {
  2518. if (ids[i] == '*')
  2519. {
  2520. var parent = this.getDefaultParent();
  2521. result = result.concat(this.model.filterDescendants(function(cell)
  2522. {
  2523. return cell != parent;
  2524. }, parent));
  2525. }
  2526. else
  2527. {
  2528. var cell = this.model.getCell(ids[i]);
  2529. if (cell != null)
  2530. {
  2531. result.push(cell);
  2532. }
  2533. }
  2534. }
  2535. }
  2536. return result;
  2537. };
  2538. /**
  2539. * Returns the cells in the model (or given array) that have all of the
  2540. * given tags in their tags property.
  2541. */
  2542. Graph.prototype.getCellsForTags = function(tagList, cells, propertyName)
  2543. {
  2544. var result = [];
  2545. if (tagList != null)
  2546. {
  2547. cells = (cells != null) ? cells : this.model.getDescendants(this.model.getRoot());
  2548. propertyName = (propertyName != null) ? propertyName : 'tags';
  2549. for (var i = 0; i < cells.length; i++)
  2550. {
  2551. if (this.model.isVertex(cells[i]) || this.model.isEdge(cells[i]))
  2552. {
  2553. var tags = (cells[i].value != null && typeof(cells[i].value) == 'object') ?
  2554. mxUtils.trim(cells[i].value.getAttribute(propertyName) || '') : '';
  2555. var match = true;
  2556. if (tags.length > 0)
  2557. {
  2558. var tmp = tags.toLowerCase().split(' ');
  2559. for (var j = 0; j < tagList.length && match; j++)
  2560. {
  2561. var tag = mxUtils.trim(tagList[j]).toLowerCase();
  2562. match = match && (tag.length == 0 || mxUtils.indexOf(tmp, tag) >= 0);
  2563. }
  2564. }
  2565. else
  2566. {
  2567. match = tagList.length == 0;
  2568. }
  2569. if (match)
  2570. {
  2571. result.push(cells[i]);
  2572. }
  2573. }
  2574. }
  2575. }
  2576. return result;
  2577. };
  2578. /**
  2579. * Shows or hides the given cells.
  2580. */
  2581. Graph.prototype.toggleCells = function(cells)
  2582. {
  2583. this.model.beginUpdate();
  2584. try
  2585. {
  2586. for (var i = 0; i < cells.length; i++)
  2587. {
  2588. this.model.setVisible(cells[i], !this.model.isVisible(cells[i]))
  2589. }
  2590. }
  2591. finally
  2592. {
  2593. this.model.endUpdate();
  2594. }
  2595. };
  2596. /**
  2597. * Shows or hides the given cells.
  2598. */
  2599. Graph.prototype.setCellsVisible = function(cells, visible)
  2600. {
  2601. this.model.beginUpdate();
  2602. try
  2603. {
  2604. for (var i = 0; i < cells.length; i++)
  2605. {
  2606. this.model.setVisible(cells[i], visible);
  2607. }
  2608. }
  2609. finally
  2610. {
  2611. this.model.endUpdate();
  2612. }
  2613. };
  2614. /**
  2615. * Highlights the given cell.
  2616. */
  2617. Graph.prototype.highlightCells = function(cells, color, duration, opacity)
  2618. {
  2619. for (var i = 0; i < cells.length; i++)
  2620. {
  2621. this.highlightCell(cells[i], color, duration, opacity);
  2622. }
  2623. };
  2624. /**
  2625. * Highlights the given cell.
  2626. */
  2627. Graph.prototype.highlightCell = function(cell, color, duration, opacity)
  2628. {
  2629. color = (color != null) ? color : mxConstants.DEFAULT_VALID_COLOR;
  2630. duration = (duration != null) ? duration : 1000;
  2631. var state = this.view.getState(cell);
  2632. if (state != null)
  2633. {
  2634. var sw = Math.max(5, mxUtils.getValue(state.style, mxConstants.STYLE_STROKEWIDTH, 1) + 4);
  2635. var hl = new mxCellHighlight(this, color, sw, false);
  2636. if (opacity != null)
  2637. {
  2638. hl.opacity = opacity;
  2639. }
  2640. hl.highlight(state);
  2641. // Fades out the highlight after a duration
  2642. window.setTimeout(function()
  2643. {
  2644. if (hl.shape != null)
  2645. {
  2646. mxUtils.setPrefixedStyle(hl.shape.node.style, 'transition', 'all 1200ms ease-in-out');
  2647. hl.shape.node.style.opacity = 0;
  2648. }
  2649. // Destroys the highlight after the fade
  2650. window.setTimeout(function()
  2651. {
  2652. hl.destroy();
  2653. }, 1200);
  2654. }, duration);
  2655. }
  2656. };
  2657. /**
  2658. * Adds a shadow filter to the given svg root.
  2659. */
  2660. Graph.prototype.addSvgShadow = function(svgRoot, group, createOnly)
  2661. {
  2662. createOnly = (createOnly != null) ? createOnly : false;
  2663. var svgDoc = svgRoot.ownerDocument;
  2664. var filter = (svgDoc.createElementNS != null) ?
  2665. svgDoc.createElementNS(mxConstants.NS_SVG, 'filter') : svgDoc.createElement('filter');
  2666. filter.setAttribute('id', this.shadowId);
  2667. var blur = (svgDoc.createElementNS != null) ?
  2668. svgDoc.createElementNS(mxConstants.NS_SVG, 'feGaussianBlur') : svgDoc.createElement('feGaussianBlur');
  2669. blur.setAttribute('in', 'SourceAlpha');
  2670. blur.setAttribute('stdDeviation', this.svgShadowBlur);
  2671. blur.setAttribute('result', 'blur');
  2672. filter.appendChild(blur);
  2673. var offset = (svgDoc.createElementNS != null) ?
  2674. svgDoc.createElementNS(mxConstants.NS_SVG, 'feOffset') : svgDoc.createElement('feOffset');
  2675. offset.setAttribute('in', 'blur');
  2676. offset.setAttribute('dx', this.svgShadowSize);
  2677. offset.setAttribute('dy', this.svgShadowSize);
  2678. offset.setAttribute('result', 'offsetBlur');
  2679. filter.appendChild(offset);
  2680. var flood = (svgDoc.createElementNS != null) ?
  2681. svgDoc.createElementNS(mxConstants.NS_SVG, 'feFlood') : svgDoc.createElement('feFlood');
  2682. flood.setAttribute('flood-color', this.svgShadowColor);
  2683. flood.setAttribute('flood-opacity', this.svgShadowOpacity);
  2684. flood.setAttribute('result', 'offsetColor');
  2685. filter.appendChild(flood);
  2686. var composite = (svgDoc.createElementNS != null) ?
  2687. svgDoc.createElementNS(mxConstants.NS_SVG, 'feComposite') : svgDoc.createElement('feComposite');
  2688. composite.setAttribute('in', 'offsetColor');
  2689. composite.setAttribute('in2', 'offsetBlur');
  2690. composite.setAttribute('operator', 'in');
  2691. composite.setAttribute('result', 'offsetBlur');
  2692. filter.appendChild(composite);
  2693. var feBlend = (svgDoc.createElementNS != null) ?
  2694. svgDoc.createElementNS(mxConstants.NS_SVG, 'feBlend') : svgDoc.createElement('feBlend');
  2695. feBlend.setAttribute('in', 'SourceGraphic');
  2696. feBlend.setAttribute('in2', 'offsetBlur');
  2697. filter.appendChild(feBlend);
  2698. // Creates defs element if not available
  2699. var defs = svgRoot.getElementsByTagName('defs');
  2700. var defsElt = null;
  2701. if (defs.length == 0)
  2702. {
  2703. defsElt = (svgDoc.createElementNS != null) ?
  2704. svgDoc.createElementNS(mxConstants.NS_SVG, 'defs') : svgDoc.createElement('defs');
  2705. if (svgRoot.firstChild != null)
  2706. {
  2707. svgRoot.insertBefore(defsElt, svgRoot.firstChild);
  2708. }
  2709. else
  2710. {
  2711. svgRoot.appendChild(defsElt);
  2712. }
  2713. }
  2714. else
  2715. {
  2716. defsElt = defs[0];
  2717. }
  2718. defsElt.appendChild(filter);
  2719. if (!createOnly)
  2720. {
  2721. (group || svgRoot.getElementsByTagName('g')[0]).setAttribute('filter', 'url(#' + this.shadowId + ')');
  2722. if (!isNaN(parseInt(svgRoot.getAttribute('width'))))
  2723. {
  2724. svgRoot.setAttribute('width', parseInt(svgRoot.getAttribute('width')) + 6);
  2725. svgRoot.setAttribute('height', parseInt(svgRoot.getAttribute('height')) + 6);
  2726. }
  2727. }
  2728. return filter;
  2729. };
  2730. /**
  2731. * Loads the stylesheet for this graph.
  2732. */
  2733. Graph.prototype.setShadowVisible = function(value, fireEvent)
  2734. {
  2735. if (mxClient.IS_SVG)
  2736. {
  2737. fireEvent = (fireEvent != null) ? fireEvent : true;
  2738. this.shadowVisible = value;
  2739. if (this.shadowVisible)
  2740. {
  2741. this.view.getDrawPane().setAttribute('filter', 'url(#' + this.shadowId + ')');
  2742. }
  2743. else
  2744. {
  2745. this.view.getDrawPane().removeAttribute('filter');
  2746. }
  2747. if (fireEvent)
  2748. {
  2749. this.fireEvent(new mxEventObject('shadowVisibleChanged'));
  2750. }
  2751. }
  2752. };
  2753. /**
  2754. * Selects first unlocked layer if one exists
  2755. */
  2756. Graph.prototype.selectUnlockedLayer = function()
  2757. {
  2758. if (this.defaultParent == null)
  2759. {
  2760. var childCount = this.model.getChildCount(this.model.root);
  2761. var cell = null;
  2762. var index = 0;
  2763. do
  2764. {
  2765. cell = this.model.getChildAt(this.model.root, index);
  2766. } while (index++ < childCount && mxUtils.getValue(this.getCellStyle(cell), 'locked', '0') == '1')
  2767. if (cell != null)
  2768. {
  2769. this.setDefaultParent(cell);
  2770. }
  2771. }
  2772. };
  2773. /**
  2774. * Specifies special libraries that are loaded via dynamic JS. Add cases
  2775. * where the filename cannot be worked out from the package name. The
  2776. * standard scheme for this mapping is stencils/packagename.xml. If there
  2777. * are multiple XML files, any JS files or any anomalies in the filename or
  2778. * directory that contains the file, then an entry must be added here and
  2779. * in EmbedServlet2 for the loading of the shapes to work.
  2780. */
  2781. // Required to avoid 404 for mockup.xml since naming of mxgraph.mockup.anchor does not contain
  2782. // buttons even though it is defined in the mxMockupButtons.js file. This could only be fixed
  2783. // with aliases for existing shapes or aliases for basenames, but this is essentially the same.
  2784. mxStencilRegistry.libraries['mockup'] = [SHAPES_PATH + '/mockup/mxMockupButtons.js'];
  2785. mxStencilRegistry.libraries['arrows2'] = [SHAPES_PATH + '/mxArrows.js'];
  2786. mxStencilRegistry.libraries['atlassian'] = [STENCIL_PATH + '/atlassian.xml', SHAPES_PATH + '/mxAtlassian.js'];
  2787. mxStencilRegistry.libraries['bpmn'] = [SHAPES_PATH + '/bpmn/mxBpmnShape2.js', STENCIL_PATH + '/bpmn.xml'];
  2788. mxStencilRegistry.libraries['dfd'] = [SHAPES_PATH + '/mxDFD.js'];
  2789. mxStencilRegistry.libraries['er'] = [SHAPES_PATH + '/er/mxER.js'];
  2790. mxStencilRegistry.libraries['flowchart'] = [SHAPES_PATH + '/mxFlowchart.js', STENCIL_PATH + '/flowchart.xml'];
  2791. mxStencilRegistry.libraries['ios'] = [SHAPES_PATH + '/mockup/mxMockupiOS.js'];
  2792. mxStencilRegistry.libraries['rackGeneral'] = [SHAPES_PATH + '/rack/mxRack.js', STENCIL_PATH + '/rack/general.xml'];
  2793. mxStencilRegistry.libraries['rackF5'] = [STENCIL_PATH + '/rack/f5.xml'];
  2794. mxStencilRegistry.libraries['lean_mapping'] = [SHAPES_PATH + '/mxLeanMap.js', STENCIL_PATH + '/lean_mapping.xml'];
  2795. mxStencilRegistry.libraries['basic'] = [SHAPES_PATH + '/mxBasic.js', STENCIL_PATH + '/basic.xml'];
  2796. mxStencilRegistry.libraries['ios7icons'] = [STENCIL_PATH + '/ios7/icons.xml'];
  2797. mxStencilRegistry.libraries['ios7ui'] = [SHAPES_PATH + '/ios7/mxIOS7Ui.js', STENCIL_PATH + '/ios7/misc.xml'];
  2798. mxStencilRegistry.libraries['android'] = [SHAPES_PATH + '/mxAndroid.js', STENCIL_PATH + '/android/android.xml'];
  2799. mxStencilRegistry.libraries['electrical/transmission'] = [SHAPES_PATH + '/mxElectrical.js', STENCIL_PATH + '/electrical/transmission.xml'];
  2800. // mxStencilRegistry.libraries['electrical/logic_gates'] = [SHAPES_PATH + '/mxElectrical.js', STENCIL_PATH + '/electrical/logic_gates.xml'];
  2801. mxStencilRegistry.libraries['infographic'] = [SHAPES_PATH + '/mxInfographic.js'];
  2802. mxStencilRegistry.libraries['mockup/buttons'] = [SHAPES_PATH + '/mockup/mxMockupButtons.js'];
  2803. mxStencilRegistry.libraries['mockup/containers'] = [SHAPES_PATH + '/mockup/mxMockupContainers.js'];
  2804. mxStencilRegistry.libraries['mockup/forms'] = [SHAPES_PATH + '/mockup/mxMockupForms.js'];
  2805. mxStencilRegistry.libraries['mockup/graphics'] = [SHAPES_PATH + '/mockup/mxMockupGraphics.js', STENCIL_PATH + '/mockup/misc.xml'];
  2806. mxStencilRegistry.libraries['mockup/markup'] = [SHAPES_PATH + '/mockup/mxMockupMarkup.js'];
  2807. mxStencilRegistry.libraries['mockup/misc'] = [SHAPES_PATH + '/mockup/mxMockupMisc.js', STENCIL_PATH + '/mockup/misc.xml'];
  2808. mxStencilRegistry.libraries['mockup/navigation'] = [SHAPES_PATH + '/mockup/mxMockupNavigation.js', STENCIL_PATH + '/mockup/misc.xml'];
  2809. mxStencilRegistry.libraries['mockup/text'] = [SHAPES_PATH + '/mockup/mxMockupText.js'];
  2810. mxStencilRegistry.libraries['floorplan'] = [SHAPES_PATH + '/mxFloorplan.js', STENCIL_PATH + '/floorplan.xml'];
  2811. mxStencilRegistry.libraries['bootstrap'] = [SHAPES_PATH + '/mxBootstrap.js', STENCIL_PATH + '/bootstrap.xml'];
  2812. mxStencilRegistry.libraries['gmdl'] = [SHAPES_PATH + '/mxGmdl.js', STENCIL_PATH + '/gmdl.xml'];
  2813. mxStencilRegistry.libraries['gcp2'] = [SHAPES_PATH + '/mxGCP2.js', STENCIL_PATH + '/gcp2.xml'];
  2814. mxStencilRegistry.libraries['cabinets'] = [SHAPES_PATH + '/mxCabinets.js', STENCIL_PATH + '/cabinets.xml'];
  2815. mxStencilRegistry.libraries['archimate'] = [SHAPES_PATH + '/mxArchiMate.js'];
  2816. mxStencilRegistry.libraries['archimate3'] = [SHAPES_PATH + '/mxArchiMate3.js'];
  2817. mxStencilRegistry.libraries['sysml'] = [SHAPES_PATH + '/mxSysML.js'];
  2818. mxStencilRegistry.libraries['eip'] = [SHAPES_PATH + '/mxEip.js', STENCIL_PATH + '/eip.xml'];
  2819. mxStencilRegistry.libraries['networks'] = [SHAPES_PATH + '/mxNetworks.js', STENCIL_PATH + '/networks.xml'];
  2820. mxStencilRegistry.libraries['aws3d'] = [SHAPES_PATH + '/mxAWS3D.js', STENCIL_PATH + '/aws3d.xml'];
  2821. mxStencilRegistry.libraries['aws4'] = [SHAPES_PATH + '/mxAWS4.js', STENCIL_PATH + '/aws4.xml'];
  2822. mxStencilRegistry.libraries['veeam'] = [STENCIL_PATH + '/veeam/2d.xml', STENCIL_PATH + '/veeam/3d.xml', STENCIL_PATH + '/veeam/veeam.xml'];
  2823. mxStencilRegistry.libraries['pid2inst'] = [SHAPES_PATH + '/pid2/mxPidInstruments.js'];
  2824. mxStencilRegistry.libraries['pid2misc'] = [SHAPES_PATH + '/pid2/mxPidMisc.js', STENCIL_PATH + '/pid/misc.xml'];
  2825. mxStencilRegistry.libraries['pid2valves'] = [SHAPES_PATH + '/pid2/mxPidValves.js'];
  2826. mxStencilRegistry.libraries['pidFlowSensors'] = [STENCIL_PATH + '/pid/flow_sensors.xml'];
  2827. // Triggers dynamic loading for markers
  2828. mxMarker.getPackageForType = function(type)
  2829. {
  2830. var name = null;
  2831. if (type != null && type.length > 0)
  2832. {
  2833. if (type.substring(0, 2) == 'ER')
  2834. {
  2835. name = 'mxgraph.er';
  2836. }
  2837. else if (type.substring(0, 5) == 'sysML')
  2838. {
  2839. name = 'mxgraph.sysml';
  2840. }
  2841. }
  2842. return name;
  2843. };
  2844. var mxMarkerCreateMarker = mxMarker.createMarker;
  2845. mxMarker.createMarker = function(canvas, shape, type, pe, unitX, unitY, size, source, sw, filled)
  2846. {
  2847. if (type != null)
  2848. {
  2849. var f = mxMarker.markers[type];
  2850. if (f == null)
  2851. {
  2852. var name = this.getPackageForType(type);
  2853. if (name != null)
  2854. {
  2855. mxStencilRegistry.getStencil(name);
  2856. }
  2857. }
  2858. }
  2859. return mxMarkerCreateMarker.apply(this, arguments);
  2860. };
  2861. /**
  2862. * Constructs a new print dialog.
  2863. */
  2864. PrintDialog.prototype.create = function(editorUi, titleText)
  2865. {
  2866. var graph = editorUi.editor.graph;
  2867. var div = document.createElement('div');
  2868. var title = document.createElement('h3');
  2869. title.style.width = '100%';
  2870. title.style.textAlign = 'center';
  2871. title.style.marginTop = '0px';
  2872. mxUtils.write(title, titleText || mxResources.get('print'));
  2873. div.appendChild(title);
  2874. var pageCount = 1;
  2875. var currentPage = 1;
  2876. // Pages
  2877. var pagesSection = document.createElement('div');
  2878. pagesSection.style.cssText = 'border-bottom:1px solid lightGray;padding-bottom:12px;margin-bottom:12px;';
  2879. var allPagesRadio = document.createElement('input');
  2880. allPagesRadio.style.cssText = 'margin-right:8px;margin-bottom:8px;';
  2881. allPagesRadio.setAttribute('value', 'all');
  2882. allPagesRadio.setAttribute('type', 'radio');
  2883. allPagesRadio.setAttribute('name', 'pages-printdialog');
  2884. pagesSection.appendChild(allPagesRadio);
  2885. var span = document.createElement('span');
  2886. mxUtils.write(span, mxResources.get('printAllPages'));
  2887. pagesSection.appendChild(span);
  2888. mxUtils.br(pagesSection);
  2889. // Pages ... to ...
  2890. var pagesRadio = allPagesRadio.cloneNode(true);
  2891. allPagesRadio.setAttribute('checked', 'checked');
  2892. pagesRadio.setAttribute('value', 'range');
  2893. pagesSection.appendChild(pagesRadio);
  2894. var span = document.createElement('span');
  2895. mxUtils.write(span, mxResources.get('pages') + ':');
  2896. pagesSection.appendChild(span);
  2897. var pagesFromInput = document.createElement('input');
  2898. pagesFromInput.style.cssText = 'margin:0 8px 0 8px;'
  2899. pagesFromInput.setAttribute('value', '1');
  2900. pagesFromInput.setAttribute('type', 'number');
  2901. pagesFromInput.setAttribute('min', '1');
  2902. pagesFromInput.style.width = '50px';
  2903. pagesSection.appendChild(pagesFromInput);
  2904. var span = document.createElement('span');
  2905. mxUtils.write(span, mxResources.get('to'));
  2906. pagesSection.appendChild(span);
  2907. var pagesToInput = pagesFromInput.cloneNode(true);
  2908. pagesSection.appendChild(pagesToInput);
  2909. mxEvent.addListener(pagesFromInput, 'focus', function()
  2910. {
  2911. pagesRadio.checked = true;
  2912. });
  2913. mxEvent.addListener(pagesToInput, 'focus', function()
  2914. {
  2915. pagesRadio.checked = true;
  2916. });
  2917. function validatePageRange()
  2918. {
  2919. pagesToInput.value = Math.max(1, Math.min(pageCount, Math.max(parseInt(pagesToInput.value), parseInt(pagesFromInput.value))));
  2920. pagesFromInput.value = Math.max(1, Math.min(pageCount, Math.min(parseInt(pagesToInput.value), parseInt(pagesFromInput.value))));
  2921. };
  2922. mxEvent.addListener(pagesFromInput, 'change', validatePageRange);
  2923. mxEvent.addListener(pagesToInput, 'change', validatePageRange);
  2924. if (editorUi.pages != null)
  2925. {
  2926. pageCount = editorUi.pages.length;
  2927. if (editorUi.currentPage != null)
  2928. {
  2929. for (var i = 0; i < editorUi.pages.length; i++)
  2930. {
  2931. if (editorUi.currentPage == editorUi.pages[i])
  2932. {
  2933. currentPage = i + 1;
  2934. pagesFromInput.value = currentPage;
  2935. pagesToInput.value = currentPage;
  2936. break;
  2937. }
  2938. }
  2939. }
  2940. }
  2941. pagesFromInput.setAttribute('max', pageCount);
  2942. pagesToInput.setAttribute('max', pageCount);
  2943. if (pageCount > 1)
  2944. {
  2945. div.appendChild(pagesSection);
  2946. }
  2947. // Adjust to ...
  2948. var adjustSection = document.createElement('div');
  2949. adjustSection.style.marginBottom = '10px';
  2950. var adjustRadio = document.createElement('input');
  2951. adjustRadio.style.marginRight = '8px';
  2952. adjustRadio.setAttribute('value', 'adjust');
  2953. adjustRadio.setAttribute('type', 'radio');
  2954. adjustRadio.setAttribute('name', 'printZoom');
  2955. adjustSection.appendChild(adjustRadio);
  2956. var span = document.createElement('span');
  2957. mxUtils.write(span, mxResources.get('adjustTo'));
  2958. adjustSection.appendChild(span);
  2959. var zoomInput = document.createElement('input');
  2960. zoomInput.style.cssText = 'margin:0 8px 0 8px;';
  2961. zoomInput.setAttribute('value', '100 %');
  2962. zoomInput.style.width = '50px';
  2963. adjustSection.appendChild(zoomInput);
  2964. mxEvent.addListener(zoomInput, 'focus', function()
  2965. {
  2966. adjustRadio.checked = true;
  2967. });
  2968. div.appendChild(adjustSection);
  2969. // Fit to ...
  2970. var fitSection = pagesSection.cloneNode(false);
  2971. var fitRadio = adjustRadio.cloneNode(true);
  2972. fitRadio.setAttribute('value', 'fit');
  2973. adjustRadio.setAttribute('checked', 'checked');
  2974. var spanFitRadio = document.createElement('div');
  2975. spanFitRadio.style.cssText = 'display:inline-block;height:100%;vertical-align:top;padding-top:2px;';
  2976. spanFitRadio.appendChild(fitRadio);
  2977. fitSection.appendChild(spanFitRadio);
  2978. var table = document.createElement('table');
  2979. table.style.display = 'inline-block';
  2980. var tbody = document.createElement('tbody');
  2981. var row1 = document.createElement('tr');
  2982. var row2 = row1.cloneNode(true);
  2983. var td1 = document.createElement('td');
  2984. var td2 = td1.cloneNode(true);
  2985. var td3 = td1.cloneNode(true);
  2986. var td4 = td1.cloneNode(true);
  2987. var td5 = td1.cloneNode(true);
  2988. var td6 = td1.cloneNode(true);
  2989. td1.style.textAlign = 'right';
  2990. td4.style.textAlign = 'right';
  2991. mxUtils.write(td1, mxResources.get('fitTo'));
  2992. var sheetsAcrossInput = document.createElement('input');
  2993. sheetsAcrossInput.style.cssText = 'margin:0 8px 0 8px;';
  2994. sheetsAcrossInput.setAttribute('value', '1');
  2995. sheetsAcrossInput.setAttribute('min', '1');
  2996. sheetsAcrossInput.setAttribute('type', 'number');
  2997. sheetsAcrossInput.style.width = '40px';
  2998. td2.appendChild(sheetsAcrossInput);
  2999. var span = document.createElement('span');
  3000. mxUtils.write(span, mxResources.get('fitToSheetsAcross'));
  3001. td3.appendChild(span);
  3002. mxUtils.write(td4, mxResources.get('fitToBy'));
  3003. var sheetsDownInput = sheetsAcrossInput.cloneNode(true);
  3004. td5.appendChild(sheetsDownInput);
  3005. mxEvent.addListener(sheetsAcrossInput, 'focus', function()
  3006. {
  3007. fitRadio.checked = true;
  3008. });
  3009. mxEvent.addListener(sheetsDownInput, 'focus', function()
  3010. {
  3011. fitRadio.checked = true;
  3012. });
  3013. var span = document.createElement('span');
  3014. mxUtils.write(span, mxResources.get('fitToSheetsDown'));
  3015. td6.appendChild(span);
  3016. row1.appendChild(td1);
  3017. row1.appendChild(td2);
  3018. row1.appendChild(td3);
  3019. row2.appendChild(td4);
  3020. row2.appendChild(td5);
  3021. row2.appendChild(td6);
  3022. tbody.appendChild(row1);
  3023. tbody.appendChild(row2);
  3024. table.appendChild(tbody);
  3025. fitSection.appendChild(table);
  3026. div.appendChild(fitSection);
  3027. // Page scale ...
  3028. var pageScaleSection = document.createElement('div');
  3029. var span = document.createElement('div');
  3030. span.style.fontWeight = 'bold';
  3031. span.style.marginBottom = '12px';
  3032. mxUtils.write(span, mxResources.get('paperSize'));
  3033. pageScaleSection.appendChild(span);
  3034. var span = document.createElement('div');
  3035. span.style.marginBottom = '12px';
  3036. var accessor = PageSetupDialog.addPageFormatPanel(span, 'printdialog',
  3037. editorUi.editor.graph.pageFormat || mxConstants.PAGE_FORMAT_A4_PORTRAIT);
  3038. pageScaleSection.appendChild(span);
  3039. var span = document.createElement('span');
  3040. mxUtils.write(span, mxResources.get('pageScale'));
  3041. pageScaleSection.appendChild(span);
  3042. var pageScaleInput = document.createElement('input');
  3043. pageScaleInput.style.cssText = 'margin:0 8px 0 8px;';
  3044. pageScaleInput.setAttribute('value', '100 %');
  3045. pageScaleInput.style.width = '60px';
  3046. pageScaleSection.appendChild(pageScaleInput);
  3047. div.appendChild(pageScaleSection);
  3048. // Buttons
  3049. var buttons = document.createElement('div');
  3050. buttons.style.cssText = 'text-align:right;margin:48px 0 0 0;';
  3051. // Overall scale for print-out to account for print borders in dialogs etc
  3052. function preview(print)
  3053. {
  3054. var printScale = parseInt(pageScaleInput.value) / 100;
  3055. if (isNaN(printScale))
  3056. {
  3057. printScale = 1;
  3058. pageScaleInput.value = '100 %';
  3059. }
  3060. // Workaround to match available paper size in actual print output
  3061. printScale *= 0.75;
  3062. function printGraph(thisGraph, pv, forcePageBreaks)
  3063. {
  3064. // Negative coordinates are cropped or shifted if page visible
  3065. var gb = thisGraph.getGraphBounds();
  3066. var border = 0;
  3067. var x0 = 0;
  3068. var y0 = 0;
  3069. var pf = accessor.get();
  3070. var scale = 1 / thisGraph.pageScale;
  3071. var autoOrigin = fitRadio.checked;
  3072. if (autoOrigin)
  3073. {
  3074. var h = parseInt(sheetsAcrossInput.value);
  3075. var v = parseInt(sheetsDownInput.value);
  3076. scale = Math.min((pf.height * v) / (gb.height / thisGraph.view.scale),
  3077. (pf.width * h) / (gb.width / thisGraph.view.scale));
  3078. }
  3079. else
  3080. {
  3081. scale = parseInt(zoomInput.value) / (100 * thisGraph.pageScale);
  3082. if (isNaN(scale))
  3083. {
  3084. printScale = 1 / thisGraph.pageScale;
  3085. zoomInput.value = '100 %';
  3086. }
  3087. }
  3088. // Applies print scale
  3089. pf = mxRectangle.fromRectangle(pf);
  3090. pf.width = Math.ceil(pf.width * printScale);
  3091. pf.height = Math.ceil(pf.height * printScale);
  3092. scale *= printScale;
  3093. // Starts at first visible page
  3094. if (!autoOrigin && thisGraph.pageVisible)
  3095. {
  3096. var layout = thisGraph.getPageLayout();
  3097. x0 -= layout.x * pf.width;
  3098. y0 -= layout.y * pf.height;
  3099. }
  3100. else
  3101. {
  3102. autoOrigin = true;
  3103. }
  3104. if (pv == null)
  3105. {
  3106. pv = PrintDialog.createPrintPreview(thisGraph, scale, pf, border, x0, y0, autoOrigin);
  3107. pv.pageSelector = false;
  3108. pv.mathEnabled = false;
  3109. var file = editorUi.getCurrentFile();
  3110. if (file != null)
  3111. {
  3112. pv.title = file.getTitle();
  3113. }
  3114. var writeHead = pv.writeHead;
  3115. // Overridden to add custom fonts
  3116. pv.writeHead = function(doc)
  3117. {
  3118. writeHead.apply(this, arguments);
  3119. if (editorUi.editor.fontCss != null)
  3120. {
  3121. doc.writeln('<style type="text/css">');
  3122. doc.writeln(editorUi.editor.fontCss);
  3123. doc.writeln('</style>');
  3124. }
  3125. };
  3126. if (typeof(MathJax) !== 'undefined')
  3127. {
  3128. // Adds class to ignore if math is disabled
  3129. var printPreviewRenderPage = pv.renderPage;
  3130. pv.renderPage = function(w, h, dx, dy, content, pageNumber)
  3131. {
  3132. var prev = mxClient.NO_FO;
  3133. mxClient.NO_FO = (this.graph.mathEnabled && !this.useForeignObjectForMath) ?
  3134. true : this.originalNoForeignObject;
  3135. var result = printPreviewRenderPage.apply(this, arguments);
  3136. mxClient.NO_FO = prev;
  3137. if (this.graph.mathEnabled)
  3138. {
  3139. this.mathEnabled = this.mathEnabled || true;
  3140. }
  3141. else
  3142. {
  3143. result.className = 'geDisableMathJax';
  3144. }
  3145. return result;
  3146. };
  3147. }
  3148. pv.open(null, null, forcePageBreaks, true);
  3149. }
  3150. else
  3151. {
  3152. var bg = thisGraph.background;
  3153. if (bg == null || bg == '' || bg == mxConstants.NONE)
  3154. {
  3155. bg = '#ffffff';
  3156. }
  3157. pv.backgroundColor = bg;
  3158. pv.autoOrigin = autoOrigin;
  3159. pv.appendGraph(thisGraph, scale, x0, y0, forcePageBreaks, true);
  3160. }
  3161. return pv;
  3162. };
  3163. var pagesFrom = pagesFromInput.value;
  3164. var pagesTo = pagesToInput.value;
  3165. var ignorePages = !allPagesRadio.checked;
  3166. var pv = null;
  3167. if (ignorePages)
  3168. {
  3169. ignorePages = pagesFrom == currentPage && pagesTo == currentPage;
  3170. }
  3171. if (!ignorePages && editorUi.pages != null && editorUi.pages.length)
  3172. {
  3173. var i0 = 0;
  3174. var imax = editorUi.pages.length - 1;
  3175. if (!allPagesRadio.checked)
  3176. {
  3177. i0 = parseInt(pagesFrom) - 1;
  3178. imax = parseInt(pagesTo) - 1;
  3179. }
  3180. for (var i = i0; i <= imax; i++)
  3181. {
  3182. var page = editorUi.pages[i];
  3183. var tempGraph = (page == editorUi.currentPage) ? graph : null;
  3184. if (tempGraph == null)
  3185. {
  3186. tempGraph = editorUi.createTemporaryGraph(graph.getStylesheet());
  3187. // Restores graph settings that are relevant for printing
  3188. var pageVisible = true;
  3189. var mathEnabled = false;
  3190. var bg = null;
  3191. var bgImage = null;
  3192. if (page.viewState == null)
  3193. {
  3194. // Workaround to extract view state from XML node
  3195. // This changes the state of the page and parses
  3196. // the XML for the graph model even if not needed.
  3197. if (page.root == null)
  3198. {
  3199. editorUi.updatePageRoot(page);
  3200. }
  3201. }
  3202. if (page.viewState != null)
  3203. {
  3204. pageVisible = page.viewState.pageVisible;
  3205. mathEnabled = page.viewState.mathEnabled;
  3206. bg = page.viewState.background;
  3207. bgImage = page.viewState.backgroundImage;
  3208. }
  3209. tempGraph.background = bg;
  3210. tempGraph.backgroundImage = (bgImage != null) ? new mxImage(bgImage.src, bgImage.width, bgImage.height) : null;
  3211. tempGraph.pageVisible = pageVisible;
  3212. tempGraph.mathEnabled = mathEnabled;
  3213. // Redirects placeholders to current page
  3214. var graphGetGlobalVariable = tempGraph.getGlobalVariable;
  3215. tempGraph.getGlobalVariable = function(name)
  3216. {
  3217. if (name == 'page')
  3218. {
  3219. return page.getName();
  3220. }
  3221. else if (name == 'pagenumber')
  3222. {
  3223. return i + 1;
  3224. }
  3225. return graphGetGlobalVariable.apply(this, arguments);
  3226. };
  3227. document.body.appendChild(tempGraph.container);
  3228. editorUi.updatePageRoot(page);
  3229. tempGraph.model.setRoot(page.root);
  3230. }
  3231. pv = printGraph(tempGraph, pv, i != imax);
  3232. if (tempGraph != graph)
  3233. {
  3234. tempGraph.container.parentNode.removeChild(tempGraph.container);
  3235. }
  3236. }
  3237. }
  3238. else
  3239. {
  3240. pv = printGraph(graph);
  3241. }
  3242. if (pv.mathEnabled)
  3243. {
  3244. var doc = pv.wnd.document;
  3245. doc.writeln('<script type="text/x-mathjax-config">');
  3246. doc.writeln('MathJax.Hub.Config({');
  3247. doc.writeln('showMathMenu: false,');
  3248. doc.writeln('messageStyle: "none",');
  3249. doc.writeln('jax: ["input/TeX", "input/MathML", "input/AsciiMath", "output/HTML-CSS"],');
  3250. doc.writeln('extensions: ["tex2jax.js", "mml2jax.js", "asciimath2jax.js"],');
  3251. doc.writeln('"HTML-CSS": {');
  3252. doc.writeln('imageFont: null');
  3253. doc.writeln('},');
  3254. doc.writeln('TeX: {');
  3255. doc.writeln('extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]');
  3256. doc.writeln('},');
  3257. doc.writeln('tex2jax: {');
  3258. doc.writeln(' ignoreClass: "geDisableMathJax"');
  3259. doc.writeln('},');
  3260. doc.writeln('asciimath2jax: {');
  3261. doc.writeln(' ignoreClass: "geDisableMathJax"');
  3262. doc.writeln('}');
  3263. doc.writeln('});');
  3264. // Adds asynchronous printing when MathJax finished rendering
  3265. if (print)
  3266. {
  3267. doc.writeln('MathJax.Hub.Queue(function () {');
  3268. doc.writeln('window.print();');
  3269. doc.writeln('});');
  3270. }
  3271. doc.writeln('</script>');
  3272. doc.writeln('<script type="text/javascript" src="https://math.draw.io/current/MathJax.js"></script>');
  3273. }
  3274. pv.closeDocument();
  3275. if (!pv.mathEnabled && print)
  3276. {
  3277. PrintDialog.printPreview(pv);
  3278. }
  3279. };
  3280. var cancelBtn = mxUtils.button(mxResources.get('cancel'), function()
  3281. {
  3282. editorUi.hideDialog();
  3283. });
  3284. cancelBtn.className = 'geBtn';
  3285. if (editorUi.editor.cancelFirst)
  3286. {
  3287. buttons.appendChild(cancelBtn);
  3288. }
  3289. if (!editorUi.isOffline())
  3290. {
  3291. var helpBtn = mxUtils.button(mxResources.get('help'), function()
  3292. {
  3293. graph.openLink('https://desk.draw.io/support/solutions/articles/16000048947');
  3294. });
  3295. helpBtn.className = 'geBtn';
  3296. buttons.appendChild(helpBtn);
  3297. }
  3298. if (PrintDialog.previewEnabled)
  3299. {
  3300. var previewBtn = mxUtils.button(mxResources.get('preview'), function()
  3301. {
  3302. editorUi.hideDialog();
  3303. preview(false);
  3304. });
  3305. previewBtn.className = 'geBtn';
  3306. buttons.appendChild(previewBtn);
  3307. }
  3308. var printBtn = mxUtils.button(mxResources.get((!PrintDialog.previewEnabled) ? 'ok' : 'print'), function()
  3309. {
  3310. editorUi.hideDialog();
  3311. preview(true);
  3312. });
  3313. printBtn.className = 'geBtn gePrimaryBtn';
  3314. buttons.appendChild(printBtn);
  3315. if (!editorUi.editor.cancelFirst)
  3316. {
  3317. buttons.appendChild(cancelBtn);
  3318. }
  3319. div.appendChild(buttons);
  3320. this.container = div;
  3321. };
  3322. // Execute fit page on page setup changes
  3323. var changePageSetupExecute = ChangePageSetup.prototype.execute;
  3324. ChangePageSetup.prototype.execute = function()
  3325. {
  3326. if (this.page == null)
  3327. {
  3328. this.page = this.ui.currentPage;
  3329. }
  3330. // Workaround for redo existing change with different current page
  3331. if (this.page != this.ui.currentPage)
  3332. {
  3333. if (this.page.viewState != null)
  3334. {
  3335. if (!this.ignoreColor)
  3336. {
  3337. this.page.viewState.background = this.color;
  3338. }
  3339. if (!this.ignoreImage)
  3340. {
  3341. this.page.viewState.backgroundImage = this.image;
  3342. }
  3343. if (this.format != null)
  3344. {
  3345. this.page.viewState.pageFormat = this.format;
  3346. }
  3347. if (this.mathEnabled != null)
  3348. {
  3349. this.page.viewState.mathEnabled = this.mathEnabled;
  3350. }
  3351. if (this.shadowVisible != null)
  3352. {
  3353. this.page.viewState.shadowVisible = this.shadowVisible;
  3354. }
  3355. }
  3356. }
  3357. else
  3358. {
  3359. changePageSetupExecute.apply(this, arguments);
  3360. if (this.mathEnabled != null && this.mathEnabled != this.ui.isMathEnabled())
  3361. {
  3362. this.ui.setMathEnabled(this.mathEnabled);
  3363. this.mathEnabled = !this.mathEnabled;
  3364. }
  3365. if (this.shadowVisible != null && this.shadowVisible != this.ui.editor.graph.shadowVisible)
  3366. {
  3367. this.ui.editor.graph.setShadowVisible(this.shadowVisible);
  3368. this.shadowVisible = !this.shadowVisible;
  3369. }
  3370. }
  3371. };
  3372. })();
  3373. /**
  3374. *
  3375. */
  3376. var ErrorDialog = function(editorUi, title, message, buttonText, fn, retry, buttonText2, fn2, hide, buttonText3, fn3)
  3377. {
  3378. hide = (hide != null) ? hide : true;
  3379. var div = document.createElement('div');
  3380. div.style.textAlign = 'center';
  3381. if (title != null)
  3382. {
  3383. var hd = document.createElement('div');
  3384. hd.style.padding = '0px';
  3385. hd.style.margin = '0px';
  3386. hd.style.fontSize = '18px';
  3387. hd.style.paddingBottom = '16px';
  3388. hd.style.marginBottom = '16px';
  3389. hd.style.borderBottom = '1px solid #c0c0c0';
  3390. hd.style.color = 'gray';
  3391. mxUtils.write(hd, title);
  3392. div.appendChild(hd);
  3393. }
  3394. var p2 = document.createElement('div');
  3395. p2.style.padding = '6px';
  3396. p2.innerHTML = message;
  3397. div.appendChild(p2);
  3398. var btns = document.createElement('div');
  3399. btns.style.marginTop = '16px';
  3400. btns.style.textAlign = 'center';
  3401. if (retry != null)
  3402. {
  3403. var retryBtn = mxUtils.button(mxResources.get('tryAgain'), function()
  3404. {
  3405. editorUi.hideDialog();
  3406. retry();
  3407. });
  3408. retryBtn.className = 'geBtn';
  3409. btns.appendChild(retryBtn);
  3410. btns.style.textAlign = 'center';
  3411. }
  3412. if (buttonText3 != null)
  3413. {
  3414. var btn3 = mxUtils.button(buttonText3, function()
  3415. {
  3416. if (fn3 != null)
  3417. {
  3418. fn3();
  3419. }
  3420. });
  3421. btn3.className = 'geBtn';
  3422. btns.appendChild(btn3);
  3423. }
  3424. var btn = mxUtils.button(buttonText, function()
  3425. {
  3426. if (hide)
  3427. {
  3428. editorUi.hideDialog();
  3429. }
  3430. if (fn != null)
  3431. {
  3432. fn();
  3433. }
  3434. });
  3435. btn.className = 'geBtn';
  3436. btns.appendChild(btn);
  3437. if (buttonText2 != null)
  3438. {
  3439. var mainBtn = mxUtils.button(buttonText2, function()
  3440. {
  3441. if (hide)
  3442. {
  3443. editorUi.hideDialog();
  3444. }
  3445. if (fn2 != null)
  3446. {
  3447. fn2();
  3448. }
  3449. });
  3450. mainBtn.className = 'geBtn gePrimaryBtn';
  3451. btns.appendChild(mainBtn);
  3452. }
  3453. this.init = function()
  3454. {
  3455. btn.focus();
  3456. };
  3457. div.appendChild(btns);
  3458. this.container = div;
  3459. };
  3460. // Extends codec for ChangePageSetup
  3461. (function()
  3462. {
  3463. var codec = new mxObjectCodec(new ChangePageSetup(), ['ui', 'previousColor', 'previousImage', 'previousFormat']);
  3464. codec.beforeDecode = function(dec, node, obj)
  3465. {
  3466. obj.ui = dec.ui;
  3467. return node;
  3468. };
  3469. codec.afterDecode = function(dec, node, obj)
  3470. {
  3471. obj.previousColor = obj.color;
  3472. obj.previousImage = obj.image;
  3473. obj.previousFormat = obj.format;
  3474. if (obj.foldingEnabled != null)
  3475. {
  3476. obj.foldingEnabled = !obj.foldingEnabled;
  3477. }
  3478. if (obj.mathEnabled != null)
  3479. {
  3480. obj.mathEnabled = !obj.mathEnabled;
  3481. }
  3482. if (obj.shadowVisible != null)
  3483. {
  3484. obj.shadowVisible = !obj.shadowVisible;
  3485. }
  3486. return obj;
  3487. };
  3488. mxCodecRegistry.register(codec);
  3489. })();