Sha256: dcfb49b9b602bf2d55c156a5679a84457b9602323fba6d293c0f8797f3838dab

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

module Document
  def self.[](selector)
    `$(#{selector})`
  end

  def self.find(selector)
    self[selector]
  end

  def self.id(id)
    %x{
      var el = document.getElementById(id);

      if (!el) {
        return nil;
      }

      return $(el);
    }
  end

  def self.parse(str)
    `$(str)`
  end

  def self.ready?(&block)
    %x{
      if (block === nil) {
        return nil;
      }

      $(function() {
        #{ block.call };
      });

      return nil;
    }
  end

  def self.title
    `document.title`
  end

  def self.title=(title)
    `document.title = title`
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-jquery-0.0.5 lib/assets/javascripts/opal/jquery/document.rb
opal-jquery-0.0.4 lib/assets/javascripts/opal/jquery/document.rb