@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.9 → 1.0.1

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 (111) hide show
  1. package/es/LcdpUeditor.js +64 -61
  2. package/es/const.js +4 -4
  3. package/es/defaultConfig.json +76 -76
  4. package/es/tools/UeditorResourceLoader.js +11 -16
  5. package/es/tools/filterHtmlNode.d.ts +5 -0
  6. package/es/tools/filterHtmlNode.js +41 -0
  7. package/es/tools/loadScript.js +5 -7
  8. package/es/type.d.ts +6 -0
  9. package/lib/LcdpUeditor.js +18 -8
  10. package/lib/defaultConfig.json +76 -76
  11. package/lib/tools/filterHtmlNode.d.ts +5 -0
  12. package/lib/tools/filterHtmlNode.js +61 -0
  13. package/lib/type.d.ts +6 -0
  14. package/package.json +35 -34
  15. package/ueditor-resource/dialogs/anchor/anchor.html +62 -62
  16. package/ueditor-resource/dialogs/attachment/attachment.css +716 -716
  17. package/ueditor-resource/dialogs/attachment/attachment.html +61 -61
  18. package/ueditor-resource/dialogs/attachment/attachment.js +803 -803
  19. package/ueditor-resource/dialogs/audio/audio.css +879 -879
  20. package/ueditor-resource/dialogs/audio/audio.html +93 -93
  21. package/ueditor-resource/dialogs/audio/audio.js +815 -815
  22. package/ueditor-resource/dialogs/background/background.css +193 -193
  23. package/ueditor-resource/dialogs/background/background.html +59 -59
  24. package/ueditor-resource/dialogs/background/background.js +370 -370
  25. package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -176
  26. package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -91
  27. package/ueditor-resource/dialogs/emotion/emotion.css +129 -129
  28. package/ueditor-resource/dialogs/emotion/emotion.html +70 -70
  29. package/ueditor-resource/dialogs/emotion/emotion.js +186 -186
  30. package/ueditor-resource/dialogs/formula/formula.html +98 -98
  31. package/ueditor-resource/dialogs/formula/formula.js +147 -147
  32. package/ueditor-resource/dialogs/help/help.css +37 -37
  33. package/ueditor-resource/dialogs/help/help.html +82 -82
  34. package/ueditor-resource/dialogs/help/help.js +57 -57
  35. package/ueditor-resource/dialogs/image/image.css +768 -768
  36. package/ueditor-resource/dialogs/image/image.html +144 -144
  37. package/ueditor-resource/dialogs/image/image.js +1060 -1060
  38. package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -135
  39. package/ueditor-resource/dialogs/internal.js +81 -81
  40. package/ueditor-resource/dialogs/link/link.html +148 -148
  41. package/ueditor-resource/dialogs/preview/preview.html +45 -45
  42. package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -324
  43. package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -95
  44. package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -682
  45. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -144
  46. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -174
  47. package/ueditor-resource/dialogs/spechars/spechars.html +42 -42
  48. package/ueditor-resource/dialogs/spechars/spechars.js +86 -86
  49. package/ueditor-resource/dialogs/table/edittable.css +85 -85
  50. package/ueditor-resource/dialogs/table/edittable.html +69 -69
  51. package/ueditor-resource/dialogs/table/edittable.js +241 -241
  52. package/ueditor-resource/dialogs/table/edittd.html +62 -62
  53. package/ueditor-resource/dialogs/table/edittip.html +33 -33
  54. package/ueditor-resource/dialogs/template/config.js +42 -42
  55. package/ueditor-resource/dialogs/template/template.css +99 -99
  56. package/ueditor-resource/dialogs/template/template.html +26 -26
  57. package/ueditor-resource/dialogs/template/template.js +53 -53
  58. package/ueditor-resource/dialogs/video/video.css +909 -909
  59. package/ueditor-resource/dialogs/video/video.html +114 -114
  60. package/ueditor-resource/dialogs/video/video.js +867 -867
  61. package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -221
  62. package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -93
  63. package/ueditor-resource/lang/en/en.js +686 -686
  64. package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -748
  65. package/ueditor-resource/lang/zh-tw/zh-tw.js +748 -748
  66. package/ueditor-resource/plugins/demo/demo.js +3 -3
  67. package/ueditor-resource/themes/default/css/ueditor.css +2148 -2148
  68. package/ueditor-resource/themes/default/dialog.css +17 -17
  69. package/ueditor-resource/themes/default/dialogbase.css +132 -132
  70. package/ueditor-resource/themes/default/exts/ai.svg +12 -12
  71. package/ueditor-resource/themes/default/exts/apk.svg +12 -12
  72. package/ueditor-resource/themes/default/exts/chm.svg +12 -12
  73. package/ueditor-resource/themes/default/exts/css.svg +12 -12
  74. package/ueditor-resource/themes/default/exts/doc.svg +22 -22
  75. package/ueditor-resource/themes/default/exts/docx.svg +22 -22
  76. package/ueditor-resource/themes/default/exts/dwg.svg +16 -16
  77. package/ueditor-resource/themes/default/exts/folder.svg +3 -3
  78. package/ueditor-resource/themes/default/exts/gif.svg +14 -14
  79. package/ueditor-resource/themes/default/exts/html.svg +12 -12
  80. package/ueditor-resource/themes/default/exts/jpeg.svg +14 -14
  81. package/ueditor-resource/themes/default/exts/jpg.svg +14 -14
  82. package/ueditor-resource/themes/default/exts/log.svg +12 -12
  83. package/ueditor-resource/themes/default/exts/mp3.svg +14 -14
  84. package/ueditor-resource/themes/default/exts/mp4.svg +12 -12
  85. package/ueditor-resource/themes/default/exts/pdf.svg +14 -14
  86. package/ueditor-resource/themes/default/exts/png.svg +14 -14
  87. package/ueditor-resource/themes/default/exts/ppt.svg +24 -24
  88. package/ueditor-resource/themes/default/exts/pptx.svg +24 -24
  89. package/ueditor-resource/themes/default/exts/psd.svg +12 -12
  90. package/ueditor-resource/themes/default/exts/rar.svg +12 -12
  91. package/ueditor-resource/themes/default/exts/svg.svg +12 -12
  92. package/ueditor-resource/themes/default/exts/torrent.svg +14 -14
  93. package/ueditor-resource/themes/default/exts/txt.svg +14 -14
  94. package/ueditor-resource/themes/default/exts/unknown.svg +12 -12
  95. package/ueditor-resource/themes/default/exts/xls.svg +25 -25
  96. package/ueditor-resource/themes/default/exts/xlsx.svg +25 -25
  97. package/ueditor-resource/themes/default/exts/zip.svg +12 -12
  98. package/ueditor-resource/themes/iframe.css +63 -63
  99. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -3655
  100. package/ueditor-resource/third-party/clipboard/clipboard.js +752 -752
  101. package/ueditor-resource/third-party/codemirror/codemirror.css +106 -106
  102. package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -3581
  103. package/ueditor-resource/third-party/jquery-3.5.1.js +1 -1
  104. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -4314
  105. package/ueditor-resource/third-party/webuploader/webuploader.css +88 -88
  106. package/ueditor-resource/third-party/webuploader/webuploader.js +3 -3
  107. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
  108. package/ueditor-resource/{lcdp-ueditor.all.js → ueditor.all.js} +5270 -5269
  109. package/ueditor-resource/ueditor.config.js +655 -655
  110. package/ueditor-resource/{lcdp-ueditor.parse.js → ueditor.parse.js} +13 -13
  111. package/ueditor-resource/index.html +0 -146
@@ -1,370 +1,370 @@
1
- (function () {
2
-
3
- var onlineImage,
4
- backupStyle = editor.queryCommandValue('background');
5
-
6
- window.onload = function () {
7
- initTabs();
8
- initColorSelector();
9
- };
10
-
11
- /* 初始化tab标签 */
12
- function initTabs() {
13
- var tabs = $G('tabHeads').children;
14
- for (var i = 0; i < tabs.length; i++) {
15
- domUtils.on(tabs[i], "click", function (e) {
16
- var target = e.target || e.srcElement;
17
- for (var j = 0; j < tabs.length; j++) {
18
- if (tabs[j] == target) {
19
- tabs[j].className = "focus";
20
- var contentId = tabs[j].getAttribute('data-content-id');
21
- $G(contentId).style.display = "block";
22
- } else {
23
- tabs[j].className = "";
24
- $G(tabs[j].getAttribute('data-content-id')).style.display = "none";
25
- }
26
- }
27
- });
28
- }
29
- }
30
-
31
- /* 初始化颜色设置 */
32
- function initColorSelector() {
33
- var obj = editor.queryCommandValue('background');
34
- if (obj) {
35
- var color = obj['background-color'],
36
- repeat = obj['background-repeat'] || 'repeat',
37
- image = obj['background-image'] || '',
38
- position = obj['background-position'] || 'center center',
39
- pos = position.split(' '),
40
- x = parseInt(pos[0]) || 0,
41
- y = parseInt(pos[1]) || 0;
42
-
43
- if (repeat == 'no-repeat' && (x || y)) repeat = 'self';
44
-
45
- image = image.match(/url[\s]*\(([^\)]*)\)/);
46
- image = image ? image[1] : '';
47
- updateFormState('colored', color, image, repeat, x, y);
48
- } else {
49
- updateFormState();
50
- }
51
-
52
- var updateHandler = function () {
53
- updateFormState();
54
- updateBackground();
55
- }
56
- domUtils.on($G('nocolorRadio'), 'click', updateBackground);
57
- domUtils.on($G('coloredRadio'), 'click', updateHandler);
58
- domUtils.on($G('url'), 'keyup', function () {
59
- if ($G('url').value && $G('alignment').style.display == "none") {
60
- utils.each($G('repeatType').children, function (item) {
61
- item.selected = ('repeat' == item.getAttribute('value') ? 'selected' : false);
62
- });
63
- }
64
- updateHandler();
65
- });
66
- domUtils.on($G('repeatType'), 'change', updateHandler);
67
- domUtils.on($G('x'), 'keyup', updateBackground);
68
- domUtils.on($G('y'), 'keyup', updateBackground);
69
-
70
- initColorPicker();
71
- }
72
-
73
- /* 初始化颜色选择器 */
74
- function initColorPicker() {
75
- var me = editor,
76
- cp = $G("colorPicker");
77
-
78
- /* 生成颜色选择器ui对象 */
79
- var popup = new UE.ui.Popup({
80
- content: new UE.ui.ColorPicker({
81
- noColorText: me.getLang("clearColor"),
82
- editor: me,
83
- onpickcolor: function (t, color) {
84
- updateFormState('colored', color);
85
- updateBackground();
86
- UE.ui.Popup.postHide();
87
- },
88
- onpicknocolor: function (t, color) {
89
- updateFormState('colored', 'transparent');
90
- updateBackground();
91
- UE.ui.Popup.postHide();
92
- }
93
- }),
94
- editor: me,
95
- onhide: function () {
96
- }
97
- });
98
-
99
- /* 设置颜色选择器 */
100
- domUtils.on(cp, "click", function () {
101
- popup.showAnchor(this);
102
- });
103
- domUtils.on(document, 'mousedown', function (evt) {
104
- var el = evt.target || evt.srcElement;
105
- UE.ui.Popup.postHide(el);
106
- });
107
- domUtils.on(window, 'scroll', function () {
108
- UE.ui.Popup.postHide();
109
- });
110
- }
111
-
112
- /* 更新背景色设置面板 */
113
- function updateFormState(radio, color, url, align, x, y) {
114
- var nocolorRadio = $G('nocolorRadio'),
115
- coloredRadio = $G('coloredRadio');
116
-
117
- if (radio) {
118
- nocolorRadio.checked = (radio == 'colored' ? false : 'checked');
119
- coloredRadio.checked = (radio == 'colored' ? 'checked' : false);
120
- }
121
- if (color) {
122
- domUtils.setStyle($G("colorPicker"), "background-color", color);
123
- }
124
-
125
- if (url && /^\//.test(url)) {
126
- var a = document.createElement('a');
127
- a.href = url;
128
- browser.ie && (a.href = a.href);
129
- url = browser.ie ? a.href : (a.protocol + '//' + a.host + a.pathname + a.search + a.hash);
130
- }
131
-
132
- if (url || url === '') {
133
- $G('url').value = url;
134
- }
135
- if (align) {
136
- utils.each($G('repeatType').children, function (item) {
137
- item.selected = (align == item.getAttribute('value') ? 'selected' : false);
138
- });
139
- }
140
- if (x || y) {
141
- $G('x').value = parseInt(x) || 0;
142
- $G('y').value = parseInt(y) || 0;
143
- }
144
-
145
- $G('alignment').style.display = coloredRadio.checked && $G('url').value ? '' : 'none';
146
- $G('custom').style.display = coloredRadio.checked && $G('url').value && $G('repeatType').value == 'self' ? '' : 'none';
147
- }
148
-
149
- /* 更新背景颜色 */
150
- function updateBackground() {
151
- if ($G('coloredRadio').checked) {
152
- var color = domUtils.getStyle($G("colorPicker"), "background-color"),
153
- bgimg = $G("url").value,
154
- align = $G("repeatType").value,
155
- backgroundObj = {
156
- "background-repeat": "no-repeat",
157
- "background-position": "center center"
158
- };
159
-
160
- if (color) backgroundObj["background-color"] = color;
161
- if (bgimg) backgroundObj["background-image"] = 'url(' + bgimg + ')';
162
- if (align == 'self') {
163
- backgroundObj["background-position"] = $G("x").value + "px " + $G("y").value + "px";
164
- } else if (align == 'repeat-x' || align == 'repeat-y' || align == 'repeat') {
165
- backgroundObj["background-repeat"] = align;
166
- }
167
-
168
- editor.execCommand('background', backgroundObj);
169
- } else {
170
- editor.execCommand('background', null);
171
- }
172
- }
173
-
174
-
175
- /* 在线图片 */
176
- function OnlineImage(target) {
177
- this.container = utils.isString(target) ? document.getElementById(target) : target;
178
- this.init();
179
- }
180
-
181
- OnlineImage.prototype = {
182
- init: function () {
183
- this.reset();
184
- this.initEvents();
185
- },
186
- /* 初始化容器 */
187
- initContainer: function () {
188
- this.container.innerHTML = '';
189
- this.list = document.createElement('ul');
190
- this.clearFloat = document.createElement('li');
191
-
192
- domUtils.addClass(this.list, 'list');
193
- domUtils.addClass(this.clearFloat, 'clearFloat');
194
-
195
- this.list.id = 'imageListUl';
196
- this.list.appendChild(this.clearFloat);
197
- this.container.appendChild(this.list);
198
- },
199
- /* 初始化滚动事件,滚动到地步自动拉取数据 */
200
- initEvents: function () {
201
- var _this = this;
202
-
203
- /* 滚动拉取图片 */
204
- domUtils.on($G('imageList'), 'scroll', function (e) {
205
- var panel = this;
206
- if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
207
- _this.getImageData();
208
- }
209
- });
210
- /* 选中图片 */
211
- domUtils.on(this.container, 'click', function (e) {
212
- var target = e.target || e.srcElement,
213
- li = target.parentNode,
214
- nodes = $G('imageListUl').childNodes;
215
-
216
- if (li.tagName.toLowerCase() == 'li') {
217
- updateFormState('nocolor', null, '');
218
- for (var i = 0, node; node = nodes[i++];) {
219
- if (node == li && !domUtils.hasClass(node, 'selected')) {
220
- domUtils.addClass(node, 'selected');
221
- updateFormState('colored', null, li.firstChild.getAttribute("_src"), 'repeat');
222
- } else {
223
- domUtils.removeClasses(node, 'selected');
224
- }
225
- }
226
- updateBackground();
227
- }
228
- });
229
- },
230
- /* 初始化第一次的数据 */
231
- initData: function () {
232
-
233
- /* 拉取数据需要使用的值 */
234
- this.state = 0;
235
- this.listSize = editor.getOpt('imageManagerListSize');
236
- this.listIndex = 0;
237
- this.listEnd = false;
238
-
239
- /* 第一次拉取数据 */
240
- this.getImageData();
241
- },
242
- /* 重置界面 */
243
- reset: function () {
244
- this.initContainer();
245
- this.initData();
246
- },
247
- /* 向后台拉取图片列表数据 */
248
- getImageData: function () {
249
- var _this = this;
250
-
251
- if (!_this.listEnd && !this.isLoadingData) {
252
- this.isLoadingData = true;
253
- var url = editor.getActionUrl(editor.getOpt('imageManagerActionName')),
254
- isJsonp = utils.isCrossDomainUrl(url);
255
- ajax.request(url, {
256
- 'timeout': 100000,
257
- 'dataType': isJsonp ? 'jsonp' : '',
258
- 'data': utils.extend({
259
- start: this.listIndex,
260
- size: this.listSize
261
- }, editor.queryCommandValue('serverparam')),
262
- 'headers': editor.options.serverHeaders || {},
263
- 'method': 'get',
264
- 'onsuccess': function (r) {
265
- try {
266
- var json = isJsonp ? r : eval('(' + r.responseText + ')');
267
- if (json.state == 'SUCCESS') {
268
- _this.pushData(json.list);
269
- _this.listIndex = parseInt(json.start) + parseInt(json.list.length);
270
- if (_this.listIndex >= json.total) {
271
- _this.listEnd = true;
272
- }
273
- _this.isLoadingData = false;
274
- }
275
- } catch (e) {
276
- if (r.responseText.indexOf('ue_separate_ue') != -1) {
277
- var list = r.responseText.split(r.responseText);
278
- _this.pushData(list);
279
- _this.listIndex = parseInt(list.length);
280
- _this.listEnd = true;
281
- _this.isLoadingData = false;
282
- }
283
- }
284
- },
285
- 'onerror': function () {
286
- _this.isLoadingData = false;
287
- }
288
- });
289
- }
290
- },
291
- /* 添加图片到列表界面上 */
292
- pushData: function (list) {
293
- var i, item, img, icon, _this = this,
294
- urlPrefix = editor.getOpt('imageManagerUrlPrefix');
295
- for (i = 0; i < list.length; i++) {
296
- if (list[i] && list[i].url) {
297
- item = document.createElement('li');
298
- img = document.createElement('img');
299
- icon = document.createElement('span');
300
-
301
- domUtils.on(img, 'load', (function (image) {
302
- return function () {
303
- _this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight);
304
- }
305
- })(img));
306
- img.width = 113;
307
- img.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=' : '&noCache=') + (+new Date()).toString(36));
308
- img.setAttribute('_src', urlPrefix + list[i].url);
309
- domUtils.addClass(icon, 'icon');
310
-
311
- item.appendChild(img);
312
- item.appendChild(icon);
313
- this.list.insertBefore(item, this.clearFloat);
314
- }
315
- }
316
- },
317
- /* 改变图片大小 */
318
- scale: function (img, w, h, type) {
319
- var ow = img.width,
320
- oh = img.height;
321
-
322
- if (type == 'justify') {
323
- if (ow >= oh) {
324
- img.width = w;
325
- img.height = h * oh / ow;
326
- img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
327
- } else {
328
- img.width = w * ow / oh;
329
- img.height = h;
330
- img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
331
- }
332
- } else {
333
- if (ow >= oh) {
334
- img.width = w * ow / oh;
335
- img.height = h;
336
- img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
337
- } else {
338
- img.width = w;
339
- img.height = h * oh / ow;
340
- img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
341
- }
342
- }
343
- },
344
- getInsertList: function () {
345
- var i, lis = this.list.children, list = [], align = getAlign();
346
- for (i = 0; i < lis.length; i++) {
347
- if (domUtils.hasClass(lis[i], 'selected')) {
348
- var img = lis[i].firstChild,
349
- src = img.getAttribute('_src');
350
- list.push({
351
- src: src,
352
- _src: src,
353
- floatStyle: align
354
- });
355
- }
356
-
357
- }
358
- return list;
359
- }
360
- };
361
-
362
- dialog.onok = function () {
363
- updateBackground();
364
- editor.fireEvent('saveScene');
365
- };
366
- dialog.oncancel = function () {
367
- editor.execCommand('background', backupStyle);
368
- };
369
-
370
- })();
1
+ (function () {
2
+
3
+ var onlineImage,
4
+ backupStyle = editor.queryCommandValue('background');
5
+
6
+ window.onload = function () {
7
+ initTabs();
8
+ initColorSelector();
9
+ };
10
+
11
+ /* 初始化tab标签 */
12
+ function initTabs() {
13
+ var tabs = $G('tabHeads').children;
14
+ for (var i = 0; i < tabs.length; i++) {
15
+ domUtils.on(tabs[i], "click", function (e) {
16
+ var target = e.target || e.srcElement;
17
+ for (var j = 0; j < tabs.length; j++) {
18
+ if (tabs[j] == target) {
19
+ tabs[j].className = "focus";
20
+ var contentId = tabs[j].getAttribute('data-content-id');
21
+ $G(contentId).style.display = "block";
22
+ } else {
23
+ tabs[j].className = "";
24
+ $G(tabs[j].getAttribute('data-content-id')).style.display = "none";
25
+ }
26
+ }
27
+ });
28
+ }
29
+ }
30
+
31
+ /* 初始化颜色设置 */
32
+ function initColorSelector() {
33
+ var obj = editor.queryCommandValue('background');
34
+ if (obj) {
35
+ var color = obj['background-color'],
36
+ repeat = obj['background-repeat'] || 'repeat',
37
+ image = obj['background-image'] || '',
38
+ position = obj['background-position'] || 'center center',
39
+ pos = position.split(' '),
40
+ x = parseInt(pos[0]) || 0,
41
+ y = parseInt(pos[1]) || 0;
42
+
43
+ if (repeat == 'no-repeat' && (x || y)) repeat = 'self';
44
+
45
+ image = image.match(/url[\s]*\(([^\)]*)\)/);
46
+ image = image ? image[1] : '';
47
+ updateFormState('colored', color, image, repeat, x, y);
48
+ } else {
49
+ updateFormState();
50
+ }
51
+
52
+ var updateHandler = function () {
53
+ updateFormState();
54
+ updateBackground();
55
+ }
56
+ domUtils.on($G('nocolorRadio'), 'click', updateBackground);
57
+ domUtils.on($G('coloredRadio'), 'click', updateHandler);
58
+ domUtils.on($G('url'), 'keyup', function () {
59
+ if ($G('url').value && $G('alignment').style.display == "none") {
60
+ utils.each($G('repeatType').children, function (item) {
61
+ item.selected = ('repeat' == item.getAttribute('value') ? 'selected' : false);
62
+ });
63
+ }
64
+ updateHandler();
65
+ });
66
+ domUtils.on($G('repeatType'), 'change', updateHandler);
67
+ domUtils.on($G('x'), 'keyup', updateBackground);
68
+ domUtils.on($G('y'), 'keyup', updateBackground);
69
+
70
+ initColorPicker();
71
+ }
72
+
73
+ /* 初始化颜色选择器 */
74
+ function initColorPicker() {
75
+ var me = editor,
76
+ cp = $G("colorPicker");
77
+
78
+ /* 生成颜色选择器ui对象 */
79
+ var popup = new UE.ui.Popup({
80
+ content: new UE.ui.ColorPicker({
81
+ noColorText: me.getLang("clearColor"),
82
+ editor: me,
83
+ onpickcolor: function (t, color) {
84
+ updateFormState('colored', color);
85
+ updateBackground();
86
+ UE.ui.Popup.postHide();
87
+ },
88
+ onpicknocolor: function (t, color) {
89
+ updateFormState('colored', 'transparent');
90
+ updateBackground();
91
+ UE.ui.Popup.postHide();
92
+ }
93
+ }),
94
+ editor: me,
95
+ onhide: function () {
96
+ }
97
+ });
98
+
99
+ /* 设置颜色选择器 */
100
+ domUtils.on(cp, "click", function () {
101
+ popup.showAnchor(this);
102
+ });
103
+ domUtils.on(document, 'mousedown', function (evt) {
104
+ var el = evt.target || evt.srcElement;
105
+ UE.ui.Popup.postHide(el);
106
+ });
107
+ domUtils.on(window, 'scroll', function () {
108
+ UE.ui.Popup.postHide();
109
+ });
110
+ }
111
+
112
+ /* 更新背景色设置面板 */
113
+ function updateFormState(radio, color, url, align, x, y) {
114
+ var nocolorRadio = $G('nocolorRadio'),
115
+ coloredRadio = $G('coloredRadio');
116
+
117
+ if (radio) {
118
+ nocolorRadio.checked = (radio == 'colored' ? false : 'checked');
119
+ coloredRadio.checked = (radio == 'colored' ? 'checked' : false);
120
+ }
121
+ if (color) {
122
+ domUtils.setStyle($G("colorPicker"), "background-color", color);
123
+ }
124
+
125
+ if (url && /^\//.test(url)) {
126
+ var a = document.createElement('a');
127
+ a.href = url;
128
+ browser.ie && (a.href = a.href);
129
+ url = browser.ie ? a.href : (a.protocol + '//' + a.host + a.pathname + a.search + a.hash);
130
+ }
131
+
132
+ if (url || url === '') {
133
+ $G('url').value = url;
134
+ }
135
+ if (align) {
136
+ utils.each($G('repeatType').children, function (item) {
137
+ item.selected = (align == item.getAttribute('value') ? 'selected' : false);
138
+ });
139
+ }
140
+ if (x || y) {
141
+ $G('x').value = parseInt(x) || 0;
142
+ $G('y').value = parseInt(y) || 0;
143
+ }
144
+
145
+ $G('alignment').style.display = coloredRadio.checked && $G('url').value ? '' : 'none';
146
+ $G('custom').style.display = coloredRadio.checked && $G('url').value && $G('repeatType').value == 'self' ? '' : 'none';
147
+ }
148
+
149
+ /* 更新背景颜色 */
150
+ function updateBackground() {
151
+ if ($G('coloredRadio').checked) {
152
+ var color = domUtils.getStyle($G("colorPicker"), "background-color"),
153
+ bgimg = $G("url").value,
154
+ align = $G("repeatType").value,
155
+ backgroundObj = {
156
+ "background-repeat": "no-repeat",
157
+ "background-position": "center center"
158
+ };
159
+
160
+ if (color) backgroundObj["background-color"] = color;
161
+ if (bgimg) backgroundObj["background-image"] = 'url(' + bgimg + ')';
162
+ if (align == 'self') {
163
+ backgroundObj["background-position"] = $G("x").value + "px " + $G("y").value + "px";
164
+ } else if (align == 'repeat-x' || align == 'repeat-y' || align == 'repeat') {
165
+ backgroundObj["background-repeat"] = align;
166
+ }
167
+
168
+ editor.execCommand('background', backgroundObj);
169
+ } else {
170
+ editor.execCommand('background', null);
171
+ }
172
+ }
173
+
174
+
175
+ /* 在线图片 */
176
+ function OnlineImage(target) {
177
+ this.container = utils.isString(target) ? document.getElementById(target) : target;
178
+ this.init();
179
+ }
180
+
181
+ OnlineImage.prototype = {
182
+ init: function () {
183
+ this.reset();
184
+ this.initEvents();
185
+ },
186
+ /* 初始化容器 */
187
+ initContainer: function () {
188
+ this.container.innerHTML = '';
189
+ this.list = document.createElement('ul');
190
+ this.clearFloat = document.createElement('li');
191
+
192
+ domUtils.addClass(this.list, 'list');
193
+ domUtils.addClass(this.clearFloat, 'clearFloat');
194
+
195
+ this.list.id = 'imageListUl';
196
+ this.list.appendChild(this.clearFloat);
197
+ this.container.appendChild(this.list);
198
+ },
199
+ /* 初始化滚动事件,滚动到地步自动拉取数据 */
200
+ initEvents: function () {
201
+ var _this = this;
202
+
203
+ /* 滚动拉取图片 */
204
+ domUtils.on($G('imageList'), 'scroll', function (e) {
205
+ var panel = this;
206
+ if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
207
+ _this.getImageData();
208
+ }
209
+ });
210
+ /* 选中图片 */
211
+ domUtils.on(this.container, 'click', function (e) {
212
+ var target = e.target || e.srcElement,
213
+ li = target.parentNode,
214
+ nodes = $G('imageListUl').childNodes;
215
+
216
+ if (li.tagName.toLowerCase() == 'li') {
217
+ updateFormState('nocolor', null, '');
218
+ for (var i = 0, node; node = nodes[i++];) {
219
+ if (node == li && !domUtils.hasClass(node, 'selected')) {
220
+ domUtils.addClass(node, 'selected');
221
+ updateFormState('colored', null, li.firstChild.getAttribute("_src"), 'repeat');
222
+ } else {
223
+ domUtils.removeClasses(node, 'selected');
224
+ }
225
+ }
226
+ updateBackground();
227
+ }
228
+ });
229
+ },
230
+ /* 初始化第一次的数据 */
231
+ initData: function () {
232
+
233
+ /* 拉取数据需要使用的值 */
234
+ this.state = 0;
235
+ this.listSize = editor.getOpt('imageManagerListSize');
236
+ this.listIndex = 0;
237
+ this.listEnd = false;
238
+
239
+ /* 第一次拉取数据 */
240
+ this.getImageData();
241
+ },
242
+ /* 重置界面 */
243
+ reset: function () {
244
+ this.initContainer();
245
+ this.initData();
246
+ },
247
+ /* 向后台拉取图片列表数据 */
248
+ getImageData: function () {
249
+ var _this = this;
250
+
251
+ if (!_this.listEnd && !this.isLoadingData) {
252
+ this.isLoadingData = true;
253
+ var url = editor.getActionUrl(editor.getOpt('imageManagerActionName')),
254
+ isJsonp = utils.isCrossDomainUrl(url);
255
+ ajax.request(url, {
256
+ 'timeout': 100000,
257
+ 'dataType': isJsonp ? 'jsonp' : '',
258
+ 'data': utils.extend({
259
+ start: this.listIndex,
260
+ size: this.listSize
261
+ }, editor.queryCommandValue('serverparam')),
262
+ 'headers': editor.options.serverHeaders || {},
263
+ 'method': 'get',
264
+ 'onsuccess': function (r) {
265
+ try {
266
+ var json = isJsonp ? r : eval('(' + r.responseText + ')');
267
+ if (json.state == 'SUCCESS') {
268
+ _this.pushData(json.list);
269
+ _this.listIndex = parseInt(json.start) + parseInt(json.list.length);
270
+ if (_this.listIndex >= json.total) {
271
+ _this.listEnd = true;
272
+ }
273
+ _this.isLoadingData = false;
274
+ }
275
+ } catch (e) {
276
+ if (r.responseText.indexOf('ue_separate_ue') != -1) {
277
+ var list = r.responseText.split(r.responseText);
278
+ _this.pushData(list);
279
+ _this.listIndex = parseInt(list.length);
280
+ _this.listEnd = true;
281
+ _this.isLoadingData = false;
282
+ }
283
+ }
284
+ },
285
+ 'onerror': function () {
286
+ _this.isLoadingData = false;
287
+ }
288
+ });
289
+ }
290
+ },
291
+ /* 添加图片到列表界面上 */
292
+ pushData: function (list) {
293
+ var i, item, img, icon, _this = this,
294
+ urlPrefix = editor.getOpt('imageManagerUrlPrefix');
295
+ for (i = 0; i < list.length; i++) {
296
+ if (list[i] && list[i].url) {
297
+ item = document.createElement('li');
298
+ img = document.createElement('img');
299
+ icon = document.createElement('span');
300
+
301
+ domUtils.on(img, 'load', (function (image) {
302
+ return function () {
303
+ _this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight);
304
+ }
305
+ })(img));
306
+ img.width = 113;
307
+ img.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=' : '&noCache=') + (+new Date()).toString(36));
308
+ img.setAttribute('_src', urlPrefix + list[i].url);
309
+ domUtils.addClass(icon, 'icon');
310
+
311
+ item.appendChild(img);
312
+ item.appendChild(icon);
313
+ this.list.insertBefore(item, this.clearFloat);
314
+ }
315
+ }
316
+ },
317
+ /* 改变图片大小 */
318
+ scale: function (img, w, h, type) {
319
+ var ow = img.width,
320
+ oh = img.height;
321
+
322
+ if (type == 'justify') {
323
+ if (ow >= oh) {
324
+ img.width = w;
325
+ img.height = h * oh / ow;
326
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
327
+ } else {
328
+ img.width = w * ow / oh;
329
+ img.height = h;
330
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
331
+ }
332
+ } else {
333
+ if (ow >= oh) {
334
+ img.width = w * ow / oh;
335
+ img.height = h;
336
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
337
+ } else {
338
+ img.width = w;
339
+ img.height = h * oh / ow;
340
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
341
+ }
342
+ }
343
+ },
344
+ getInsertList: function () {
345
+ var i, lis = this.list.children, list = [], align = getAlign();
346
+ for (i = 0; i < lis.length; i++) {
347
+ if (domUtils.hasClass(lis[i], 'selected')) {
348
+ var img = lis[i].firstChild,
349
+ src = img.getAttribute('_src');
350
+ list.push({
351
+ src: src,
352
+ _src: src,
353
+ floatStyle: align
354
+ });
355
+ }
356
+
357
+ }
358
+ return list;
359
+ }
360
+ };
361
+
362
+ dialog.onok = function () {
363
+ updateBackground();
364
+ editor.fireEvent('saveScene');
365
+ };
366
+ dialog.oncancel = function () {
367
+ editor.execCommand('background', backupStyle);
368
+ };
369
+
370
+ })();