lib/wysihat-engine.rb in wysihat-engine-0.1.6 vs lib/wysihat-engine.rb in wysihat-engine-0.1.7
- old
+ new
@@ -8,36 +8,31 @@
end
end
class InstanceTag #:nodoc:
def to_wysihat_editor_tag(options = {})
-
options = DEFAULT_TEXT_AREA_OPTIONS.merge(options.stringify_keys)
add_default_name_and_id(options)
-
- if size = options.delete("size")
- options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
- end
- buttons, helpers = '', ''
+ size = options.delete("size")
+ options["cols"], options["rows"] = size.split("x") if size && size.respond_to?(:split)
- case options['buttons']
- when nil, :all
- options['buttons'] = [:bold, :italic, :underline, :strikethrough, :justify_left, :justify_center, :justify_right, :insert_ordered_list, :insert_unordered_list, :undo, :redo, :link, :html, :image]
+ if options['buttons'] == nil || options['buttons'] == :all
+ buttons = [:bold, :italic, :underline, :strikethrough, :justify_left, :justify_center, :justify_right, :insert_ordered_list, :insert_unordered_list, :undo, :redo, :link, :html, :image]
end
-
- content_tag(
- :script,
- "addButtons('#{tag_id}', ['#{options.delete('buttons').join('\', \'')}']);",
- :type => 'text/javascript'
- ) <<
- content_tag("textarea", html_escape(options.delete('value') || value_before_type_cast(object)), options.merge(:class => 'wysihat_editor'))
+
+ javascript = "Event.observe(window, 'load', function() {" <<
+ "wysiHatify('#{tag_id}', ['#{buttons.join('\', \'')}']);" <<
+ "});"
+
+ content_tag(:script, javascript, :type => 'text/javascript') <<
+ content_tag(:textarea, html_escape(options.delete('value') || value_before_type_cast(object)), options.merge(:class => 'wysihat_editor'))
end
end
class FormBuilder #:nodoc:
def wysihat_editor(method, options = {})
@template.wysihat_editor(@object_name, method, options)
end
end
end
-end
\ No newline at end of file
+end