@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.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.
- package/es/LcdpUeditor.d.ts +74 -0
- package/es/LcdpUeditor.js +335 -0
- package/es/const.d.ts +12 -0
- package/es/const.js +19 -0
- package/es/defaultConfig.json +77 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +3 -0
- package/es/tools/UeditorResourceLoader.d.ts +21 -0
- package/es/tools/UeditorResourceLoader.js +114 -0
- package/es/tools/loadScript.d.ts +5 -0
- package/es/tools/loadScript.js +54 -0
- package/es/type.d.ts +142 -0
- package/es/type.js +1 -0
- package/package.json +32 -0
- package/ueditor-resource/dialogs/anchor/anchor.html +62 -0
- package/ueditor-resource/dialogs/attachment/attachment.css +716 -0
- package/ueditor-resource/dialogs/attachment/attachment.html +61 -0
- package/ueditor-resource/dialogs/attachment/attachment.js +803 -0
- package/ueditor-resource/dialogs/attachment/images/alignicon.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/alignicon.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/bg.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/file-icons.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/file-icons.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/icons.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/image.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/progress.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/success.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/success.png +0 -0
- package/ueditor-resource/dialogs/audio/audio.css +879 -0
- package/ueditor-resource/dialogs/audio/audio.html +94 -0
- package/ueditor-resource/dialogs/audio/audio.js +815 -0
- package/ueditor-resource/dialogs/audio/icon/center-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/center.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/img.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/left-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/left.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/none-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/none.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/right-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/right.png +0 -0
- package/ueditor-resource/dialogs/audio/images/bg.png +0 -0
- package/ueditor-resource/dialogs/audio/images/center_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/file-icons.gif +0 -0
- package/ueditor-resource/dialogs/audio/images/file-icons.png +0 -0
- package/ueditor-resource/dialogs/audio/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/audio/images/icons.png +0 -0
- package/ueditor-resource/dialogs/audio/images/image.png +0 -0
- package/ueditor-resource/dialogs/audio/images/left_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/none_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/progress.png +0 -0
- package/ueditor-resource/dialogs/audio/images/right_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/success.gif +0 -0
- package/ueditor-resource/dialogs/audio/images/success.png +0 -0
- package/ueditor-resource/dialogs/background/background.css +193 -0
- package/ueditor-resource/dialogs/background/background.html +59 -0
- package/ueditor-resource/dialogs/background/background.js +370 -0
- package/ueditor-resource/dialogs/background/images/bg.png +0 -0
- package/ueditor-resource/dialogs/background/images/success.png +0 -0
- package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -0
- package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -0
- package/ueditor-resource/dialogs/emotion/emotion.css +129 -0
- package/ueditor-resource/dialogs/emotion/emotion.html +70 -0
- package/ueditor-resource/dialogs/emotion/emotion.js +186 -0
- package/ueditor-resource/dialogs/emotion/images/0.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/bface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/cface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/fface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/jxface2.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- package/ueditor-resource/dialogs/emotion/images/tface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/wface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/yface.gif +0 -0
- package/ueditor-resource/dialogs/formula/formula.html +98 -0
- package/ueditor-resource/dialogs/formula/formula.js +147 -0
- package/ueditor-resource/dialogs/help/help.css +37 -0
- package/ueditor-resource/dialogs/help/help.html +82 -0
- package/ueditor-resource/dialogs/help/help.js +57 -0
- package/ueditor-resource/dialogs/image/icon/center-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/center.png +0 -0
- package/ueditor-resource/dialogs/image/icon/img.png +0 -0
- package/ueditor-resource/dialogs/image/icon/left-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/left.png +0 -0
- package/ueditor-resource/dialogs/image/icon/none-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/none.png +0 -0
- package/ueditor-resource/dialogs/image/icon/right-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/right.png +0 -0
- package/ueditor-resource/dialogs/image/image.css +768 -0
- package/ueditor-resource/dialogs/image/image.html +145 -0
- package/ueditor-resource/dialogs/image/image.js +1060 -0
- package/ueditor-resource/dialogs/image/images/alignicon.jpg +0 -0
- package/ueditor-resource/dialogs/image/images/bg.png +0 -0
- package/ueditor-resource/dialogs/image/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/image/images/icons.png +0 -0
- package/ueditor-resource/dialogs/image/images/image.png +0 -0
- package/ueditor-resource/dialogs/image/images/progress.png +0 -0
- package/ueditor-resource/dialogs/image/images/success.gif +0 -0
- package/ueditor-resource/dialogs/image/images/success.png +0 -0
- package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -0
- package/ueditor-resource/dialogs/internal.js +81 -0
- package/ueditor-resource/dialogs/link/link.html +148 -0
- package/ueditor-resource/dialogs/preview/preview.html +45 -0
- package/ueditor-resource/dialogs/scrawl/images/addimg.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/brush.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/delimg.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/delimgH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/empty.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/emptyH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/eraser.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/redo.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/redoH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/scale.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/scaleH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/size.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/undo.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/undoH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -0
- package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -0
- package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -0
- package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -0
- package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -0
- package/ueditor-resource/dialogs/spechars/spechars.html +42 -0
- package/ueditor-resource/dialogs/spechars/spechars.js +86 -0
- package/ueditor-resource/dialogs/table/dragicon.png +0 -0
- package/ueditor-resource/dialogs/table/edittable.css +85 -0
- package/ueditor-resource/dialogs/table/edittable.html +69 -0
- package/ueditor-resource/dialogs/table/edittable.js +241 -0
- package/ueditor-resource/dialogs/table/edittd.html +62 -0
- package/ueditor-resource/dialogs/table/edittip.html +33 -0
- package/ueditor-resource/dialogs/template/config.js +42 -0
- package/ueditor-resource/dialogs/template/images/bg.gif +0 -0
- package/ueditor-resource/dialogs/template/images/pre0.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre1.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre2.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre3.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre4.png +0 -0
- package/ueditor-resource/dialogs/template/template.css +99 -0
- package/ueditor-resource/dialogs/template/template.html +26 -0
- package/ueditor-resource/dialogs/template/template.js +53 -0
- package/ueditor-resource/dialogs/video/icon/center-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/center.png +0 -0
- package/ueditor-resource/dialogs/video/icon/img.png +0 -0
- package/ueditor-resource/dialogs/video/icon/left-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/left.png +0 -0
- package/ueditor-resource/dialogs/video/icon/none-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/none.png +0 -0
- package/ueditor-resource/dialogs/video/icon/right-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/right.png +0 -0
- package/ueditor-resource/dialogs/video/images/bg.png +0 -0
- package/ueditor-resource/dialogs/video/images/center_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/file-icons.gif +0 -0
- package/ueditor-resource/dialogs/video/images/file-icons.png +0 -0
- package/ueditor-resource/dialogs/video/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/video/images/icons.png +0 -0
- package/ueditor-resource/dialogs/video/images/image.png +0 -0
- package/ueditor-resource/dialogs/video/images/left_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/none_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/progress.png +0 -0
- package/ueditor-resource/dialogs/video/images/right_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/success.gif +0 -0
- package/ueditor-resource/dialogs/video/images/success.png +0 -0
- package/ueditor-resource/dialogs/video/video.css +909 -0
- package/ueditor-resource/dialogs/video/video.html +115 -0
- package/ueditor-resource/dialogs/video/video.js +867 -0
- package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -0
- package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -0
- package/ueditor-resource/index.html +146 -0
- package/ueditor-resource/lang/en/en.js +686 -0
- package/ueditor-resource/lang/en/images/addimage.png +0 -0
- package/ueditor-resource/lang/en/images/alldeletebtnhoverskin.png +0 -0
- package/ueditor-resource/lang/en/images/alldeletebtnupskin.png +0 -0
- package/ueditor-resource/lang/en/images/background.png +0 -0
- package/ueditor-resource/lang/en/images/button.png +0 -0
- package/ueditor-resource/lang/en/images/copy.png +0 -0
- package/ueditor-resource/lang/en/images/deletedisable.png +0 -0
- package/ueditor-resource/lang/en/images/deleteenable.png +0 -0
- package/ueditor-resource/lang/en/images/listbackground.png +0 -0
- package/ueditor-resource/lang/en/images/localimage.png +0 -0
- package/ueditor-resource/lang/en/images/music.png +0 -0
- package/ueditor-resource/lang/en/images/rotateleftdisable.png +0 -0
- package/ueditor-resource/lang/en/images/rotateleftenable.png +0 -0
- package/ueditor-resource/lang/en/images/rotaterightdisable.png +0 -0
- package/ueditor-resource/lang/en/images/rotaterightenable.png +0 -0
- package/ueditor-resource/lang/en/images/upload.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/copy.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/localimage.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/music.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/upload.png +0 -0
- package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -0
- package/ueditor-resource/plugins/demo/demo.js +3 -0
- package/ueditor-resource/themes/default/css/ueditor.css +2148 -0
- package/ueditor-resource/themes/default/dialog.css +17 -0
- package/ueditor-resource/themes/default/dialogbase.css +132 -0
- package/ueditor-resource/themes/default/exts/ai.svg +12 -0
- package/ueditor-resource/themes/default/exts/apk.svg +12 -0
- package/ueditor-resource/themes/default/exts/chm.svg +12 -0
- package/ueditor-resource/themes/default/exts/css.svg +12 -0
- package/ueditor-resource/themes/default/exts/doc.svg +22 -0
- package/ueditor-resource/themes/default/exts/docx.svg +22 -0
- package/ueditor-resource/themes/default/exts/dwg.svg +16 -0
- package/ueditor-resource/themes/default/exts/folder.svg +3 -0
- package/ueditor-resource/themes/default/exts/gif.svg +14 -0
- package/ueditor-resource/themes/default/exts/html.svg +12 -0
- package/ueditor-resource/themes/default/exts/jpeg.svg +14 -0
- package/ueditor-resource/themes/default/exts/jpg.svg +14 -0
- package/ueditor-resource/themes/default/exts/log.svg +12 -0
- package/ueditor-resource/themes/default/exts/mp3.svg +14 -0
- package/ueditor-resource/themes/default/exts/mp4.svg +12 -0
- package/ueditor-resource/themes/default/exts/pdf.svg +14 -0
- package/ueditor-resource/themes/default/exts/png.svg +14 -0
- package/ueditor-resource/themes/default/exts/ppt.svg +24 -0
- package/ueditor-resource/themes/default/exts/pptx.svg +24 -0
- package/ueditor-resource/themes/default/exts/psd.svg +12 -0
- package/ueditor-resource/themes/default/exts/rar.svg +12 -0
- package/ueditor-resource/themes/default/exts/svg.svg +12 -0
- package/ueditor-resource/themes/default/exts/torrent.svg +14 -0
- package/ueditor-resource/themes/default/exts/txt.svg +14 -0
- package/ueditor-resource/themes/default/exts/unknown.svg +12 -0
- package/ueditor-resource/themes/default/exts/xls.svg +25 -0
- package/ueditor-resource/themes/default/exts/xlsx.svg +25 -0
- package/ueditor-resource/themes/default/exts/zip.svg +12 -0
- package/ueditor-resource/themes/default/images/anchor.gif +0 -0
- package/ueditor-resource/themes/default/images/arrow.png +0 -0
- package/ueditor-resource/themes/default/images/arrow_down.png +0 -0
- package/ueditor-resource/themes/default/images/arrow_up.png +0 -0
- package/ueditor-resource/themes/default/images/button-bg.gif +0 -0
- package/ueditor-resource/themes/default/images/cancelbutton.gif +0 -0
- package/ueditor-resource/themes/default/images/charts.png +0 -0
- package/ueditor-resource/themes/default/images/cursor_h.gif +0 -0
- package/ueditor-resource/themes/default/images/cursor_h.png +0 -0
- package/ueditor-resource/themes/default/images/cursor_v.gif +0 -0
- package/ueditor-resource/themes/default/images/cursor_v.png +0 -0
- package/ueditor-resource/themes/default/images/dialog-title-bg.png +0 -0
- package/ueditor-resource/themes/default/images/filescan.png +0 -0
- package/ueditor-resource/themes/default/images/highlighted.gif +0 -0
- package/ueditor-resource/themes/default/images/icons-all.gif +0 -0
- package/ueditor-resource/themes/default/images/icons.gif +0 -0
- package/ueditor-resource/themes/default/images/icons.png +0 -0
- package/ueditor-resource/themes/default/images/img-cracked.png +0 -0
- package/ueditor-resource/themes/default/images/loaderror.png +0 -0
- package/ueditor-resource/themes/default/images/loading.gif +0 -0
- package/ueditor-resource/themes/default/images/lock.gif +0 -0
- package/ueditor-resource/themes/default/images/neweditor-tab-bg.png +0 -0
- package/ueditor-resource/themes/default/images/pagebreak.gif +0 -0
- package/ueditor-resource/themes/default/images/scale.png +0 -0
- package/ueditor-resource/themes/default/images/sortable.png +0 -0
- package/ueditor-resource/themes/default/images/spacer.gif +0 -0
- package/ueditor-resource/themes/default/images/sparator_v.png +0 -0
- package/ueditor-resource/themes/default/images/table-cell-align.png +0 -0
- package/ueditor-resource/themes/default/images/tangram-colorpicker.png +0 -0
- package/ueditor-resource/themes/default/images/toolbar_bg.png +0 -0
- package/ueditor-resource/themes/default/images/unhighlighted.gif +0 -0
- package/ueditor-resource/themes/default/images/upload.png +0 -0
- package/ueditor-resource/themes/default/images/videologo.gif +0 -0
- package/ueditor-resource/themes/default/images/word.gif +0 -0
- package/ueditor-resource/themes/default/images/wordpaste.png +0 -0
- package/ueditor-resource/themes/iframe.css +63 -0
- package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -0
- package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
- package/ueditor-resource/third-party/clipboard/clipboard.js +753 -0
- package/ueditor-resource/third-party/clipboard/clipboard.swf +0 -0
- package/ueditor-resource/third-party/codemirror/codemirror.css +106 -0
- package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -0
- package/ueditor-resource/third-party/jquery-3.5.1.js +2 -0
- package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -0
- package/ueditor-resource/third-party/webuploader/webuploader.css +88 -0
- package/ueditor-resource/third-party/webuploader/webuploader.js +4 -0
- package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
- package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
- package/ueditor-resource/ueditor.all.js +32643 -0
- package/ueditor-resource/ueditor.config.js +656 -0
- package/ueditor-resource/ueditor.parse.js +639 -0
|
@@ -0,0 +1,815 @@
|
|
|
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 audio = {},
|
|
12
|
+
uploadaudioList = [],
|
|
13
|
+
isModifyUploadaudio = false,
|
|
14
|
+
uploadFile;
|
|
15
|
+
var editorOpt = {};
|
|
16
|
+
|
|
17
|
+
window.onload = function () {
|
|
18
|
+
editorOpt = editor.getOpt('audioConfig');
|
|
19
|
+
$focus($G("audioUrl"));
|
|
20
|
+
initTabs();
|
|
21
|
+
initAudio();
|
|
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('audioSelect').style.display = 'inline-block';
|
|
48
|
+
domUtils.on($G('audioSelect'), "click", function (e) {
|
|
49
|
+
editorOpt.selectCallback(editor, function (info) {
|
|
50
|
+
if (info) {
|
|
51
|
+
$G('audioUrl').value = info.path;
|
|
52
|
+
createPreview(info.path);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function initAudio() {
|
|
60
|
+
createAlignButton(["audioFloat", "upload_alignment"]);
|
|
61
|
+
addUrlChangeListener($G("audioUrl"));
|
|
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-audio"),
|
|
69
|
+
hasUploadClass = img.className.indexOf("edui-upload-audio") != -1;
|
|
70
|
+
if (hasFakedClass || hasUploadClass) {
|
|
71
|
+
$G("audioUrl").value = url = img.getAttribute("_url");
|
|
72
|
+
var align = domUtils.getComputedStyle(img, "float"),
|
|
73
|
+
parentAlign = domUtils.getComputedStyle(img.parentNode, "text-align");
|
|
74
|
+
updateAlignButton(parentAlign === "center" ? "center" : align);
|
|
75
|
+
}
|
|
76
|
+
if (hasUploadClass) {
|
|
77
|
+
isModifyUploadaudio = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
createPreview(url);
|
|
81
|
+
})();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 监听确认和取消两个按钮事件,用户执行插入或者清空正在播放的视频实例操作
|
|
86
|
+
*/
|
|
87
|
+
function addOkListener() {
|
|
88
|
+
dialog.onok = function () {
|
|
89
|
+
$G("preview").innerHTML = "";
|
|
90
|
+
var currentTab = findFocus("tabHeads", "tabSrc");
|
|
91
|
+
switch (currentTab) {
|
|
92
|
+
case "audio":
|
|
93
|
+
return insertSingle();
|
|
94
|
+
// case "audioSearch":
|
|
95
|
+
// return insertSearch("searchList");
|
|
96
|
+
// break;
|
|
97
|
+
case "upload":
|
|
98
|
+
return insertUpload();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
dialog.oncancel = function () {
|
|
102
|
+
$G("preview").innerHTML = "";
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 依据传入的align值更新按钮信息
|
|
108
|
+
* @param align
|
|
109
|
+
*/
|
|
110
|
+
function updateAlignButton(align) {
|
|
111
|
+
var aligns = $G("audioFloat").children;
|
|
112
|
+
for (var i = 0, ci; ci = aligns[i++];) {
|
|
113
|
+
if (ci.getAttribute("name") == align) {
|
|
114
|
+
if (ci.className != "focus") {
|
|
115
|
+
ci.className = "focus";
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
if (ci.className == "focus") {
|
|
119
|
+
ci.className = "";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 将单个视频信息插入编辑器中
|
|
127
|
+
*/
|
|
128
|
+
function insertSingle() {
|
|
129
|
+
var url = $G('audioUrl').value,
|
|
130
|
+
align = findFocus("audioFloat", "name");
|
|
131
|
+
if (!url) return false;
|
|
132
|
+
editor.execCommand('insertaudio', {
|
|
133
|
+
url: url,
|
|
134
|
+
}, isModifyUploadaudio ? 'upload' : null);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 将元素id下的所有代表视频的图片插入编辑器中
|
|
139
|
+
* @param id
|
|
140
|
+
*/
|
|
141
|
+
function insertSearch(id) {
|
|
142
|
+
var imgs = domUtils.getElementsByTagName($G(id), "img"),
|
|
143
|
+
audioObjs = [];
|
|
144
|
+
for (var i = 0, img; img = imgs[i++];) {
|
|
145
|
+
if (img.getAttribute("selected")) {
|
|
146
|
+
audioObjs.push({
|
|
147
|
+
url: img.getAttribute("ue_audio_url"),
|
|
148
|
+
width: 420,
|
|
149
|
+
height: 280,
|
|
150
|
+
align: "none"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
editor.execCommand('insertaudio', audioObjs);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 找到id下具有focus类的节点并返回该节点下的某个属性
|
|
159
|
+
* @param id
|
|
160
|
+
* @param returnProperty
|
|
161
|
+
*/
|
|
162
|
+
function findFocus(id, returnProperty) {
|
|
163
|
+
var tabs = $G(id).children,
|
|
164
|
+
property;
|
|
165
|
+
for (var i = 0, ci; ci = tabs[i++];) {
|
|
166
|
+
if (ci.className == "focus") {
|
|
167
|
+
property = ci.getAttribute(returnProperty);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return property;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 数字判断
|
|
176
|
+
* @param value
|
|
177
|
+
*/
|
|
178
|
+
function isNumber(value) {
|
|
179
|
+
return /(0|^[1-9]\d*$)/.test(value);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 创建图片浮动选择按钮
|
|
184
|
+
* @param ids
|
|
185
|
+
*/
|
|
186
|
+
function createAlignButton(ids) {
|
|
187
|
+
for (var i = 0, ci; ci = ids[i++];) {
|
|
188
|
+
var floatContainer = $G(ci),
|
|
189
|
+
nameMaps = {
|
|
190
|
+
"none": lang['default'],
|
|
191
|
+
"left": lang.floatLeft,
|
|
192
|
+
"right": lang.floatRight,
|
|
193
|
+
"center": lang.block
|
|
194
|
+
};
|
|
195
|
+
for (var j in nameMaps) {
|
|
196
|
+
var div = document.createElement("div");
|
|
197
|
+
div.setAttribute("name", j);
|
|
198
|
+
if (j == "none") {
|
|
199
|
+
div.className = "focus"
|
|
200
|
+
div.style.cssText = "background-image:url(icon/" + j + "-active.png);";
|
|
201
|
+
} else {
|
|
202
|
+
div.style.cssText = "background-image:url(icon/" + j + ".png);";
|
|
203
|
+
}
|
|
204
|
+
div.setAttribute("title", nameMaps[j]);
|
|
205
|
+
floatContainer.appendChild(div);
|
|
206
|
+
}
|
|
207
|
+
switchSelect(ci);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 选择切换
|
|
213
|
+
* @param selectParentId
|
|
214
|
+
*/
|
|
215
|
+
function switchSelect(selectParentId) {
|
|
216
|
+
var selects = $G(selectParentId).children;
|
|
217
|
+
for (var i = 0, ci; ci = selects[i++];) {
|
|
218
|
+
domUtils.on(ci, "click", function () {
|
|
219
|
+
for (var j = 0, cj; cj = selects[j++];) {
|
|
220
|
+
cj.className = "";
|
|
221
|
+
cj.style.cssText = "background-image:url(icon/" + cj.getAttribute('name') + ".png);";
|
|
222
|
+
cj.removeAttribute && cj.removeAttribute("class");
|
|
223
|
+
}
|
|
224
|
+
this.className = "focus";
|
|
225
|
+
this.style.cssText = "background-image:url(icon/" + this.getAttribute('name') + "-active.png);";
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 监听url改变事件
|
|
232
|
+
* @param url
|
|
233
|
+
*/
|
|
234
|
+
function addUrlChangeListener(url) {
|
|
235
|
+
if (browser.ie) {
|
|
236
|
+
url.onpropertychange = function () {
|
|
237
|
+
createPreview(this.value);
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
url.addEventListener("input", function () {
|
|
241
|
+
createPreview(this.value);
|
|
242
|
+
}, false);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function createAudioHtml(url, param) {
|
|
247
|
+
param = param || {};
|
|
248
|
+
var str = [
|
|
249
|
+
"<audio",
|
|
250
|
+
(param.id ? ' id="' + param.id + '"' : ""),
|
|
251
|
+
(param.cls ? ' class="' + param.cls + '"' : ''),
|
|
252
|
+
' controls >',
|
|
253
|
+
'<source src="' + url + '" type="audio/mpeg' + '" />',
|
|
254
|
+
'</audio>',
|
|
255
|
+
];
|
|
256
|
+
return str.join('');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 根据url生成视频预览
|
|
261
|
+
* @param url
|
|
262
|
+
*/
|
|
263
|
+
function createPreview(url) {
|
|
264
|
+
if (!url) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
$G("preview").innerHTML = '<div class="previewMsg"><span>' + lang.urlError + '</span></div>' +
|
|
269
|
+
'<div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;">' +
|
|
270
|
+
'<div style="text-align:center;flex-grow:1;">' + createAudioHtml(url) + '</div>'
|
|
271
|
+
+ '</div>';
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
/* 插入上传视频 */
|
|
276
|
+
function insertUpload() {
|
|
277
|
+
var audioObjs = [],
|
|
278
|
+
uploadDir = editor.getOpt('audioUrlPrefix'),
|
|
279
|
+
align = findFocus("upload_alignment", "name") || 'none';
|
|
280
|
+
for (var key in uploadaudioList) {
|
|
281
|
+
var file = uploadaudioList[key];
|
|
282
|
+
audioObjs.push({
|
|
283
|
+
url: uploadDir + file.url,
|
|
284
|
+
align: align
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
var count = uploadFile.getQueueCount();
|
|
289
|
+
if (count) {
|
|
290
|
+
$('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
|
|
291
|
+
return false;
|
|
292
|
+
} else {
|
|
293
|
+
editor.execCommand('insertaudio', audioObjs, 'upload');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/*初始化上传标签*/
|
|
298
|
+
function initUpload() {
|
|
299
|
+
uploadFile = new UploadFile('queueList');
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
/* 上传附件 */
|
|
304
|
+
function UploadFile(target) {
|
|
305
|
+
this.$wrap = target.constructor == String ? $('#' + target) : $(target);
|
|
306
|
+
this.init();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
UploadFile.prototype = {
|
|
310
|
+
init: function () {
|
|
311
|
+
this.fileList = [];
|
|
312
|
+
this.initContainer();
|
|
313
|
+
this.initUploader();
|
|
314
|
+
},
|
|
315
|
+
initContainer: function () {
|
|
316
|
+
this.$queue = this.$wrap.find('.filelist');
|
|
317
|
+
},
|
|
318
|
+
/* 初始化容器 */
|
|
319
|
+
initUploader: function () {
|
|
320
|
+
var _this = this,
|
|
321
|
+
$ = jQuery, // just in case. Make sure it's not an other libaray.
|
|
322
|
+
$wrap = _this.$wrap,
|
|
323
|
+
// 图片容器
|
|
324
|
+
$queue = $wrap.find('.filelist'),
|
|
325
|
+
// 状态栏,包括进度和控制按钮
|
|
326
|
+
$statusBar = $wrap.find('.statusBar'),
|
|
327
|
+
// 文件总体选择信息。
|
|
328
|
+
$info = $statusBar.find('.info'),
|
|
329
|
+
// 上传按钮
|
|
330
|
+
$upload = $wrap.find('.uploadBtn'),
|
|
331
|
+
// 上传按钮
|
|
332
|
+
$filePickerBtn = $wrap.find('.filePickerBtn'),
|
|
333
|
+
// 上传按钮
|
|
334
|
+
$filePickerBlock = $wrap.find('.filePickerBlock'),
|
|
335
|
+
// 没选择文件之前的内容。
|
|
336
|
+
$placeHolder = $wrap.find('.placeholder'),
|
|
337
|
+
// 总体进度条
|
|
338
|
+
$progress = $statusBar.find('.progress').hide(),
|
|
339
|
+
// 添加的文件数量
|
|
340
|
+
fileCount = 0,
|
|
341
|
+
// 添加的文件总大小
|
|
342
|
+
fileSize = 0,
|
|
343
|
+
// 优化retina, 在retina下这个值是2
|
|
344
|
+
ratio = window.devicePixelRatio || 1,
|
|
345
|
+
// 缩略图大小
|
|
346
|
+
thumbnailWidth = 113 * ratio,
|
|
347
|
+
thumbnailHeight = 113 * ratio,
|
|
348
|
+
// 可能有pedding, ready, uploading, confirm, done.
|
|
349
|
+
state = '',
|
|
350
|
+
// 所有文件的进度信息,key为file id
|
|
351
|
+
percentages = {},
|
|
352
|
+
supportTransition = (function () {
|
|
353
|
+
var s = document.createElement('p').style,
|
|
354
|
+
r = 'transition' in s ||
|
|
355
|
+
'WebkitTransition' in s ||
|
|
356
|
+
'MozTransition' in s ||
|
|
357
|
+
'msTransition' in s ||
|
|
358
|
+
'OTransition' in s;
|
|
359
|
+
s = null;
|
|
360
|
+
return r;
|
|
361
|
+
})(),
|
|
362
|
+
// WebUploader实例
|
|
363
|
+
uploader,
|
|
364
|
+
actionUrl = editor.getActionUrl(editor.getOpt('audioActionName')),
|
|
365
|
+
fileMaxSize = editor.getOpt('audioMaxSize'),
|
|
366
|
+
acceptExtensions = (editor.getOpt('audioAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');
|
|
367
|
+
// 隐藏上传按钮
|
|
368
|
+
$upload.hide();
|
|
369
|
+
|
|
370
|
+
if (!WebUploader.Uploader.support()) {
|
|
371
|
+
$('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
|
|
372
|
+
return;
|
|
373
|
+
} else if (!editor.getOpt('audioActionName')) {
|
|
374
|
+
$('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
uploader = _this.uploader = WebUploader.create({
|
|
379
|
+
pick: {
|
|
380
|
+
id: '#filePickerReady',
|
|
381
|
+
label: lang.uploadSelectFile
|
|
382
|
+
},
|
|
383
|
+
swf: '../../third-party/webuploader/Uploader.swf',
|
|
384
|
+
server: actionUrl,
|
|
385
|
+
fileVal: editor.getOpt('audioFieldName'),
|
|
386
|
+
duplicate: true,
|
|
387
|
+
fileSingleSizeLimit: fileMaxSize,
|
|
388
|
+
headers: editor.getOpt('serverHeaders') || {},
|
|
389
|
+
compress: false
|
|
390
|
+
});
|
|
391
|
+
uploader.addButton({
|
|
392
|
+
id: '#filePickerBlock'
|
|
393
|
+
});
|
|
394
|
+
uploader.addButton({
|
|
395
|
+
id: '#filePickerBtn',
|
|
396
|
+
label: lang.uploadAddFile
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
setState('pedding');
|
|
400
|
+
|
|
401
|
+
// 当有文件添加进来时执行,负责view的创建
|
|
402
|
+
function addFile(file) {
|
|
403
|
+
var $li = $('<li id="' + file.id + '">' +
|
|
404
|
+
'<p class="title">' + file.name + '</p>' +
|
|
405
|
+
'<p class="imgWrap"></p>' +
|
|
406
|
+
'<p class="progress"><span></span></p>' +
|
|
407
|
+
'</li>'),
|
|
408
|
+
|
|
409
|
+
$btns = $('<div class="file-panel">' +
|
|
410
|
+
'<span class="cancel">' + lang.uploadDelete + '</span>' +
|
|
411
|
+
'<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
|
|
412
|
+
'<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
|
|
413
|
+
$prgress = $li.find('p.progress span'),
|
|
414
|
+
$wrap = $li.find('p.imgWrap'),
|
|
415
|
+
$info = $('<p class="error"></p>').hide().appendTo($li),
|
|
416
|
+
|
|
417
|
+
showError = function (code) {
|
|
418
|
+
switch (code) {
|
|
419
|
+
case 'exceed_size':
|
|
420
|
+
text = lang.errorExceedSize;
|
|
421
|
+
break;
|
|
422
|
+
case 'interrupt':
|
|
423
|
+
text = lang.errorInterrupt;
|
|
424
|
+
break;
|
|
425
|
+
case 'http':
|
|
426
|
+
text = lang.errorHttp;
|
|
427
|
+
break;
|
|
428
|
+
case 'not_allow_type':
|
|
429
|
+
text = lang.errorFileType;
|
|
430
|
+
break;
|
|
431
|
+
default:
|
|
432
|
+
text = lang.errorUploadRetry;
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
$info.text(text).show();
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
if (file.getStatus() === 'invalid') {
|
|
439
|
+
showError(file.statusText);
|
|
440
|
+
} else {
|
|
441
|
+
$wrap.text(lang.uploadPreview);
|
|
442
|
+
if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|' + file.ext.toLowerCase() + '|') == -1) {
|
|
443
|
+
$wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
|
|
444
|
+
'<span class="file-title">' + file.name + '</span>');
|
|
445
|
+
} else {
|
|
446
|
+
if (browser.ie && browser.version <= 7) {
|
|
447
|
+
$wrap.text(lang.uploadNoPreview);
|
|
448
|
+
} else {
|
|
449
|
+
uploader.makeThumb(file, function (error, src) {
|
|
450
|
+
if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
|
|
451
|
+
$wrap.text(lang.uploadNoPreview);
|
|
452
|
+
} else {
|
|
453
|
+
var $img = $('<img src="' + src + '">');
|
|
454
|
+
$wrap.empty().append($img);
|
|
455
|
+
$img.on('error', function () {
|
|
456
|
+
$wrap.text(lang.uploadNoPreview);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}, thumbnailWidth, thumbnailHeight);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
percentages[file.id] = [file.size, 0];
|
|
463
|
+
file.rotation = 0;
|
|
464
|
+
|
|
465
|
+
/* 检查文件格式 */
|
|
466
|
+
if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
|
|
467
|
+
showError('not_allow_type');
|
|
468
|
+
uploader.removeFile(file);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
file.on('statuschange', function (cur, prev) {
|
|
473
|
+
if (prev === 'progress') {
|
|
474
|
+
$prgress.hide().width(0);
|
|
475
|
+
} else if (prev === 'queued') {
|
|
476
|
+
$li.off('mouseenter mouseleave');
|
|
477
|
+
$btns.remove();
|
|
478
|
+
}
|
|
479
|
+
// 成功
|
|
480
|
+
if (cur === 'error' || cur === 'invalid') {
|
|
481
|
+
showError(file.statusText);
|
|
482
|
+
percentages[file.id][1] = 1;
|
|
483
|
+
} else if (cur === 'interrupt') {
|
|
484
|
+
showError('interrupt');
|
|
485
|
+
} else if (cur === 'queued') {
|
|
486
|
+
percentages[file.id][1] = 0;
|
|
487
|
+
} else if (cur === 'progress') {
|
|
488
|
+
$info.hide();
|
|
489
|
+
$prgress.css('display', 'block');
|
|
490
|
+
} else if (cur === 'complete') {
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
$li.removeClass('state-' + prev).addClass('state-' + cur);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
$li.on('mouseenter', function () {
|
|
497
|
+
$btns.stop().animate({ height: 30 });
|
|
498
|
+
});
|
|
499
|
+
$li.on('mouseleave', function () {
|
|
500
|
+
$btns.stop().animate({ height: 0 });
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
$btns.on('click', 'span', function () {
|
|
504
|
+
var index = $(this).index(),
|
|
505
|
+
deg;
|
|
506
|
+
|
|
507
|
+
switch (index) {
|
|
508
|
+
case 0:
|
|
509
|
+
uploader.removeFile(file);
|
|
510
|
+
return;
|
|
511
|
+
case 1:
|
|
512
|
+
file.rotation += 90;
|
|
513
|
+
break;
|
|
514
|
+
case 2:
|
|
515
|
+
file.rotation -= 90;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (supportTransition) {
|
|
520
|
+
deg = 'rotate(' + file.rotation + 'deg)';
|
|
521
|
+
$wrap.css({
|
|
522
|
+
'-webkit-transform': deg,
|
|
523
|
+
'-mos-transform': deg,
|
|
524
|
+
'-o-transform': deg,
|
|
525
|
+
'transform': deg
|
|
526
|
+
});
|
|
527
|
+
} else {
|
|
528
|
+
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
$li.insertBefore($filePickerBlock);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// 负责view的销毁
|
|
537
|
+
function removeFile(file) {
|
|
538
|
+
var $li = $('#' + file.id);
|
|
539
|
+
delete percentages[file.id];
|
|
540
|
+
updateTotalProgress();
|
|
541
|
+
$li.off().find('.file-panel').off().end().remove();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function updateTotalProgress() {
|
|
545
|
+
var loaded = 0,
|
|
546
|
+
total = 0,
|
|
547
|
+
spans = $progress.children(),
|
|
548
|
+
percent;
|
|
549
|
+
|
|
550
|
+
$.each(percentages, function (k, v) {
|
|
551
|
+
total += v[0];
|
|
552
|
+
loaded += v[0] * v[1];
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
percent = total ? loaded / total : 0;
|
|
556
|
+
|
|
557
|
+
spans.eq(0).text(Math.round(percent * 100) + '%');
|
|
558
|
+
spans.eq(1).css('width', Math.round(percent * 100) + '%');
|
|
559
|
+
updateStatus();
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function setState(val, files) {
|
|
563
|
+
|
|
564
|
+
if (val != state) {
|
|
565
|
+
|
|
566
|
+
var stats = uploader.getStats();
|
|
567
|
+
|
|
568
|
+
$upload.removeClass('state-' + state);
|
|
569
|
+
$upload.addClass('state-' + val);
|
|
570
|
+
|
|
571
|
+
switch (val) {
|
|
572
|
+
|
|
573
|
+
/* 未选择文件 */
|
|
574
|
+
case 'pedding':
|
|
575
|
+
$queue.addClass('element-invisible');
|
|
576
|
+
$statusBar.addClass('element-invisible');
|
|
577
|
+
$placeHolder.removeClass('element-invisible');
|
|
578
|
+
$progress.hide();
|
|
579
|
+
$info.hide();
|
|
580
|
+
uploader.refresh();
|
|
581
|
+
break;
|
|
582
|
+
|
|
583
|
+
/* 可以开始上传 */
|
|
584
|
+
case 'ready':
|
|
585
|
+
$placeHolder.addClass('element-invisible');
|
|
586
|
+
$queue.removeClass('element-invisible');
|
|
587
|
+
$statusBar.removeClass('element-invisible');
|
|
588
|
+
$progress.hide();
|
|
589
|
+
$info.show();
|
|
590
|
+
$upload.text(lang.uploadStart);
|
|
591
|
+
uploader.refresh();
|
|
592
|
+
break;
|
|
593
|
+
|
|
594
|
+
/* 上传中 */
|
|
595
|
+
case 'uploading':
|
|
596
|
+
$progress.show();
|
|
597
|
+
$info.hide();
|
|
598
|
+
$upload.text(lang.uploadPause);
|
|
599
|
+
break;
|
|
600
|
+
|
|
601
|
+
/* 暂停上传 */
|
|
602
|
+
case 'paused':
|
|
603
|
+
$progress.show();
|
|
604
|
+
$info.hide();
|
|
605
|
+
$upload.text(lang.uploadContinue);
|
|
606
|
+
break;
|
|
607
|
+
|
|
608
|
+
case 'confirm':
|
|
609
|
+
$progress.show();
|
|
610
|
+
$info.hide();
|
|
611
|
+
$upload.text(lang.uploadStart);
|
|
612
|
+
|
|
613
|
+
stats = uploader.getStats();
|
|
614
|
+
if (stats.successNum && !stats.uploadFailNum) {
|
|
615
|
+
setState('finish');
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
break;
|
|
619
|
+
|
|
620
|
+
case 'finish':
|
|
621
|
+
$progress.hide();
|
|
622
|
+
$info.show();
|
|
623
|
+
if (stats.uploadFailNum) {
|
|
624
|
+
$upload.text(lang.uploadRetry);
|
|
625
|
+
} else {
|
|
626
|
+
$upload.text(lang.uploadStart);
|
|
627
|
+
}
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
state = val;
|
|
632
|
+
updateStatus();
|
|
633
|
+
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
if (!_this.getQueueCount()) {
|
|
637
|
+
$upload.addClass('disabled')
|
|
638
|
+
} else {
|
|
639
|
+
$upload.removeClass('disabled')
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function updateStatus() {
|
|
645
|
+
var text = '', stats;
|
|
646
|
+
|
|
647
|
+
if (state === 'ready') {
|
|
648
|
+
text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
|
|
649
|
+
} else if (state === 'confirm') {
|
|
650
|
+
stats = uploader.getStats();
|
|
651
|
+
if (stats.uploadFailNum) {
|
|
652
|
+
text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
|
|
653
|
+
}
|
|
654
|
+
} else {
|
|
655
|
+
stats = uploader.getStats();
|
|
656
|
+
text = lang.updateStatusFinish.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)).replace('_', stats.successNum);
|
|
657
|
+
|
|
658
|
+
if (stats.uploadFailNum) {
|
|
659
|
+
text += lang.updateStatusError.replace('_', stats.uploadFailNum);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
$info.html(text);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* 前置校验
|
|
668
|
+
*/
|
|
669
|
+
uploader.on('beforeFileQueued', function (file) {
|
|
670
|
+
if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1) {
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
return false;
|
|
674
|
+
})
|
|
675
|
+
|
|
676
|
+
uploader.on('fileQueued', function (file) {
|
|
677
|
+
fileCount++;
|
|
678
|
+
fileSize += file.size;
|
|
679
|
+
|
|
680
|
+
if (fileCount === 1) {
|
|
681
|
+
$placeHolder.addClass('element-invisible');
|
|
682
|
+
$statusBar.show();
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
addFile(file);
|
|
686
|
+
|
|
687
|
+
const uploadFunc = editor.getOpt('uploadFunction');
|
|
688
|
+
if (typeof uploadFunc === 'function') {
|
|
689
|
+
// 开始上传
|
|
690
|
+
if (state === 'ready') {
|
|
691
|
+
setState('uploading');
|
|
692
|
+
} else if (state === 'pedding') {
|
|
693
|
+
setState('ready');
|
|
694
|
+
setState('uploading');
|
|
695
|
+
}
|
|
696
|
+
file.setStatus('progress');
|
|
697
|
+
uploader.trigger('uploadProgress', file, 0);
|
|
698
|
+
uploadFunc(file.source.source).then(function (response) {
|
|
699
|
+
uploader.trigger('uploadProgress', file, 1);
|
|
700
|
+
file.setStatus('complete');
|
|
701
|
+
setState('finish');
|
|
702
|
+
uploader.trigger('uploadSuccess', file, response);
|
|
703
|
+
uploader.trigger('uploadComplete', file);
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
uploader.on('fileDequeued', function (file) {
|
|
709
|
+
fileCount--;
|
|
710
|
+
fileSize -= file.size;
|
|
711
|
+
|
|
712
|
+
removeFile(file);
|
|
713
|
+
updateTotalProgress();
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
uploader.on('filesQueued', function (file) {
|
|
717
|
+
if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
|
|
718
|
+
setState('ready');
|
|
719
|
+
}
|
|
720
|
+
updateTotalProgress();
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
uploader.on('all', function (type, files) {
|
|
724
|
+
switch (type) {
|
|
725
|
+
case 'uploadFinished':
|
|
726
|
+
setState('confirm', files);
|
|
727
|
+
break;
|
|
728
|
+
case 'startUpload':
|
|
729
|
+
/* 添加额外的GET参数 */
|
|
730
|
+
var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
|
|
731
|
+
url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + 'encode=utf-8&' + params);
|
|
732
|
+
uploader.option('server', url);
|
|
733
|
+
setState('uploading', files);
|
|
734
|
+
break;
|
|
735
|
+
case 'stopUpload':
|
|
736
|
+
setState('paused', files);
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
uploader.on('uploadBeforeSend', function (file, data, header) {
|
|
742
|
+
//这里可以通过data对象添加POST参数
|
|
743
|
+
if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
|
|
744
|
+
header['X_Requested_With'] = 'XMLHttpRequest';
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
uploader.on('uploadProgress', function (file, percentage) {
|
|
749
|
+
var $li = $('#' + file.id),
|
|
750
|
+
$percent = $li.find('.progress span');
|
|
751
|
+
|
|
752
|
+
$percent.css('width', percentage * 100 + '%');
|
|
753
|
+
percentages[file.id][1] = percentage;
|
|
754
|
+
updateTotalProgress();
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
uploader.on('uploadSuccess', function (file, json) {
|
|
758
|
+
var $file = $('#' + file.id);
|
|
759
|
+
try {
|
|
760
|
+
if (json.state == 'SUCCESS') {
|
|
761
|
+
uploadaudioList.push({
|
|
762
|
+
'url': json.url,
|
|
763
|
+
'type': json.type,
|
|
764
|
+
'original': json.original
|
|
765
|
+
});
|
|
766
|
+
$file.append('<span class="success"></span>');
|
|
767
|
+
} else {
|
|
768
|
+
$file.find('.error').text(json.state).show();
|
|
769
|
+
}
|
|
770
|
+
} catch (e) {
|
|
771
|
+
$file.find('.error').text(lang.errorServerUpload).show();
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
uploader.on('uploadError', function (file, code) {
|
|
776
|
+
});
|
|
777
|
+
uploader.on('error', function (code, file) {
|
|
778
|
+
if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
|
|
779
|
+
addFile(file);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
uploader.on('uploadComplete', function (file, ret) {
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
$upload.on('click', function () {
|
|
786
|
+
if ($(this).hasClass('disabled')) {
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
if (state === 'ready') {
|
|
791
|
+
uploader.upload();
|
|
792
|
+
} else if (state === 'paused') {
|
|
793
|
+
uploader.upload();
|
|
794
|
+
} else if (state === 'uploading') {
|
|
795
|
+
uploader.stop();
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
$upload.addClass('state-' + state);
|
|
800
|
+
updateTotalProgress();
|
|
801
|
+
},
|
|
802
|
+
getQueueCount: function () {
|
|
803
|
+
var file, i, status, readyFile = 0, files = this.uploader.getFiles();
|
|
804
|
+
for (i = 0; file = files[i++];) {
|
|
805
|
+
status = file.getStatus();
|
|
806
|
+
if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
|
|
807
|
+
}
|
|
808
|
+
return readyFile;
|
|
809
|
+
},
|
|
810
|
+
refresh: function () {
|
|
811
|
+
this.uploader.refresh();
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
})();
|