tag with class 'formfield'
def display_form_field(label, html_for_field)
content_tag('div', content_tag('div', content_tag('label', label)) + html_for_field, :class => 'formfield')
end
def display_submit_tag(label)
content_tag('p', submit_tag( label, :class => 'submit'), :class => 'submitline')
end
alias_method :labelled_form_field, :display_form_field
def labelled_form_for(name, object = nil, options = {}, &proc)
object ||= instance_variable_get("@#{name}")
form_for(name, object, { :builder => NoosferoFormBuilder }.merge(options), &proc)
end
class NoosferoFormBuilder < ActionView::Helpers::FormBuilder
include GetText
(field_helpers - %w(hidden_field)).each do |selector|
src = <<-END_SRC
def #{selector}(field, *args, &proc)
column = object.class.columns_hash[field.to_s]
"
"
end
END_SRC
class_eval src, __FILE__, __LINE__
end
end
def category_color
if @category.nil?
""
else
@category.top_ancestor.display_color
end
end
def text_editor(object, method, filter_type_method = nil, options = {})
text_area(object, method, { :rows => 10, :cols => 64 }.merge(options))
end
def file_manager(&block)
concat(content_tag('div', capture(&block), :class => 'file-manager') + "
", block.binding)
end
def file_manager_button(title, icon, url)
content_tag('div', link_to(image_tag(icon, :alt => title, :title => title) + content_tag('div', title), url), :class => 'file-manager-button')
end
def hide(id)
"Element.hide(#{id.inspect});"
end
def show(id)
"Element.show(#{id.inspect});"
end
def toggle_panel(hide_label, show_label, id)
hide_button_id = id + "-hide"
show_button_id = id + "-show"
result = ""
result << button_to_function('open', show_label, show(id) + show(hide_button_id) + hide(show_button_id), :id => show_button_id, :class => 'show-button with_text', :style => 'display: none;' )
result < " "
result << button_to_function('close', hide_label, hide(id) + hide(hide_button_id) + show(show_button_id), :id => hide_button_id, :class => 'hide-button with_text')
result
end
def button(type, label, url, html_options = {})
design_display_button(type, label, url, { :class => 'with_text' }.merge(html_options))
end
def submit_button(type, label, html_options = {})
design_display_button_submit(type, label, { :class => 'with_text' }.merge(html_options))
end
def button_to_function(type, label, js_code, html_options = {})
#design_display_function_button(type, label, js_code, { :class => 'with_text' }.merge(html_options))
html_options[:class] = "" unless html_options[:class]
html_options[:class] << " button #{type}"
link_to_function(label, js_code, html_options)
end
def icon(icon_name)
design_display_icon(icon_name)
end
def button_bar(options = {}, &block)
concat(content_tag('div', capture(&block) + tag('br', :style => 'clear: left;'), { :class => 'button-bar' }.merge(options)), block.binding)
end
def link_to_category(category)
return _('Uncategorized product') unless category
link_to category.name, :controller => 'category', :action => 'view', :path => category.path.split('/')
end
def link_to_product(product)
return _('No product') unless product
link_to product.name, :controller => 'catalog', :action => 'show', :id => product, :profile => product.enterprise.identifier
end
end