center_image_tag 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/center_image_tag.gemspec +0 -1
- data/lib/center_image_tag.rb +73 -2
- data/lib/center_image_tag/version.rb +1 -1
- data/spec/center_image_tag_spec.rb +141 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -18
- data/lib/center_image_tag/view_helper.rb +0 -77
- data/spec/view_helper_spec.rb +0 -143
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTRjNjFlZjBkMzE5YTcwZWIzMGIyOWY4ODAzZTVkMWFmZjA0MGEzNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTU5OTFlOThjOTkwYTgzZjQzZmVkZGVjZDZlNGEyZGNmOTg4NjcyZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzEwZGNhYjFkNDUzY2NkOWMxODYwZjdmNTFkNWEzOTBjM2ExMDkyYmRjYWFi
|
10
|
+
MWYxZGU4OTlmY2RlNmNlMzEyNzFhNDU4MWI5YzZkOGFjMDYzMTg3YWIxZjIz
|
11
|
+
YWYwMGM3NGI1YmU4YjVlOGVkN2E2NjA1ZjExZWIxNGVjZGYxZjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGU0MWRiYmRhYzI3NjRhNjI0YTk0MGE5ZGQyZjhlYjI3OTIzYzNiZWRhNjUz
|
14
|
+
NzBhMWEzMjFkOWE5YTU2NmE5MDg2ZjIxM2E4OTUzNDFiMTY3NmZiYTRkYTZj
|
15
|
+
MjgwMmNmYTliYTk4NTc2NzM4MmU2YTZkYmZhNTc1NzlmY2UyY2U=
|
data/center_image_tag.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'activesupport', '>= 3.0'
|
22
21
|
spec.add_dependency 'actionpack', '>= 3.0'
|
23
22
|
|
24
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/lib/center_image_tag.rb
CHANGED
@@ -1,6 +1,77 @@
|
|
1
|
+
require "action_view"
|
2
|
+
|
3
|
+
require "center_image_tag/version"
|
4
|
+
|
1
5
|
module CenterImageTag
|
6
|
+
include ActionView::Context
|
7
|
+
include ActionView::Helpers::TagHelper
|
8
|
+
include ActionView::Helpers::AssetTagHelper
|
9
|
+
|
10
|
+
def center_image_tag(source, options = {})
|
11
|
+
container_class = options.delete(:container_class)
|
12
|
+
if fluid_percentage = options.delete(:fluid)
|
13
|
+
return container_fluid fluid_percentage, container_class do
|
14
|
+
clip do
|
15
|
+
image_tag(source, options) +
|
16
|
+
tag(:span, class: "vertical-align")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
else
|
20
|
+
width, height = dimension(options)
|
21
|
+
if width && height
|
22
|
+
return container_fixed width, height, container_class do
|
23
|
+
clip do
|
24
|
+
image_tag(source, rebuild_options(options, width, height)) +
|
25
|
+
tag(:span, class: "vertical-align")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
image_tag(source, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def container_fluid(fluid_percentage, outer_class, &block)
|
36
|
+
div class: "cit-standard-thumb cit-thumb-fluid #{outer_class}" do
|
37
|
+
div class: "cit-thumb-default", style: "padding-bottom: #{fluid_percentage}", &block
|
38
|
+
end
|
39
|
+
end
|
2
40
|
|
41
|
+
def container_fixed(width, height, outer_class, &block)
|
42
|
+
div class: "cit-standard-thumb #{outer_class}", style: "width: #{width}px" do
|
43
|
+
div class: "cit-thumb-default", style: "padding-bottom: #{height}px", &block
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def clip(&block)
|
48
|
+
div class: "cit-thumb-clip" do
|
49
|
+
div class: "cit-thumb-clip-inner", &block
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def dimension(options)
|
54
|
+
if size = options[:size]
|
55
|
+
width, height = size.split("x") if size =~ %r{\A\d+x\d+\z}
|
56
|
+
width = height = size if size =~ %r{\A\d+\z}
|
57
|
+
else
|
58
|
+
width = options[:width]
|
59
|
+
height = options[:height]
|
60
|
+
end
|
61
|
+
|
62
|
+
[width, height]
|
63
|
+
end
|
64
|
+
|
65
|
+
def div(options = {}, &block)
|
66
|
+
content_tag :div, options, &block
|
67
|
+
end
|
68
|
+
|
69
|
+
def rebuild_options(options, width, height)
|
70
|
+
# rebuild options
|
71
|
+
options.delete(:size)
|
72
|
+
options.delete(:height)
|
73
|
+
options.merge(width: width)
|
74
|
+
end
|
3
75
|
end
|
4
76
|
|
5
|
-
|
6
|
-
require 'center_image_tag/view_helper'
|
77
|
+
ActionView::Base.send :include, CenterImageTag
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CenterImageTag
|
4
|
+
describe 'normal' do
|
5
|
+
it 'renders the image normally if it\'s not fluid or width x height set' do
|
6
|
+
output = View.new.center_image_tag 'image.png'
|
7
|
+
expected = "<img alt=\"Image\" src=\"/images/image.png\" />"
|
8
|
+
expect(output).to eq expected
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'ignores container_class options' do
|
12
|
+
output = View.new.center_image_tag 'image.png', container_class: 'custom-class'
|
13
|
+
expected = "<img alt=\"Image\" src=\"/images/image.png\" />"
|
14
|
+
expect(output).to eq expected
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'fluid' do
|
19
|
+
it 'renders the fluid image correctly' do
|
20
|
+
output = View.new.center_image_tag 'image.png', fluid: "56.25%"
|
21
|
+
expected = "<div class=\"cit-standard-thumb cit-thumb-fluid \">" +
|
22
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 56.25%\">" +
|
23
|
+
"<div class=\"cit-thumb-clip\">" +
|
24
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
25
|
+
"<img alt=\"Image\" src=\"/images/image.png\" />" +
|
26
|
+
"<span class=\"vertical-align\" />" +
|
27
|
+
"</div>" +
|
28
|
+
"</div>" +
|
29
|
+
"</div>" +
|
30
|
+
"</div>"
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'renders the fluid image with container class' do
|
34
|
+
output = View.new.center_image_tag 'image.png', fluid: "56.25%", container_class: 'custom-class'
|
35
|
+
expected = "<div class=\"cit-standard-thumb cit-thumb-fluid custom-class\">" +
|
36
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 56.25%\">" +
|
37
|
+
"<div class=\"cit-thumb-clip\">" +
|
38
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
39
|
+
"<img alt=\"Image\" src=\"/images/image.png\" />" +
|
40
|
+
"<span class=\"vertical-align\" />" +
|
41
|
+
"</div>" +
|
42
|
+
"</div>" +
|
43
|
+
"</div>" +
|
44
|
+
"</div>"
|
45
|
+
expect(output).to eq expected
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'fixed' do
|
50
|
+
it 'renders the fixed image correctly from size options (size = widthxheight)' do
|
51
|
+
output = View.new.center_image_tag 'image.png', size: "200x100"
|
52
|
+
expected = "<div class=\"cit-standard-thumb \" style=\"width: 200px\">" +
|
53
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
54
|
+
"<div class=\"cit-thumb-clip\">" +
|
55
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
56
|
+
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
57
|
+
"<span class=\"vertical-align\" />" +
|
58
|
+
"</div>" +
|
59
|
+
"</div>" +
|
60
|
+
"</div>" +
|
61
|
+
"</div>"
|
62
|
+
expect(output).to eq expected
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'renders the fixed image correctly from size options (size = widthxheight) with container class' do
|
66
|
+
output = View.new.center_image_tag 'image.png', size: "200x100", container_class: 'custom-class'
|
67
|
+
expected = "<div class=\"cit-standard-thumb custom-class\" style=\"width: 200px\">" +
|
68
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
69
|
+
"<div class=\"cit-thumb-clip\">" +
|
70
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
71
|
+
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
72
|
+
"<span class=\"vertical-align\" />" +
|
73
|
+
"</div>" +
|
74
|
+
"</div>" +
|
75
|
+
"</div>" +
|
76
|
+
"</div>"
|
77
|
+
expect(output).to eq expected
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'renders the fixed image correctly from size options (single size value)' do
|
81
|
+
output = View.new.center_image_tag 'image.png', size: "200"
|
82
|
+
expected = "<div class=\"cit-standard-thumb \" style=\"width: 200px\">" +
|
83
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 200px\">" +
|
84
|
+
"<div class=\"cit-thumb-clip\">" +
|
85
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
86
|
+
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
87
|
+
"<span class=\"vertical-align\" />" +
|
88
|
+
"</div>" +
|
89
|
+
"</div>" +
|
90
|
+
"</div>" +
|
91
|
+
"</div>"
|
92
|
+
expect(output).to eq expected
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'renders the fixed image correctly from size options (single size value) with container class' do
|
96
|
+
output = View.new.center_image_tag 'image.png', size: "200", container_class: 'custom-class'
|
97
|
+
expected = "<div class=\"cit-standard-thumb custom-class\" style=\"width: 200px\">" +
|
98
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 200px\">" +
|
99
|
+
"<div class=\"cit-thumb-clip\">" +
|
100
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
101
|
+
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
102
|
+
"<span class=\"vertical-align\" />" +
|
103
|
+
"</div>" +
|
104
|
+
"</div>" +
|
105
|
+
"</div>" +
|
106
|
+
"</div>"
|
107
|
+
expect(output).to eq expected
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
it 'renders the fixed image correctly from width and height options' do
|
112
|
+
output = View.new.center_image_tag 'image.png', width: "200", height: 100
|
113
|
+
expected = "<div class=\"cit-standard-thumb \" style=\"width: 200px\">" +
|
114
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
115
|
+
"<div class=\"cit-thumb-clip\">" +
|
116
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
117
|
+
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
118
|
+
"<span class=\"vertical-align\" />" +
|
119
|
+
"</div>" +
|
120
|
+
"</div>" +
|
121
|
+
"</div>" +
|
122
|
+
"</div>"
|
123
|
+
expect(output).to eq expected
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'renders the fixed image correctly from width and height options with container class' do
|
127
|
+
output = View.new.center_image_tag 'image.png', width: "200", height: 100, container_class: 'custom-class'
|
128
|
+
expected = "<div class=\"cit-standard-thumb custom-class\" style=\"width: 200px\">" +
|
129
|
+
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
130
|
+
"<div class=\"cit-thumb-clip\">" +
|
131
|
+
"<div class=\"cit-thumb-clip-inner\">" +
|
132
|
+
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
133
|
+
"<span class=\"vertical-align\" />" +
|
134
|
+
"</div>" +
|
135
|
+
"</div>" +
|
136
|
+
"</div>" +
|
137
|
+
"</div>"
|
138
|
+
expect(output).to eq expected
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: center_image_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anh Nguyen
|
@@ -10,20 +10,6 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2013-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: actionpack
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,9 +109,8 @@ files:
|
|
123
109
|
- center_image_tag.gemspec
|
124
110
|
- lib/center_image_tag.rb
|
125
111
|
- lib/center_image_tag/version.rb
|
126
|
-
-
|
112
|
+
- spec/center_image_tag_spec.rb
|
127
113
|
- spec/spec_helper.rb
|
128
|
-
- spec/view_helper_spec.rb
|
129
114
|
- vendor/assets/stylesheets/center_image_tag.scss
|
130
115
|
homepage: ''
|
131
116
|
licenses:
|
@@ -152,5 +137,5 @@ signing_key:
|
|
152
137
|
specification_version: 4
|
153
138
|
summary: Center your images without js.
|
154
139
|
test_files:
|
140
|
+
- spec/center_image_tag_spec.rb
|
155
141
|
- spec/spec_helper.rb
|
156
|
-
- spec/view_helper_spec.rb
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require "action_view"
|
2
|
-
|
3
|
-
module CenterImageTag
|
4
|
-
module ViewHelper
|
5
|
-
include ActionView::Context
|
6
|
-
include ActionView::Helpers::TagHelper
|
7
|
-
include ActionView::Helpers::AssetTagHelper
|
8
|
-
|
9
|
-
def center_image_tag(source, options = {})
|
10
|
-
container_class = options.delete(:container_class)
|
11
|
-
if fluid_percentage = options.delete(:fluid)
|
12
|
-
return container_fluid fluid_percentage, container_class do
|
13
|
-
clip do
|
14
|
-
image_tag(source, options) +
|
15
|
-
tag(:span, class: "vertical-align")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
else
|
19
|
-
width, height = dimension(options)
|
20
|
-
if width && height
|
21
|
-
return container_fixed width, height, container_class do
|
22
|
-
clip do
|
23
|
-
image_tag(source, rebuild_options(options, width, height)) +
|
24
|
-
tag(:span, class: "vertical-align")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
image_tag(source, options)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
def container_fluid(fluid_percentage, outer_class, &block)
|
35
|
-
div class: "cit-standard-thumb cit-thumb-fluid #{outer_class}" do
|
36
|
-
div class: "cit-thumb-default", style: "padding-bottom: #{fluid_percentage}", &block
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def container_fixed(width, height, outer_class, &block)
|
41
|
-
div class: "cit-standard-thumb #{outer_class}", style: "width: #{width}px" do
|
42
|
-
div class: "cit-thumb-default", style: "padding-bottom: #{height}px", &block
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def clip(&block)
|
47
|
-
div class: "cit-thumb-clip" do
|
48
|
-
div class: "cit-thumb-clip-inner", &block
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def dimension(options)
|
53
|
-
if size = options[:size]
|
54
|
-
width, height = size.split("x") if size =~ %r{\A\d+x\d+\z}
|
55
|
-
width = height = size if size =~ %r{\A\d+\z}
|
56
|
-
else
|
57
|
-
width = options[:width]
|
58
|
-
height = options[:height]
|
59
|
-
end
|
60
|
-
|
61
|
-
[width, height]
|
62
|
-
end
|
63
|
-
|
64
|
-
def div(options = {}, &block)
|
65
|
-
content_tag :div, options, &block
|
66
|
-
end
|
67
|
-
|
68
|
-
def rebuild_options(options, width, height)
|
69
|
-
# rebuild options
|
70
|
-
options.delete(:size)
|
71
|
-
options.delete(:height)
|
72
|
-
options.merge(width: width)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
ActionView::Base.send :include, CenterImageTag::ViewHelper
|
data/spec/view_helper_spec.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CenterImageTag
|
4
|
-
describe ViewHelper do
|
5
|
-
describe 'normal' do
|
6
|
-
it 'renders the image normally if it\'s not fluid or width x height set' do
|
7
|
-
output = View.new.center_image_tag 'image.png'
|
8
|
-
expected = "<img alt=\"Image\" src=\"/images/image.png\" />"
|
9
|
-
expect(output).to eq expected
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'ignores container_class options' do
|
13
|
-
output = View.new.center_image_tag 'image.png', container_class: 'custom-class'
|
14
|
-
expected = "<img alt=\"Image\" src=\"/images/image.png\" />"
|
15
|
-
expect(output).to eq expected
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'fluid' do
|
20
|
-
it 'renders the fluid image correctly' do
|
21
|
-
output = View.new.center_image_tag 'image.png', fluid: "56.25%"
|
22
|
-
expected = "<div class=\"cit-standard-thumb cit-thumb-fluid \">" +
|
23
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 56.25%\">" +
|
24
|
-
"<div class=\"cit-thumb-clip\">" +
|
25
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
26
|
-
"<img alt=\"Image\" src=\"/images/image.png\" />" +
|
27
|
-
"<span class=\"vertical-align\" />" +
|
28
|
-
"</div>" +
|
29
|
-
"</div>" +
|
30
|
-
"</div>" +
|
31
|
-
"</div>"
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'renders the fluid image with container class' do
|
35
|
-
output = View.new.center_image_tag 'image.png', fluid: "56.25%", container_class: 'custom-class'
|
36
|
-
expected = "<div class=\"cit-standard-thumb cit-thumb-fluid custom-class\">" +
|
37
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 56.25%\">" +
|
38
|
-
"<div class=\"cit-thumb-clip\">" +
|
39
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
40
|
-
"<img alt=\"Image\" src=\"/images/image.png\" />" +
|
41
|
-
"<span class=\"vertical-align\" />" +
|
42
|
-
"</div>" +
|
43
|
-
"</div>" +
|
44
|
-
"</div>" +
|
45
|
-
"</div>"
|
46
|
-
expect(output).to eq expected
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'fixed' do
|
51
|
-
it 'renders the fixed image correctly from size options (size = widthxheight)' do
|
52
|
-
output = View.new.center_image_tag 'image.png', size: "200x100"
|
53
|
-
expected = "<div class=\"cit-standard-thumb \" style=\"width: 200px\">" +
|
54
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
55
|
-
"<div class=\"cit-thumb-clip\">" +
|
56
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
57
|
-
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
58
|
-
"<span class=\"vertical-align\" />" +
|
59
|
-
"</div>" +
|
60
|
-
"</div>" +
|
61
|
-
"</div>" +
|
62
|
-
"</div>"
|
63
|
-
expect(output).to eq expected
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'renders the fixed image correctly from size options (size = widthxheight) with container class' do
|
67
|
-
output = View.new.center_image_tag 'image.png', size: "200x100", container_class: 'custom-class'
|
68
|
-
expected = "<div class=\"cit-standard-thumb custom-class\" style=\"width: 200px\">" +
|
69
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
70
|
-
"<div class=\"cit-thumb-clip\">" +
|
71
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
72
|
-
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
73
|
-
"<span class=\"vertical-align\" />" +
|
74
|
-
"</div>" +
|
75
|
-
"</div>" +
|
76
|
-
"</div>" +
|
77
|
-
"</div>"
|
78
|
-
expect(output).to eq expected
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'renders the fixed image correctly from size options (single size value)' do
|
82
|
-
output = View.new.center_image_tag 'image.png', size: "200"
|
83
|
-
expected = "<div class=\"cit-standard-thumb \" style=\"width: 200px\">" +
|
84
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 200px\">" +
|
85
|
-
"<div class=\"cit-thumb-clip\">" +
|
86
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
87
|
-
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
88
|
-
"<span class=\"vertical-align\" />" +
|
89
|
-
"</div>" +
|
90
|
-
"</div>" +
|
91
|
-
"</div>" +
|
92
|
-
"</div>"
|
93
|
-
expect(output).to eq expected
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'renders the fixed image correctly from size options (single size value) with container class' do
|
97
|
-
output = View.new.center_image_tag 'image.png', size: "200", container_class: 'custom-class'
|
98
|
-
expected = "<div class=\"cit-standard-thumb custom-class\" style=\"width: 200px\">" +
|
99
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 200px\">" +
|
100
|
-
"<div class=\"cit-thumb-clip\">" +
|
101
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
102
|
-
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
103
|
-
"<span class=\"vertical-align\" />" +
|
104
|
-
"</div>" +
|
105
|
-
"</div>" +
|
106
|
-
"</div>" +
|
107
|
-
"</div>"
|
108
|
-
expect(output).to eq expected
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
it 'renders the fixed image correctly from width and height options' do
|
113
|
-
output = View.new.center_image_tag 'image.png', width: "200", height: 100
|
114
|
-
expected = "<div class=\"cit-standard-thumb \" style=\"width: 200px\">" +
|
115
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
116
|
-
"<div class=\"cit-thumb-clip\">" +
|
117
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
118
|
-
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
119
|
-
"<span class=\"vertical-align\" />" +
|
120
|
-
"</div>" +
|
121
|
-
"</div>" +
|
122
|
-
"</div>" +
|
123
|
-
"</div>"
|
124
|
-
expect(output).to eq expected
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'renders the fixed image correctly from width and height options with container class' do
|
128
|
-
output = View.new.center_image_tag 'image.png', width: "200", height: 100, container_class: 'custom-class'
|
129
|
-
expected = "<div class=\"cit-standard-thumb custom-class\" style=\"width: 200px\">" +
|
130
|
-
"<div class=\"cit-thumb-default\" style=\"padding-bottom: 100px\">" +
|
131
|
-
"<div class=\"cit-thumb-clip\">" +
|
132
|
-
"<div class=\"cit-thumb-clip-inner\">" +
|
133
|
-
"<img alt=\"Image\" src=\"/images/image.png\" width=\"200\" />" +
|
134
|
-
"<span class=\"vertical-align\" />" +
|
135
|
-
"</div>" +
|
136
|
-
"</div>" +
|
137
|
-
"</div>" +
|
138
|
-
"</div>"
|
139
|
-
expect(output).to eq expected
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|