Module: Merb::GlobalHelpers

Defined in:
lib/merb-laszlo/helpers.rb

Instance Method Summary collapse

Instance Method Details

#add_lz_resource(src) ⇒ Object



34
35
36
37
# File 'lib/merb-laszlo/helpers.rb', line 34

def add_lz_resource(src)
  @lz_resources ||= []
  @lz_resources << src unless URI.parse(src).scheme
end

#lz(name, *args, &blk) ⇒ Object



4
5
6
# File 'lib/merb-laszlo/helpers.rb', line 4

def lz(name, *args, &blk)
  send("lz_#{name}", *args, &blk)
end

#lz_attr(name, value, type = nil) ⇒ Object



51
52
53
54
55
# File 'lib/merb-laszlo/helpers.rb', line 51

def lz_attr(name, value, type = nil)
  mrg = {:name => name, :value => value}
  mrg.merge!(:type => type) if type
  self_closing_tag(:attribute, mrg)
end

#lz_class(name, extends = nil, opts = {}, &blk) ⇒ Object



16
17
18
19
20
# File 'lib/merb-laszlo/helpers.rb', line 16

def lz_class(name, extends = nil, opts = {}, &blk)
  opts.merge!(:name => name)
  opts.merge!(:extends => extends) if extends
  tag(:class, nil, opts, &blk)
end

#lz_def(name, *args, &blk) ⇒ Object



57
58
59
# File 'lib/merb-laszlo/helpers.rb', line 57

def lz_def(name, *args, &blk)
  tag(:method, blk ? capture(&blk) : "", :name => name, :args => args.map {|x| x.to_s}.join(","))
end

#lz_on(name, options = {}, *args, &blk) ⇒ Object



45
46
47
48
49
# File 'lib/merb-laszlo/helpers.rb', line 45

def lz_on(name, options = {}, *args, &blk)
  options.merge!(:name => "on#{name}")
  options.merge!(:args => args.map {|x| x.to_s}.join(", ")) unless args.empty?
  tag(:handler, capture(&blk), options)
end

#lz_reload_buttonObject



8
9
10
11
12
13
14
# File 'lib/merb-laszlo/helpers.rb', line 8

def lz_reload_button
  contents = "Reload" +
  tag(:handler, %{LzBrowser.loadJS("window.location = \\\"#{request.full_uri}\\\"")}, :name => "onclick") +
  tag(:handler, %{this.bringToFront()}, :name => "oninit")
  
  tag(:button, contents, :valign => "bottom", :align => "right")
end

#lz_resource(name, src, opts = {}) ⇒ Object



39
40
41
42
43
# File 'lib/merb-laszlo/helpers.rb', line 39

def lz_resource(name, src, opts = {})
  add_lz_resource(src)
  opts.merge!(:name => name, :src => src)
  self_closing_tag(:resource, opts)
end

#lz_resource_view(src, options = {}, &blk) ⇒ Object



65
66
67
68
# File 'lib/merb-laszlo/helpers.rb', line 65

def lz_resource_view(src, options = {}, &blk)
  add_lz_resource(src)
  tag(:view, blk ? capture(&blk) : "", {:resource => src}.merge(options))
end

#lz_text(text, opts = {}) ⇒ Object



22
23
24
# File 'lib/merb-laszlo/helpers.rb', line 22

def lz_text(text, opts = {})
  self_closing_tag(:text, {:text => text}.merge(opts))
end

#lz_view(width, height, bgcolor, options = {}, &blk) ⇒ Object



61
62
63
# File 'lib/merb-laszlo/helpers.rb', line 61

def lz_view(width, height, bgcolor, options = {}, &blk)
  tag(:view, blk ? capture(&blk) : "", {:width => width, :height => height, :bgcolor => bgcolor}.merge(options))
end

#lz_window(width = nil, height = nil, opts = {}, &blk) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/merb-laszlo/helpers.rb', line 26

def lz_window(width = nil, height = nil, opts = {}, &blk)
  mrg = {:resizable => true}
  mrg.merge!(:width => width) if width
  mrg.merge!(:height => height) if height
  opts = mrg.merge(opts)
  tag(:window, nil, opts, &blk)
end