textile_editor_helper 0.0.14 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/.gitignore +0 -0
  2. data/CHANGELOG.md +14 -0
  3. data/Gemfile +0 -0
  4. data/README.md +54 -95
  5. data/Rakefile +8 -3
  6. data/features/copy_assets.feature +5 -10
  7. data/features/step_definitions/common_steps.rb +0 -0
  8. data/features/step_definitions/rails_setup_steps.rb +0 -0
  9. data/features/support/env.rb +0 -0
  10. data/features/support/setup.rb +0 -0
  11. data/lib/generators/textile_editor_helper/install_generator.rb +4 -13
  12. data/lib/helpers/default.rb +138 -0
  13. data/lib/helpers/formtastic.rb +39 -0
  14. data/lib/helpers/simple_form.rb +27 -0
  15. data/lib/helpers/textile_editor_initialize.rb +19 -0
  16. data/lib/textile_editor_helper/version.rb +1 -1
  17. data/lib/textile_editor_helper.rb +15 -201
  18. data/test/abstract_unit.rb +11 -4
  19. data/test/formtastic_test.rb +21 -0
  20. data/test/simple_form_test.rb +21 -0
  21. data/test/support_methods.rb +54 -0
  22. data/test/test_helper.rb +7 -0
  23. data/test/textile_editor_helper_test.rb +30 -172
  24. data/textile_editor_helper.gemspec +14 -15
  25. data/travis.yml +0 -0
  26. data/vendor/README +26 -31
  27. data/vendor/assets/images/textile-editor/background.png +0 -0
  28. data/vendor/assets/images/textile-editor/blockquote.png +0 -0
  29. data/vendor/assets/images/textile-editor/bold.png +0 -0
  30. data/vendor/assets/images/textile-editor/center.png +0 -0
  31. data/vendor/assets/images/textile-editor/h1.png +0 -0
  32. data/vendor/assets/images/textile-editor/h2.png +0 -0
  33. data/vendor/assets/images/textile-editor/h3.png +0 -0
  34. data/vendor/assets/images/textile-editor/h4.png +0 -0
  35. data/vendor/assets/images/textile-editor/h5.png +0 -0
  36. data/vendor/assets/images/textile-editor/h6.png +0 -0
  37. data/vendor/assets/images/textile-editor/indent.png +0 -0
  38. data/vendor/assets/images/textile-editor/italic.png +0 -0
  39. data/vendor/assets/images/textile-editor/justify.png +0 -0
  40. data/vendor/assets/images/textile-editor/left.png +0 -0
  41. data/vendor/assets/images/textile-editor/list_bullets.png +0 -0
  42. data/vendor/assets/images/textile-editor/list_numbers.png +0 -0
  43. data/vendor/assets/images/textile-editor/omega.png +0 -0
  44. data/vendor/assets/images/textile-editor/outdent.png +0 -0
  45. data/vendor/assets/images/textile-editor/paragraph.png +0 -0
  46. data/vendor/assets/images/textile-editor/right.png +0 -0
  47. data/vendor/assets/images/textile-editor/strikethrough.png +0 -0
  48. data/vendor/assets/images/textile-editor/underline.png +0 -0
  49. data/vendor/assets/javascripts/textile-editor-config.js +0 -0
  50. data/vendor/assets/javascripts/textile-editor.js +0 -0
  51. data/vendor/assets/stylesheets/textile-editor.css +0 -0
  52. metadata +76 -36
  53. data/vendor/app/controllers/textile_preview_controller.rb +0 -14
  54. data/vendor/app/helpers/textile_preview_helper.rb +0 -13
  55. data/vendor/app/views/textile_preview/show.js.coffee +0 -2
data/.gitignore CHANGED
File without changes
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## Version 0.0.30
4
+
5
+ ### Textile Editor Helper now supports simple_form and formtastic
6
+
7
+ * Removed options for simple and extended
8
+ * Removed preview options. The wiki pages will be updated to show different ways to have a preview feature
9
+ * Refactored the helpers and tests
10
+ * Added support for simple_form. fixes <a href="https://github.com/bridgeutopia/textile_editor_helper/issues/2" target="_blank">#2</a>
11
+ * Added support for formtastic. fixes <a href="https://github.com/bridgeutopia/textile_editor_helper/issues/4" target="_blank">#4</a>
12
+ * Fixed some generator bugs.
13
+ * Refactored tests and helpers to make sure there is no duplicated coda
14
+ * Load and require simple_form and formtastic helpers and dependencies only when the gems are found.
data/Gemfile CHANGED
File without changes
data/README.md CHANGED
@@ -1,43 +1,43 @@
1
- Textile Editor Helper
2
- ==========================
1
+ ## Textile Editor Helper [![Build Status](https://secure.travis-ci.org/bridgeutopia/textile_editor_helper.png)](http://travis-ci.org/bridgeutopia/textile_editor_helper)
3
2
 
4
- Textile Editor Helper is a plugin for Ruby on Rails to add a Textile toolbar above textareas
5
-
6
- This version of Textile Editor Helper is a fork of the code found at http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/ to allow for use with the form_for method.
3
+ Textile Editor Helper is a plugin for Ruby on Rails to add a Textile toolbar above textareas.
7
4
 
8
- Dependency
9
- ----------
5
+ This version of Textile Editor Helper is a fork of the code found at http://svn.webtest.wvu.edu/repos/rails/plugins/textile_editor_helper/ to allow for use with the form_for method.
10
6
 
11
- To use Textile Editor Helper you must be using either the jQuery JavaScript library.
12
7
 
13
- jQuery is required and make sure $(document).ready() method is called. Prototype is no longer supported.
8
+ ##Dependencies
14
9
 
15
- For Rails 3.2, vendor/plugins was removed that is why this gem exists.
10
+ To use Textile Editor Helper you must be using either the jQuery JavaScript library.
16
11
 
17
- Travis CI Build Status
18
- -----------------------
12
+ jQuery is required and make sure $(document).ready() method is called.
19
13
 
20
- [![Build Status](https://secure.travis-ci.org/bridgeutopia/textile_editor_helper.png)](http://travis-ci.org/bridgeutopia/textile_editor_helper)
14
+ For Rails 3.2, vendor/plugins was removed that is why this gem exists. Rails versions below 3.2 are not supported. Ruby version 1.8.7 is not supported.
21
15
 
22
16
 
23
- To use Textile Editor Helper
24
- ----------------------------
17
+ ## Rails Quickstart
25
18
 
26
19
  Directions to get the helper up and running for your install:
27
20
 
28
- First, you'll need to add the gems required. RedCloth and htmlentities are for the preview feature.
21
+ First, you'll need to add the gems required. RedCloth (or an alterntative) and htmlentities are also required.
29
22
 
30
- `gem 'textile_editor_helper'`
23
+ gem 'textile_editor_helper'
31
24
 
32
- `gem 'RedCloth'`
25
+ gem 'RedCloth'
33
26
 
34
- `gem 'htmlentities'`
27
+ gem 'htmlentities'
35
28
 
36
29
  and do
37
30
 
38
- `rails g textile_editor_helper:install`
31
+ rails g textile_editor_helper:install
39
32
 
40
- To use the Textile-Editor-Helper with a specific text area, you can choose between the following options:
33
+ It's important that you read the example provided. Your application.js should look like the following. Make sure to update the order of your JS files.
34
+
35
+ //= require jquery
36
+ //= require jquery_ujs
37
+ //= require textile-editor
38
+ //= require textile-editor-config
39
+
40
+ To use the Textile Editor Helper with a specific text area, you can choose between the following options:
41
41
 
42
42
  <%= f.textile_editor :description %>
43
43
 
@@ -45,114 +45,73 @@ To use the Textile-Editor-Helper with a specific text area, you can choose betwe
45
45
 
46
46
  <%= textile_editor_tag 'description', :description %>
47
47
 
48
- **Just like writing a text area tag!**
48
+ ### For simple_form users
49
49
 
50
- At the end of your form put in the following code:
51
-
52
- <%= textile_editor_initialize %> **Important!**
50
+ <%= f.input :body, :as => :textile_editor %>
53
51
 
52
+ ### For formtastic users
54
53
 
55
- Then, just save your view and check it out
54
+ <%= f.input :body, :as => :textile_editor %>
56
55
 
56
+ **Just like writing a text area tag!**
57
57
 
58
- Simple vs. Extended
59
- ===================
58
+ At the end of your form put in the following code:
60
59
 
61
- TEH has a built-in mode to show only a sub-selection of available tags called simple.
60
+ <%= textile_editor_initialize %> **Important!**
62
61
 
63
- Currently the _simple_ tags are: _bold_, _underline_, _italic_, _strikethrough_.
64
62
 
65
- To create a text area that will only use the 'simple' tags create your text area with the following code:
63
+ Then, just save your view and check it out.
66
64
 
67
- <%= textile_editor 'object', 'field', :simple=>true -%>
65
+ ## Examples
68
66
 
69
- or
70
-
71
- <%= f.textile_editor :body, :simple=>true %>
67
+ <a href="https://github.com/bridgeutopia/textile_editor_helper/wiki/Examples" target="_blank">Basic Examples</a>
72
68
 
69
+ Recently created a Rails 3.2.8 app that uses simple_form and textile_editor_helper, <a href="https://github.com/bridgeutopia/textile-editor-helper-examples" target="_blank">check it out</a>.
73
70
 
74
- To Modify Textile Editor Helper
75
- -------------------------------
71
+ ## Testing
76
72
 
77
- Most of the options that you might want to modify (e.g. access keystroke or whether a tag is available in simple) are found in textile_editor_config.js. Pretty straightforward.
73
+ git clone git://github.com/bridgeutopia/textile_editor_helper.git
74
+ cd textile_editor_helper
75
+ bundle install
76
+ bundle exec rake
78
77
 
79
- TESTING (Cucumber is required)
80
- --------------------
81
- bundle exec rake
82
78
 
83
- TEH Preview
84
- --------------------
85
- Recently added a preview feature. To use:
79
+ ## Preview Feature
86
80
 
87
- <%= f.textile_editor :body, :preview=>true %>
88
-
89
- <%= textile_editor_initialize :preview=>true %>
81
+ Textile Editor Preview feature is no longer supported. The wiki page will be updated to show two different ways of adding the preview feature to your app.
90
82
 
91
- Update the helper. If you wish to move this helper to ApplicationHelper to make it work for all views, you have to remove view_context.
83
+ ## Requests for improvement
92
84
 
93
- def to_html(m)
94
- require 'redcloth'
95
- require 'htmlentities'
85
+ A lot of features have been removed and added here. This is completely refactored for simplicity and support of form builders other than the Rails default.
86
+ To request for improvement, please do not send email to the maintainer. Create an issue instead. Thank you.
96
87
 
97
- coder = HTMLEntities.new
98
- m = coder.decode(m)
99
- m = RedCloth.new(m).to_html
100
- view_context.raw m
101
- end
102
-
103
- Update code:
104
88
 
105
- def to_html(m)
106
- require 'redcloth'
107
- require 'htmlentities'
89
+ ## More Info on Textile
108
90
 
109
- coder = HTMLEntities.new
110
- m = coder.decode(m)
111
- m = RedCloth.new(m).to_html
112
- raw m
113
- end
114
-
115
- This is shown in detail on the wiki page. Check it out.
91
+ To learn more about Textile check out: <a href="http://www.textism.com/tools/textile/index.php" target="_blank">Textism</a> & <a href="http://hobix.com/textile/" target="_blank">Textile Reference</a>
116
92
 
117
- Styling TEH Preview
118
- --------------------
119
- Add this to your CSS file and modify as needed:
120
93
 
121
- .textile-preview {
122
- width:83%;
123
- padding:20px;
124
- margin:10px 0px;
125
- border:5px dotted #eee;
126
- display:block;
127
- }
94
+ ## More Info on Slate
128
95
 
96
+ slate is the CMS in development at West Virginia University that led to the development of Textile Editor Helper. Learn more at: http://slateinfo.blogs.wvu.edu
129
97
 
130
- More Info on Textile
131
- --------------------
132
98
 
133
- To learn more about Textile check out: Textism, http://www.textism.com/tools/textile/index.php & Textile Reference, http://hobix.com/textile/
99
+ ## License
134
100
 
101
+ Textile Editor Helper is released under the MIT license.
135
102
 
136
- More Info on Slate
137
- ------------------
138
103
 
139
- slate is the CMS in development at West Virginia University that led to the development of Textile Editor Helper. Learn more at: http://slateinfo.blogs.wvu.edu
104
+ ## Acknowledgements
140
105
 
106
+ Textile Editor Helper was created by Dave Olsen (Javascript) and Chris Scharf (Ruby/Rails) of <a href="http://webservices.wvu.edu/" target="_blank">West Virginia University Web Services</a>
141
107
 
142
- License
143
- -------
144
- Textile Editor Helper is released under the MIT license.
108
+ The project is now maintained by <a href="http://blog.bridgeutopiaweb.com" target="_blank">Katherine G. Pe</a>
145
109
 
146
110
 
147
- Credits
148
- -------
111
+ ## Inspired by
149
112
 
150
- Textile Editor Helper was created by Dave Olsen (Javascript) and Chris Scharf (Ruby/Rails) of West Virginia University Web Services (http://webservices.wvu.edu/)
151
113
 
152
- The project is now, unofficially maintained by Nicolás Hock
114
+ <a href="http://www.hakjoon.com/code/38/textile-quicktags-redirect" target="_blank">Patrick Woods</a> &
115
+ <a href="http://alexking.org/projects/js-quicktags" target="_blank">Alex King</a>
153
116
 
154
- Inspired by
155
- -----------
156
117
 
157
- Patrick Woods, http://www.hakjoon.com/code/38/textile-quicktags-redirect &
158
- Alex King, http://alexking.org/projects/js-quicktags
data/Rakefile CHANGED
@@ -1,8 +1,13 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+ require 'cucumber/rake/task'
5
+
3
6
  task(:default).clear
4
- task :default => [:cucumber]
7
+ task :default => [:cucumber, :test]
5
8
 
9
+ Rake::TestTask.new do |t|
10
+ t.pattern = "test/**/*_test.rb"
11
+ end
6
12
 
7
- require 'cucumber/rake/task'
8
- Cucumber::Rake::Task.new
13
+ Cucumber::Rake::Task.new
@@ -1,17 +1,12 @@
1
1
  Feature: Copy Assets
2
- In order to install the textile editor helper gem
2
+ In order to install the textile editor helper gem
3
3
  As a rails developer
4
- I want to copy the assets to respective directories
4
+ I want to copy the assets to respective directories
5
5
 
6
-
7
- Scenario: Assets are copied to rails asset directories
6
+ Scenario: Assets are copied to rails asset directories if the default generator is used
8
7
  Given a new Rails app
9
8
  When I run "rails g textile_editor_helper:install"
10
9
  Then I should see file "app/assets/stylesheets/textile-editor.css"
11
10
  And I should see file "app/assets/javascripts/textile-editor-config.js"
12
- And I should see file "app/assets/javascripts/textile-editor.js"
13
- And I should see file "public/images/textile-editor/italic.png"
14
- And I should see file "app/controllers/textile_preview_controller.rb"
15
- And I should see file "app/helpers/textile_preview_helper.rb"
16
- And I should see file "app/views/textile_preview/show.js.coffee"
17
- And I should see "textile_preview" in file "config/routes.rb"
11
+ And I should see file "app/assets/javascripts/textile-editor.js"
12
+ And I should see file "public/images/textile-editor/italic.png"
File without changes
File without changes
File without changes
File without changes
@@ -21,7 +21,7 @@ module TextileEditorHelper
21
21
  desc 'Creates a TextileEditorHelper initializer and copies assets to public directories.'
22
22
  end
23
23
 
24
- def copy_javascript_asset
24
+ def copy_assets
25
25
  if asset_pipeline_enabled?
26
26
  js_destination = 'app/assets/javascripts'
27
27
  css_destination = 'app/assets/stylesheets'
@@ -33,20 +33,11 @@ module TextileEditorHelper
33
33
  copy_file 'assets/javascripts/textile-editor.js', "#{js_destination}/textile-editor.js"
34
34
  copy_file 'assets/javascripts/textile-editor-config.js', "#{js_destination}/textile-editor-config.js"
35
35
  copy_file 'assets/stylesheets/textile-editor.css', "#{css_destination}/textile-editor.css"
36
- copy_file 'app/controllers/textile_preview_controller.rb', "app/controllers/textile_preview_controller.rb"
37
- copy_file 'app/helpers/textile_preview_helper.rb', "app/helpers/textile_preview_helper.rb"
38
-
39
-
40
- lines = File.read("config/routes.rb").split("\n")
41
- lines[3, 0] = "match 'textile_preview' => 'textile_preview#show'"
42
- File.open("config/routes.rb", 'w') { |f| f.write(lines.join("\n")) }
43
-
44
-
45
- directory 'app/views/textile_preview', 'app/views/textile_preview'
36
+
46
37
  directory 'assets/images/textile-editor', 'public/images/textile-editor'
47
-
38
+
48
39
  readme 'README' if behavior == :invoke
49
-
40
+
50
41
  end
51
42
  end
52
43
  end
@@ -0,0 +1,138 @@
1
+ require_relative 'textile_editor_initialize'
2
+
3
+ module ActionView::Helpers
4
+ class FormBuilder
5
+ def textile_editor(method, options = {})
6
+ @template.textile_editor(@object_name, method, options.merge(:object => @object))
7
+ end
8
+ end
9
+
10
+ module FormHelper
11
+ # Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+)
12
+ # on an object assigned to the template (identified by +object+). Additional options on the input tag can be passed as a
13
+ # hash with +options+ and places the textile toolbar above it
14
+ #
15
+ # ==== Examples
16
+ # textile_editor(:post, :body, :cols => 20, :rows => 40)
17
+ # # => <textarea cols="20" rows="40" id="post_body" name="post[body]">
18
+ # # #{@post.body}
19
+ # # </textarea>
20
+ #
21
+ # textile_editor(:comment, :text, :size => "20x30")
22
+ # # => <textarea cols="20" rows="30" id="comment_text" name="comment[text]">
23
+ # # #{@comment.text}
24
+ # # </textarea>
25
+ #
26
+ # textile_editor(:application, :notes, :cols => 40, :rows => 15, :class => 'app_input')
27
+ # # => <textarea cols="40" rows="15" id="application_notes" name="application[notes]" class="app_input">
28
+ # # #{@application.notes}
29
+ # # </textarea>
30
+ #
31
+ # textile_editor(:entry, :body, :size => "20x20", :disabled => 'disabled')
32
+ # # => <textarea cols="20" rows="20" id="entry_body" name="entry[body]" disabled="disabled">
33
+ # # #{@entry.body}
34
+ # # </textarea>
35
+ def textile_editor(object_name, method, options = {})
36
+ output = []
37
+ output << InstanceTag.new(object_name, method, self, options.delete(:object)).to_text_area_tag(options.merge(:class=>"textile_editor"))
38
+ output.join("\n").html_safe
39
+ end
40
+
41
+ def textile_editor_options(options={})
42
+ (@textile_editor_options ||= { }).merge! options
43
+ end
44
+
45
+
46
+ def textile_editor_initialize
47
+ unless request.xhr?
48
+ TextileEditorInitialize.textile_editor_initialize
49
+ else
50
+ [].join("\n").html_safe
51
+ end
52
+ end
53
+
54
+ def textile_editor_support
55
+ output = []
56
+ output << stylesheet_link_tag('textile-editor')
57
+ output << javascript_include_tag('textile-editor')
58
+ output.join("\n").html_safe
59
+ end
60
+
61
+ # registers a new button for the Textile Editor toolbar
62
+ # Parameters:
63
+ # * +text+: text to display (contents of button tag, so HTML is valid as well)
64
+ # * +options+: options Hash as supported by +content_tag+ helper in Rails
65
+ #
66
+ # Example:
67
+ # The following example adds a button labeled 'Greeting' which triggers an
68
+ # alert:
69
+ #
70
+ # <% textile_editor_button 'Greeting', :onclick => "alert('Hello!')" %>
71
+ #
72
+ # *Note*: this method must be called before +textile_editor_initialize+
73
+ # TO DO: Test for this feature
74
+ def textile_editor_button(text, options={})
75
+ return textile_editor_button_separator if text == :separator
76
+ button = content_tag(:button, text, options)
77
+ button = "TextileEditor.buttons.push(""#{button}"");".html_safe
78
+ (@textile_editor_buttons ||= []) << button
79
+ end
80
+
81
+
82
+ # adds the necessary javascript include tags, stylesheet tags,
83
+ # and load event with necessary javascript to active textile editor(s)
84
+ # sample output:
85
+ # <link href="/stylesheets/textile-editor.css" media="screen" rel="stylesheet" type="text/css" />
86
+ # <script src="/javascripts/textile-editor.js" type="text/javascript"></script>
87
+ # <script type="text/javascript">
88
+ # document.observe('dom:loaded', function() {
89
+ # TextileEditor.initialize('article_body', 'extended');
90
+ # TextileEditor.initialize('article_body_excerpt', 'simple');
91
+ # });
92
+ # </script>
93
+ #
94
+ # Note: in the case of this helper being called via AJAX, the output will be reduced:
95
+ # <script type="text/javascript">
96
+ # TextileEditor.initialize('article_body', 'extended');
97
+ # TextileEditor.initialize('article_body_excerpt', 'simple');
98
+ # </script>
99
+ #
100
+ # This means that the support files must be loaded outside of the AJAX request, either
101
+ # via a call to this helper or the textile_editor_support() helper
102
+
103
+ end
104
+
105
+ module FormTagHelper
106
+ # Creates a text input area; use a textarea for longer text inputs such as blog posts or descriptions
107
+ # and includes the textile toolbar above it.
108
+ #
109
+ # ==== Options
110
+ # * <tt>:size</tt> - A string specifying the dimensions (columns by rows) of the textarea (e.g., "25x10").
111
+ # * <tt>:rows</tt> - Specify the number of rows in the textarea
112
+ # * <tt>:cols</tt> - Specify the number of columns in the textarea
113
+ # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
114
+ # * Any other key creates standard HTML attributes for the tag.
115
+ #
116
+ # ==== Examples
117
+ # textile_editor_tag 'post'
118
+ # # => <textarea id="post" name="post"></textarea>
119
+ #
120
+ # textile_editor_tag 'bio', @user.bio
121
+ # # => <textarea id="bio" name="bio">This is my biography.</textarea>
122
+ #
123
+ # textile_editor_tag 'body', nil, :rows => 10, :cols => 25
124
+ # # => <textarea cols="25" id="body" name="body" rows="10"></textarea>
125
+ #
126
+ # textile_editor_tag 'body', nil, :size => "25x10"
127
+ # # => <textarea name="body" id="body" cols="25" rows="10"></textarea>
128
+ #
129
+ # textile_editor_tag 'description', "Description goes here.", :disabled => true
130
+ # # => <textarea disabled="disabled" id="description" name="description">Description goes here.</textarea>
131
+ #
132
+ # textile_editor_tag 'comment', nil, :class => 'comment_input'
133
+ # # => <textarea class="comment_input" id="comment" name="comment"></textarea>
134
+ def textile_editor_tag(name, content = nil, options = {})
135
+ text_area_tag(name, content, options.merge(:class=>"textile_editor"))
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,39 @@
1
+ require_relative 'textile_editor_initialize'
2
+
3
+ module Formtastic
4
+ module Helpers
5
+ module FormHelper
6
+ def textile_editor_initialize
7
+ unless request.xhr?
8
+ TextileEditorInitialize.textile_editor_initialize
9
+ else
10
+ [].join("\n").html_safe
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ module Inputs
17
+
18
+ class TextileEditorInput
19
+ include Base
20
+ include Base::Placeholder
21
+
22
+ def input_html_options
23
+ {
24
+ :cols => builder.default_text_area_width,
25
+ :rows => builder.default_text_area_height,
26
+ :class => "textile_editor"
27
+ }.merge(super)
28
+ end
29
+
30
+ def to_html
31
+ input_wrapping do
32
+ label_html <<
33
+ builder.text_area(method, input_html_options)
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'textile_editor_initialize'
2
+
3
+ module SimpleForm
4
+ module ActionViewExtensions
5
+ module FormHelper
6
+
7
+ def textile_editor_initialize
8
+ unless request.xhr?
9
+ TextileEditorInitialize.textile_editor_initialize
10
+ else
11
+ [].join("\n").html_safe
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+
18
+ module Inputs
19
+ class TextileEditorInput < Base
20
+
21
+ def input
22
+ @builder.text_area(attribute_name, input_html_options)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ class TextileEditorInitialize
2
+
3
+ class << self
4
+ def textile_editor_initialize
5
+ output = []
6
+ output << '<script type="text/javascript">'
7
+ output << %{$(document).ready(function() \{}
8
+ output << '/* <![CDATA[ */'
9
+ output << %{$.each($('textarea.textile_editor'),function(i,el){
10
+ TextileEditor.initialize($(el).attr('id'));
11
+ });}
12
+ output << '/* ]]> */'
13
+ output << '});'
14
+ output << '</script>'
15
+ output.join("\n").html_safe
16
+ end
17
+ end
18
+
19
+ end
@@ -1,3 +1,3 @@
1
1
  module TextileEditorHelper
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.30"
3
3
  end