Module: Interpret::InterpretHelpers
- Defined in:
- lib/interpret/helpers.rb
Instance Method Summary collapse
- #interpret_live_edition ⇒ Object
- #interpret_parent_layout(layout) ⇒ Object
- #interpret_section_link_to(name, options = {}, html_options = {}) ⇒ Object
-
#interpret_show_tree(tree, origin_keys) ⇒ Object
Generates the html tree from the given keys.
- #interpret_title(title) ⇒ Object
- #t(key, options = {}) ⇒ Object
Instance Method Details
#interpret_live_edition ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/interpret/helpers.rb', line 40 def interpret_live_edition return unless Interpret.live_edit && @interpret_admin content_tag(:div) do concat(javascript_include_tag "facebox-1.3/facebox") concat javascript_tag <<-JS $(document).ready(function(){ $(".interpret_editable").click(function() { var key = $(this).attr("data-key"); jQuery.facebox({ ajax: '#{live_edit_interpret_translations_path}?key=' + key}); return false; }); }); JS concat(stylesheet_link_tag "interpret_live_edit_style") concat(stylesheet_link_tag "/javascripts/facebox-1.3/facebox.css") end end |
#interpret_parent_layout(layout) ⇒ Object
26 27 28 29 |
# File 'lib/interpret/helpers.rb', line 26 def interpret_parent_layout(layout) @_content_for[:layout] = self.output_buffer self.output_buffer = render(:file => "layouts/#{layout}") end |
#interpret_section_link_to(name, options = {}, html_options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/interpret/helpers.rb', line 15 def interpret_section_link_to(name, = {}, = {}) .merge!({ :class => 'current' }) if current_controller?() link_to name, , end |
#interpret_show_tree(tree, origin_keys) ⇒ Object
Generates the html tree from the given keys
5 6 7 8 9 10 11 12 13 |
# File 'lib/interpret/helpers.rb', line 5 def interpret_show_tree(tree, origin_keys) tree = tree.first[1] unless origin_keys.nil? origin_keys.split(".").each do |key| tree = tree[key] end end build_tree(tree, origin_keys) end |
#interpret_title(title) ⇒ Object
20 21 22 23 24 |
# File 'lib/interpret/helpers.rb', line 20 def interpret_title(title) content_for :title do title end end |
#t(key, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/interpret/helpers.rb', line 31 def t(key, = {}) if Interpret.live_edit && @interpret_admin keys = build_keys(key, ) "<span class='interpret_editable' data-key='#{keys}'>#{translate(key, )}</span>".html_safe else translate(key, ) #.html_safe end end |