Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed May 31, 2013
1 parent e5e3d9c commit e58da72
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/rake/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application.js
4 changes: 4 additions & 0 deletions examples/rake/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'opal-jquery', :path => '../..'
gem 'opal', '0.3.44'
8 changes: 8 additions & 0 deletions examples/rake/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Install dependencies:

$ bundle install

Build `application.js` with:

$ bundle exec rake build

11 changes: 11 additions & 0 deletions examples/rake/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'bundler'
Bundler.require

desc "Build to application.js"
task :build do
File.open("application.js", "w+") do |out|
env = Opal::Environment.new
env.append_path "app"
out << env["application"].to_s
end
end
6 changes: 6 additions & 0 deletions examples/rake/app/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'opal'
require 'opal-jquery'

Document.ready? do
Element.find('#foo').text = "Opal is loaded"
end
12 changes: 12 additions & 0 deletions examples/rake/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>opal-jquery example</title>

<script src="../../spec/jquery.js"></script>
<script src="application.js"></script>
</head>
<body>
<div id="foo"></div>
</body>
</html>
16 changes: 7 additions & 9 deletions opal/opal-jquery/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ def self.document

Document = Element.document

class << Document
def self.ready?(&block)
%x{
if (block === nil) {
return nil;
}
$(block);
def Document.ready?(&block)
%x{
if (block === nil) {
return nil;
}
end
$(block);
return nil;
}
end

0 comments on commit e58da72

Please sign in to comment.