| Class | Wee::Brush::GenericTagBrush |
| In: |
lib/wee/html_brushes.rb
|
| Parent: | Brush |
| css_class | [HtmlAttribute] | |
| css_style | [HtmlAttribute] | |
| html_name | [HtmlAttribute] | |
| html_name | [HtmlAttribute] | |
| id | [HtmlAttribute] | |
| name | [HtmlAttribute] | |
| onclick | [HtmlAttribute] |
# 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
# File lib/wee/html_brushes.rb, line 92 def initialize(tag) super() @tag = tag @attributes = Hash.new end
# File lib/wee/html_brushes.rb, line 134 def __action_callback(&block) name(@canvas.register_callback(:action, block)) end
The callback id is listed in the URL (not as a form-data field)
# File lib/wee/html_brushes.rb, line 141 def __actionurl_callback(&block) __set_url(@canvas.url_for_callback(block)) end
# File lib/wee/html_brushes.rb, line 130 def __input_callback(&block) name(@canvas.register_callback(:input, block)) end
# File lib/wee/html_brushes.rb, line 103 def onclick_callback(&block) url = @canvas.url_for_callback(block) onclick_javascript("document.location.href='#{ url }'") end
# File lib/wee/html_brushes.rb, line 98 def onclick_javascript(v) onclick("javascript: #{v};") self end
# File lib/wee/html_brushes.rb, line 108 def onclick_update(update_id, &block) url = @canvas.url_for_callback(block) onclick_javascript("jQuery.get('#{url}', {}, function(data) {jQuery('##{update_id}').html(data);}, 'html'); return false") end
# File lib/wee/html_brushes.rb, line 113 def onclick_update_multi(&block) url = @canvas.url_for_callback(block) onclick_javascript("jQuery.get('#{url}', {}, function(data) {" + "jQuery(data).each(function(i,j){ var e = jQuery(j); jQuery('#'+e.attr('id')).html(e.html()); }); }, 'html'); return false") end