Module: Editor::EditorHelper

Defined in:
app/helpers/amalgam/editor/editor_helper.rb

Instance Method Summary collapse

Instance Method Details

#editable_content_tag(tag, obj, field, options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/amalgam/editor/editor_helper.rb', line 4

def  tag,obj,field,options={},&block
  if can_edit?
    options[:data] = (options[:data] || {}).merge(:type => 'editable')
    options[:data][:mercury] = "full"
    options[:data][:id] = "#{obj.class.to_s.tableize}/#{obj.id.to_s}.#{field.to_s}"
  end
  value = fetch_field(obj,field)
  if value.present?
    (tag,value.to_s.html_safe,options)
  else
    (tag,options,&block) if block_given?
  end
end

#properties_button(model_or_url, title = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/helpers/amalgam/editor/editor_helper.rb', line 18

def properties_button(model_or_url,title=nil)
  return unless can_edit?
  title ||= I18n.t('properties_edit')
  url = case url
         when String then "#{model_or_url}?mercury_frame=true"
         else "#{url_for(model_or_url)}?mercury_frame=true"
        end
  button_tag(title, :type=>'button', :data => {:url => url }, :class => 'properties', :style => "display:none")
end