app/helpers/imperavi_rails/imperavi_helper.rb in imperavi-rails-0.0.8.beta vs app/helpers/imperavi_rails/imperavi_helper.rb in imperavi-rails-0.0.9.beta

- old
+ new

@@ -11,51 +11,58 @@ end def imperavi(element, options = {}, wrap = true) result = %Q( $(document).ready(function() { - $('##{element}').redactor(#{imperavi_options(options).to_json}); + document.#{element}_redactor = $('##{element}').redactor(#{imperavi_options(options).to_json}); }); ) raw(wrap ? "<script>#{result}</script>" : result) end def imperavi_options(options) - imperavi_default_options.deep_merge!(options) + merged_opt = imperavi_default_options.deep_merge!(options) + imperavi_default_paths(merged_opt).deep_merge!(options) end def imperavi_default_options { :air => false, :autosave => false, :interval => 20, :resize => true, :visual => true, :focus => false, + :lang => 'en', + :toolbar => 'main', :autoclear => true, :removeClasses => false, :removeStyles => true, :convertLinks => true, :autoformat => true, :clearOnInit => false, :overlay => true, :fileUploadCallback => false, :imageUploadCallback => false, - + } + end + + def imperavi_default_paths(base_options) + { # Paths to various handlers :paths => { # Editor css # TODO stylesheet_path does not work here. # this is temoarary fix I hope #:stylesheets => [stylesheet_link_tag('wym').match(/href="([^"]+)"/)[1]], :stylesheets => [], # Toolbar - :toolbar => imperavi_rails.toolbar_path(:format => :js), + :toolbar => imperavi_rails.toolbar_path(base_options[:toolbar], :format => :js), # Interface translations - :language => imperavi_rails.language_path(:format => :js), + :language => imperavi_rails.language_path(base_options[:lang], :format => :js), # Typograf :typograf => imperavi_rails.typograf_path, # Dialogs