Class: Wee::Brush::GenericTagBrush
- Inherits:
-
Wee::Brush
show all
- Defined in:
- lib/wee/html_brushes.rb,
lib/wee/html_brushes.rb
Direct Known Subclasses
AnchorTag, FormTag, GenericSingleTagBrush, JavascriptTag, SelectListTag, SelectOptionTag, TableDataTag, TableHeaderTag, TableRowTag, TableTag, TextAreaTag
Instance Attribute Summary
Attributes inherited from Wee::Brush
#canvas, #document
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Wee::Brush
#close, nesting?, #setup
Constructor Details
Returns a new instance of GenericTagBrush.
93
94
95
96
97
|
# File 'lib/wee/html_brushes.rb', line 93
def initialize(tag)
super()
@tag = tag
@attributes = Hash.new
end
|
Class Method Details
.html_attr(attr, hash = {}) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/wee/html_brushes.rb', line 49
def self.html_attr(attr, hash={})
name = hash[:html_name] || attr
if hash[:type] == :bool
class_eval %{
def #{ attr }(bool=true)
if bool
@attributes[:"#{ name }"] = nil
else
@attributes.delete(:"#{ name }")
end
self
end
}
else
class_eval %{
def #{ attr }(value)
if value == nil
@attributes.delete(:"#{ name }")
else
@attributes[:"#{ name }"] = value
end
self
end
}
end
(hash[:aliases] || []).each do |a|
class_eval "alias #{ a } #{ attr }"
end
(hash[:shortcuts] || {}).each_pair do |k, v|
class_eval "def #{ k }() #{ attr }(#{ v.inspect }) end"
end
end
|
Instance Method Details
Returns a unique DOM id for the underlying component
109
110
111
|
# File 'lib/wee/html_brushes.rb', line 109
def get_oid
"wee_#{@canvas.current_component.object_id}"
end
|
102
103
104
|
# File 'lib/wee/html_brushes.rb', line 102
def oid
id(get_oid())
end
|
#onclick_callback(&block) ⇒ Object
117
118
119
120
|
# File 'lib/wee/html_brushes.rb', line 117
def onclick_callback(&block)
url = @canvas.url_for_callback(block)
onclick("javascript: document.location.href='#{ url }'")
end
|
#onclick_javascript(v) ⇒ Object
113
114
115
|
# File 'lib/wee/html_brushes.rb', line 113
def onclick_javascript(v)
onclick("javascript: #{v}")
end
|
#onclick_update_callback(&block) ⇒ Object
136
137
138
139
140
|
# File 'lib/wee/html_brushes.rb', line 136
def onclick_update_callback(&block)
raise ArgumentError unless block
url = @canvas.url_for_callback(@canvas.session.render_ajax_proc(block, @canvas.current_component))
onclick("javascript: wee.update('#{url}')")
end
|
#onclick_update_self_callback(&block) ⇒ Object
127
128
129
130
131
132
133
134
|
# File 'lib/wee/html_brushes.rb', line 127
def onclick_update_self_callback(&block)
raise ArgumentError unless block
current_component = @canvas.current_component
onclick_update_callback {|r|
block.call(r)
r.update(current_component)
}
end
|
#ondblclick_callback(&block) ⇒ Object
122
123
124
125
|
# File 'lib/wee/html_brushes.rb', line 122
def ondblclick_callback(&block)
url = @canvas.url_for_callback(block)
ondblclick("javascript: document.location.href='#{ url }'")
end
|
#with(text = nil, &block) ⇒ Object
142
143
144
145
146
147
148
|
# File 'lib/wee/html_brushes.rb', line 142
def with(text=nil, &block)
@document.start_tag(@tag, @attributes)
@document.text(text) if text
@canvas.nest(&block) if block
@document.end_tag(@tag)
@document = @canvas = nil
end
|