Sha256: edc830c3bd8d216535b9796fdfec08eadc4f3cfb69b6d9915c19cb0e5e860546
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module PhraseApp module InContextEditor module ViewHelpers def phraseapp_in_context_editor_js return "" unless PhraseApp::InContextEditor.enabled? js_config = ["projectId: '#{PhraseApp::InContextEditor.project_id}'"] if PhraseApp::InContextEditor.api_host.present? js_config << "apiBaseUrl: '#{PhraseApp::InContextEditor.api_host}/api/v2'" end js = <<-eos <script> window.PHRASEAPP_CONFIG = { #{js_config.join(', ')} }; (function() { var phraseapp = document.createElement('script'); phraseapp.type = 'text/javascript'; phraseapp.async = true; phraseapp.src = ['#{PhraseApp::InContextEditor.js_use_ssl ? 'https' : 'http'}://', '#{PhraseApp::InContextEditor.js_host}/assets/in-context-editor/2.0/app.js?', new Date().getTime()].join(''); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(phraseapp, s); })(); </script> eos js.respond_to?(:html_safe) ? js.html_safe : js end end end end
Version data entries
3 entries across 3 versions & 1 rubygems