retina_tag 1.0.1 → 1.0.2
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.
- data/.gitignore +1 -0
- data/README.md +6 -3
- data/Rakefile +0 -1
- data/app/assets/javascripts/retina_tag.js +0 -17
- data/lib/retina_tag/engine.rb +0 -1
- data/lib/retina_tag/image_tag_helper.rb +7 -12
- data/lib/retina_tag/version.rb +1 -1
- data/lib/retina_tag.rb +3 -4
- data/retina_tag.gemspec +0 -1
- metadata +2 -11
- data/.DS_Store +0 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# RetinaTag
|
2
2
|
|
3
|
-
Interested in making your web-sites retina compatible? Rails asset pipeline
|
3
|
+
Interested in making your web-sites retina compatible? Rails asset pipeline
|
4
|
+
makes this a pain with retina `image_tag`s, especially when precompiling assets.
|
5
|
+
RetinaTag resolves this by extending `image_tag` to create a `hidpi_src`
|
6
|
+
attribute with the retina image path if it exists.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -19,7 +22,7 @@ Or install it yourself as:
|
|
19
22
|
|
20
23
|
## Usage
|
21
24
|
|
22
|
-
Add retina_tag.js to your application.js file after including
|
25
|
+
Add `retina_tag.js` to your application.js file after including jQuery:
|
23
26
|
|
24
27
|
//require retina_tag
|
25
28
|
|
@@ -28,7 +31,7 @@ Add double pixel resolution images in your assets directory with the @2x modifie
|
|
28
31
|
logo.png
|
29
32
|
logo@2x.png
|
30
33
|
|
31
|
-
Be sure to also specify the base dimensions in your image_tag calls
|
34
|
+
Be sure to also specify the base dimensions in your `image_tag` calls:
|
32
35
|
|
33
36
|
<%=image_tag('logo.png',:height=>50)%>
|
34
37
|
|
data/Rakefile
CHANGED
@@ -1,30 +1,13 @@
|
|
1
1
|
function highdpi_init() {
|
2
2
|
if(window.devicePixelRatio > 1)
|
3
3
|
{
|
4
|
-
|
5
4
|
var els = jQuery("img").get();
|
6
5
|
for(var i = 0; i < els.length; i++) {
|
7
6
|
var hiDpiSrc = $(els[i]).attr('hidpi_src');
|
8
|
-
var src = els[i].src;
|
9
|
-
|
10
|
-
if(hiDpiSrc)
|
11
|
-
{
|
12
|
-
src = hiDpiSrc;
|
13
|
-
}
|
14
|
-
else
|
15
|
-
{
|
16
|
-
var path_segments = src.split('.');
|
17
|
-
var path_without_extension = path_segments.slice(0, (path_segments.length - 1)).join(".");
|
18
|
-
var extension = path_segments[path_segments.length - 1];
|
19
|
-
src = path_without_extension + "@2x." + extension;
|
20
|
-
}
|
21
7
|
|
22
8
|
if(hiDpiSrc) {
|
23
9
|
els[i].src = hiDpiSrc;
|
24
10
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
11
|
}
|
29
12
|
}
|
30
13
|
}
|
data/lib/retina_tag/engine.rb
CHANGED
@@ -8,25 +8,20 @@ module ActionView
|
|
8
8
|
retina_els.slice!(-1)
|
9
9
|
retina_path = "#{retina_els.join('.')}@2x.#{extension}"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
if !Rails.application.assets.find_asset(retina_path).nil?
|
12
|
+
asset_path(retina_path)
|
13
|
+
end
|
14
14
|
rescue
|
15
|
-
|
16
|
-
return nil
|
15
|
+
nil
|
17
16
|
end
|
18
17
|
end
|
19
|
-
def image_tag_with_retina(source,options={})
|
20
|
-
|
21
|
-
options_default = {:hidpi_src=>hidpi_asset_path(source)}
|
22
18
|
|
23
|
-
|
19
|
+
def image_tag_with_retina(source,options={})
|
20
|
+
options_default = { :hidpi_src => hidpi_asset_path(source) }
|
21
|
+
image_tag_without_retina(source,options_default.merge(options))
|
24
22
|
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
24
|
alias_method_chain :image_tag, :retina
|
29
|
-
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
data/lib/retina_tag/version.rb
CHANGED
data/lib/retina_tag.rb
CHANGED
data/retina_tag.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retina_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|
@@ -51,14 +51,11 @@ executables: []
|
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
|
-
- .DS_Store
|
55
54
|
- .gitignore
|
56
55
|
- Gemfile
|
57
56
|
- LICENSE
|
58
57
|
- README.md
|
59
58
|
- Rakefile
|
60
|
-
- app/.DS_Store
|
61
|
-
- app/assets/.DS_Store
|
62
59
|
- app/assets/javascripts/retina_tag.js
|
63
60
|
- lib/retina_tag.rb
|
64
61
|
- lib/retina_tag/engine.rb
|
@@ -77,18 +74,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
74
|
- - ! '>='
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: '0'
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
hash: -3005191928238692356
|
83
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
78
|
none: false
|
85
79
|
requirements:
|
86
80
|
- - ! '>='
|
87
81
|
- !ruby/object:Gem::Version
|
88
82
|
version: '0'
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
hash: -3005191928238692356
|
92
83
|
requirements: []
|
93
84
|
rubyforge_project:
|
94
85
|
rubygems_version: 1.8.24
|
data/.DS_Store
DELETED
Binary file
|
data/app/.DS_Store
DELETED
Binary file
|
data/app/assets/.DS_Store
DELETED
Binary file
|