ueditor_rails 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/README.markdown +2 -2
  2. data/app/assets/images/ueditor_rails/dialogs/scrawl/addimg.png +0 -0
  3. data/app/assets/images/ueditor_rails/dialogs/scrawl/brush.png +0 -0
  4. data/app/assets/images/ueditor_rails/dialogs/scrawl/delimg.png +0 -0
  5. data/app/assets/images/ueditor_rails/dialogs/scrawl/delimgH.png +0 -0
  6. data/app/assets/images/ueditor_rails/dialogs/scrawl/empty.png +0 -0
  7. data/app/assets/images/ueditor_rails/dialogs/scrawl/emptyH.png +0 -0
  8. data/app/assets/images/ueditor_rails/dialogs/scrawl/eraser.png +0 -0
  9. data/app/assets/images/ueditor_rails/dialogs/scrawl/redo.png +0 -0
  10. data/app/assets/images/ueditor_rails/dialogs/scrawl/redoH.png +0 -0
  11. data/app/assets/images/ueditor_rails/dialogs/scrawl/scale.png +0 -0
  12. data/app/assets/images/ueditor_rails/dialogs/scrawl/scaleH.png +0 -0
  13. data/app/assets/images/ueditor_rails/dialogs/scrawl/size.png +0 -0
  14. data/app/assets/images/ueditor_rails/dialogs/scrawl/undo.png +0 -0
  15. data/app/assets/images/ueditor_rails/dialogs/scrawl/undoH.png +0 -0
  16. data/app/assets/javascripts/ueditor_rails/_config.js.erb +28 -24
  17. data/app/assets/javascripts/ueditor_rails/dialogs/scrawl.js +655 -0
  18. data/app/assets/javascripts/ueditor_rails/dialogs/wordimage.js +154 -0
  19. data/app/assets/stylesheets/ueditor_rails/dialogs/scrawl.css.erb +72 -0
  20. data/app/controllers/ueditor_rails/dialogs_controller.rb +8 -0
  21. data/app/controllers/ueditor_rails/libs_controller.rb +14 -1
  22. data/app/helpers/ueditor_rails/application_helper.rb +23 -0
  23. data/app/views/ueditor_rails/dialogs/attachment.html.erb +3 -3
  24. data/app/views/ueditor_rails/dialogs/image.html.erb +2 -2
  25. data/app/views/ueditor_rails/dialogs/scrawl.html.erb +96 -0
  26. data/app/views/ueditor_rails/dialogs/wordimage.html.erb +155 -0
  27. data/config/routes.rb +2 -2
  28. data/lib/generators/ueditor_rails/templates/ueditor_config.js.erb +33 -21
  29. data/lib/ueditor_rails.rb +7 -0
  30. data/lib/ueditor_rails/util.rb +1 -1
  31. data/lib/ueditor_rails/version.rb +1 -1
  32. data/test/dummy/config/application.rb +2 -0
  33. data/test/dummy/log/development.log +594 -0
  34. data/test/dummy/tmp/cache/assets/C81/610/sprockets%2F74551592340adfb31d564a6f0780986a +0 -0
  35. data/test/dummy/tmp/cache/assets/C81/680/sprockets%2F05f48503b0539542bae58cd42890287d +0 -0
  36. data/test/dummy/tmp/cache/assets/C92/A50/sprockets%2Fb8ab434fa9743f8545988223229ef813 +0 -0
  37. data/test/dummy/tmp/cache/assets/CA9/8D0/sprockets%2F430c458f24b93f37143e610b7af710d8 +0 -0
  38. data/test/dummy/tmp/cache/assets/CDD/110/sprockets%2F201786630fb75920fef0b95a7ba8e404 +0 -0
  39. data/test/dummy/tmp/cache/assets/CF8/FC0/sprockets%2Fe181c7f625e3797eaa44e044c77e9688 +0 -0
  40. data/test/dummy/tmp/cache/assets/CFC/560/sprockets%2Fbc63d027b162a565426fdbb4611619ab +0 -0
  41. data/test/dummy/tmp/cache/assets/D05/3A0/sprockets%2F8362a0d2c101ef1148d5efcb53e34893 +0 -0
  42. data/test/dummy/tmp/cache/assets/D05/570/sprockets%2Fca8368b2f01a1645dfe894d41152f2c0 +0 -0
  43. data/test/dummy/tmp/cache/assets/D16/E70/sprockets%2Ffcc7289ae3530fcff4500f35990533f4 +0 -0
  44. data/test/dummy/tmp/cache/assets/D2D/F70/sprockets%2F1db6dd5b1f0887b130386d6bc20d13e2 +0 -0
  45. data/test/dummy/tmp/cache/assets/D31/7D0/sprockets%2Fe9f71394f8e86a70e9431c3d83fb86f9 +0 -0
  46. data/test/dummy/tmp/cache/assets/D39/B00/sprockets%2F84ac6151984303fcaec0d48651b6d7ca +0 -0
  47. data/test/dummy/tmp/cache/assets/D40/280/sprockets%2Fc564b6fa3f835a246df0355a83058fcd +0 -0
  48. data/test/dummy/tmp/cache/assets/D41/C00/sprockets%2F0f88cb64779d212943bbab3f5ac483d4 +0 -0
  49. data/test/dummy/tmp/cache/assets/D4A/CF0/sprockets%2F78a5eda44e97ab212ce37b889470c4d7 +0 -0
  50. data/test/dummy/tmp/cache/assets/D4D/060/sprockets%2Fdf8071fd9e383d72ba1f17b5d5e98516 +0 -0
  51. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  52. data/test/dummy/tmp/cache/assets/D55/1F0/sprockets%2F978d1a29569eb1c8ca9883b64ffb91b3 +0 -0
  53. data/test/dummy/tmp/cache/assets/D70/B70/sprockets%2F6ebaed371aa715b95667e416378cba4d +0 -0
  54. data/test/dummy/tmp/cache/assets/D75/2B0/sprockets%2F7a4cbc3862aa0d6f1ec9e7518fa55838 +0 -0
  55. data/test/dummy/tmp/cache/assets/DCD/870/sprockets%2Fd5daf18cb49181ab0ba896acfd8c8334 +0 -0
  56. data/test/dummy/tmp/cache/assets/DD7/600/sprockets%2F0cec2cc545e1d3bd889d195f68dea4b7 +0 -0
  57. data/test/dummy/tmp/cache/assets/DDB/C20/sprockets%2F46613f4acf7d7cc09f5190f2d8bbdf9f +0 -0
  58. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  59. data/test/dummy/tmp/cache/assets/DFE/FF0/sprockets%2F9d2bcad3ae0c53ee9a4685b5aac1887f +0 -0
  60. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  61. data/test/dummy/tmp/cache/assets/E34/9F0/sprockets%2F2dbdbaffe3f466f85cee37cee4331f34 +0 -0
  62. data/test/dummy/tmp/cache/assets/E3A/DA0/sprockets%2Ffd736ded1575dfbcf2d45ad5eb4e28d9 +0 -0
  63. data/vendor/assets/javascripts/ueditor/dialogs/anchor/anchor.html.erb +57 -0
  64. data/vendor/assets/javascripts/ueditor/dialogs/background/background.css +24 -0
  65. data/vendor/assets/javascripts/ueditor/dialogs/background/background.html.erb +55 -0
  66. data/vendor/assets/javascripts/ueditor/dialogs/background/background.js +348 -0
  67. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css.erb +0 -1
  68. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html.erb +41 -41
  69. data/vendor/assets/javascripts/ueditor/dialogs/gmap/gmap.html.erb +89 -0
  70. data/vendor/assets/javascripts/ueditor/dialogs/help/help.html.erb +72 -70
  71. data/vendor/assets/javascripts/ueditor/dialogs/highlightcode/highlightcode.html.erb +131 -0
  72. data/vendor/assets/javascripts/ueditor/dialogs/insertframe/insertframe.html.erb +98 -0
  73. data/vendor/assets/javascripts/ueditor/dialogs/link/link.html.erb +122 -107
  74. data/vendor/assets/javascripts/ueditor/dialogs/map/map.html.erb +105 -0
  75. data/vendor/assets/javascripts/ueditor/dialogs/music/music.css +30 -0
  76. data/vendor/assets/javascripts/ueditor/dialogs/music/music.html.erb +32 -0
  77. data/vendor/assets/javascripts/ueditor/dialogs/music/music.js +192 -0
  78. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.html.erb +74 -0
  79. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.js +160 -0
  80. data/vendor/assets/javascripts/ueditor/dialogs/snapscreen/snapscreen.html.erb +91 -0
  81. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.html.erb +2 -2
  82. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.html.erb +46 -45
  83. data/vendor/assets/javascripts/ueditor/dialogs/table/edittd.html.erb +40 -39
  84. data/vendor/assets/javascripts/ueditor/dialogs/table/edittip.html.erb +21 -21
  85. data/vendor/assets/javascripts/ueditor/dialogs/template/config.js +42 -0
  86. data/vendor/assets/javascripts/ueditor/dialogs/template/images/bg.gif +0 -0
  87. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre0.png +0 -0
  88. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre1.png +0 -0
  89. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre2.png +0 -0
  90. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre3.png +0 -0
  91. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre4.png +0 -0
  92. data/vendor/assets/javascripts/ueditor/dialogs/template/template.css +18 -0
  93. data/vendor/assets/javascripts/ueditor/dialogs/template/template.html.erb +26 -0
  94. data/vendor/assets/javascripts/ueditor/dialogs/template/template.js +53 -0
  95. data/vendor/assets/javascripts/ueditor/dialogs/video/video.html.erb +64 -53
  96. data/vendor/assets/javascripts/ueditor/dialogs/video/video.js.erb +409 -0
  97. data/vendor/assets/javascripts/ueditor/dialogs/webapp/webapp.html.erb +64 -0
  98. data/vendor/assets/javascripts/ueditor/editor_all.js.erb +17209 -15783
  99. data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
  100. data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +316 -0
  101. data/vendor/assets/javascripts/ueditor/third-party/fClipboard_ueditor.swf +0 -0
  102. data/vendor/assets/javascripts/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
  103. data/vendor/assets/javascripts/ueditor/uparse.js +3 -13
  104. metadata +77 -3
  105. data/vendor/assets/javascripts/ueditor/dialogs/video/video.js +0 -402
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Created by JetBrains PhpStorm.
3
+ * User: taoqili
4
+ * Date: 12-1-30
5
+ * Time: 下午12:50
6
+ * To change this template use File | Settings | File Templates.
7
+ */
8
+
9
+ //editor.execCommand("wordimage","word_img");
10
+
11
+
12
+ var wordImage = {};
13
+ //(function(){
14
+ var g = baidu.g,
15
+ flashObj,flashContainer;
16
+ wordImage.init = function(opt, callbacks) {
17
+ showLocalPath("localPath");
18
+ //createCopyButton("clipboard","localPath");
19
+ createFlashUploader(opt, callbacks);
20
+ addUploadListener();
21
+ addOkListener();
22
+ };
23
+
24
+ function hideFlash(){
25
+ flashObj = null;
26
+ flashContainer.innerHTML = "";
27
+ }
28
+ function addOkListener() {
29
+ dialog.onok = function() {
30
+ if (!imageUrls.length) return;
31
+ var images = domUtils.getElementsByTagName(editor.document,"img");
32
+ for (var i = 0,img; img = images[i++];) {
33
+ var src = img.getAttribute("word_img");
34
+ if (!src) continue;
35
+ for (var j = 0,url; url = imageUrls[j++];) {
36
+ if (src.indexOf(url.original.replace(" ","")) != -1) {
37
+ img.src = editor.options.wordImagePath + url.url;
38
+ img.setAttribute("data_ue_src", editor.options.wordImagePath + url.url); //同时修改"data_ue_src"属性
39
+ img.setAttribute("title",url.title);
40
+ parent.baidu.editor.dom.domUtils.removeAttributes(img, ["word_img","style","width","height"]);
41
+ editor.fireEvent("selectionchange");
42
+ break;
43
+ }
44
+ }
45
+ }
46
+ hideFlash();
47
+ };
48
+ dialog.oncancel = function(){
49
+ hideFlash();
50
+ }
51
+ }
52
+
53
+ /**
54
+ * 绑定开始上传事件
55
+ */
56
+ function addUploadListener() {
57
+ g("upload").onclick = function () {
58
+ flashObj.upload();
59
+ this.style.display = "none";
60
+ };
61
+ }
62
+
63
+ function showLocalPath(id) {
64
+ //单张编辑
65
+ var img = editor.selection.getRange().getClosedNode();
66
+ if(editor.word_img.length==1 || img && img.tagName == 'IMG'){
67
+ g(id).value = editor.word_img[0];
68
+ return;
69
+ }
70
+ var path = editor.word_img[0];
71
+ var leftSlashIndex = path.lastIndexOf("/")||0, //不同版本的doc和浏览器都可能影响到这个符号,故直接判断两种
72
+ rightSlashIndex = path.lastIndexOf("\\")||0,
73
+ separater = leftSlashIndex > rightSlashIndex ? "/":"\\" ;
74
+
75
+ path = path.substring(0, path.lastIndexOf(separater)+1);
76
+ g(id).value = path;
77
+ }
78
+
79
+ function createFlashUploader(opt, callbacks) {
80
+ //由于lang.flashI18n是静态属性,不可以直接进行修改,否则会影响到后续内容
81
+ var i18n = utils.extend({},lang.flashI18n);
82
+ //处理图片资源地址的编码,补全等问题
83
+ for(var i in i18n){
84
+ if(!(i in {"lang":1,"uploadingTF":1,"imageTF":1,"textEncoding":1}) && i18n[i]){
85
+ i18n[i] = encodeURIComponent(editor.options.langPath + editor.options.lang + "/images/" + i18n[i]);
86
+ }
87
+ }
88
+ opt = utils.extend(opt,i18n,false);
89
+ var option = {
90
+ createOptions:{
91
+ id:'flash',
92
+ url:opt.flashUrl,
93
+ width:opt.width,
94
+ height:opt.height,
95
+ errorMessage:lang.flashError,
96
+ wmode:browser.safari ? 'transparent' : 'window',
97
+ ver:'10.0.0',
98
+ vars:opt,
99
+ container:opt.container
100
+ }
101
+ };
102
+
103
+ option = extendProperty(callbacks, option);
104
+ flashObj = new baidu.flash.imageUploader(option);
105
+ flashContainer = $G(opt.container);
106
+ }
107
+
108
+ function extendProperty(fromObj, toObj) {
109
+ for (var i in fromObj) {
110
+ if (!toObj[i]) {
111
+ toObj[i] = fromObj[i];
112
+ }
113
+ }
114
+ return toObj;
115
+ }
116
+
117
+ //})();
118
+
119
+ function getPasteData(id) {
120
+ baidu.g("msg").innerHTML = lang.copySuccess + "</br>";
121
+ setTimeout(function() {
122
+ baidu.g("msg").innerHTML = "";
123
+ }, 5000);
124
+ return baidu.g(id).value;
125
+ }
126
+
127
+ function createCopyButton(id, dataFrom) {
128
+ baidu.swf.create({
129
+ id:"copyFlash",
130
+ url:"fClipboard_ueditor.swf",
131
+ width:"58",
132
+ height:"25",
133
+ errorMessage:"",
134
+ bgColor:"#CBCBCB",
135
+ wmode:"transparent",
136
+ ver:"10.0.0",
137
+ vars:{
138
+ tid:dataFrom
139
+ }
140
+ }, id
141
+ );
142
+
143
+ var clipboard = baidu.swf.getMovie("copyFlash");
144
+ var clipinterval = setInterval(function() {
145
+ if (clipboard && clipboard.flashInit) {
146
+ clearInterval(clipinterval);
147
+ clipboard.setHandCursor(true);
148
+ clipboard.setContentFuncName("getPasteData");
149
+ //clipboard.setMEFuncName("mouseEventHandler");
150
+ }
151
+
152
+ }, 500);
153
+ }
154
+ createCopyButton("clipboard", "localPath");
@@ -0,0 +1,72 @@
1
+ /*common
2
+ */
3
+ body{margin: 0;}
4
+ table{width:100%;}
5
+ table td{padding:2px 4px;vertical-align: middle;}
6
+ a{text-decoration: none;}
7
+ em{font-style: normal;}
8
+ .border_style1{border: 1px solid #ccc;border-radius: 5px;box-shadow:2px 2px 5px #d3d6da;}
9
+ /*module
10
+ */
11
+ .main{margin: 8px;overflow: hidden;}
12
+
13
+ .hot{float:left;height:335px;}
14
+ .drawBoard{position: relative; cursor: crosshair;}
15
+ .brushBorad{position: absolute;left:0;top:0;z-index: 998;}
16
+ .picBoard{border: none;text-align: center;line-height: 300px;cursor: default;}
17
+ .operateBar{margin-top:10px;font-size:12px;text-align: center;}
18
+ .operateBar span{margin-left: 10px;}
19
+
20
+ .drawToolbar{float:right;width:110px;height:300px;overflow: hidden;}
21
+ .colorBar{margin-top:10px;font-size: 12px;text-align: center;}
22
+ .colorBar a{display:block;width: 10px;height: 10px;border:1px solid #1006F1;border-radius: 3px; box-shadow:2px 2px 5px #d3d6da;opacity: 0.3}
23
+ .sectionBar{margin-top:15px;font-size: 12px;text-align: center;}
24
+ .sectionBar a{display:inline-block;width:10px;height:12px;color: #888;text-indent: -999px;opacity: 0.3}
25
+ .size1{background: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/size.png' %>') 1px center no-repeat ;}
26
+ .size2{background: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/size.png' %>') -10px center no-repeat;}
27
+ .size3{background: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/size.png' %>') -22px center no-repeat;}
28
+ .size4{background: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/size.png' %>') -35px center no-repeat;}
29
+
30
+ .addImgH{position: relative;}
31
+ .addImgH_form{position: absolute;left: 18px;top: -1px;width: 75px;height: 21px;opacity: 0;cursor: pointer;}
32
+ .addImgH_form input{width: 100%;}
33
+ /*scrawl遮罩层
34
+ */
35
+ .maskLayerNull{display: none;}
36
+ .maskLayer{position: absolute;top:0;left:0;width: 100%; height: 100%;opacity: 0.7;
37
+ background-color: #fff;text-align:center;font-weight:bold;line-height:300px;z-index: 1000;}
38
+ /*btn state
39
+ */
40
+ .previousStepH .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/undoH.png' %>');cursor: pointer;}
41
+ .previousStepH .text{color:#888;cursor:pointer;}
42
+ .previousStep .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/undo.png' %>');cursor:default;}
43
+ .previousStep .text{color:#ccc;cursor:default;}
44
+
45
+ .nextStepH .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/redoH.png' %>');cursor: pointer;}
46
+ .nextStepH .text{color:#888;cursor:pointer;}
47
+ .nextStep .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/redo.png' %>');cursor:default;}
48
+ .nextStep .text{color:#ccc;cursor:default;}
49
+
50
+ .clearBoardH .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/emptyH.png' %>');cursor: pointer;}
51
+ .clearBoardH .text{color:#888;cursor:pointer;}
52
+ .clearBoard .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/empty.png' %>');cursor:default;}
53
+ .clearBoard .text{color:#ccc;cursor:default;}
54
+
55
+ .scaleBoardH .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/scaleH.png' %>');cursor: pointer;}
56
+ .scaleBoardH .text{color:#888;cursor:pointer;}
57
+ .scaleBoard .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/scale.png' %>');cursor:default;}
58
+ .scaleBoard .text{color:#ccc;cursor:default;}
59
+
60
+ .removeImgH .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/delimgH.png' %>');cursor: pointer;}
61
+ .removeImgH .text{color:#888;cursor:pointer;}
62
+ .removeImg .icon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/delimg.png' %>');cursor:default;}
63
+ .removeImg .text{color:#ccc;cursor:default;}
64
+
65
+ .addImgH .icon{vertical-align:top;display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/addimg.png' %>')}
66
+ .addImgH .text{color:#888;cursor:pointer;}
67
+ /*icon
68
+ */
69
+ .brushIcon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/brush.png' %>')}
70
+ .eraserIcon{display: inline-block;width:16px;height:16px;background-image: url('<%= asset_path 'ueditor_rails/dialogs/scrawl/eraser.png' %>')}
71
+
72
+
@@ -9,5 +9,13 @@ module UeditorRails
9
9
  def image
10
10
 
11
11
  end
12
+
13
+ def wordimage
14
+
15
+ end
16
+
17
+ def scrawl
18
+
19
+ end
12
20
  end
13
21
  end
@@ -2,8 +2,10 @@ require_dependency "ueditor_rails/application_controller"
2
2
 
3
3
  module UeditorRails
4
4
  class LibsController < ApplicationController
5
+ after_filter :set_expires_at
6
+
5
7
  def swf_image_uploader
6
- send_file UeditorRails.ueditor_base_path.join('dialogs/image/imageUploader.swf'),
8
+ send_file UeditorRails.ueditor_base_path.join('third-party/imageUploader.swf'),
7
9
  :disposition => 'inline', :type => 'application/x-shockwave-flash'
8
10
  end
9
11
 
@@ -16,5 +18,16 @@ module UeditorRails
16
18
  send_file UeditorRails.ueditor_base_path.join('third-party/swfupload/swfupload_fp9.swf'),
17
19
  :disposition => 'inline', :type => 'application/x-shockwave-flash'
18
20
  end
21
+
22
+ def fclipboard_ueditor
23
+ send_file UeditorRails.ueditor_base_path.join('third-party/fClipboard_ueditor.swf'),
24
+ :disposition => 'inline', :type => 'application/x-shockwave-flash'
25
+ end
26
+
27
+ protected
28
+
29
+ def set_expires_at
30
+ response.headers['Expires'] = CGI.rfc1123_date(Time.now + 1.weeks)
31
+ end
19
32
  end
20
33
  end
@@ -1,4 +1,27 @@
1
1
  module UeditorRails
2
2
  module ApplicationHelper
3
+ def swfupload_path
4
+ UeditorRails.enable_cross_domain ?
5
+ UeditorRails::Engine.routes.url_helpers.libs_swf_upload_path :
6
+ asset_path('ueditor/third-party/swfupload/swfupload.swf')
7
+ end
8
+
9
+ def swfupload_fp9_path
10
+ UeditorRails.enable_cross_domain ?
11
+ UeditorRails::Engine.routes.url_helpers.libs_swf_upload_fp9_path :
12
+ asset_path('ueditor/third-party/swfupload/swfupload_fp9.swf')
13
+ end
14
+
15
+ def swf_imageuploader_path
16
+ UeditorRails.enable_cross_domain ?
17
+ UeditorRails::Engine.routes.url_helpers.libs_swf_image_uploader_path :
18
+ asset_path('ueditor/third-party/imageUploader.swf')
19
+ end
20
+
21
+ def fclipboard_ueditor_path
22
+ UeditorRails.enable_cross_domain ?
23
+ UeditorRails::Engine.routes.url_helpers.libs_fclipboard_ueditor_path :
24
+ asset_path('ueditor/third-party/fClipboard_ueditor.swf')
25
+ end
3
26
  end
4
27
  end
@@ -4,7 +4,6 @@
4
4
  <head>
5
5
  <title></title>
6
6
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
7
- <%= javascript_include_tag 'ueditor/dialogs/internal' %>
8
7
  <%= stylesheet_link_tag 'ueditor_rails/dialogs/attachment' %>
9
8
  </head>
10
9
  <body>
@@ -18,6 +17,7 @@
18
17
 
19
18
  </div>
20
19
 
20
+ <%= javascript_include_tag 'ueditor/dialogs/internal' %>
21
21
  <%= javascript_include_tag 'ueditor_rails/dialogs/attachment.js' %>
22
22
  <script type="text/javascript">
23
23
  var swfupload,
@@ -29,8 +29,8 @@
29
29
  var settings = {
30
30
  upload_url:editor.options.fileUrl, //附件上传服务器地址
31
31
  file_post_name:editor.options.fileFieldName, //向后台提交的表单名
32
- flash_url:"<%= asset_path 'ueditor/third-party/swfupload/swfupload.swf' %>",
33
- flash9_url:"<%= asset_path 'ueditor/third-party/swfupload/swfupload_fp9.swf' %>",
32
+ flash_url:"<%= swfupload_path %>",
33
+ flash9_url:"<%= swfupload_fp9_path %>",
34
34
  post_params:{"<%= request_forgery_protection_token %>":"<%= form_authenticity_token %>"}, //解决session丢失问题
35
35
  file_size_limit:"100 MB", //文件大小限制,此处仅是前端flash选择时候的限制,具体还需要和后端结合判断
36
36
  file_types:"*.*", //允许的扩展名,多个扩展名之间用分号隔开,支持*通配符
@@ -4,7 +4,6 @@
4
4
  <head>
5
5
  <title></title>
6
6
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
7
- <%= javascript_include_tag 'ueditor/dialogs/internal' %>
8
7
  <%= stylesheet_link_tag 'ueditor_rails/dialogs/image' %>
9
8
  </head>
10
9
  <body>
@@ -89,6 +88,7 @@
89
88
  </div>
90
89
  </div>
91
90
 
91
+ <%= javascript_include_tag 'ueditor/dialogs/internal' %>
92
92
  <%= javascript_include_tag 'ueditor_rails/dialogs/image.js' %>
93
93
  <script type="text/javascript">
94
94
  //全局变量
@@ -106,7 +106,7 @@
106
106
  url:editor.options.imageUrl, // 上传处理页面的url地址
107
107
  ext:"{}", //可向服务器提交的自定义参数列表
108
108
  fileType:'{"description":"'+lang.fileType+'", "extension":"*.gif;*.jpeg;*.png;*.jpg"}', //上传文件格式限制
109
- flashUrl:'<%= asset_path 'ueditor/third-party/imageUploader.swf' %>', //上传用的flash组件地址
109
+ flashUrl:'<%= swf_imageuploader_path %>', //上传用的flash组件地址
110
110
  width:608, //flash的宽度
111
111
  height:272, //flash的高度
112
112
  gridWidth:121, // 每一个预览图片所占的宽度
@@ -0,0 +1,96 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <meta name="robots" content="noindex, nofollow"/>
7
+ <%= stylesheet_link_tag 'ueditor_rails/dialogs/scrawl.css' %>
8
+ </head>
9
+ <body>
10
+ <div class="main" id="J_wrap">
11
+ <div class="hot">
12
+ <div class="drawBoard border_style1">
13
+ <canvas id="J_brushBoard" class="brushBorad" width="360" height="300"></canvas>
14
+ <div id="J_picBoard" class="picBoard" style="width: 360px;height: 300px"></div>
15
+ </div>
16
+ <div id="J_operateBar" class="operateBar">
17
+ <span id="J_previousStep" class="previousStep">
18
+ <em class="icon"></em>
19
+ <em class="text"><var id="lang_input_previousStep"></var></em>
20
+ </span>
21
+ <span id="J_nextStep" class="nextStep">
22
+ <em class="icon"></em>
23
+ <em class="text"><var id="lang_input_nextsStep"></var></em>
24
+ </span>
25
+ <span id="J_clearBoard" class="clearBoard">
26
+ <em class="icon"></em>
27
+ <em class="text"><var id="lang_input_clear"></var></em>
28
+ </span>
29
+ <span id="J_sacleBoard" class="scaleBoard">
30
+ <em class="icon"></em>
31
+ <em class="text"><var id="lang_input_ScalePic"></var></em>
32
+ </span>
33
+ </div>
34
+ </div>
35
+ <div class="drawToolbar border_style1">
36
+ <div id="J_colorBar" class="colorBar"></div>
37
+ <div id="J_brushBar" class="sectionBar">
38
+ <em class="brushIcon"></em>
39
+ <a href="javascript:void(0)" class="size1">1</a>
40
+ <a href="javascript:void(0)" class="size2">3</a>
41
+ <a href="javascript:void(0)" class="size3">5</a>
42
+ <a href="javascript:void(0)" class="size4">7</a>
43
+ </div>
44
+ <div id="J_eraserBar" class="sectionBar">
45
+ <em class="eraserIcon"></em>
46
+ <a href="javascript:void(0)" class="size1">1</a>
47
+ <a href="javascript:void(0)" class="size2">3</a>
48
+ <a href="javascript:void(0)" class="size3">5</a>
49
+ <a href="javascript:void(0)" class="size4">7</a>
50
+ </div>
51
+ <div class="sectionBar">
52
+ <div class="addImgH">
53
+ <em class="icon"></em>
54
+ <em class="text"><var id="lang_input_addPic"></var></em>
55
+
56
+ <form method="post" id="fileForm" enctype="multipart/form-data" class="addImgH_form" target="up">
57
+ <input type="file" name="upfile" id="J_imgTxt"
58
+ accept="image/gif,image/jpeg,image/png,image/jpg,image/bmp"/>
59
+ </form>
60
+ <iframe name="up" style="display: none"></iframe>
61
+ </div>
62
+ </div>
63
+ <div class="sectionBar">
64
+ <span id="J_removeImg" class="removeImg">
65
+ <em class="icon"></em>
66
+ <em class="text"><var id="lang_input_removePic"></var></em>
67
+ </span>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ <div id="J_maskLayer" class="maskLayerNull"></div>
72
+
73
+ <%= javascript_include_tag 'ueditor/dialogs/internal.js' %>
74
+ <%= javascript_include_tag 'ueditor_rails/dialogs/scrawl.js' %>
75
+ <script type="text/javascript">
76
+ var settings = {
77
+ drawBrushSize: 3, //画笔初始大小
78
+ drawBrushColor: "#4bacc6", //画笔初始颜色
79
+ colorList: ['c00000', 'ff0000', 'ffc000', 'ffff00', '92d050', '00b050', '00b0f0', '0070c0', '002060', '7030a0', 'ffffff',
80
+ '000000', 'eeece1', '1f497d', '4f81bd', 'c0504d', '9bbb59', '8064a2', '4bacc6', 'f79646'], //画笔选择颜色
81
+ saveNum: 10 //撤销次数
82
+ };
83
+
84
+ var scrawlObj = new scrawl(settings);
85
+ scrawlObj.isCancelScrawl = false;
86
+
87
+ dialog.onok = function () {
88
+ exec(scrawlObj);
89
+ return false;
90
+ };
91
+ dialog.oncancel = function () {
92
+ scrawlObj.isCancelScrawl = true;
93
+ };
94
+ </script>
95
+ </body>
96
+ </html>
@@ -0,0 +1,155 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title></title>
6
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
7
+ <style type="text/css">
8
+ .wrapper {
9
+ width: 600px;
10
+ padding: 10px;
11
+ height: 352px;
12
+ overflow: hidden;
13
+ position: relative;
14
+ border-bottom: 1px solid #d7d7d7
15
+ }
16
+
17
+ .localPath input {
18
+ float: left;
19
+ width: 350px;
20
+ line-height: 20px;
21
+ height: 20px;
22
+ }
23
+
24
+ #clipboard {
25
+ float: left;
26
+ width: 70px;
27
+ height: 30px;
28
+ }
29
+
30
+ .description {
31
+ color: #0066cc;
32
+ margin-top: 2px;
33
+ width: 450px;
34
+ height: 45px;
35
+ float: left;
36
+ line-height: 22px
37
+ }
38
+
39
+ #upload {
40
+ width: 100px;
41
+ height: 30px;
42
+ float: right;
43
+ margin: 10px 2px 0 0;
44
+ cursor: pointer;
45
+ }
46
+
47
+ #msg {
48
+ width: 140px;
49
+ height: 30px;
50
+ line-height: 25px;
51
+ float: left;
52
+ color: red
53
+ }
54
+ </style>
55
+ </head>
56
+ <body>
57
+ <div class="wrapper">
58
+ <div class="localPath">
59
+ <input id="localPath" type="text" readonly/>
60
+
61
+ <div id="clipboard"></div>
62
+ <div id="msg"></div>
63
+ </div>
64
+ <div id="flashContainer"></div>
65
+ <div>
66
+ <div id="upload" style="display: none"><img id="uploadBtn"></div>
67
+ <div class="description">
68
+ <span style="color: red"><var id="lang_resave"></var>: </span><var id="lang_step"></var>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ <%= javascript_include_tag 'ueditor/dialogs/internal.js' %>
73
+ <%= javascript_include_tag 'ueditor/dialogs/tangram.js' %>
74
+ <%= javascript_include_tag 'ueditor_rails/dialogs/wordimage.js' %>
75
+ <script type="text/javascript">
76
+ //全局变量
77
+ var imageUrls = [], //用于保存从服务器返回的图片信息数组
78
+ selectedImageCount = 0; //当前已选择的但未上传的图片数量
79
+ editor.setOpt({
80
+ wordImageFieldName: "upfile",
81
+ compressSide: 0,
82
+ maxImageSideLength: 900
83
+ });
84
+ utils.domReady(function () {
85
+ //创建Flash相关的参数集合
86
+ var flashOptions = {
87
+ container: "flashContainer", //flash容器id
88
+ url: editor.options.wordImageUrl, // 上传处理页面的url地址
89
+ ext: '{""}', //可向服务器提交的自定义参数列表
90
+ fileType: '{"description":"' + lang.fileType + '", "extension":"*.gif;*.jpeg;*.png;*.jpg"}', //上传文件格式限制
91
+ flashUrl: '<%= swf_imageuploader_path %>', //上传用的flash组件地址
92
+ width: 600, //flash的宽度
93
+ height: 272, //flash的高度
94
+ gridWidth: 120, // 每一个预览图片所占的宽度
95
+ gridHeight: 120, // 每一个预览图片所占的高度
96
+ picWidth: 100, // 单张预览图片的宽度
97
+ picHeight: 100, // 单张预览图片的高度
98
+ uploadDataFieldName: editor.options.wordImageFieldName, // POST请求中图片数据的key
99
+ picDescFieldName: 'pictitle', // POST请求中图片描述的key
100
+ maxSize: 2, // 文件的最大体积,单位M
101
+ compressSize: 1, // 上传前如果图片体积超过该值,会先压缩,单位M
102
+ maxNum: 32, // 单次最大可上传多少个文件
103
+ compressSide: editor.options.compressSide, //等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度
104
+ compressLength: editor.options.maxImageSideLength //能接受的最大边长,超过该值Flash会自动等比压缩
105
+ };
106
+ //回调函数集合,支持传递函数名的字符串、函数句柄以及函数本身三种类型
107
+ var callbacks = {
108
+ selectFileCallback: function (selectFiles) { // 选择文件的回调
109
+ selectedImageCount += selectFiles.length;
110
+ if (selectedImageCount) baidu.g("upload").style.display = "";
111
+ dialog.buttons[0].setDisabled(true); //初始化时置灰确定按钮
112
+ },
113
+ deleteFileCallback: function (delFiles) { // 删除文件的回调
114
+ selectedImageCount -= delFiles.length;
115
+ if (!selectedImageCount) {
116
+ baidu.g("upload").style.display = "none";
117
+ dialog.buttons[0].setDisabled(false); //没有选择图片时重新点亮按钮
118
+ }
119
+ },
120
+ uploadCompleteCallback: function (data) { // 单个文件上传完成的回调
121
+ try {
122
+ var info = eval("(" + data.info + ")");
123
+ info && imageUrls.push(info);
124
+ selectedImageCount--;
125
+ } catch (e) {
126
+ }
127
+ },
128
+ uploadErrorCallback: function (data) { // 单个文件上传失败的回调,
129
+ console && console.log(data);
130
+ },
131
+ allCompleteCallback: function () { // 全部上传完成时的回调
132
+ dialog.buttons[0].setDisabled(false); //上传完毕后点亮按钮
133
+ }
134
+ //exceedFileCallback: 'exceedFileCallback', // 文件超出限制的最大体积时的回调
135
+ //startUploadCallback: startUploadCallback // 开始上传某个文件时的回调
136
+ };
137
+ wordImage.init(flashOptions, callbacks);
138
+ });
139
+ $G("upload").onclick = function () {
140
+ /**
141
+ * 接口imageUploader.setPostParams()可以在提交时设置本次上传提交的参数(包括所有图片)
142
+ * 参数为json对象{"key1":"value1","key2":"value2"},其中key即为向后台post提交的name,value即为值。
143
+ * 其中有一个特殊的保留key值为action,若设置,可以更改本次提交的处理地址
144
+ */
145
+ var postParams = {
146
+ "<%= request_forgery_protection_token %>": "<%= form_authenticity_token %>",
147
+ };
148
+ wordImage.setPostParams(postParams);
149
+ flashObj.upload();
150
+ };
151
+
152
+ </script>
153
+
154
+ </body>
155
+ </html>