app/helpers/imperavi_rails/imperavi_helper.rb in imperavi-rails-0.0.9.beta vs app/helpers/imperavi_rails/imperavi_helper.rb in imperavi-rails-0.0.10.beta
- old
+ new
@@ -9,13 +9,16 @@
def include_imperavi_javascript
javascript_include_tag "imperavi-rails/imperavi"
end
def imperavi(element, options = {}, wrap = true)
+ javascript_var = options.delete(:javascript_var) || imperavi_default_options[:javascript_var]
result = %Q(
+ var #{javascript_var};
+
$(document).ready(function() {
- document.#{element}_redactor = $('##{element}').redactor(#{imperavi_options(options).to_json});
+ #{javascript_var} = document.#{element}_redactor = $('##{element}').redactor(#{imperavi_options(options).to_json});
});
)
raw(wrap ? "<script>#{result}</script>" : result)
end
@@ -27,11 +30,11 @@
def imperavi_default_options
{
:air => false,
:autosave => false,
- :interval => 20,
+ :interval => 20,
:resize => true,
:visual => true,
:focus => false,
:lang => 'en',
:toolbar => 'main',
@@ -39,13 +42,14 @@
:removeClasses => false,
:removeStyles => true,
:convertLinks => true,
:autoformat => true,
:clearOnInit => false,
- :overlay => true,
+ :overlay => true,
:fileUploadCallback => false,
:imageUploadCallback => false,
+ :javascript_var => 'imperavi_redactor'
}
end
def imperavi_default_paths(base_options)
{
@@ -94,5 +98,6 @@
}
}
end
end
end
+