opal-jquery 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -2
- data/Rakefile +2 -25
- data/config.ru +31 -0
- data/lib/assets/javascripts/opal-jquery.js.erb +3 -0
- data/lib/assets/javascripts/opal/jquery.rb +6 -0
- data/lib/assets/javascripts/opal/jquery/element.rb +21 -22
- data/lib/assets/javascripts/opal/jquery/event.rb +13 -0
- data/lib/assets/javascripts/opal/jquery/http.rb +13 -1
- data/lib/opal/jquery/version.rb +1 -1
- data/spec/autorun.rb +3 -0
- data/spec/element_spec.rb +2 -2
- data/spec/http_spec.rb +1 -1
- data/spec/local_storage_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -5
- metadata +8 -7
- data/lib/assets/javascripts/opal-jquery.js +0 -1
- data/lib/assets/javascripts/opal/jquery.js +0 -6
- data/spec/index.html +0 -10
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,28 +1,5 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler.require
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
File.open('build/opal-jquery.js', 'w+') do |out|
|
7
|
-
out.puts Opal.process('opal-jquery')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
desc "Build example specs ready to run"
|
12
|
-
task :build_specs => [:dir] do
|
13
|
-
Opal.append_path File.join(File.dirname(__FILE__), 'spec')
|
14
|
-
|
15
|
-
File.open('build/specs.js', 'w+') do |out|
|
16
|
-
out.puts Opal.process('spec_helper')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
task :dir do
|
21
|
-
FileUtils.mkdir_p 'build'
|
22
|
-
end
|
23
|
-
|
24
|
-
task :test do
|
25
|
-
OpalSpec.runner
|
26
|
-
end
|
27
|
-
|
28
|
-
task :default => [:build_specs, :test]
|
4
|
+
require 'opal/spec/rake_task'
|
5
|
+
Opal::Spec::RakeTask.new(:default)
|
data/config.ru
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
|
4
|
+
html = <<-HTML
|
5
|
+
<!DOCTYPE html>
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>opal-jquery specs</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<script src="/assets/autorun.js"></script>
|
12
|
+
</body>
|
13
|
+
</html>
|
14
|
+
HTML
|
15
|
+
|
16
|
+
map '/assets' do
|
17
|
+
env = Opal::Environment.new
|
18
|
+
env.append_path 'vendor' # for jquery
|
19
|
+
env.append_path 'spec'
|
20
|
+
run env
|
21
|
+
end
|
22
|
+
|
23
|
+
map '/' do
|
24
|
+
run lambda { |env|
|
25
|
+
if env['PATH_INFO'] == '/'
|
26
|
+
[200, {'Content-Type' => 'text/html'}, [html]]
|
27
|
+
else
|
28
|
+
Rack::Directory.new('spec').call(env)
|
29
|
+
end
|
30
|
+
}
|
31
|
+
end
|
@@ -226,6 +226,12 @@ class Element < `jQuery`
|
|
226
226
|
}
|
227
227
|
end
|
228
228
|
|
229
|
+
alias_native :blur, :blur
|
230
|
+
|
231
|
+
alias_native :closest, :closest
|
232
|
+
|
233
|
+
alias_native :data, :data
|
234
|
+
|
229
235
|
# Yields each element in #{self} collection in turn. The yielded element
|
230
236
|
# is wrapped as a `DOM` instance.
|
231
237
|
#
|
@@ -342,45 +348,38 @@ class Element < `jQuery`
|
|
342
348
|
|
343
349
|
alias_native :siblings, :siblings
|
344
350
|
|
345
|
-
def
|
351
|
+
def on(name, selector = nil, &handler)
|
346
352
|
%x{
|
347
|
-
if (
|
348
|
-
handler
|
349
|
-
#{self}.off(event_name, handler._jq);
|
353
|
+
if (selector === nil) {
|
354
|
+
#{self}.on(name, handler);
|
350
355
|
}
|
351
356
|
else {
|
352
|
-
#{self}.
|
357
|
+
#{self}.on(name, selector, handler);
|
353
358
|
}
|
359
|
+
|
360
|
+
return handler;
|
354
361
|
}
|
355
|
-
|
356
|
-
handler
|
357
362
|
end
|
358
363
|
|
359
|
-
def
|
360
|
-
return unless block_given?
|
361
|
-
|
362
|
-
# The choice of allowing a maximum of four parameters is arbitrary. arg1 is typically the
|
363
|
-
# event object and the rest are parameters passed by trigger(). For example, Rails 3 AJAX
|
364
|
-
# event handlers get passed up to three additional parameters in addition to the event object.
|
364
|
+
def off(name, selector = nil, &handler)
|
365
365
|
%x{
|
366
|
-
var handler = function(arg1, arg2, arg3, arg4) {
|
367
|
-
return #{ block.call `arg1, arg2, arg3, arg4` }
|
368
|
-
};
|
369
|
-
block._jq = handler;
|
370
|
-
|
371
366
|
if (selector === nil) {
|
372
|
-
#{self}.
|
367
|
+
return #{self}.off(name, handler);
|
373
368
|
}
|
374
369
|
else {
|
375
|
-
#{self}.
|
370
|
+
return #{self}.off(name, selector, handler);
|
376
371
|
}
|
377
372
|
}
|
378
|
-
|
379
|
-
block
|
380
373
|
end
|
381
374
|
|
375
|
+
alias_native :remove_attr, :removeAttr
|
376
|
+
|
382
377
|
alias_native :parent, :parent
|
383
378
|
|
379
|
+
alias_native :parents, :parents
|
380
|
+
|
381
|
+
alias_native :prepend, :prepend
|
382
|
+
|
384
383
|
alias_native :prev, :prev
|
385
384
|
|
386
385
|
alias_native :remove, :remove
|
@@ -10,6 +10,11 @@ class Event < `$.Event`
|
|
10
10
|
|
11
11
|
alias_native :default_prevented?, :isDefaultPrevented
|
12
12
|
|
13
|
+
def kill
|
14
|
+
stop_propagation
|
15
|
+
prevent_default
|
16
|
+
end
|
17
|
+
|
13
18
|
alias_native :prevent_default, :preventDefault
|
14
19
|
|
15
20
|
def page_x
|
@@ -30,6 +35,14 @@ class Event < `$.Event`
|
|
30
35
|
`$(#{self}.target)`
|
31
36
|
end
|
32
37
|
|
38
|
+
def touch_x
|
39
|
+
`#{self}.originalEvent.touches[0].pageX`
|
40
|
+
end
|
41
|
+
|
42
|
+
def touch_y
|
43
|
+
`#{self}.originalEvent.touches[0].pageY`
|
44
|
+
end
|
45
|
+
|
33
46
|
def type
|
34
47
|
`#{self}.type`
|
35
48
|
end
|
@@ -19,11 +19,16 @@ class HTTP
|
|
19
19
|
self.new(url, :POST, opts, block).send!
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.put(url, opts={}, &block)
|
23
|
+
self.new(url, :PUT, opts, block).send!
|
24
|
+
end
|
25
|
+
|
22
26
|
def initialize(url, method, options, handler=nil)
|
23
27
|
@url = url
|
24
28
|
@method = method
|
25
29
|
@ok = true
|
26
30
|
http = self
|
31
|
+
payload = options.delete :payload
|
27
32
|
settings = options.to_native
|
28
33
|
|
29
34
|
if handler
|
@@ -31,7 +36,14 @@ class HTTP
|
|
31
36
|
end
|
32
37
|
|
33
38
|
%x{
|
34
|
-
|
39
|
+
if (typeof(payload) === 'string') {
|
40
|
+
settings.data = payload;
|
41
|
+
}
|
42
|
+
else if (payload !== nil) {
|
43
|
+
settings.data = payload.$to_json();
|
44
|
+
settings.contentType = 'application/json';
|
45
|
+
}
|
46
|
+
|
35
47
|
settings.url = url;
|
36
48
|
settings.type = method;
|
37
49
|
|
data/lib/opal/jquery/version.rb
CHANGED
data/spec/autorun.rb
ADDED
data/spec/element_spec.rb
CHANGED
@@ -65,14 +65,14 @@ describe Element do
|
|
65
65
|
foo.trigger(:click)
|
66
66
|
end
|
67
67
|
|
68
|
-
it 'has an Event instance, plus
|
68
|
+
it 'has an Event instance, plus any additional parameters passed to the handler' do
|
69
69
|
foo = Document['#foo']
|
70
70
|
foo.on :bozo do |event, foo, bar, baz, buz|
|
71
71
|
event.should be_kind_of(Event)
|
72
72
|
foo.should == 'foo'
|
73
73
|
bar.should == 'bar'
|
74
74
|
baz.should == 'baz'
|
75
|
-
buz.should
|
75
|
+
buz.should == 'buz'
|
76
76
|
end
|
77
77
|
foo.trigger(:bozo, ['foo', 'bar', 'baz', 'buz'])
|
78
78
|
end
|
data/spec/http_spec.rb
CHANGED
data/spec/local_storage_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
#= require_tree .
|
1
|
+
require 'jquery'
|
2
|
+
require 'opal-spec'
|
3
|
+
require 'opal-jquery'
|
5
4
|
|
6
5
|
module OpalSpec
|
7
6
|
class ExampleGroup
|
@@ -34,4 +33,4 @@ module OpalSpec
|
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
|
-
|
36
|
+
Opal::Spec::Runner.autorun
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-jquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Opal DOM library for jquery
|
15
15
|
email: adam.beynon@gmail.com
|
@@ -23,8 +23,9 @@ files:
|
|
23
23
|
- LICENSE
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
|
-
-
|
27
|
-
- lib/assets/javascripts/opal
|
26
|
+
- config.ru
|
27
|
+
- lib/assets/javascripts/opal-jquery.js.erb
|
28
|
+
- lib/assets/javascripts/opal/jquery.rb
|
28
29
|
- lib/assets/javascripts/opal/jquery/document.rb
|
29
30
|
- lib/assets/javascripts/opal/jquery/element.rb
|
30
31
|
- lib/assets/javascripts/opal/jquery/event.rb
|
@@ -35,6 +36,7 @@ files:
|
|
35
36
|
- lib/opal/jquery.rb
|
36
37
|
- lib/opal/jquery/version.rb
|
37
38
|
- opal-jquery.gemspec
|
39
|
+
- spec/autorun.rb
|
38
40
|
- spec/data/simple.txt
|
39
41
|
- spec/data/user.json
|
40
42
|
- spec/document_spec.rb
|
@@ -55,7 +57,6 @@ files:
|
|
55
57
|
- spec/element_spec.rb
|
56
58
|
- spec/event_spec.rb
|
57
59
|
- spec/http_spec.rb
|
58
|
-
- spec/index.html
|
59
60
|
- spec/local_storage_spec.rb
|
60
61
|
- spec/spec_helper.rb
|
61
62
|
- vendor/jquery.js
|
@@ -79,11 +80,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
80
|
version: '0'
|
80
81
|
requirements: []
|
81
82
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.8.
|
83
|
+
rubygems_version: 1.8.23
|
83
84
|
signing_key:
|
84
85
|
specification_version: 3
|
85
86
|
summary: Opal access to jquery
|
86
87
|
test_files:
|
88
|
+
- spec/autorun.rb
|
87
89
|
- spec/data/simple.txt
|
88
90
|
- spec/data/user.json
|
89
91
|
- spec/document_spec.rb
|
@@ -104,6 +106,5 @@ test_files:
|
|
104
106
|
- spec/element_spec.rb
|
105
107
|
- spec/event_spec.rb
|
106
108
|
- spec/http_spec.rb
|
107
|
-
- spec/index.html
|
108
109
|
- spec/local_storage_spec.rb
|
109
110
|
- spec/spec_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require opal/jquery
|