Class: Wee::Brush::GenericTagBrush

Inherits:
Wee::Brush show all
Defined in:
lib/wee/renderer/html/brushes.rb

Instance Attribute Summary

Attributes inherited from Wee::Brush

#canvas, #parent

Instance Method Summary collapse

Methods inherited from Wee::Brush

#close

Constructor Details

#initialize(tag, is_single_tag = false) ⇒ GenericTagBrush

Returns a new instance of GenericTagBrush.



136
137
138
139
140
# File 'lib/wee/renderer/html/brushes.rb', line 136

def initialize(tag, is_single_tag=false)
  super()
  @tag, @is_single_tag = tag, is_single_tag
  @attributes = Hash.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, attr) ⇒ Object



132
133
134
# File 'lib/wee/renderer/html/brushes.rb', line 132

def method_missing(id, attr)
  html_attr(id.to_s, attr)
end

Instance Method Details

#__action_callback(symbol = nil, *args, &block) ⇒ Object



116
117
118
# File 'lib/wee/renderer/html/brushes.rb', line 116

def __action_callback(symbol=nil, *args, &block)
  name(@canvas.register_callback(:action, to_callback(symbol, args, block)))
end

#__actionurl_callback(symbol = nil, *args, &block) ⇒ Object

The callback id is listed in the URL (not as a form-data field)



122
123
124
# File 'lib/wee/renderer/html/brushes.rb', line 122

def __actionurl_callback(symbol=nil, *args, &block)
  __set_url(@canvas.url_for_callback(to_callback(symbol, args, block)))
end

#__actionurl_named_callback(name, symbol = nil, *args, &block) ⇒ Object

The callback id is listed in the URL (not as a form-data field)



128
129
130
# File 'lib/wee/renderer/html/brushes.rb', line 128

def __actionurl_named_callback(name, symbol=nil, *args, &block)
  __set_url(@canvas.url_for_named_callback(name, to_callback(symbol, args, block)))
end

#__input_callback(symbol = nil, *args, &block) ⇒ Object



112
113
114
# File 'lib/wee/renderer/html/brushes.rb', line 112

def __input_callback(symbol=nil, *args, &block)
  name(@canvas.register_callback(:input, to_callback(symbol, args, block)))
end

#css_class(c) ⇒ Object



144
145
146
# File 'lib/wee/renderer/html/brushes.rb', line 144

def css_class(c)
  html_attr("class", c)
end

#css_class_for(prop) ⇒ Object

This method construct the css-class attribute by looking up the property from the current component.



163
164
165
166
167
# File 'lib/wee/renderer/html/brushes.rb', line 163

def css_class_for(prop)
  val = @canvas.current_component.lookup_property(prop)
  raise "no property found for: <#{ prop }>" if val.nil?
  css_class(val)
end

#onclick_callback(symbol = nil, *args, &block) ⇒ Object

Raises:

  • (ArgumentError)


148
149
150
151
152
# File 'lib/wee/renderer/html/brushes.rb', line 148

def onclick_callback(symbol=nil, *args, &block)
  raise ArgumentError if symbol and block
  url = @canvas.url_for_callback(to_callback(symbol, args, block))
  onclick("javascript: document.location.href='#{ url }';")          
end

#onclick_update(update_id, symbol = nil, *args, &block) ⇒ Object

Raises:

  • (ArgumentError)


154
155
156
157
158
# File 'lib/wee/renderer/html/brushes.rb', line 154

def onclick_update(update_id, symbol=nil, *args, &block)
  raise ArgumentError if symbol and block
  url = @canvas.url_for_callback(to_callback(symbol, args, block))
  onclick("javascript: new Ajax.Updater('#{ update_id }', '#{ url }', {method:'get'}); return false;")
end

#with(text = nil, &block) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/wee/renderer/html/brushes.rb', line 169

def with(text=nil, &block)
  doc = @canvas.document
  if @is_single_tag
    raise ArgumentError if text or block
    doc.single_tag(@tag, @attributes) 
    @closed = true
  else
    doc.start_tag(@tag, @attributes)
    if text
      doc.text(text)
      super(text, &block)
    else
      super(&block)
    end
    doc.end_tag(@tag)
  end
  nil
end