| Module | LayoutHelper |
| In: |
app/helpers/layout_helper.rb
|
Project iboard4 Author Andreas Altendorfer Copyright 2009 by Andreas Altendorfer
Some helpers for the layout
insert a right floating box
# File app/helpers/layout_helper.rb, line 50
50: def box_float_right(width=RIGHT_BOX_DEFAULT_WIDTH,css_class='box_float_right')
51: concat("<div class='#{css_class}' style='width: #{width}'>")
52: yield
53: concat("</div>")
54: end
use this instead of <hr>
# File app/helpers/layout_helper.rb, line 45
45: def divider
46: "<div class='divider'></div>"
47: end
search will be splitted by whitespace or colons and then text found for each part in txt will be highlighted by span color green…
# File app/helpers/layout_helper.rb, line 36
36: def highlight_search(search,txt)
37: return txt if search.blank?
38: search.split(/[\s|,]+/).each do |s|
39: txt.gsub!("#{s}","<span style=\"color: #080; font-weight: bold;\">#{s}</span>")
40: end
41: txt
42: end
Append a javascript to the html-head
# File app/helpers/layout_helper.rb, line 25
25: def javascript(*args)
26: args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
27: content_for(:html_head) { javascript_include_tag(*args) }
28: end
Append a rss-link to the html-head
# File app/helpers/layout_helper.rb, line 31
31: def rss_link(*args)
32: content_for(:html_head) { auto_discovery_link_tag(*args.map(&:to_s)) }
33: end
Append a stylesheet to the :head for yield in application.html.erb
# File app/helpers/layout_helper.rb, line 20
20: def stylesheet(*args)
21: content_for(:html_head) { stylesheet_link_tag(*args.map(&:to_s)) }
22: end
sets the page_tile which is used in application.html.erb
# File app/helpers/layout_helper.rb, line 9
9: def title(page_title, show_title = true)
10: @content_for_title = page_title.to_s
11: @show_title = show_title
12: end
Display the lable as a link which toggles display of the given block
# File app/helpers/layout_helper.rb, line 57
57: def toggle_display_link(label='show more', options = {})
58:
59: ids = options[:id] ? options[:id] : "details_#{rand(999999).round.to_s}"
60: sticky = options[:sticky] ? "" : "style='display: none;'"
61: inverse_sticky = options[:sticky] ? "style='display: none;'" : ""
62:
63: set_sticky = options[:id] ? remote_function(:update => 'debug',
64: :url => { :controller => 'user_sessions',
65: :action => :set_sticky, :id => ids }
66: ) : ""
67:
68: set_unsticky = options[:id] ? remote_function(:update => 'debug',
69: :url => { :controller => 'user_sessions',
70: :action => :set_unsticky, :id => ids }
71: ) : ""
72:
73: concat("<div style='")
74: concat("width:#{options[:width]};") if options[:width]
75: concat("min-width:#{options[:minwidth]};") if options[:minwidth]
76: concat("'>")
77: concat(
78: "<div id='can_open_#{ids}' #{inverse_sticky}>
79: <a href='##{ids}'
80: onclick=\"Element.blindDown(\'#{ids}\');Element.hide(\'can_open_#{ids}\');"+
81: "Element.show(\'can_close_#{ids}\');"+
82: set_sticky +
83: ";return false;\">#{CAN_OPEN} #{label}</a>" +
84: "</div>" +
85: "<div id='can_close_#{ids}' #{sticky} >
86: <a href='##{ids}'
87: onclick=\"Element.blindUp(\'#{ids}\'); "+"
88: Element.hide(\'can_close_#{ids}\');Element.show(\'can_open_#{ids}\');"+
89: set_unsticky +
90: ";return false;\">#{IS_OPEN} #{label}</a>" +
91: "</div>"+
92: "<div id='#{ids}' #{sticky}>"
93: )
94:
95: yield
96:
97: concat( "<div id='close_up#{ids}'>" )
98:
99: unless options[:no_bottom_link] == true
100: concat("
101: <a href='##{ids}'
102: onclick=\"Element.blindUp(\'#{ids}\'); Element.hide(\'can_close_#{ids}\');Element.show(\'can_open_#{ids}\');"+
103: set_unsticky+
104: ";return false;\">#{CLOSE_UP} #{label}</a>"
105: )
106: end
107:
108: concat("</div>\n</div>\n</div>"
109: )
110: end