Module: ApplicationHelper

Defined in:
lib/branston/app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#clippy(text, bgcolor = '#FFFFFF') ⇒ Object



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
# File 'lib/branston/app/helpers/application_helper.rb', line 14

def clippy(text, bgcolor='#FFFFFF')
  html = "    <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"\n            width=\"110\"\n            height=\"14\"\n            id=\"clippy\" >\n    <param name=\"movie\" value=\"/flash/clippy.swf\"/>\n    <param name=\"allowScriptAccess\" value=\"always\" />\n    <param name=\"quality\" value=\"high\" />\n    <param name=\"scale\" value=\"noscale\" />\n    <param NAME=\"FlashVars\" value=\"text=\#{text}\">\n    <param name=\"bgcolor\" value=\"\#{bgcolor}\">\n    <embed src=\"/flash/clippy.swf\"\n           width=\"110\"\n           height=\"14\"\n           name=\"clippy\"\n           quality=\"high\"\n           allowScriptAccess=\"always\"\n           type=\"application/x-shockwave-flash\"\n           pluginspage=\"http://www.macromedia.com/go/getflashplayer\"\n           FlashVars=\"text=\#{text}\"\n           bgcolor=\"\#{bgcolor}\"\n    />\n    </object>\n  EOF\nend\n"

#element_id(obj, field = "") ⇒ Object

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’



10
11
12
# File 'lib/branston/app/helpers/application_helper.rb', line 10

def element_id(obj, field="")
  obj.class.to_s + '_' + obj.id.to_s + (field.blank? ? '' : '_' + field)
end

#tab_on(tab_name, html_class = "current_page_item") ⇒ Object

Applies an html class attribute where the controller name contains the ‘tab_name’.



3
4
5
# File 'lib/branston/app/helpers/application_helper.rb', line 3

def tab_on(tab_name, html_class="current_page_item")
  controller_name.match(Regexp.new("#{tab_name}")) ? " class=\"#{html_class}\"" : ''
end