Class Wee::Brush::GenericTagBrush
In: lib/wee/html_brushes.rb
Parent: Brush

Methods

Attributes

css_class  [HtmlAttribute] 
css_style  [HtmlAttribute] 
html_name  [HtmlAttribute] 
html_name  [HtmlAttribute] 
id  [HtmlAttribute] 
name  [HtmlAttribute] 
onclick  [HtmlAttribute] 

Public Class methods

[Source]

# 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

[Source]

# File lib/wee/html_brushes.rb, line 92
    def initialize(tag)
      super()
      @tag = tag
      @attributes = Hash.new
    end

Public Instance methods

[Source]

# 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)

[Source]

# File lib/wee/html_brushes.rb, line 141
    def __actionurl_callback(&block)
      __set_url(@canvas.url_for_callback(block))
    end

[Source]

# File lib/wee/html_brushes.rb, line 130
    def __input_callback(&block)
      name(@canvas.register_callback(:input, block))
    end

[Source]

# File lib/wee/html_brushes.rb, line 145
    def __set_url(url)
      raise
    end

[Source]

# 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

[Source]

# File lib/wee/html_brushes.rb, line 98
    def onclick_javascript(v)
      onclick("javascript: #{v};")
      self
    end

[Source]

# 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

[Source]

# 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

[Source]

# File lib/wee/html_brushes.rb, line 122
    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

[Validate]