lazyload-rails 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +27 -21
- data/lib/lazyload-rails.rb +1 -3
- data/lib/lazyload-rails/{configuration.rb → config.rb} +1 -1
- data/lib/lazyload-rails/version.rb +1 -1
- metadata +37 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9bea9d89fb6ecb8a0218753ab51a6a6aa39e31a613b9c943c8562957c3fbb28a
|
4
|
+
data.tar.gz: 7cda2a364ee6b450965eacba99085a670b4e0f0f09d51e6c7003657903c65e18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da29205ffe57d1de0eabc3ebf82cadff46484306fea78046ee6089912bd13dc1b17de9c37399d44c54049476c7e51596652e9da037bec2e8a8271dedf10f1e13
|
7
|
+
data.tar.gz: 75ad188919cb37d8297d0b898687f4332177a152600183839cd6d928dc41a85baaeee2bc58222f5d884fddcf8f5008c4618fd98f6a27087512f005f8bd493452
|
data/README.md
CHANGED
@@ -17,48 +17,54 @@ See [example](http://backbonejs.org/#examples) (scroll down to see images load)
|
|
17
17
|
|
18
18
|
### Features
|
19
19
|
|
20
|
-
* Add `lazy: true` option to Rails `image_tag` helpers to render lazyload-friendly
|
21
|
-
|
22
|
-
* Simple, really. That's pretty much it.
|
20
|
+
* Add `lazy: true` option to Rails `image_tag` helpers to render lazyload-friendly img tags.
|
21
|
+
* Simple (really). That's pretty much it.
|
23
22
|
|
24
23
|
### Example
|
25
24
|
|
26
|
-
|
25
|
+
```erb
|
26
|
+
<%= image_tag "kittenz.png", alt: "OMG a cat!", lazy: true %>
|
27
|
+
```
|
27
28
|
|
28
29
|
Equals:
|
29
30
|
|
30
|
-
|
31
|
+
```html
|
32
|
+
<img alt="OMG a cat!" data-original="/images/kittenz.png" src="http://www.appelsiini.net/projects/lazyload/img/grey.gif">
|
33
|
+
```
|
34
|
+
|
35
|
+
**PRO TIP!** You must set image dimensions either as width and height attributes or in CSS. Otherwise plugin might not work properly.
|
31
36
|
|
32
37
|
## Install
|
33
38
|
|
34
|
-
Add this line to your application's Gemfile:
|
39
|
+
1. Add this line to your application's Gemfile:
|
40
|
+
|
41
|
+
gem "lazyload-rails"
|
42
|
+
|
43
|
+
2. Download the [jQuery Lazy Load Plugin](https://raw.github.com/tuupola/jquery_lazyload/master/jquery.lazyload.js)
|
44
|
+
into your `vendor/assets/javascripts` directory.
|
35
45
|
|
36
|
-
|
46
|
+
3. Include it however you prefer. For example, in your application.js you could add:
|
37
47
|
|
38
|
-
|
39
|
-
into your `vendor/assets/javascripts` directory and include it however you prefer.
|
48
|
+
//= require jquery.lazyload
|
40
49
|
|
41
|
-
|
50
|
+
4. In your JavaScript code do:
|
42
51
|
|
43
|
-
|
52
|
+
$("img").lazyload();
|
44
53
|
|
45
54
|
Lazy Load can be customized, [see more options](http://www.appelsiini.net/projects/lazyload)
|
46
55
|
|
47
|
-
*
|
56
|
+
*__Important__: Remember that the Lazy Load Plugin depends on jQuery.*
|
48
57
|
|
49
58
|
## Configuration
|
50
59
|
|
51
60
|
By default, a 1x1 grey gif is used as placeholder (from [http://appelsiini.net/projects/lazyload/img/grey.gif](http://www.appelsiini.net/projects/lazyload/img/grey.gif)). This can be easily customized:
|
52
61
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
* *Q: How can I use the old `image_tag` method?*
|
61
|
-
* R: Try with `x_image_tag`
|
62
|
+
```ruby
|
63
|
+
# config/initializers/lazyload.rb
|
64
|
+
Lazyload::Rails.configure do |config|
|
65
|
+
config.placeholder = "/public/img/grey.gif"
|
66
|
+
end
|
67
|
+
```
|
62
68
|
|
63
69
|
## License
|
64
70
|
|
data/lib/lazyload-rails.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require "nokogiri"
|
2
2
|
require "action_view"
|
3
|
-
|
4
3
|
require "lazyload-rails/version"
|
5
|
-
require "lazyload-rails/
|
4
|
+
require "lazyload-rails/config"
|
6
5
|
|
7
6
|
module Lazyload
|
8
7
|
module Rails
|
@@ -68,5 +67,4 @@ ActionView::Helpers::AssetTagHelper.module_eval do
|
|
68
67
|
|
69
68
|
[options, args]
|
70
69
|
end
|
71
|
-
|
72
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazyload-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Javier Saldana
|
7
|
+
- Javier Trevino Saldana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,23 +24,51 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: actionpack
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - ">="
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3
|
61
|
+
version: '3'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3
|
41
|
-
description: lazyload-rails
|
68
|
+
version: '3'
|
69
|
+
description: lazyload-rails integrates jQuery's Lazy Load Plugin with Rails image_tag
|
42
70
|
helpers
|
43
|
-
email:
|
71
|
+
email: jts@dynamic.tech
|
44
72
|
executables: []
|
45
73
|
extensions: []
|
46
74
|
extra_rdoc_files: []
|
@@ -48,7 +76,7 @@ files:
|
|
48
76
|
- MIT-LICENSE
|
49
77
|
- README.md
|
50
78
|
- lib/lazyload-rails.rb
|
51
|
-
- lib/lazyload-rails/
|
79
|
+
- lib/lazyload-rails/config.rb
|
52
80
|
- lib/lazyload-rails/version.rb
|
53
81
|
homepage: https://github.com/jassa/lazyload-rails
|
54
82
|
licenses:
|
@@ -69,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
97
|
- !ruby/object:Gem::Version
|
70
98
|
version: '0'
|
71
99
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.2.2
|
100
|
+
rubygems_version: 3.0.1
|
74
101
|
signing_key:
|
75
102
|
specification_version: 4
|
76
103
|
summary: jQuery Lazy Load for Rails image_tag helpers
|