dcim-topology2d 2.2.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/activity-diagram/src/final/final.d.ts +1 -1
  2. package/activity-diagram/src/final/final.rect.d.ts +1 -1
  3. package/activity-diagram/src/final/final.rect.js +1 -1
  4. package/activity-diagram/src/fork/fork.anchor.d.ts +1 -1
  5. package/activity-diagram/src/fork/fork.anchor.js +1 -1
  6. package/activity-diagram/src/fork/fork.d.ts +1 -1
  7. package/activity-diagram/src/fork/fork.rect.d.ts +1 -1
  8. package/activity-diagram/src/fork/fork.rect.js +1 -1
  9. package/activity-diagram/src/register.js +1 -1
  10. package/activity-diagram/src/swimlaneH/swimlaneH.d.ts +1 -1
  11. package/activity-diagram/src/swimlaneH/swimlaneH.rect.d.ts +1 -1
  12. package/activity-diagram/src/swimlaneH/swimlaneH.rect.js +1 -1
  13. package/activity-diagram/src/swimlaneV/swimlaneV.d.ts +1 -1
  14. package/activity-diagram/src/swimlaneV/swimlaneV.rect.d.ts +1 -1
  15. package/activity-diagram/src/swimlaneV/swimlaneV.rect.js +1 -1
  16. package/chart-diagram/index.d.ts +1 -3
  17. package/chart-diagram/index.js +1 -2
  18. package/chart-diagram/src/echarts/index.d.ts +2 -1
  19. package/chart-diagram/src/echarts/index.js +104 -112
  20. package/chart-diagram/src/register.js +8 -9
  21. package/class-diagram/src/class/class.d.ts +1 -1
  22. package/class-diagram/src/class/class.rect.d.ts +1 -1
  23. package/class-diagram/src/class/class.rect.js +1 -1
  24. package/class-diagram/src/register.js +1 -1
  25. package/core/index.d.ts +0 -2
  26. package/core/index.js +0 -2
  27. package/core/src/activeLayer.d.ts +10 -2
  28. package/core/src/activeLayer.js +47 -42
  29. package/core/src/animateLayer.d.ts +7 -3
  30. package/core/src/animateLayer.js +12 -10
  31. package/core/src/calling.d.ts +4 -1
  32. package/core/src/calling.js +41 -43
  33. package/core/src/canvas.d.ts +6 -1
  34. package/core/src/canvas.js +21 -22
  35. package/core/src/common.d.ts +7 -6
  36. package/core/src/common.js +675 -343
  37. package/core/src/core.d.ts +4 -5
  38. package/core/src/core.js +385 -536
  39. package/core/src/divLayer.d.ts +36 -2
  40. package/core/src/divLayer.js +305 -33
  41. package/core/src/healps/changeData.d.ts +2 -1
  42. package/core/src/healps/changeData.js +100 -86
  43. package/core/src/hoverLayer.d.ts +9 -2
  44. package/core/src/hoverLayer.js +34 -31
  45. package/core/src/middles/default.d.ts +3 -1
  46. package/core/src/middles/default.js +51 -63
  47. package/core/src/middles/index.js +2 -3
  48. package/core/src/middles/nodes/arbitrarygraph.js +9 -11
  49. package/core/src/middles/nodes/pentagon.rect.js +1 -1
  50. package/core/src/middles/nodes/rectangle.rect.js +1 -1
  51. package/core/src/models/data.d.ts +26 -0
  52. package/core/src/models/data.js +77 -0
  53. package/core/src/models/data.js.map +1 -0
  54. package/core/src/models/index.d.ts +1 -0
  55. package/core/src/models/index.js +1 -0
  56. package/core/src/models/line.js +7 -7
  57. package/core/src/models/node.d.ts +0 -10
  58. package/core/src/models/node.js +101 -148
  59. package/core/src/models/pen.js +67 -27
  60. package/core/src/models/rect.js +2 -2
  61. package/core/src/mqtt.d.ts +14 -0
  62. package/core/src/mqtt.js +82 -0
  63. package/core/src/mqtt.js.map +1 -0
  64. package/core/src/offscreen.d.ts +4 -1
  65. package/core/src/offscreen.js +24 -26
  66. package/core/src/options.d.ts +1 -3
  67. package/core/src/options.js +0 -2
  68. package/core/src/poll.js +39 -0
  69. package/core/src/preview.d.ts +13 -2
  70. package/core/src/preview.js +43 -144
  71. package/core/src/renderLayer.d.ts +9 -11
  72. package/core/src/renderLayer.js +61 -60
  73. package/core/src/socket.d.ts +10 -0
  74. package/core/src/socket.js +51 -0
  75. package/core/src/socket.js.map +1 -0
  76. package/core/src/utils/canvas.js +1 -1
  77. package/core/src/utils/construction.d.ts +3 -36
  78. package/core/src/utils/construction.js +1 -29
  79. package/core/src/utils/conversion.d.ts +0 -15
  80. package/core/src/utils/conversion.js +0 -319
  81. package/core/src/utils/dom.d.ts +8 -0
  82. package/core/src/utils/dom.js +67 -0
  83. package/core/src/utils/dom.js.map +1 -0
  84. package/core/src/utils/index.d.ts +1 -2
  85. package/core/src/utils/index.js +1 -2
  86. package/core/src/utils/onmousevent.d.ts +0 -3
  87. package/core/src/utils/onmousevent.js +10 -42
  88. package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
  89. package/flow-diagram/src/comment/comment.anchor.js +1 -1
  90. package/flow-diagram/src/comment/comment.d.ts +1 -1
  91. package/flow-diagram/src/data/data.anchor.d.ts +1 -1
  92. package/flow-diagram/src/data/data.anchor.js +1 -1
  93. package/flow-diagram/src/data/data.d.ts +1 -1
  94. package/flow-diagram/src/data/data.rect.d.ts +1 -1
  95. package/flow-diagram/src/data/data.rect.js +1 -1
  96. package/flow-diagram/src/db/db.d.ts +1 -1
  97. package/flow-diagram/src/db/db.rect.d.ts +1 -1
  98. package/flow-diagram/src/db/db.rect.js +1 -1
  99. package/flow-diagram/src/display/display.anchor.d.ts +1 -1
  100. package/flow-diagram/src/display/display.anchor.js +1 -1
  101. package/flow-diagram/src/display/display.d.ts +1 -1
  102. package/flow-diagram/src/display/display.rect.d.ts +1 -1
  103. package/flow-diagram/src/display/display.rect.js +1 -1
  104. package/flow-diagram/src/document/document.anchor.d.ts +1 -1
  105. package/flow-diagram/src/document/document.anchor.js +1 -1
  106. package/flow-diagram/src/document/document.d.ts +1 -1
  107. package/flow-diagram/src/document/document.rect.d.ts +1 -1
  108. package/flow-diagram/src/document/document.rect.js +1 -1
  109. package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
  110. package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
  111. package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
  112. package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
  113. package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
  114. package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
  115. package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
  116. package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
  117. package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
  118. package/flow-diagram/src/manually/manually.anchor.js +1 -1
  119. package/flow-diagram/src/manually/manually.d.ts +1 -1
  120. package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
  121. package/flow-diagram/src/manually/manually.rect.js +1 -1
  122. package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
  123. package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
  124. package/flow-diagram/src/parallel/parallel.d.ts +1 -1
  125. package/flow-diagram/src/queue/queue.d.ts +1 -1
  126. package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
  127. package/flow-diagram/src/queue/queue.rect.js +1 -1
  128. package/flow-diagram/src/register.js +1 -1
  129. package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
  130. package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
  131. package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
  132. package/layout/src/align.d.ts +1 -1
  133. package/layout/src/align.js +1 -1
  134. package/layout/src/layout.d.ts +1 -1
  135. package/layout/src/layout.js +1 -1
  136. package/myShape-diagram/{index.js → myShape.js} +1 -4
  137. package/package.json +1 -1
  138. package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
  139. package/sequence-diagram/src/focus/focus.anchor.js +1 -1
  140. package/sequence-diagram/src/focus/focus.d.ts +1 -1
  141. package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
  142. package/sequence-diagram/src/focus/focus.rect.js +1 -1
  143. package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
  144. package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
  145. package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
  146. package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
  147. package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
  148. package/sequence-diagram/src/register.js +1 -1
  149. package/chart-diagram/src/utils/changeOptions.d.ts +0 -8
  150. package/chart-diagram/src/utils/changeOptions.js +0 -267
  151. package/chart-diagram/src/utils/conversion.d.ts +0 -19
  152. package/chart-diagram/src/utils/conversion.js +0 -560
  153. package/chart-diagram/src/utils/drawGraphic.d.ts +0 -3
  154. package/chart-diagram/src/utils/drawGraphic.js +0 -97
  155. package/chart-diagram/src/utils/formatter.d.ts +0 -1
  156. package/chart-diagram/src/utils/formatter.js +0 -206
  157. package/chart-diagram/src/utils/index.d.ts +0 -5
  158. package/chart-diagram/src/utils/index.js +0 -5
  159. package/chart-diagram/src/utils/render.d.ts +0 -8
  160. package/chart-diagram/src/utils/render.js +0 -219
  161. package/chart-diagram/src/utils/surfaceParametricConversion.d.ts +0 -3
  162. package/chart-diagram/src/utils/surfaceParametricConversion.js +0 -252
  163. package/core/src/element/common.d.ts +0 -6
  164. package/core/src/element/common.js +0 -63
  165. package/core/src/element/datePicker.d.ts +0 -3
  166. package/core/src/element/datePicker.js +0 -44
  167. package/core/src/element/iframe.d.ts +0 -3
  168. package/core/src/element/iframe.js +0 -12
  169. package/core/src/element/index.d.ts +0 -5
  170. package/core/src/element/index.js +0 -6
  171. package/core/src/element/select.d.ts +0 -11
  172. package/core/src/element/select.js +0 -273
  173. package/core/src/element/tab.d.ts +0 -1
  174. package/core/src/element/tab.js +0 -20
  175. package/core/src/element/time.d.ts +0 -3
  176. package/core/src/element/time.js +0 -44
  177. package/core/src/middles/arrows/index.d.ts +0 -4
  178. package/core/src/middles/arrows/index.js +0 -5
  179. package/core/src/middles/lines/index.d.ts +0 -4
  180. package/core/src/middles/lines/index.js +0 -5
  181. package/core/src/middles/nodes/formDatePicker.d.ts +0 -2
  182. package/core/src/middles/nodes/formDatePicker.js +0 -107
  183. package/core/src/middles/nodes/formoverflow.js +0 -61
  184. package/core/src/middles/nodes/formselect.d.ts +0 -2
  185. package/core/src/middles/nodes/formselect.js +0 -111
  186. package/core/src/middles/nodes/iframe.d.ts +0 -2
  187. package/core/src/middles/nodes/iframe.js +0 -29
  188. package/core/src/middles/nodes/index.d.ts +0 -51
  189. package/core/src/middles/nodes/index.js +0 -53
  190. package/core/src/middles/nodes/switchs.d.ts +0 -2
  191. package/core/src/middles/nodes/switchs.js +0 -46
  192. package/core/src/middles/nodes/time.d.ts +0 -2
  193. package/core/src/middles/nodes/time.js +0 -98
  194. package/core/src/store/common.d.ts +0 -9
  195. package/core/src/store/common.js +0 -5
  196. package/core/src/store/data.d.ts +0 -196
  197. package/core/src/store/data.js +0 -193
  198. package/core/src/store/index.d.ts +0 -2
  199. package/core/src/store/index.js +0 -2
  200. package/core/src/utils/assignment.d.ts +0 -7
  201. package/core/src/utils/assignment.js +0 -216
  202. package/core/src/utils/params.d.ts +0 -3
  203. package/core/src/utils/params.js +0 -136
  204. package/static/echartsDefaultData.js +0 -178
  205. package/static/element.js +0 -14
  206. package/static/form.js +0 -11
  207. package/static/index.js +0 -3
  208. package/store/actions.js +0 -1
  209. package/store/clear.js +0 -10
  210. package/store/default.js +0 -22
  211. package/store/index.js +0 -3
  212. package/style/common.css +0 -15
  213. package/style/datePicker.css +0 -44
  214. package/style/editor.css +0 -16
  215. package/style/index.css +0 -5
  216. package/style/select.css +0 -143
  217. /package/myShape-diagram/{index.ts → myShape.ts} +0 -0
@@ -1,7 +1,37 @@
1
- import { Node } from './models';
1
+ import { Options } from './options';
2
+ import { Node } from './models/node';
3
+ import { TopologyData } from './models/data';
2
4
  import { Layer } from './layer';
3
5
  export declare class DivLayer extends Layer {
6
+ parentElem: HTMLElement;
7
+ options: Options;
8
+ protected data: TopologyData;
4
9
  canvas: HTMLDivElement;
10
+ player: HTMLDivElement;
11
+ curNode: Node;
12
+ playBtn: HTMLElement;
13
+ currentTime: HTMLElement;
14
+ progressCurrent: HTMLElement;
15
+ progress: HTMLElement;
16
+ loop: HTMLElement;
17
+ media: HTMLMediaElement;
18
+ videos: {
19
+ [key: string]: {
20
+ player: HTMLElement;
21
+ current: HTMLElement;
22
+ media: HTMLMediaElement;
23
+ };
24
+ };
25
+ audios: {
26
+ [key: string]: {
27
+ player: HTMLElement;
28
+ current: HTMLElement;
29
+ media: HTMLMediaElement;
30
+ };
31
+ };
32
+ iframes: {
33
+ [key: string]: HTMLIFrameElement;
34
+ };
5
35
  elements: {
6
36
  [key: string]: HTMLElement;
7
37
  };
@@ -10,8 +40,12 @@ export declare class DivLayer extends Layer {
10
40
  };
11
41
  private subcribe;
12
42
  private subcribeNode;
13
- constructor(TID: String);
43
+ constructor(parentElem: HTMLElement, options: Options, TID: String);
14
44
  addDiv: (node: Node) => void;
45
+ createPlayer(): void;
46
+ getMediaCurrent(): void;
47
+ addMedia(node: Node, type: string): HTMLDivElement;
48
+ playNext(next: string): void;
15
49
  addIframe(node: Node): HTMLIFrameElement;
16
50
  addGif(node: Node): HTMLImageElement;
17
51
  setElemPosition(node: Node, elem: HTMLElement): void;
@@ -20,23 +20,53 @@ var __extends = (this && this.__extends) || (function () {
20
20
  };
21
21
  })();
22
22
  import {Store} from 'le5le-store';
23
- import {Node, PenType, images, defaultImages} from './models';
23
+ import {Node, images} from './models/node';
24
+ import {Lock} from './models/status';
25
+ import {PenType} from './models/pen';
24
26
  import {Layer} from './layer';
25
- import { setStyleForElementIdDiv } from './element';
26
- import { commonStore } from './store';
27
+ import { setStyleForElementIdDiv, DomElements } from './utils'
27
28
  var DivLayer = /** @class */ (function (_super) {
28
29
  __extends(DivLayer, _super);
29
- function DivLayer(TID) {
30
+
31
+ function DivLayer(parentElem, options, TID) {
32
+ if (options === void 0) {
33
+ options = {};
34
+ }
30
35
  var _this = _super.call(this, TID) || this;
36
+ _this.parentElem = parentElem;
37
+ _this.options = options;
31
38
  _this.canvas = document.createElement('div');
39
+ // _this.player = document.createElement('div');
40
+ // _this.videos = {};
41
+ // _this.audios = {};
42
+ _this.iframes = {};
32
43
  _this.elements = {};
33
44
  _this.gifs = {};
34
45
  _this.addDiv = function (node) {
46
+ // if (node.audio) {
47
+ // if (_this.audios[node.id] && _this.audios[node.id].media.src !== node.audio) {
48
+ // _this.audios[node.id].media.src = node.audio;
49
+ // }
50
+ // _this.setElemPosition(node, (_this.audios[node.id] && _this.audios[node.id].player) || _this.addMedia(node, 'audio'));
51
+ // }
52
+ // if (node.video) {
53
+ // if (_this.videos[node.id] && _this.videos[node.id].media.src !== node.video) {
54
+ // _this.videos[node.id].media.src = node.video;
55
+ // }
56
+ // _this.setElemPosition(node, (_this.videos[node.id] && _this.videos[node.id].player) || _this.addMedia(node, 'video'));
57
+ // }
58
+ if (node.iframe) {
59
+ if (_this.iframes[node.id] && _this.iframes[node.id].src !== node.iframe) {
60
+ _this.iframes[node.id].src = node.iframe;
61
+ }
62
+ _this.setElemPosition(node, _this.iframes[node.id] || _this.addIframe(node));
63
+ }
35
64
  if (node.elementId) {
65
+ Object.assign(_this.elements, DomElements);
36
66
  if (!_this.elements[node.id]) {
37
67
  _this.elements[node.id] = document.getElementById(node.id);
38
68
  if (_this.elements[node.id]) {
39
- _this.addElement(node);
69
+ _this.canvas.appendChild(_this.elements[node.id]);
40
70
  }
41
71
  }
42
72
  _this.setElemPosition(node, _this.elements[node.id]);
@@ -65,22 +95,249 @@ var DivLayer = /** @class */ (function (_super) {
65
95
  }
66
96
  }
67
97
  };
98
+ _this.data = Store.get(_this.generateStoreKey('topology-data'));
99
+ // if (!_this.options.playIcon) {
100
+ // _this.options.playIcon = 'iconfont icon-play';
101
+ // }
102
+ // if (!_this.options.pauseIcon) {
103
+ // _this.options.pauseIcon = 'iconfont icon-pause';
104
+ // }
105
+ // if (!_this.options.fullScreenIcon) {
106
+ // _this.options.fullScreenIcon = 'iconfont icon-full-screen';
107
+ // }
108
+ // if (!_this.options.loopIcon) {
109
+ // _this.options.loopIcon = 'iconfont icon-loop';
110
+ // }
68
111
  _this.canvas.style.position = 'absolute';
69
112
  _this.canvas.style.left = '0';
70
113
  _this.canvas.style.top = '0';
71
114
  _this.canvas.style.outline = 'none';
72
115
  _this.canvas.style.background = 'transparent';
73
116
  _this.canvas.setAttribute('class', 'canvas-point');
74
- commonStore[TID].parentElem.appendChild(_this.canvas);
117
+ parentElem.appendChild(_this.canvas);
118
+ // parentElem.appendChild(_this.player);
119
+ //_this.createPlayer();
75
120
  _this.subcribe = Store.subscribe(_this.generateStoreKey('LT:addDiv'), _this.addDiv);
121
+ // _this.subcribeNode = Store.subscribe(_this.generateStoreKey('LT:activeNode'), function (node) {
122
+ // if (!node || (!node.video && !node.audio)) {
123
+ // _this.player.style.top = '-99999px';
124
+ // return;
125
+ // }
126
+ // if (node.audio && _this.audios[node.id]) {
127
+ // _this.media = _this.audios[node.id].media;
128
+ // }
129
+ // else if (node.video && _this.videos[node.id]) {
130
+ // _this.media = _this.videos[node.id].media;
131
+ // }
132
+ // else {
133
+ // return;
134
+ // }
135
+ // _this.curNode = node;
136
+ // _this.player.style.top = _this.parentElem.offsetTop + _this.parentElem.clientHeight + 'px';
137
+ // _this.player.style.left = _this.parentElem.getBoundingClientRect().left + 'px';
138
+ // _this.player.style.width = _this.parentElem.clientWidth + 'px';
139
+ // _this.getMediaCurrent();
140
+ // if (_this.media.paused) {
141
+ // _this.playBtn.className = _this.options.playIcon;
142
+ // }
143
+ // else {
144
+ // _this.playBtn.className = _this.options.pauseIcon;
145
+ // }
146
+ // });
147
+ // document.addEventListener('fullscreenchange', function (e) {
148
+ // if (!_this.media) {
149
+ // return;
150
+ // }
151
+ // if (document.fullscreen) {
152
+ // _this.media.controls = true;
153
+ // _this.media.style.userSelect = 'initial';
154
+ // _this.media.style.pointerEvents = 'initial';
155
+ // }
156
+ // else {
157
+ // _this.media.style.userSelect = 'none';
158
+ // _this.media.style.pointerEvents = 'none';
159
+ // _this.media.controls = false;
160
+ // }
161
+ // });
76
162
  return _this;
77
163
  }
78
- DivLayer.prototype.addElement = function (node){
79
- if(['iframe', 'echarts', 'formOverflow'].includes(node.name)) {
80
- this.canvas.parentNode.appendChild(this.elements[node.id]);
81
- }else {
82
- this.canvas.appendChild(this.elements[node.id]);
164
+
165
+ DivLayer.prototype.createPlayer = function () {
166
+ var _this = this;
167
+ this.player.style.position = 'fixed';
168
+ this.player.style.outline = 'none';
169
+ this.player.style.top = '-99999px';
170
+ this.player.style.height = '40px';
171
+ this.player.style.padding = '10px 15px';
172
+ this.player.style.background = 'rgba(200,200,200,.1)';
173
+ this.player.style.display = 'flex';
174
+ this.player.style.alignItems = 'center';
175
+ this.player.style.userSelect = 'initial';
176
+ this.player.style.pointerEvents = 'initial';
177
+ this.player.style.zIndex = '1';
178
+ this.playBtn = document.createElement('i');
179
+ this.currentTime = document.createElement('span');
180
+ this.progress = document.createElement('div');
181
+ this.progressCurrent = document.createElement('div');
182
+ this.loop = document.createElement('i');
183
+ var fullScreen = document.createElement('i');
184
+ this.playBtn.className = this.options.playIcon;
185
+ this.playBtn.style.fontSize = '18px';
186
+ this.playBtn.style.lineHeight = '20px';
187
+ this.playBtn.style.cursor = 'pointer';
188
+ this.currentTime.style.padding = '0 10px';
189
+ this.currentTime.innerText = '0 / 0';
190
+ this.progress.style.position = 'relative';
191
+ this.progress.style.flexGrow = '1';
192
+ this.progress.style.top = '0';
193
+ this.progress.style.height = '4px';
194
+ this.progress.style.background = '#ccc';
195
+ this.progress.style.borderRadius = '2px';
196
+ this.progress.style.overflow = 'hidden';
197
+ this.progress.style.cursor = 'pointer';
198
+ this.progressCurrent.style.position = 'absolute';
199
+ this.progressCurrent.style.left = '0';
200
+ this.progressCurrent.style.top = '0';
201
+ this.progressCurrent.style.bottom = '0';
202
+ this.progressCurrent.style.width = '0';
203
+ this.progressCurrent.style.background = '#52c41a';
204
+ this.loop.style.margin = '0 10px';
205
+ this.loop.style.padding = '2px 5px';
206
+ this.loop.style.borderRadius = '2px';
207
+ this.loop.className = this.options.loopIcon;
208
+ this.loop.style.fontSize = '18px';
209
+ this.loop.style.lineHeight = '20px';
210
+ this.loop.style.cursor = 'pointer';
211
+ fullScreen.className = this.options.fullScreenIcon;
212
+ fullScreen.style.fontSize = '17px';
213
+ fullScreen.style.lineHeight = '20px';
214
+ fullScreen.style.cursor = 'pointer';
215
+ this.player.appendChild(this.playBtn);
216
+ this.player.appendChild(this.currentTime);
217
+ this.player.appendChild(this.progress);
218
+ this.progress.appendChild(this.progressCurrent);
219
+ this.player.appendChild(this.loop);
220
+ this.player.appendChild(fullScreen);
221
+ this.playBtn.onclick = function () {
222
+ if (_this.media.paused) {
223
+ _this.media.play();
224
+ _this.playBtn.className = _this.options.pauseIcon;
225
+ } else {
226
+ _this.media.pause();
227
+ _this.playBtn.className = _this.options.playIcon;
228
+ }
229
+ };
230
+ this.progress.onclick = function (e) {
231
+ _this.media.currentTime = (e.offsetX / _this.progress.clientWidth) * _this.media.duration;
232
+ };
233
+ this.loop.onclick = function () {
234
+ _this.media.loop = !_this.media.loop;
235
+ _this.curNode.playLoop = _this.media.loop;
236
+ if (_this.media.loop) {
237
+ _this.loop.style.background = '#ddd';
238
+ } else {
239
+ _this.loop.style.background = 'none';
240
+ }
241
+ };
242
+ fullScreen.onclick = function () {
243
+ _this.media.requestFullscreen();
244
+ };
245
+ };
246
+ DivLayer.prototype.getMediaCurrent = function () {
247
+ if (!this.media) {
248
+ return;
83
249
  }
250
+ this.currentTime.innerText =
251
+ this.formatSeconds(this.media.currentTime) + ' / ' + this.formatSeconds(this.media.duration);
252
+ this.progressCurrent.style.width =
253
+ (this.media.currentTime / this.media.duration) * this.progress.clientWidth + 'px';
254
+ };
255
+ DivLayer.prototype.addMedia = function (node, type) {
256
+ var _this = this;
257
+ var player = document.createElement('div');
258
+ var current = document.createElement('div');
259
+ var media = document.createElement(type);
260
+ current.style.position = 'absolute';
261
+ current.style.outline = 'none';
262
+ current.style.left = '0';
263
+ current.style.bottom = '0';
264
+ current.style.height = '2px';
265
+ current.style.background = '#52c41a';
266
+ media.style.position = 'absolute';
267
+ media.style.outline = 'none';
268
+ media.style.left = '0';
269
+ media.style.right = '0';
270
+ media.style.top = '0';
271
+ media.style.bottom = '0';
272
+ if (type === 'video') {
273
+ media.style.width = node.rect.width + 'px';
274
+ media.style.height = node.rect.height + 'px';
275
+ }
276
+ player.style.background = 'transparent';
277
+ if (node.play === 1) {
278
+ media.autoplay = true;
279
+ }
280
+ media.loop = node.playLoop;
281
+ media.ontimeupdate = function () {
282
+ current.style.width = (media.currentTime / media.duration) * node.rect.width + 'px';
283
+ _this.getMediaCurrent();
284
+ if (_this.media === media) {
285
+ if (node.playLoop) {
286
+ media.loop = true;
287
+ _this.loop.style.background = '#ddd';
288
+ } else {
289
+ media.loop = false;
290
+ _this.loop.style.background = 'none';
291
+ }
292
+ }
293
+ };
294
+ media.onended = function () {
295
+ Store.set(_this.generateStoreKey('mediaEnd'), node);
296
+ if (_this.media === media) {
297
+ _this.playBtn.className = _this.options.playIcon;
298
+ }
299
+ _this.playNext(node.nextPlay);
300
+ };
301
+ media.onloadedmetadata = function () {
302
+ _this.getMediaCurrent();
303
+ };
304
+ media.src = node[type];
305
+ player.appendChild(media);
306
+ player.appendChild(current);
307
+ this[type + 's'][node.id] = {
308
+ player: player,
309
+ current: current,
310
+ media: media
311
+ };
312
+ this.canvas.appendChild(player);
313
+ return player;
314
+ };
315
+ DivLayer.prototype.playNext = function (next) {
316
+ if (!next) {
317
+ return;
318
+ }
319
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
320
+ var item = _a[_i];
321
+ if (!(item instanceof Node)) {
322
+ continue;
323
+ }
324
+ if (item.tags.indexOf(next) > -1) {
325
+ if (item.audio && this.audios[item.id] && this.audios[item.id].media && this.audios[item.id].media.paused) {
326
+ this.audios[item.id].media.play();
327
+ } else if (item.video && this.videos[item.id].media && this.videos[item.id].media.paused) {
328
+ this.videos[item.id].media.play();
329
+ }
330
+ }
331
+ }
332
+ };
333
+ DivLayer.prototype.addIframe = function (node) {
334
+ var iframe = document.createElement('iframe');
335
+ iframe.scrolling = 'no';
336
+ iframe.frameBorder = '0';
337
+ iframe.src = node.iframe;
338
+ this.iframes[node.id] = iframe;
339
+ this.canvas.appendChild(iframe);
340
+ return iframe;
84
341
  };
85
342
  DivLayer.prototype.addGif = function (node) {
86
343
  this.gifs[node.id] = node.img;
@@ -88,18 +345,30 @@ var DivLayer = /** @class */ (function (_super) {
88
345
  return node.img;
89
346
  };
90
347
  DivLayer.prototype.setElemPosition = function (node, elem) {
91
- setStyleForElementIdDiv(node, elem, commonStore[this.TID].data);
348
+ setStyleForElementIdDiv(node, elem, this.data);
92
349
  };
93
350
  DivLayer.prototype.removeDiv = function (item) {
94
351
  if (this.curNode && item.id === this.curNode.id) {
95
352
  this.curNode = null;
353
+ // this.media = null;
354
+ // this.player.style.top = '-99999px';
355
+ }
356
+ // if (item.audio) {
357
+ // this.canvas.removeChild(this.audios[item.id].player);
358
+ // this.audios[item.id] = null;
359
+ // }
360
+ // if (item.video) {
361
+ // this.canvas.removeChild(this.videos[item.id].player);
362
+ // this.videos[item.id] = null;
363
+ // }
364
+ if (item.iframe) {
365
+ this.canvas.removeChild(this.iframes[item.id]);
366
+ this.iframes[item.id] = null;
96
367
  }
97
368
  if (item.elementId) {
98
- const elementNode = this.elements[item.id];
99
- if(elementNode) {
100
- elementNode.parentNode.removeChild(elementNode);
101
- this.elements[item.id] = null;
102
- }
369
+ const elementNode = this.elements[item.id] || DomElements[item.id];
370
+ this.canvas.removeChild(elementNode);
371
+ this.elements[item.id] = null;
103
372
  }
104
373
  if (item.gif) {
105
374
  this.canvas.removeChild(this.gifs[item.id]);
@@ -117,15 +386,19 @@ var DivLayer = /** @class */ (function (_super) {
117
386
  };
118
387
  DivLayer.prototype.clear = function () {
119
388
  this.canvas.innerHTML = '';
389
+ //this.audios = {};
390
+ //this.videos = {};
391
+ this.iframes = {};
120
392
  this.elements = {};
121
393
  this.gifs = {};
394
+ for (var key in DomElements) {
395
+ delete DomElements[key];
396
+ }
122
397
  // tslint:disable-next-line:forin
123
- for (let key in images) {
398
+ for (var key in images) {
124
399
  delete images[key];
125
400
  }
126
- for (let key in defaultImages) {
127
- delete defaultImages[key];
128
- }
401
+ //this.player.style.top = '-99999px';
129
402
  };
130
403
  DivLayer.prototype.formatSeconds = function (seconds) {
131
404
  var h = Math.floor(seconds / 3600);
@@ -143,30 +416,25 @@ var DivLayer = /** @class */ (function (_super) {
143
416
  return txt;
144
417
  };
145
418
  DivLayer.prototype.resize = function (size) {
146
- let store = commonStore[this.TID];
147
- if(!store || !store.options) return;
148
419
  if (size) {
149
420
  this.canvas.style.width = size.width + 'px';
150
421
  this.canvas.style.height = size.height + 'px';
151
422
  } else {
152
- if (store.options.width && store.options.width !== 'auto') {
153
- this.canvas.style.width = store.options.width + 'px';
423
+ if (this.options.width && this.options.width !== 'auto') {
424
+ this.canvas.style.width = this.options.width + 'px';
154
425
  } else {
155
- this.canvas.style.width = store.parentElem.clientWidth + 'px';
426
+ this.canvas.style.width = this.parentElem.clientWidth + 'px';
156
427
  }
157
- if (store.options.height && store.options.height !== 'auto') {
158
- this.canvas.style.height = store.options.height + 'px';
428
+ if (this.options.height && this.options.height !== 'auto') {
429
+ this.canvas.style.height = this.options.height + 'px';
159
430
  } else {
160
- this.canvas.style.height = store.parentElem.clientHeight - 8 + 'px';
431
+ this.canvas.style.height = this.parentElem.clientHeight - 8 + 'px';
161
432
  }
162
433
  }
163
- store = null;
164
434
  };
165
435
  DivLayer.prototype.render = function () {
166
- if(commonStore[this.TID] || !commonStore[this.TID].data) return;
167
- for (var _i = 0, _a = commonStore[this.TID].data.pens; _i < _a.length; _i++) {
436
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
168
437
  var item = _a[_i];
169
- if(!(item instanceof Node)) item = new Node(item);
170
438
  if (!item.getTID()) {
171
439
  item.setTID(this.TID);
172
440
  }
@@ -177,6 +445,8 @@ var DivLayer = /** @class */ (function (_super) {
177
445
  DivLayer.prototype.destroy = function () {
178
446
  this.clear();
179
447
  this.subcribe.unsubscribe();
448
+ //this.subcribeNode.unsubscribe();
449
+
180
450
  //优化
181
451
  this.canvas.onmousemove = null;
182
452
  this.canvas.onmousedown = null
@@ -187,6 +457,8 @@ var DivLayer = /** @class */ (function (_super) {
187
457
  this.canvas.ondragover = null;
188
458
  this.canvas.ondrop = null;
189
459
  this.canvas.onwheel = null;
460
+
461
+ this.data = null;
190
462
  //end
191
463
  };
192
464
 
@@ -4,4 +4,5 @@ export declare function setConfItemNode(item: any[], syncData: Node): Node;
4
4
  export declare function setNodeEvents(item: any[], pen: Pen): void;
5
5
  export declare function setControlData(pen: Pen, syncData: Node): void;
6
6
  export declare function getControlNode(item: any, data: any): Node;
7
- export declare function getDetailData(data: Node): void;
7
+ export declare function getDetailData(data: Node): void;
8
+ export declare function setStatisticalData(pen: Pen, data: any): Node;