Embed.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. (function(stylesheet, stencils)
  2. {
  3. // Callbacks:
  4. // mxClientOnLoad is called after the script is loaded with the stylesheet and the function to create a
  5. // graph (wich takes the container as an argument and returns the graph instance that was created).
  6. // mxClientOnCreate is called when a graph has been created with the graph.
  7. mxStencilRegistry.dynamicLoading = false;
  8. // Adds CSS for tooltips
  9. try
  10. {
  11. var style = document.createElement('style')
  12. style.type = 'text/css'
  13. style.innerHTML = ['div.mxTooltip {',
  14. '-webkit-box-shadow: 3px 3px 12px #C0C0C0;',
  15. '-moz-box-shadow: 3px 3px 12px #C0C0C0;',
  16. 'box-shadow: 3px 3px 12px #C0C0C0;',
  17. 'background: #FFFFCC;',
  18. 'border-style: solid;',
  19. 'border-width: 1px;',
  20. 'border-color: black;',
  21. 'font-family: Arial;',
  22. 'font-size: 8pt;',
  23. 'position: absolute;',
  24. 'cursor: default;',
  25. 'padding: 4px;',
  26. 'color: black;}'].join('\n');
  27. document.getElementsByTagName('head')[0].appendChild(style)
  28. }
  29. catch (e)
  30. {
  31. // ignore
  32. }
  33. var originalNoFo = mxClient.NO_FO;
  34. var mathJaxLoading = (typeof(MathJax) !== 'undefined' && typeof(MathJax.Hub) !== 'undefined');
  35. var mathJaxQueue = [];
  36. function loadMathJax()
  37. {
  38. // Uses existing configuration if MathJax already in page
  39. if (!mathJaxLoading)
  40. {
  41. mathJaxLoading = true;
  42. window.MathJax =
  43. {
  44. skipStartupTypeset: true,
  45. showMathMenu: false,
  46. messageStyle: 'none',
  47. AuthorInit: function ()
  48. {
  49. MathJax.Hub.Config({
  50. jax: ['input/TeX', 'input/MathML', 'input/AsciiMath', 'output/HTML-CSS'],
  51. extensions: ['tex2jax.js', 'mml2jax.js', 'asciimath2jax.js'],
  52. 'HTML-CSS': {
  53. imageFont: null
  54. },
  55. TeX: {
  56. extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
  57. }
  58. });
  59. MathJax.Hub.Register.StartupHook('Begin', function()
  60. {
  61. for (var i = 0; i < mathJaxQueue.length; i++)
  62. {
  63. MathJax.Hub.Queue(['Typeset', MathJax.Hub, mathJaxQueue[i]]);
  64. }
  65. });
  66. }
  67. };
  68. var script = document.createElement('script');
  69. script.type = 'text/javascript';
  70. script.src = 'https://www.draw.io/math/MathJax.js?config=TeX-MML-AM_HTMLorMML';
  71. document.getElementsByTagName('head')[0].appendChild(script);
  72. }
  73. };
  74. function addMathJaxGraph(graph)
  75. {
  76. // Initial rendering when MathJax finished loading
  77. if (typeof(MathJax) !== 'undefined' && typeof(MathJax.Hub) !== 'undefined')
  78. {
  79. MathJax.Hub.Queue(['Typeset', MathJax.Hub, graph.container]);
  80. }
  81. else
  82. {
  83. mathJaxQueue.push(graph.container);
  84. }
  85. // Rendering math again on repaint
  86. graph.addListener(mxEvent.SIZE, function(sender, evt)
  87. {
  88. if (typeof(MathJax) !== 'undefined' && typeof(MathJax.Hub) !== 'undefined')
  89. {
  90. MathJax.Hub.Queue(['Typeset', MathJax.Hub, graph.container]);
  91. }
  92. });
  93. };
  94. // Handles relative images
  95. mxGraph.prototype.getImageFromBundles = function(key)
  96. {
  97. if (key != null)
  98. {
  99. if (key.substring(0, 7) != 'http://' && key.substring(0, 8) != 'https://' && key.substring(0, 10) != 'data:image')
  100. {
  101. if (key.charAt(0) == '/')
  102. {
  103. key = key.substring(1, key.length);
  104. }
  105. key = 'https://www.draw.io/' + key;
  106. }
  107. return key;
  108. }
  109. return null;
  110. };
  111. if (stencils != null)
  112. {
  113. for (var i = 0; i < stencils.length; i++)
  114. {
  115. var xmlDoc = mxUtils.parseXml(stencils[i]);
  116. mxStencilRegistry.parseStencilSet(xmlDoc.documentElement);
  117. }
  118. }
  119. // Panning for touch devices
  120. if (mxClient.IS_TOUCH)
  121. {
  122. mxPanningHandler.prototype.isPanningTrigger = function(me)
  123. {
  124. return true;
  125. };
  126. }
  127. (function()
  128. {
  129. function initGraph(container)
  130. {
  131. try
  132. {
  133. var child = container.firstChild;
  134. while (child != null && child.nodeType != mxConstants.NODETYPE_ELEMENT)
  135. {
  136. child = child.nextSibling;
  137. }
  138. var xml = mxUtils.trim(child.innerHTML);
  139. container.innerHTML = '';
  140. // Instance needed for decompress helper function
  141. var graph = new Graph(container);
  142. if (xml.substring(0, 4) == '&lt;')
  143. {
  144. xml = xml.replace(/&lt;/g, '<').replace(/&gt;/g, '>').
  145. replace(/&amp;gt;/g, '&gt;').replace(/&amp;lt;/g, '&lt;').
  146. replace(/&amp;quot;/g, '&quot;').replace(/&#xa;/g, '\n');
  147. }
  148. else if (xml.substring(0, 3) == '%3C')
  149. {
  150. xml = decodeURIComponent(xml);
  151. }
  152. else
  153. {
  154. xml = Graph.decompress(xml);
  155. }
  156. var xmlDocument = mxUtils.parseXml(xml);
  157. var configNode = null;
  158. var diagrams = null;
  159. if (xmlDocument.documentElement != null && xmlDocument.documentElement.nodeName == 'mxfile')
  160. {
  161. diagrams = xmlDocument.documentElement.getElementsByTagName('diagram');
  162. configNode = xmlDocument.documentElement;
  163. if (diagrams.length > 0)
  164. {
  165. xml = mxUtils.getTextContent(diagrams[0]);
  166. xml = Graph.decompress(xml);
  167. xmlDocument = mxUtils.parseXml(xml);
  168. }
  169. }
  170. if (xmlDocument.documentElement != null && xmlDocument.documentElement.nodeName == 'mxGraphModel')
  171. {
  172. var decoder = new mxCodec(xmlDocument);
  173. var node = xmlDocument.documentElement;
  174. if (configNode == null)
  175. {
  176. configNode = node;
  177. }
  178. graph.resetViewOnRootChange = false;
  179. graph.setEnabled(false);
  180. if (diagrams != null && diagrams.length > 0)
  181. {
  182. /**
  183. * Adds placeholder for %page% and %pagenumber%
  184. */
  185. var graphGetGlobalVariable = graph.getGlobalVariable;
  186. graph.getGlobalVariable = function(name)
  187. {
  188. if (name == 'page')
  189. {
  190. return diagrams[0].getAttribute('name') || 'Page-1';
  191. }
  192. else if (name == 'pagenumber')
  193. {
  194. return 1;
  195. }
  196. else if (name == 'pagecount')
  197. {
  198. return diagrams.length;
  199. }
  200. return graphGetGlobalVariable.apply(this, arguments);
  201. };
  202. }
  203. graph.foldingEnabled = configNode.getAttribute('nav') == '1';
  204. graph.cellRenderer.forceControlClickHandler = graph.foldingEnabled;
  205. var tooltips = configNode.getAttribute('tooltips');
  206. if (tooltips != '0')
  207. {
  208. graph.setTooltips(true);
  209. }
  210. else
  211. {
  212. graph.setTooltips(false);
  213. }
  214. // Workaround for parent div ignoring child size
  215. if (mxClient.IS_VML)
  216. {
  217. var canvas = graph.view.getCanvas();
  218. if (canvas != null && canvas.nodeName == 'DIV')
  219. {
  220. canvas.style.position = 'relative';
  221. }
  222. }
  223. // Loads the stylesheet
  224. if (stylesheet != null)
  225. {
  226. var xmlDoc = mxUtils.parseXml(stylesheet);
  227. var dec = new mxCodec(xmlDoc);
  228. dec.decode(xmlDoc.documentElement, graph.getStylesheet());
  229. }
  230. var math = configNode.getAttribute('math');
  231. if (math == '1')
  232. {
  233. mxClient.NO_FO = true;
  234. loadMathJax();
  235. }
  236. // Enables panning with left mouse button
  237. var pan = configNode.getAttribute('pan');
  238. if (pan != '0')
  239. {
  240. graph.panningHandler.useLeftButtonForPanning = true;
  241. graph.panningHandler.ignoreCell = true;
  242. container.style.cursor = 'move';
  243. graph.setPanning(true);
  244. }
  245. else
  246. {
  247. container.style.cursor = 'default';
  248. }
  249. var resize = configNode.getAttribute('resize');
  250. var border = Number(configNode.getAttribute('border') || 0);
  251. graph.border = border;
  252. var fit = configNode.getAttribute('fit');
  253. if ((container.style.width != '100%' && fit != '1' && resize != '0') ||
  254. (container.style.width == '' && container.style.height == ''))
  255. {
  256. graph.resizeContainer = true;
  257. graph.centerZoom = false;
  258. }
  259. else
  260. {
  261. // Updates the container height for autosize width
  262. if (resize != '0' && container.style.width == '100%' && container.style.height == '')
  263. {
  264. graph.resizeContainer = true;
  265. graph.centerZoom = false;
  266. graph.doResizeContainer = function(width, height)
  267. {
  268. // Fixes container size for different box models
  269. if (mxClient.IS_IE)
  270. {
  271. if (mxClient.IS_QUIRKS)
  272. {
  273. var borders = this.getBorderSizes();
  274. // max(2, ...) required for native IE8 in quirks mode
  275. width += Math.max(2, borders.x + borders.width + 1);
  276. height += Math.max(2, borders.y + borders.height + 1);
  277. }
  278. else if (document.documentMode >= 9)
  279. {
  280. width += 3;
  281. height += 5;
  282. }
  283. else
  284. {
  285. width += 1;
  286. height += 1;
  287. }
  288. }
  289. else
  290. {
  291. height += 1;
  292. }
  293. if (this.maximumContainerSize != null)
  294. {
  295. width = Math.min(this.maximumContainerSize.width, width);
  296. height = Math.min(this.maximumContainerSize.height, height);
  297. }
  298. this.container.style.height = Math.ceil(height + 18) + 'px';
  299. };
  300. }
  301. else
  302. {
  303. graph.centerZoom = true;
  304. }
  305. }
  306. // Adds handling for hyperlinks, tooltips
  307. var links = configNode.getAttribute('links');
  308. var hl = configNode.getAttribute('highlight');
  309. if (links != '0' || tooltips != '0')
  310. {
  311. var cursor = container.style.cursor;
  312. var tol = graph.getTolerance();
  313. graph.addMouseListener(
  314. {
  315. currentState: null,
  316. currentLink: null,
  317. highlight: (hl != null && hl != '' && hl != mxConstants.NONE) ?
  318. new mxCellHighlight(graph, hl, 2) : null,
  319. startX: 0,
  320. startY: 0,
  321. mouseDown: function(sender, me)
  322. {
  323. this.startX = me.getGraphX();
  324. this.startY = me.getGraphY();
  325. },
  326. mouseMove: function(sender, me)
  327. {
  328. if (graph.isMouseDown)
  329. {
  330. if (this.currentLink != null)
  331. {
  332. var dx = Math.abs(this.startX - me.getGraphX());
  333. var dy = Math.abs(this.startY - me.getGraphY());
  334. if (dx > tol || dy > tol)
  335. {
  336. this.clear();
  337. }
  338. }
  339. }
  340. else
  341. {
  342. if (this.currentState != null && (me.getState() == this.currentState || me.getState() == null) &&
  343. graph.intersects(this.currentState, me.getGraphX(), me.getGraphY()))
  344. {
  345. return;
  346. }
  347. var tmp = graph.view.getState(me.getCell());
  348. if (tmp != this.currentState)
  349. {
  350. if (this.currentState != null)
  351. {
  352. this.clear();
  353. }
  354. this.currentState = tmp;
  355. if (this.currentState != null)
  356. {
  357. this.activate(this.currentState);
  358. }
  359. }
  360. }
  361. },
  362. mouseUp: function(sender, me)
  363. {
  364. var tmp = this.currentLink;
  365. this.clear();
  366. if (tmp != null)
  367. {
  368. if (tmp.charAt(0) == '#')
  369. {
  370. window.location.hash = tmp;
  371. }
  372. else
  373. {
  374. window.open(tmp);
  375. }
  376. }
  377. },
  378. activate: function(state)
  379. {
  380. this.currentLink = graph.getLinkForCell(state.cell);
  381. if (this.currentLink != null)
  382. {
  383. container.style.cursor = 'pointer';
  384. if (this.highlight != null)
  385. {
  386. this.highlight.highlight(state);
  387. }
  388. }
  389. },
  390. clear: function()
  391. {
  392. container.style.cursor = cursor;
  393. this.currentState = null;
  394. this.currentLink = null;
  395. if (this.highlight != null)
  396. {
  397. this.highlight.hide();
  398. }
  399. }
  400. });
  401. }
  402. var x0 = Number(configNode.getAttribute('x0') || 0);
  403. var y0 = Number(configNode.getAttribute('y0') || 0);
  404. graph.view.translate.x = -x0 + border;
  405. graph.view.translate.y = -y0 + border;
  406. function graphAdded(node)
  407. {
  408. var img = node.getAttribute('backgroundImage');
  409. if (img != null)
  410. {
  411. img = JSON.parse(img);
  412. graph.setBackgroundImage(new mxImage(img.src, img.width, img.height));
  413. graph.view.validateBackgroundImage();
  414. }
  415. if (fit != '0')
  416. {
  417. graph.fit(border);
  418. }
  419. if (math == '1')
  420. {
  421. addMathJaxGraph(graph);
  422. }
  423. // Keeps hashtag links on same page
  424. var links = graph.container.getElementsByTagName('a');
  425. if (links != null)
  426. {
  427. for (var i = 0; i < links.length; i++)
  428. {
  429. var href = links[i].getAttribute('href');
  430. if (href != null && href.charAt(0) == '#' &&
  431. links[i].getAttribute('target') == '_blank')
  432. {
  433. links[i].removeAttribute('target');
  434. }
  435. }
  436. }
  437. };
  438. // Load from URL via url attribute
  439. var url = configNode.getAttribute('url');
  440. if (url != null)
  441. {
  442. try
  443. {
  444. // Workaround for unsupported CORS in IE9 XHR
  445. var xhr = (navigator.userAgent.indexOf('MSIE 9') > 0) ? new XDomainRequest() : new XMLHttpRequest();
  446. xhr.open('GET', url);
  447. xhr.onload = mxUtils.bind(this, function()
  448. {
  449. try
  450. {
  451. if (math == '1')
  452. {
  453. mxClient.NO_FO = true;
  454. }
  455. var data = (xhr.getText != null) ? xhr.getText() : xhr.responseText;
  456. if (data != null)
  457. {
  458. var newDocument = mxUtils.parseXml(data);
  459. // LATER: Add support for .png (with XML) files
  460. // Adds support for HTML
  461. if (newDocument != null && newDocument.documentElement.nodeName == 'html')
  462. {
  463. var divs = newDocument.documentElement.getElementsByTagName('div');
  464. if (divs.length > 0 && divs[0].getAttribute('class') == 'mxgraph')
  465. {
  466. var divs2 = divs[0].getElementsByTagName('div');
  467. if (divs2.length > 0)
  468. {
  469. var data = mxUtils.getTextContent(divs2[0]);
  470. data = Graph.decompress(data);
  471. if (data.length > 0)
  472. {
  473. newDocument = mxUtils.parseXml(data);
  474. }
  475. }
  476. }
  477. }
  478. if (newDocument != null && newDocument.documentElement.nodeName == 'svg')
  479. {
  480. var tmp = newDocument.documentElement.getAttribute('content');
  481. if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
  482. {
  483. tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
  484. }
  485. if (tmp != null && tmp.charAt(0) == '%')
  486. {
  487. tmp = decodeURIComponent(tmp);
  488. }
  489. if (tmp != null && tmp.length > 0)
  490. {
  491. newDocument = mxUtils.parseXml(tmp);
  492. }
  493. }
  494. if (newDocument.documentElement.nodeName == 'mxfile')
  495. {
  496. var diagrams = newDocument.documentElement.getElementsByTagName('diagram');
  497. if (diagrams.length > 0)
  498. {
  499. data = Graph.decompress(mxUtils.getTextContent(diagrams[0]));
  500. newDocument = mxUtils.parseXml(data);
  501. }
  502. }
  503. decoder = new mxCodec(newDocument);
  504. decoder.decode(newDocument.documentElement, graph.getModel());
  505. graphAdded(newDocument.documentElement);
  506. }
  507. else
  508. {
  509. graph.container.innerHTML = 'Cannot load ' + url;
  510. }
  511. mxClient.NO_FO = originalNoFo;
  512. }
  513. catch (e)
  514. {
  515. graph.container.innerHTML = 'Cannot load ' + url + ': ' + e.message;
  516. }
  517. });
  518. xhr.onerror = function()
  519. {
  520. graph.container.innerHTML = 'Cannot load ' + url;
  521. };
  522. xhr.send();
  523. }
  524. catch (e)
  525. {
  526. graph.container.innerHTML = 'Cannot load ' + url + ': ' + e.message;
  527. }
  528. }
  529. else
  530. {
  531. decoder.decode(node, graph.getModel());
  532. graphAdded(node);
  533. }
  534. if (container.style.width != '100%' && fit != '0' && resize == '1')
  535. {
  536. graph.resizeContainer = true;
  537. graph.centerZoom = false;
  538. }
  539. // Adds zoom, edit etc in top, left corner
  540. var buttons = document.createElement('div');
  541. buttons.style.position = 'absolute';
  542. buttons.style.overflow = 'visible';
  543. buttons.style.cursor = 'pointer';
  544. var bs = graph.getBorderSizes();
  545. var left = 0;
  546. var fontSize = 10;
  547. var bw = 16;
  548. var bh = 16;
  549. if (mxClient.IS_QUIRKS)
  550. {
  551. bw -= 1;
  552. bh -= 1;
  553. }
  554. else if (mxClient.IS_TOUCH)
  555. {
  556. bw = 24;
  557. bh = 24;
  558. var fontSize = 14;
  559. }
  560. function addButton(label, funct)
  561. {
  562. var btn = document.createElement('div');
  563. btn.style.position = 'absolute';
  564. btn.style.border = '1px solid gray';
  565. btn.style.textAlign = 'center';
  566. btn.style.cursor = 'hand';
  567. btn.style.width = bw + 'px';
  568. btn.style.height = bh + 'px';
  569. btn.style.left = left + 'px';
  570. btn.style.top = '0px';
  571. btn.style.backgroundColor = 'white';
  572. mxUtils.setOpacity(btn, 50);
  573. var table = document.createElement('table');
  574. table.style.borderWidth = '0px';
  575. table.style.width = '100%';
  576. table.style.height = '100%';
  577. var tbody = document.createElement('tbody');
  578. var tr = document.createElement('tr');
  579. var td = document.createElement('td');
  580. td.style.verticalAlign = 'middle';
  581. td.style.textAlign = 'center';
  582. td.style.fontSize = fontSize + 'px';
  583. td.style.padding = '0px';
  584. mxUtils.write(td, label);
  585. tr.appendChild(td);
  586. tbody.appendChild(tr);
  587. table.appendChild(tbody);
  588. btn.appendChild(table);
  589. mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown', function(evt)
  590. {
  591. mxEvent.consume(evt);
  592. });
  593. mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerup' : 'mouseup', function(evt)
  594. {
  595. funct();
  596. mxEvent.consume(evt);
  597. });
  598. if (!mxClient.IS_POINTER && mxClient.IS_TOUCH)
  599. {
  600. mxEvent.addListener(btn, 'touchstart', function(evt)
  601. {
  602. mxEvent.consume(evt);
  603. });
  604. mxEvent.addListener(btn, 'touchend', function(evt)
  605. {
  606. funct();
  607. mxEvent.consume(evt);
  608. });
  609. }
  610. left += bw;
  611. buttons.appendChild(btn);
  612. return btn;
  613. };
  614. var zoom = configNode.getAttribute('zoom');
  615. if (zoom != '0')
  616. {
  617. addButton('+', function()
  618. {
  619. graph.zoomIn();
  620. });
  621. addButton('-', function()
  622. {
  623. graph.zoomOut();
  624. });
  625. }
  626. var edit = configNode.getAttribute('edit');
  627. if (edit != null)
  628. {
  629. var button = addButton('', function()
  630. {
  631. // _blank is a special value to open a new editor
  632. // in client mode and send the XML as a message
  633. if (edit == '_blank')
  634. {
  635. if (url != null)
  636. {
  637. window.open('https://www.draw.io/#U' + encodeURIComponent(url));
  638. }
  639. else
  640. {
  641. var wnd = null;
  642. var receive = function(evt)
  643. {
  644. if (evt.data == 'ready' && evt.source == wnd)
  645. {
  646. wnd.postMessage(xml, '*');
  647. window.removeEventListener('message', receive);
  648. }
  649. };
  650. window.addEventListener('message', receive);
  651. wnd = window.open('https://www.draw.io/?client=1');
  652. }
  653. }
  654. else
  655. {
  656. window.open(edit);
  657. }
  658. });
  659. // Do not use HTML entity to avoid problems with XHTML
  660. button.innerHTML = '...';
  661. }
  662. function show()
  663. {
  664. buttons.style.top = (container.offsetTop + bs.y) + 'px';
  665. buttons.style.left = (container.offsetLeft + bs.x) + 'px';
  666. buttons.style.visibility = 'visible';
  667. };
  668. if (!mxClient.IS_POINTER && !mxClient.IS_TOUCH)
  669. {
  670. function hide()
  671. {
  672. buttons.style.visibility = 'hidden';
  673. };
  674. mxEvent.addListener(container, 'mouseover', show);
  675. mxEvent.addListener(buttons, 'mouseover', show);
  676. mxEvent.addListener(container, 'mouseout', hide);
  677. mxEvent.addListener(buttons, 'mouseout', hide);
  678. hide();
  679. }
  680. else
  681. {
  682. show();
  683. }
  684. if (buttons.firstChild != null)
  685. {
  686. if (container.nextSibling != null)
  687. {
  688. container.parentNode.insertBefore(buttons, container.nextSibling);
  689. }
  690. else
  691. {
  692. container.parentNode.appendChild(buttons);
  693. }
  694. }
  695. if (typeof(window.mxClientOnCreate) == 'function')
  696. {
  697. window.mxClientOnCreate(graph);
  698. }
  699. }
  700. }
  701. catch (err)
  702. {
  703. if (window.console != null)
  704. {
  705. console.log('Error:', err);
  706. }
  707. }
  708. mxClient.NO_FO = originalNoFo;
  709. return graph;
  710. };
  711. if (typeof(mxClientOnLoad) == 'function')
  712. {
  713. mxClientOnLoad(stylesheet, initGraph);
  714. }
  715. else if (mxClient.isBrowserSupported())
  716. {
  717. var tmp = document.getElementsByTagName('*');
  718. var divs = [];
  719. for (var i = 0; i < tmp.length; i++)
  720. {
  721. divs.push(tmp[i]);
  722. }
  723. for (var i = 0; i < divs.length; i++)
  724. {
  725. if (divs[i].className.toString().indexOf('mxgraph') >= 0)
  726. {
  727. initGraph(divs[i]);
  728. }
  729. }
  730. }
  731. })();
  732. // Last line will be replaced by servlet for passing arguments.
  733. })();