@lingxiteam/lcdp-ueditor-react 1.0.2 → 1.0.3-alpha.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 (76) hide show
  1. package/es/LcdpUeditor.d.ts.map +1 -1
  2. package/es/LcdpUeditor.js +2 -1
  3. package/es/tools/UeditorResourceLoader.d.ts +1 -1
  4. package/es/tools/UeditorResourceLoader.d.ts.map +1 -1
  5. package/es/tools/UeditorResourceLoader.js +18 -7
  6. package/es/tools/filterHtmlNode.d.ts.map +1 -1
  7. package/es/tools/filterHtmlNode.js +7 -2
  8. package/lib/LcdpUeditor.js +1 -3
  9. package/lib/tools/UeditorResourceLoader.d.ts +1 -1
  10. package/lib/tools/UeditorResourceLoader.js +15 -7
  11. package/lib/tools/filterHtmlNode.js +8 -4
  12. package/package.json +1 -1
  13. package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
  14. package/ueditor-resource/dialogs/attachment/attachment.css +2 -715
  15. package/ueditor-resource/dialogs/attachment/attachment.html +6 -6
  16. package/ueditor-resource/dialogs/attachment/attachment.js +2 -803
  17. package/ueditor-resource/dialogs/audio/audio.css +2 -878
  18. package/ueditor-resource/dialogs/audio/audio.js +2 -815
  19. package/ueditor-resource/dialogs/background/background.css +2 -192
  20. package/ueditor-resource/dialogs/background/background.html +3 -3
  21. package/ueditor-resource/dialogs/background/background.js +2 -370
  22. package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
  23. package/ueditor-resource/dialogs/contentimport/contentimport.js +2 -91
  24. package/ueditor-resource/dialogs/emotion/emotion.css +2 -128
  25. package/ueditor-resource/dialogs/emotion/emotion.html +3 -3
  26. package/ueditor-resource/dialogs/emotion/emotion.js +2 -186
  27. package/ueditor-resource/dialogs/formula/formula.html +4 -4
  28. package/ueditor-resource/dialogs/formula/formula.js +2 -147
  29. package/ueditor-resource/dialogs/help/help.css +2 -36
  30. package/ueditor-resource/dialogs/help/help.html +3 -3
  31. package/ueditor-resource/dialogs/help/help.js +2 -57
  32. package/ueditor-resource/dialogs/image/image.css +2 -767
  33. package/ueditor-resource/dialogs/image/image.js +2 -1060
  34. package/ueditor-resource/dialogs/insertframe/insertframe.html +2 -2
  35. package/ueditor-resource/dialogs/internal.js +2 -81
  36. package/ueditor-resource/dialogs/preview/preview.html +2 -2
  37. package/ueditor-resource/dialogs/scrawl/scrawl.css +2 -323
  38. package/ueditor-resource/dialogs/scrawl/scrawl.html +3 -3
  39. package/ueditor-resource/dialogs/scrawl/scrawl.js +2 -682
  40. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
  41. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +2 -174
  42. package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
  43. package/ueditor-resource/dialogs/spechars/spechars.js +2 -86
  44. package/ueditor-resource/dialogs/table/edittable.css +2 -84
  45. package/ueditor-resource/dialogs/table/edittable.html +3 -3
  46. package/ueditor-resource/dialogs/table/edittable.js +2 -241
  47. package/ueditor-resource/dialogs/table/edittd.html +1 -1
  48. package/ueditor-resource/dialogs/table/edittip.html +1 -1
  49. package/ueditor-resource/dialogs/template/config.js +2 -42
  50. package/ueditor-resource/dialogs/template/template.css +2 -98
  51. package/ueditor-resource/dialogs/template/template.html +4 -4
  52. package/ueditor-resource/dialogs/template/template.js +2 -53
  53. package/ueditor-resource/dialogs/video/video.css +2 -908
  54. package/ueditor-resource/dialogs/video/video.js +2 -867
  55. package/ueditor-resource/dialogs/wordimage/wordimage.html +5 -5
  56. package/ueditor-resource/dialogs/wordimage/wordimage.js +2 -93
  57. package/ueditor-resource/lang/en/en.js +2 -686
  58. package/ueditor-resource/lang/zh-cn/zh-cn.js +2 -748
  59. package/ueditor-resource/lang/zh-tw/zh-tw.js +2 -748
  60. package/ueditor-resource/plugins/demo/demo.js +1 -3
  61. package/ueditor-resource/themes/default/css/ueditor.css +2 -2148
  62. package/ueditor-resource/themes/default/dialog.css +2 -16
  63. package/ueditor-resource/themes/default/dialogbase.css +2 -131
  64. package/ueditor-resource/themes/iframe.css +2 -62
  65. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +4 -3655
  66. package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +3 -1
  67. package/ueditor-resource/third-party/clipboard/clipboard.js +2 -753
  68. package/ueditor-resource/third-party/codemirror/codemirror.css +2 -105
  69. package/ueditor-resource/third-party/codemirror/codemirror.js +3 -3581
  70. package/ueditor-resource/third-party/jquery-3.5.1.js +4 -2
  71. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4 -4314
  72. package/ueditor-resource/third-party/webuploader/webuploader.css +2 -87
  73. package/ueditor-resource/third-party/webuploader/webuploader.js +5 -4
  74. package/ueditor-resource/ueditor.all.js +20 -32644
  75. package/ueditor-resource/ueditor.config.js +2 -655
  76. package/ueditor-resource/ueditor.parse.js +2 -639
@@ -1,803 +1,2 @@
1
- /**
2
- * User: Jinqn
3
- * Date: 14-04-08
4
- * Time: 下午16:34
5
- * 上传图片对话框逻辑代码,包括tab: 远程图片/上传图片/在线图片/搜索图片
6
- */
7
-
8
- (function () {
9
-
10
- var uploadFile,
11
- onlineFile;
12
-
13
- window.onload = function () {
14
- initTabs();
15
- initButtons();
16
- };
17
-
18
- /* 初始化tab标签 */
19
- function initTabs() {
20
- $G('tabhead').querySelector('[data-content-id="online"]').style.display = 'none';
21
- var tabs = $G('tabhead').children;
22
- for (var i = 0; i < tabs.length; i++) {
23
- domUtils.on(tabs[i], "click", function (e) {
24
- var target = e.target || e.srcElement;
25
- setTabFocus(target.getAttribute('data-content-id'));
26
- });
27
- }
28
-
29
- setTabFocus('upload');
30
- }
31
-
32
- /* 初始化tabbody */
33
- function setTabFocus(id) {
34
- if (!id) return;
35
- var i, bodyId, tabs = $G('tabhead').children;
36
- for (i = 0; i < tabs.length; i++) {
37
- bodyId = tabs[i].getAttribute('data-content-id')
38
- if (bodyId == id) {
39
- domUtils.addClass(tabs[i], 'focus');
40
- domUtils.addClass($G(bodyId), 'focus');
41
- } else {
42
- domUtils.removeClasses(tabs[i], 'focus');
43
- domUtils.removeClasses($G(bodyId), 'focus');
44
- }
45
- }
46
- switch (id) {
47
- case 'upload':
48
- uploadFile = uploadFile || new UploadFile('queueList');
49
- break;
50
- case 'online':
51
- onlineFile = onlineFile || new OnlineFile('fileList');
52
- break;
53
- }
54
- }
55
-
56
- /* 初始化onok事件 */
57
- function initButtons() {
58
-
59
- dialog.onok = function () {
60
- var list = [], id, tabs = $G('tabhead').children;
61
- for (var i = 0; i < tabs.length; i++) {
62
- if (domUtils.hasClass(tabs[i], 'focus')) {
63
- id = tabs[i].getAttribute('data-content-id');
64
- break;
65
- }
66
- }
67
-
68
- switch (id) {
69
- case 'upload':
70
- list = uploadFile.getInsertList();
71
- var count = uploadFile.getQueueCount();
72
- if (count) {
73
- $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
74
- return false;
75
- }
76
- break;
77
- case 'online':
78
- list = onlineFile.getInsertList();
79
- break;
80
- }
81
-
82
- editor.execCommand('insertfile', list);
83
- };
84
- }
85
-
86
-
87
- /* 上传附件 */
88
- function UploadFile(target) {
89
- this.$wrap = target.constructor == String ? $('#' + target) : $(target);
90
- this.init();
91
- }
92
-
93
- UploadFile.prototype = {
94
- init: function () {
95
- this.fileList = [];
96
- this.initContainer();
97
- this.initUploader();
98
- },
99
- initContainer: function () {
100
- this.$queue = this.$wrap.find('.filelist');
101
- },
102
- /* 初始化容器 */
103
- initUploader: function () {
104
- var _this = this,
105
- $ = jQuery, // just in case. Make sure it's not an other libaray.
106
- $wrap = _this.$wrap,
107
- // 图片容器
108
- $queue = $wrap.find('.filelist'),
109
- // 状态栏,包括进度和控制按钮
110
- $statusBar = $wrap.find('.statusBar'),
111
- // 文件总体选择信息。
112
- $info = $statusBar.find('.info'),
113
- // 上传按钮
114
- $upload = $wrap.find('.uploadBtn'),
115
- // 上传按钮
116
- $filePickerBtn = $wrap.find('.filePickerBtn'),
117
- // 上传按钮
118
- $filePickerBlock = $wrap.find('.filePickerBlock'),
119
- // 没选择文件之前的内容。
120
- $placeHolder = $wrap.find('.placeholder'),
121
- // 总体进度条
122
- $progress = $statusBar.find('.progress').hide(),
123
- // 添加的文件数量
124
- fileCount = 0,
125
- // 添加的文件总大小
126
- fileSize = 0,
127
- // 优化retina, 在retina下这个值是2
128
- ratio = window.devicePixelRatio || 1,
129
- // 缩略图大小
130
- thumbnailWidth = 113 * ratio,
131
- thumbnailHeight = 113 * ratio,
132
- // 可能有pedding, ready, uploading, confirm, done.
133
- state = '',
134
- // 所有文件的进度信息,key为file id
135
- percentages = {},
136
- supportTransition = (function () {
137
- var s = document.createElement('p').style,
138
- r = 'transition' in s ||
139
- 'WebkitTransition' in s ||
140
- 'MozTransition' in s ||
141
- 'msTransition' in s ||
142
- 'OTransition' in s;
143
- s = null;
144
- return r;
145
- })(),
146
- // WebUploader实例
147
- uploader,
148
- actionUrl = editor.getActionUrl(editor.getOpt('fileActionName')),
149
- fileMaxSize = editor.getOpt('fileMaxSize'),
150
- acceptExtensions = (editor.getOpt('fileAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');
151
- // 隐藏上传按钮
152
- $upload.hide();
153
-
154
- if (!WebUploader.Uploader.support()) {
155
- $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
156
- return;
157
- } else if (!editor.getOpt('fileActionName')) {
158
- // $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
159
- // return;
160
- }
161
-
162
- uploader = _this.uploader = WebUploader.create({
163
- pick: {
164
- id: '#filePickerReady',
165
- label: lang.uploadSelectFile
166
- },
167
- swf: '../../third-party/webuploader/Uploader.swf',
168
- server: actionUrl,
169
- fileVal: editor.getOpt('fileFieldName'),
170
- duplicate: true,
171
- fileSingleSizeLimit: fileMaxSize,
172
- headers: editor.getOpt('serverHeaders') || {},
173
- compress: false
174
- });
175
- uploader.addButton({
176
- id: '#filePickerBlock'
177
- });
178
- uploader.addButton({
179
- id: '#filePickerBtn',
180
- label: lang.uploadAddFile
181
- });
182
-
183
- setState('pedding');
184
-
185
- // 当有文件添加进来时执行,负责view的创建
186
- function addFile(file) {
187
- var $li = $('<li id="' + file.id + '">' +
188
- '<p class="title">' + file.name + '</p>' +
189
- '<p class="imgWrap"></p>' +
190
- '<p class="progress"><span></span></p>' +
191
- '</li>'),
192
-
193
- $btns = $('<div class="file-panel">' +
194
- '<span class="cancel">' + lang.uploadDelete + '</span>' +
195
- '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
196
- '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
197
- $prgress = $li.find('p.progress span'),
198
- $wrap = $li.find('p.imgWrap'),
199
- $info = $('<p class="error"></p>').hide().appendTo($li),
200
-
201
- showError = function (code) {
202
- switch (code) {
203
- case 'exceed_size':
204
- text = lang.errorExceedSize;
205
- break;
206
- case 'interrupt':
207
- text = lang.errorInterrupt;
208
- break;
209
- case 'http':
210
- text = lang.errorHttp;
211
- break;
212
- case 'not_allow_type':
213
- text = lang.errorFileType;
214
- break;
215
- default:
216
- text = lang.errorUploadRetry;
217
- break;
218
- }
219
- $info.text(text).show();
220
- };
221
-
222
- if (file.getStatus() === 'invalid') {
223
- showError(file.statusText);
224
- } else {
225
- $wrap.text(lang.uploadPreview);
226
- if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|' + file.ext.toLowerCase() + '|') == -1) {
227
- $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
228
- '<span class="file-title" title="' + file.name + '">' + file.name + '</span>');
229
- } else {
230
- if (browser.ie && browser.version <= 7) {
231
- $wrap.text(lang.uploadNoPreview);
232
- } else {
233
- uploader.makeThumb(file, function (error, src) {
234
- if (error || !src) {
235
- $wrap.text(lang.uploadNoPreview);
236
- } else {
237
- var $img = $('<img src="' + src + '">');
238
- $wrap.empty().append($img);
239
- $img.on('error', function () {
240
- $wrap.text(lang.uploadNoPreview);
241
- });
242
- }
243
- }, thumbnailWidth, thumbnailHeight);
244
- }
245
- }
246
- percentages[file.id] = [file.size, 0];
247
- file.rotation = 0;
248
-
249
- /* 检查文件格式 */
250
- if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
251
- showError('not_allow_type');
252
- uploader.removeFile(file);
253
- }
254
- }
255
-
256
- file.on('statuschange', function (cur, prev) {
257
- if (prev === 'progress') {
258
- $prgress.hide().width(0);
259
- } else if (prev === 'queued') {
260
- $li.off('mouseenter mouseleave');
261
- $btns.remove();
262
- }
263
- // 成功
264
- if (cur === 'error' || cur === 'invalid') {
265
- showError(file.statusText);
266
- percentages[file.id][1] = 1;
267
- } else if (cur === 'interrupt') {
268
- showError('interrupt');
269
- } else if (cur === 'queued') {
270
- percentages[file.id][1] = 0;
271
- } else if (cur === 'progress') {
272
- $info.hide();
273
- $prgress.css('display', 'block');
274
- } else if (cur === 'complete') {
275
- }
276
-
277
- $li.removeClass('state-' + prev).addClass('state-' + cur);
278
- });
279
-
280
- $li.on('mouseenter', function () {
281
- $btns.stop().animate({ height: 30 });
282
- });
283
- $li.on('mouseleave', function () {
284
- $btns.stop().animate({ height: 0 });
285
- });
286
-
287
- $btns.on('click', 'span', function () {
288
- var index = $(this).index(),
289
- deg;
290
-
291
- switch (index) {
292
- case 0:
293
- uploader.removeFile(file);
294
- return;
295
- case 1:
296
- file.rotation += 90;
297
- break;
298
- case 2:
299
- file.rotation -= 90;
300
- break;
301
- }
302
-
303
- if (supportTransition) {
304
- deg = 'rotate(' + file.rotation + 'deg)';
305
- $wrap.css({
306
- '-webkit-transform': deg,
307
- '-mos-transform': deg,
308
- '-o-transform': deg,
309
- 'transform': deg
310
- });
311
- } else {
312
- $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
313
- }
314
-
315
- });
316
-
317
- $li.insertBefore($filePickerBlock);
318
- }
319
-
320
- // 负责view的销毁
321
- function removeFile(file) {
322
- var $li = $('#' + file.id);
323
- delete percentages[file.id];
324
- updateTotalProgress();
325
- $li.off().find('.file-panel').off().end().remove();
326
- }
327
-
328
- function updateTotalProgress() {
329
- var loaded = 0,
330
- total = 0,
331
- spans = $progress.children(),
332
- percent;
333
-
334
- $.each(percentages, function (k, v) {
335
- total += v[0];
336
- loaded += v[0] * v[1];
337
- });
338
-
339
- percent = total ? loaded / total : 0;
340
-
341
- spans.eq(0).text(Math.round(percent * 100) + '%');
342
- spans.eq(1).css('width', Math.round(percent * 100) + '%');
343
- updateStatus();
344
- }
345
-
346
- function setState(val, files) {
347
-
348
- if (val != state) {
349
-
350
- var stats = uploader.getStats();
351
-
352
- $upload.removeClass('state-' + state);
353
- $upload.addClass('state-' + val);
354
-
355
- switch (val) {
356
-
357
- /* 未选择文件 */
358
- case 'pedding':
359
- $queue.addClass('element-invisible');
360
- $statusBar.addClass('element-invisible');
361
- $placeHolder.removeClass('element-invisible');
362
- $progress.hide();
363
- $info.hide();
364
- uploader.refresh();
365
- break;
366
-
367
- /* 可以开始上传 */
368
- case 'ready':
369
- $placeHolder.addClass('element-invisible');
370
- $queue.removeClass('element-invisible');
371
- $statusBar.removeClass('element-invisible');
372
- $progress.hide();
373
- $info.show();
374
- $upload.text(lang.uploadStart);
375
- uploader.refresh();
376
- break;
377
-
378
- /* 上传中 */
379
- case 'uploading':
380
- $progress.show();
381
- $info.hide();
382
- $upload.text(lang.uploadPause);
383
- break;
384
-
385
- /* 暂停上传 */
386
- case 'paused':
387
- $progress.show();
388
- $info.hide();
389
- $upload.text(lang.uploadContinue);
390
- break;
391
-
392
- case 'confirm':
393
- $progress.show();
394
- $info.hide();
395
- $upload.text(lang.uploadStart);
396
-
397
- stats = uploader.getStats();
398
- if (stats.successNum && !stats.uploadFailNum) {
399
- setState('finish');
400
- return;
401
- }
402
- break;
403
-
404
- case 'finish':
405
- $progress.hide();
406
- $info.show();
407
- if (stats.uploadFailNum) {
408
- $upload.text(lang.uploadRetry);
409
- } else {
410
- $upload.text(lang.uploadStart);
411
- }
412
- break;
413
- }
414
-
415
- state = val;
416
- updateStatus();
417
-
418
- }
419
-
420
- if (!_this.getQueueCount()) {
421
- $upload.addClass('disabled')
422
- } else {
423
- $upload.removeClass('disabled')
424
- }
425
-
426
- }
427
-
428
- function updateStatus() {
429
- var text = '', stats;
430
-
431
- if (state === 'ready') {
432
- text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
433
- } else if (state === 'confirm') {
434
- stats = uploader.getStats();
435
- if (stats.uploadFailNum) {
436
- text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
437
- }
438
- } else {
439
- stats = uploader.getStats();
440
- text = lang.updateStatusFinish.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)).replace('_', stats.successNum);
441
-
442
- if (stats.uploadFailNum) {
443
- text += lang.updateStatusError.replace('_', stats.uploadFailNum);
444
- }
445
- }
446
-
447
- $info.html(text);
448
- }
449
-
450
- /**
451
- * 前置校验
452
- */
453
- uploader.on('beforeFileQueued', function (file) {
454
- if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) {
455
- return true;
456
- }
457
- return false;
458
- })
459
-
460
- uploader.on('fileQueued', function (file) {
461
- if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) {
462
- fileCount++;
463
- fileSize += file.size;
464
- }
465
-
466
- if (fileCount === 1) {
467
- $placeHolder.addClass('element-invisible');
468
- $statusBar.show();
469
- }
470
-
471
- addFile(file);
472
- var uploadFunc = editor.getOpt('uploadFunction');
473
- if (typeof uploadFunc === 'function') {
474
- // 开始上传
475
- if (state === 'ready') {
476
- setState('uploading');
477
- } else {
478
- setState('ready');
479
- setState('uploading');
480
- };
481
- file.setStatus('progress');
482
- uploader.trigger('uploadProgress', file, 0);
483
- uploadFunc(file.source.source).then(function (response) {
484
- uploader.trigger('uploadProgress', file, 1);
485
- file.setStatus('complete');
486
- setState('finish');
487
- uploader.trigger('uploadSuccess', file, response);
488
- uploader.trigger('uploadComplete', file);
489
- });
490
- }
491
- });
492
-
493
- uploader.on('fileDequeued', function (file) {
494
- if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) {
495
- fileCount--;
496
- fileSize -= file.size;
497
- }
498
-
499
- removeFile(file);
500
- updateTotalProgress();
501
- });
502
-
503
- uploader.on('filesQueued', function (file) {
504
- if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
505
- setState('ready');
506
- }
507
- updateTotalProgress();
508
- });
509
-
510
- uploader.on('all', function (type, files) {
511
- switch (type) {
512
- case 'uploadFinished':
513
- setState('confirm', files);
514
- break;
515
- case 'startUpload':
516
- /* 添加额外的GET参数 */
517
- var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
518
- url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + 'encode=utf-8&' + params);
519
- uploader.option('server', url);
520
- setState('uploading', files);
521
- break;
522
- case 'stopUpload':
523
- setState('paused', files);
524
- break;
525
- }
526
- });
527
-
528
- uploader.on('uploadBeforeSend', function (file, data, header) {
529
- //这里可以通过data对象添加POST参数
530
- if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
531
- header['X_Requested_With'] = 'XMLHttpRequest';
532
- }
533
- });
534
-
535
- uploader.on('uploadProgress', function (file, percentage) {
536
- var $li = $('#' + file.id),
537
- $percent = $li.find('.progress span');
538
-
539
- $percent.css('width', percentage * 100 + '%');
540
- percentages[file.id][1] = percentage;
541
- updateTotalProgress();
542
- });
543
-
544
- uploader.on('uploadSuccess', function (file, json) {
545
- var $file = $('#' + file.id);
546
- try {
547
- if (json.state == 'SUCCESS') {
548
- _this.fileList.push(json);
549
- $file.append('<span class="success"></span>');
550
- // 触发上传附件事件
551
- editor.fireEvent("uploadsuccess", {
552
- res: json,
553
- type: 'file'
554
- });
555
- } else {
556
- $file.find('.error').text(json.state).show();
557
- }
558
- } catch (e) {
559
- $file.find('.error').text(lang.errorServerUpload).show();
560
- }
561
- });
562
-
563
- uploader.on('uploadError', function (file, code) {
564
- });
565
- uploader.on('error', function (code, file) {
566
- if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
567
- addFile(file);
568
- }
569
- });
570
- uploader.on('uploadComplete', function (file, ret) {
571
- });
572
-
573
- $upload.on('click', function () {
574
- if ($(this).hasClass('disabled')) {
575
- return false;
576
- }
577
-
578
- if (state === 'ready') {
579
- uploader.upload();
580
- } else if (state === 'paused') {
581
- uploader.upload();
582
- } else if (state === 'uploading') {
583
- uploader.stop();
584
- }
585
- });
586
-
587
- $upload.addClass('state-' + state);
588
- updateTotalProgress();
589
- },
590
- getQueueCount: function () {
591
- var file, i, status, readyFile = 0, files = this.uploader.getFiles();
592
- for (i = 0; file = files[i++];) {
593
- status = file.getStatus();
594
- if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
595
- }
596
- return readyFile;
597
- },
598
- getInsertList: function () {
599
- var i, link, data, list = [],
600
- prefix = editor.getOpt('fileUrlPrefix');
601
- for (i = 0; i < this.fileList.length; i++) {
602
- data = this.fileList[i];
603
- link = data.url;
604
- list.push({
605
- title: data.original || link.substr(link.lastIndexOf('/') + 1),
606
- url: prefix + link
607
- });
608
- }
609
- return list;
610
- }
611
- };
612
-
613
-
614
- /* 在线附件 */
615
- function OnlineFile(target) {
616
- this.container = utils.isString(target) ? document.getElementById(target) : target;
617
- this.init();
618
- }
619
-
620
- OnlineFile.prototype = {
621
- init: function () {
622
- this.initContainer();
623
- this.initEvents();
624
- this.initData();
625
- },
626
- /* 初始化容器 */
627
- initContainer: function () {
628
- this.container.innerHTML = '';
629
- this.list = document.createElement('ul');
630
- this.clearFloat = document.createElement('li');
631
-
632
- domUtils.addClass(this.list, 'list');
633
- domUtils.addClass(this.clearFloat, 'clearFloat');
634
-
635
- this.list.appendChild(this.clearFloat);
636
- this.container.appendChild(this.list);
637
- },
638
- /* 初始化滚动事件,滚动到地步自动拉取数据 */
639
- initEvents: function () {
640
- var _this = this;
641
-
642
- /* 滚动拉取图片 */
643
- domUtils.on($G('fileList'), 'scroll', function (e) {
644
- var panel = this;
645
- if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
646
- _this.getFileData();
647
- }
648
- });
649
- /* 选中图片 */
650
- domUtils.on(this.list, 'click', function (e) {
651
- var target = e.target || e.srcElement,
652
- li = target.parentNode;
653
-
654
- if (li.tagName.toLowerCase() == 'li') {
655
- if (domUtils.hasClass(li, 'selected')) {
656
- domUtils.removeClasses(li, 'selected');
657
- } else {
658
- domUtils.addClass(li, 'selected');
659
- }
660
- }
661
- });
662
- },
663
- /* 初始化第一次的数据 */
664
- initData: function () {
665
-
666
- /* 拉取数据需要使用的值 */
667
- this.state = 0;
668
- this.listSize = editor.getOpt('fileManagerListSize');
669
- this.listIndex = 0;
670
- this.listEnd = false;
671
-
672
- /* 第一次拉取数据 */
673
- this.getFileData();
674
- },
675
- /* 向后台拉取图片列表数据 */
676
- getFileData: function () {
677
- var _this = this;
678
-
679
- if (!_this.listEnd && !this.isLoadingData) {
680
- this.isLoadingData = true;
681
- ajax.request(editor.getActionUrl(editor.getOpt('fileManagerActionName')), {
682
- timeout: 100000,
683
- data: utils.extend({
684
- start: this.listIndex,
685
- size: this.listSize
686
- }, editor.queryCommandValue('serverparam')),
687
- headers: editor.options.serverHeaders || {},
688
- method: 'get',
689
- onsuccess: function (r) {
690
- try {
691
- var json = eval('(' + r.responseText + ')');
692
- if (json.state == 'SUCCESS') {
693
- _this.pushData(json.list);
694
- _this.listIndex = parseInt(json.start) + parseInt(json.list.length);
695
- if (_this.listIndex >= json.total) {
696
- _this.listEnd = true;
697
- }
698
- _this.isLoadingData = false;
699
- }
700
- } catch (e) {
701
- if (r.responseText.indexOf('ue_separate_ue') != -1) {
702
- var list = r.responseText.split(r.responseText);
703
- _this.pushData(list);
704
- _this.listIndex = parseInt(list.length);
705
- _this.listEnd = true;
706
- _this.isLoadingData = false;
707
- }
708
- }
709
- },
710
- onerror: function () {
711
- _this.isLoadingData = false;
712
- }
713
- });
714
- }
715
- },
716
- /* 添加图片到列表界面上 */
717
- pushData: function (list) {
718
- var i, item, img, filetype, preview, icon, _this = this,
719
- urlPrefix = editor.getOpt('fileManagerUrlPrefix');
720
- for (i = 0; i < list.length; i++) {
721
- if (list[i] && list[i].url) {
722
- item = document.createElement('li');
723
- icon = document.createElement('span');
724
- filetype = list[i].url.substr(list[i].url.lastIndexOf('.') + 1);
725
-
726
- if ("png|jpg|jpeg|gif|bmp".indexOf(filetype) != -1) {
727
- preview = document.createElement('img');
728
- domUtils.on(preview, 'load', (function (image) {
729
- return function () {
730
- _this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight);
731
- };
732
- })(preview));
733
- preview.width = 113;
734
- preview.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=' : '&noCache=') + (+new Date()).toString(36));
735
- } else {
736
- var ic = document.createElement('i'),
737
- textSpan = document.createElement('span');
738
- textSpan.innerHTML = list[i].original || list[i].url.substr(list[i].url.lastIndexOf('/') + 1);
739
- preview = document.createElement('div');
740
- preview.appendChild(ic);
741
- preview.appendChild(textSpan);
742
- domUtils.addClass(preview, 'file-wrapper');
743
- domUtils.addClass(textSpan, 'file-title');
744
- domUtils.addClass(ic, 'file-type-' + filetype);
745
- domUtils.addClass(ic, 'file-preview');
746
- }
747
- domUtils.addClass(icon, 'icon');
748
- item.setAttribute('data-url', urlPrefix + list[i].url);
749
- if (list[i].original) {
750
- item.setAttribute('data-title', list[i].original);
751
- }
752
-
753
- item.appendChild(preview);
754
- item.appendChild(icon);
755
- this.list.insertBefore(item, this.clearFloat);
756
- }
757
- }
758
- },
759
- /* 改变图片大小 */
760
- scale: function (img, w, h, type) {
761
- var ow = img.width,
762
- oh = img.height;
763
-
764
- if (type == 'justify') {
765
- if (ow >= oh) {
766
- img.width = w;
767
- img.height = h * oh / ow;
768
- img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
769
- } else {
770
- img.width = w * ow / oh;
771
- img.height = h;
772
- img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
773
- }
774
- } else {
775
- if (ow >= oh) {
776
- img.width = w * ow / oh;
777
- img.height = h;
778
- img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
779
- } else {
780
- img.width = w;
781
- img.height = h * oh / ow;
782
- img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
783
- }
784
- }
785
- },
786
- getInsertList: function () {
787
- var i, lis = this.list.children, list = [];
788
- for (i = 0; i < lis.length; i++) {
789
- if (domUtils.hasClass(lis[i], 'selected')) {
790
- var url = lis[i].getAttribute('data-url');
791
- var title = lis[i].getAttribute('data-title') || url.substr(url.lastIndexOf('/') + 1);
792
- list.push({
793
- title: title,
794
- url: url
795
- });
796
- }
797
- }
798
- return list;
799
- }
800
- };
801
-
802
-
803
- })();
1
+ /*! UEditorPlus v2.0.0*/
2
+ !function(){function initTabs(){$G("tabhead").querySelector('[data-content-id="online"]').style.display="none";for(var a=$G("tabhead").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(a){var b=a.target||a.srcElement;setTabFocus(b.getAttribute("data-content-id"))});setTabFocus("upload")}function setTabFocus(a){if(a){var b,c,d=$G("tabhead").children;for(b=0;b<d.length;b++)c=d[b].getAttribute("data-content-id"),c==a?(domUtils.addClass(d[b],"focus"),domUtils.addClass($G(c),"focus")):(domUtils.removeClasses(d[b],"focus"),domUtils.removeClasses($G(c),"focus"));switch(a){case"upload":uploadFile=uploadFile||new UploadFile("queueList");break;case"online":onlineFile=onlineFile||new OnlineFile("fileList")}}}function initButtons(){dialog.onok=function(){for(var a,b=[],c=$G("tabhead").children,d=0;d<c.length;d++)if(domUtils.hasClass(c[d],"focus")){a=c[d].getAttribute("data-content-id");break}switch(a){case"upload":b=uploadFile.getInsertList();var e=uploadFile.getQueueCount();if(e)return $(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,e)+"</span>"),!1;break;case"online":b=onlineFile.getInsertList()}editor.execCommand("insertfile",b)}}function UploadFile(a){this.$wrap=a.constructor==String?$("#"+a):$(a),this.init()}function OnlineFile(a){this.container=utils.isString(a)?document.getElementById(a):a,this.init()}var uploadFile,onlineFile;window.onload=function(){initTabs(),initButtons()},UploadFile.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function a(a){var b=h('<li id="'+a.id+'"><p class="title">'+a.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),c=h('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo(b),d=b.find("p.progress span"),e=b.find("p.imgWrap"),g=h('<p class="error"></p>').hide().appendTo(b),i=function(a){switch(a){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}g.text(text).show()};"invalid"===a.getStatus()?i(a.statusText):(e.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+a.ext.toLowerCase()+"|")==-1?e.empty().addClass("notimage").append('<i class="file-preview file-type-'+a.ext.toLowerCase()+'"></i><span class="file-title" title="'+a.name+'">'+a.name+"</span>"):browser.ie&&browser.version<=7?e.text(lang.uploadNoPreview):f.makeThumb(a,function(a,b){if(a||!b)e.text(lang.uploadNoPreview);else{var c=h('<img src="'+b+'">');e.empty().append(c),c.on("error",function(){e.text(lang.uploadNoPreview)})}},t,u),w[a.id]=[a.size,0],a.rotation=0,a.ext&&A.indexOf(a.ext.toLowerCase())!=-1||(i("not_allow_type"),f.removeFile(a))),a.on("statuschange",function(e,f){"progress"===f?d.hide().width(0):"queued"===f&&(b.off("mouseenter mouseleave"),c.remove()),"error"===e||"invalid"===e?(i(a.statusText),w[a.id][1]=1):"interrupt"===e?i("interrupt"):"queued"===e?w[a.id][1]=0:"progress"===e&&(g.hide(),d.css("display","block")),b.removeClass("state-"+f).addClass("state-"+e)}),b.on("mouseenter",function(){c.stop().animate({height:30})}),b.on("mouseleave",function(){c.stop().animate({height:0})}),c.on("click","span",function(){var b,c=h(this).index();switch(c){case 0:return void f.removeFile(a);case 1:a.rotation+=90;break;case 2:a.rotation-=90}x?(b="rotate("+a.rotation+"deg)",e.css({"-webkit-transform":b,"-mos-transform":b,"-o-transform":b,transform:b})):e.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(a.rotation/90%4+4)%4+")")}),b.insertBefore(n)}function b(a){var b=h("#"+a.id);delete w[a.id],c(),b.off().find(".file-panel").off().end().remove()}function c(){var a,b=0,c=0,d=p.children();h.each(w,function(a,d){c+=d[0],b+=d[0]*d[1]}),a=c?b/c:0,d.eq(0).text(Math.round(100*a)+"%"),d.eq(1).css("width",Math.round(100*a)+"%"),e()}function d(a,b){if(a!=v){var c=f.getStats();switch(m.removeClass("state-"+v),m.addClass("state-"+a),a){case"pedding":j.addClass("element-invisible"),k.addClass("element-invisible"),o.removeClass("element-invisible"),p.hide(),l.hide(),f.refresh();break;case"ready":o.addClass("element-invisible"),j.removeClass("element-invisible"),k.removeClass("element-invisible"),p.hide(),l.show(),m.text(lang.uploadStart),f.refresh();break;case"uploading":p.show(),l.hide(),m.text(lang.uploadPause);break;case"paused":p.show(),l.hide(),m.text(lang.uploadContinue);break;case"confirm":if(p.show(),l.hide(),m.text(lang.uploadStart),c=f.getStats(),c.successNum&&!c.uploadFailNum)return void d("finish");break;case"finish":p.hide(),l.show(),c.uploadFailNum?m.text(lang.uploadRetry):m.text(lang.uploadStart)}v=a,e()}g.getQueueCount()?m.removeClass("disabled"):m.addClass("disabled")}function e(){var a,b="";"ready"===v?b=lang.updateStatusReady.replace("_",q).replace("_KB",WebUploader.formatSize(r)):"confirm"===v?(a=f.getStats(),a.uploadFailNum&&(b=lang.updateStatusConfirm.replace("_",a.successNum).replace("_",a.successNum))):(a=f.getStats(),b=lang.updateStatusFinish.replace("_",q).replace("_KB",WebUploader.formatSize(r)).replace("_",a.successNum),a.uploadFailNum&&(b+=lang.updateStatusError.replace("_",a.uploadFailNum))),l.html(b)}var f,g=this,h=jQuery,i=g.$wrap,j=i.find(".filelist"),k=i.find(".statusBar"),l=k.find(".info"),m=i.find(".uploadBtn"),n=(i.find(".filePickerBtn"),i.find(".filePickerBlock")),o=i.find(".placeholder"),p=k.find(".progress").hide(),q=0,r=0,s=window.devicePixelRatio||1,t=113*s,u=113*s,v="",w={},x=function(){var a=document.createElement("p").style,b="transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"OTransition"in a;return a=null,b}(),y=editor.getActionUrl(editor.getOpt("fileActionName")),z=editor.getOpt("fileMaxSize"),A=(editor.getOpt("fileAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return m.hide(),WebUploader.Uploader.support()?(!editor.getOpt("fileActionName"),f=g.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:y,fileVal:editor.getOpt("fileFieldName"),duplicate:!0,fileSingleSizeLimit:z,headers:editor.getOpt("serverHeaders")||{},compress:!1}),f.addButton({id:"#filePickerBlock"}),f.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),d("pedding"),f.on("beforeFileQueued",function(a){return!!(a.ext&&A.indexOf(a.ext.toLowerCase())!=-1&&a.size<=z)}),f.on("fileQueued",function(b){b.ext&&A.indexOf(b.ext.toLowerCase())!=-1&&b.size<=z&&(q++,r+=b.size),1===q&&(o.addClass("element-invisible"),k.show()),a(b);var c=editor.getOpt("uploadFunction");"function"==typeof c&&("ready"===v?d("uploading"):(d("ready"),d("uploading")),b.setStatus("progress"),f.trigger("uploadProgress",b,0),c(b.source.source).then(function(a){f.trigger("uploadProgress",b,1),b.setStatus("complete"),d("finish"),f.trigger("uploadSuccess",b,a),f.trigger("uploadComplete",b)}))}),f.on("fileDequeued",function(a){a.ext&&A.indexOf(a.ext.toLowerCase())!=-1&&a.size<=z&&(q--,r-=a.size),b(a),c()}),f.on("filesQueued",function(a){f.isInProgress()||"pedding"!=v&&"finish"!=v&&"confirm"!=v&&"ready"!=v||d("ready"),c()}),f.on("all",function(a,b){switch(a){case"uploadFinished":d("confirm",b);break;case"startUpload":var c=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",e=utils.formatUrl(y+(y.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+c);f.option("server",e),d("uploading",b);break;case"stopUpload":d("paused",b)}}),f.on("uploadBeforeSend",function(a,b,c){y.toLowerCase().indexOf("jsp")!=-1&&(c.X_Requested_With="XMLHttpRequest")}),f.on("uploadProgress",function(a,b){var d=h("#"+a.id),e=d.find(".progress span");e.css("width",100*b+"%"),w[a.id][1]=b,c()}),f.on("uploadSuccess",function(a,b){var c=h("#"+a.id);try{"SUCCESS"==b.state?(g.fileList.push(b),c.append('<span class="success"></span>'),editor.fireEvent("uploadsuccess",{res:b,type:"file"})):c.find(".error").text(b.state).show()}catch(d){c.find(".error").text(lang.errorServerUpload).show()}}),f.on("uploadError",function(a,b){}),f.on("error",function(b,c){"Q_TYPE_DENIED"!=b&&"F_EXCEED_SIZE"!=b||a(c)}),f.on("uploadComplete",function(a,b){}),m.on("click",function(){return!h(this).hasClass("disabled")&&void("ready"===v?f.upload():"paused"===v?f.upload():"uploading"===v&&f.stop())}),m.addClass("state-"+v),void c()):void h("#filePickerReady").after(h("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var a,b,c,d=0,e=this.uploader.getFiles();for(b=0;a=e[b++];)c=a.getStatus(),"queued"!=c&&"uploading"!=c&&"progress"!=c||d++;return d},getInsertList:function(){var a,b,c,d=[],e=editor.getOpt("fileUrlPrefix");for(a=0;a<this.fileList.length;a++)c=this.fileList[a],b=c.url,d.push({title:c.original||b.substr(b.lastIndexOf("/")+1),url:e+b});return d}},OnlineFile.prototype={init:function(){this.initContainer(),this.initEvents(),this.initData()},initContainer:function(){this.container.innerHTML="",this.list=document.createElement("ul"),this.clearFloat=document.createElement("li"),domUtils.addClass(this.list,"list"),domUtils.addClass(this.clearFloat,"clearFloat"),this.list.appendChild(this.clearFloat),this.container.appendChild(this.list)},initEvents:function(){var a=this;domUtils.on($G("fileList"),"scroll",function(b){var c=this;c.scrollHeight-(c.offsetHeight+c.scrollTop)<10&&a.getFileData()}),domUtils.on(this.list,"click",function(a){var b=a.target||a.srcElement,c=b.parentNode;"li"==c.tagName.toLowerCase()&&(domUtils.hasClass(c,"selected")?domUtils.removeClasses(c,"selected"):domUtils.addClass(c,"selected"))})},initData:function(){this.state=0,this.listSize=editor.getOpt("fileManagerListSize"),this.listIndex=0,this.listEnd=!1,this.getFileData()},getFileData:function(){var _this=this;_this.listEnd||this.isLoadingData||(this.isLoadingData=!0,ajax.request(editor.getActionUrl(editor.getOpt("fileManagerActionName")),{timeout:1e5,data:utils.extend({start:this.listIndex,size:this.listSize},editor.queryCommandValue("serverparam")),headers:editor.options.serverHeaders||{},method:"get",onsuccess:function(r){try{var json=eval("("+r.responseText+")");"SUCCESS"==json.state&&(_this.pushData(json.list),_this.listIndex=parseInt(json.start)+parseInt(json.list.length),_this.listIndex>=json.total&&(_this.listEnd=!0),_this.isLoadingData=!1)}catch(e){if(r.responseText.indexOf("ue_separate_ue")!=-1){var list=r.responseText.split(r.responseText);_this.pushData(list),_this.listIndex=parseInt(list.length),_this.listEnd=!0,_this.isLoadingData=!1}}},onerror:function(){_this.isLoadingData=!1}}))},pushData:function(a){var b,c,d,e,f,g=this,h=editor.getOpt("fileManagerUrlPrefix");for(b=0;b<a.length;b++)if(a[b]&&a[b].url){if(c=document.createElement("li"),f=document.createElement("span"),d=a[b].url.substr(a[b].url.lastIndexOf(".")+1),"png|jpg|jpeg|gif|bmp".indexOf(d)!=-1)e=document.createElement("img"),domUtils.on(e,"load",function(a){return function(){g.scale(a,a.parentNode.offsetWidth,a.parentNode.offsetHeight)}}(e)),e.width=113,e.setAttribute("src",h+a[b].url+(a[b].url.indexOf("?")==-1?"?noCache=":"&noCache=")+(+new Date).toString(36));else{var i=document.createElement("i"),j=document.createElement("span");j.innerHTML=a[b].original||a[b].url.substr(a[b].url.lastIndexOf("/")+1),e=document.createElement("div"),e.appendChild(i),e.appendChild(j),domUtils.addClass(e,"file-wrapper"),domUtils.addClass(j,"file-title"),domUtils.addClass(i,"file-type-"+d),domUtils.addClass(i,"file-preview")}domUtils.addClass(f,"icon"),c.setAttribute("data-url",h+a[b].url),a[b].original&&c.setAttribute("data-title",a[b].original),c.appendChild(e),c.appendChild(f),this.list.insertBefore(c,this.clearFloat)}},scale:function(a,b,c,d){var e=a.width,f=a.height;"justify"==d?e>=f?(a.width=b,a.height=c*f/e,a.style.marginLeft="-"+parseInt((a.width-b)/2)+"px"):(a.width=b*e/f,a.height=c,a.style.marginTop="-"+parseInt((a.height-c)/2)+"px"):e>=f?(a.width=b*e/f,a.height=c,a.style.marginLeft="-"+parseInt((a.width-b)/2)+"px"):(a.width=b,a.height=c*f/e,a.style.marginTop="-"+parseInt((a.height-c)/2)+"px")},getInsertList:function(){var a,b=this.list.children,c=[];for(a=0;a<b.length;a++)if(domUtils.hasClass(b[a],"selected")){var d=b[a].getAttribute("data-url"),e=b[a].getAttribute("data-title")||d.substr(d.lastIndexOf("/")+1);c.push({title:e,url:d})}return c}}}();