jquery-rails-cdn 1.0.3 → 1.1.0
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 +4 -4
- data/README.md +17 -2
- data/lib/jquery-rails-cdn.rb +20 -8
- data/lib/jquery-rails-cdn/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74f2fc075f341160c003b22d6ac144273772eed7
|
4
|
+
data.tar.gz: e301f983738623f8847385d6dd8d3967960f31ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801acf82ee8c3ddee109a8f63da786c9d4dedee74e0371f4e4a32614a46bae4b4871564e95382ec55c2262e8f1425c4306a1ad5cd179f532020b3fd46d6bca92
|
7
|
+
data.tar.gz: 6816ed13a68305e82d94651b5635d7f8367eb24ade9878169dd1e639c9a4fcc11665d8d06018ef274c4c2aab8ea9c755a9a6305779f3ddc367c9a29f85cd84ca
|
data/README.md
CHANGED
@@ -27,6 +27,7 @@ On top of that, if you're using asset pipeline, you may have noticed that the ma
|
|
27
27
|
|
28
28
|
Changelog:
|
29
29
|
|
30
|
+
* v1.1.0: Support jQuery2. (Thanks to @timurkhafizov)
|
30
31
|
* v1.0.0: Options like `defer: true` or `data-turbolinks-eval: false` are allowed to be passed. (Thanks to @mkitt)
|
31
32
|
* v0.4.0: Added Cloudflare. (Thanks to @damonmorgan)
|
32
33
|
* v0.3.0: Microsoft and Yandex are now always scheme-less. (Thanks to @atipugin)
|
@@ -82,8 +83,22 @@ on development:
|
|
82
83
|
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
|
83
84
|
```
|
84
85
|
|
85
|
-
If you want to check the production URL, you can pass
|
86
|
+
If you want to check the production URL, you can pass `force: true` as an option.
|
86
87
|
|
87
88
|
```ruby
|
88
|
-
jquery_include_tag :google, :
|
89
|
+
jquery_include_tag :google, force: true
|
90
|
+
```
|
91
|
+
|
92
|
+
## jQuery 2
|
93
|
+
|
94
|
+
If you want to use jQuery 2, drop the following line in `config/initializers/jquery_cdn.rb`:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
Jquery::Rails::Cdn.major_version = 2
|
98
|
+
```
|
99
|
+
|
100
|
+
and then in `config/application.rb`:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
config.assets.precompile += ['jquery2.js']
|
89
104
|
```
|
data/lib/jquery-rails-cdn.rb
CHANGED
@@ -2,23 +2,35 @@ require 'jquery-rails'
|
|
2
2
|
require 'jquery-rails-cdn/version'
|
3
3
|
|
4
4
|
module Jquery::Rails::Cdn
|
5
|
+
mattr_accessor :major_version
|
6
|
+
|
5
7
|
module ActionViewExtensions
|
6
|
-
JQUERY_VERSION = Jquery::Rails::JQUERY_VERSION
|
7
8
|
OFFLINE = (Rails.env.development? or Rails.env.test?)
|
8
9
|
URL = {
|
9
|
-
:google
|
10
|
-
:microsoft
|
11
|
-
:jquery
|
12
|
-
:yandex
|
13
|
-
:cloudflare
|
10
|
+
:google => "//ajax.googleapis.com/ajax/libs/jquery/{JQUERY_VERSION}/jquery.min.js",
|
11
|
+
:microsoft => "//ajax.aspnetcdn.com/ajax/jQuery/jquery-{JQUERY_VERSION}.min.js",
|
12
|
+
:jquery => "//code.jquery.com/jquery-{JQUERY_VERSION}.min.js",
|
13
|
+
:yandex => "//yandex.st/jquery/{JQUERY_VERSION}/jquery.min.js",
|
14
|
+
:cloudflare => "//cdnjs.cloudflare.com/ajax/libs/jquery/{JQUERY_VERSION}/jquery.min.js"
|
14
15
|
}
|
15
16
|
|
16
17
|
def jquery_url(name)
|
17
|
-
|
18
|
+
@@jquery_urls ||= begin
|
19
|
+
version = case Jquery::Rails::Cdn.major_version
|
20
|
+
when 1, NilClass
|
21
|
+
Jquery::Rails::JQUERY_VERSION
|
22
|
+
when 2
|
23
|
+
Jquery::Rails::JQUERY_2_VERSION
|
24
|
+
else
|
25
|
+
raise 'invalid :major_version option'
|
26
|
+
end
|
27
|
+
Hash[URL.map{|k,v| [k, v.sub(/\{JQUERY_VERSION\}/, version)] }]
|
28
|
+
end
|
29
|
+
@@jquery_urls[name]
|
18
30
|
end
|
19
31
|
|
20
32
|
def jquery_include_tag(name, options = {})
|
21
|
-
return javascript_include_tag(:jquery, options) if !options.delete(:force)
|
33
|
+
return javascript_include_tag(:jquery, options) if OFFLINE && !options.delete(:force)
|
22
34
|
|
23
35
|
[ javascript_include_tag(jquery_url(name), options),
|
24
36
|
javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(:jquery, options).gsub('<','%3C')}'))")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-rails-cdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-rails
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.
|
61
|
+
rubygems_version: 2.4.8
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Add CDN support to jquery-rails
|