ueditor_rails4 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +45 -0
- data/Rakefile +40 -0
- data/app/assets/images/ueditor/themes/default/anchor.gif +0 -0
- data/app/assets/images/ueditor/themes/default/arrow.png +0 -0
- data/app/assets/images/ueditor/themes/default/button-bg.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cancelbutton.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_h.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_h.png +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_v.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_v.png +0 -0
- data/app/assets/images/ueditor/themes/default/dialog-title-bg.png +0 -0
- data/app/assets/images/ueditor/themes/default/filescan.png +0 -0
- data/app/assets/images/ueditor/themes/default/highlighted.gif +0 -0
- data/app/assets/images/ueditor/themes/default/icons-all.gif +0 -0
- data/app/assets/images/ueditor/themes/default/icons.gif +0 -0
- data/app/assets/images/ueditor/themes/default/icons.png +0 -0
- data/app/assets/images/ueditor/themes/default/lock.gif +0 -0
- data/app/assets/images/ueditor/themes/default/neweditor-tab-bg.png +0 -0
- data/app/assets/images/ueditor/themes/default/pagebreak.gif +0 -0
- data/app/assets/images/ueditor/themes/default/scale.png +0 -0
- data/app/assets/images/ueditor/themes/default/spacer.gif +0 -0
- data/app/assets/images/ueditor/themes/default/sparator_v.png +0 -0
- data/app/assets/images/ueditor/themes/default/toolbar_bg.png +0 -0
- data/app/assets/images/ueditor/themes/default/unhighlighted.gif +0 -0
- data/app/assets/images/ueditor/themes/default/upload.png +0 -0
- data/app/assets/images/ueditor/themes/default/videologo.gif +0 -0
- data/app/assets/images/ueditor/themes/default/word.gif +0 -0
- data/app/assets/images/ueditor/themes/default/wordpaste.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/center_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/left_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/none_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/right_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/addimg.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/brush.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/delimg.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/delimgH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/empty.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/emptyH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/eraser.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/redo.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/redoH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/scale.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/scaleH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/size.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/undo.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/undoH.png +0 -0
- data/app/assets/javascripts/ueditor_rails/_config.js.erb +211 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/attachment.js +5 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_callbacks.js +166 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_file_type_maps.js.erb +14 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/image.js.erb +724 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/scrawl.js +655 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/wordimage.js +154 -0
- data/app/assets/javascripts/ueditor_rails/init.js +12 -0
- data/app/assets/stylesheets/ueditor/themes/default/dialogbase.css.erb +100 -0
- data/app/assets/stylesheets/ueditor/themes/default/ueditor.css +1582 -0
- data/app/assets/stylesheets/ueditor/themes/iframe.css +1 -0
- data/app/assets/stylesheets/ueditor_rails/dialogs/attachment.css.erb +161 -0
- data/app/assets/stylesheets/ueditor_rails/dialogs/image.css.erb +69 -0
- data/app/assets/stylesheets/ueditor_rails/dialogs/scrawl.css.erb +72 -0
- data/app/controllers/ueditor_rails/application_controller.rb +5 -0
- data/app/controllers/ueditor_rails/dialogs_controller.rb +21 -0
- data/app/controllers/ueditor_rails/libs_controller.rb +33 -0
- data/app/helpers/ueditor_rails/application_helper.rb +27 -0
- data/app/views/ueditor_rails/dialogs/attachment.html.erb +124 -0
- data/app/views/ueditor_rails/dialogs/image.html.erb +203 -0
- data/app/views/ueditor_rails/dialogs/scrawl.html.erb +96 -0
- data/app/views/ueditor_rails/dialogs/wordimage.html.erb +155 -0
- data/config/routes.rb +11 -0
- data/lib/generators/ueditor_rails/USAGE +8 -0
- data/lib/generators/ueditor_rails/install_generator.rb +15 -0
- data/lib/generators/ueditor_rails/templates/ueditor_config.js.erb +216 -0
- data/lib/tasks/ueditor_rails_tasks.rake +4 -0
- data/lib/ueditor_rails/engine.rb +17 -0
- data/lib/ueditor_rails/helpers/form_builder.rb +11 -0
- data/lib/ueditor_rails/helpers/form_helper.rb +37 -0
- data/lib/ueditor_rails/helpers/view_helper.rb +21 -0
- data/lib/ueditor_rails/util.rb +42 -0
- data/lib/ueditor_rails/version.rb +3 -0
- data/lib/ueditor_rails4.rb +32 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/javascripts/posts.js +2 -0
- data/test/dummy/app/assets/javascripts/ueditor_config.js.erb +208 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/posts.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/posts_controller.rb +83 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/models/post.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/posts/_form.html.erb +25 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +29 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +61 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +8 -0
- data/test/dummy/db/migrate/20130327173045_create_posts.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/posts.yml +9 -0
- data/test/dummy/test/functional/posts_controller_test.rb +49 -0
- data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
- data/test/dummy/test/unit/post_test.rb +7 -0
- data/test/functional/ueditor_rails/dialogs_controller_test.rb +16 -0
- data/test/functional/ueditor_rails/libs_controller_test.rb +21 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/ueditor_rails_test.rb +7 -0
- data/vendor/assets/javascripts/ueditor/dialogs/anchor/anchor.html.erb +57 -0
- data/vendor/assets/javascripts/ueditor/dialogs/background/background.css +24 -0
- data/vendor/assets/javascripts/ueditor/dialogs/background/background.html.erb +55 -0
- data/vendor/assets/javascripts/ueditor/dialogs/background/background.js +348 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css.erb +43 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html.erb +54 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.js +186 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/0.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/bface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/cface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/fface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/tface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/wface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/yface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/gmap/gmap.html.erb +89 -0
- data/vendor/assets/javascripts/ueditor/dialogs/help/help.css +7 -0
- data/vendor/assets/javascripts/ueditor/dialogs/help/help.html.erb +84 -0
- data/vendor/assets/javascripts/ueditor/dialogs/help/help.js +54 -0
- data/vendor/assets/javascripts/ueditor/dialogs/highlightcode/highlightcode.html.erb +131 -0
- data/vendor/assets/javascripts/ueditor/dialogs/insertframe/insertframe.html.erb +98 -0
- data/vendor/assets/javascripts/ueditor/dialogs/internal.js +79 -0
- data/vendor/assets/javascripts/ueditor/dialogs/link/link.html.erb +141 -0
- data/vendor/assets/javascripts/ueditor/dialogs/map/map.html.erb +105 -0
- data/vendor/assets/javascripts/ueditor/dialogs/music/music.css +30 -0
- data/vendor/assets/javascripts/ueditor/dialogs/music/music.html.erb +32 -0
- data/vendor/assets/javascripts/ueditor/dialogs/music/music.js +192 -0
- data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.html.erb +74 -0
- data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.js +160 -0
- data/vendor/assets/javascripts/ueditor/dialogs/snapscreen/snapscreen.html.erb +91 -0
- data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.html.erb +21 -0
- data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.js +56 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/dragicon.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.css +75 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.html.erb +57 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.js +182 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittd.html.erb +51 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittip.html.erb +33 -0
- data/vendor/assets/javascripts/ueditor/dialogs/tangram.js +1238 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/config.js +42 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/bg.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre0.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre1.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre2.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre3.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre4.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/template.css +18 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/template.html.erb +26 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/template.js +53 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/center_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/left_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/none_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/right_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.css +59 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.html.erb +78 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.js.erb +409 -0
- data/vendor/assets/javascripts/ueditor/dialogs/webapp/webapp.html.erb +64 -0
- data/vendor/assets/javascripts/ueditor/editor_all.js.erb +19133 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/copy.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/imglabel.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/localimage.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/music.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/upload.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/zh-cn.js +492 -0
- data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
- data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +316 -0
- data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.css +104 -0
- data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.js +3581 -0
- data/vendor/assets/javascripts/ueditor/third-party/fClipboard_ueditor.swf +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/imageUploader.swf +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/fileprogress.js +215 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.cookies.js +53 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.js +1132 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.proxy.js +96 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.queue.js +98 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.speed.js +346 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.swf +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload_fp9.swf +0 -0
- data/vendor/assets/javascripts/ueditor/uparse.js +348 -0
- metadata +363 -0
@@ -0,0 +1,655 @@
|
|
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
|
+
url = editor.options.scrawlUrl;
|
45
|
+
|
46
|
+
me.brushWidth = options.drawBrushSize;//同步画笔粗细
|
47
|
+
me.brushColor = options.drawBrushColor;//同步画笔颜色
|
48
|
+
|
49
|
+
$G("fileForm").action = url + (url.indexOf("?") == -1 ? "?" : "&") + "action=tmpImg";//初始form提交地址
|
50
|
+
context.lineWidth = me.brushWidth;//初始画笔大小
|
51
|
+
context.strokeStyle = me.brushColor;//初始画笔颜色
|
52
|
+
context.fillStyle = "transparent";//初始画布背景颜色
|
53
|
+
context.lineCap = "round";//去除锯齿
|
54
|
+
context.fill();
|
55
|
+
},
|
56
|
+
_buildToolbarColor:function (colorList) {
|
57
|
+
var tmp = null, arr = [];
|
58
|
+
arr.push("<table id='J_colorList'>");
|
59
|
+
for (var i = 0, color; color = colorList[i++];) {
|
60
|
+
if ((i - 1) % 5 == 0) {
|
61
|
+
if (i != 1) {
|
62
|
+
arr.push("</tr>");
|
63
|
+
}
|
64
|
+
arr.push("<tr>");
|
65
|
+
}
|
66
|
+
tmp = '#' + color;
|
67
|
+
arr.push("<td><a title='" + tmp + "' href='javascript:void(0)' style='background-color:" + tmp + "'></a></td>");
|
68
|
+
}
|
69
|
+
arr.push("</tr></table>");
|
70
|
+
$G("J_colorBar").innerHTML = arr.join("");
|
71
|
+
},
|
72
|
+
|
73
|
+
_addBoardListener:function (saveNum) {
|
74
|
+
var me = this,
|
75
|
+
margin = 0,
|
76
|
+
startX = -1,
|
77
|
+
startY = -1,
|
78
|
+
isMouseDown = false,
|
79
|
+
isMouseMove = false,
|
80
|
+
isMouseUp = false,
|
81
|
+
buttonPress = 0, button, flag = '';
|
82
|
+
|
83
|
+
margin = parseInt(domUtils.getComputedStyle($G("J_wrap"), "margin-left"));
|
84
|
+
drawStep.push(context.getImageData(0, 0, context.canvas.width, context.canvas.height));
|
85
|
+
drawStepIndex += 1;
|
86
|
+
|
87
|
+
domUtils.on(canvas, ["mousedown", "mousemove", "mouseup", "mouseout"], function (e) {
|
88
|
+
button = browser.webkit ? e.which : buttonPress;
|
89
|
+
switch (e.type) {
|
90
|
+
case 'mousedown':
|
91
|
+
buttonPress = 1;
|
92
|
+
flag = 1;
|
93
|
+
isMouseDown = true;
|
94
|
+
isMouseUp = false;
|
95
|
+
isMouseMove = false;
|
96
|
+
me.isScrawl = true;
|
97
|
+
startX = e.clientX - margin;//10为外边距总和
|
98
|
+
startY = e.clientY - margin;
|
99
|
+
context.beginPath();
|
100
|
+
break;
|
101
|
+
case 'mousemove' :
|
102
|
+
if (!flag && button == 0) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
if (!flag && button) {
|
106
|
+
startX = e.clientX - margin;//10为外边距总和
|
107
|
+
startY = e.clientY - margin;
|
108
|
+
context.beginPath();
|
109
|
+
flag = 1;
|
110
|
+
}
|
111
|
+
if (isMouseUp || !isMouseDown) {
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
var endX = e.clientX - margin,
|
115
|
+
endY = e.clientY - margin;
|
116
|
+
|
117
|
+
context.moveTo(startX, startY);
|
118
|
+
context.lineTo(endX, endY);
|
119
|
+
context.stroke();
|
120
|
+
startX = endX;
|
121
|
+
startY = endY;
|
122
|
+
isMouseMove = true;
|
123
|
+
break;
|
124
|
+
case 'mouseup':
|
125
|
+
buttonPress = 0;
|
126
|
+
if (!isMouseDown)return;
|
127
|
+
if (!isMouseMove) {
|
128
|
+
context.arc(startX, startY, context.lineWidth, 0, Math.PI * 2, false);
|
129
|
+
context.fillStyle = context.strokeStyle;
|
130
|
+
context.fill();
|
131
|
+
}
|
132
|
+
context.closePath();
|
133
|
+
me._saveOPerate(saveNum);
|
134
|
+
isMouseDown = false;
|
135
|
+
isMouseMove = false;
|
136
|
+
isMouseUp = true;
|
137
|
+
startX = -1;
|
138
|
+
startY = -1;
|
139
|
+
break;
|
140
|
+
case 'mouseout':
|
141
|
+
flag = '';
|
142
|
+
buttonPress = 0;
|
143
|
+
if (button == 1) return;
|
144
|
+
context.closePath();
|
145
|
+
break;
|
146
|
+
}
|
147
|
+
});
|
148
|
+
},
|
149
|
+
_addOPerateListener:function (saveNum) {
|
150
|
+
var me = this;
|
151
|
+
domUtils.on($G("J_previousStep"), "click", function () {
|
152
|
+
if (drawStepIndex > 1) {
|
153
|
+
drawStepIndex -= 1;
|
154
|
+
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
155
|
+
context.putImageData(drawStep[drawStepIndex - 1], 0, 0);
|
156
|
+
me.btn2Highlight("J_nextStep");
|
157
|
+
drawStepIndex == 1 && me.btn2disable("J_previousStep");
|
158
|
+
}
|
159
|
+
});
|
160
|
+
domUtils.on($G("J_nextStep"), "click", function () {
|
161
|
+
if (drawStepIndex > 0 && drawStepIndex < drawStep.length) {
|
162
|
+
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
163
|
+
context.putImageData(drawStep[drawStepIndex], 0, 0);
|
164
|
+
drawStepIndex += 1;
|
165
|
+
me.btn2Highlight("J_previousStep");
|
166
|
+
drawStepIndex == drawStep.length && me.btn2disable("J_nextStep");
|
167
|
+
}
|
168
|
+
});
|
169
|
+
domUtils.on($G("J_clearBoard"), "click", function () {
|
170
|
+
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
171
|
+
drawStep = [];
|
172
|
+
me._saveOPerate(saveNum);
|
173
|
+
drawStepIndex = 1;
|
174
|
+
me.isScrawl = false;
|
175
|
+
me.btn2disable("J_previousStep");
|
176
|
+
me.btn2disable("J_nextStep");
|
177
|
+
me.btn2disable("J_clearBoard");
|
178
|
+
});
|
179
|
+
},
|
180
|
+
_addColorBarListener:function () {
|
181
|
+
var me = this;
|
182
|
+
domUtils.on($G("J_colorBar"), "click", function (e) {
|
183
|
+
var target = me.getTarget(e),
|
184
|
+
color = target.title;
|
185
|
+
if (!!color) {
|
186
|
+
me._addColorSelect(target);
|
187
|
+
|
188
|
+
me.brushColor = color;
|
189
|
+
context.globalCompositeOperation = "source-over";
|
190
|
+
context.lineWidth = me.brushWidth;
|
191
|
+
context.strokeStyle = color;
|
192
|
+
}
|
193
|
+
});
|
194
|
+
},
|
195
|
+
_addBrushBarListener:function () {
|
196
|
+
var me = this;
|
197
|
+
domUtils.on($G("J_brushBar"), "click", function (e) {
|
198
|
+
var target = me.getTarget(e),
|
199
|
+
size = browser.ie ? target.innerText : target.text;
|
200
|
+
if (!!size) {
|
201
|
+
me._addBESelect(target);
|
202
|
+
|
203
|
+
context.globalCompositeOperation = "source-over";
|
204
|
+
context.lineWidth = parseInt(size);
|
205
|
+
context.strokeStyle = me.brushColor;
|
206
|
+
me.brushWidth = context.lineWidth;
|
207
|
+
}
|
208
|
+
});
|
209
|
+
},
|
210
|
+
_addEraserBarListener:function () {
|
211
|
+
var me = this;
|
212
|
+
domUtils.on($G("J_eraserBar"), "click", function (e) {
|
213
|
+
var target = me.getTarget(e),
|
214
|
+
size = browser.ie ? target.innerText : target.text;
|
215
|
+
if (!!size) {
|
216
|
+
me._addBESelect(target);
|
217
|
+
|
218
|
+
context.lineWidth = parseInt(size);
|
219
|
+
context.globalCompositeOperation = "destination-out";
|
220
|
+
context.strokeStyle = "#FFF";
|
221
|
+
}
|
222
|
+
});
|
223
|
+
},
|
224
|
+
_addAddImgListener:function () {
|
225
|
+
var doc = document,
|
226
|
+
file = $G("J_imgTxt");
|
227
|
+
domUtils.on(file, "change", function () {
|
228
|
+
var frm = file.parentNode;
|
229
|
+
addMaskLayer(lang.backgroundUploading);
|
230
|
+
frm.submit();
|
231
|
+
frm.reset();
|
232
|
+
});
|
233
|
+
},
|
234
|
+
_addRemoveImgListenter:function () {
|
235
|
+
var me = this;
|
236
|
+
domUtils.on($G("J_removeImg"), "click", function () {
|
237
|
+
$G("J_picBoard").innerHTML = "";
|
238
|
+
me.btn2disable("J_removeImg");
|
239
|
+
me.btn2disable("J_sacleBoard");
|
240
|
+
});
|
241
|
+
},
|
242
|
+
_addScalePicListenter:function () {
|
243
|
+
domUtils.on($G("J_sacleBoard"), "click", function () {
|
244
|
+
var picBoard = $G("J_picBoard"),
|
245
|
+
scaleCon = $G("J_scaleCon"),
|
246
|
+
img = picBoard.children[0];
|
247
|
+
|
248
|
+
if (img) {
|
249
|
+
if (!scaleCon) {
|
250
|
+
picBoard.style.cssText = "position:relative;z-index:999;"+picBoard.style.cssText;
|
251
|
+
img.style.cssText = "position: absolute;top:" + (canvas.height - img.height) / 2 + "px;left:" + (canvas.width - img.width) / 2 + "px;";
|
252
|
+
var scale = new ScaleBoy();
|
253
|
+
picBoard.appendChild(scale.init());
|
254
|
+
scale.startScale(img);
|
255
|
+
} else {
|
256
|
+
if (scaleCon.style.visibility == "visible") {
|
257
|
+
scaleCon.style.visibility = "hidden";
|
258
|
+
picBoard.style.position = "";
|
259
|
+
picBoard.style.zIndex = "";
|
260
|
+
} else {
|
261
|
+
scaleCon.style.visibility = "visible";
|
262
|
+
picBoard.style.cssText += "position:relative;z-index:999";
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
});
|
267
|
+
},
|
268
|
+
_addClearSelectionListenter:function () {
|
269
|
+
var doc = document;
|
270
|
+
domUtils.on(doc, 'mousemove', function (e) {
|
271
|
+
if (browser.ie)
|
272
|
+
doc.selection.clear();
|
273
|
+
else
|
274
|
+
window.getSelection().removeAllRanges();
|
275
|
+
});
|
276
|
+
},
|
277
|
+
_clearSelection:function () {
|
278
|
+
var list = ["J_operateBar", "J_colorBar", "J_brushBar", "J_eraserBar", "J_picBoard"];
|
279
|
+
for (var i = 0, group; group = list[i++];) {
|
280
|
+
domUtils.unSelectable($G(group));
|
281
|
+
}
|
282
|
+
},
|
283
|
+
|
284
|
+
_saveOPerate:function (saveNum) {
|
285
|
+
var me = this;
|
286
|
+
if (drawStep.length <= saveNum) {
|
287
|
+
if(drawStepIndex<drawStep.length){
|
288
|
+
me.btn2disable("J_nextStep");
|
289
|
+
drawStep.splice(drawStepIndex);
|
290
|
+
}
|
291
|
+
drawStep.push(context.getImageData(0, 0, context.canvas.width, context.canvas.height));
|
292
|
+
drawStepIndex = drawStep.length;
|
293
|
+
} else {
|
294
|
+
drawStep.shift();
|
295
|
+
drawStep.push(context.getImageData(0, 0, context.canvas.width, context.canvas.height));
|
296
|
+
drawStepIndex = drawStep.length;
|
297
|
+
}
|
298
|
+
me.btn2Highlight("J_previousStep");
|
299
|
+
me.btn2Highlight("J_clearBoard");
|
300
|
+
},
|
301
|
+
|
302
|
+
_originalColorSelect:function (title) {
|
303
|
+
var colorList = $G("J_colorList").getElementsByTagName("td");
|
304
|
+
for (var j = 0, cell; cell = colorList[j++];) {
|
305
|
+
if (cell.children[0].title.toLowerCase() == title) {
|
306
|
+
cell.children[0].style.opacity = 1;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
},
|
310
|
+
_originalBrushSelect:function (text) {
|
311
|
+
var brushList = $G("J_brushBar").children;
|
312
|
+
for (var i = 0, ele; ele = brushList[i++];) {
|
313
|
+
if (ele.tagName.toLowerCase() == "a") {
|
314
|
+
var size = browser.ie ? ele.innerText : ele.text;
|
315
|
+
if (size.toLowerCase() == text) {
|
316
|
+
ele.style.opacity = 1;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}
|
320
|
+
},
|
321
|
+
_addColorSelect:function (target) {
|
322
|
+
var me = this,
|
323
|
+
colorList = $G("J_colorList").getElementsByTagName("td"),
|
324
|
+
eraserList = $G("J_eraserBar").children,
|
325
|
+
brushList = $G("J_brushBar").children;
|
326
|
+
|
327
|
+
for (var i = 0, cell; cell = colorList[i++];) {
|
328
|
+
cell.children[0].style.opacity = 0.3;
|
329
|
+
}
|
330
|
+
for (var k = 0, ele; ele = brushList[k++];) {
|
331
|
+
if (ele.tagName.toLowerCase() == "a") {
|
332
|
+
ele.style.opacity = 0.3;
|
333
|
+
var size = browser.ie ? ele.innerText : ele.text;
|
334
|
+
if (size.toLowerCase() == this.brushWidth) {
|
335
|
+
ele.style.opacity = 1;
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
for (var j = 0, node; node = eraserList[j++];) {
|
340
|
+
if (node.tagName.toLowerCase() == "a") {
|
341
|
+
node.style.opacity = 0.3;
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
target.style.opacity = 1;
|
346
|
+
target.blur();
|
347
|
+
},
|
348
|
+
_addBESelect:function (target) {
|
349
|
+
var brushList = $G("J_brushBar").children;
|
350
|
+
var eraserList = $G("J_eraserBar").children;
|
351
|
+
|
352
|
+
for (var i = 0, ele; ele = brushList[i++];) {
|
353
|
+
if (ele.tagName.toLowerCase() == "a") {
|
354
|
+
ele.style.opacity = 0.3;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
for (var j = 0, node; node = eraserList[j++];) {
|
358
|
+
if (node.tagName.toLowerCase() == "a") {
|
359
|
+
node.style.opacity = 0.3;
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
target.style.opacity = 1;
|
364
|
+
target.blur();
|
365
|
+
},
|
366
|
+
getCanvasData:function () {
|
367
|
+
var picContainer = $G("J_picBoard"),
|
368
|
+
img = picContainer.children[0];
|
369
|
+
if (img) {
|
370
|
+
var x, y;
|
371
|
+
if (img.style.position == "absolute") {
|
372
|
+
x = parseInt(img.style.left);
|
373
|
+
y = parseInt(img.style.top);
|
374
|
+
} else {
|
375
|
+
x = (picContainer.offsetWidth - img.width) / 2;
|
376
|
+
y = (picContainer.offsetHeight - img.height) / 2;
|
377
|
+
}
|
378
|
+
context.globalCompositeOperation = "destination-over";
|
379
|
+
context.drawImage(img, x, y, img.width, img.height);
|
380
|
+
} else {
|
381
|
+
context.globalCompositeOperation = "destination-atop";
|
382
|
+
context.fillStyle = "#fff";//重置画布背景白色
|
383
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
384
|
+
}
|
385
|
+
try {
|
386
|
+
return canvas.toDataURL("image/png").substring(22);
|
387
|
+
} catch (e) {
|
388
|
+
return "";
|
389
|
+
}
|
390
|
+
},
|
391
|
+
btn2Highlight:function (id) {
|
392
|
+
var cur = $G(id);
|
393
|
+
cur.className.indexOf("H") == -1 && (cur.className += "H");
|
394
|
+
},
|
395
|
+
btn2disable:function (id) {
|
396
|
+
var cur = $G(id);
|
397
|
+
cur.className.indexOf("H") != -1 && (cur.className = cur.className.replace("H", ""));
|
398
|
+
},
|
399
|
+
getTarget:function (evt) {
|
400
|
+
return evt.target || evt.srcElement;
|
401
|
+
}
|
402
|
+
};
|
403
|
+
})();
|
404
|
+
|
405
|
+
var ScaleBoy = function () {
|
406
|
+
this.dom = null;
|
407
|
+
this.scalingElement = null;
|
408
|
+
};
|
409
|
+
(function () {
|
410
|
+
function _appendStyle() {
|
411
|
+
var doc = document,
|
412
|
+
head = doc.getElementsByTagName('head')[0],
|
413
|
+
style = doc.createElement('style'),
|
414
|
+
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);}'
|
415
|
+
+ '.scale span{position:absolute;left:0;top:0;width:6px;height:6px;background-color:#006DAE;}'
|
416
|
+
+ '.scale .hand0, .scale .hand7{cursor:nw-resize;}'
|
417
|
+
+ '.scale .hand1, .scale .hand6{left:50%;margin-left:-3px;cursor:n-resize;}'
|
418
|
+
+ '.scale .hand2, .scale .hand4, .scale .hand7{left:100%;margin-left:-6px;}'
|
419
|
+
+ '.scale .hand3, .scale .hand4{top:50%;margin-top:-3px;cursor:w-resize;}'
|
420
|
+
+ '.scale .hand5, .scale .hand6, .scale .hand7{margin-top:-6px;top:100%;}'
|
421
|
+
+ '.scale .hand2, .scale .hand5{cursor:ne-resize;}';
|
422
|
+
style.type = 'text/css';
|
423
|
+
|
424
|
+
try {
|
425
|
+
style.appendChild(doc.createTextNode(cssText));
|
426
|
+
} catch (e) {
|
427
|
+
style.styleSheet.cssText = cssText;
|
428
|
+
}
|
429
|
+
head.appendChild(style);
|
430
|
+
}
|
431
|
+
|
432
|
+
function _getDom() {
|
433
|
+
var doc = document,
|
434
|
+
hand,
|
435
|
+
arr = [],
|
436
|
+
scale = doc.createElement('div');
|
437
|
+
|
438
|
+
scale.id = 'J_scaleCon';
|
439
|
+
scale.className = 'scale';
|
440
|
+
for (var i = 0; i < 8; i++) {
|
441
|
+
arr.push("<span class='hand" + i + "'></span>");
|
442
|
+
}
|
443
|
+
scale.innerHTML = arr.join("");
|
444
|
+
return scale;
|
445
|
+
}
|
446
|
+
|
447
|
+
var rect = [
|
448
|
+
//[left, top, width, height]
|
449
|
+
[1, 1, -1, -1],
|
450
|
+
[0, 1, 0, -1],
|
451
|
+
[0, 1, 1, -1],
|
452
|
+
[1, 0, -1, 0],
|
453
|
+
[0, 0, 1, 0],
|
454
|
+
[1, 0, -1, 1],
|
455
|
+
[0, 0, 0, 1],
|
456
|
+
[0, 0, 1, 1]
|
457
|
+
];
|
458
|
+
ScaleBoy.prototype = {
|
459
|
+
init:function () {
|
460
|
+
_appendStyle();
|
461
|
+
var me = this,
|
462
|
+
scale = me.dom = _getDom();
|
463
|
+
|
464
|
+
me.scaleMousemove.fp = me;
|
465
|
+
domUtils.on(scale, 'mousedown', function (e) {
|
466
|
+
var target = e.target || e.srcElement;
|
467
|
+
me.start = {x:e.clientX, y:e.clientY};
|
468
|
+
if (target.className.indexOf('hand') != -1) {
|
469
|
+
me.dir = target.className.replace('hand', '');
|
470
|
+
}
|
471
|
+
domUtils.on(document.body, 'mousemove', me.scaleMousemove);
|
472
|
+
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
|
473
|
+
});
|
474
|
+
domUtils.on(document.body, 'mouseup', function (e) {
|
475
|
+
if (me.start) {
|
476
|
+
domUtils.un(document.body, 'mousemove', me.scaleMousemove);
|
477
|
+
if (me.moved) {
|
478
|
+
me.updateScaledElement({position:{x:scale.style.left, y:scale.style.top}, size:{w:scale.style.width, h:scale.style.height}});
|
479
|
+
}
|
480
|
+
delete me.start;
|
481
|
+
delete me.moved;
|
482
|
+
delete me.dir;
|
483
|
+
}
|
484
|
+
});
|
485
|
+
return scale;
|
486
|
+
},
|
487
|
+
startScale:function (objElement) {
|
488
|
+
var me = this, Idom = me.dom;
|
489
|
+
|
490
|
+
Idom.style.cssText = 'visibility:visible;top:' + objElement.style.top + ';left:' + objElement.style.left + ';width:' + objElement.offsetWidth + 'px;height:' + objElement.offsetHeight + 'px;';
|
491
|
+
me.scalingElement = objElement;
|
492
|
+
},
|
493
|
+
updateScaledElement:function (objStyle) {
|
494
|
+
var cur = this.scalingElement,
|
495
|
+
pos = objStyle.position,
|
496
|
+
size = objStyle.size;
|
497
|
+
if (pos) {
|
498
|
+
typeof pos.x != 'undefined' && (cur.style.left = pos.x);
|
499
|
+
typeof pos.y != 'undefined' && (cur.style.top = pos.y);
|
500
|
+
}
|
501
|
+
if (size) {
|
502
|
+
size.w && (cur.style.width = size.w);
|
503
|
+
size.h && (cur.style.height = size.h);
|
504
|
+
}
|
505
|
+
},
|
506
|
+
updateStyleByDir:function (dir, offset) {
|
507
|
+
var me = this,
|
508
|
+
dom = me.dom, tmp;
|
509
|
+
|
510
|
+
rect['def'] = [1, 1, 0, 0];
|
511
|
+
if (rect[dir][0] != 0) {
|
512
|
+
tmp = parseInt(dom.style.left) + offset.x;
|
513
|
+
dom.style.left = me._validScaledProp('left', tmp) + 'px';
|
514
|
+
}
|
515
|
+
if (rect[dir][1] != 0) {
|
516
|
+
tmp = parseInt(dom.style.top) + offset.y;
|
517
|
+
dom.style.top = me._validScaledProp('top', tmp) + 'px';
|
518
|
+
}
|
519
|
+
if (rect[dir][2] != 0) {
|
520
|
+
tmp = dom.clientWidth + rect[dir][2] * offset.x;
|
521
|
+
dom.style.width = me._validScaledProp('width', tmp) + 'px';
|
522
|
+
}
|
523
|
+
if (rect[dir][3] != 0) {
|
524
|
+
tmp = dom.clientHeight + rect[dir][3] * offset.y;
|
525
|
+
dom.style.height = me._validScaledProp('height', tmp) + 'px';
|
526
|
+
}
|
527
|
+
if (dir === 'def') {
|
528
|
+
me.updateScaledElement({position:{x:dom.style.left, y:dom.style.top}});
|
529
|
+
}
|
530
|
+
},
|
531
|
+
scaleMousemove:function (e) {
|
532
|
+
var me = arguments.callee.fp,
|
533
|
+
start = me.start,
|
534
|
+
dir = me.dir || 'def',
|
535
|
+
offset = {x:e.clientX - start.x, y:e.clientY - start.y};
|
536
|
+
|
537
|
+
me.updateStyleByDir(dir, offset);
|
538
|
+
arguments.callee.fp.start = {x:e.clientX, y:e.clientY};
|
539
|
+
arguments.callee.fp.moved = 1;
|
540
|
+
},
|
541
|
+
_validScaledProp:function (prop, value) {
|
542
|
+
var ele = this.dom,
|
543
|
+
wrap = $G("J_picBoard");
|
544
|
+
|
545
|
+
value = isNaN(value) ? 0 : value;
|
546
|
+
switch (prop) {
|
547
|
+
case 'left':
|
548
|
+
return value < 0 ? 0 : (value + ele.clientWidth) > wrap.clientWidth ? wrap.clientWidth - ele.clientWidth : value;
|
549
|
+
case 'top':
|
550
|
+
return value < 0 ? 0 : (value + ele.clientHeight) > wrap.clientHeight ? wrap.clientHeight - ele.clientHeight : value;
|
551
|
+
case 'width':
|
552
|
+
return value <= 0 ? 1 : (value + ele.offsetLeft) > wrap.clientWidth ? wrap.clientWidth - ele.offsetLeft : value;
|
553
|
+
case 'height':
|
554
|
+
return value <= 0 ? 1 : (value + ele.offsetTop) > wrap.clientHeight ? wrap.clientHeight - ele.offsetTop : value;
|
555
|
+
}
|
556
|
+
}
|
557
|
+
};
|
558
|
+
})();
|
559
|
+
|
560
|
+
//后台回调
|
561
|
+
function ue_callback(url, state) {
|
562
|
+
var doc = document,
|
563
|
+
picBorard = $G("J_picBoard"),
|
564
|
+
img = doc.createElement("img");
|
565
|
+
|
566
|
+
//图片缩放
|
567
|
+
function scale(img, max, oWidth, oHeight) {
|
568
|
+
var width = 0, height = 0, percent, ow = img.width || oWidth, oh = img.height || oHeight;
|
569
|
+
if (ow > max || oh > max) {
|
570
|
+
if (ow >= oh) {
|
571
|
+
if (width = ow - max) {
|
572
|
+
percent = (width / ow).toFixed(2);
|
573
|
+
img.height = oh - oh * percent;
|
574
|
+
img.width = max;
|
575
|
+
}
|
576
|
+
} else {
|
577
|
+
if (height = oh - max) {
|
578
|
+
percent = (height / oh).toFixed(2);
|
579
|
+
img.width = ow - ow * percent;
|
580
|
+
img.height = max;
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}
|
584
|
+
}
|
585
|
+
|
586
|
+
//移除遮罩层
|
587
|
+
removeMaskLayer();
|
588
|
+
//状态响应
|
589
|
+
if (state == "SUCCESS") {
|
590
|
+
picBorard.innerHTML = "";
|
591
|
+
img.onload = function () {
|
592
|
+
scale(this, 300);
|
593
|
+
picBorard.appendChild(img);
|
594
|
+
|
595
|
+
var obj = new scrawl();
|
596
|
+
obj.btn2Highlight("J_removeImg");
|
597
|
+
//trace 2457
|
598
|
+
obj.btn2Highlight("J_sacleBoard");
|
599
|
+
};
|
600
|
+
img.src = editor.options.scrawlPath + url;
|
601
|
+
} else {
|
602
|
+
alert(state);
|
603
|
+
}
|
604
|
+
}
|
605
|
+
//去掉遮罩层
|
606
|
+
function removeMaskLayer() {
|
607
|
+
var maskLayer = $G("J_maskLayer");
|
608
|
+
maskLayer.className = "maskLayerNull";
|
609
|
+
maskLayer.innerHTML = "";
|
610
|
+
dialog.buttons[0].setDisabled(false);
|
611
|
+
}
|
612
|
+
//添加遮罩层
|
613
|
+
function addMaskLayer(html) {
|
614
|
+
var maskLayer = $G("J_maskLayer");
|
615
|
+
dialog.buttons[0].setDisabled(true);
|
616
|
+
maskLayer.className = "maskLayer";
|
617
|
+
maskLayer.innerHTML = html;
|
618
|
+
}
|
619
|
+
//执行确认按钮方法
|
620
|
+
function exec(scrawlObj) {
|
621
|
+
if (scrawlObj.isScrawl) {
|
622
|
+
addMaskLayer(lang.scrawlUpLoading);
|
623
|
+
var base64 = scrawlObj.getCanvasData();
|
624
|
+
if (!!base64) {
|
625
|
+
ajax.request(editor.options.scrawlUrl, {
|
626
|
+
timeout:100000,
|
627
|
+
content:base64,
|
628
|
+
onsuccess:function (xhr) {
|
629
|
+
if (!scrawlObj.isCancelScrawl) {
|
630
|
+
var responseObj;
|
631
|
+
responseObj = eval("(" + xhr.responseText + ")");
|
632
|
+
if (responseObj.state == "SUCCESS") {
|
633
|
+
var imgObj = {},
|
634
|
+
url = editor.options.scrawlPath + responseObj.url;
|
635
|
+
imgObj.src = url;
|
636
|
+
imgObj.data_ue_src = url;
|
637
|
+
editor.execCommand("insertImage", imgObj);
|
638
|
+
dialog.close();
|
639
|
+
} else {
|
640
|
+
alert(responseObj.state);
|
641
|
+
}
|
642
|
+
|
643
|
+
}
|
644
|
+
},
|
645
|
+
onerror:function () {
|
646
|
+
alert(lang.imageError);
|
647
|
+
dialog.close();
|
648
|
+
}
|
649
|
+
});
|
650
|
+
}
|
651
|
+
} else {
|
652
|
+
addMaskLayer(lang.noScarwl + " <input type='button' value='" + lang.continueBtn + "' onclick='removeMaskLayer()'/>");
|
653
|
+
}
|
654
|
+
}
|
655
|
+
|