Sha256: fbf2cdf93a3b8b3fb4cc7455407883cf199a201cc6d580953b71c1f7f04e8298
Contents?: true
Size: 1.95 KB
Versions: 9
Compression:
Stored size: 1.95 KB
Contents
module Smithy module ApplicationHelper def smithy_link_to_add_fields(name, association, form_builder) html = content_tag(:div, :id => "#{association}_fields_blueprint", :style => "display:none;") do form_builder.semantic_fields_for(association, model_object(form_builder, association), :child_index => "new_#{association}") do |builder| form_builder.template.concat(raw render("#{form_builder.object.class.to_s.tableize}/#{association.to_s.singularize}_fields", :f => builder)) end end form_builder.template.concat(html) form_builder.template.link_to(name, "javascript:void(0)", :class => "add_nested_fields", "data-association" => association) end def smithy_link_to_remove_fields(name, form_builder) form_builder.hidden_field(:_destroy) + @template.link_to(name, "javascript:void(0)", :class => "remove_nested_fields") end def render_markdown_input(fieldname, editor_name, form_builder) content_for(:javascript) do javascript_tag do raw("var editor = ace_edit('#{form_builder.object.id || 'new'}', 'markdown', '#{editor_name}');\n") + raw("editor.renderer.setShowGutter(false);") end end hint = "Use markdown syntax for formatting. You can also use HTML directly. <a href=\"#{guide_path('markdown')}\" data-toggle=\"remote-load\" data-target=\"#content-guide\">See our markdown syntax reference</a>".html_safe form_builder.input(fieldname, :as => :text, :input_html => { :class => "span12", :id => "#{editor_name}-#{form_builder.object.id || 'new'}" }, :hint => hint) + content_tag(:div, nil, :id => "#{editor_name}_editor-#{form_builder.object.id || 'new'}", :class => "#{editor_name}_editor ace_editor") + content_tag(:div, nil, :id => 'content-guide') end private def model_object(form_builder, association) model_object = form_builder.object.class.reflect_on_association(association).klass.new end end end
Version data entries
9 entries across 9 versions & 1 rubygems