@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.1 → 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.
- package/es/LcdpUeditor.d.ts +4 -0
- package/es/LcdpUeditor.js +43 -8
- package/es/tools/filterHtmlNode.js +7 -2
- package/lib/LcdpUeditor.d.ts +4 -0
- package/lib/LcdpUeditor.js +35 -8
- package/lib/tools/filterHtmlNode.js +8 -4
- package/package.json +1 -1
- package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
- package/ueditor-resource/dialogs/attachment/attachment.html +3 -3
- package/ueditor-resource/dialogs/attachment/attachment.js +1 -1
- package/ueditor-resource/dialogs/audio/audio.js +1 -1
- package/ueditor-resource/dialogs/background/background.html +2 -2
- package/ueditor-resource/dialogs/background/background.js +1 -1
- package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
- package/ueditor-resource/dialogs/contentimport/contentimport.js +1 -1
- package/ueditor-resource/dialogs/emotion/emotion.html +2 -2
- package/ueditor-resource/dialogs/emotion/emotion.js +1 -1
- package/ueditor-resource/dialogs/formula/formula.html +4 -4
- package/ueditor-resource/dialogs/formula/formula.js +1 -1
- package/ueditor-resource/dialogs/help/help.html +2 -2
- package/ueditor-resource/dialogs/help/help.js +1 -1
- package/ueditor-resource/dialogs/image/image.js +1 -1
- package/ueditor-resource/dialogs/insertframe/insertframe.html +1 -1
- package/ueditor-resource/dialogs/internal.js +1 -1
- package/ueditor-resource/dialogs/preview/preview.html +2 -2
- package/ueditor-resource/dialogs/scrawl/scrawl.html +2 -2
- package/ueditor-resource/dialogs/scrawl/scrawl.js +1 -1
- package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
- package/ueditor-resource/dialogs/searchreplace/searchreplace.js +1 -1
- package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
- package/ueditor-resource/dialogs/spechars/spechars.js +1 -1
- package/ueditor-resource/dialogs/table/edittable.html +2 -2
- package/ueditor-resource/dialogs/table/edittable.js +1 -1
- package/ueditor-resource/dialogs/table/edittd.html +1 -1
- package/ueditor-resource/dialogs/table/edittip.html +1 -1
- package/ueditor-resource/dialogs/template/template.html +2 -2
- package/ueditor-resource/dialogs/template/template.js +1 -1
- package/ueditor-resource/dialogs/video/video.js +1 -1
- package/ueditor-resource/dialogs/wordimage/wordimage.html +4 -4
- package/ueditor-resource/dialogs/wordimage/wordimage.js +1 -1
- package/ueditor-resource/plugins/browser-image-compression.js +9 -0
- package/ueditor-resource/plugins/demo/demo.js +3 -1
- package/ueditor-resource/themes/default/css/ueditor.css +1 -1
- package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3 -3
- package/ueditor-resource/third-party/clipboard/clipboard.js +1 -1
- package/ueditor-resource/third-party/codemirror/codemirror.js +3 -2
- package/ueditor-resource/third-party/jquery-3.5.1.js +3 -3
- package/ueditor-resource/third-party/jquery-3.5.1_1.js +3 -3
- package/ueditor-resource/ueditor.all.js +22 -19
- package/ueditor-resource/ueditor.config.js +1 -1
- package/ueditor-resource/ueditor.parse.js +1 -1
package/es/LcdpUeditor.d.ts
CHANGED
package/es/LcdpUeditor.js
CHANGED
|
@@ -60,6 +60,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
60
60
|
* 是否加载完成
|
|
61
61
|
*/
|
|
62
62
|
_defineProperty(_assertThisInitialized(_this), "isReady", false);
|
|
63
|
+
/**
|
|
64
|
+
* 保存 compositionend 事件处理器引用
|
|
65
|
+
*/
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "compositionEndHandler", void 0);
|
|
63
67
|
/**
|
|
64
68
|
* 初始加载失败
|
|
65
69
|
*/
|
|
@@ -139,8 +143,14 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
139
143
|
key: "componentWillUnmount",
|
|
140
144
|
value: function componentWillUnmount() {
|
|
141
145
|
if (this.isReady) {
|
|
142
|
-
var _this$ueditorInst, _this$
|
|
143
|
-
(_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0
|
|
146
|
+
var _this$ueditorInst, _this$ueditorInst2, _this$ueditorInst2$de;
|
|
147
|
+
var editorBody = (_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0 ? void 0 : _this$ueditorInst.body;
|
|
148
|
+
if (editorBody && this.compositionEndHandler) {
|
|
149
|
+
// 销毁时移除监听
|
|
150
|
+
editorBody.removeEventListener('compositionend', this.compositionEndHandler);
|
|
151
|
+
this.compositionEndHandler = undefined;
|
|
152
|
+
}
|
|
153
|
+
(_this$ueditorInst2 = this.ueditorInst) === null || _this$ueditorInst2 === void 0 || (_this$ueditorInst2$de = _this$ueditorInst2.destroy) === null || _this$ueditorInst2$de === void 0 || _this$ueditorInst2$de.call(_this$ueditorInst2);
|
|
144
154
|
}
|
|
145
155
|
}
|
|
146
156
|
}, {
|
|
@@ -302,14 +312,30 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
302
312
|
value: (function () {
|
|
303
313
|
var _initUeditor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
304
314
|
var _this3 = this;
|
|
305
|
-
var jsList;
|
|
315
|
+
var timer, readyFunc, jsList;
|
|
306
316
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
307
317
|
while (1) switch (_context3.prev = _context3.next) {
|
|
308
318
|
case 0:
|
|
309
|
-
|
|
319
|
+
// 在弹窗页面中反复开关,会导致 dom 丢失
|
|
320
|
+
readyFunc = function readyFunc() {
|
|
310
321
|
_this3.initConfig();
|
|
322
|
+
var target = document.getElementById(_this3.containerId);
|
|
323
|
+
if (!window.UE || !target) {
|
|
324
|
+
timer = setInterval(function () {
|
|
325
|
+
target = document.getElementById(_this3.containerId);
|
|
326
|
+
if (target) {
|
|
327
|
+
clearInterval(timer);
|
|
328
|
+
readyFunc();
|
|
329
|
+
}
|
|
330
|
+
}, 50);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
311
333
|
_this3.ueditorInst = window.UE.getEditor(_this3.containerId, _this3.editorConfig);
|
|
312
334
|
_this3.ueditorInst.ready(function () {
|
|
335
|
+
var nextValue = filterHtmlNode(_this3.props.value || '').str;
|
|
336
|
+
if (nextValue) {
|
|
337
|
+
_this3.ueditorInst.setContent(nextValue);
|
|
338
|
+
}
|
|
313
339
|
_this3.isReady = true;
|
|
314
340
|
// 禁用状态设置
|
|
315
341
|
if (_this3.props.disabled) {
|
|
@@ -320,11 +346,20 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
320
346
|
_this3.ueditorInst.addListener('contentChange', function () {
|
|
321
347
|
_this3.debounceContentChange();
|
|
322
348
|
});
|
|
349
|
+
|
|
350
|
+
// 处理微软拼音输入法输入中文时,内容不会触发contentChange事件
|
|
351
|
+
var editorBody = _this3.ueditorInst.body;
|
|
352
|
+
if (editorBody) {
|
|
353
|
+
_this3.compositionEndHandler = function () {
|
|
354
|
+
_this3.debounceContentChange();
|
|
355
|
+
};
|
|
356
|
+
editorBody.addEventListener('compositionend', _this3.compositionEndHandler);
|
|
357
|
+
}
|
|
323
358
|
_this3.initStyle();
|
|
359
|
+
_this3.mountRef();
|
|
324
360
|
});
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
361
|
+
};
|
|
362
|
+
UeditorResourceLoader.onReady(readyFunc);
|
|
328
363
|
// 默认配置 语言包 统一打包到 ueditor-all.js中
|
|
329
364
|
jsList = ["".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL)];
|
|
330
365
|
UeditorResourceLoader.onLoadError(function () {
|
|
@@ -333,7 +368,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
|
|
|
333
368
|
});
|
|
334
369
|
});
|
|
335
370
|
UeditorResourceLoader.startLoad(jsList);
|
|
336
|
-
case
|
|
371
|
+
case 5:
|
|
337
372
|
case "end":
|
|
338
373
|
return _context3.stop();
|
|
339
374
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export var filterHtmlNode = function filterHtmlNode(str) {
|
|
2
|
+
var _doc$body;
|
|
2
3
|
var flag = false;
|
|
3
4
|
if (typeof str !== 'string') return str || '';
|
|
4
5
|
var blacklist = ['script', 'style', 'iframe'];
|
|
@@ -11,6 +12,9 @@ export var filterHtmlNode = function filterHtmlNode(str) {
|
|
|
11
12
|
|
|
12
13
|
// 遍历 DOM 树并删除恶意节点
|
|
13
14
|
function cleanNode(node) {
|
|
15
|
+
if (!node) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
14
18
|
if (node.nodeType === 1) {
|
|
15
19
|
// 元素节点
|
|
16
20
|
if (blacklist.indexOf(node.nodeName.toLowerCase()) !== -1) {
|
|
@@ -28,13 +32,14 @@ export var filterHtmlNode = function filterHtmlNode(str) {
|
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
|
-
for (var _i = 0; _i < node.childNodes.length; _i += 1) {
|
|
35
|
+
for (var _i = 0; _i < (node === null || node === void 0 || (_node$childNodes = node.childNodes) === null || _node$childNodes === void 0 ? void 0 : _node$childNodes.length); _i += 1) {
|
|
36
|
+
var _node$childNodes;
|
|
32
37
|
cleanNode(node.childNodes[_i]);
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
cleanNode(doc.body);
|
|
36
41
|
return {
|
|
37
|
-
str: doc.body.innerHTML,
|
|
42
|
+
str: ((_doc$body = doc.body) === null || _doc$body === void 0 ? void 0 : _doc$body.innerHTML) || '',
|
|
38
43
|
flag: flag,
|
|
39
44
|
source: str
|
|
40
45
|
};
|
package/lib/LcdpUeditor.d.ts
CHANGED
package/lib/LcdpUeditor.js
CHANGED
|
@@ -136,9 +136,14 @@ var LcdpUeditor = class extends import_react.default.Component {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
componentWillUnmount() {
|
|
139
|
-
var _a, _b;
|
|
139
|
+
var _a, _b, _c;
|
|
140
140
|
if (this.isReady) {
|
|
141
|
-
|
|
141
|
+
const editorBody = (_a = this.ueditorInst) == null ? void 0 : _a.body;
|
|
142
|
+
if (editorBody && this.compositionEndHandler) {
|
|
143
|
+
editorBody.removeEventListener("compositionend", this.compositionEndHandler);
|
|
144
|
+
this.compositionEndHandler = void 0;
|
|
145
|
+
}
|
|
146
|
+
(_c = (_b = this.ueditorInst) == null ? void 0 : _b.destroy) == null ? void 0 : _c.call(_b);
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
onContentChange() {
|
|
@@ -234,10 +239,26 @@ var LcdpUeditor = class extends import_react.default.Component {
|
|
|
234
239
|
* 初始化编辑器实例
|
|
235
240
|
*/
|
|
236
241
|
async initUeditor() {
|
|
237
|
-
|
|
242
|
+
let timer;
|
|
243
|
+
const readyFunc = () => {
|
|
238
244
|
this.initConfig();
|
|
245
|
+
let target = document.getElementById(this.containerId);
|
|
246
|
+
if (!window.UE || !target) {
|
|
247
|
+
timer = setInterval(() => {
|
|
248
|
+
target = document.getElementById(this.containerId);
|
|
249
|
+
if (target) {
|
|
250
|
+
clearInterval(timer);
|
|
251
|
+
readyFunc();
|
|
252
|
+
}
|
|
253
|
+
}, 50);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
239
256
|
this.ueditorInst = window.UE.getEditor(this.containerId, this.editorConfig);
|
|
240
257
|
this.ueditorInst.ready(() => {
|
|
258
|
+
const nextValue = (0, import_filterHtmlNode.filterHtmlNode)(this.props.value || "").str;
|
|
259
|
+
if (nextValue) {
|
|
260
|
+
this.ueditorInst.setContent(nextValue);
|
|
261
|
+
}
|
|
241
262
|
this.isReady = true;
|
|
242
263
|
if (this.props.disabled) {
|
|
243
264
|
this.ueditorInst.setDisabled();
|
|
@@ -247,13 +268,19 @@ var LcdpUeditor = class extends import_react.default.Component {
|
|
|
247
268
|
this.ueditorInst.addListener("contentChange", () => {
|
|
248
269
|
this.debounceContentChange();
|
|
249
270
|
});
|
|
271
|
+
const editorBody = this.ueditorInst.body;
|
|
272
|
+
if (editorBody) {
|
|
273
|
+
this.compositionEndHandler = () => {
|
|
274
|
+
this.debounceContentChange();
|
|
275
|
+
};
|
|
276
|
+
editorBody.addEventListener("compositionend", this.compositionEndHandler);
|
|
277
|
+
}
|
|
250
278
|
this.initStyle();
|
|
279
|
+
this.mountRef();
|
|
251
280
|
});
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const jsList = [
|
|
255
|
-
`${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL}`
|
|
256
|
-
];
|
|
281
|
+
};
|
|
282
|
+
import_UeditorResourceLoader.default.onReady(readyFunc);
|
|
283
|
+
const jsList = [`${this.ueditorPath}/${import_const.DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL}`];
|
|
257
284
|
import_UeditorResourceLoader.default.onLoadError(() => {
|
|
258
285
|
this.setState({
|
|
259
286
|
initError: true
|
|
@@ -23,6 +23,7 @@ __export(filterHtmlNode_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(filterHtmlNode_exports);
|
|
25
25
|
var filterHtmlNode = (str) => {
|
|
26
|
+
var _a;
|
|
26
27
|
let flag = false;
|
|
27
28
|
if (typeof str !== "string")
|
|
28
29
|
return str || "";
|
|
@@ -30,10 +31,13 @@ var filterHtmlNode = (str) => {
|
|
|
30
31
|
const parser = new DOMParser();
|
|
31
32
|
const doc = parser.parseFromString(str, "text/html");
|
|
32
33
|
function cleanNode(node) {
|
|
33
|
-
var
|
|
34
|
+
var _a2, _b;
|
|
35
|
+
if (!node) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
34
38
|
if (node.nodeType === 1) {
|
|
35
39
|
if (blacklist.indexOf(node.nodeName.toLowerCase()) !== -1) {
|
|
36
|
-
(
|
|
40
|
+
(_a2 = node.parentNode) == null ? void 0 : _a2.removeChild(node);
|
|
37
41
|
return;
|
|
38
42
|
}
|
|
39
43
|
for (let i = node.attributes.length - 1; i >= 0; i -= 1) {
|
|
@@ -44,13 +48,13 @@ var filterHtmlNode = (str) => {
|
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
|
-
for (let i = 0; i < node.childNodes.length; i += 1) {
|
|
51
|
+
for (let i = 0; i < ((_b = node == null ? void 0 : node.childNodes) == null ? void 0 : _b.length); i += 1) {
|
|
48
52
|
cleanNode(node.childNodes[i]);
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
cleanNode(doc.body);
|
|
52
56
|
return {
|
|
53
|
-
str: doc.body.innerHTML,
|
|
57
|
+
str: ((_a = doc.body) == null ? void 0 : _a.innerHTML) || "",
|
|
54
58
|
flag,
|
|
55
59
|
source: str
|
|
56
60
|
};
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<div class="content">
|
|
38
38
|
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value=""/>
|
|
39
39
|
</div>
|
|
40
|
-
<script type="text/javascript" src="../internal.js?
|
|
40
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
41
41
|
<script type="text/javascript">
|
|
42
42
|
var anchorInput = $G('anchorName'),
|
|
43
43
|
node = editor.selection.getRange().getClosedNode();
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<title>ueditor图片对话框</title>
|
|
6
|
-
<script type="text/javascript" src="../internal.js?
|
|
6
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
7
7
|
|
|
8
8
|
<!-- jquery -->
|
|
9
|
-
<script type="text/javascript" src="../../third-party/jquery-3.5.1.js?
|
|
9
|
+
<script type="text/javascript" src="../../third-party/jquery-3.5.1.js?cdb3992e"></script>
|
|
10
10
|
|
|
11
11
|
<!-- webuploader -->
|
|
12
12
|
<script src="../../third-party/webuploader/webuploader.js?5e398948"></script>
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
58
|
-
<script type="text/javascript" src="attachment.js?
|
|
58
|
+
<script type="text/javascript" src="attachment.js?5f0b87d6"></script>
|
|
59
59
|
|
|
60
60
|
</body>
|
|
61
61
|
</html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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}}}();
|
|
2
|
+
!function(){function initTabs(){$G("tabhead").querySelector('[data-content-id="online"]').style.display="none";for(var tabs=$G("tabhead").children,i=0;i<tabs.length;i++)domUtils.on(tabs[i],"click",function(e){var target=e.target||e.srcElement;setTabFocus(target.getAttribute("data-content-id"))});setTabFocus("upload")}function setTabFocus(id){if(id){var i,bodyId,tabs=$G("tabhead").children;for(i=0;i<tabs.length;i++)bodyId=tabs[i].getAttribute("data-content-id"),bodyId==id?(domUtils.addClass(tabs[i],"focus"),domUtils.addClass($G(bodyId),"focus")):(domUtils.removeClasses(tabs[i],"focus"),domUtils.removeClasses($G(bodyId),"focus"));switch(id){case"upload":uploadFile=uploadFile||new UploadFile("queueList");break;case"online":onlineFile=onlineFile||new OnlineFile("fileList")}}}function initButtons(){dialog.onok=function(){for(var id,list=[],tabs=$G("tabhead").children,i=0;i<tabs.length;i++)if(domUtils.hasClass(tabs[i],"focus")){id=tabs[i].getAttribute("data-content-id");break}switch(id){case"upload":list=uploadFile.getInsertList();var count=uploadFile.getQueueCount();if(count)return $(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,count)+"</span>"),!1;break;case"online":list=onlineFile.getInsertList()}editor.execCommand("insertfile",list)}}function UploadFile(target){this.$wrap=target.constructor==String?$("#"+target):$(target),this.init()}function OnlineFile(target){this.container=utils.isString(target)?document.getElementById(target):target,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 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" title="'+file.name+'">'+file.name+"</span>"):browser.ie&&browser.version<=7?$wrap.text(lang.uploadNoPreview):uploader.makeThumb(file,function(error,src){if(error||!src)$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("fileActionName")),fileMaxSize=editor.getOpt("fileMaxSize"),acceptExtensions=(editor.getOpt("fileAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return $upload.hide(),WebUploader.Uploader.support()?(!editor.getOpt("fileActionName"),uploader=_this.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:actionUrl,fileVal:editor.getOpt("fileFieldName"),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&&file.size<=fileMaxSize)}),uploader.on("fileQueued",function(file){file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1&&file.size<=fileMaxSize&&(fileCount++,fileSize+=file.size),1===fileCount&&($placeHolder.addClass("element-invisible"),$statusBar.show()),addFile(file);var uploadFunc=editor.getOpt("uploadFunction");"function"==typeof uploadFunc&&("ready"===state?setState("uploading"):(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){file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1&&file.size<=fileMaxSize&&(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?(_this.fileList.push(json),$file.append('<span class="success"></span>'),editor.fireEvent("uploadsuccess",{res:json,type:"file"})):$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.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},getInsertList:function(){var i,link,data,list=[],prefix=editor.getOpt("fileUrlPrefix");for(i=0;i<this.fileList.length;i++)data=this.fileList[i],link=data.url,list.push({title:data.original||link.substr(link.lastIndexOf("/")+1),url:prefix+link});return list}},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 _this=this;domUtils.on($G("fileList"),"scroll",function(e){var panel=this;panel.scrollHeight-(panel.offsetHeight+panel.scrollTop)<10&&_this.getFileData()}),domUtils.on(this.list,"click",function(e){var target=e.target||e.srcElement,li=target.parentNode;"li"==li.tagName.toLowerCase()&&(domUtils.hasClass(li,"selected")?domUtils.removeClasses(li,"selected"):domUtils.addClass(li,"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(list){var i,item,filetype,preview,icon,_this=this,urlPrefix=editor.getOpt("fileManagerUrlPrefix");for(i=0;i<list.length;i++)if(list[i]&&list[i].url){if(item=document.createElement("li"),icon=document.createElement("span"),filetype=list[i].url.substr(list[i].url.lastIndexOf(".")+1),"png|jpg|jpeg|gif|bmp".indexOf(filetype)!=-1)preview=document.createElement("img"),domUtils.on(preview,"load",function(image){return function(){_this.scale(image,image.parentNode.offsetWidth,image.parentNode.offsetHeight)}}(preview)),preview.width=113,preview.setAttribute("src",urlPrefix+list[i].url+(list[i].url.indexOf("?")==-1?"?noCache=":"&noCache=")+(+new Date).toString(36));else{var ic=document.createElement("i"),textSpan=document.createElement("span");textSpan.innerHTML=list[i].original||list[i].url.substr(list[i].url.lastIndexOf("/")+1),preview=document.createElement("div"),preview.appendChild(ic),preview.appendChild(textSpan),domUtils.addClass(preview,"file-wrapper"),domUtils.addClass(textSpan,"file-title"),domUtils.addClass(ic,"file-type-"+filetype),domUtils.addClass(ic,"file-preview")}domUtils.addClass(icon,"icon"),item.setAttribute("data-url",urlPrefix+list[i].url),list[i].original&&item.setAttribute("data-title",list[i].original),item.appendChild(preview),item.appendChild(icon),this.list.insertBefore(item,this.clearFloat)}},scale:function(img,w,h,type){var ow=img.width,oh=img.height;"justify"==type?ow>=oh?(img.width=w,img.height=h*oh/ow,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w*ow/oh,img.height=h,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px"):ow>=oh?(img.width=w*ow/oh,img.height=h,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w,img.height=h*oh/ow,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px")},getInsertList:function(){var i,lis=this.list.children,list=[];for(i=0;i<lis.length;i++)if(domUtils.hasClass(lis[i],"selected")){var url=lis[i].getAttribute("data-url"),title=lis[i].getAttribute("data-title")||url.substr(url.lastIndexOf("/")+1);list.push({title:title,url:url})}return list}}}();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
!function(){function a(){for(var a=$G("tabHeads").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(b){var c,d,e=b.target||b.srcElement;for(c=0;c<a.length;c++)d=a[c].getAttribute("data-content-id"),a[c]==e?(domUtils.addClass(a[c],"focus"),domUtils.addClass($G(d),"focus")):(domUtils.removeClasses(a[c],"focus"),domUtils.removeClasses($G(d),"focus"))});r.disableUpload||($G("tabHeads").querySelector('[data-content-id="upload"]').style.display="inline-block"),r.selectCallback&&($G("audioSelect").style.display="inline-block",domUtils.on($G("audioSelect"),"click",function(a){r.selectCallback(editor,function(a){a&&($G("audioUrl").value=a.path,k(a.path))})}))}function b(){g(["audioFloat","upload_alignment"]),i($G("audioUrl")),c(),function(){var a,b=editor.selection.getRange().getClosedNode();if(b&&b.className){var c="edui-faked-audio"==b.className,e=b.className.indexOf("edui-upload-audio")!=-1;if(c||e){$G("audioUrl").value=a=b.getAttribute("_url");var f=domUtils.getComputedStyle(b,"float"),g=domUtils.getComputedStyle(b.parentNode,"text-align");d("center"===g?"center":f)}e&&(q=!0)}k(a)}()}function c(){dialog.onok=function(){$G("preview").innerHTML="";var a=f("tabHeads","tabSrc");switch(a){case"audio":return e();case"upload":return l()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function d(a){for(var b,c=$G("audioFloat").children,d=0;b=c[d++];)b.getAttribute("name")==a?"focus"!=b.className&&(b.className="focus"):"focus"==b.className&&(b.className="")}function e(){var a=$G("audioUrl").value;f("audioFloat","name");return!!a&&void editor.execCommand("insertaudio",{url:a},q?"upload":null)}function f(a,b){for(var c,d,e=$G(a).children,f=0;d=e[f++];)if("focus"==d.className){c=d.getAttribute(b);break}return c}function g(a){for(var b,c=0;b=a[c++];){var d=$G(b),e={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var f in e){var g=document.createElement("div");g.setAttribute("name",f),"none"==f?(g.className="focus",g.style.cssText="background-image:url(icon/"+f+"-active.png);"):g.style.cssText="background-image:url(icon/"+f+".png);",g.setAttribute("title",e[f]),d.appendChild(g)}h(b)}}function h(a){for(var b,c=$G(a).children,d=0;b=c[d++];)domUtils.on(b,"click",function(){for(var a,b=0;a=c[b++];)a.className="",a.style.cssText="background-image:url(icon/"+a.getAttribute("name")+".png);",a.removeAttribute&&a.removeAttribute("class");this.className="focus",this.style.cssText="background-image:url(icon/"+this.getAttribute("name")+"-active.png);"})}function i(a){browser.ie?a.onpropertychange=function(){k(this.value)}:a.addEventListener("input",function(){k(this.value)},!1)}function j(a,b){b=b||{};var c=["<audio",b.id?' id="'+b.id+'"':"",b.cls?' class="'+b.cls+'"':""," controls >",'<source src="'+a+'" type="audio/mpeg" />',"</audio>"];return c.join("")}function k(a){a&&($G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;"><div style="text-align:center;flex-grow:1;">'+j(a)+"</div></div>")}function l(){var a=[],b=editor.getOpt("audioUrlPrefix"),c=f("upload_alignment","name")||"none";for(var d in p){var e=p[d];a.push({url:b+e.url,align:c})}var g=o.getQueueCount();return g?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,g)+"</span>"),!1):void editor.execCommand("insertaudio",a,"upload")}function m(){o=new n("queueList")}function n(a){this.$wrap=a.constructor==String?$("#"+a):$(a),this.init()}var o,p=[],q=!1,r={};window.onload=function(){r=editor.getOpt("audioConfig"),$focus($G("audioUrl")),a(),b(),m()},n.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">'+a.name+"</span>"):browser.ie&&browser.version<=7?e.text(lang.uploadNoPreview):f.makeThumb(a,function(a,b){if(a||!b||/^data:/.test(b)&&browser.ie&&browser.version<=7)e.text(lang.uploadNoPreview);else{var c=h('<img src="'+b+'">');e.empty().append(c),c.on("error",function(){e.text(lang.uploadNoPreview)})}},u,v),x[a.id]=[a.size,0],a.rotation=0,a.ext&&B.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),x[a.id][1]=1):"interrupt"===e?i("interrupt"):"queued"===e?x[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}y?(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 x[a.id],c(),b.off().find(".file-panel").off().end().remove()}function c(){var a,b=0,c=0,d=q.children();h.each(x,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!=w){var c=f.getStats();switch(m.removeClass("state-"+w),m.addClass("state-"+a),a){case"pedding":j.addClass("element-invisible"),k.addClass("element-invisible"),o.removeClass("element-invisible"),q.hide(),l.hide(),f.refresh();break;case"ready":o.addClass("element-invisible"),j.removeClass("element-invisible"),k.removeClass("element-invisible"),q.hide(),l.show(),m.text(lang.uploadStart),f.refresh();break;case"uploading":q.show(),l.hide(),m.text(lang.uploadPause);break;case"paused":q.show(),l.hide(),m.text(lang.uploadContinue);break;case"confirm":if(q.show(),l.hide(),m.text(lang.uploadStart),c=f.getStats(),c.successNum&&!c.uploadFailNum)return void d("finish");break;case"finish":q.hide(),l.show(),c.uploadFailNum?m.text(lang.uploadRetry):m.text(lang.uploadStart)}w=a,e()}g.getQueueCount()?m.removeClass("disabled"):m.addClass("disabled")}function e(){var a,b="";"ready"===w?b=lang.updateStatusReady.replace("_",r).replace("_KB",WebUploader.formatSize(s)):"confirm"===w?(a=f.getStats(),a.uploadFailNum&&(b=lang.updateStatusConfirm.replace("_",a.successNum).replace("_",a.successNum))):(a=f.getStats(),b=lang.updateStatusFinish.replace("_",r).replace("_KB",WebUploader.formatSize(s)).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"),q=k.find(".progress").hide(),r=0,s=0,t=window.devicePixelRatio||1,u=113*t,v=113*t,w="",x={},y=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}(),z=editor.getActionUrl(editor.getOpt("audioActionName")),A=editor.getOpt("audioMaxSize"),B=(editor.getOpt("audioAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return m.hide(),WebUploader.Uploader.support()?editor.getOpt("audioActionName")?(f=g.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:z,fileVal:editor.getOpt("audioFieldName"),duplicate:!0,fileSingleSizeLimit:A,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||B.indexOf(a.ext.toLowerCase())==-1)}),f.on("fileQueued",function(b){r++,s+=b.size,1===r&&(o.addClass("element-invisible"),k.show()),a(b);const c=editor.getOpt("uploadFunction");"function"==typeof c&&("ready"===w?d("uploading"):"pedding"===w&&(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){r--,s-=a.size,b(a),c()}),f.on("filesQueued",function(a){f.isInProgress()||"pedding"!=w&&"finish"!=w&&"confirm"!=w&&"ready"!=w||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(z+(z.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){z.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+"%"),x[a.id][1]=b,c()}),f.on("uploadSuccess",function(a,b){var c=h("#"+a.id);try{"SUCCESS"==b.state?(p.push({url:b.url,type:b.type,original:b.original}),c.append('<span class="success"></span>')):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"===w?f.upload():"paused"===w?f.upload():"uploading"===w&&f.stop())}),m.addClass("state-"+w),void c()):void h("#filePickerReady").after(h("<div>").html(lang.errorLoadConfig)).hide():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},refresh:function(){this.uploader.refresh()}}}();
|
|
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("audioSelect").style.display="inline-block",domUtils.on($G("audioSelect"),"click",function(e){editorOpt.selectCallback(editor,function(info){info&&($G("audioUrl").value=info.path,createPreview(info.path))})}))}function initAudio(){createAlignButton(["audioFloat","upload_alignment"]),addUrlChangeListener($G("audioUrl")),addOkListener(),function(){var url,img=editor.selection.getRange().getClosedNode();if(img&&img.className){var hasFakedClass="edui-faked-audio"==img.className,hasUploadClass=img.className.indexOf("edui-upload-audio")!=-1;if(hasFakedClass||hasUploadClass){$G("audioUrl").value=url=img.getAttribute("_url");var align=domUtils.getComputedStyle(img,"float"),parentAlign=domUtils.getComputedStyle(img.parentNode,"text-align");updateAlignButton("center"===parentAlign?"center":align)}hasUploadClass&&(isModifyUploadaudio=!0)}createPreview(url)}()}function addOkListener(){dialog.onok=function(){$G("preview").innerHTML="";var currentTab=findFocus("tabHeads","tabSrc");switch(currentTab){case"audio":return insertSingle();case"upload":return insertUpload()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function updateAlignButton(align){for(var ci,aligns=$G("audioFloat").children,i=0;ci=aligns[i++];)ci.getAttribute("name")==align?"focus"!=ci.className&&(ci.className="focus"):"focus"==ci.className&&(ci.className="")}function insertSingle(){var url=$G("audioUrl").value;findFocus("audioFloat","name");return!!url&&void editor.execCommand("insertaudio",{url:url},isModifyUploadaudio?"upload":null)}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 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(){createPreview(this.value)}:url.addEventListener("input",function(){createPreview(this.value)},!1)}function createAudioHtml(url,param){param=param||{};var str=["<audio",param.id?' id="'+param.id+'"':"",param.cls?' class="'+param.cls+'"':""," controls >",'<source src="'+url+'" type="audio/mpeg" />',"</audio>"];return str.join("")}function createPreview(url){url&&($G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;"><div style="text-align:center;flex-grow:1;">'+createAudioHtml(url)+"</div></div>")}function insertUpload(){var audioObjs=[],uploadDir=editor.getOpt("audioUrlPrefix"),align=findFocus("upload_alignment","name")||"none";for(var key in uploadaudioList){var file=uploadaudioList[key];audioObjs.push({url:uploadDir+file.url,align:align})}var count=uploadFile.getQueueCount();return count?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,count)+"</span>"),!1):void editor.execCommand("insertaudio",audioObjs,"upload")}function initUpload(){uploadFile=new UploadFile("queueList")}function UploadFile(target){this.$wrap=target.constructor==String?$("#"+target):$(target),this.init()}var uploadFile,uploadaudioList=[],isModifyUploadaudio=!1,editorOpt={};window.onload=function(){editorOpt=editor.getOpt("audioConfig"),$focus($G("audioUrl")),initTabs(),initAudio(),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("audioActionName")),fileMaxSize=editor.getOpt("audioMaxSize"),acceptExtensions=(editor.getOpt("audioAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return $upload.hide(),WebUploader.Uploader.support()?editor.getOpt("audioActionName")?(uploader=_this.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:actionUrl,fileVal:editor.getOpt("audioFieldName"),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?(uploadaudioList.push({url:json.url,type:json.type,original:json.original}),$file.append('<span class="success"></span>')):$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()}}}();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
|
5
|
-
<script type="text/javascript" src="../internal.js?
|
|
5
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
6
6
|
<link rel="stylesheet" type="text/css" href="background.css?982ee6c2">
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
</div>
|
|
55
55
|
</div>
|
|
56
56
|
</div>
|
|
57
|
-
<script type="text/javascript" src="background.js?
|
|
57
|
+
<script type="text/javascript" src="background.js?8ab58061"></script>
|
|
58
58
|
</body>
|
|
59
59
|
</html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
!function(){function initTabs(){for(var
|
|
2
|
+
!function(){function initTabs(){for(var tabs=$G("tabHeads").children,i=0;i<tabs.length;i++)domUtils.on(tabs[i],"click",function(e){for(var target=e.target||e.srcElement,j=0;j<tabs.length;j++)if(tabs[j]==target){tabs[j].className="focus";var contentId=tabs[j].getAttribute("data-content-id");$G(contentId).style.display="block"}else tabs[j].className="",$G(tabs[j].getAttribute("data-content-id")).style.display="none"})}function initColorSelector(){var obj=editor.queryCommandValue("background");if(obj){var color=obj["background-color"],repeat=obj["background-repeat"]||"repeat",image=obj["background-image"]||"",position=obj["background-position"]||"center center",pos=position.split(" "),x=parseInt(pos[0])||0,y=parseInt(pos[1])||0;"no-repeat"==repeat&&(x||y)&&(repeat="self"),image=image.match(/url[\s]*\(([^\)]*)\)/),image=image?image[1]:"",updateFormState("colored",color,image,repeat,x,y)}else updateFormState();var updateHandler=function(){updateFormState(),updateBackground()};domUtils.on($G("nocolorRadio"),"click",updateBackground),domUtils.on($G("coloredRadio"),"click",updateHandler),domUtils.on($G("url"),"keyup",function(){$G("url").value&&"none"==$G("alignment").style.display&&utils.each($G("repeatType").children,function(item){item.selected="repeat"==item.getAttribute("value")&&"selected"}),updateHandler()}),domUtils.on($G("repeatType"),"change",updateHandler),domUtils.on($G("x"),"keyup",updateBackground),domUtils.on($G("y"),"keyup",updateBackground),initColorPicker()}function initColorPicker(){var me=editor,cp=$G("colorPicker"),popup=new UE.ui.Popup({content:new UE.ui.ColorPicker({noColorText:me.getLang("clearColor"),editor:me,onpickcolor:function(t,color){updateFormState("colored",color),updateBackground(),UE.ui.Popup.postHide()},onpicknocolor:function(t,color){updateFormState("colored","transparent"),updateBackground(),UE.ui.Popup.postHide()}}),editor:me,onhide:function(){}});domUtils.on(cp,"click",function(){popup.showAnchor(this)}),domUtils.on(document,"mousedown",function(evt){var el=evt.target||evt.srcElement;UE.ui.Popup.postHide(el)}),domUtils.on(window,"scroll",function(){UE.ui.Popup.postHide()})}function updateFormState(radio,color,url,align,x,y){var nocolorRadio=$G("nocolorRadio"),coloredRadio=$G("coloredRadio");if(radio&&(nocolorRadio.checked="colored"!=radio&&"checked",coloredRadio.checked="colored"==radio&&"checked"),color&&domUtils.setStyle($G("colorPicker"),"background-color",color),url&&/^\//.test(url)){var a=document.createElement("a");a.href=url,browser.ie&&(a.href=a.href),url=browser.ie?a.href:a.protocol+"//"+a.host+a.pathname+a.search+a.hash}(url||""===url)&&($G("url").value=url),align&&utils.each($G("repeatType").children,function(item){item.selected=align==item.getAttribute("value")&&"selected"}),(x||y)&&($G("x").value=parseInt(x)||0,$G("y").value=parseInt(y)||0),$G("alignment").style.display=coloredRadio.checked&&$G("url").value?"":"none",$G("custom").style.display=coloredRadio.checked&&$G("url").value&&"self"==$G("repeatType").value?"":"none"}function updateBackground(){if($G("coloredRadio").checked){var color=domUtils.getStyle($G("colorPicker"),"background-color"),bgimg=$G("url").value,align=$G("repeatType").value,backgroundObj={"background-repeat":"no-repeat","background-position":"center center"};color&&(backgroundObj["background-color"]=color),bgimg&&(backgroundObj["background-image"]="url("+bgimg+")"),"self"==align?backgroundObj["background-position"]=$G("x").value+"px "+$G("y").value+"px":"repeat-x"!=align&&"repeat-y"!=align&&"repeat"!=align||(backgroundObj["background-repeat"]=align),editor.execCommand("background",backgroundObj)}else editor.execCommand("background",null)}function OnlineImage(target){this.container=utils.isString(target)?document.getElementById(target):target,this.init()}var onlineImage,backupStyle=editor.queryCommandValue("background");window.onload=function(){initTabs(),initColorSelector()},OnlineImage.prototype={init:function(){this.reset(),this.initEvents()},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.id="imageListUl",this.list.appendChild(this.clearFloat),this.container.appendChild(this.list)},initEvents:function(){var _this=this;domUtils.on($G("imageList"),"scroll",function(e){var panel=this;panel.scrollHeight-(panel.offsetHeight+panel.scrollTop)<10&&_this.getImageData()}),domUtils.on(this.container,"click",function(e){var target=e.target||e.srcElement,li=target.parentNode,nodes=$G("imageListUl").childNodes;if("li"==li.tagName.toLowerCase()){updateFormState("nocolor",null,"");for(var node,i=0;node=nodes[i++];)node!=li||domUtils.hasClass(node,"selected")?domUtils.removeClasses(node,"selected"):(domUtils.addClass(node,"selected"),updateFormState("colored",null,li.firstChild.getAttribute("_src"),"repeat"));updateBackground()}})},initData:function(){this.state=0,this.listSize=editor.getOpt("imageManagerListSize"),this.listIndex=0,this.listEnd=!1,this.getImageData()},reset:function(){this.initContainer(),this.initData()},getImageData:function(){var _this=this;if(!_this.listEnd&&!this.isLoadingData){this.isLoadingData=!0;var url=editor.getActionUrl(editor.getOpt("imageManagerActionName")),isJsonp=utils.isCrossDomainUrl(url);ajax.request(url,{timeout:1e5,dataType:isJsonp?"jsonp":"",data:utils.extend({start:this.listIndex,size:this.listSize},editor.queryCommandValue("serverparam")),headers:editor.options.serverHeaders||{},method:"get",onsuccess:function(r){try{var json=isJsonp?r: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(list){var i,item,img,icon,_this=this,urlPrefix=editor.getOpt("imageManagerUrlPrefix");for(i=0;i<list.length;i++)list[i]&&list[i].url&&(item=document.createElement("li"),img=document.createElement("img"),icon=document.createElement("span"),domUtils.on(img,"load",function(image){return function(){_this.scale(image,image.parentNode.offsetWidth,image.parentNode.offsetHeight)}}(img)),img.width=113,img.setAttribute("src",urlPrefix+list[i].url+(list[i].url.indexOf("?")==-1?"?noCache=":"&noCache=")+(+new Date).toString(36)),img.setAttribute("_src",urlPrefix+list[i].url),domUtils.addClass(icon,"icon"),item.appendChild(img),item.appendChild(icon),this.list.insertBefore(item,this.clearFloat))},scale:function(img,w,h,type){var ow=img.width,oh=img.height;"justify"==type?ow>=oh?(img.width=w,img.height=h*oh/ow,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w*ow/oh,img.height=h,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px"):ow>=oh?(img.width=w*ow/oh,img.height=h,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w,img.height=h*oh/ow,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px")},getInsertList:function(){var i,lis=this.list.children,list=[],align=getAlign();for(i=0;i<lis.length;i++)if(domUtils.hasClass(lis[i],"selected")){var img=lis[i].firstChild,src=img.getAttribute("_src");list.push({src:src,_src:src,floatStyle:align})}return list}},dialog.onok=function(){updateBackground(),editor.fireEvent("saveScene")},dialog.oncancel=function(){editor.execCommand("background",backupStyle)}}();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<head>
|
|
3
3
|
<title></title>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
|
5
|
-
<script type="text/javascript" src="../internal.js?
|
|
5
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
6
6
|
<style type="text/css">
|
|
7
7
|
.wrapper {
|
|
8
8
|
width: 600px;
|
|
@@ -161,10 +161,10 @@
|
|
|
161
161
|
</div>
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
164
|
-
<script src="../../third-party/jquery-3.5.1.js?
|
|
164
|
+
<script src="../../third-party/jquery-3.5.1.js?cdb3992e"></script>
|
|
165
165
|
<script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
|
|
166
166
|
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
|
|
167
|
-
<script type="text/javascript" src="contentimport.js?
|
|
167
|
+
<script type="text/javascript" src="contentimport.js?e0504ca5"></script>
|
|
168
168
|
<script type="text/javascript">
|
|
169
169
|
utils.domReady(function () {
|
|
170
170
|
var options = {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
function processWord(
|
|
2
|
+
function processWord(file){$(".file-tip").html("正在转换Word文件,请稍后..."),$(".file-result").html("").hide();var reader=new FileReader;reader.onload=function(loadEvent){mammoth.convertToHtml({arrayBuffer:loadEvent.target.result}).then(function(result){$(".file-tip").html("转换成功"),contentImport.data.result=result.value,$(".file-result").html(result.value).show()},function(error){$(".file-tip").html("Word文件转换失败:"+error)})},reader.onerror=function(loadEvent){$(".file-tip").html("Word文件转换失败:"+loadEvent)},reader.readAsArrayBuffer(file)}function processMarkdown(markdown){var converter=new showdown.Converter,html=converter.makeHtml(markdown);$(".file-tip").html("转换成功"),contentImport.data.result=html,$(".file-result").html(html).show()}function processMarkdownFile(file){$(".file-tip").html("正在转换Markdown文件,请稍后..."),$(".file-result").html("").hide();var reader=new FileReader;reader.onload=function(loadEvent){processMarkdown(loadEvent.target.result)},reader.onerror=function(loadEvent){$(".file-tip").html("Markdown文件转换失败:"+loadEvent)},reader.readAsText(file,"UTF-8")}function addUploadButtonListener(){g("contentImport").addEventListener("change",function(){const file=this.files[0],fileName=file.name,fileExt=fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();switch(fileExt){case"docx":case"doc":processWord(file);break;case"md":processMarkdownFile(file);break;default:$(".file-tip").html("不支持的文件格式:"+fileExt)}}),g("fileInputConfirm").addEventListener("click",function(){processMarkdown(g("fileInputContent").value),$(".file-input").hide()})}function addOkListener(){dialog.onok=function(){return contentImport.data.result?(editor.fireEvent("saveScene"),editor.execCommand("inserthtml",contentImport.data.result),void editor.fireEvent("saveScene")):(alert("请先上传文件识别内容"),!1)},dialog.oncancel=function(){}}var contentImport={},g=$G;contentImport.data={result:null},contentImport.init=function(opt,callbacks){addUploadButtonListener(),addOkListener()};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<title></title>
|
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
6
6
|
<meta name="robots" content="noindex, nofollow"/>
|
|
7
|
-
<script type="text/javascript" src="../internal.js?
|
|
7
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
8
8
|
<link rel="stylesheet" type="text/css" href="emotion.css?f71063c6">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<div id="tabIconReview">
|
|
32
32
|
<img id='faceReview' class='review' src="../../themes/default/images/spacer.gif"/>
|
|
33
33
|
</div>
|
|
34
|
-
<script type="text/javascript" src="emotion.js?
|
|
34
|
+
<script type="text/javascript" src="emotion.js?ce619d40"></script>
|
|
35
35
|
<script type="text/javascript">
|
|
36
36
|
var emotion = {
|
|
37
37
|
tabNum: 7, //切换面板数量
|