responsive_image_tag 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
@@ -1 +1,19 @@
|
|
1
|
-
|
1
|
+
function replaceImages(){
|
2
|
+
|
3
|
+
var responsiveImages = $$(".responsivize");
|
4
|
+
var i,
|
5
|
+
noOfresponsiveImages = responsiveImages.length;
|
6
|
+
|
7
|
+
for(i = 0; i < noOfresponsiveImages; i = i + 1 ){
|
8
|
+
var newImg = window.document.createElement("img");
|
9
|
+
newImg.src = responsiveImages[i].getAttribute("data-fullsrc");
|
10
|
+
var imgNo = i+1;
|
11
|
+
responsiveImages[i].previous().appendChild(newImg);
|
12
|
+
responsiveImages[i].style.display = "none";
|
13
|
+
}
|
14
|
+
|
15
|
+
}
|
16
|
+
|
17
|
+
document.observe("dom:loaded", function() {
|
18
|
+
replaceImages()
|
19
|
+
})
|
data/lib/responsive_image_tag.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
module ResponsiveImageTag
|
2
2
|
|
3
|
+
# Emits the special (and somewhat ugly) markup for our responsive image
|
4
|
+
# tag.
|
5
|
+
#
|
6
|
+
# NB: the @image_path@ method is a private method of the Rails
|
7
|
+
# asset_tag_helper.
|
8
|
+
#
|
3
9
|
def responsive_image_tag(small, big, options = {})
|
4
|
-
|
5
|
-
|
6
|
-
|
10
|
+
options["full-src"] = image_path(big)
|
11
|
+
output = tag "span", {:class => "img-placeholder"}
|
12
|
+
output += tag "noscript", nil, true
|
13
|
+
output += image_tag(small, options)
|
14
|
+
output += tag "/noscript", nil, true
|
15
|
+
output
|
7
16
|
end
|
8
17
|
|
9
18
|
end
|
10
19
|
|
11
|
-
ActionView::Base.send(:include, ResponsiveImageTag) if defined?(ActionView::Base)
|
20
|
+
ActionView::Base.send(:include, ResponsiveImageTag) if defined?(ActionView::Base)
|
@@ -28,7 +28,7 @@ class TestResponsiveImageTag < MiniTest::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should use big.jpg as the value for full-src" do
|
31
|
-
@tag.must_match "full-src=\"big.jpg\""
|
31
|
+
@tag.must_match "full-src=\"/images/big.jpg\""
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "with an :alt option specified" do
|
@@ -49,7 +49,7 @@ class TestResponsiveImageTag < MiniTest::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should prepend the correct asset path onto full-src" do
|
52
|
-
@tag.must_match "full-src=\"images/big.jpg
|
52
|
+
@tag.must_match "full-src=\"/images/big.jpg"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responsive_image_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dave Hrycyszyn
|