Skip to content

Commit

Permalink
removed concat binding parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
paolodona committed Feb 25, 2009
1 parent 04d0f0e commit 8e65a2f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
22 changes: 9 additions & 13 deletions lib/widgets/navigation_helper.rb
Expand Up @@ -11,12 +11,11 @@ def render_navigation(name=:main, opts={}, &proc)
raise ArgumentError, "Missing name parameter in render_navigation call" unless name
raise ArgumentError, "Missing block in render_navigation call" unless block_given?
@_navigation = Navigation.new(name, opts)
@_binding = proc.binding # the binding of calling page
instance_eval(&proc)
out @_navigation.render_css('navigation') if @_navigation.generate_css?
out tag('div',@_navigation.html ,true)
concat @_navigation.render_css('navigation') if @_navigation.generate_css?
concat tag('div',@_navigation.html ,true)
render_navigation_items
out '</div>'
concat '</div>'
nil
end

Expand All @@ -39,20 +38,17 @@ def render_navigation_items
item.html[:class] = 'active'
end

out '<li>'
concat '<li>'
if item.disabled?
out content_tag('span', item.name, item.html)
concat content_tag('span', item.name, item.html)
else
out link_to(item.name, item.link, item.html)
concat link_to(item.name, item.link, item.html)
end
out @_navigation.separator unless index == @_navigation.items.size - 1
out "</li>\n"
concat @_navigation.separator unless index == @_navigation.items.size - 1
concat "</li>\n"
end
out '</ul>'
concat '</ul>'
end

def out(string); concat string, @_binding; end

end
end

25 changes: 11 additions & 14 deletions lib/widgets/tabnav_helper.rb
Expand Up @@ -23,7 +23,7 @@ def tabnav name, opts={}, &block
html << tag('div', options, true)
html << capture(&block)
html << '</div>'
concat( html, block.binding)
concat html
nil # avoid duplication if called with <%= %>
else
return html
Expand All @@ -39,14 +39,13 @@ def render_tabnav(name, opts={}, &proc)
raise ArgumentError, "Missing name parameter in tabnav call" unless name
raise ArgumentError, "Missing block in tabnav call" unless block_given?
@_tabnav = Tabnav.new(name, opts)
@_binding = proc.binding # the binding of calling page

instance_eval(&proc)
out @_tabnav.render_css('tabnav') if @_tabnav.generate_css?
out tag('div',@_tabnav.html ,true)
concat @_tabnav.render_css('tabnav') if @_tabnav.generate_css?
concat tag('div',@_tabnav.html ,true)
@_tabnav.sort! if opts[:sort] == true
render_tabnav_tabs
out "</div>\n"
concat "</div>\n"
nil
end

Expand All @@ -69,7 +68,7 @@ def controller_names
def render_tabnav_tabs
return if @_tabnav.tabs.empty?

out tag('ul', {} , true)
concat tag('ul', {} , true)

@_tabnav.tabs.each do |tab|
li_options = {}
Expand All @@ -84,11 +83,11 @@ def render_tabnav_tabs
end
li_options[:class] = tab_html[:class]

out tag('li', li_options, true)
concat tag('li', li_options, true)
if tab.disabled? || (tab.link.empty? && tab.remote_link.nil?)
out content_tag('span', tab.name, tab_html)
concat content_tag('span', tab.name, tab_html)
elsif !tab.link.empty?
out link_to(tab.name, tab.link, tab_html)
concat link_to(tab.name, tab.link, tab_html)
elsif tab.remote_link
success = "document.getElementsByClassName('active', $('" + @_tabnav.html[:id]+ "')).each(function(item){item.removeClassName('active');});"
success += "$('#{tab.html[:id]}').addClassName('active');"
Expand All @@ -100,17 +99,15 @@ def render_tabnav_tabs
:loading => loading_function + success,
:loaded => "$('#{@_tabnav.html[:id]}_content').setStyle({height: 'auto'});"
}
out link_to_remote(tab.name, remote_opts.merge(tab.remote_link), tab_html)
concat link_to_remote(tab.name, remote_opts.merge(tab.remote_link), tab_html)
else
raise "WHAT THE HELL?"
end
out "</li>\n"
concat "</li>\n"
end
out '</ul>'
concat '</ul>'
end

def out(string); concat string, @_binding; end

# generate javascript function to use
# while loading remote tabs
# NB: EXPERIMENTAL
Expand Down

0 comments on commit 8e65a2f

Please sign in to comment.