opal-jquery 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/config.ru +1 -1
- data/lib/opal/jquery/version.rb +1 -1
- data/opal-jquery.gemspec +1 -1
- data/opal/opal-jquery/element.rb +12 -16
- data/opal/opal-jquery/http.rb +1 -0
- data/spec/element/animations_spec.rb +11 -7
- data/spec/element/attributes_spec.rb +10 -10
- data/spec/element/method_missing_spec.rb +2 -2
- data/spec/http_spec.rb +4 -4
- data/spec/spec_helper.rb +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15f89460a5383c4cac26b038d21b86d96543a44a
|
4
|
+
data.tar.gz: bffe7c3427abcdd767fbf8db2ae69b8ee4c54e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5220c73d6ef31b04c166e38e37ca8f0a2481768fa018550abf9fe48864e513679cff67d95126eb2179a432507c82dd2974f4ca67c9aecaabef15d0659e6e4003
|
7
|
+
data.tar.gz: 383b2fe50f6f72ee987310fc4835c41271d740d3be1e4f907f083af1b3aa686a8011891c442826586b4df2e683cba833090399f84029f3c7c1edc6b5d2705a02
|
data/Rakefile
CHANGED
@@ -2,12 +2,12 @@ require 'bundler'
|
|
2
2
|
Bundler.require
|
3
3
|
Bundler::GemHelper.install_tasks
|
4
4
|
|
5
|
-
require 'opal/
|
6
|
-
Opal::
|
5
|
+
require 'opal/rspec/rake_task'
|
6
|
+
Opal::RSpec::RakeTask.new(:default) do |s|
|
7
7
|
s.index_path = 'spec/jquery/index.html'
|
8
8
|
end
|
9
9
|
|
10
|
-
Opal::
|
10
|
+
Opal::RSpec::RakeTask.new(:zepto) do |s|
|
11
11
|
s.index_path = 'spec/zepto/index.html'
|
12
12
|
end
|
13
13
|
|
data/config.ru
CHANGED
data/lib/opal/jquery/version.rb
CHANGED
data/opal-jquery.gemspec
CHANGED
data/opal/opal-jquery/element.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
var root = $opal.global, dom_class;
|
1
|
+
%x{
|
2
|
+
var root = $opal.global, dom_class;
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
self._proto = dom_class.prototype, def = self._proto;
|
16
|
-
dom_class.prototype._klass = self;
|
4
|
+
if (root.jQuery) {
|
5
|
+
dom_class = jQuery
|
6
|
+
}
|
7
|
+
else if (root.Zepto) {
|
8
|
+
dom_class = Zepto.zepto.Z;
|
9
|
+
}
|
10
|
+
else {
|
11
|
+
throw new Error("jQuery must be included before opal-jquery");
|
17
12
|
}
|
13
|
+
}
|
18
14
|
|
19
|
-
|
15
|
+
class Element < `dom_class`
|
20
16
|
include Enumerable
|
21
17
|
|
22
18
|
def self.find(selector)
|
data/opal/opal-jquery/http.rb
CHANGED
@@ -9,33 +9,37 @@ describe "Element animation methods" do
|
|
9
9
|
### HACKY
|
10
10
|
# jQUery's animate method doesn't *always* finish on time
|
11
11
|
# so the values are being compared using greater than
|
12
|
-
|
12
|
+
|
13
13
|
it "should animate a set of properties and values" do
|
14
14
|
foo = Element.find "#animate-foo"
|
15
15
|
foo.animate :width => "200px"
|
16
16
|
|
17
17
|
set_timeout 400 do
|
18
|
-
(foo.css("width").to_f > 199).should
|
18
|
+
(foo.css("width").to_f > 199).should eq(true)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
async "should allow you to set a speed in the params" do
|
23
23
|
foo = Element.find "#animate-foo"
|
24
24
|
foo.animate :width => "200px", :speed => 100
|
25
25
|
|
26
26
|
set_timeout 105 do
|
27
|
-
|
27
|
+
run_async {
|
28
|
+
(foo.css("width").to_f > 199).should eq(true)
|
29
|
+
}
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
|
33
|
+
async "should accept a block as a callback" do
|
32
34
|
foo = Element.find "#animate-foo"
|
33
|
-
foo.animate :width => "200px" do
|
35
|
+
foo.animate :width => "200px", :speed => 100 do
|
34
36
|
foo.add_class "finished"
|
35
37
|
end
|
36
38
|
|
37
39
|
set_timeout 405 do
|
38
|
-
|
40
|
+
run_async {
|
41
|
+
foo.class_name.should eq("finished")
|
42
|
+
}
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
@@ -72,14 +72,14 @@ describe Element do
|
|
72
72
|
describe "#add_class" do
|
73
73
|
it "should add the given class name to the element" do
|
74
74
|
foo = Element.find '#foo'
|
75
|
-
foo.has_class?('lemons').should
|
75
|
+
foo.has_class?('lemons').should eq(false)
|
76
76
|
foo.add_class 'lemons'
|
77
|
-
foo.has_class?('lemons').should
|
77
|
+
foo.has_class?('lemons').should eq(true)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not duplicate class names on an element" do
|
81
81
|
bar = Element.find '#bar'
|
82
|
-
bar.has_class?('apples').should
|
82
|
+
bar.has_class?('apples').should eq(true)
|
83
83
|
bar.add_class 'apples'
|
84
84
|
bar.class_name.should == 'apples'
|
85
85
|
end
|
@@ -93,9 +93,9 @@ describe Element do
|
|
93
93
|
|
94
94
|
describe '#has_class?' do
|
95
95
|
it "should return true if the element has the given class" do
|
96
|
-
Element.find('#has-foo').has_class?("apples").should
|
97
|
-
Element.find('#has-foo').has_class?("oranges").should
|
98
|
-
Element.find('#has-bar').has_class?("lemons").should
|
96
|
+
Element.find('#has-foo').has_class?("apples").should eq(true)
|
97
|
+
Element.find('#has-foo').has_class?("oranges").should eq(false)
|
98
|
+
Element.find('#has-bar').has_class?("lemons").should eq(true)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -152,16 +152,16 @@ describe Element do
|
|
152
152
|
describe '#toggle_class' do
|
153
153
|
it 'adds the given class name to the element if not already present' do
|
154
154
|
foo = Element.find('#foo')
|
155
|
-
foo.has_class?('oranges').should
|
155
|
+
foo.has_class?('oranges').should eq(false)
|
156
156
|
foo.toggle_class 'oranges'
|
157
|
-
foo.has_class?('oranges').should
|
157
|
+
foo.has_class?('oranges').should eq(true)
|
158
158
|
end
|
159
159
|
|
160
160
|
it 'removes the class if the element already has it' do
|
161
161
|
bar = Element.find('#bar')
|
162
|
-
bar.has_class?('apples').should
|
162
|
+
bar.has_class?('apples').should eq(true)
|
163
163
|
bar.toggle_class 'apples'
|
164
|
-
bar.has_class?('apples').should
|
164
|
+
bar.has_class?('apples').should eq(false)
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
data/spec/http_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe HTTP do
|
|
13
13
|
async 'can add a success callback after the request is sent' do
|
14
14
|
http = HTTP.get('spec/fixtures/simple.txt')
|
15
15
|
http.callback do |response|
|
16
|
-
run_async { response.
|
16
|
+
run_async { response.should be_ok }
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -22,7 +22,7 @@ describe HTTP do
|
|
22
22
|
async 'can add a failure callback after the request is sent' do
|
23
23
|
http = HTTP.get('spec/fixtures/bad_url.txt')
|
24
24
|
http.errback do |response|
|
25
|
-
run_async { response.
|
25
|
+
run_async { response.should_not be_ok }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -38,13 +38,13 @@ describe HTTP do
|
|
38
38
|
describe '#ok?' do
|
39
39
|
async 'returns true when the request was a sucess' do
|
40
40
|
HTTP.get('spec/fixtures/simple.txt') do |response|
|
41
|
-
run_async { response.
|
41
|
+
run_async { response.should be_ok }
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
async 'returns false when the request failed' do
|
46
46
|
HTTP.get('spec/fixtures/non_existant.txt') do |response|
|
47
|
-
run_async { response.
|
47
|
+
run_async { response.should_not be_ok }
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'opal-
|
1
|
+
require 'opal-rspec'
|
2
2
|
require 'opal-jquery'
|
3
3
|
|
4
4
|
module JqueryHelpers
|
@@ -30,6 +30,6 @@ module JqueryHelpers
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
extend JqueryHelpers
|
33
|
+
RSpec.configure do |config|
|
34
|
+
config.extend JqueryHelpers
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-jquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: opal-
|
28
|
+
name: opal-rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
description: Opal DOM library for jquery
|
42
42
|
email: adam.beynon@gmail.com
|
43
43
|
executables: []
|