Module: XmtFroala::Helper
- Defined in:
- lib/xmt_froala/helper.rb
Instance Method Summary collapse
- #froalaeditor(name, method, options = {}) ⇒ Object
- #froalaeditor_file_manager_json_path ⇒ Object
- #froalaeditor_tag(name, content = nil, options = {}) ⇒ Object
- #froalaeditor_upload_json_path(*args) ⇒ Object
- #merge_assets_info(options) ⇒ Object
Instance Method Details
#froalaeditor(name, method, options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/xmt_froala/helper.rb', line 12 def froalaeditor(name, method, = {}) # TODO: Refactory options: 1. kindeditor_option 2. html_option input_html = (.delete(:input_html) || {}).stringify_keys output_buffer = ActiveSupport::SafeBuffer.new output_buffer << build_text_area_tag(name, method, self, merge_assets_info(), input_html) output_buffer << javascript_tag(js_replace(input_html['id'], )) end |
#froalaeditor_file_manager_json_path ⇒ Object
46 47 48 |
# File 'lib/xmt_froala/helper.rb', line 46 def froalaeditor_file_manager_json_path "#{main_app_root_url}xmt_froala/filemanager" end |
#froalaeditor_tag(name, content = nil, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/xmt_froala/helper.rb', line 3 def froalaeditor_tag(name, content = nil, = {}) id = sanitize_to_id(name) input_html = { :id => id }.merge(.delete(:input_html) || {}) input_html[:class] = "#{input_html[:class]} xmt_froala" output = ActiveSupport::SafeBuffer.new output << text_area_tag(name, content, input_html) output << javascript_tag(js_replace(id, )) end |
#froalaeditor_upload_json_path(*args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/xmt_froala/helper.rb', line 35 def froalaeditor_upload_json_path(*args) = args. owner_id_query_string = [:owner_id] ? "?owner_id=#{[:owner_id]}" : '' owner_type_query_string = [:owner_type] ? "&owner_type=#{[:owner_type]}" : '' if owner_id_query_string == '' && owner_type_query_string == '' "#{main_app_root_url}xmt_froala/upload" else "#{main_app_root_url}xmt_froala/upload#{owner_id_query_string}#{owner_type_query_string}" end end |
#merge_assets_info(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xmt_froala/helper.rb', line 20 def merge_assets_info() owner = .delete(:owner) [:class] = "#{[:class]} xmt_froala" if (!owner.nil?) && (!owner.id.nil?) begin owner_id = owner.id owner_type = owner.class.name .reverse_merge!(owner_id: owner_id, owner_type: owner_type, data: {upload: froalaeditor_upload_json_path(owner_id: owner_id, owner_type: owner_type), filemanager: froalaeditor_file_manager_json_path}) return end else .reverse_merge!(data: {upload: froalaeditor_upload_json_path, filemanager: froalaeditor_file_manager_json_path}) end end |