cleanup and add translation hooks

This commit is contained in:
2012-11-29 19:01:35 +01:00
parent b9c0ca326b
commit e0a3333e8f
8 changed files with 65 additions and 38 deletions
+16
View File
@@ -77,4 +77,20 @@ module ApplicationHelper
link_to 'Twitter', 'https://www.twitter.com/Qwaiter', target: :_blank
end
# Add a script call to be executed when the dom is loaded.
# When called without a script it will return the total added script content
# - onload_javascript 'var a=1'
# - onload_javascript 'var b=3'
# = onload_javascript #=> var a=1;var b=3
def onload_javascript(script = nil)
if block_given?
script = script.to_s
value = nil
buffer = with_output_buffer { value = yield }
script += (buffer.presence || value).to_s
end
script = script.call if script.respond_to?(:call)
script.present? ? (@onload_javascripts ||= []) << script : (@onload_javascripts || []).join(';')
end
end