opal-jquery 0.4.2 → 0.4.6
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.
- checksums.yaml +5 -5
- data/.editorconfig +12 -0
- data/.travis.yml +22 -15
- data/CHANGELOG.md +59 -3
- data/Gemfile +13 -2
- data/README.md +5 -3
- data/Rakefile +22 -4
- data/config.ru +4 -6
- data/lib/opal/jquery/document.rb +2 -0
- data/lib/opal/jquery/element.rb +86 -24
- data/lib/opal/jquery/http.rb +5 -1
- data/lib/opal/jquery/version.rb +1 -1
- data/lib/opal/jquery/window.rb +2 -1
- data/opal-jquery.gemspec +8 -7
- data/{spec → spec-opal}/document_spec.rb +11 -4
- data/{spec → spec-opal}/element/after_spec.rb +1 -1
- data/{spec → spec-opal}/element/animations_spec.rb +5 -5
- data/{spec → spec-opal}/element/append_spec.rb +1 -1
- data/{spec → spec-opal}/element/append_to_spec.rb +1 -1
- data/{spec → spec-opal}/element/at_spec.rb +1 -1
- data/{spec → spec-opal}/element/attributes_spec.rb +1 -1
- data/{spec → spec-opal}/element/before_spec.rb +1 -1
- data/{spec → spec-opal}/element/class_name_spec.rb +2 -2
- data/{spec → spec-opal}/element/css_spec.rb +3 -3
- data/{spec → spec-opal}/element/display_spec.rb +6 -6
- data/spec-opal/element/expose_spec.rb +73 -0
- data/{spec → spec-opal}/element/height_width_spec.rb +1 -1
- data/{spec → spec-opal}/element/inspect_spec.rb +1 -1
- data/{spec → spec-opal}/element/iterable_spec.rb +1 -1
- data/{spec → spec-opal}/element/length_spec.rb +1 -1
- data/spec-opal/element/method_missing_spec.rb +34 -0
- data/{spec → spec-opal}/element/prepend_spec.rb +1 -1
- data/{spec → spec-opal}/element/to_s_spec.rb +1 -1
- data/{spec → spec-opal}/element/traversing_spec.rb +5 -5
- data/spec-opal/element_spec.rb +261 -0
- data/{spec → spec-opal}/event_spec.rb +1 -1
- data/{spec → spec-opal}/fixtures/simple.txt +0 -0
- data/{spec → spec-opal}/fixtures/user.json +0 -0
- data/{spec → spec-opal}/http_spec.rb +1 -1
- data/{spec → spec-opal}/jquery/index.html.erb +1 -1
- data/spec-opal/jquery/index3.html.erb +10 -0
- data/{spec/jquery/jquery.js → spec-opal/jquery/jquery-1.8.3.js} +0 -0
- data/spec-opal/jquery/jquery-3.0.0.js +4 -0
- data/spec-opal/kernel_spec.rb +15 -0
- data/{spec → spec-opal}/local_storage_spec.rb +1 -1
- data/{spec → spec-opal}/spec_helper.rb +10 -0
- data/{spec → spec-opal}/zepto/index.html.erb +0 -0
- data/{spec → spec-opal}/zepto/zepto.js +0 -0
- metadata +81 -83
- data/spec/element/method_missing_spec.rb +0 -32
- data/spec/element_spec.rb +0 -273
- data/spec/kernel_spec.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 17e1701d287a5fb7acf42bbeb048aa016cd6d8227f0934553bba451497f19137
|
|
4
|
+
data.tar.gz: fc349c46157151fc8d61f29c353d8e9f4ea52ac961a6046b8895d4aa1fbb995f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf2238899bdcd262622da77911e9ec21486130386b7cf4cb1abf01fee14379f180e11cdc67f5f25e69a718294cf11ebf8e05f11c15ac5585f5386d684a0200a6
|
|
7
|
+
data.tar.gz: c6832e7ce09f567586f234ce1a94c447f602f0a792ced7dee29f7d827f24058796ec8015eff2fd4d15376edbe2cf61c020f03b14cfe4ee8ffe980989e9ce73be
|
data/.editorconfig
ADDED
data/.travis.yml
CHANGED
|
@@ -2,25 +2,18 @@ language: ruby
|
|
|
2
2
|
sudo: false
|
|
3
3
|
|
|
4
4
|
fast_finish: true
|
|
5
|
-
script: rake $RUN
|
|
6
|
-
|
|
7
|
-
before_install:
|
|
8
|
-
# thanks to https://mediocre.com/forum/topics/phantomjs-2-and-travis-ci-we-beat-our-heads-against-a-wall-so-you-dont-have-to
|
|
9
|
-
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
|
|
10
|
-
- tar -xjf phantomjs-2.0.0-ubuntu-12.04.tar.bz2
|
|
11
|
-
# Keep track of which version of phantomjs we're running the specs against
|
|
12
|
-
- phantomjs -v
|
|
5
|
+
script: bundle exec rake $RUN
|
|
13
6
|
|
|
14
7
|
matrix:
|
|
15
8
|
include:
|
|
16
|
-
- rvm: 2.
|
|
17
|
-
env:
|
|
18
|
-
- rvm: 2.
|
|
19
|
-
env:
|
|
9
|
+
- rvm: 2.4.2
|
|
10
|
+
env: OPAL_VERSION='master'
|
|
11
|
+
- rvm: 2.3.4
|
|
12
|
+
env: OPAL_VERSION='~> 0.10.5'
|
|
20
13
|
- rvm: 2.1.10
|
|
21
|
-
env:
|
|
14
|
+
env: RACK_VERSION='< 2.0'
|
|
22
15
|
- rvm: 2.0.0
|
|
23
|
-
env:
|
|
16
|
+
env: RACK_VERSION='< 2.0'
|
|
24
17
|
|
|
25
18
|
# We use 2.1.9 to differentiate the rvm version
|
|
26
19
|
# as travis doesn't allow failures by env.
|
|
@@ -28,5 +21,19 @@ matrix:
|
|
|
28
21
|
env: RUN=zepto PATH=".:$PATH" RACK_VERSION='< 2.0'
|
|
29
22
|
|
|
30
23
|
allow_failures:
|
|
31
|
-
- rvm: 2.1.9
|
|
24
|
+
- rvm: 2.1.9 # zepto
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
cache:
|
|
28
|
+
bundler: true
|
|
29
|
+
directories:
|
|
30
|
+
- node_modules
|
|
31
|
+
|
|
32
|
+
before_install:
|
|
33
|
+
- gem update --system
|
|
34
|
+
- "export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH"
|
|
35
|
+
- "if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
|
|
36
|
+
- "if [ $(phantomjs --version) != '2.1.1' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi"
|
|
37
|
+
- "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
|
|
38
|
+
- "phantomjs --version"
|
|
32
39
|
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,64 @@
|
|
|
1
|
-
## 0.4.
|
|
1
|
+
## [0.5.0](https://github.com/opal/opal-jquery/compare/v0.4.6...HEAD) Unreleased
|
|
2
|
+
|
|
3
|
+
*see diff*
|
|
4
|
+
|
|
5
|
+
## [0.4.6](https://github.com/opal/opal-jquery/compare/v0.4.5...v0.4.6) Unreleased
|
|
6
|
+
|
|
7
|
+
* Initialize @@__isReady (#115)
|
|
8
|
+
|
|
9
|
+
* Added `Element#select` (#111)
|
|
10
|
+
|
|
11
|
+
## [0.4.5](https://github.com/opal/opal-jquery/compare/v0.4.4...v0.4.5) 2021-07-28
|
|
12
|
+
|
|
13
|
+
* Expose `Element#replace_all` and `Element#replace_with` (#110)
|
|
14
|
+
|
|
15
|
+
* Open the opal dependency to any 1.x
|
|
16
|
+
|
|
17
|
+
## [0.4.4](https://github.com/opal/opal-jquery/compare/v0.4.3...v0.4.4) 2019-07-01
|
|
18
|
+
|
|
19
|
+
* Use `::Native::Wrapper` where available
|
|
20
|
+
|
|
21
|
+
* Allow Opal 1.0 in gemspec
|
|
22
|
+
|
|
23
|
+
## [0.4.3](https://github.com/opal/opal-jquery/compare/v0.4.2...v0.4.3) 2018-09-07
|
|
24
|
+
|
|
25
|
+
* Add `Element#==` as an alias of `.is()`
|
|
26
|
+
|
|
27
|
+
* Add `Element#method_missing` to allow not yet wrapped methods and plugins to be accessed with zero setup
|
|
28
|
+
|
|
29
|
+
* Avoid `||` in JS-land because it would consider some values as falsy (e.g. `""` and `0`). **breaking**
|
|
30
|
+
|
|
31
|
+
* Call `Element#prop` via `Native.call` to get the right semantics around `nil` vs. `undefined` **breaking**
|
|
32
|
+
|
|
33
|
+
* Expose `Element#click`
|
|
34
|
+
|
|
35
|
+
* Fix semantics of `Element#attr` to better reflect jQuery's **breaking**
|
|
36
|
+
|
|
37
|
+
* Skip sending a callback to `Element#animate` if no block is given
|
|
38
|
+
|
|
39
|
+
* Let `Element#data` return a usable Ruby object (`Array`/`Hash`) instead of a native one **breaking**
|
|
40
|
+
|
|
41
|
+
* Don't wrap events with `Event.new` if no args are provided or the event is not a native object to increase performance in `Element#on` and `Element#one`
|
|
42
|
+
|
|
43
|
+
* Rename the internal property holding the callback wrapper in `Element#on` and `Element#one` from `._jq_wrap` to `.$$jqwrap` to avoid polluting instance variables and following the custom of Opal's core classes
|
|
44
|
+
|
|
45
|
+
* Fix `Element#value`, `Element#height` and `Element#width` to perform the `||` at ruby level to avoid overwriting values that are *falsy* in JavaScript with `nil` **breaking**
|
|
46
|
+
|
|
47
|
+
* Add `Element#==` as an alias to jQuery's `.is()`
|
|
48
|
+
|
|
49
|
+
* Add `Element#method_missing` and `Element#respond_to_missing?` to forward calls to native plugins
|
|
50
|
+
|
|
51
|
+
* Add `HTTP#inspect` with a basic summary
|
|
52
|
+
|
|
53
|
+
* Updated specs to also use jQuery 3
|
|
54
|
+
|
|
55
|
+
* Allow Opal v0.11.0
|
|
56
|
+
|
|
57
|
+
## [0.4.2](https://github.com/opal/opal-jquery/compare/v0.4.1...v0.4.2) 2016-07-04
|
|
2
58
|
|
|
3
59
|
* Allow Opal v0.10.0
|
|
4
60
|
|
|
5
|
-
## 0.4.1 2015-11-02
|
|
61
|
+
## [0.4.1](https://github.com/opal/opal-jquery/compare/v0.4.0...v0.4.1) 2015-11-02
|
|
6
62
|
|
|
7
63
|
* Updated specs to use jQuery 1.8 (that was initially released in 2012)
|
|
8
64
|
|
|
@@ -12,7 +68,7 @@
|
|
|
12
68
|
|
|
13
69
|
* `Document.ready?` now works even after the document is loaded (unlike jQuery)
|
|
14
70
|
|
|
15
|
-
## 0.4.0 2015-07-17
|
|
71
|
+
## [0.4.0](https://github.com/opal/opal-jquery/compare/v0.3.0...v0.4.0) 2015-07-17
|
|
16
72
|
|
|
17
73
|
* `Element#[]=` now removes the attribute when the assigned value is nil.
|
|
18
74
|
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
case (opal_version = ENV['OPAL_VERSION'])
|
|
5
|
+
when 'master'
|
|
6
|
+
gem 'opal', github: 'opal/opal', branch: 'master'
|
|
7
|
+
gem 'opal-sprockets', github: 'opal/opal-sprockets'
|
|
8
|
+
gem 'opal-rspec', github: 'opal/opal-rspec', branch: 'master', submodules: true
|
|
9
|
+
when nil
|
|
10
|
+
gem 'opal' # let bundler pick a version
|
|
11
|
+
else
|
|
12
|
+
gem 'opal', opal_version
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# gem 'opal-rspec', github: 'opal/opal-rspec', submodules: true
|
|
16
|
+
# gem 'opal-rspec', path: '../opal-rspec'
|
|
6
17
|
gem 'rack', ENV['RACK_VERSION'] || '> 0'
|
data/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Opal jQuery
|
|
2
|
+
|
|
3
|
+
*jQuery wrapper for Opal*
|
|
2
4
|
|
|
3
5
|
[](http://travis-ci.org/opal/opal-jquery)
|
|
4
6
|
|
|
5
|
-
opal-jquery provides DOM access to opal by wrapping jQuery (or zepto)
|
|
7
|
+
**opal-jquery** provides DOM access to opal by wrapping jQuery (or zepto)
|
|
6
8
|
and providing a nice ruby syntax for dealing with jQuery instances.
|
|
7
9
|
|
|
8
|
-
See the Opal website for [documentation](http://opalrb.org/docs/jquery).
|
|
10
|
+
<!-- See the Opal website for [documentation](http://opalrb.org/docs/jquery). -->
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
|
data/Rakefile
CHANGED
|
@@ -2,13 +2,22 @@ require 'bundler'
|
|
|
2
2
|
Bundler.require
|
|
3
3
|
Bundler::GemHelper.install_tasks
|
|
4
4
|
|
|
5
|
+
ENV['RUNNER'] = 'chrome'
|
|
6
|
+
|
|
5
7
|
require 'opal/rspec/rake_task'
|
|
6
|
-
Opal::RSpec::RakeTask.new(:default) do |
|
|
7
|
-
|
|
8
|
+
Opal::RSpec::RakeTask.new(:default) do |server, task|
|
|
9
|
+
server.index_path = 'spec-opal/jquery/index.html.erb'
|
|
10
|
+
task.default_path = 'spec-opal'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Opal::RSpec::RakeTask.new(:jquery3) do |server, task|
|
|
14
|
+
server.index_path = 'spec-opal/jquery/index3.html.erb'
|
|
15
|
+
task.default_path = 'spec-opal'
|
|
8
16
|
end
|
|
9
17
|
|
|
10
|
-
Opal::RSpec::RakeTask.new(:zepto) do |
|
|
11
|
-
|
|
18
|
+
Opal::RSpec::RakeTask.new(:zepto) do |server, task|
|
|
19
|
+
server.index_path = 'spec-opal/zepto/index.html.erb'
|
|
20
|
+
task.default_path = 'spec-opal'
|
|
12
21
|
end
|
|
13
22
|
|
|
14
23
|
desc "Build build/opal-jquery.js"
|
|
@@ -64,6 +73,11 @@ namespace :doc do
|
|
|
64
73
|
sh 'git', 'clone', '-b', 'gh-pages', '--', remote, doc_repo.to_s
|
|
65
74
|
end
|
|
66
75
|
|
|
76
|
+
# To generate docs that live on http://opalrb.org/opal-jquery/ use the
|
|
77
|
+
# `rake doc` task
|
|
78
|
+
#
|
|
79
|
+
# DOC_REPO_REMOTE=https://github.com/opal/opal-jquery.git bundle exec rake doc
|
|
80
|
+
# open gh-pages/index.html
|
|
67
81
|
task :default => doc_repo.to_s do
|
|
68
82
|
git = current_git_release.call
|
|
69
83
|
name = 'api'
|
|
@@ -72,6 +86,10 @@ namespace :doc do
|
|
|
72
86
|
"--readme opal/README.md -o gh-pages/doc/#{git}/#{name}"
|
|
73
87
|
puts command; system command
|
|
74
88
|
end
|
|
89
|
+
|
|
90
|
+
# To generate api docs on rubygems: http://www.rubydoc.info/gems/opal-jquery/0.4.2
|
|
91
|
+
# yard --main README.md --markup markdown --github
|
|
92
|
+
# open doc/index.html
|
|
75
93
|
end
|
|
76
94
|
|
|
77
95
|
task :doc => 'doc:default'
|
data/config.ru
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
2
|
Bundler.require
|
|
3
3
|
|
|
4
|
-
require 'opal
|
|
5
|
-
Opal.append_path File.expand_path('../spec', __FILE__)
|
|
4
|
+
require 'opal/rspec'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
sprockets_env = Opal::RSpec::SprocketsEnvironment.new
|
|
7
|
+
run Opal::Server.new(sprockets: sprockets_env) { |s|
|
|
8
8
|
s.main = 'opal/rspec/sprockets_runner'
|
|
9
|
-
|
|
9
|
+
sprockets_env.add_spec_paths_to_sprockets
|
|
10
10
|
s.debug = false
|
|
11
|
-
s.index_path = 'spec/jquery/index.html.erb'
|
|
12
11
|
}
|
|
13
|
-
|
data/lib/opal/jquery/document.rb
CHANGED
data/lib/opal/jquery/element.rb
CHANGED
|
@@ -298,10 +298,12 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
298
298
|
# @!method get
|
|
299
299
|
alias_native :get
|
|
300
300
|
|
|
301
|
-
# @!method prop(name, value =
|
|
301
|
+
# @!method prop(name, value = undefined)
|
|
302
302
|
#
|
|
303
303
|
# Get or set the property `name` on each element in collection.
|
|
304
|
-
|
|
304
|
+
def prop(*args)
|
|
305
|
+
Native.call(self, :prop, *args)
|
|
306
|
+
end
|
|
305
307
|
|
|
306
308
|
alias succ next
|
|
307
309
|
alias << append
|
|
@@ -335,9 +337,21 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
335
337
|
# @!method remove_class(class_name)
|
|
336
338
|
alias_native :remove_class, :removeClass
|
|
337
339
|
|
|
340
|
+
# @!method replace_all(target)
|
|
341
|
+
alias_native :replace_all, :replaceAll
|
|
342
|
+
|
|
343
|
+
# @!method replace_with(new_content)
|
|
344
|
+
alias_native :replace_with, :replaceWith
|
|
345
|
+
|
|
346
|
+
# @!method select()
|
|
347
|
+
alias_native :select
|
|
348
|
+
|
|
338
349
|
# @!method submit()
|
|
339
350
|
alias_native :submit
|
|
340
351
|
|
|
352
|
+
# @!method click()
|
|
353
|
+
alias_native :click
|
|
354
|
+
|
|
341
355
|
# @!method text=(text)
|
|
342
356
|
#
|
|
343
357
|
# Set text content of each element in this collection.
|
|
@@ -416,10 +430,11 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
416
430
|
var size = args.length;
|
|
417
431
|
switch (size) {
|
|
418
432
|
case 1:
|
|
419
|
-
|
|
433
|
+
var result = self.attr(args[0]);
|
|
434
|
+
return( (result == null) ? nil : result );
|
|
420
435
|
break;
|
|
421
436
|
case 2:
|
|
422
|
-
return
|
|
437
|
+
return self.attr(args[0], args[1]);
|
|
423
438
|
break;
|
|
424
439
|
default:
|
|
425
440
|
#{raise ArgumentError, '#attr only accepts 1 or 2 arguments'}
|
|
@@ -508,16 +523,21 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
508
523
|
# is given, the block is run as a callback when the animation finishes.
|
|
509
524
|
def animate(params, &block)
|
|
510
525
|
speed = params.has_key?(:speed) ? params.delete(:speed) : 400
|
|
511
|
-
|
|
512
|
-
self.animate(#{params.to_n}, #{speed},
|
|
513
|
-
|
|
514
|
-
})
|
|
515
|
-
|
|
526
|
+
if block_given?
|
|
527
|
+
`self.animate(#{params.to_n}, #{speed}, block)`
|
|
528
|
+
else
|
|
529
|
+
`self.animate(#{params.to_n}, #{speed})`
|
|
530
|
+
end
|
|
516
531
|
end
|
|
517
532
|
|
|
518
533
|
def data(*args)
|
|
519
534
|
%x{
|
|
520
535
|
var result = self.data.apply(self, args);
|
|
536
|
+
if (
|
|
537
|
+
(typeof(result) === 'object') && !(result instanceof #{JQUERY_CLASS})
|
|
538
|
+
) {
|
|
539
|
+
result = #{ JSON.from_object `result` };
|
|
540
|
+
}
|
|
521
541
|
return result == null ? nil : result;
|
|
522
542
|
}
|
|
523
543
|
end
|
|
@@ -646,15 +666,22 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
646
666
|
|
|
647
667
|
def on(name, sel = nil, &block)
|
|
648
668
|
%x{
|
|
649
|
-
var
|
|
650
|
-
|
|
651
|
-
|
|
669
|
+
var has_args = #{block.arity} !== 0;
|
|
670
|
+
|
|
671
|
+
var wrapper = function() {
|
|
672
|
+
for(var args = new Array(arguments.length), i = 0, ii = args.length; i < ii; i++) {
|
|
673
|
+
args[i] = arguments[i];
|
|
652
674
|
}
|
|
653
675
|
|
|
654
|
-
|
|
676
|
+
// Use preventDefault as a canary for native events
|
|
677
|
+
if (has_args && args[0].preventDefault) {
|
|
678
|
+
args[0] = #{Event.new `args[0]`};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return block.apply(null, args);
|
|
655
682
|
};
|
|
656
683
|
|
|
657
|
-
block
|
|
684
|
+
block.$$jqwrap = wrapper;
|
|
658
685
|
|
|
659
686
|
if (sel == nil) {
|
|
660
687
|
self.on(name, wrapper);
|
|
@@ -669,15 +696,22 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
669
696
|
|
|
670
697
|
def one(name, sel = nil, &block)
|
|
671
698
|
%x{
|
|
672
|
-
var
|
|
673
|
-
|
|
674
|
-
|
|
699
|
+
var has_args = #{block.arity} !== 0;
|
|
700
|
+
|
|
701
|
+
var wrapper = function() {
|
|
702
|
+
for(var args = new Array(arguments.length), i = 0, ii = args.length; i < ii; i++) {
|
|
703
|
+
args[i] = arguments[i];
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// Use preventDefault as a canary for native events
|
|
707
|
+
if (has_args && args[0].preventDefault) {
|
|
708
|
+
args[0] = #{Event.new `args[0]`};
|
|
675
709
|
}
|
|
676
710
|
|
|
677
|
-
return block.apply(null,
|
|
711
|
+
return block.apply(null, args);
|
|
678
712
|
};
|
|
679
713
|
|
|
680
|
-
block
|
|
714
|
+
block.$$jqwrap = wrapper;
|
|
681
715
|
|
|
682
716
|
if (sel == nil) {
|
|
683
717
|
self.one(name, wrapper);
|
|
@@ -696,10 +730,10 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
696
730
|
return self.off(name);
|
|
697
731
|
}
|
|
698
732
|
else if (block === nil) {
|
|
699
|
-
return self.off(name, sel
|
|
733
|
+
return self.off(name, sel.$$jqwrap);
|
|
700
734
|
}
|
|
701
735
|
else {
|
|
702
|
-
return self.off(name, sel, block
|
|
736
|
+
return self.off(name, sel, block.$$jqwrap);
|
|
703
737
|
}
|
|
704
738
|
}
|
|
705
739
|
end
|
|
@@ -714,18 +748,46 @@ class Element < `#{JQUERY_CLASS.to_n}`
|
|
|
714
748
|
alias size length
|
|
715
749
|
|
|
716
750
|
def value
|
|
717
|
-
`self.val() || ""
|
|
751
|
+
`self.val()` || ""
|
|
718
752
|
end
|
|
719
753
|
|
|
720
754
|
def height
|
|
721
|
-
`self.height() || nil
|
|
755
|
+
`self.height()` || nil
|
|
722
756
|
end
|
|
723
757
|
|
|
724
758
|
def width
|
|
725
|
-
`self.width() || nil
|
|
759
|
+
`self.width()` || nil
|
|
726
760
|
end
|
|
727
761
|
|
|
728
762
|
def position
|
|
729
763
|
Native(`self.position()`)
|
|
730
764
|
end
|
|
765
|
+
|
|
766
|
+
def ==(other)
|
|
767
|
+
`self.is(other)`
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
def respond_to_missing?(name, _)
|
|
771
|
+
%x{
|
|
772
|
+
var method = self[#{name}];
|
|
773
|
+
if (typeof(method) === 'function') {
|
|
774
|
+
return true;
|
|
775
|
+
} else {
|
|
776
|
+
return #{super};
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
def method_missing(name, *args, &block)
|
|
782
|
+
args << block if block_given?
|
|
783
|
+
|
|
784
|
+
%x{
|
|
785
|
+
var method = self[#{name}];
|
|
786
|
+
if (typeof(method) === 'function') {
|
|
787
|
+
return method.apply(self, #{args.to_n});
|
|
788
|
+
} else {
|
|
789
|
+
return #{super};
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
end
|
|
731
793
|
end
|
data/lib/opal/jquery/http.rb
CHANGED
|
@@ -165,7 +165,7 @@ class HTTP
|
|
|
165
165
|
|
|
166
166
|
%x{
|
|
167
167
|
if (typeof(#{payload}) === 'string') {
|
|
168
|
-
|
|
168
|
+
settings.data = payload;
|
|
169
169
|
}
|
|
170
170
|
else if (payload != nil) {
|
|
171
171
|
settings.data = payload.$to_json();
|
|
@@ -231,6 +231,10 @@ class HTTP
|
|
|
231
231
|
}
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
+
def inspect
|
|
235
|
+
"#<HTTP @url=#{@url} @method=#{@method}>"
|
|
236
|
+
end
|
|
237
|
+
|
|
234
238
|
private
|
|
235
239
|
|
|
236
240
|
def promise
|
data/lib/opal/jquery/version.rb
CHANGED
data/lib/opal/jquery/window.rb
CHANGED
|
@@ -6,7 +6,8 @@ module Browser
|
|
|
6
6
|
# Generally, you will want to use the top level {::Window} instance, which
|
|
7
7
|
# wraps `window` from the main page.
|
|
8
8
|
class Window
|
|
9
|
-
|
|
9
|
+
# In more recent Opal versions Native::Wrapper should be used
|
|
10
|
+
include defined?(Native::Wrapper) ? Native::Wrapper : Native
|
|
10
11
|
|
|
11
12
|
# Returns this {Window} instance wrapped as an {Element}. Useful for
|
|
12
13
|
# delegating jQuery events, which allows the use of `window` as target.
|
data/opal-jquery.gemspec
CHANGED
|
@@ -4,19 +4,20 @@ require File.expand_path('../lib/opal/jquery/version', __FILE__)
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'opal-jquery'
|
|
6
6
|
s.version = Opal::JQuery::VERSION
|
|
7
|
-
s.
|
|
8
|
-
s.email = '
|
|
9
|
-
s.homepage = '
|
|
10
|
-
s.summary = 'Opal access to
|
|
11
|
-
s.description = 'Opal DOM library for
|
|
7
|
+
s.authors = ['Adam Beynon', 'Elia Schito']
|
|
8
|
+
s.email = 'elia@schito.me'
|
|
9
|
+
s.homepage = 'https://github.com/opal/opal-jquery#readme'
|
|
10
|
+
s.summary = 'Opal access to jQuery'
|
|
11
|
+
s.description = 'Opal DOM library for jQuery'
|
|
12
12
|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
|
14
14
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
16
|
s.require_paths = ['lib']
|
|
17
17
|
|
|
18
|
-
s.add_runtime_dependency 'opal', '>= 0.
|
|
19
|
-
s.add_development_dependency 'opal-rspec', '
|
|
18
|
+
s.add_runtime_dependency 'opal', ['>= 0.10.0', '< 2.0']
|
|
19
|
+
s.add_development_dependency 'opal-rspec', ['>= 0.7', '< 2.0']
|
|
20
|
+
s.add_development_dependency 'opal-sprockets', ['>= 0.4.1', '< 2.0']
|
|
20
21
|
s.add_development_dependency 'yard'
|
|
21
22
|
s.add_development_dependency 'rake'
|
|
22
23
|
end
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Document do
|
|
3
|
+
RSpec.describe 'Document' do
|
|
4
4
|
subject { Document }
|
|
5
5
|
|
|
6
6
|
describe "ready?" do
|
|
7
|
+
it "accepts a block" do
|
|
8
|
+
Document.ready? {
|
|
9
|
+
puts `$.fn.jquery`
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
it "accepts a block" do
|
|
8
14
|
Document.ready? { }
|
|
9
15
|
end
|
|
10
16
|
end
|
|
11
|
-
|
|
17
|
+
|
|
12
18
|
describe "ready" do
|
|
19
|
+
p self.ancestors
|
|
13
20
|
async "resolves when document is ready" do
|
|
14
|
-
Document.ready.then do
|
|
21
|
+
Document.ready.then do
|
|
15
22
|
async { Document.ready.resolved?.should be_truthy }
|
|
16
23
|
end
|
|
17
24
|
end
|
|
18
25
|
end
|
|
19
|
-
|
|
26
|
+
|
|
20
27
|
describe "title" do
|
|
21
28
|
it "gets the document title" do
|
|
22
29
|
Document.title.should be_kind_of(String)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe "Element animation methods" do
|
|
3
|
+
RSpec.describe "Element animation methods" do
|
|
4
4
|
html <<-HTML
|
|
5
5
|
<div id="animate-foo"></div>
|
|
6
6
|
HTML
|
|
@@ -41,16 +41,16 @@ describe "Element animation methods" do
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
describe "Element effects methods" do
|
|
44
|
+
RSpec.describe "Element effects methods" do
|
|
45
45
|
html <<-HTML
|
|
46
46
|
<div id="effects-foo"></div>
|
|
47
47
|
HTML
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
describe "#fadeout / #fadein" do
|
|
50
50
|
async "should fade the element out first" do
|
|
51
51
|
foo = Element.find "#effects-foo"
|
|
52
52
|
foo.effect(:fade_out)
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
delay 1 do
|
|
55
55
|
async {
|
|
56
56
|
foo.css("display").should eq("none")
|
|
@@ -64,4 +64,4 @@ describe "Element effects methods" do
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
|
-
end
|
|
67
|
+
end
|