holder_rails 2.3.2 → 2.9.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +12 -9
- data/holder_rails.gemspec +2 -2
- data/lib/holder_rails/helpers.rb +8 -4
- data/lib/holder_rails/version.rb +1 -1
- data/test/holder_rails_test.rb +13 -8
- data/vendor/assets/javascripts/holder.js +4795 -607
- data/vendor/assets/javascripts/holder.min.js +13 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1647e82904f852a88dd02b8b37054e7126413bffb0a399d14d39695f8ff850cc
|
4
|
+
data.tar.gz: 7b7fef0ae9ead9b12a94045e3f9e2275fa771871c85507efc9ced740a4978fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ce5d45ef4f2886b5b67d1698491e854d53b9e619ca7c461dc7a699396f1d83572f6bf93a7a458055002f2ae79010b608e32a767d0ec5cece8ea5d391731706
|
7
|
+
data.tar.gz: c72be02418a324043ebeb739d46a3bcfc196c7fb2353834f50272aefe22ec663dc7db88622f0f516f9cd72c5a8786f8d04cfed1fb9f6b8adc485b629c84ea5d0
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Holder.js for Rails
|
2
2
|
|
3
|
-
[![Build Status](https://
|
4
|
-
[![Gem Version](https://
|
3
|
+
[![Build Status](https://img.shields.io/travis/NARKOZ/holder_rails.svg)](https://travis-ci.org/NARKOZ/holder_rails)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/holder_rails.svg)](https://rubygems.org/gems/holder_rails)
|
5
5
|
|
6
6
|
Provides Holder.js to render image placeholders entirely on the client side.
|
7
7
|
|
@@ -27,7 +27,7 @@ Add to your JavaScript manifest file:
|
|
27
27
|
//= require holder
|
28
28
|
```
|
29
29
|
|
30
|
-
|
30
|
+
For versions **less than 2.3.2**, if you're using [turbolinks](https://github.com/rails/turbolinks)
|
31
31
|
don't forget to run `Holder` after `page:change` event:
|
32
32
|
|
33
33
|
```coffee
|
@@ -39,19 +39,22 @@ You can use `holder_tag` helper in your views:
|
|
39
39
|
|
40
40
|
```ruby
|
41
41
|
holder_tag 100
|
42
|
-
# => <img data-src="holder.js/100x100
|
42
|
+
# => <img data-src="holder.js/100x100?" src="" />
|
43
43
|
|
44
44
|
holder_tag '200x300'
|
45
|
-
# => <img data-src="holder.js/200x300
|
45
|
+
# => <img data-src="holder.js/200x300?" src="" />
|
46
46
|
|
47
47
|
holder_tag '200x300', 'Lorem ipsum'
|
48
|
-
# => <img data-src="holder.js/200x300
|
48
|
+
# => <img data-src="holder.js/200x300?text=Lorem ipsum" src="" />
|
49
49
|
|
50
50
|
holder_tag '200x300', 'Lorem ipsum', 'social'
|
51
|
-
# => <img data-src="holder.js/200x300
|
51
|
+
# => <img data-src="holder.js/200x300?text=Lorem ipsum&theme=social" src="" />
|
52
52
|
|
53
|
-
holder_tag '500x800', 'Example text', 'gray', :
|
54
|
-
# => <img class="special" data-src="holder.js/500x800
|
53
|
+
holder_tag '500x800', 'Example text', 'gray', id: 'new', class: 'special'
|
54
|
+
# => <img class="special" data-src="holder.js/500x800?text=Example text&theme=gray" id="new" src="" />
|
55
|
+
|
56
|
+
holder_tag '500x800', 'Example text', 'gray', { id: 'new', class: 'special' }, { font: 'Helvetica' }
|
57
|
+
# => <img class="special" data-src="holder.js/500x800?font=Helvetica&text=Example text&theme=gray" id="new" src="" />
|
55
58
|
```
|
56
59
|
|
57
60
|
For more information, check out [holder readme](https://github.com/imsky/holder#readme).
|
data/holder_rails.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = "holder_rails"
|
8
8
|
gem.version = HolderRails::VERSION
|
9
9
|
gem.authors = ["Nihad Abbasov"]
|
10
|
-
gem.email = ["
|
10
|
+
gem.email = ["nihad@42na.in"]
|
11
11
|
gem.description = %q{Provides Holder.js to render image placeholders entirely on the client side}
|
12
|
-
gem.summary = %q{Holder.js for Rails
|
12
|
+
gem.summary = %q{Holder.js for Rails asset pipeline}
|
13
13
|
gem.homepage = "https://github.com/narkoz/holder_rails"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
data/lib/holder_rails/helpers.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module HolderRails
|
2
2
|
module Helpers
|
3
|
-
def holder_tag(size, text='', theme=nil, html_options={})
|
4
|
-
size = "#{size}x#{size}" unless size =~ /\A\d
|
5
|
-
|
6
|
-
|
3
|
+
def holder_tag(size, text='', theme=nil, html_options={}, holder_options={})
|
4
|
+
size = "#{size}x#{size}" unless size =~ /\A\d+p?x\d+\z/
|
5
|
+
|
6
|
+
holder_options[:text] = text unless text.to_s.empty?
|
7
|
+
holder_options[:theme] = theme unless theme.nil?
|
8
|
+
holder_options = holder_options.map {|e| e.join('=') }.join('&')
|
9
|
+
|
10
|
+
options = { src: '', data: { src: "holder.js/#{size}?#{holder_options}" }}
|
7
11
|
options = options.merge(html_options)
|
8
12
|
|
9
13
|
tag :img, options
|
data/lib/holder_rails/version.rb
CHANGED
data/test/holder_rails_test.rb
CHANGED
@@ -1,25 +1,30 @@
|
|
1
1
|
require 'holder_rails'
|
2
|
-
require '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
|
4
4
|
class HolderRailsTest < ActionView::TestCase
|
5
5
|
include HolderRails::Helpers
|
6
6
|
|
7
7
|
test "size" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
assert_dom_equal '<img data-src="holder.js/100x100?" src="" />', holder_tag(100)
|
9
|
+
assert_dom_equal '<img data-src="holder.js/200x300?" src="" />', holder_tag('200x300')
|
10
|
+
assert_dom_equal '<img data-src="holder.js/100px75?" src="" />', holder_tag('100px75')
|
11
11
|
end
|
12
12
|
|
13
13
|
test "text" do
|
14
|
-
|
14
|
+
assert_dom_equal '<img data-src="holder.js/200x300?text=Lorem ipsum" src="" />', holder_tag('200x300', 'Lorem ipsum')
|
15
15
|
end
|
16
16
|
|
17
17
|
test "theme" do
|
18
|
-
|
18
|
+
assert_dom_equal '<img data-src="holder.js/200x300?text=Lorem ipsum&theme=social" src="" />', holder_tag('200x300', 'Lorem ipsum', 'social')
|
19
19
|
end
|
20
20
|
|
21
21
|
test "html_options" do
|
22
|
-
|
23
|
-
holder_tag('500x800', 'Example text', 'gray', :
|
22
|
+
assert_dom_equal '<img class="special" data-src="holder.js/500x800?text=Example text&theme=gray" id="new" src="" />',
|
23
|
+
holder_tag('500x800', 'Example text', 'gray', id: 'new', class: 'special')
|
24
|
+
end
|
25
|
+
|
26
|
+
test "holder_options" do
|
27
|
+
assert_dom_equal '<img class="special" data-src="holder.js/500x800?font=Helvetica&text=Example text&theme=gray" id="new" src="" />',
|
28
|
+
holder_tag('500x800', 'Example text', 'gray', { id: 'new', class: 'special' }, { font: 'Helvetica' })
|
24
29
|
end
|
25
30
|
end
|