3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/helpers/uservoice_widget/main_helper.rb', line 3
def uservoice_widget(account = UservoiceWidget::Account.default, options = {})
account = account.dup.update_attributes(options)
javascript_tag do
code = <<-JS
(function() {
var uv = document.createElement('script'); uv.type = 'text/javascript'; uv.async = true;
uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/#{account.key}.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(uv, s);
})();
JS
code.html_safe
end +
javascript_tag do
"UserVoice = window.UserVoice || []; UserVoice.push(['showTab', 'classic_widget', #{account.to_json}])".html_safe
end
end
|