retina_tag 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .DS_Store
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
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 makes this a pain with retina image_tags, especially when precompiling assets. RetinaTag resolves this by extending image_tag to create a hidpi_src attribute with the retina image path if it exists.
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 jquery
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,2 +1 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
@@ -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
  }
@@ -1,5 +1,4 @@
1
1
  module RetinaTag
2
2
  class Engine < ::Rails::Engine
3
-
4
3
  end
5
4
  end
@@ -8,25 +8,20 @@ module ActionView
8
8
  retina_els.slice!(-1)
9
9
  retina_path = "#{retina_els.join('.')}@2x.#{extension}"
10
10
 
11
- return nil if Rails.application.assets.find_asset(retina_path).nil?
12
- asset_path = asset_path(retina_path)
13
- return asset_path
11
+ if !Rails.application.assets.find_asset(retina_path).nil?
12
+ asset_path(retina_path)
13
+ end
14
14
  rescue
15
- puts " WOAH"
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
- return image_tag_without_retina(source,options_default.merge(options))
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
@@ -1,3 +1,3 @@
1
1
  module RetinaTag
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/retina_tag.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "retina_tag/version"
2
- require 'retina_tag/image_tag_helper'
2
+ require "retina_tag/image_tag_helper"
3
+ require "retina_tag/engine"
4
+
3
5
  module RetinaTag
4
- # Your code goes here...
5
6
  end
6
-
7
- require "retina_tag/engine"
data/retina_tag.gemspec CHANGED
@@ -17,5 +17,4 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency 'jquery-rails'
19
19
  gem.add_dependency "rails", "~> 3.1"
20
-
21
20
  end
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.1
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-07-12 00:00:00.000000000 Z
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