/
application_helper.rb
71 lines (64 loc) · 1.86 KB
/
application_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module ApplicationHelper
#
#
#
# @returns [String] -
#
def is_active?(*controllers)
controllers.each do |controller|
if controller_name.match(Regexp.new("#{controller}"))
return true
end
end
return false
end
# Produces a string id using the type and id of obj plus any field suffix supplied useful when
# assigning html ids on index pages.
# e.g. element_id(user, 'name') => 'User_23_name'
def element_id(obj, field="")
obj.class.to_s + '_' + obj.id.to_s + (field.blank? ? '' : '_' + field)
end
def clippy(text, bgcolor='#FFFFFF')
html = <<-EOF
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="14"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=#{text}">
<param name="bgcolor" value="#{bgcolor}">
<embed src="/flash/clippy.swf"
width="110"
height="14"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="text=#{text}"
bgcolor="#{bgcolor}"
/>
</object>
EOF
end
# Translates default Padrino flash keys into default Twitter Bootstrap
# alert CSS class name extension.
#
# @param [Symbol] flash - The flash key
# @return [String] the CSS class name
def bootstrap_alert_for(flash)
case flash
when :error
return "error"
when :warning
return "block"
when :notice
return "success"
when :info
return "info"
end
end
end