module WangeditorRails::Helper
Public Instance Methods
create_scripts(id)
click to toggle source
# File lib/wangeditor_rails/helper.rb, line 26 def create_scripts(id) "var E = window.wangEditor var editor = new E('##{id}_editor') editor.customConfig.onchange = function (content) { document.getElementById('#{id}').value = content } editor.create()" end
display_area(id, content)
click to toggle source
# File lib/wangeditor_rails/helper.rb, line 19 def display_area(id, content) unless content.nil? content = sanitize content end content_tag(:div, content, id: "#{id}_editor") end
wangeditor(name, method, options = {})
click to toggle source
# File lib/wangeditor_rails/helper.rb, line 3 def wangeditor(name, method, options = {}) content = options[:object][method] id = options[:id] || "#{name}_#{method}" name = "#{name}[#{method}]" #puts options output_buffer = ActiveSupport::SafeBuffer.new output_buffer << hidden_area(id, content, name) output_buffer << display_area(id, content) output_buffer << javascript_tag(create_scripts(id)) end