jwysiwyg_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.document +5 -0
  2. data/Gemfile +14 -0
  3. data/Gemfile.lock +98 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/app/assets/images/ajax-loader.gif +0 -0
  9. data/app/assets/images/jquery.wysiwyg.bg.png +0 -0
  10. data/app/assets/images/jquery.wysiwyg.gif +0 -0
  11. data/app/assets/images/jquery.wysiwyg.jpg +0 -0
  12. data/app/assets/images/jquery.wysiwyg.no-alpha.gif +0 -0
  13. data/app/assets/images/plugins/fileManager/icon.png +0 -0
  14. data/app/assets/images/plugins/fileManager/images/application.png +0 -0
  15. data/app/assets/images/plugins/fileManager/images/code.png +0 -0
  16. data/app/assets/images/plugins/fileManager/images/css.png +0 -0
  17. data/app/assets/images/plugins/fileManager/images/db.png +0 -0
  18. data/app/assets/images/plugins/fileManager/images/directory.png +0 -0
  19. data/app/assets/images/plugins/fileManager/images/doc.png +0 -0
  20. data/app/assets/images/plugins/fileManager/images/file.png +0 -0
  21. data/app/assets/images/plugins/fileManager/images/film.png +0 -0
  22. data/app/assets/images/plugins/fileManager/images/flash.png +0 -0
  23. data/app/assets/images/plugins/fileManager/images/folder_open.png +0 -0
  24. data/app/assets/images/plugins/fileManager/images/html.png +0 -0
  25. data/app/assets/images/plugins/fileManager/images/java.png +0 -0
  26. data/app/assets/images/plugins/fileManager/images/linux.png +0 -0
  27. data/app/assets/images/plugins/fileManager/images/mkdir.png +0 -0
  28. data/app/assets/images/plugins/fileManager/images/music.png +0 -0
  29. data/app/assets/images/plugins/fileManager/images/pdf.png +0 -0
  30. data/app/assets/images/plugins/fileManager/images/php.png +0 -0
  31. data/app/assets/images/plugins/fileManager/images/picture.png +0 -0
  32. data/app/assets/images/plugins/fileManager/images/ppt.png +0 -0
  33. data/app/assets/images/plugins/fileManager/images/prev-directory.png +0 -0
  34. data/app/assets/images/plugins/fileManager/images/psd.png +0 -0
  35. data/app/assets/images/plugins/fileManager/images/remove.png +0 -0
  36. data/app/assets/images/plugins/fileManager/images/rename.png +0 -0
  37. data/app/assets/images/plugins/fileManager/images/ruby.png +0 -0
  38. data/app/assets/images/plugins/fileManager/images/script.png +0 -0
  39. data/app/assets/images/plugins/fileManager/images/txt.png +0 -0
  40. data/app/assets/images/plugins/fileManager/images/upload.png +0 -0
  41. data/app/assets/images/plugins/fileManager/images/xls.png +0 -0
  42. data/app/assets/images/plugins/fileManager/images/zip.png +0 -0
  43. data/app/assets/javascripts/controls/wysiwyg.colorpicker.js +250 -0
  44. data/app/assets/javascripts/controls/wysiwyg.cssWrap.js +134 -0
  45. data/app/assets/javascripts/controls/wysiwyg.image.js +285 -0
  46. data/app/assets/javascripts/controls/wysiwyg.link.js +249 -0
  47. data/app/assets/javascripts/controls/wysiwyg.table.js +129 -0
  48. data/app/assets/javascripts/i18n/lang.cs.js +116 -0
  49. data/app/assets/javascripts/i18n/lang.de.js +94 -0
  50. data/app/assets/javascripts/i18n/lang.en.js +117 -0
  51. data/app/assets/javascripts/i18n/lang.es.js +94 -0
  52. data/app/assets/javascripts/i18n/lang.fr.js +94 -0
  53. data/app/assets/javascripts/i18n/lang.he.js +94 -0
  54. data/app/assets/javascripts/i18n/lang.hr.js +98 -0
  55. data/app/assets/javascripts/i18n/lang.it.js +94 -0
  56. data/app/assets/javascripts/i18n/lang.ja.js +95 -0
  57. data/app/assets/javascripts/i18n/lang.nl.js +94 -0
  58. data/app/assets/javascripts/i18n/lang.pl.js +94 -0
  59. data/app/assets/javascripts/i18n/lang.pt_br.js +94 -0
  60. data/app/assets/javascripts/i18n/lang.ru.js +117 -0
  61. data/app/assets/javascripts/i18n/lang.se.js +94 -0
  62. data/app/assets/javascripts/i18n/lang.sl.js +94 -0
  63. data/app/assets/javascripts/i18n/lang.zh-cn.js +93 -0
  64. data/app/assets/javascripts/plugins/wysiwyg.autoload.js +61 -0
  65. data/app/assets/javascripts/plugins/wysiwyg.fileManager.js +572 -0
  66. data/app/assets/javascripts/plugins/wysiwyg.fullscreen.js +141 -0
  67. data/app/assets/javascripts/plugins/wysiwyg.i18n.js +99 -0
  68. data/app/assets/javascripts/plugins/wysiwyg.rmFormat.js +357 -0
  69. data/app/assets/stylesheets/jquery.wysiwyg.css +95 -0
  70. data/app/assets/stylesheets/jquery.wysiwyg.modal.css +62 -0
  71. data/app/assets/stylesheets/jquery.wysiwyg.old-school.css +63 -0
  72. data/app/assets/stylesheets/jwysiwyg.css +1 -0
  73. data/app/assets/stylesheets/plugins/fileManager/wysiwyg.fileManager.css +113 -0
  74. data/jwysiwyg_rails.gemspec +129 -0
  75. data/lib/engine.rb +8 -0
  76. data/lib/jwysiwyg_rails.rb +14 -0
  77. data/test/helper.rb +18 -0
  78. data/test/test_jwysiwyg_rails.rb +7 -0
  79. metadata +219 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
14
+ gem "rails", "~>3.1"
data/Gemfile.lock ADDED
@@ -0,0 +1,98 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.3)
5
+ actionpack (= 3.1.3)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.3)
8
+ activemodel (= 3.1.3)
9
+ activesupport (= 3.1.3)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.5)
14
+ rack-cache (~> 1.1)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.3)
18
+ activemodel (3.1.3)
19
+ activesupport (= 3.1.3)
20
+ builder (~> 3.0.0)
21
+ i18n (~> 0.6)
22
+ activerecord (3.1.3)
23
+ activemodel (= 3.1.3)
24
+ activesupport (= 3.1.3)
25
+ arel (~> 2.2.1)
26
+ tzinfo (~> 0.3.29)
27
+ activeresource (3.1.3)
28
+ activemodel (= 3.1.3)
29
+ activesupport (= 3.1.3)
30
+ activesupport (3.1.3)
31
+ multi_json (~> 1.0)
32
+ arel (2.2.1)
33
+ builder (3.0.0)
34
+ erubis (2.7.0)
35
+ git (1.2.5)
36
+ hike (1.2.1)
37
+ i18n (0.6.0)
38
+ jeweler (1.6.4)
39
+ bundler (~> 1.0)
40
+ git (>= 1.2.5)
41
+ rake
42
+ json (1.6.1)
43
+ mail (2.3.0)
44
+ i18n (>= 0.4.0)
45
+ mime-types (~> 1.16)
46
+ treetop (~> 1.4.8)
47
+ mime-types (1.17.2)
48
+ multi_json (1.0.3)
49
+ polyglot (0.3.3)
50
+ rack (1.3.5)
51
+ rack-cache (1.1)
52
+ rack (>= 0.4)
53
+ rack-mount (0.8.3)
54
+ rack (>= 1.0.0)
55
+ rack-ssl (1.3.2)
56
+ rack
57
+ rack-test (0.6.1)
58
+ rack (>= 1.0)
59
+ rails (3.1.3)
60
+ actionmailer (= 3.1.3)
61
+ actionpack (= 3.1.3)
62
+ activerecord (= 3.1.3)
63
+ activeresource (= 3.1.3)
64
+ activesupport (= 3.1.3)
65
+ bundler (~> 1.0)
66
+ railties (= 3.1.3)
67
+ railties (3.1.3)
68
+ actionpack (= 3.1.3)
69
+ activesupport (= 3.1.3)
70
+ rack-ssl (~> 1.3.2)
71
+ rake (>= 0.8.7)
72
+ rdoc (~> 3.4)
73
+ thor (~> 0.14.6)
74
+ rake (0.9.2.2)
75
+ rcov (0.9.11)
76
+ rdoc (3.11)
77
+ json (~> 1.4)
78
+ shoulda (2.11.3)
79
+ sprockets (2.0.3)
80
+ hike (~> 1.2)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ thor (0.14.6)
84
+ tilt (1.3.3)
85
+ treetop (1.4.10)
86
+ polyglot
87
+ polyglot (>= 0.3.1)
88
+ tzinfo (0.3.31)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ bundler (~> 1.0.0)
95
+ jeweler (~> 1.6.4)
96
+ rails (~> 3.1)
97
+ rcov
98
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jeff Wigal
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = jwysiwyg_rails
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to jwysiwyg_rails
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Jeff Wigal. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "jwysiwyg_rails"
18
+ gem.homepage = "http://github.com/jwigal/jwysiwyg_rails"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Rails 3.1 engine for jwysiwyg}
21
+ gem.description = %Q{Rails 3.1 engine for jwysiwyg}
22
+ gem.email = "jeff@assignr.com"
23
+ gem.authors = ["Jeff Wigal"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "jwysiwyg_rails #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
Binary file
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Controls: Colorpicker plugin
3
+ *
4
+ * Depends on jWYSIWYG, (farbtastic || other colorpicker plugins)
5
+ */
6
+ (function ($) {
7
+ "use strict";
8
+
9
+ if (undefined === $.wysiwyg) {
10
+ throw "wysiwyg.colorpicker.js depends on $.wysiwyg";
11
+ }
12
+
13
+ if (!$.wysiwyg.controls) {
14
+ $.wysiwyg.controls = {};
15
+ }
16
+
17
+ /*
18
+ * Wysiwyg namespace: public properties and methods
19
+ */
20
+ $.wysiwyg.controls.colorpicker = {
21
+ modalOpen: false,
22
+ color: {
23
+ back: {
24
+ prev: "#ffffff",
25
+ palette: []
26
+ },
27
+ fore: {
28
+ prev: "#123456",
29
+ palette: []
30
+ }
31
+ },
32
+
33
+ addColorToPalette: function (type, color) {
34
+ if (-1 === $.inArray(color, this.color[type].palette)) {
35
+ this.color[type].palette.push(color);
36
+ } else {
37
+ this.color[type].palette.sort(function (a, b) {
38
+ if (a === color) {
39
+ return 1;
40
+ }
41
+
42
+ return 0;
43
+ });
44
+ }
45
+ },
46
+
47
+ init: function (Wysiwyg) {
48
+ if ($.wysiwyg.controls.colorpicker.modalOpen === true) {
49
+ return false;
50
+ } else {
51
+ $.wysiwyg.controls.colorpicker.modalOpen = true;
52
+ }
53
+ var self = this, elements, dialog, colorpickerHtml, dialogReplacements, key, translation;
54
+
55
+ dialogReplacements = {
56
+ legend: "Colorpicker",
57
+ color: "Color",
58
+ submit: "Apply",
59
+ reset: "Cancel"
60
+ };
61
+
62
+ colorpickerHtml = '<form class="wysiwyg"><fieldset><legend>{legend}</legend>' +
63
+ '<ul class="palette"></ul>' +
64
+ '<label>{color}: <input type="text" name="color" value="#123456"/></label>' +
65
+ '<div class="wheel"></div>' +
66
+ '<input type="submit" class="button" value="{submit}"/> ' +
67
+ '<input type="reset" value="{reset}"/></fieldset></form>';
68
+
69
+ for (key in dialogReplacements) {
70
+ if ($.wysiwyg.i18n) {
71
+ translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs.colorpicker");
72
+
73
+ if (translation === dialogReplacements[key]) { // if not translated search in dialogs
74
+ translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs");
75
+ }
76
+
77
+ dialogReplacements[key] = translation;
78
+ }
79
+
80
+ colorpickerHtml = colorpickerHtml.replace("{" + key + "}", dialogReplacements[key]);
81
+ }
82
+
83
+ if ($.modal) {
84
+ elements = $(colorpickerHtml);
85
+
86
+ if ($.farbtastic) {
87
+ this.renderPalette(elements, "fore");
88
+ elements.find(".wheel").farbtastic(elements.find("input:text"));
89
+ }
90
+
91
+ $.modal(elements.html(), {
92
+ maxWidth: Wysiwyg.defaults.formWidth,
93
+ maxHeight: Wysiwyg.defaults.formHeight,
94
+ overlayClose: true,
95
+
96
+ onShow: function (dialog) {
97
+ $("input:submit", dialog.data).click(function (e) {
98
+ var color = $('input[name="color"]', dialog.data).val();
99
+ self.color.fore.prev = color;
100
+ self.addColorToPalette("fore", color);
101
+
102
+ if ($.browser.msie) {
103
+ Wysiwyg.ui.returnRange();
104
+ }
105
+
106
+ Wysiwyg.editorDoc.execCommand('ForeColor', false, color);
107
+ $.modal.close();
108
+ return false;
109
+ });
110
+ $("input:reset", dialog.data).click(function (e) {
111
+ if ($.browser.msie) {
112
+ Wysiwyg.ui.returnRange();
113
+ }
114
+
115
+ $.modal.close();
116
+ return false;
117
+ });
118
+ $("fieldset", dialog.data).click(function (e) {
119
+ e.stopPropagation();
120
+ });
121
+ },
122
+
123
+ onClose: function (dialog) {
124
+ $.wysiwyg.controls.colorpicker.modalOpen = false;
125
+ $.modal.close();
126
+ }
127
+ });
128
+ } else if ($.fn.dialog) {
129
+ elements = $(colorpickerHtml);
130
+
131
+ if ($.farbtastic) {
132
+ this.renderPalette(elements, "fore");
133
+ elements.find(".wheel").farbtastic(elements.find("input:text"));
134
+ }
135
+
136
+ dialog = elements.appendTo("body");
137
+ dialog.dialog({
138
+ modal: true,
139
+
140
+ open: function (event, ui) {
141
+ $("input:submit", elements).click(function (e) {
142
+ var color = $('input[name="color"]', dialog).val();
143
+ self.color.fore.prev = color;
144
+ self.addColorToPalette("fore", color);
145
+
146
+ if ($.browser.msie) {
147
+ Wysiwyg.ui.returnRange();
148
+ }
149
+
150
+ Wysiwyg.editorDoc.execCommand('ForeColor', false, color);
151
+ $(dialog).dialog("close");
152
+ return false;
153
+ });
154
+ $("input:reset", elements).click(function (e) {
155
+ if ($.browser.msie) {
156
+ Wysiwyg.ui.returnRange();
157
+ }
158
+
159
+ $(dialog).dialog("close");
160
+ return false;
161
+ });
162
+ $('fieldset', elements).click(function (e) {
163
+ e.stopPropagation();
164
+ });
165
+ },
166
+
167
+ close: function (event, ui) {
168
+ $.wysiwyg.controls.colorpicker.modalOpen = false;
169
+ dialog.dialog("destroy");
170
+ dialog.remove();
171
+ }
172
+ });
173
+ } else {
174
+ if ($.farbtastic) {
175
+ elements = $("<div/>")
176
+ .css({"position": "fixed",
177
+ "z-index": 2000,
178
+ "left": "50%", "top": "50%", "background": "rgb(0, 0, 0)",
179
+ "margin-top": -1 * Math.round(Wysiwyg.defaults.formHeight / 2),
180
+ "margin-left": -1 * Math.round(Wysiwyg.defaults.formWidth / 2)})
181
+ .html(colorpickerHtml);
182
+ this.renderPalette(elements, "fore");
183
+ elements.find("input[name=color]").val(self.color.fore.prev);
184
+ elements.find(".wheel").farbtastic(elements.find("input:text"));
185
+ $("input:submit", elements).click(function (event) {
186
+ var color = $('input[name="color"]', elements).val();
187
+ self.color.fore.prev = color;
188
+ self.addColorToPalette("fore", color);
189
+
190
+ if ($.browser.msie) {
191
+ Wysiwyg.ui.returnRange();
192
+ }
193
+
194
+ Wysiwyg.editorDoc.execCommand('ForeColor', false, color);
195
+
196
+ $(elements).remove();
197
+ $.wysiwyg.controls.colorpicker.modalOpen = false;
198
+ return false;
199
+ });
200
+ $("input:reset", elements).click(function (event) {
201
+
202
+ if ($.browser.msie) {
203
+ Wysiwyg.ui.returnRange();
204
+ }
205
+
206
+ $(elements).remove();
207
+ $.wysiwyg.controls.colorpicker.modalOpen = false;
208
+ return false;
209
+ });
210
+ $("body").append(elements);
211
+ elements.click(function (e) {
212
+ e.stopPropagation();
213
+ });
214
+ }
215
+ }
216
+ },
217
+
218
+ renderPalette: function (jqObj, type) {
219
+ var palette = jqObj.find(".palette"),
220
+ bind = function () {
221
+ var color = $(this).text();
222
+ jqObj.find("input[name=color]").val(color);
223
+ // farbtastic binds on keyup
224
+ if ($.farbtastic) {
225
+ jqObj.find("input[name=color]").trigger("keyup");
226
+ }
227
+ },
228
+ colorExample,
229
+ colorSelect,
230
+ i;
231
+
232
+ for (i = this.color[type].palette.length - 1; i > -1; i -= 1) {
233
+ colorExample = $("<div/>").css({
234
+ "float": "left",
235
+ "width": "16px",
236
+ "height": "16px",
237
+ "margin": "0px 5px 0px 0px",
238
+ "background-color": this.color[type].palette[i]
239
+ });
240
+
241
+ colorSelect = $("<li>" + this.color[type].palette[i] + "</li>")
242
+ .css({"float": "left", "list-style": "none"})
243
+ .append(colorExample)
244
+ .bind("click.wysiwyg", bind);
245
+
246
+ palette.append(colorSelect).css({"margin": "0px", "padding": "0px"});
247
+ }
248
+ }
249
+ };
250
+ })(jQuery);