Blame view

build/Common/Common.js 2.61 KB
3a3ecabe   Imshann   init
1
  import baseStyle from "antd/lib/style/index.css";
1b6f912f   Imshann   优化
2
3
4
5
6
7
8
9
10
11
12
13
  angular.module("esNgAntd").service("esNgAntd", [
      "$compile",
      function ($compile) {
          this.styleSheets = null;
  
          this.createStyle = function (key, style) {
              if (!document.querySelector("#antd")) {
                  let styleElement = document.createElement("style");
                  styleElement.setAttribute("id", "antd");
                  styleElement.setAttribute("type", "text/css");
                  styleElement.innerHTML = baseStyle.toString();
                  document.head.appendChild(styleElement);
3a3ecabe   Imshann   init
14
              }
1b6f912f   Imshann   优化
15
16
17
18
19
20
21
22
23
24
25
  
              if (!document.querySelector("#" + key)) {
                  let styleElement = document.createElement("style");
                  styleElement.setAttribute("id", key);
                  styleElement.setAttribute("type", "text/css");
                  styleElement.innerHTML = style.toString();
                  document.head.appendChild(styleElement);
  
                  if (this.styleSheets) {
                      this.disableStyle(key);
                  }
3a3ecabe   Imshann   init
26
              }
1b6f912f   Imshann   优化
27
          };
3a3ecabe   Imshann   init
28
  
1b6f912f   Imshann   优化
29
30
31
          this.disableStyle = function (name) {
              for (let i = 0; i < this.styleSheets.cssRules.length; i++) {
                  let rule = this.styleSheets.cssRules[i];
3a3ecabe   Imshann   init
32
  
1b6f912f   Imshann   优化
33
34
35
36
37
                  if (
                      rule.selectorText &&
                      rule.selectorText.indexOf(name) !== -1
                  ) {
                      rule.selectorText = rule.selectorText.replace(
061629e7   Imshann   add
38
                          /\.ant\-/g,
1b6f912f   Imshann   优化
39
40
                          ".disabled-ant-"
                      );
061629e7   Imshann   add
41
                      console.log(rule.selectorText);
1b6f912f   Imshann   优化
42
                  }
3a3ecabe   Imshann   init
43
              }
1b6f912f   Imshann   优化
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
          };
  
          this.conflict = function (filename) {
              for (let i = 0; i < document.styleSheets.length; i++) {
                  const element = document.styleSheets[i];
  
                  if (element.href && element.href.indexOf(filename) !== -1) {
                      this.styleSheets = element;
                  }
              }
          };
  
          this.createLayer = function (content, scope) {
              let div = document.createElement("div");
              div.innerHTML = content;
              document.body.appendChild(div);
              $compile(div)(scope);
          };
6fcf6aec   Imshann   feat(popover): 优化组件
62
63
64
65
66
67
68
69
70
71
72
73
74
  
          this.getOffset = function (ele) {
              if (!ele || ele.nodeType != 1) {
                  return;
              }
  
              let rect = ele.getBoundingClientRect();
              let doc = ele.ownerDocument.documentElement;
              return {
                  top: rect.top + window.pageYOffset - doc.clientTop,
                  left: rect.left + window.pageXOffset - doc.clientLeft,
              };
          };
1b6f912f   Imshann   优化
75
76
      },
  ]);