smart_editor 0.0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/smart_editor/application.js +15 -0
  5. data/app/assets/javascripts/smart_editor/editor_images.js +1 -0
  6. data/app/assets/stylesheets/smart_editor/application.css +13 -0
  7. data/app/assets/stylesheets/smart_editor/editor_images.css +4 -0
  8. data/app/controllers/smart_editor/application_controller.rb +4 -0
  9. data/app/controllers/smart_editor/editor_images_controller.rb +41 -0
  10. data/app/helpers/smart_editor/application_helper.rb +4 -0
  11. data/app/helpers/smart_editor/editor_images_helper.rb +4 -0
  12. data/app/models/smart_editor/editor_image.rb +7 -0
  13. data/app/uploaders/file_uploader.rb +55 -0
  14. data/app/views/layouts/smart_editor/application.html.erb +14 -0
  15. data/app/views/smart_editor/editor_images/index.html.erb +4 -0
  16. data/config/routes.rb +7 -0
  17. data/db/migrate/20130101074444_create_smart_editor_editor_images.rb +10 -0
  18. data/lib/generators/smart_editor/smart_editor_generator.rb +18 -0
  19. data/lib/generators/smart_editor/templates/public/smart_editor/SmartEditor2Skin.html +635 -0
  20. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/FileUploader.php +22 -0
  21. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/FileUploader_html5.php +25 -0
  22. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/Photo_Quick_UploadPopup.html +100 -0
  23. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/QuickPhotoPopup.js +675 -0
  24. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/callback.html +32 -0
  25. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/jindo.min.js +12686 -0
  26. data/lib/generators/smart_editor/templates/public/smart_editor/popup/quick_photo/jindo_fileUpload.js +390 -0
  27. data/lib/generators/smart_editor/templates/public/smart_editor/smart_editor2_inputarea.html +9 -0
  28. data/lib/generators/smart_editor/templates/public/smart_editor/smart_editor2_inputarea_ie8.html +10 -0
  29. data/lib/smart_editor/class_methods.rb +10 -0
  30. data/lib/smart_editor/engine.rb +5 -0
  31. data/lib/smart_editor/form_builder.rb +11 -0
  32. data/lib/smart_editor/version.rb +3 -0
  33. data/lib/smart_editor.rb +18 -0
  34. data/lib/tasks/smart_editor_tasks.rake +4 -0
  35. data/test/dummy/README.rdoc +261 -0
  36. data/test/dummy/Rakefile +7 -0
  37. data/test/dummy/app/assets/javascripts/application.js +16 -0
  38. data/test/dummy/app/assets/javascripts/posts.js +2 -0
  39. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  40. data/test/dummy/app/assets/stylesheets/posts.css +4 -0
  41. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  42. data/test/dummy/app/controllers/application_controller.rb +3 -0
  43. data/test/dummy/app/controllers/posts_controller.rb +85 -0
  44. data/test/dummy/app/helpers/application_helper.rb +2 -0
  45. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  46. data/test/dummy/app/models/post.rb +4 -0
  47. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  48. data/test/dummy/app/views/posts/_form.html.erb +30 -0
  49. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  50. data/test/dummy/app/views/posts/index.html.erb +27 -0
  51. data/test/dummy/app/views/posts/new.html.erb +5 -0
  52. data/test/dummy/app/views/posts/show.html.erb +20 -0
  53. data/test/dummy/config/application.rb +59 -0
  54. data/test/dummy/config/boot.rb +10 -0
  55. data/test/dummy/config/database.yml +25 -0
  56. data/test/dummy/config/environment.rb +5 -0
  57. data/test/dummy/config/environments/development.rb +37 -0
  58. data/test/dummy/config/environments/production.rb +67 -0
  59. data/test/dummy/config/environments/test.rb +37 -0
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/test/dummy/config/initializers/inflections.rb +15 -0
  62. data/test/dummy/config/initializers/mime_types.rb +5 -0
  63. data/test/dummy/config/initializers/secret_token.rb +7 -0
  64. data/test/dummy/config/initializers/session_store.rb +8 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/locales/en.yml +5 -0
  67. data/test/dummy/config/routes.rb +7 -0
  68. data/test/dummy/config.ru +4 -0
  69. data/test/dummy/db/development.sqlite3 +0 -0
  70. data/test/dummy/db/migrate/20130103085542_create_posts.rb +11 -0
  71. data/test/dummy/db/migrate/20130103090021_create_smart_editor_editor_images.smart_editor.rb +11 -0
  72. data/test/dummy/db/schema.rb +32 -0
  73. data/test/dummy/log/development.log +713 -0
  74. data/test/dummy/public/404.html +26 -0
  75. data/test/dummy/public/422.html +26 -0
  76. data/test/dummy/public/500.html +25 -0
  77. data/test/dummy/public/favicon.ico +0 -0
  78. data/test/dummy/public/smart_editor/SmartEditor2Skin.html +635 -0
  79. data/test/dummy/public/smart_editor/popup/quick_photo/FileUploader.php +22 -0
  80. data/test/dummy/public/smart_editor/popup/quick_photo/FileUploader_html5.php +25 -0
  81. data/test/dummy/public/smart_editor/popup/quick_photo/Photo_Quick_UploadPopup.html +100 -0
  82. data/test/dummy/public/smart_editor/popup/quick_photo/QuickPhotoPopup.js +675 -0
  83. data/test/dummy/public/smart_editor/popup/quick_photo/callback.html +32 -0
  84. data/test/dummy/public/smart_editor/popup/quick_photo/jindo.min.js +12686 -0
  85. data/test/dummy/public/smart_editor/popup/quick_photo/jindo_fileUpload.js +390 -0
  86. data/test/dummy/public/smart_editor/smart_editor2_inputarea.html +9 -0
  87. data/test/dummy/public/smart_editor/smart_editor2_inputarea_ie8.html +10 -0
  88. data/test/dummy/script/rails +6 -0
  89. data/test/dummy/test/fixtures/posts.yml +11 -0
  90. data/test/dummy/test/functional/posts_controller_test.rb +49 -0
  91. data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  92. data/test/dummy/test/unit/post_test.rb +7 -0
  93. data/test/dummy/tmp/cache/assets/C39/A20/sprockets%2Fd75302feb7958c52568020a888775667 +0 -0
  94. data/test/dummy/tmp/cache/assets/C8B/9F0/sprockets%2F42090f88c5061f72460d7c83a9bc8990 +0 -0
  95. data/test/dummy/tmp/cache/assets/C8E/A60/sprockets%2F74b1945f4d4a322ab567f73798c32838 +0 -0
  96. data/test/dummy/tmp/cache/assets/CD4/040/sprockets%2F7c241e3470f7210ab843c109c9d68a4b +0 -0
  97. data/test/dummy/tmp/cache/assets/CE3/740/sprockets%2F200278c67b4dde839345d7b018fed561 +0 -0
  98. data/test/dummy/tmp/cache/assets/CEE/680/sprockets%2F6d653ad72aed952816dd79e63c761417 +0 -0
  99. data/test/dummy/tmp/cache/assets/D12/CA0/sprockets%2Fcd507925f6bb1f62170d028ca668ad98 +0 -0
  100. data/test/dummy/tmp/cache/assets/D13/8A0/sprockets%2Fec89fa303e9609b18f50b6de2831433e +0 -0
  101. data/test/dummy/tmp/cache/assets/D6F/A80/sprockets%2F8893ca0d5d16eb3d85c0964bdbbe3381 +0 -0
  102. data/test/dummy/tmp/cache/assets/D86/AF0/sprockets%2Fcfa5f1244012fcd263cee551afe412b2 +0 -0
  103. data/test/dummy/tmp/cache/assets/D92/5A0/sprockets%2Fb0e45a13b900ecbf7011b78bdff2595e +0 -0
  104. data/test/dummy/tmp/cache/assets/D9D/950/sprockets%2F65093fff17b1aa3bed7e0dda53563b79 +0 -0
  105. data/test/dummy/tmp/cache/assets/DF9/8C0/sprockets%2Fc27a71cbee6a5dffdc2534b267b2fa66 +0 -0
  106. data/test/dummy/tmp/cache/assets/E54/F60/sprockets%2Ff1bba5cc065ebbb83addfbba59f82059 +0 -0
  107. data/test/fixtures/smart_editor/editor_images.yml +11 -0
  108. data/test/functional/smart_editor/editor_images_controller_test.rb +9 -0
  109. data/test/integration/navigation_test.rb +10 -0
  110. data/test/smart_editor_test.rb +7 -0
  111. data/test/test_helper.rb +15 -0
  112. data/test/unit/helpers/smart_editor/editor_images_helper_test.rb +6 -0
  113. data/test/unit/smart_editor/editor_image_test.rb +9 -0
  114. data/vendor/assets/images/smart_editor/bg_b1.png +0 -0
  115. data/vendor/assets/images/smart_editor/bg_find_h3.gif +0 -0
  116. data/vendor/assets/images/smart_editor/bg_line1.gif +0 -0
  117. data/vendor/assets/images/smart_editor/bg_quote2.gif +0 -0
  118. data/vendor/assets/images/smart_editor/bg_set.gif +0 -0
  119. data/vendor/assets/images/smart_editor/bg_tool2.gif +0 -0
  120. data/vendor/assets/images/smart_editor/btn_set.png +0 -0
  121. data/vendor/assets/images/smart_editor/bx_set_110302.gif +0 -0
  122. data/vendor/assets/images/smart_editor/editor_guideline_698.gif +0 -0
  123. data/vendor/assets/images/smart_editor/editor_guideline_890.gif +0 -0
  124. data/vendor/assets/images/smart_editor/icon_set.gif +0 -0
  125. data/vendor/assets/images/smart_editor/photoQuickPopup/bg_drag_image.png +0 -0
  126. data/vendor/assets/images/smart_editor/photoQuickPopup/btn_cancel.png +0 -0
  127. data/vendor/assets/images/smart_editor/photoQuickPopup/btn_confirm.png +0 -0
  128. data/vendor/assets/images/smart_editor/photoQuickPopup/btn_confirm2.png +0 -0
  129. data/vendor/assets/images/smart_editor/photoQuickPopup/btn_del.png +0 -0
  130. data/vendor/assets/images/smart_editor/photoQuickPopup/btn_find.png +0 -0
  131. data/vendor/assets/images/smart_editor/text_tool_set.png +0 -0
  132. data/vendor/assets/images/smart_editor/text_tool_set2.png +0 -0
  133. data/vendor/assets/javascripts/smart_editor/HuskyEZCreator.js +133 -0
  134. data/vendor/assets/javascripts/smart_editor/SE2B_Configuration.js +77 -0
  135. data/vendor/assets/javascripts/smart_editor/SE2BasicCreator.js +85 -0
  136. data/vendor/assets/javascripts/smart_editor/hp_SE2M_AttachQuickPhoto.js +106 -0
  137. data/vendor/assets/javascripts/smart_editor/jindo.min.js +12699 -0
  138. data/vendor/assets/javascripts/smart_editor/jindo_component.js +279 -0
  139. data/vendor/assets/javascripts/smart_editor/loader-min.js +120 -0
  140. data/vendor/assets/javascripts/smart_editor.js +21 -0
  141. data/vendor/assets/stylesheets/smart_editor/smart_editor2.css +262 -0
  142. data/vendor/assets/stylesheets/smart_editor/smart_editor2_in.css +20 -0
  143. data/vendor/assets/stylesheets/smart_editor/smart_editor2_items.css +454 -0
  144. data/vendor/assets/stylesheets/smart_editor/smart_editor2_out.css +24 -0
  145. metadata +331 -0
@@ -0,0 +1,390 @@
1
+ /**
2
+ * Jindo Component
3
+ * @version 1.0.3
4
+ * NHN_Library:Jindo_Component-1.0.3;JavaScript Components for Jindo;
5
+ * @include Component, UIComponent, FileUploader
6
+ */
7
+ jindo.Component = jindo.$Class({
8
+ _htEventHandler: null,
9
+ _htOption: null,
10
+ $init: function () {
11
+ var aInstance = this.constructor.getInstance();
12
+ aInstance.push(this);
13
+ this._htEventHandler = {};
14
+ this._htOption = {};
15
+ this._htOption._htSetter = {};
16
+ },
17
+ option: function (sName, vValue) {
18
+ switch (typeof sName) {
19
+ case "undefined":
20
+ return this._htOption;
21
+ case "string":
22
+ if (typeof vValue != "undefined") {
23
+ if (sName == "htCustomEventHandler") {
24
+ if (typeof this._htOption[sName] == "undefined") {
25
+ this.attach(vValue);
26
+ } else {
27
+ return this;
28
+ }
29
+ }
30
+ this._htOption[sName] = vValue;
31
+ if (typeof this._htOption._htSetter[sName] == "function") {
32
+ this._htOption._htSetter[sName](vValue);
33
+ }
34
+ } else {
35
+ return this._htOption[sName];
36
+ }
37
+ break;
38
+ case "object":
39
+ for (var sKey in sName) {
40
+ if (sKey == "htCustomEventHandler") {
41
+ if (typeof this._htOption[sKey] == "undefined") {
42
+ this.attach(sName[sKey]);
43
+ } else {
44
+ continue;
45
+ }
46
+ }
47
+ this._htOption[sKey] = sName[sKey];
48
+ if (typeof this._htOption._htSetter[sKey] == "function") {
49
+ this._htOption._htSetter[sKey](sName[sKey]);
50
+ }
51
+ }
52
+ break;
53
+ }
54
+ return this;
55
+ },
56
+ optionSetter: function (sName, fSetter) {
57
+ switch (typeof sName) {
58
+ case "undefined":
59
+ return this._htOption._htSetter;
60
+ case "string":
61
+ if (typeof fSetter != "undefined") {
62
+ this._htOption._htSetter[sName] = jindo.$Fn(fSetter, this).bind();
63
+ } else {
64
+ return this._htOption._htSetter[sName];
65
+ }
66
+ break;
67
+ case "object":
68
+ for (var sKey in sName) {
69
+ this._htOption._htSetter[sKey] = jindo.$Fn(sName[sKey], this).bind();
70
+ }
71
+ break;
72
+ }
73
+ return this;
74
+ },
75
+ fireEvent: function (sEvent, oEvent) {
76
+ oEvent = oEvent || {};
77
+ var fInlineHandler = this['on' + sEvent],
78
+ aHandlerList = this._htEventHandler[sEvent] || [],
79
+ bHasInlineHandler = typeof fInlineHandler == "function",
80
+ bHasHandlerList = aHandlerList.length > 0;
81
+ if (!bHasInlineHandler && !bHasHandlerList) {
82
+ return true;
83
+ }
84
+ aHandlerList = aHandlerList.concat();
85
+ oEvent.sType = sEvent;
86
+ if (typeof oEvent._aExtend == 'undefined') {
87
+ oEvent._aExtend = [];
88
+ oEvent.stop = function () {
89
+ if (oEvent._aExtend.length > 0) {
90
+ oEvent._aExtend[oEvent._aExtend.length - 1].bCanceled = true;
91
+ }
92
+ };
93
+ }
94
+ oEvent._aExtend.push({
95
+ sType: sEvent,
96
+ bCanceled: false
97
+ });
98
+ var aArg = [oEvent],
99
+ i, nLen;
100
+ for (i = 2, nLen = arguments.length; i < nLen; i++) {
101
+ aArg.push(arguments[i]);
102
+ }
103
+ if (bHasInlineHandler) {
104
+ fInlineHandler.apply(this, aArg);
105
+ }
106
+ if (bHasHandlerList) {
107
+ var fHandler;
108
+ for (i = 0, fHandler;
109
+ (fHandler = aHandlerList[i]); i++) {
110
+ fHandler.apply(this, aArg);
111
+ }
112
+ }
113
+ return !oEvent._aExtend.pop().bCanceled;
114
+ },
115
+ attach: function (sEvent, fHandlerToAttach) {
116
+ if (arguments.length == 1) {
117
+ jindo.$H(arguments[0]).forEach(jindo.$Fn(function (fHandler, sEvent) {
118
+ this.attach(sEvent, fHandler);
119
+ }, this).bind());
120
+ return this;
121
+ }
122
+ var aHandler = this._htEventHandler[sEvent];
123
+ if (typeof aHandler == 'undefined') {
124
+ aHandler = this._htEventHandler[sEvent] = [];
125
+ }
126
+ aHandler.push(fHandlerToAttach);
127
+ return this;
128
+ },
129
+ detach: function (sEvent, fHandlerToDetach) {
130
+ if (arguments.length == 1) {
131
+ jindo.$H(arguments[0]).forEach(jindo.$Fn(function (fHandler, sEvent) {
132
+ this.detach(sEvent, fHandler);
133
+ }, this).bind());
134
+ return this;
135
+ }
136
+ var aHandler = this._htEventHandler[sEvent];
137
+ if (aHandler) {
138
+ for (var i = 0, fHandler;
139
+ (fHandler = aHandler[i]); i++) {
140
+ if (fHandler === fHandlerToDetach) {
141
+ aHandler = aHandler.splice(i, 1);
142
+ break;
143
+ }
144
+ }
145
+ }
146
+ return this;
147
+ },
148
+ detachAll: function (sEvent) {
149
+ var aHandler = this._htEventHandler;
150
+ if (arguments.length) {
151
+ if (typeof aHandler[sEvent] == 'undefined') {
152
+ return this;
153
+ }
154
+ delete aHandler[sEvent];
155
+ return this;
156
+ }
157
+ for (var o in aHandler) {
158
+ delete aHandler[o];
159
+ }
160
+ return this;
161
+ }
162
+ });
163
+ jindo.Component.factory = function (aObject, htOption) {
164
+ var aReturn = [],
165
+ oInstance;
166
+ if (typeof htOption == "undefined") {
167
+ htOption = {};
168
+ }
169
+ for (var i = 0, el;
170
+ (el = aObject[i]); i++) {
171
+ oInstance = new this(el, htOption);
172
+ aReturn[aReturn.length] = oInstance;
173
+ }
174
+ return aReturn;
175
+ };
176
+ jindo.Component.getInstance = function () {
177
+ if (typeof this._aInstance == "undefined") {
178
+ this._aInstance = [];
179
+ }
180
+ return this._aInstance;
181
+ };
182
+ jindo.UIComponent = jindo.$Class({
183
+ $init: function () {
184
+ this._bIsActivating = false;
185
+ },
186
+ isActivating: function () {
187
+ return this._bIsActivating;
188
+ },
189
+ activate: function () {
190
+ if (this.isActivating()) {
191
+ return this;
192
+ }
193
+ this._bIsActivating = true;
194
+ if (arguments.length > 0) {
195
+ this._onActivate.apply(this, arguments);
196
+ } else {
197
+ this._onActivate();
198
+ }
199
+ return this;
200
+ },
201
+ deactivate: function () {
202
+ if (!this.isActivating()) {
203
+ return this;
204
+ }
205
+ this._bIsActivating = false;
206
+ if (arguments.length > 0) {
207
+ this._onDeactivate.apply(this, arguments);
208
+ } else {
209
+ this._onDeactivate();
210
+ }
211
+ return this;
212
+ }
213
+ }).extend(jindo.Component);
214
+ jindo.FileUploader = jindo.$Class({
215
+ _bIsActivating: false,
216
+ _aHiddenInput: [],
217
+ $init: function (elFileSelect, htOption) {
218
+ var htDefaultOption = {
219
+ sUrl: '',
220
+ sCallback: '',
221
+ htData: {},
222
+ sFiletype: '*',
223
+ sMsgNotAllowedExt: "업로드가 허용되지 않는 파일형식입니다",
224
+ bAutoUpload: false,
225
+ bAutoReset: true,
226
+ bActivateOnload: true
227
+ };
228
+ this.option(htDefaultOption);
229
+ this.option(htOption || {});
230
+ this._el = jindo.$(elFileSelect);
231
+ this._wel = jindo.$Element(this._el);
232
+ this._elForm = this._el.form;
233
+ this._aHiddenInput = [];
234
+ this.constructor._oCallback = {};
235
+ this._wfChange = jindo.$Fn(this._onFileSelectChange, this);
236
+ if (this.option("bActivateOnload")) {
237
+ this.activate();
238
+ }
239
+ },
240
+ _appendIframe: function () {
241
+ var sIframeName = 'tmpFrame_' + this._makeUniqueId();
242
+ this._welIframe = jindo.$Element(jindo.$('<iframe name="' + sIframeName + '" src="' + this.option("sCallback") + '?blank">')).css({
243
+ width: '10px',
244
+ border: '2px',
245
+ height: '10px',
246
+ left: '10px',
247
+ top: '10px'
248
+ });
249
+ document.body.appendChild(this._welIframe.$value());
250
+ },
251
+ _removeIframe: function () {
252
+ this._welIframe.leave();
253
+ },
254
+ getBaseElement: function () {
255
+ return this.getFileSelect();
256
+ },
257
+ getFileSelect: function () {
258
+ return this._el;
259
+ },
260
+ getFormElement: function () {
261
+ return this._elForm;
262
+ },
263
+ upload: function () {
264
+ this._appendIframe();
265
+ var elForm = this.getFormElement(),
266
+ welForm = jindo.$Element(elForm),
267
+ sIframeName = this._welIframe.attr("name"),
268
+ sFunctionName = sIframeName + '_func',
269
+ sAction = this.option("sUrl");
270
+ welForm.attr({
271
+ target: sIframeName,
272
+ action: sAction
273
+ });
274
+ this._aHiddenInput.push(this._createElement('input', {
275
+ 'type': 'hidden',
276
+ 'name': 'callback',
277
+ 'value': this.option("sCallback")
278
+ }));
279
+ this._aHiddenInput.push(this._createElement('input', {
280
+ 'type': 'hidden',
281
+ 'name': 'callback_func',
282
+ 'value': sFunctionName
283
+ }));
284
+ for (var k in this.option("htData")) {
285
+ this._aHiddenInput.push(this._createElement('input', {
286
+ 'type': 'hidden',
287
+ 'name': k,
288
+ 'value': this.option("htData")[k]
289
+ }));
290
+ }
291
+ for (var i = 0; i < this._aHiddenInput.length; i++) {
292
+ elForm.appendChild(this._aHiddenInput[i]);
293
+ }
294
+ this.constructor._oCallback[sFunctionName + '_success'] = jindo.$Fn(function (oParameter) {
295
+ this.fireEvent("success", {
296
+ htResult: oParameter
297
+ });
298
+ delete this.constructor._oCallback[oParameter.callback_func + '_success'];
299
+ delete this.constructor._oCallback[oParameter.callback_func + '_error'];
300
+ for (var i = 0; i < this._aHiddenInput.length; i++) {
301
+ jindo.$Element(this._aHiddenInput[i]).leave();
302
+ }
303
+ this._aHiddenInput.length = 0;
304
+ this._removeIframe();
305
+ }, this).bind();
306
+ this.constructor._oCallback[sFunctionName + '_error'] = jindo.$Fn(function (oParameter) {
307
+ this.fireEvent("error", {
308
+ htResult: oParameter
309
+ });
310
+ delete this.constructor._oCallback[oParameter.callback_func + '_success'];
311
+ delete this.constructor._oCallback[oParameter.callback_func + '_error'];
312
+ for (var i = 0; i < this._aHiddenInput.length; i++) {
313
+ jindo.$Element(this._aHiddenInput[i]).leave();
314
+ }
315
+ this._aHiddenInput.length = 0;
316
+ this._removeIframe();
317
+ }, this).bind();
318
+
319
+ elForm.submit();
320
+ if (this.option("bAutoReset")) {
321
+ this.reset();
322
+ }
323
+ },
324
+ reset: function () {
325
+ var elWrapForm = jindo.$("<form>");
326
+ this._wel.wrap(elWrapForm);
327
+ elWrapForm.reset();
328
+ jindo.$Element(elWrapForm).replace(this._el);
329
+ var elForm = this.getFormElement(),
330
+ welForm = jindo.$Element(elForm);
331
+ welForm.attr({
332
+ target: this._sPrevTarget,
333
+ action: this._sAction
334
+ });
335
+ return this;
336
+ },
337
+ _onActivate: function () {
338
+ var elForm = this.getFormElement(),
339
+ welForm = jindo.$Element(elForm);
340
+ this._sPrevTarget = welForm.attr("target");
341
+ this._sAction = welForm.attr("action");
342
+ this._el.value = "";
343
+ this._wfChange.attach(this._el, "change");
344
+ },
345
+ _onDeactivate: function () {
346
+ this._wfChange.detach(this._el, "change");
347
+ },
348
+ _makeUniqueId: function () {
349
+ return new Date().getMilliseconds() + Math.floor(Math.random() * 100000);
350
+ },
351
+ _createElement: function (name, attributes) {
352
+ var el = jindo.$("<" + name + ">");
353
+ var wel = jindo.$Element(el);
354
+ for (var k in attributes) {
355
+ wel.attr(k, attributes[k]);
356
+ }
357
+ return el;
358
+ },
359
+ _checkExtension: function (sFile) {
360
+ var aType = this.option("sFiletype").split(';');
361
+ for (var i = 0, sType; i < aType.length; i++) {
362
+ sType = (aType[i] == "*.*") ? "*" : aType[i];
363
+ sType = sType.replace(/^\s+|\s+$/, '');
364
+ sType = sType.replace(/\./g, '\\.');
365
+ sType = sType.replace(/\*/g, '[^\\\/]+');
366
+ if ((new RegExp(sType + '$', 'gi')).test(sFile)) {
367
+ return true;
368
+ }
369
+ }
370
+ return false;
371
+ },
372
+ _onFileSelectChange: function (we) {
373
+ var sValue = we.element.value,
374
+ bAllowed = this._checkExtension(sValue),
375
+ htParam = {
376
+ sValue: sValue,
377
+ bAllowed: bAllowed,
378
+ sMsgNotAllowedExt: this.option("sMsgNotAllowedExt")
379
+ };
380
+ if (sValue.length && this.fireEvent("select", htParam)) {
381
+ if (bAllowed) {
382
+ if (this.option("bAutoUpload")) {
383
+ this.upload();
384
+ }
385
+ } else {
386
+ alert(htParam.sMsgNotAllowedExt);
387
+ }
388
+ }
389
+ }
390
+ }).extend(jindo.UIComponent);
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html lang="ko">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Smart Editor&#8482; WYSIWYG Mode</title>
6
+ <link href="/assets/smart_editor/smart_editor2_in.css" rel="stylesheet" type="text/css">
7
+ </head>
8
+ <body class="se2_inputarea" style="height:0"></body>
9
+ </html>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html lang="ko">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
6
+ <title>Smart Editor&#8482; WYSIWYG Mode</title>
7
+ <link href="/assets/smart_editor/smart_editor2_in.css" rel="stylesheet" type="text/css">
8
+ </head>
9
+ <body class="se2_inputarea" style="height:0"></body>
10
+ </html>
@@ -0,0 +1,10 @@
1
+ module ActiveRecord
2
+ module Associations
3
+ module ClassMethods
4
+ def has_editor_images
5
+ has_many :editor_images, :as => :attachable, :class_name => "SmartEditor::EditorImage", :dependent => :destroy
6
+ attr_accessible :editor_image_ids
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module SmartEditor
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace SmartEditor
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module ActionView
2
+ module Helpers
3
+ class FormBuilder
4
+ def editor_image_field
5
+ method = "editor_image_ids"
6
+ options = {:value => "[]", :class => "image_ids"}
7
+ hidden_field(method, options)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module SmartEditor
2
+ VERSION = "0.0.2.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ require "smart_editor/engine"
2
+ require "smart_editor/class_methods"
3
+ require "smart_editor/form_builder"
4
+
5
+ module SmartEditor
6
+ def self.bind_editor_images(controller, model_name, actions)
7
+ controller.class_eval <<-eos
8
+ before_filter :_bind_image, :only => [#{actions.map{|a| ":#{a}" } .join(",")}]
9
+ def _bind_image
10
+ if params[:#{model_name}][:editor_image_ids] == "[]" or params["#{model_name}"]["editor_image_ids"].blank?
11
+ params[:#{model_name}].delete("editor_image_ids")
12
+ else
13
+ params[:#{model_name}][:editor_image_ids] = params[:#{model_name}][:editor_image_ids].gsub('[','').sub(']','').split(",")
14
+ end
15
+ end
16
+ eos
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :smart_editor do
3
+ # # Task goes here
4
+ # end