Sha256: ab44a2735ee3a188938fc32ca2abf2714baf222ccdfec7c8d1eaf99a2a4d87bd

Contents?: true

Size: 965 Bytes

Versions: 6

Compression:

Stored size: 965 Bytes

Contents

module UnderOs::UI::Commons
  def id
    @_id
  end

  def id=(id)
    @_id = id
  end

  def tagName
    @_tag_name ||= begin
      wraps = UnderOs::UI::Wrap::WRAPS_TAGS_MAP
      klass = self.class; tag = 'VIEW'

      while klass
        if wrap = wraps.detect{|t,k| k == klass}
          tag = wrap[0].upcase
          break
        else
          klass = klass.superclass
        end
      end

      tag
    end
  end

  def data(key=nil)
    key && @_data ? @_data[key.to_sym] : @_data
  end

  def data=(hash)
    @_data = hash
  end

  def page
    resp = @_

    while resp = resp.nextResponder
      if resp.is_a?(UIViewController)
        return resp.wrapper
      end
    end

    nil
  end

  def hide
    style.display = :none
  end

  def show
    style.display = :block
  end

  def toggle
    hidden ? show : hide
  end

  def hidden
    @_.isHidden
  end

  def visible
    !hidden
  end

  alias :hidden?  :hidden
  alias :visible? :visible
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 lib/under_os/ui/utils/commons.rb
under-os-1.3.0 lib/under_os/ui/utils/commons.rb
under-os-1.2.1 lib/under_os/ui/utils/commons.rb
under-os-1.2.0 lib/under_os/ui/utils/commons.rb
under-os-1.1.0 lib/under_os/ui/utils/commons.rb
under-os-1.0.0 lib/under_os/ui/utils/commons.rb