cleanup and add translation hooks
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user