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