Module: Merb::MerbUi::StylesHelper

Defined in:
app/helpers/styles_helper.rb

Instance Method Summary collapse

Instance Method Details

#color(r, g, b) ⇒ Object



54
55
56
# File 'app/helpers/styles_helper.rb', line 54

def color(r,g,b)
  "rgb(#{decimal_to_rgb(r)}, #{decimal_to_rgb(g)}, #{decimal_to_rgb(b)})"
end

#decimal_to_rgb(d) ⇒ Object



58
59
60
# File 'app/helpers/styles_helper.rb', line 58

def decimal_to_rgb(d)
  (d * 255).to_i
end

#has_layoutObject



62
63
64
# File 'app/helpers/styles_helper.rb', line 62

def has_layout
  'min-height: 0;' if msie?
end

#property(title, options = {}) ⇒ Object



66
67
68
69
70
# File 'app/helpers/styles_helper.rb', line 66

def property(title, options={})
  output = ''
  output << "\r  " if options[:linebreak] == true
  output << title + ': ' + options[:value].to_s + ';'
end

#round(options = {}) ⇒ Object



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
# File 'app/helpers/styles_helper.rb', line 3

def round(options={})

  options[:amount] ||= 0.4
  value_false = 0
  value_true = "#{options[:amount]}em"
  if options[:bottom_left]
    bottom_left = {:value => value_true}
  else
    bottom_left = {:value => value_false}
  end
  if options[:bottom_right]
    bottom_right = {:linebreak => true, :value => value_true}
  else
    bottom_right = {:linebreak => true, :value => value_false}
  end
  if options[:top_left]
    top_left = {:linebreak => true, :value => value_true}
  else
    top_left = {:linebreak => true, :value => value_false}
  end
  if options[:top_right]
    top_right = {:linebreak => true, :value => value_true}
  else
    top_right = {:linebreak => true, :value => value_false}
  end

  if options[:bottom_left] | options[:bottom_right] | options[:top_left] | options[:top_right]
    if mui_browser == 'gecko'
      title = "-moz-border-"
      property("#{title}radius-bottomleft", bottom_left) +
      property("#{title}radius-bottomright", bottom_right) +
      property("#{title}radius-topleft", top_left) +
      property("#{title}radius-topright", top_right)
    elsif mui_browser == 'webkit'
      title = "-webkit-border-"
      property("#{title}bottom-left-radius", bottom_left) +
      property("#{title}bottom-right-radius", bottom_right) +
      property("#{title}top-left-radius", top_left) +
      property("#{title}top-right-radius", top_right)
    end
  else
    if mui_browser == 'gecko'
      title = "-moz-border-"
    elsif mui_browser == 'webkit'
      title = "-webkit-border-"
    end
    property("#{title}radius", :value => value_true)
  end

end

#selector(title) ⇒ Object



72
73
74
# File 'app/helpers/styles_helper.rb', line 72

def selector(title)
  title + ' {' + yield + "}\r"
end