Module: MainHelper

Defined in:
lib/helpers/main_helper.rb

Instance Method Summary collapse

Instance Method Details

#button(text, styles = {}, &callback) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/helpers/main_helper.rb', line 2

def button(text, styles={}, &callback)
  if admin_window?
    stack(:height => 32, :width => styles[:width]||(40+(text.length * 8)), :margin => [5,10,5,0], :padding_top => 0) do
      background(button_background||styles[:fill]||("#e5e6e6"..."#c1c2c4"), :curve => 1)
      border(button_border||styles[:border]||"#ffcf01")
      t = inscription(text, :align => styles[:align]||'center', :stroke => styles[:stroke]||black, :margin => styles[:margin]||[0]*4)
      click &callback
      hover {
        self.cursor = :hand
      }
      leave {
        self.cursor = :arrow
      }
    end
  end
end

#containerObject


53
54
55
56
# File 'lib/helpers/main_helper.rb', line 53

def container
  background(container_background||("#e5e6e6"..."#babcbe"), :curve => 1)
  border(container_border||"#ffcf01")
end

#delete_button(styles = {}, &callback) ⇒ Object


46
47
48
# File 'lib/helpers/main_helper.rb', line 46

def delete_button(styles={}, &callback)
  image_button("media/cross.png", styles, &callback)
end

#edit_button(styles = {}, &callback) ⇒ Object


49
50
51
# File 'lib/helpers/main_helper.rb', line 49

def edit_button(styles={}, &callback)
  image_button("media/application_form_edit.png", styles, &callback)
end

#image_button(path, styles = {}, &callback) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/helpers/main_helper.rb', line 27

def image_button(path,styles={}, &callback)
  if admin_window?
    stack(:margin_top => 8, :width => 20) do
      click &callback
      b = background(link_hover_background||"#ffcf01")
      image path
      b.hide
      hover {
        b.show
        self.cursor = :hand
      }
      leave {
        b.hide
        self.cursor = :arrow
      }
    end
  end
end

#left_button(text, styles = {}, &callback) ⇒ Object


19
20
21
# File 'lib/helpers/main_helper.rb', line 19

def left_button(text, styles={}, &callback)
  button(text, styles.merge({:width => 1.0, :align => 'left', :margin => [10,0,0,0]}), &callback)
end

#light_button(text, styles = {}, &callback) ⇒ Object


23
24
25
# File 'lib/helpers/main_helper.rb', line 23

def light_button(text, styles={}, &callback)
  button(text, styles.merge({}), &callback)
end

#separator_line(n = 45) ⇒ Object


66
67
68
69
70
# File 'lib/helpers/main_helper.rb', line 66

def separator_line(n=45)
  flow(:height => 18, :scroll => false) do
    inscription '_'*n, :margin => [0]*4, :stroke => divider_color||"#ffcf01"
  end
end

#sessionObject


58
59
60
61
62
63
64
# File 'lib/helpers/main_helper.rb', line 58

def session
  if(defined?(@@session) && @@session)
    @@session
  else
    @@session = {:referrer => []}
  end
end

#small_logoObject


72
73
74
75
76
77
78
# File 'lib/helpers/main_helper.rb', line 72

def 
  if(defined?(SKIN)&&File.exist?("media/skins/#{SKIN}/logo_text.png"))
    image("media/skins/#{SKIN}/logo_text.png", :attach => Window, :top => 30, :left => WIDTH-110)
  else
    image("media/logo_text.png", :attach => Window, :top => 30, :left => WIDTH-110)
  end
end