fix.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // 运行在 mxgraph-editor 内部的 fix.js
  2. // 用于和 WhLayoutDesign.js 组件打配合
  3. // window.designer 代表 whLayoutDesign 对象
  4. // window.editorInitFn 是 whLayoutDesign 的回调对象
  5. (function () {
  6. var editorUiInit = EditorUi.prototype.init;
  7. var editorInitFn = window['editorInitFn']
  8. EditorUi.prototype.init = function () {
  9. editorUiInit.apply(this, arguments);
  10. if (typeof editorInitFn === 'function') {
  11. editorInitFn(this)
  12. } else {
  13. alert('无法找到 editorInitFn')
  14. }
  15. };
  16. // Adds required resources (disables loading of fallback properties, this can only
  17. // be used if we know that all keys are defined in the language specific file)
  18. mxResources.loadDefaultBundle = false;
  19. var bundle = mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||
  20. mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage);
  21. // Fixes possible asynchronous requests
  22. mxUtils.getAll([bundle, STYLE_PATH + '/default.xml'], function (xhr) {
  23. // Adds bundle text to resources
  24. mxResources.parse(xhr[0].getText());
  25. // Configures the default graph theme
  26. var themes = new Object();
  27. themes[Graph.prototype.defaultThemeName] = xhr[1].getDocumentElement();
  28. // Main
  29. new EditorUi(new Editor(urlParams['chrome'] == '0', themes));
  30. }, function () {
  31. document.body.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
  32. });
  33. })();