@lingxiteam/lcdp-ueditor-react 1.0.2 → 1.0.3-alpha.10

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 (82) hide show
  1. package/es/LcdpUeditor.d.ts +4 -0
  2. package/es/LcdpUeditor.js +45 -8
  3. package/es/tools/UeditorResourceLoader.d.ts +1 -1
  4. package/es/tools/UeditorResourceLoader.js +18 -7
  5. package/es/tools/filterHtmlNode.js +7 -2
  6. package/lib/LcdpUeditor.d.ts +4 -0
  7. package/lib/LcdpUeditor.js +35 -10
  8. package/lib/tools/UeditorResourceLoader.d.ts +1 -1
  9. package/lib/tools/UeditorResourceLoader.js +15 -7
  10. package/lib/tools/filterHtmlNode.js +8 -4
  11. package/package.json +1 -1
  12. package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
  13. package/ueditor-resource/dialogs/attachment/attachment.css +2 -715
  14. package/ueditor-resource/dialogs/attachment/attachment.html +6 -6
  15. package/ueditor-resource/dialogs/attachment/attachment.js +2 -803
  16. package/ueditor-resource/dialogs/audio/audio.css +2 -878
  17. package/ueditor-resource/dialogs/audio/audio.js +2 -815
  18. package/ueditor-resource/dialogs/background/background.css +2 -192
  19. package/ueditor-resource/dialogs/background/background.html +3 -3
  20. package/ueditor-resource/dialogs/background/background.js +2 -370
  21. package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
  22. package/ueditor-resource/dialogs/contentimport/contentimport.js +2 -91
  23. package/ueditor-resource/dialogs/emotion/emotion.css +2 -128
  24. package/ueditor-resource/dialogs/emotion/emotion.html +3 -3
  25. package/ueditor-resource/dialogs/emotion/emotion.js +2 -186
  26. package/ueditor-resource/dialogs/formula/formula.html +4 -4
  27. package/ueditor-resource/dialogs/formula/formula.js +2 -147
  28. package/ueditor-resource/dialogs/help/help.css +2 -36
  29. package/ueditor-resource/dialogs/help/help.html +3 -3
  30. package/ueditor-resource/dialogs/help/help.js +2 -57
  31. package/ueditor-resource/dialogs/image/image.css +2 -767
  32. package/ueditor-resource/dialogs/image/image.js +2 -1060
  33. package/ueditor-resource/dialogs/insertframe/insertframe.html +2 -2
  34. package/ueditor-resource/dialogs/internal.js +2 -81
  35. package/ueditor-resource/dialogs/preview/preview.html +2 -2
  36. package/ueditor-resource/dialogs/scrawl/scrawl.css +2 -323
  37. package/ueditor-resource/dialogs/scrawl/scrawl.html +3 -3
  38. package/ueditor-resource/dialogs/scrawl/scrawl.js +2 -682
  39. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
  40. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +2 -174
  41. package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
  42. package/ueditor-resource/dialogs/spechars/spechars.js +2 -86
  43. package/ueditor-resource/dialogs/table/edittable.css +2 -84
  44. package/ueditor-resource/dialogs/table/edittable.html +3 -3
  45. package/ueditor-resource/dialogs/table/edittable.js +2 -241
  46. package/ueditor-resource/dialogs/table/edittd.html +1 -1
  47. package/ueditor-resource/dialogs/table/edittip.html +1 -1
  48. package/ueditor-resource/dialogs/template/config.js +2 -42
  49. package/ueditor-resource/dialogs/template/template.css +2 -98
  50. package/ueditor-resource/dialogs/template/template.html +4 -4
  51. package/ueditor-resource/dialogs/template/template.js +2 -53
  52. package/ueditor-resource/dialogs/video/video.css +2 -908
  53. package/ueditor-resource/dialogs/video/video.js +2 -867
  54. package/ueditor-resource/dialogs/wordimage/wordimage.html +5 -5
  55. package/ueditor-resource/dialogs/wordimage/wordimage.js +2 -93
  56. package/ueditor-resource/lang/en/en.js +2 -686
  57. package/ueditor-resource/lang/zh-cn/zh-cn.js +2 -748
  58. package/ueditor-resource/lang/zh-tw/zh-tw.js +2 -748
  59. package/ueditor-resource/plugins/browser-image-compression.js +9 -0
  60. package/ueditor-resource/themes/default/css/ueditor.css +2 -2148
  61. package/ueditor-resource/themes/default/dialog.css +2 -16
  62. package/ueditor-resource/themes/default/dialogbase.css +2 -131
  63. package/ueditor-resource/themes/iframe.css +2 -62
  64. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +4 -3655
  65. package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +3 -1
  66. package/ueditor-resource/third-party/clipboard/clipboard.js +2 -753
  67. package/ueditor-resource/third-party/codemirror/codemirror.css +2 -105
  68. package/ueditor-resource/third-party/codemirror/codemirror.js +4 -3581
  69. package/ueditor-resource/third-party/jquery-3.5.1.js +4 -2
  70. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4 -4314
  71. package/ueditor-resource/third-party/webuploader/webuploader.css +2 -87
  72. package/ueditor-resource/third-party/webuploader/webuploader.js +5 -4
  73. package/ueditor-resource/ueditor.all.js +23 -32644
  74. package/ueditor-resource/ueditor.config.js +2 -655
  75. package/ueditor-resource/ueditor.parse.js +2 -639
  76. package/es/LcdpUeditor.d.ts.map +0 -1
  77. package/es/const.d.ts.map +0 -1
  78. package/es/index.d.ts.map +0 -1
  79. package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
  80. package/es/tools/filterHtmlNode.d.ts.map +0 -1
  81. package/es/tools/loadScript.d.ts.map +0 -1
  82. package/es/type.d.ts.map +0 -1
@@ -1,867 +1,2 @@
1
- /**
2
- * Created by JetBrains PhpStorm.
3
- * User: taoqili
4
- * Date: 12-2-20
5
- * Time: 上午11:19
6
- * To change this template use File | Settings | File Templates.
7
- */
8
-
9
- (function () {
10
-
11
- var video = {},
12
- uploadVideoList = [],
13
- isModifyUploadVideo = false,
14
- uploadFile;
15
- var editorOpt = {};
16
-
17
- window.onload = function () {
18
- editorOpt = editor.getOpt('videoConfig');
19
- $focus($G("videoUrl"));
20
- initTabs();
21
- initVideo();
22
- initUpload();
23
- };
24
-
25
- /* 初始化tab标签 */
26
- function initTabs() {
27
- var tabs = $G('tabHeads').children;
28
- for (var i = 0; i < tabs.length; i++) {
29
- domUtils.on(tabs[i], "click", function (e) {
30
- var j, bodyId, target = e.target || e.srcElement;
31
- for (j = 0; j < tabs.length; j++) {
32
- bodyId = tabs[j].getAttribute('data-content-id');
33
- if (tabs[j] == target) {
34
- domUtils.addClass(tabs[j], 'focus');
35
- domUtils.addClass($G(bodyId), 'focus');
36
- } else {
37
- domUtils.removeClasses(tabs[j], 'focus');
38
- domUtils.removeClasses($G(bodyId), 'focus');
39
- }
40
- }
41
- });
42
- }
43
- if (!editorOpt.disableUpload) {
44
- $G('tabHeads').querySelector('[data-content-id="upload"]').style.display = 'inline-block';
45
- }
46
- if (!!editorOpt.selectCallback) {
47
- $G('videoSelect').style.display = 'inline-block';
48
- domUtils.on($G('videoSelect'), "click", function (e) {
49
- editorOpt.selectCallback(editor, function (info) {
50
- if (info) {
51
- $G('videoUrl').value = info.path;
52
- createPreviewVideo(info.path);
53
- }
54
- });
55
- });
56
- }
57
- }
58
-
59
- function initVideo() {
60
- createAlignButton(["videoFloat", "upload_alignment"]);
61
- addUrlChangeListener($G("videoUrl"));
62
- addOkListener();
63
-
64
- //编辑视频时初始化相关信息
65
- (function () {
66
- var img = editor.selection.getRange().getClosedNode(), url;
67
- if (img && img.className) {
68
- var hasFakedClass = (img.className == "edui-faked-video"),
69
- hasUploadClass = img.className.indexOf("edui-upload-video") != -1;
70
- if (hasFakedClass || hasUploadClass) {
71
- $G("videoUrl").value = url = img.getAttribute("_url");
72
- $G("videoWidth").value = img.width;
73
- $G("videoHeight").value = img.height;
74
- var align = domUtils.getComputedStyle(img, "float"),
75
- parentAlign = domUtils.getComputedStyle(img.parentNode, "text-align");
76
- updateAlignButton(parentAlign === "center" ? "center" : align);
77
- }
78
- if (hasUploadClass) {
79
- isModifyUploadVideo = true;
80
- }
81
- }
82
- createPreviewVideo(url);
83
- })();
84
- }
85
-
86
- /**
87
- * 监听确认和取消两个按钮事件,用户执行插入或者清空正在播放的视频实例操作
88
- */
89
- function addOkListener() {
90
- dialog.onok = function () {
91
- $G("preview").innerHTML = "";
92
- var currentTab = findFocus("tabHeads", "tabSrc");
93
- switch (currentTab) {
94
- case "video":
95
- return insertSingle();
96
- case "videoSearch":
97
- return insertSearch("searchList");
98
- case "upload":
99
- return insertUpload();
100
- }
101
- };
102
- dialog.oncancel = function () {
103
- $G("preview").innerHTML = "";
104
- };
105
- }
106
-
107
- /**
108
- * 依据传入的align值更新按钮信息
109
- * @param align
110
- */
111
- function updateAlignButton(align) {
112
- var aligns = $G("videoFloat").children;
113
- for (var i = 0, ci; ci = aligns[i++];) {
114
- if (ci.getAttribute("name") == align) {
115
- if (ci.className != "focus") {
116
- ci.className = "focus";
117
- }
118
- } else {
119
- if (ci.className == "focus") {
120
- ci.className = "";
121
- }
122
- }
123
- }
124
- }
125
-
126
- /**
127
- * 将单个视频信息插入编辑器中
128
- */
129
- function insertSingle() {
130
- var width = $G("videoWidth"),
131
- height = $G("videoHeight"),
132
- url = $G('videoUrl').value,
133
- align = findFocus("videoFloat", "name");
134
- if (!url) return false;
135
- if (!checkNum([width, height])) return false;
136
- editor.execCommand('insertvideo', {
137
- url: convert_url(url),
138
- width: width.value,
139
- height: height.value,
140
- align: align
141
- }, isModifyUploadVideo ? 'upload' : null);
142
- }
143
-
144
- /**
145
- * 将元素id下的所有代表视频的图片插入编辑器中
146
- * @param id
147
- */
148
- function insertSearch(id) {
149
- var imgs = domUtils.getElementsByTagName($G(id), "img"),
150
- videoObjs = [];
151
- for (var i = 0, img; img = imgs[i++];) {
152
- if (img.getAttribute("selected")) {
153
- videoObjs.push({
154
- url: img.getAttribute("ue_video_url"),
155
- width: 420,
156
- height: 280,
157
- align: "none"
158
- });
159
- }
160
- }
161
- editor.execCommand('insertvideo', videoObjs);
162
- }
163
-
164
- /**
165
- * 找到id下具有focus类的节点并返回该节点下的某个属性
166
- * @param id
167
- * @param returnProperty
168
- */
169
- function findFocus(id, returnProperty) {
170
- var tabs = $G(id).children,
171
- property;
172
- for (var i = 0, ci; ci = tabs[i++];) {
173
- if (ci.className == "focus") {
174
- property = ci.getAttribute(returnProperty);
175
- break;
176
- }
177
- }
178
- return property;
179
- }
180
-
181
- function convert_url(url) {
182
- if (!url) return '';
183
- url = utils.trim(url);
184
- // .replace(/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i, 'player.youku.com/embed/$1')
185
- // .replace(/(www\.)?youtube\.com\/watch\?v=([\w\-]+)/i, "www.youtube.com/v/$2")
186
- // .replace(/youtu.be\/(\w+)$/i, "www.youtube.com/v/$1")
187
- //.replace(/www\.iqiyi\.com\/v_(\w+)\.html/i, "www.youtube.com/v/$1")
188
- // .replace(/v\.ku6\.com\/.+\/([\w\.]+)\.html.*$/i, "player.ku6.com/refer/$1/v.swf")
189
- // .replace(/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i, "player.56.com/v_$1.swf")
190
- // .replace(/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i, "player.56.com/v_$1.swf")
191
- // .replace(/v\.pps\.tv\/play_([\w]+)\.html.*$/i, "player.pps.tv/player/sid/$1/v.swf")
192
- // .replace(/www\.letv\.com\/ptv\/vplay\/([\d]+)\.html.*$/i, "i7.imgs.letv.com/player/swfPlayer.swf?id=$1&autoplay=0")
193
- // .replace(/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i, "www.tudou.com/v/$1")
194
- // https://v.qq.com/x/cover/wagzbx91asjomnu/w05337nxfof.html
195
- // https://v.qq.com/iframe/player.html?vid=w05337nxfof&tiny=0&auto=0
196
- // .replace(/v\.qq\.com\/x\/cover\/[\w]+\/([\w]+)\.html/i, "v.qq.com/iframe/player.html?vid=$1&tiny=0&auto=0")
197
- // .replace(/v\.qq\.com\/x\/page\/([\w]+)\.html/i, "v.qq.com/iframe/player.html?vid=$1&tiny=0&auto=0")
198
- // .replace(/www\.bilibili\.com\/video\/([a-zA-Z0-9]+)\/?.*$/i, "player.bilibili.com/player.html?bvid=$1")
199
- // .replace(/v\.qq\.com\/cover\/[\w]+\/[\w]+\/([\w]+)\.html/i, "static.video.qq.com/TPout.swf?vid=$1")
200
- // .replace(/v\.qq\.com\/.+[\?\&]vid=([^&]+).*$/i, "static.video.qq.com/TPout.swf?vid=$1")
201
- // .replace(/my\.tv\.sohu\.com\/[\w]+\/[\d]+\/([\d]+)\.shtml.*$/i, "share.vrs.sohu.com/my/v.swf&id=$1")
202
- ;
203
- return url;
204
- }
205
-
206
- /**
207
- * 检测传入的所有input框中输入的长宽是否是正数
208
- * @param nodes input框集合,
209
- */
210
- function checkNum(nodes) {
211
- for (var i = 0, ci; ci = nodes[i++];) {
212
- var value = ci.value;
213
- if (!isNumber(value) && value) {
214
- alert(lang.numError);
215
- ci.value = "";
216
- ci.focus();
217
- return false;
218
- }
219
- }
220
- return true;
221
- }
222
-
223
- /**
224
- * 数字判断
225
- * @param value
226
- */
227
- function isNumber(value) {
228
- return /(0|^[1-9]\d*$)/.test(value);
229
- }
230
-
231
- /**
232
- * 创建图片浮动选择按钮
233
- * @param ids
234
- */
235
- function createAlignButton(ids) {
236
- for (var i = 0, ci; ci = ids[i++];) {
237
- var floatContainer = $G(ci),
238
- nameMaps = {
239
- "none": lang['default'],
240
- "left": lang.floatLeft,
241
- "right": lang.floatRight,
242
- "center": lang.block
243
- };
244
- for (var j in nameMaps) {
245
- var div = document.createElement("div");
246
- div.setAttribute("name", j);
247
- if (j == "none") {
248
- div.className = "focus"
249
- div.style.cssText = "background-image:url(icon/" + j + "-active.png);";
250
- } else {
251
- div.style.cssText = "background-image:url(icon/" + j + ".png);";
252
- }
253
- div.setAttribute("title", nameMaps[j]);
254
- floatContainer.appendChild(div);
255
- }
256
- switchSelect(ci);
257
- }
258
- }
259
-
260
- /**
261
- * 选择切换
262
- * @param selectParentId
263
- */
264
- function switchSelect(selectParentId) {
265
- var selects = $G(selectParentId).children;
266
- for (var i = 0, ci; ci = selects[i++];) {
267
- domUtils.on(ci, "click", function () {
268
- for (var j = 0, cj; cj = selects[j++];) {
269
- cj.className = "";
270
- cj.style.cssText = "background-image:url(icon/" + cj.getAttribute('name') + ".png);";
271
- cj.removeAttribute && cj.removeAttribute("class");
272
- }
273
- this.className = "focus";
274
- this.style.cssText = "background-image:url(icon/" + this.getAttribute('name') + "-active.png);";
275
- })
276
- }
277
- }
278
-
279
- /**
280
- * 监听url改变事件
281
- * @param url
282
- */
283
- function addUrlChangeListener(url) {
284
- if (browser.ie) {
285
- url.onpropertychange = function () {
286
- createPreviewVideo(this.value);
287
- }
288
- } else {
289
- url.addEventListener("input", function () {
290
- createPreviewVideo(this.value);
291
- }, false);
292
- }
293
- }
294
-
295
- /**
296
- * 根据url生成视频预览
297
- * @param url
298
- */
299
- function createPreviewVideo(url) {
300
- const location = window.parent.location;
301
- const host = location.protocol + '//' + location.host + location.pathname;
302
- if (!url) return;
303
-
304
- var conUrl = convert_url(url);
305
-
306
- conUrl = utils.unhtml(conUrl);
307
-
308
- $G("preview").innerHTML = '<div class="previewMsg"><span>' + lang.urlError + '</span></div>' +
309
- '<iframe class="previewVideo" ' +
310
- ' src="' + encodeURI(host + conUrl) + '"' +
311
- ' width="' + 420 + '"' +
312
- ' height="' + 280 + '"' +
313
- ' frameborder=0 allowfullscreen>' +
314
- '</iframe>';
315
- }
316
-
317
-
318
- /* 插入上传视频 */
319
- function insertUpload() {
320
- var videoObjs = [],
321
- uploadDir = editor.getOpt('videoUrlPrefix'),
322
- width = $G('upload_width').value || 420,
323
- height = $G('upload_height').value || 280,
324
- align = findFocus("upload_alignment", "name") || 'none';
325
- for (var key in uploadVideoList) {
326
- var file = uploadVideoList[key];
327
- videoObjs.push({
328
- url: uploadDir + file.url,
329
- width: width,
330
- height: height,
331
- align: align
332
- });
333
- }
334
-
335
- var count = uploadFile.getQueueCount();
336
- if (count) {
337
- $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
338
- return false;
339
- } else {
340
- editor.execCommand('insertvideo', videoObjs, 'upload');
341
- }
342
- }
343
-
344
- /*初始化上传标签*/
345
- function initUpload() {
346
- uploadFile = new UploadFile('queueList');
347
- }
348
-
349
-
350
- /* 上传附件 */
351
- function UploadFile(target) {
352
- this.$wrap = target.constructor == String ? $('#' + target) : $(target);
353
- this.init();
354
- }
355
-
356
- UploadFile.prototype = {
357
- init: function () {
358
- this.fileList = [];
359
- this.initContainer();
360
- this.initUploader();
361
- },
362
- initContainer: function () {
363
- this.$queue = this.$wrap.find('.filelist');
364
- },
365
- /* 初始化容器 */
366
- initUploader: function () {
367
- var _this = this,
368
- $ = jQuery, // just in case. Make sure it's not an other libaray.
369
- $wrap = _this.$wrap,
370
- // 图片容器
371
- $queue = $wrap.find('.filelist'),
372
- // 状态栏,包括进度和控制按钮
373
- $statusBar = $wrap.find('.statusBar'),
374
- // 文件总体选择信息。
375
- $info = $statusBar.find('.info'),
376
- // 上传按钮
377
- $upload = $wrap.find('.uploadBtn'),
378
- // 上传按钮
379
- $filePickerBtn = $wrap.find('.filePickerBtn'),
380
- // 上传按钮
381
- $filePickerBlock = $wrap.find('.filePickerBlock'),
382
- // 没选择文件之前的内容。
383
- $placeHolder = $wrap.find('.placeholder'),
384
- // 总体进度条
385
- $progress = $statusBar.find('.progress').hide(),
386
- // 添加的文件数量
387
- fileCount = 0,
388
- // 添加的文件总大小
389
- fileSize = 0,
390
- // 优化retina, 在retina下这个值是2
391
- ratio = window.devicePixelRatio || 1,
392
- // 缩略图大小
393
- thumbnailWidth = 113 * ratio,
394
- thumbnailHeight = 113 * ratio,
395
- // 可能有pedding, ready, uploading, confirm, done.
396
- state = '',
397
- // 所有文件的进度信息,key为file id
398
- percentages = {},
399
- supportTransition = (function () {
400
- var s = document.createElement('p').style,
401
- r = 'transition' in s ||
402
- 'WebkitTransition' in s ||
403
- 'MozTransition' in s ||
404
- 'msTransition' in s ||
405
- 'OTransition' in s;
406
- s = null;
407
- return r;
408
- })(),
409
- // WebUploader实例
410
- uploader,
411
- actionUrl = editor.getActionUrl(editor.getOpt('videoActionName')),
412
- fileMaxSize = editor.getOpt('videoMaxSize'),
413
- acceptExtensions = (editor.getOpt('videoAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');
414
- // 隐藏上传按钮
415
- $upload.hide();
416
-
417
- if (!WebUploader.Uploader.support()) {
418
- $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
419
- return;
420
- } else if (!editor.getOpt('videoActionName')) {
421
- $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
422
- return;
423
- }
424
-
425
- uploader = _this.uploader = WebUploader.create({
426
- pick: {
427
- id: '#filePickerReady',
428
- label: lang.uploadSelectFile
429
- },
430
- swf: '../../third-party/webuploader/Uploader.swf',
431
- server: actionUrl,
432
- fileVal: editor.getOpt('videoFieldName'),
433
- duplicate: true,
434
- fileSingleSizeLimit: fileMaxSize,
435
- headers: editor.getOpt('serverHeaders') || {},
436
- compress: false
437
- });
438
- uploader.addButton({
439
- id: '#filePickerBlock'
440
- });
441
- uploader.addButton({
442
- id: '#filePickerBtn',
443
- label: lang.uploadAddFile
444
- });
445
-
446
- setState('pedding');
447
-
448
- // 当有文件添加进来时执行,负责view的创建
449
- function addFile(file) {
450
- var $li = $('<li id="' + file.id + '">' +
451
- '<p class="title">' + file.name + '</p>' +
452
- '<p class="imgWrap"></p>' +
453
- '<p class="progress"><span></span></p>' +
454
- '</li>'),
455
-
456
- $btns = $('<div class="file-panel">' +
457
- '<span class="cancel">' + lang.uploadDelete + '</span>' +
458
- '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
459
- '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
460
- $prgress = $li.find('p.progress span'),
461
- $wrap = $li.find('p.imgWrap'),
462
- $info = $('<p class="error"></p>').hide().appendTo($li),
463
-
464
- showError = function (code) {
465
- switch (code) {
466
- case 'exceed_size':
467
- text = lang.errorExceedSize;
468
- break;
469
- case 'interrupt':
470
- text = lang.errorInterrupt;
471
- break;
472
- case 'http':
473
- text = lang.errorHttp;
474
- break;
475
- case 'not_allow_type':
476
- text = lang.errorFileType;
477
- break;
478
- default:
479
- text = lang.errorUploadRetry;
480
- break;
481
- }
482
- $info.text(text).show();
483
- };
484
-
485
- if (file.getStatus() === 'invalid') {
486
- showError(file.statusText);
487
- } else {
488
- $wrap.text(lang.uploadPreview);
489
- if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|' + file.ext.toLowerCase() + '|') == -1) {
490
- $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
491
- '<span class="file-title">' + file.name + '</span>');
492
- } else {
493
- if (browser.ie && browser.version <= 7) {
494
- $wrap.text(lang.uploadNoPreview);
495
- } else {
496
- uploader.makeThumb(file, function (error, src) {
497
- if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
498
- $wrap.text(lang.uploadNoPreview);
499
- } else {
500
- var $img = $('<img src="' + src + '">');
501
- $wrap.empty().append($img);
502
- $img.on('error', function () {
503
- $wrap.text(lang.uploadNoPreview);
504
- });
505
- }
506
- }, thumbnailWidth, thumbnailHeight);
507
- }
508
- }
509
- percentages[file.id] = [file.size, 0];
510
- file.rotation = 0;
511
-
512
- /* 检查文件格式 */
513
- if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
514
- showError('not_allow_type');
515
- uploader.removeFile(file);
516
- }
517
- }
518
-
519
- file.on('statuschange', function (cur, prev) {
520
- if (prev === 'progress') {
521
- $prgress.hide().width(0);
522
- } else if (prev === 'queued') {
523
- $li.off('mouseenter mouseleave');
524
- $btns.remove();
525
- }
526
- // 成功
527
- if (cur === 'error' || cur === 'invalid') {
528
- showError(file.statusText);
529
- percentages[file.id][1] = 1;
530
- } else if (cur === 'interrupt') {
531
- showError('interrupt');
532
- } else if (cur === 'queued') {
533
- percentages[file.id][1] = 0;
534
- } else if (cur === 'progress') {
535
- $info.hide();
536
- $prgress.css('display', 'block');
537
- } else if (cur === 'complete') {
538
- }
539
-
540
- $li.removeClass('state-' + prev).addClass('state-' + cur);
541
- });
542
-
543
- $li.on('mouseenter', function () {
544
- $btns.stop().animate({ height: 30 });
545
- });
546
- $li.on('mouseleave', function () {
547
- $btns.stop().animate({ height: 0 });
548
- });
549
-
550
- $btns.on('click', 'span', function () {
551
- var index = $(this).index(),
552
- deg;
553
-
554
- switch (index) {
555
- case 0:
556
- uploader.removeFile(file);
557
- return;
558
- case 1:
559
- file.rotation += 90;
560
- break;
561
- case 2:
562
- file.rotation -= 90;
563
- break;
564
- }
565
-
566
- if (supportTransition) {
567
- deg = 'rotate(' + file.rotation + 'deg)';
568
- $wrap.css({
569
- '-webkit-transform': deg,
570
- '-mos-transform': deg,
571
- '-o-transform': deg,
572
- 'transform': deg
573
- });
574
- } else {
575
- $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
576
- }
577
-
578
- });
579
-
580
- $li.insertBefore($filePickerBlock);
581
- }
582
-
583
- // 负责view的销毁
584
- function removeFile(file) {
585
- var $li = $('#' + file.id);
586
- delete percentages[file.id];
587
- updateTotalProgress();
588
- $li.off().find('.file-panel').off().end().remove();
589
- }
590
-
591
- function updateTotalProgress() {
592
- var loaded = 0,
593
- total = 0,
594
- spans = $progress.children(),
595
- percent;
596
-
597
- $.each(percentages, function (k, v) {
598
- total += v[0];
599
- loaded += v[0] * v[1];
600
- });
601
-
602
- percent = total ? loaded / total : 0;
603
-
604
- spans.eq(0).text(Math.round(percent * 100) + '%');
605
- spans.eq(1).css('width', Math.round(percent * 100) + '%');
606
- updateStatus();
607
- }
608
-
609
- function setState(val, files) {
610
-
611
- if (val != state) {
612
-
613
- var stats = uploader.getStats();
614
-
615
- $upload.removeClass('state-' + state);
616
- $upload.addClass('state-' + val);
617
-
618
- switch (val) {
619
-
620
- /* 未选择文件 */
621
- case 'pedding':
622
- $queue.addClass('element-invisible');
623
- $statusBar.addClass('element-invisible');
624
- $placeHolder.removeClass('element-invisible');
625
- $progress.hide();
626
- $info.hide();
627
- uploader.refresh();
628
- break;
629
-
630
- /* 可以开始上传 */
631
- case 'ready':
632
- $placeHolder.addClass('element-invisible');
633
- $queue.removeClass('element-invisible');
634
- $statusBar.removeClass('element-invisible');
635
- $progress.hide();
636
- $info.show();
637
- $upload.text(lang.uploadStart);
638
- uploader.refresh();
639
- break;
640
-
641
- /* 上传中 */
642
- case 'uploading':
643
- $progress.show();
644
- $info.hide();
645
- $upload.text(lang.uploadPause);
646
- break;
647
-
648
- /* 暂停上传 */
649
- case 'paused':
650
- $progress.show();
651
- $info.hide();
652
- $upload.text(lang.uploadContinue);
653
- break;
654
-
655
- case 'confirm':
656
- $progress.show();
657
- $info.hide();
658
- $upload.text(lang.uploadStart);
659
-
660
- stats = uploader.getStats();
661
- if (stats.successNum && !stats.uploadFailNum) {
662
- setState('finish');
663
- return;
664
- }
665
- break;
666
-
667
- case 'finish':
668
- $progress.hide();
669
- $info.show();
670
- if (stats.uploadFailNum) {
671
- $upload.text(lang.uploadRetry);
672
- } else {
673
- $upload.text(lang.uploadStart);
674
- }
675
- break;
676
- }
677
-
678
- state = val;
679
- updateStatus();
680
-
681
- }
682
-
683
- if (!_this.getQueueCount()) {
684
- $upload.addClass('disabled')
685
- } else {
686
- $upload.removeClass('disabled')
687
- }
688
-
689
- }
690
-
691
- function updateStatus() {
692
- var text = '', stats;
693
-
694
- if (state === 'ready') {
695
- text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
696
- } else if (state === 'confirm') {
697
- stats = uploader.getStats();
698
- if (stats.uploadFailNum) {
699
- text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
700
- }
701
- } else {
702
- stats = uploader.getStats();
703
- text = lang.updateStatusFinish.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)).replace('_', stats.successNum);
704
-
705
- if (stats.uploadFailNum) {
706
- text += lang.updateStatusError.replace('_', stats.uploadFailNum);
707
- }
708
- }
709
-
710
- $info.html(text);
711
- }
712
-
713
- /**
714
- * 前置校验
715
- */
716
- uploader.on('beforeFileQueued', function (file) {
717
- if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1) {
718
- return true;
719
- }
720
- return false;
721
- })
722
-
723
- uploader.on('fileQueued', function (file) {
724
- fileCount++;
725
- fileSize += file.size;
726
-
727
- if (fileCount === 1) {
728
- $placeHolder.addClass('element-invisible');
729
- $statusBar.show();
730
- }
731
-
732
- addFile(file);
733
-
734
- const uploadFunc = editor.getOpt('uploadFunction');
735
- if (typeof uploadFunc === 'function') {
736
- // 开始上传
737
- if (state === 'ready') {
738
- setState('uploading');
739
- } else if (state === 'pedding') {
740
- setState('ready');
741
- setState('uploading');
742
- }
743
- file.setStatus('progress');
744
- uploader.trigger('uploadProgress', file, 0);
745
- uploadFunc(file.source.source).then(function (response) {
746
- uploader.trigger('uploadProgress', file, 1);
747
- file.setStatus('complete');
748
- setState('finish');
749
- uploader.trigger('uploadSuccess', file, response);
750
- uploader.trigger('uploadComplete', file);
751
- });
752
- }
753
- });
754
-
755
- uploader.on('fileDequeued', function (file) {
756
- fileCount--;
757
- fileSize -= file.size;
758
-
759
- removeFile(file);
760
- updateTotalProgress();
761
- });
762
-
763
- uploader.on('filesQueued', function (file) {
764
- if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
765
- setState('ready');
766
- }
767
- updateTotalProgress();
768
- });
769
-
770
- uploader.on('all', function (type, files) {
771
- switch (type) {
772
- case 'uploadFinished':
773
- setState('confirm', files);
774
- break;
775
- case 'startUpload':
776
- /* 添加额外的GET参数 */
777
- var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
778
- url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + 'encode=utf-8&' + params);
779
- uploader.option('server', url);
780
- setState('uploading', files);
781
- break;
782
- case 'stopUpload':
783
- setState('paused', files);
784
- break;
785
- }
786
- });
787
-
788
- uploader.on('uploadBeforeSend', function (file, data, header) {
789
- //这里可以通过data对象添加POST参数
790
- if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
791
- header['X_Requested_With'] = 'XMLHttpRequest';
792
- }
793
- });
794
-
795
- uploader.on('uploadProgress', function (file, percentage) {
796
- var $li = $('#' + file.id),
797
- $percent = $li.find('.progress span');
798
-
799
- $percent.css('width', percentage * 100 + '%');
800
- percentages[file.id][1] = percentage;
801
- updateTotalProgress();
802
- });
803
-
804
- uploader.on('uploadSuccess', function (file, json) {
805
- var $file = $('#' + file.id);
806
- try {
807
- if (json.state == 'SUCCESS') {
808
- uploadVideoList.push({
809
- 'url': json.url,
810
- 'type': json.type,
811
- 'original': json.original
812
- });
813
- $file.append('<span class="success"></span>');
814
- // 触发上传视频事件
815
- editor.fireEvent("uploadsuccess", {
816
- res: json,
817
- type: 'video'
818
- });
819
- } else {
820
- $file.find('.error').text(json.state).show();
821
- }
822
- } catch (e) {
823
- $file.find('.error').text(lang.errorServerUpload).show();
824
- }
825
- });
826
-
827
- uploader.on('uploadError', function (file, code) {
828
- });
829
- uploader.on('error', function (code, file) {
830
- if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
831
- addFile(file);
832
- }
833
- });
834
- uploader.on('uploadComplete', function (file, ret) {
835
- });
836
-
837
- $upload.on('click', function () {
838
- if ($(this).hasClass('disabled')) {
839
- return false;
840
- }
841
-
842
- if (state === 'ready') {
843
- uploader.upload();
844
- } else if (state === 'paused') {
845
- uploader.upload();
846
- } else if (state === 'uploading') {
847
- uploader.stop();
848
- }
849
- });
850
-
851
- $upload.addClass('state-' + state);
852
- updateTotalProgress();
853
- },
854
- getQueueCount: function () {
855
- var file, i, status, readyFile = 0, files = this.uploader.getFiles();
856
- for (i = 0; file = files[i++];) {
857
- status = file.getStatus();
858
- if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
859
- }
860
- return readyFile;
861
- },
862
- refresh: function () {
863
- this.uploader.refresh();
864
- }
865
- };
866
-
867
- })();
1
+ /*! UEditorPlus v2.0.0*/
2
+ !function(){function initTabs(){for(var tabs=$G("tabHeads").children,i=0;i<tabs.length;i++)domUtils.on(tabs[i],"click",function(e){var j,bodyId,target=e.target||e.srcElement;for(j=0;j<tabs.length;j++)bodyId=tabs[j].getAttribute("data-content-id"),tabs[j]==target?(domUtils.addClass(tabs[j],"focus"),domUtils.addClass($G(bodyId),"focus")):(domUtils.removeClasses(tabs[j],"focus"),domUtils.removeClasses($G(bodyId),"focus"))});editorOpt.disableUpload||($G("tabHeads").querySelector('[data-content-id="upload"]').style.display="inline-block"),editorOpt.selectCallback&&($G("videoSelect").style.display="inline-block",domUtils.on($G("videoSelect"),"click",function(e){editorOpt.selectCallback(editor,function(info){info&&($G("videoUrl").value=info.path,createPreviewVideo(info.path))})}))}function initVideo(){createAlignButton(["videoFloat","upload_alignment"]),addUrlChangeListener($G("videoUrl")),addOkListener(),function(){var url,img=editor.selection.getRange().getClosedNode();if(img&&img.className){var hasFakedClass="edui-faked-video"==img.className,hasUploadClass=img.className.indexOf("edui-upload-video")!=-1;if(hasFakedClass||hasUploadClass){$G("videoUrl").value=url=img.getAttribute("_url"),$G("videoWidth").value=img.width,$G("videoHeight").value=img.height;var align=domUtils.getComputedStyle(img,"float"),parentAlign=domUtils.getComputedStyle(img.parentNode,"text-align");updateAlignButton("center"===parentAlign?"center":align)}hasUploadClass&&(isModifyUploadVideo=!0)}createPreviewVideo(url)}()}function addOkListener(){dialog.onok=function(){$G("preview").innerHTML="";var currentTab=findFocus("tabHeads","tabSrc");switch(currentTab){case"video":return insertSingle();case"videoSearch":return insertSearch("searchList");case"upload":return insertUpload()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function updateAlignButton(align){for(var ci,aligns=$G("videoFloat").children,i=0;ci=aligns[i++];)ci.getAttribute("name")==align?"focus"!=ci.className&&(ci.className="focus"):"focus"==ci.className&&(ci.className="")}function insertSingle(){var width=$G("videoWidth"),height=$G("videoHeight"),url=$G("videoUrl").value,align=findFocus("videoFloat","name");return!!url&&(!!checkNum([width,height])&&void editor.execCommand("insertvideo",{url:convert_url(url),width:width.value,height:height.value,align:align},isModifyUploadVideo?"upload":null))}function insertSearch(id){for(var img,imgs=domUtils.getElementsByTagName($G(id),"img"),videoObjs=[],i=0;img=imgs[i++];)img.getAttribute("selected")&&videoObjs.push({url:img.getAttribute("ue_video_url"),width:420,height:280,align:"none"});editor.execCommand("insertvideo",videoObjs)}function findFocus(id,returnProperty){for(var property,ci,tabs=$G(id).children,i=0;ci=tabs[i++];)if("focus"==ci.className){property=ci.getAttribute(returnProperty);break}return property}function convert_url(url){return url?url=utils.trim(url):""}function checkNum(nodes){for(var ci,i=0;ci=nodes[i++];){var value=ci.value;if(!isNumber(value)&&value)return alert(lang.numError),ci.value="",ci.focus(),!1}return!0}function isNumber(value){return/(0|^[1-9]\d*$)/.test(value)}function createAlignButton(ids){for(var ci,i=0;ci=ids[i++];){var floatContainer=$G(ci),nameMaps={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var j in nameMaps){var div=document.createElement("div");div.setAttribute("name",j),"none"==j?(div.className="focus",div.style.cssText="background-image:url(icon/"+j+"-active.png);"):div.style.cssText="background-image:url(icon/"+j+".png);",div.setAttribute("title",nameMaps[j]),floatContainer.appendChild(div)}switchSelect(ci)}}function switchSelect(selectParentId){for(var ci,selects=$G(selectParentId).children,i=0;ci=selects[i++];)domUtils.on(ci,"click",function(){for(var cj,j=0;cj=selects[j++];)cj.className="",cj.style.cssText="background-image:url(icon/"+cj.getAttribute("name")+".png);",cj.removeAttribute&&cj.removeAttribute("class");this.className="focus",this.style.cssText="background-image:url(icon/"+this.getAttribute("name")+"-active.png);"})}function addUrlChangeListener(url){browser.ie?url.onpropertychange=function(){createPreviewVideo(this.value)}:url.addEventListener("input",function(){createPreviewVideo(this.value)},!1)}function createPreviewVideo(url){const location=window.parent.location,host=location.protocol+"//"+location.host+location.pathname;if(url){var conUrl=convert_url(url);conUrl=utils.unhtml(conUrl),$G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><iframe class="previewVideo" src="'+encodeURI(host+conUrl)+'" width="420" height="280" frameborder=0 allowfullscreen></iframe>'}}function insertUpload(){var videoObjs=[],uploadDir=editor.getOpt("videoUrlPrefix"),width=$G("upload_width").value||420,height=$G("upload_height").value||280,align=findFocus("upload_alignment","name")||"none";for(var key in uploadVideoList){var file=uploadVideoList[key];videoObjs.push({url:uploadDir+file.url,width:width,height:height,align:align})}var count=uploadFile.getQueueCount();return count?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,count)+"</span>"),!1):void editor.execCommand("insertvideo",videoObjs,"upload")}function initUpload(){uploadFile=new UploadFile("queueList")}function UploadFile(target){this.$wrap=target.constructor==String?$("#"+target):$(target),this.init()}var uploadFile,uploadVideoList=[],isModifyUploadVideo=!1,editorOpt={};window.onload=function(){editorOpt=editor.getOpt("videoConfig"),$focus($G("videoUrl")),initTabs(),initVideo(),initUpload()},UploadFile.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function addFile(file){var $li=$('<li id="'+file.id+'"><p class="title">'+file.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),$btns=$('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo($li),$prgress=$li.find("p.progress span"),$wrap=$li.find("p.imgWrap"),$info=$('<p class="error"></p>').hide().appendTo($li),showError=function(code){switch(code){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}$info.text(text).show()};"invalid"===file.getStatus()?showError(file.statusText):($wrap.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+file.ext.toLowerCase()+"|")==-1?$wrap.empty().addClass("notimage").append('<i class="file-preview file-type-'+file.ext.toLowerCase()+'"></i><span class="file-title">'+file.name+"</span>"):browser.ie&&browser.version<=7?$wrap.text(lang.uploadNoPreview):uploader.makeThumb(file,function(error,src){if(error||!src||/^data:/.test(src)&&browser.ie&&browser.version<=7)$wrap.text(lang.uploadNoPreview);else{var $img=$('<img src="'+src+'">');$wrap.empty().append($img),$img.on("error",function(){$wrap.text(lang.uploadNoPreview)})}},thumbnailWidth,thumbnailHeight),percentages[file.id]=[file.size,0],file.rotation=0,file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1||(showError("not_allow_type"),uploader.removeFile(file))),file.on("statuschange",function(cur,prev){"progress"===prev?$prgress.hide().width(0):"queued"===prev&&($li.off("mouseenter mouseleave"),$btns.remove()),"error"===cur||"invalid"===cur?(showError(file.statusText),percentages[file.id][1]=1):"interrupt"===cur?showError("interrupt"):"queued"===cur?percentages[file.id][1]=0:"progress"===cur&&($info.hide(),$prgress.css("display","block")),$li.removeClass("state-"+prev).addClass("state-"+cur)}),$li.on("mouseenter",function(){$btns.stop().animate({height:30})}),$li.on("mouseleave",function(){$btns.stop().animate({height:0})}),$btns.on("click","span",function(){var deg,index=$(this).index();switch(index){case 0:return void uploader.removeFile(file);case 1:file.rotation+=90;break;case 2:file.rotation-=90}supportTransition?(deg="rotate("+file.rotation+"deg)",$wrap.css({"-webkit-transform":deg,"-mos-transform":deg,"-o-transform":deg,transform:deg})):$wrap.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(file.rotation/90%4+4)%4+")")}),$li.insertBefore($filePickerBlock)}function removeFile(file){var $li=$("#"+file.id);delete percentages[file.id],updateTotalProgress(),$li.off().find(".file-panel").off().end().remove()}function updateTotalProgress(){var percent,loaded=0,total=0,spans=$progress.children();$.each(percentages,function(k,v){total+=v[0],loaded+=v[0]*v[1]}),percent=total?loaded/total:0,spans.eq(0).text(Math.round(100*percent)+"%"),spans.eq(1).css("width",Math.round(100*percent)+"%"),updateStatus()}function setState(val,files){if(val!=state){var stats=uploader.getStats();switch($upload.removeClass("state-"+state),$upload.addClass("state-"+val),val){case"pedding":$queue.addClass("element-invisible"),$statusBar.addClass("element-invisible"),$placeHolder.removeClass("element-invisible"),$progress.hide(),$info.hide(),uploader.refresh();break;case"ready":$placeHolder.addClass("element-invisible"),$queue.removeClass("element-invisible"),$statusBar.removeClass("element-invisible"),$progress.hide(),$info.show(),$upload.text(lang.uploadStart),uploader.refresh();break;case"uploading":$progress.show(),$info.hide(),$upload.text(lang.uploadPause);break;case"paused":$progress.show(),$info.hide(),$upload.text(lang.uploadContinue);break;case"confirm":if($progress.show(),$info.hide(),$upload.text(lang.uploadStart),stats=uploader.getStats(),stats.successNum&&!stats.uploadFailNum)return void setState("finish");break;case"finish":$progress.hide(),$info.show(),stats.uploadFailNum?$upload.text(lang.uploadRetry):$upload.text(lang.uploadStart)}state=val,updateStatus()}_this.getQueueCount()?$upload.removeClass("disabled"):$upload.addClass("disabled")}function updateStatus(){var stats,text="";"ready"===state?text=lang.updateStatusReady.replace("_",fileCount).replace("_KB",WebUploader.formatSize(fileSize)):"confirm"===state?(stats=uploader.getStats(),stats.uploadFailNum&&(text=lang.updateStatusConfirm.replace("_",stats.successNum).replace("_",stats.successNum))):(stats=uploader.getStats(),text=lang.updateStatusFinish.replace("_",fileCount).replace("_KB",WebUploader.formatSize(fileSize)).replace("_",stats.successNum),stats.uploadFailNum&&(text+=lang.updateStatusError.replace("_",stats.uploadFailNum))),$info.html(text)}var uploader,_this=this,$=jQuery,$wrap=_this.$wrap,$queue=$wrap.find(".filelist"),$statusBar=$wrap.find(".statusBar"),$info=$statusBar.find(".info"),$upload=$wrap.find(".uploadBtn"),$filePickerBlock=($wrap.find(".filePickerBtn"),$wrap.find(".filePickerBlock")),$placeHolder=$wrap.find(".placeholder"),$progress=$statusBar.find(".progress").hide(),fileCount=0,fileSize=0,ratio=window.devicePixelRatio||1,thumbnailWidth=113*ratio,thumbnailHeight=113*ratio,state="",percentages={},supportTransition=function(){var s=document.createElement("p").style,r="transition"in s||"WebkitTransition"in s||"MozTransition"in s||"msTransition"in s||"OTransition"in s;return s=null,r}(),actionUrl=editor.getActionUrl(editor.getOpt("videoActionName")),fileMaxSize=editor.getOpt("videoMaxSize"),acceptExtensions=(editor.getOpt("videoAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return $upload.hide(),WebUploader.Uploader.support()?editor.getOpt("videoActionName")?(uploader=_this.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:actionUrl,fileVal:editor.getOpt("videoFieldName"),duplicate:!0,fileSingleSizeLimit:fileMaxSize,headers:editor.getOpt("serverHeaders")||{},compress:!1}),uploader.addButton({id:"#filePickerBlock"}),uploader.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),setState("pedding"),uploader.on("beforeFileQueued",function(file){return!(!file.ext||acceptExtensions.indexOf(file.ext.toLowerCase())==-1)}),uploader.on("fileQueued",function(file){fileCount++,fileSize+=file.size,1===fileCount&&($placeHolder.addClass("element-invisible"),$statusBar.show()),addFile(file);const uploadFunc=editor.getOpt("uploadFunction");"function"==typeof uploadFunc&&("ready"===state?setState("uploading"):"pedding"===state&&(setState("ready"),setState("uploading")),file.setStatus("progress"),uploader.trigger("uploadProgress",file,0),uploadFunc(file.source.source).then(function(response){uploader.trigger("uploadProgress",file,1),file.setStatus("complete"),setState("finish"),uploader.trigger("uploadSuccess",file,response),uploader.trigger("uploadComplete",file)}))}),uploader.on("fileDequeued",function(file){fileCount--,fileSize-=file.size,removeFile(file),updateTotalProgress()}),uploader.on("filesQueued",function(file){uploader.isInProgress()||"pedding"!=state&&"finish"!=state&&"confirm"!=state&&"ready"!=state||setState("ready"),updateTotalProgress()}),uploader.on("all",function(type,files){switch(type){case"uploadFinished":setState("confirm",files);break;case"startUpload":var params=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",url=utils.formatUrl(actionUrl+(actionUrl.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+params);uploader.option("server",url),setState("uploading",files);break;case"stopUpload":setState("paused",files)}}),uploader.on("uploadBeforeSend",function(file,data,header){actionUrl.toLowerCase().indexOf("jsp")!=-1&&(header.X_Requested_With="XMLHttpRequest")}),uploader.on("uploadProgress",function(file,percentage){var $li=$("#"+file.id),$percent=$li.find(".progress span");$percent.css("width",100*percentage+"%"),percentages[file.id][1]=percentage,updateTotalProgress()}),uploader.on("uploadSuccess",function(file,json){var $file=$("#"+file.id);try{"SUCCESS"==json.state?(uploadVideoList.push({url:json.url,type:json.type,original:json.original}),$file.append('<span class="success"></span>'),editor.fireEvent("uploadsuccess",{res:json,type:"video"})):$file.find(".error").text(json.state).show()}catch(e){$file.find(".error").text(lang.errorServerUpload).show()}}),uploader.on("uploadError",function(file,code){}),uploader.on("error",function(code,file){"Q_TYPE_DENIED"!=code&&"F_EXCEED_SIZE"!=code||addFile(file)}),uploader.on("uploadComplete",function(file,ret){}),$upload.on("click",function(){return!$(this).hasClass("disabled")&&void("ready"===state?uploader.upload():"paused"===state?uploader.upload():"uploading"===state&&uploader.stop())}),$upload.addClass("state-"+state),void updateTotalProgress()):void $("#filePickerReady").after($("<div>").html(lang.errorLoadConfig)).hide():void $("#filePickerReady").after($("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var file,i,status,readyFile=0,files=this.uploader.getFiles();for(i=0;file=files[i++];)status=file.getStatus(),"queued"!=status&&"uploading"!=status&&"progress"!=status||readyFile++;return readyFile},refresh:function(){this.uploader.refresh()}}}();