internal.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. (function () {
  2. /* eslint-disable */
  3. if (window.frameElement.id) {
  4. let parent = window.parent,
  5. dialog = parent.$EDITORUI[window.frameElement.id.replace(/_iframe$/, '')],
  6. editor = dialog.editor,
  7. UE = parent.UE,
  8. domUtils = UE.dom.domUtils,
  9. utils = UE.utils,
  10. browser = UE.browser,
  11. /* eslint-disable */
  12. ajax = UE.ajax,
  13. $G = function (id) {
  14. return document.getElementById(id)
  15. },
  16. $focus = function (node) {
  17. setTimeout(function () {
  18. if (browser.ie) {
  19. var r = node.createTextRange();
  20. r.collapse(false);
  21. r.select();
  22. } else {
  23. node.focus()
  24. }
  25. }, 0)
  26. };
  27. window.nowEditor = {editor: editor, dialog: dialog};
  28. utils.loadFile(document, {
  29. href: editor.options.themePath + editor.options.theme + '/dialogbase.css?cache=' + Math.random(),
  30. tag: 'link',
  31. type: 'text/css',
  32. rel: 'stylesheet'
  33. });
  34. var lang = editor.getLang(dialog.className.split('-')[2]);
  35. if (lang) {
  36. domUtils.on(window, 'load', function () {
  37. var langImgPath = editor.options.langPath + editor.options.lang + '/images/';
  38. // 针对静态资源
  39. for (var i in lang['static']) {
  40. var dom = $G(i);
  41. if (!dom) continue;
  42. let tagName = dom.tagName,
  43. content = lang['static'][i];
  44. if (content.src) {
  45. // clone
  46. content = utils.extend({}, content, false);
  47. content.src = langImgPath + content.src;
  48. }
  49. if (content.style) {
  50. content = utils.extend({}, content, false);
  51. content.style = content.style.replace(/url\s*\(/g, 'url(' + langImgPath)
  52. }
  53. switch (tagName.toLowerCase()) {
  54. case 'var':
  55. dom.parentNode.replaceChild(document.createTextNode(content), dom);
  56. break;
  57. case 'select':
  58. var ops = dom.options;
  59. for (var j = 0, oj; oj = ops[j];) {
  60. oj.innerHTML = content.options[j++];
  61. }
  62. for (var p in content) {
  63. p != 'options' && dom.setAttribute(p, content[p]);
  64. }
  65. break;
  66. default :
  67. domUtils.setAttributes(dom, content);
  68. }
  69. }
  70. });
  71. }
  72. }
  73. })();