@lingxiteam/lcdp-ueditor-react 1.0.2 → 1.0.3-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/LcdpUeditor.d.ts.map +1 -1
- package/es/LcdpUeditor.js +2 -1
- package/es/tools/UeditorResourceLoader.d.ts +1 -1
- package/es/tools/UeditorResourceLoader.d.ts.map +1 -1
- package/es/tools/UeditorResourceLoader.js +18 -7
- package/es/tools/filterHtmlNode.d.ts.map +1 -1
- package/es/tools/filterHtmlNode.js +7 -2
- package/lib/LcdpUeditor.js +1 -3
- package/lib/tools/UeditorResourceLoader.d.ts +1 -1
- package/lib/tools/UeditorResourceLoader.js +15 -7
- 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.css +2 -715
- package/ueditor-resource/dialogs/attachment/attachment.html +6 -6
- package/ueditor-resource/dialogs/attachment/attachment.js +2 -803
- package/ueditor-resource/dialogs/audio/audio.css +2 -878
- package/ueditor-resource/dialogs/audio/audio.js +2 -815
- package/ueditor-resource/dialogs/background/background.css +2 -192
- package/ueditor-resource/dialogs/background/background.html +3 -3
- package/ueditor-resource/dialogs/background/background.js +2 -370
- package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
- package/ueditor-resource/dialogs/contentimport/contentimport.js +2 -91
- package/ueditor-resource/dialogs/emotion/emotion.css +2 -128
- package/ueditor-resource/dialogs/emotion/emotion.html +3 -3
- package/ueditor-resource/dialogs/emotion/emotion.js +2 -186
- package/ueditor-resource/dialogs/formula/formula.html +4 -4
- package/ueditor-resource/dialogs/formula/formula.js +2 -147
- package/ueditor-resource/dialogs/help/help.css +2 -36
- package/ueditor-resource/dialogs/help/help.html +3 -3
- package/ueditor-resource/dialogs/help/help.js +2 -57
- package/ueditor-resource/dialogs/image/image.css +2 -767
- package/ueditor-resource/dialogs/image/image.js +2 -1060
- package/ueditor-resource/dialogs/insertframe/insertframe.html +2 -2
- package/ueditor-resource/dialogs/internal.js +2 -81
- package/ueditor-resource/dialogs/preview/preview.html +2 -2
- package/ueditor-resource/dialogs/scrawl/scrawl.css +2 -323
- package/ueditor-resource/dialogs/scrawl/scrawl.html +3 -3
- package/ueditor-resource/dialogs/scrawl/scrawl.js +2 -682
- package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
- package/ueditor-resource/dialogs/searchreplace/searchreplace.js +2 -174
- package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
- package/ueditor-resource/dialogs/spechars/spechars.js +2 -86
- package/ueditor-resource/dialogs/table/edittable.css +2 -84
- package/ueditor-resource/dialogs/table/edittable.html +3 -3
- package/ueditor-resource/dialogs/table/edittable.js +2 -241
- package/ueditor-resource/dialogs/table/edittd.html +1 -1
- package/ueditor-resource/dialogs/table/edittip.html +1 -1
- package/ueditor-resource/dialogs/template/config.js +2 -42
- package/ueditor-resource/dialogs/template/template.css +2 -98
- package/ueditor-resource/dialogs/template/template.html +4 -4
- package/ueditor-resource/dialogs/template/template.js +2 -53
- package/ueditor-resource/dialogs/video/video.css +2 -908
- package/ueditor-resource/dialogs/video/video.js +2 -867
- package/ueditor-resource/dialogs/wordimage/wordimage.html +5 -5
- package/ueditor-resource/dialogs/wordimage/wordimage.js +2 -93
- package/ueditor-resource/lang/en/en.js +2 -686
- package/ueditor-resource/lang/zh-cn/zh-cn.js +2 -748
- package/ueditor-resource/lang/zh-tw/zh-tw.js +2 -748
- package/ueditor-resource/plugins/demo/demo.js +1 -3
- package/ueditor-resource/themes/default/css/ueditor.css +2 -2148
- package/ueditor-resource/themes/default/dialog.css +2 -16
- package/ueditor-resource/themes/default/dialogbase.css +2 -131
- package/ueditor-resource/themes/iframe.css +2 -62
- package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +4 -3655
- package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +3 -1
- package/ueditor-resource/third-party/clipboard/clipboard.js +2 -753
- package/ueditor-resource/third-party/codemirror/codemirror.css +2 -105
- package/ueditor-resource/third-party/codemirror/codemirror.js +3 -3581
- package/ueditor-resource/third-party/jquery-3.5.1.js +4 -2
- package/ueditor-resource/third-party/jquery-3.5.1_1.js +4 -4314
- package/ueditor-resource/third-party/webuploader/webuploader.css +2 -87
- package/ueditor-resource/third-party/webuploader/webuploader.js +5 -4
- package/ueditor-resource/ueditor.all.js +20 -32644
- package/ueditor-resource/ueditor.config.js +2 -655
- package/ueditor-resource/ueditor.parse.js +2 -639
|
@@ -1,682 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Created with JetBrains PhpStorm.
|
|
3
|
-
* User: xuheng
|
|
4
|
-
* Date: 12-5-22
|
|
5
|
-
* Time: 上午11:38
|
|
6
|
-
* To change this template use File | Settings | File Templates.
|
|
7
|
-
*/
|
|
8
|
-
var scrawl = function (options) {
|
|
9
|
-
options && this.initOptions(options);
|
|
10
|
-
};
|
|
11
|
-
(function () {
|
|
12
|
-
var canvas = $G("J_brushBoard"),
|
|
13
|
-
context = canvas.getContext('2d'),
|
|
14
|
-
drawStep = [], //undo redo存储
|
|
15
|
-
drawStepIndex = 0; //undo redo指针
|
|
16
|
-
|
|
17
|
-
scrawl.prototype = {
|
|
18
|
-
isScrawl: false, //是否涂鸦
|
|
19
|
-
brushWidth: -1, //画笔粗细
|
|
20
|
-
brushColor: "", //画笔颜色
|
|
21
|
-
|
|
22
|
-
initOptions: function (options) {
|
|
23
|
-
var me = this;
|
|
24
|
-
me.originalState(options);//初始页面状态
|
|
25
|
-
me._buildToolbarColor(options.colorList);//动态生成颜色选择集合
|
|
26
|
-
|
|
27
|
-
me._addBoardListener(options.saveNum);//添加画板处理
|
|
28
|
-
me._addOPerateListener(options.saveNum);//添加undo redo clearBoard处理
|
|
29
|
-
me._addColorBarListener();//添加颜色选择处理
|
|
30
|
-
me._addBrushBarListener();//添加画笔大小处理
|
|
31
|
-
me._addEraserBarListener();//添加橡皮大小处理
|
|
32
|
-
me._addAddImgListener();//添加增添背景图片处理
|
|
33
|
-
me._addRemoveImgListenter();//删除背景图片处理
|
|
34
|
-
me._addScalePicListenter();//添加缩放处理
|
|
35
|
-
me._addClearSelectionListenter();//添加清楚选中状态处理
|
|
36
|
-
|
|
37
|
-
me._originalColorSelect(options.drawBrushColor);//初始化颜色选中
|
|
38
|
-
me._originalBrushSelect(options.drawBrushSize);//初始化画笔选中
|
|
39
|
-
me._clearSelection();//清楚选中状态
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
originalState: function (options) {
|
|
43
|
-
var me = this;
|
|
44
|
-
|
|
45
|
-
me.brushWidth = options.drawBrushSize;//同步画笔粗细
|
|
46
|
-
me.brushColor = options.drawBrushColor;//同步画笔颜色
|
|
47
|
-
|
|
48
|
-
context.lineWidth = me.brushWidth;//初始画笔大小
|
|
49
|
-
context.strokeStyle = me.brushColor;//初始画笔颜色
|
|
50
|
-
context.fillStyle = "transparent";//初始画布背景颜色
|
|
51
|
-
context.lineCap = "round";//去除锯齿
|
|
52
|
-
context.fill();
|
|
53
|
-
},
|
|
54
|
-
_buildToolbarColor: function (colorList) {
|
|
55
|
-
var tmp = null, arr = [];
|
|
56
|
-
arr.push("<table id='J_colorList'>");
|
|
57
|
-
for (var i = 0, color; color = colorList[i++];) {
|
|
58
|
-
if ((i - 1) % 5 == 0) {
|
|
59
|
-
if (i != 1) {
|
|
60
|
-
arr.push("</tr>");
|
|
61
|
-
}
|
|
62
|
-
arr.push("<tr>");
|
|
63
|
-
}
|
|
64
|
-
tmp = '#' + color;
|
|
65
|
-
arr.push("<td><a title='" + tmp + "' href='javascript:void(0)' style='background-color:" + tmp + "'></a></td>");
|
|
66
|
-
}
|
|
67
|
-
arr.push("</tr></table>");
|
|
68
|
-
$G("J_colorBar").innerHTML = arr.join("");
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
_addBoardListener: function (saveNum) {
|
|
72
|
-
var me = this,
|
|
73
|
-
margin = 0,
|
|
74
|
-
startX = -1,
|
|
75
|
-
startY = -1,
|
|
76
|
-
isMouseDown = false,
|
|
77
|
-
isMouseMove = false,
|
|
78
|
-
isMouseUp = false,
|
|
79
|
-
buttonPress = 0, button, flag = '';
|
|
80
|
-
|
|
81
|
-
margin = parseInt(domUtils.getComputedStyle($G("J_wrap"), "margin-left"));
|
|
82
|
-
drawStep.push(context.getImageData(0, 0, context.canvas.width, context.canvas.height));
|
|
83
|
-
drawStepIndex += 1;
|
|
84
|
-
|
|
85
|
-
domUtils.on(canvas, ["mousedown", "mousemove", "mouseup", "mouseout"], function (e) {
|
|
86
|
-
button = browser.webkit ? e.which : buttonPress;
|
|
87
|
-
switch (e.type) {
|
|
88
|
-
case 'mousedown':
|
|
89
|
-
buttonPress = 1;
|
|
90
|
-
flag = 1;
|
|
91
|
-
isMouseDown = true;
|
|
92
|
-
isMouseUp = false;
|
|
93
|
-
isMouseMove = false;
|
|
94
|
-
me.isScrawl = true;
|
|
95
|
-
startX = e.clientX - margin;//10为外边距总和
|
|
96
|
-
startY = e.clientY - margin;
|
|
97
|
-
context.beginPath();
|
|
98
|
-
break;
|
|
99
|
-
case 'mousemove' :
|
|
100
|
-
if (!flag && button == 0) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (!flag && button) {
|
|
104
|
-
startX = e.clientX - margin;//10为外边距总和
|
|
105
|
-
startY = e.clientY - margin;
|
|
106
|
-
context.beginPath();
|
|
107
|
-
flag = 1;
|
|
108
|
-
}
|
|
109
|
-
if (isMouseUp || !isMouseDown) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
var endX = e.clientX - margin,
|
|
113
|
-
endY = e.clientY - margin;
|
|
114
|
-
|
|
115
|
-
context.moveTo(startX, startY);
|
|
116
|
-
context.lineTo(endX, endY);
|
|
117
|
-
context.stroke();
|
|
118
|
-
startX = endX;
|
|
119
|
-
startY = endY;
|
|
120
|
-
isMouseMove = true;
|
|
121
|
-
break;
|
|
122
|
-
case 'mouseup':
|
|
123
|
-
buttonPress = 0;
|
|
124
|
-
if (!isMouseDown) return;
|
|
125
|
-
if (!isMouseMove) {
|
|
126
|
-
context.arc(startX, startY, context.lineWidth, 0, Math.PI * 2, false);
|
|
127
|
-
context.fillStyle = context.strokeStyle;
|
|
128
|
-
context.fill();
|
|
129
|
-
}
|
|
130
|
-
context.closePath();
|
|
131
|
-
me._saveOPerate(saveNum);
|
|
132
|
-
isMouseDown = false;
|
|
133
|
-
isMouseMove = false;
|
|
134
|
-
isMouseUp = true;
|
|
135
|
-
startX = -1;
|
|
136
|
-
startY = -1;
|
|
137
|
-
break;
|
|
138
|
-
case 'mouseout':
|
|
139
|
-
flag = '';
|
|
140
|
-
buttonPress = 0;
|
|
141
|
-
if (button == 1) return;
|
|
142
|
-
context.closePath();
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
_addOPerateListener: function (saveNum) {
|
|
148
|
-
var me = this;
|
|
149
|
-
domUtils.on($G("J_previousStep"), "click", function () {
|
|
150
|
-
if (drawStepIndex > 1) {
|
|
151
|
-
drawStepIndex -= 1;
|
|
152
|
-
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|
153
|
-
context.putImageData(drawStep[drawStepIndex - 1], 0, 0);
|
|
154
|
-
me.btn2Highlight("J_nextStep");
|
|
155
|
-
drawStepIndex == 1 && me.btn2disable("J_previousStep");
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
domUtils.on($G("J_nextStep"), "click", function () {
|
|
159
|
-
if (drawStepIndex > 0 && drawStepIndex < drawStep.length) {
|
|
160
|
-
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|
161
|
-
context.putImageData(drawStep[drawStepIndex], 0, 0);
|
|
162
|
-
drawStepIndex += 1;
|
|
163
|
-
me.btn2Highlight("J_previousStep");
|
|
164
|
-
drawStepIndex == drawStep.length && me.btn2disable("J_nextStep");
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
domUtils.on($G("J_clearBoard"), "click", function () {
|
|
168
|
-
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|
169
|
-
drawStep = [];
|
|
170
|
-
me._saveOPerate(saveNum);
|
|
171
|
-
drawStepIndex = 1;
|
|
172
|
-
me.isScrawl = false;
|
|
173
|
-
me.btn2disable("J_previousStep");
|
|
174
|
-
me.btn2disable("J_nextStep");
|
|
175
|
-
me.btn2disable("J_clearBoard");
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
_addColorBarListener: function () {
|
|
179
|
-
var me = this;
|
|
180
|
-
domUtils.on($G("J_colorBar"), "click", function (e) {
|
|
181
|
-
var target = me.getTarget(e),
|
|
182
|
-
color = target.title;
|
|
183
|
-
if (!!color) {
|
|
184
|
-
me._addColorSelect(target);
|
|
185
|
-
|
|
186
|
-
me.brushColor = color;
|
|
187
|
-
context.globalCompositeOperation = "source-over";
|
|
188
|
-
context.lineWidth = me.brushWidth;
|
|
189
|
-
context.strokeStyle = color;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
_addBrushBarListener: function () {
|
|
194
|
-
var me = this;
|
|
195
|
-
domUtils.on($G("J_brushBar"), "click", function (e) {
|
|
196
|
-
var target = me.getTarget(e),
|
|
197
|
-
size = browser.ie ? target.innerText : target.text;
|
|
198
|
-
if (!!size) {
|
|
199
|
-
me._addBESelect(target);
|
|
200
|
-
|
|
201
|
-
context.globalCompositeOperation = "source-over";
|
|
202
|
-
context.lineWidth = parseInt(size);
|
|
203
|
-
context.strokeStyle = me.brushColor;
|
|
204
|
-
me.brushWidth = context.lineWidth;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
_addEraserBarListener: function () {
|
|
209
|
-
var me = this;
|
|
210
|
-
domUtils.on($G("J_eraserBar"), "click", function (e) {
|
|
211
|
-
var target = me.getTarget(e),
|
|
212
|
-
size = browser.ie ? target.innerText : target.text;
|
|
213
|
-
if (!!size) {
|
|
214
|
-
me._addBESelect(target);
|
|
215
|
-
|
|
216
|
-
context.lineWidth = parseInt(size);
|
|
217
|
-
context.globalCompositeOperation = "destination-out";
|
|
218
|
-
context.strokeStyle = "#FFF";
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
_addAddImgListener: function () {
|
|
223
|
-
var file = $G("J_imgTxt");
|
|
224
|
-
if (!window.FileReader) {
|
|
225
|
-
$G("J_addImg").style.display = 'none';
|
|
226
|
-
$G("J_removeImg").style.display = 'none';
|
|
227
|
-
$G("J_sacleBoard").style.display = 'none';
|
|
228
|
-
}
|
|
229
|
-
domUtils.on(file, "change", function (e) {
|
|
230
|
-
var frm = file.parentNode;
|
|
231
|
-
addMaskLayer(lang.backgroundUploading);
|
|
232
|
-
|
|
233
|
-
var target = e.target || e.srcElement,
|
|
234
|
-
reader = new FileReader();
|
|
235
|
-
reader.onload = function (evt) {
|
|
236
|
-
var target = evt.target || evt.srcElement;
|
|
237
|
-
ue_callback(target.result, 'SUCCESS');
|
|
238
|
-
};
|
|
239
|
-
reader.readAsDataURL(target.files[0]);
|
|
240
|
-
frm.reset();
|
|
241
|
-
});
|
|
242
|
-
},
|
|
243
|
-
_addRemoveImgListenter: function () {
|
|
244
|
-
var me = this;
|
|
245
|
-
domUtils.on($G("J_removeImg"), "click", function () {
|
|
246
|
-
$G("J_picBoard").innerHTML = "";
|
|
247
|
-
me.btn2disable("J_removeImg");
|
|
248
|
-
me.btn2disable("J_sacleBoard");
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
_addScalePicListenter: function () {
|
|
252
|
-
domUtils.on($G("J_sacleBoard"), "click", function () {
|
|
253
|
-
var picBoard = $G("J_picBoard"),
|
|
254
|
-
scaleCon = $G("J_scaleCon"),
|
|
255
|
-
img = picBoard.children[0];
|
|
256
|
-
|
|
257
|
-
if (img) {
|
|
258
|
-
if (!scaleCon) {
|
|
259
|
-
picBoard.style.cssText = "position:relative;z-index:999;" + picBoard.style.cssText;
|
|
260
|
-
img.style.cssText = "position: absolute;top:" + (canvas.height - img.height) / 2 + "px;left:" + (canvas.width - img.width) / 2 + "px;";
|
|
261
|
-
var scale = new ScaleBoy();
|
|
262
|
-
picBoard.appendChild(scale.init());
|
|
263
|
-
scale.startScale(img);
|
|
264
|
-
} else {
|
|
265
|
-
if (scaleCon.style.visibility == "visible") {
|
|
266
|
-
scaleCon.style.visibility = "hidden";
|
|
267
|
-
picBoard.style.position = "";
|
|
268
|
-
picBoard.style.zIndex = "";
|
|
269
|
-
} else {
|
|
270
|
-
scaleCon.style.visibility = "visible";
|
|
271
|
-
picBoard.style.cssText += "position:relative;z-index:999";
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
_addClearSelectionListenter: function () {
|
|
278
|
-
var doc = document;
|
|
279
|
-
domUtils.on(doc, 'mousemove', function (e) {
|
|
280
|
-
if (browser.ie && browser.version < 11)
|
|
281
|
-
doc.selection.clear();
|
|
282
|
-
else
|
|
283
|
-
window.getSelection().removeAllRanges();
|
|
284
|
-
});
|
|
285
|
-
},
|
|
286
|
-
_clearSelection: function () {
|
|
287
|
-
var list = ["J_operateBar", "J_colorBar", "J_brushBar", "J_eraserBar", "J_picBoard"];
|
|
288
|
-
for (var i = 0, group; group = list[i++];) {
|
|
289
|
-
domUtils.unSelectable($G(group));
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
_saveOPerate: function (saveNum) {
|
|
294
|
-
var me = this;
|
|
295
|
-
if (drawStep.length <= saveNum) {
|
|
296
|
-
if (drawStepIndex < drawStep.length) {
|
|
297
|
-
me.btn2disable("J_nextStep");
|
|
298
|
-
drawStep.splice(drawStepIndex);
|
|
299
|
-
}
|
|
300
|
-
drawStep.push(context.getImageData(0, 0, context.canvas.width, context.canvas.height));
|
|
301
|
-
drawStepIndex = drawStep.length;
|
|
302
|
-
} else {
|
|
303
|
-
drawStep.shift();
|
|
304
|
-
drawStep.push(context.getImageData(0, 0, context.canvas.width, context.canvas.height));
|
|
305
|
-
drawStepIndex = drawStep.length;
|
|
306
|
-
}
|
|
307
|
-
me.btn2Highlight("J_previousStep");
|
|
308
|
-
me.btn2Highlight("J_clearBoard");
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
_originalColorSelect: function (title) {
|
|
312
|
-
var colorList = $G("J_colorList").getElementsByTagName("td");
|
|
313
|
-
for (var j = 0, cell; cell = colorList[j++];) {
|
|
314
|
-
if (cell.children[0].title.toLowerCase() == title) {
|
|
315
|
-
cell.children[0].style.opacity = 1;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
_originalBrushSelect: function (text) {
|
|
320
|
-
var brushList = $G("J_brushBar").children;
|
|
321
|
-
for (var i = 0, ele; ele = brushList[i++];) {
|
|
322
|
-
if (ele.tagName.toLowerCase() == "a") {
|
|
323
|
-
var size = browser.ie ? ele.innerText : ele.text;
|
|
324
|
-
if (size.toLowerCase() == text) {
|
|
325
|
-
ele.style.opacity = 1;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
_addColorSelect: function (target) {
|
|
331
|
-
var me = this,
|
|
332
|
-
colorList = $G("J_colorList").getElementsByTagName("td"),
|
|
333
|
-
eraserList = $G("J_eraserBar").children,
|
|
334
|
-
brushList = $G("J_brushBar").children;
|
|
335
|
-
|
|
336
|
-
for (var i = 0, cell; cell = colorList[i++];) {
|
|
337
|
-
cell.children[0].style.opacity = 0.3;
|
|
338
|
-
}
|
|
339
|
-
for (var k = 0, ele; ele = brushList[k++];) {
|
|
340
|
-
if (ele.tagName.toLowerCase() == "a") {
|
|
341
|
-
ele.style.opacity = 0.3;
|
|
342
|
-
var size = browser.ie ? ele.innerText : ele.text;
|
|
343
|
-
if (size.toLowerCase() == this.brushWidth) {
|
|
344
|
-
ele.style.opacity = 1;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
for (var j = 0, node; node = eraserList[j++];) {
|
|
349
|
-
if (node.tagName.toLowerCase() == "a") {
|
|
350
|
-
node.style.opacity = 0.3;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
target.style.opacity = 1;
|
|
355
|
-
target.blur();
|
|
356
|
-
},
|
|
357
|
-
_addBESelect: function (target) {
|
|
358
|
-
var brushList = $G("J_brushBar").children;
|
|
359
|
-
var eraserList = $G("J_eraserBar").children;
|
|
360
|
-
|
|
361
|
-
for (var i = 0, ele; ele = brushList[i++];) {
|
|
362
|
-
if (ele.tagName.toLowerCase() == "a") {
|
|
363
|
-
ele.style.opacity = 0.3;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
for (var j = 0, node; node = eraserList[j++];) {
|
|
367
|
-
if (node.tagName.toLowerCase() == "a") {
|
|
368
|
-
node.style.opacity = 0.3;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
target.style.opacity = 1;
|
|
373
|
-
target.blur();
|
|
374
|
-
},
|
|
375
|
-
getCanvasData: function () {
|
|
376
|
-
var picContainer = $G("J_picBoard"),
|
|
377
|
-
img = picContainer.children[0];
|
|
378
|
-
if (img) {
|
|
379
|
-
var x, y;
|
|
380
|
-
if (img.style.position == "absolute") {
|
|
381
|
-
x = parseInt(img.style.left);
|
|
382
|
-
y = parseInt(img.style.top);
|
|
383
|
-
} else {
|
|
384
|
-
x = (picContainer.offsetWidth - img.width) / 2;
|
|
385
|
-
y = (picContainer.offsetHeight - img.height) / 2;
|
|
386
|
-
}
|
|
387
|
-
context.globalCompositeOperation = "destination-over";
|
|
388
|
-
context.drawImage(img, x, y, img.width, img.height);
|
|
389
|
-
} else {
|
|
390
|
-
context.globalCompositeOperation = "destination-atop";
|
|
391
|
-
context.fillStyle = "#fff";//重置画布背景白色
|
|
392
|
-
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
393
|
-
}
|
|
394
|
-
try {
|
|
395
|
-
return canvas.toDataURL("image/png").substring(22);
|
|
396
|
-
} catch (e) {
|
|
397
|
-
return "";
|
|
398
|
-
}
|
|
399
|
-
},
|
|
400
|
-
btn2Highlight: function (id) {
|
|
401
|
-
var cur = $G(id);
|
|
402
|
-
cur.className.indexOf("H") == -1 && (cur.className += "H");
|
|
403
|
-
},
|
|
404
|
-
btn2disable: function (id) {
|
|
405
|
-
var cur = $G(id);
|
|
406
|
-
cur.className.indexOf("H") != -1 && (cur.className = cur.className.replace("H", ""));
|
|
407
|
-
},
|
|
408
|
-
getTarget: function (evt) {
|
|
409
|
-
return evt.target || evt.srcElement;
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
})();
|
|
413
|
-
|
|
414
|
-
var ScaleBoy = function () {
|
|
415
|
-
this.dom = null;
|
|
416
|
-
this.scalingElement = null;
|
|
417
|
-
};
|
|
418
|
-
(function () {
|
|
419
|
-
function _appendStyle() {
|
|
420
|
-
var doc = document,
|
|
421
|
-
head = doc.getElementsByTagName('head')[0],
|
|
422
|
-
style = doc.createElement('style'),
|
|
423
|
-
cssText = '.scale{visibility:hidden;cursor:move;position:absolute;left:0;top:0;width:100px;height:50px;background-color:#fff;font-size:0;line-height:0;opacity:.4;filter:Alpha(opacity=40);}'
|
|
424
|
-
+ '.scale span{position:absolute;left:0;top:0;width:6px;height:6px;background-color:#006DAE;}'
|
|
425
|
-
+ '.scale .hand0, .scale .hand7{cursor:nw-resize;}'
|
|
426
|
-
+ '.scale .hand1, .scale .hand6{left:50%;margin-left:-3px;cursor:n-resize;}'
|
|
427
|
-
+ '.scale .hand2, .scale .hand4, .scale .hand7{left:100%;margin-left:-6px;}'
|
|
428
|
-
+ '.scale .hand3, .scale .hand4{top:50%;margin-top:-3px;cursor:w-resize;}'
|
|
429
|
-
+ '.scale .hand5, .scale .hand6, .scale .hand7{margin-top:-6px;top:100%;}'
|
|
430
|
-
+ '.scale .hand2, .scale .hand5{cursor:ne-resize;}';
|
|
431
|
-
style.type = 'text/css';
|
|
432
|
-
|
|
433
|
-
try {
|
|
434
|
-
style.appendChild(doc.createTextNode(cssText));
|
|
435
|
-
} catch (e) {
|
|
436
|
-
style.styleSheet.cssText = cssText;
|
|
437
|
-
}
|
|
438
|
-
head.appendChild(style);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function _getDom() {
|
|
442
|
-
var doc = document,
|
|
443
|
-
hand,
|
|
444
|
-
arr = [],
|
|
445
|
-
scale = doc.createElement('div');
|
|
446
|
-
|
|
447
|
-
scale.id = 'J_scaleCon';
|
|
448
|
-
scale.className = 'scale';
|
|
449
|
-
for (var i = 0; i < 8; i++) {
|
|
450
|
-
arr.push("<span class='hand" + i + "'></span>");
|
|
451
|
-
}
|
|
452
|
-
scale.innerHTML = arr.join("");
|
|
453
|
-
return scale;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
var rect = [
|
|
457
|
-
//[left, top, width, height]
|
|
458
|
-
[1, 1, -1, -1],
|
|
459
|
-
[0, 1, 0, -1],
|
|
460
|
-
[0, 1, 1, -1],
|
|
461
|
-
[1, 0, -1, 0],
|
|
462
|
-
[0, 0, 1, 0],
|
|
463
|
-
[1, 0, -1, 1],
|
|
464
|
-
[0, 0, 0, 1],
|
|
465
|
-
[0, 0, 1, 1]
|
|
466
|
-
];
|
|
467
|
-
ScaleBoy.prototype = {
|
|
468
|
-
init: function () {
|
|
469
|
-
_appendStyle();
|
|
470
|
-
var me = this,
|
|
471
|
-
scale = me.dom = _getDom();
|
|
472
|
-
|
|
473
|
-
me.scaleMousemove.fp = me;
|
|
474
|
-
domUtils.on(scale, 'mousedown', function (e) {
|
|
475
|
-
var target = e.target || e.srcElement;
|
|
476
|
-
me.start = {x: e.clientX, y: e.clientY};
|
|
477
|
-
if (target.className.indexOf('hand') != -1) {
|
|
478
|
-
me.dir = target.className.replace('hand', '');
|
|
479
|
-
}
|
|
480
|
-
domUtils.on(document.body, 'mousemove', me.scaleMousemove);
|
|
481
|
-
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
|
|
482
|
-
});
|
|
483
|
-
domUtils.on(document.body, 'mouseup', function (e) {
|
|
484
|
-
if (me.start) {
|
|
485
|
-
domUtils.un(document.body, 'mousemove', me.scaleMousemove);
|
|
486
|
-
if (me.moved) {
|
|
487
|
-
me.updateScaledElement({
|
|
488
|
-
position: {x: scale.style.left, y: scale.style.top},
|
|
489
|
-
size: {w: scale.style.width, h: scale.style.height}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
delete me.start;
|
|
493
|
-
delete me.moved;
|
|
494
|
-
delete me.dir;
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
return scale;
|
|
498
|
-
},
|
|
499
|
-
startScale: function (objElement) {
|
|
500
|
-
var me = this, Idom = me.dom;
|
|
501
|
-
|
|
502
|
-
Idom.style.cssText = 'visibility:visible;top:' + objElement.style.top + ';left:' + objElement.style.left + ';width:' + objElement.offsetWidth + 'px;height:' + objElement.offsetHeight + 'px;';
|
|
503
|
-
me.scalingElement = objElement;
|
|
504
|
-
},
|
|
505
|
-
updateScaledElement: function (objStyle) {
|
|
506
|
-
var cur = this.scalingElement,
|
|
507
|
-
pos = objStyle.position,
|
|
508
|
-
size = objStyle.size;
|
|
509
|
-
if (pos) {
|
|
510
|
-
typeof pos.x != 'undefined' && (cur.style.left = pos.x);
|
|
511
|
-
typeof pos.y != 'undefined' && (cur.style.top = pos.y);
|
|
512
|
-
}
|
|
513
|
-
if (size) {
|
|
514
|
-
size.w && (cur.style.width = size.w);
|
|
515
|
-
size.h && (cur.style.height = size.h);
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
updateStyleByDir: function (dir, offset) {
|
|
519
|
-
var me = this,
|
|
520
|
-
dom = me.dom, tmp;
|
|
521
|
-
|
|
522
|
-
rect['def'] = [1, 1, 0, 0];
|
|
523
|
-
if (rect[dir][0] != 0) {
|
|
524
|
-
tmp = parseInt(dom.style.left) + offset.x;
|
|
525
|
-
dom.style.left = me._validScaledProp('left', tmp) + 'px';
|
|
526
|
-
}
|
|
527
|
-
if (rect[dir][1] != 0) {
|
|
528
|
-
tmp = parseInt(dom.style.top) + offset.y;
|
|
529
|
-
dom.style.top = me._validScaledProp('top', tmp) + 'px';
|
|
530
|
-
}
|
|
531
|
-
if (rect[dir][2] != 0) {
|
|
532
|
-
tmp = dom.clientWidth + rect[dir][2] * offset.x;
|
|
533
|
-
dom.style.width = me._validScaledProp('width', tmp) + 'px';
|
|
534
|
-
}
|
|
535
|
-
if (rect[dir][3] != 0) {
|
|
536
|
-
tmp = dom.clientHeight + rect[dir][3] * offset.y;
|
|
537
|
-
dom.style.height = me._validScaledProp('height', tmp) + 'px';
|
|
538
|
-
}
|
|
539
|
-
if (dir === 'def') {
|
|
540
|
-
me.updateScaledElement({position: {x: dom.style.left, y: dom.style.top}});
|
|
541
|
-
}
|
|
542
|
-
},
|
|
543
|
-
scaleMousemove: function (e) {
|
|
544
|
-
var me = arguments.callee.fp,
|
|
545
|
-
start = me.start,
|
|
546
|
-
dir = me.dir || 'def',
|
|
547
|
-
offset = {x: e.clientX - start.x, y: e.clientY - start.y};
|
|
548
|
-
|
|
549
|
-
me.updateStyleByDir(dir, offset);
|
|
550
|
-
arguments.callee.fp.start = {x: e.clientX, y: e.clientY};
|
|
551
|
-
arguments.callee.fp.moved = 1;
|
|
552
|
-
},
|
|
553
|
-
_validScaledProp: function (prop, value) {
|
|
554
|
-
var ele = this.dom,
|
|
555
|
-
wrap = $G("J_picBoard");
|
|
556
|
-
|
|
557
|
-
value = isNaN(value) ? 0 : value;
|
|
558
|
-
switch (prop) {
|
|
559
|
-
case 'left':
|
|
560
|
-
return value < 0 ? 0 : (value + ele.clientWidth) > wrap.clientWidth ? wrap.clientWidth - ele.clientWidth : value;
|
|
561
|
-
case 'top':
|
|
562
|
-
return value < 0 ? 0 : (value + ele.clientHeight) > wrap.clientHeight ? wrap.clientHeight - ele.clientHeight : value;
|
|
563
|
-
case 'width':
|
|
564
|
-
return value <= 0 ? 1 : (value + ele.offsetLeft) > wrap.clientWidth ? wrap.clientWidth - ele.offsetLeft : value;
|
|
565
|
-
case 'height':
|
|
566
|
-
return value <= 0 ? 1 : (value + ele.offsetTop) > wrap.clientHeight ? wrap.clientHeight - ele.offsetTop : value;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
})();
|
|
571
|
-
|
|
572
|
-
//后台回调
|
|
573
|
-
function ue_callback(url, state) {
|
|
574
|
-
var doc = document,
|
|
575
|
-
picBorard = $G("J_picBoard"),
|
|
576
|
-
img = doc.createElement("img");
|
|
577
|
-
|
|
578
|
-
//图片缩放
|
|
579
|
-
function scale(img, max, oWidth, oHeight) {
|
|
580
|
-
var width = 0, height = 0, percent, ow = img.width || oWidth, oh = img.height || oHeight;
|
|
581
|
-
if (ow > max || oh > max) {
|
|
582
|
-
if (ow >= oh) {
|
|
583
|
-
if (width = ow - max) {
|
|
584
|
-
percent = (width / ow).toFixed(2);
|
|
585
|
-
img.height = oh - oh * percent;
|
|
586
|
-
img.width = max;
|
|
587
|
-
}
|
|
588
|
-
} else {
|
|
589
|
-
if (height = oh - max) {
|
|
590
|
-
percent = (height / oh).toFixed(2);
|
|
591
|
-
img.width = ow - ow * percent;
|
|
592
|
-
img.height = max;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
//移除遮罩层
|
|
599
|
-
removeMaskLayer();
|
|
600
|
-
//状态响应
|
|
601
|
-
if (state == "SUCCESS") {
|
|
602
|
-
picBorard.innerHTML = "";
|
|
603
|
-
img.onload = function () {
|
|
604
|
-
scale(this, 300);
|
|
605
|
-
picBorard.appendChild(img);
|
|
606
|
-
|
|
607
|
-
var obj = new scrawl();
|
|
608
|
-
obj.btn2Highlight("J_removeImg");
|
|
609
|
-
//trace 2457
|
|
610
|
-
obj.btn2Highlight("J_sacleBoard");
|
|
611
|
-
};
|
|
612
|
-
img.src = url;
|
|
613
|
-
} else {
|
|
614
|
-
alert(state);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
//去掉遮罩层
|
|
619
|
-
function removeMaskLayer() {
|
|
620
|
-
var maskLayer = $G("J_maskLayer");
|
|
621
|
-
maskLayer.className = "maskLayerNull";
|
|
622
|
-
maskLayer.innerHTML = "";
|
|
623
|
-
dialog.buttons[0].setDisabled(false);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
//添加遮罩层
|
|
627
|
-
function addMaskLayer(html) {
|
|
628
|
-
var maskLayer = $G("J_maskLayer");
|
|
629
|
-
dialog.buttons[0].setDisabled(true);
|
|
630
|
-
maskLayer.className = "maskLayer";
|
|
631
|
-
maskLayer.innerHTML = html;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
//执行确认按钮方法
|
|
635
|
-
function exec(scrawlObj) {
|
|
636
|
-
if (scrawlObj.isScrawl) {
|
|
637
|
-
addMaskLayer(lang.scrawlUpLoading);
|
|
638
|
-
var base64 = scrawlObj.getCanvasData();
|
|
639
|
-
if (!!base64) {
|
|
640
|
-
var options = {
|
|
641
|
-
timeout: 100000,
|
|
642
|
-
headers: editor.options.serverHeaders || {},
|
|
643
|
-
onsuccess: function (xhr) {
|
|
644
|
-
if (!scrawlObj.isCancelScrawl) {
|
|
645
|
-
var responseObj;
|
|
646
|
-
responseObj = eval("(" + xhr.responseText + ")");
|
|
647
|
-
if (responseObj.state === "SUCCESS") {
|
|
648
|
-
var imgObj = {},
|
|
649
|
-
url = editor.options.scrawlUrlPrefix + responseObj.url;
|
|
650
|
-
imgObj.src = url;
|
|
651
|
-
imgObj._src = url;
|
|
652
|
-
imgObj.alt = responseObj.original || '';
|
|
653
|
-
editor.execCommand("insertImage", imgObj);
|
|
654
|
-
dialog.close();
|
|
655
|
-
// 触发上传涂鸦事件
|
|
656
|
-
editor.fireEvent("uploadsuccess", {
|
|
657
|
-
res: responseObj,
|
|
658
|
-
type: 'scrawl'
|
|
659
|
-
});
|
|
660
|
-
} else {
|
|
661
|
-
alert(responseObj.state);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
}
|
|
665
|
-
},
|
|
666
|
-
onerror: function () {
|
|
667
|
-
alert(lang.imageError);
|
|
668
|
-
dialog.close();
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
options[editor.getOpt('scrawlFieldName')] = base64;
|
|
672
|
-
|
|
673
|
-
var actionUrl = editor.getActionUrl(editor.getOpt('scrawlActionName')),
|
|
674
|
-
params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
|
|
675
|
-
url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + params);
|
|
676
|
-
ajax.request(url, options);
|
|
677
|
-
}
|
|
678
|
-
} else {
|
|
679
|
-
addMaskLayer(lang.noScarwl + " <input type='button' value='" + lang.continueBtn + "' onclick='removeMaskLayer()'/>");
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
|
|
1
|
+
/*! UEditorPlus v2.0.0*/
|
|
2
|
+
function ue_callback(a,b){function c(a,b,c,d){var e,f=0,g=0,h=a.width||c,i=a.height||d;(h>b||i>b)&&(h>=i?(f=h-b)&&(e=(f/h).toFixed(2),a.height=i-i*e,a.width=b):(g=i-b)&&(e=(g/i).toFixed(2),a.width=h-h*e,a.height=b))}var d=document,e=$G("J_picBoard"),f=d.createElement("img");removeMaskLayer(),"SUCCESS"==b?(e.innerHTML="",f.onload=function(){c(this,300),e.appendChild(f);var a=new scrawl;a.btn2Highlight("J_removeImg"),a.btn2Highlight("J_sacleBoard")},f.src=a):alert(b)}function removeMaskLayer(){var a=$G("J_maskLayer");a.className="maskLayerNull",a.innerHTML="",dialog.buttons[0].setDisabled(!1)}function addMaskLayer(a){var b=$G("J_maskLayer");dialog.buttons[0].setDisabled(!0),b.className="maskLayer",b.innerHTML=a}function exec(scrawlObj){if(scrawlObj.isScrawl){addMaskLayer(lang.scrawlUpLoading);var base64=scrawlObj.getCanvasData();if(base64){var options={timeout:1e5,headers:editor.options.serverHeaders||{},onsuccess:function(xhr){if(!scrawlObj.isCancelScrawl){var responseObj;if(responseObj=eval("("+xhr.responseText+")"),"SUCCESS"===responseObj.state){var imgObj={},url=editor.options.scrawlUrlPrefix+responseObj.url;imgObj.src=url,imgObj._src=url,imgObj.alt=responseObj.original||"",editor.execCommand("insertImage",imgObj),dialog.close(),editor.fireEvent("uploadsuccess",{res:responseObj,type:"scrawl"})}else alert(responseObj.state)}},onerror:function(){alert(lang.imageError),dialog.close()}};options[editor.getOpt("scrawlFieldName")]=base64;var actionUrl=editor.getActionUrl(editor.getOpt("scrawlActionName")),params=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",url=utils.formatUrl(actionUrl+(actionUrl.indexOf("?")==-1?"?":"&")+params);ajax.request(url,options)}}else addMaskLayer(lang.noScarwl+" <input type='button' value='"+lang.continueBtn+"' onclick='removeMaskLayer()'/>")}var scrawl=function(a){a&&this.initOptions(a)};!function(){var a=$G("J_brushBoard"),b=a.getContext("2d"),c=[],d=0;scrawl.prototype={isScrawl:!1,brushWidth:-1,brushColor:"",initOptions:function(a){var b=this;b.originalState(a),b._buildToolbarColor(a.colorList),b._addBoardListener(a.saveNum),b._addOPerateListener(a.saveNum),b._addColorBarListener(),b._addBrushBarListener(),b._addEraserBarListener(),b._addAddImgListener(),b._addRemoveImgListenter(),b._addScalePicListenter(),b._addClearSelectionListenter(),b._originalColorSelect(a.drawBrushColor),b._originalBrushSelect(a.drawBrushSize),b._clearSelection()},originalState:function(a){var c=this;c.brushWidth=a.drawBrushSize,c.brushColor=a.drawBrushColor,b.lineWidth=c.brushWidth,b.strokeStyle=c.brushColor,b.fillStyle="transparent",b.lineCap="round",b.fill()},_buildToolbarColor:function(a){var b=null,c=[];c.push("<table id='J_colorList'>");for(var d,e=0;d=a[e++];)(e-1)%5==0&&(1!=e&&c.push("</tr>"),c.push("<tr>")),b="#"+d,c.push("<td><a title='"+b+"' href='javascript:void(0)' style='background-color:"+b+"'></a></td>");c.push("</tr></table>"),$G("J_colorBar").innerHTML=c.join("")},_addBoardListener:function(e){var f,g=this,h=0,i=-1,j=-1,k=!1,l=!1,m=!1,n=0,o="";h=parseInt(domUtils.getComputedStyle($G("J_wrap"),"margin-left")),c.push(b.getImageData(0,0,b.canvas.width,b.canvas.height)),d+=1,domUtils.on(a,["mousedown","mousemove","mouseup","mouseout"],function(a){switch(f=browser.webkit?a.which:n,a.type){case"mousedown":n=1,o=1,k=!0,m=!1,l=!1,g.isScrawl=!0,i=a.clientX-h,j=a.clientY-h,b.beginPath();break;case"mousemove":if(!o&&0==f)return;if(!o&&f&&(i=a.clientX-h,j=a.clientY-h,b.beginPath(),o=1),m||!k)return;var c=a.clientX-h,d=a.clientY-h;b.moveTo(i,j),b.lineTo(c,d),b.stroke(),i=c,j=d,l=!0;break;case"mouseup":if(n=0,!k)return;l||(b.arc(i,j,b.lineWidth,0,2*Math.PI,!1),b.fillStyle=b.strokeStyle,b.fill()),b.closePath(),g._saveOPerate(e),k=!1,l=!1,m=!0,i=-1,j=-1;break;case"mouseout":if(o="",n=0,1==f)return;b.closePath()}})},_addOPerateListener:function(a){var e=this;domUtils.on($G("J_previousStep"),"click",function(){d>1&&(d-=1,b.clearRect(0,0,b.canvas.width,b.canvas.height),b.putImageData(c[d-1],0,0),e.btn2Highlight("J_nextStep"),1==d&&e.btn2disable("J_previousStep"))}),domUtils.on($G("J_nextStep"),"click",function(){d>0&&d<c.length&&(b.clearRect(0,0,b.canvas.width,b.canvas.height),b.putImageData(c[d],0,0),d+=1,e.btn2Highlight("J_previousStep"),d==c.length&&e.btn2disable("J_nextStep"))}),domUtils.on($G("J_clearBoard"),"click",function(){b.clearRect(0,0,b.canvas.width,b.canvas.height),c=[],e._saveOPerate(a),d=1,e.isScrawl=!1,e.btn2disable("J_previousStep"),e.btn2disable("J_nextStep"),e.btn2disable("J_clearBoard")})},_addColorBarListener:function(){var a=this;domUtils.on($G("J_colorBar"),"click",function(c){var d=a.getTarget(c),e=d.title;e&&(a._addColorSelect(d),a.brushColor=e,b.globalCompositeOperation="source-over",b.lineWidth=a.brushWidth,b.strokeStyle=e)})},_addBrushBarListener:function(){var a=this;domUtils.on($G("J_brushBar"),"click",function(c){var d=a.getTarget(c),e=browser.ie?d.innerText:d.text;e&&(a._addBESelect(d),b.globalCompositeOperation="source-over",b.lineWidth=parseInt(e),b.strokeStyle=a.brushColor,a.brushWidth=b.lineWidth)})},_addEraserBarListener:function(){var a=this;domUtils.on($G("J_eraserBar"),"click",function(c){var d=a.getTarget(c),e=browser.ie?d.innerText:d.text;e&&(a._addBESelect(d),b.lineWidth=parseInt(e),b.globalCompositeOperation="destination-out",b.strokeStyle="#FFF")})},_addAddImgListener:function(){var a=$G("J_imgTxt");window.FileReader||($G("J_addImg").style.display="none",$G("J_removeImg").style.display="none",$G("J_sacleBoard").style.display="none"),domUtils.on(a,"change",function(b){var c=a.parentNode;addMaskLayer(lang.backgroundUploading);var d=b.target||b.srcElement,e=new FileReader;e.onload=function(a){var b=a.target||a.srcElement;ue_callback(b.result,"SUCCESS")},e.readAsDataURL(d.files[0]),c.reset()})},_addRemoveImgListenter:function(){var a=this;domUtils.on($G("J_removeImg"),"click",function(){$G("J_picBoard").innerHTML="",a.btn2disable("J_removeImg"),a.btn2disable("J_sacleBoard")})},_addScalePicListenter:function(){domUtils.on($G("J_sacleBoard"),"click",function(){var b=$G("J_picBoard"),c=$G("J_scaleCon"),d=b.children[0];if(d)if(c)"visible"==c.style.visibility?(c.style.visibility="hidden",b.style.position="",b.style.zIndex=""):(c.style.visibility="visible",b.style.cssText+="position:relative;z-index:999");else{b.style.cssText="position:relative;z-index:999;"+b.style.cssText,d.style.cssText="position: absolute;top:"+(a.height-d.height)/2+"px;left:"+(a.width-d.width)/2+"px;";var e=new ScaleBoy;b.appendChild(e.init()),e.startScale(d)}})},_addClearSelectionListenter:function(){var a=document;domUtils.on(a,"mousemove",function(b){browser.ie&&browser.version<11?a.selection.clear():window.getSelection().removeAllRanges()})},_clearSelection:function(){for(var a,b=["J_operateBar","J_colorBar","J_brushBar","J_eraserBar","J_picBoard"],c=0;a=b[c++];)domUtils.unSelectable($G(a))},_saveOPerate:function(a){var e=this;c.length<=a?(d<c.length&&(e.btn2disable("J_nextStep"),c.splice(d)),c.push(b.getImageData(0,0,b.canvas.width,b.canvas.height)),d=c.length):(c.shift(),c.push(b.getImageData(0,0,b.canvas.width,b.canvas.height)),d=c.length),e.btn2Highlight("J_previousStep"),e.btn2Highlight("J_clearBoard")},_originalColorSelect:function(a){for(var b,c=$G("J_colorList").getElementsByTagName("td"),d=0;b=c[d++];)b.children[0].title.toLowerCase()==a&&(b.children[0].style.opacity=1)},_originalBrushSelect:function(a){for(var b,c=$G("J_brushBar").children,d=0;b=c[d++];)if("a"==b.tagName.toLowerCase()){var e=browser.ie?b.innerText:b.text;e.toLowerCase()==a&&(b.style.opacity=1)}},_addColorSelect:function(a){for(var b,c=$G("J_colorList").getElementsByTagName("td"),d=$G("J_eraserBar").children,e=$G("J_brushBar").children,f=0;b=c[f++];)b.children[0].style.opacity=.3;for(var g,h=0;g=e[h++];)if("a"==g.tagName.toLowerCase()){g.style.opacity=.3;var i=browser.ie?g.innerText:g.text;i.toLowerCase()==this.brushWidth&&(g.style.opacity=1)}for(var j,k=0;j=d[k++];)"a"==j.tagName.toLowerCase()&&(j.style.opacity=.3);a.style.opacity=1,a.blur()},_addBESelect:function(a){for(var b,c=$G("J_brushBar").children,d=$G("J_eraserBar").children,e=0;b=c[e++];)"a"==b.tagName.toLowerCase()&&(b.style.opacity=.3);for(var f,g=0;f=d[g++];)"a"==f.tagName.toLowerCase()&&(f.style.opacity=.3);a.style.opacity=1,a.blur()},getCanvasData:function(){var c=$G("J_picBoard"),d=c.children[0];if(d){var e,f;"absolute"==d.style.position?(e=parseInt(d.style.left),f=parseInt(d.style.top)):(e=(c.offsetWidth-d.width)/2,f=(c.offsetHeight-d.height)/2),b.globalCompositeOperation="destination-over",b.drawImage(d,e,f,d.width,d.height)}else b.globalCompositeOperation="destination-atop",b.fillStyle="#fff",b.fillRect(0,0,a.width,a.height);try{return a.toDataURL("image/png").substring(22)}catch(g){return""}},btn2Highlight:function(a){var b=$G(a);b.className.indexOf("H")==-1&&(b.className+="H")},btn2disable:function(a){var b=$G(a);b.className.indexOf("H")!=-1&&(b.className=b.className.replace("H",""))},getTarget:function(a){return a.target||a.srcElement}}}();var ScaleBoy=function(){this.dom=null,this.scalingElement=null};!function(){function a(){var a=document,b=a.getElementsByTagName("head")[0],c=a.createElement("style"),d=".scale{visibility:hidden;cursor:move;position:absolute;left:0;top:0;width:100px;height:50px;background-color:#fff;font-size:0;line-height:0;opacity:.4;filter:Alpha(opacity=40);}.scale span{position:absolute;left:0;top:0;width:6px;height:6px;background-color:#006DAE;}.scale .hand0, .scale .hand7{cursor:nw-resize;}.scale .hand1, .scale .hand6{left:50%;margin-left:-3px;cursor:n-resize;}.scale .hand2, .scale .hand4, .scale .hand7{left:100%;margin-left:-6px;}.scale .hand3, .scale .hand4{top:50%;margin-top:-3px;cursor:w-resize;}.scale .hand5, .scale .hand6, .scale .hand7{margin-top:-6px;top:100%;}.scale .hand2, .scale .hand5{cursor:ne-resize;}";c.type="text/css";try{c.appendChild(a.createTextNode(d))}catch(e){c.styleSheet.cssText=d}b.appendChild(c)}function b(){var a=document,b=[],c=a.createElement("div");c.id="J_scaleCon",c.className="scale";for(var d=0;d<8;d++)b.push("<span class='hand"+d+"'></span>");return c.innerHTML=b.join(""),c}var c=[[1,1,-1,-1],[0,1,0,-1],[0,1,1,-1],[1,0,-1,0],[0,0,1,0],[1,0,-1,1],[0,0,0,1],[0,0,1,1]];ScaleBoy.prototype={init:function(){a();var c=this,d=c.dom=b();return c.scaleMousemove.fp=c,domUtils.on(d,"mousedown",function(a){var b=a.target||a.srcElement;c.start={x:a.clientX,y:a.clientY},b.className.indexOf("hand")!=-1&&(c.dir=b.className.replace("hand","")),domUtils.on(document.body,"mousemove",c.scaleMousemove),a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}),domUtils.on(document.body,"mouseup",function(a){c.start&&(domUtils.un(document.body,"mousemove",c.scaleMousemove),c.moved&&c.updateScaledElement({position:{x:d.style.left,y:d.style.top},size:{w:d.style.width,h:d.style.height}}),delete c.start,delete c.moved,delete c.dir)}),d},startScale:function(a){var b=this,c=b.dom;c.style.cssText="visibility:visible;top:"+a.style.top+";left:"+a.style.left+";width:"+a.offsetWidth+"px;height:"+a.offsetHeight+"px;",b.scalingElement=a},updateScaledElement:function(a){var b=this.scalingElement,c=a.position,d=a.size;c&&("undefined"!=typeof c.x&&(b.style.left=c.x),"undefined"!=typeof c.y&&(b.style.top=c.y)),d&&(d.w&&(b.style.width=d.w),d.h&&(b.style.height=d.h))},updateStyleByDir:function(a,b){var d,e=this,f=e.dom;c.def=[1,1,0,0],0!=c[a][0]&&(d=parseInt(f.style.left)+b.x,f.style.left=e._validScaledProp("left",d)+"px"),0!=c[a][1]&&(d=parseInt(f.style.top)+b.y,f.style.top=e._validScaledProp("top",d)+"px"),0!=c[a][2]&&(d=f.clientWidth+c[a][2]*b.x,f.style.width=e._validScaledProp("width",d)+"px"),0!=c[a][3]&&(d=f.clientHeight+c[a][3]*b.y,f.style.height=e._validScaledProp("height",d)+"px"),"def"===a&&e.updateScaledElement({position:{x:f.style.left,y:f.style.top}})},scaleMousemove:function(a){var b=arguments.callee.fp,c=b.start,d=b.dir||"def",e={x:a.clientX-c.x,y:a.clientY-c.y};b.updateStyleByDir(d,e),arguments.callee.fp.start={x:a.clientX,y:a.clientY},arguments.callee.fp.moved=1},_validScaledProp:function(a,b){var c=this.dom,d=$G("J_picBoard");switch(b=isNaN(b)?0:b,a){case"left":return b<0?0:b+c.clientWidth>d.clientWidth?d.clientWidth-c.clientWidth:b;case"top":return b<0?0:b+c.clientHeight>d.clientHeight?d.clientHeight-c.clientHeight:b;case"width":return b<=0?1:b+c.offsetLeft>d.clientWidth?d.clientWidth-c.offsetLeft:b;case"height":return b<=0?1:b+c.offsetTop>d.clientHeight?d.clientHeight-c.offsetTop:b}}}}();
|