Files
componentowl-rails-archive/app/helpers/application_helper.rb

160 lines
4.7 KiB
Ruby
Raw Normal View History

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def blv_version
featured_product.current_version
end
# ========== DEXTRONET_CORE_HELPER ===========
def antispam_field
hidden_field_tag :magicwand, "you-shall-not-pass", :id => nil
end
def link_to_new_window(name, options, html_options = {})
html_options[:onclick] = [html_options[:onclick], "window.open(this.href); return false"].compact.join("; ")
link_to(name, options, html_options);
end
def back_button
link_to t('txt.common.back'), root_path, :class => "back-header-button history-back"
end
def releases_page_path(product, version = nil)
p = product_path(product)+"/#{Settings.releases_code}"
p << "?since=#{version}" if version
p
end
def submit_button(value, options = {})
options[:class] = ["dbtn", options[:class]].compact.join(" ")
btn_id = options.delete(:btn_id) || "send"
btn_class = ["dbtn-c", options.delete(:btn_class)].compact.join(" ")
content_tag(:span, content_tag(:span, submit_tag(value, options), :class => "dbtn-w"), :class => btn_class, :id => btn_id)
end
# tady tyhle paths k product pages by mely byt generovane automaticky
def story_path(product)
product_path(product)+"/#{Settings.story_code}"
end
def submit_image(*args)
options = args.extract_options!
case args.first
when Symbol, String
options[:class] = [args.first, options[:class]].compact.join(" ")
end
image_submit_tag("blank.gif", options)
end
def screenshot_path(id)
ss = Screenshot.find_by_id(id)
ss ? ss.image.url : "/images/blank.gif"
end
# ========== /DEXTRONET_CORE_HELPER ===========
def more_link_button(product_or_edition, klass = "standard", text = nil)
text = t('txt.products.learn_more') unless text
case product_or_edition
when ProductEdition
path = product_path(product_or_edition.product)
else
path = product_path(product_or_edition)
end
link_to text, path, :class => "#{klass}-more image-link"
end
def documentation_path(product)
"#{product_path(product)}/#{Settings.documentation_code}"
end
def quick_start_guide_path(product)
"#{product_path(product)}/#{Settings.quick_start_guide_code}"
end
def class_reference_path(product)
"#{product_path(product)}/#{Settings.class_reference_code}"
end
def pricing_path(product)
"#{product_path(product)}/#{Settings.pricing_code}"
end
def twitter_url
"http://twitter.com/ComponentOwl"
end
def upgrade_path(static_page_code)
"/upgrade/#{StaticPage[static_page_code].url_param}"
end
def buy_professional(product)
edition = product.edition('professional')
buy_link(edition, "buy_professional", t('txt.products.buy_professional', :price => number_to_currency(edition.price)))
end
def buy_standard(product)
edition = product.edition('standard')
buy_link(edition, "buy_standard", t('txt.products.buy_standard', :price => number_to_currency(edition.price)))
end
def subscription_lists(location_code, product = nil)
product_id = product ? product.id : nil
lists = SubscriptionLocation[location_code].lists(product_id)
product_list = lists.detect {|l| l.product == product }
can_deselect = false
content = []
lists.each do |list|
# zatim bude vsecko hidden
#if !product || (product && list.product == product) || (product && product_list.nil?)
content << hidden_field_tag("subscription[subscription_list_ids][]", list.id, :id => nil)
#else
# content << check_box_tag("subscription[subscription_list_ids][]", list.id, true, :id => "subscription_subscription_list_ids_#{list.id}")
# content << label_tag("subscription_subscription_list_ids_#{list.id}", t('txt.product.send_also', :newsletter => list.name))
# can_deselect = true
#end
end
if can_deselect
content.insert(0, '<div class="subscription-lists">')
content << "</div>"
end
content.join("\n")
end
def subscribe(type = nil, text = t('txt.common.subscribe'), options = {})
btn_class = "subscribe"
btn_class << " dbtn-#{type}" if type
submit_button(text, options.merge(:btn_class => btn_class))
end
def pricing_licensing?(product_page)
product_page.code == "pricing-licensing"
end
def cached_javascripts_base
javascript_include_merged :base
end
def cached_javascripts_app
javascript_include_merged :app
end
def cached_javascripts_simple
javascript_include_merged :simple
end
def cached_stylesheets_base
stylesheet_link_merged :base
end
def cached_stylesheets_simple
stylesheet_link_merged :simple
end
end