Created
February 3, 2013 16:58
-
-
Save sergey-alekseev/4702578 to your computer and use it in GitHub Desktop.
reformal.ru widget Rails helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ERB: | |
# | |
# <%= reformal_widget 'alma-by' %> | |
# </head> | |
# | |
# Haml: | |
# | |
# = reformal_widget('alma-by') | |
# %body | |
# put the following snippet in application_helper.rb | |
def reformal_widget(subdomain) | |
if Rails.env.production? | |
content_tag(:script, type: 'text/javascript') do | |
"var reformalOptions = { | |
project_id: 90222, | |
project_host: \"#{subdomain}.reformal.ru\", | |
tab_orientation: 'left', | |
tab_indent: '50%', | |
tab_bg_color: '#00f024', | |
tab_border_color: '#FFFFFF', | |
tab_image_url: 'http://tab.reformal.ru/0JLQsNGI0Lgg0LjQtNC10Lgh/FFFFFF/9454def23a517db45a055fdd94339bd0/left/1/tab.png', | |
tab_border_width: 2 | |
}; | |
(function() { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; script.async = true; | |
script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'media.reformal.ru/widgets/v3/reformal.js'; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
})();".html_safe | |
end + | |
content_tag(:noscript) do | |
link_to('http://reformal.ru') do | |
image_tag('http://media.reformal.ru/reformal.png') | |
end.concat(link_to t('reformal.ideas'), "http://#{subdomain}.reformal.ru") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment