initialjs-rails 0.2.0.1 → 0.2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a13a1bac7547b5cccd0d0f4436d004d7668edfc1
4
- data.tar.gz: 651c53490a6b9283875ded978d4223651425b526
3
+ metadata.gz: 235e89e592a71f91e8b516e22c29f502171c3333
4
+ data.tar.gz: 743bdbca989b41ac6e108f743a206bdae5c017d0
5
5
  SHA512:
6
- metadata.gz: 35d104655055b4db00f9854e3fd638af0db8d1f437bfbf4c63dbcc4a9ff41cd4470f0cefcc9f279264fffb33dec35e64d465502c2249c7ae22f91dbc84ee1b29
7
- data.tar.gz: d80a0308992b766ce3757bb322ff0748c47b7aa7ec91d03dcc0f41c6e0a55b3ad4cf0b3208d49cb404259e9b61523b828172c0ba9917481725173803c2248502
6
+ metadata.gz: eaa80ec1c8b6b9eb97e9d637b5d8baa6cc48e012a09c66533c817f58d1b3dc24361fa8a773b023464aac89f67aa48e31478a5721c89de34efdbaf7234f311247
7
+ data.tar.gz: 8955ce10edd02915c25400e0e860482d599f1347ebcaa60f8e15affb78bc693cea225ce2b612429e890f6f434596c96d97730f7b6859c3c989d93e3e04001382
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # initialjs-rails
2
2
 
3
- [initial.js](https://github.com/mozilla/metrics-graphics) is a simple jQuery plugin to make Gmail-like text avatars for profile pictures using SVG.
3
+ [initial.js](https://github.com/judesfernando/initial.js) is a simple jQuery plugin to make Gmail-like text avatars for profile pictures using SVG.
4
4
 
5
5
  **initialjs-rails** is a wrapper to easily include it in your Rails projects using the assets pipeline.
6
6
 
@@ -28,18 +28,20 @@ Add this to your application.js after page is ready:
28
28
 
29
29
  $('.initialjs-avatar').initial();
30
30
 
31
- And finally, in your views, tag your *<img/>* class with `initialjs-avatar` class. You can use *data-attributes* as described in [initial.js](https://github.com/mozilla/metrics-graphics). Or you can use the helper below.
31
+ And finally, in your views, tag your *<img/>* class with `initialjs-avatar` class. You can use *data-attributes* as described in [initial.js](https://github.com/judesfernando/initial.js). Or you can use the helper below.
32
32
 
33
33
  Enjoy.
34
34
 
35
35
  ## ActionView Helper
36
36
 
37
- For extra simplicity, you can use this helper in your view to generate your avatar image from your model. In the following examples we'll use User, but any model responding to `:name` will do. You can learn the options available and their defaults directly from the examples:
37
+ For extra simplicity, you can use this helper in your view to generate your avatar image from your model. In the following examples we'll use User, but any model responding to `:name` will do. You can also provide a `String` directly. You can learn the options available and their defaults directly from the examples:
38
38
 
39
39
  avatar_image(user) # => 100x100 image with round corners
40
40
  avatar_image(user, size: 32) # => 32x32 image with round corners
41
41
  avatar_image(user, class: 'extra_class') # => add an extra CSS class to <img/> tag
42
42
  avatar_image(user, round_corners: false) # => disable round corners
43
+ avatar_image(user, count: 2) # => Number of characters shown in the image
44
+ avatar_image(user, color: 'black') # => Text color black. You can also provide any color in hex format: #000
43
45
 
44
46
  ## Development
45
47
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'railties', [">= 3.1", "< 5.0"]
22
+ spec.add_dependency 'railties', [">= 3.1", "< 6.0"]
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.9"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -0,0 +1,3 @@
1
+ ## 0.2.0.2
2
+
3
+ * Adds `color` and `count` options; Allows the helper to accept both an object responding to `:name` and a String name. ~ @shah743
@@ -1,3 +1,3 @@
1
1
  module InitialjsRails
2
- VERSION = "0.2.0.1"
2
+ VERSION = "0.2.0.3"
3
3
  end
@@ -7,16 +7,35 @@ module InitialjsRails
7
7
  klass = options.fetch(:class) { '' }
8
8
  round_corners = options.fetch(:round_corners) { true }
9
9
  seed = options.fetch(:seed) { 0 }
10
+ char_count = options.fetch(:count) { 1 }
11
+ txt_color = options.fetch(:color) { '#ffffff' }
10
12
 
11
- data_attributes = { name: avatarable.name,
12
- seed: seed,
13
- height: size,
14
- width: size,
15
- "font-size" => (size * 0.6) }
13
+ data_attributes = {
14
+ name: get_name_with_count(avatarable, char_count),
15
+ seed: seed,
16
+ height: size,
17
+ width: size,
18
+ 'char-count': char_count,
19
+ 'font-size': (size * 0.6),
20
+ 'text-color': txt_color
21
+ }
16
22
 
17
23
  data_attributes.merge!(radius: (size * 0.13).round) if round_corners
18
24
 
19
- content_tag :img, nil, alt: avatarable.name, class: "initialjs-avatar #{klass}".strip, data: data_attributes
25
+ content_tag :img, nil, alt: get_name(avatarable), class: "initialjs-avatar #{klass}".strip, data: data_attributes
26
+ end
27
+
28
+ def get_name_with_count(avatarable, count)
29
+ name = get_name(avatarable)
30
+ if count == 2
31
+ "#{name.partition(" ").first[0]}#{name.partition(" ").last[0]}"
32
+ else
33
+ name
34
+ end
35
+ end
36
+
37
+ def get_name(avatarable)
38
+ avatarable.is_a?(String) ? avatarable : avatarable.try(:name)
20
39
  end
21
40
  end
22
41
  end
@@ -62,4 +62,4 @@
62
62
  })
63
63
  };
64
64
 
65
- }(jQuery));
65
+ }(jQuery));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: initialjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.1
4
+ version: 0.2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.0'
22
+ version: '6.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.0'
32
+ version: '6.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +75,7 @@ files:
75
75
  - bin/setup
76
76
  - initialjs-rails.gemspec
77
77
  - lib/initialjs-rails.rb
78
+ - lib/initialjs-rails/CHANGELOG.md
78
79
  - lib/initialjs-rails/engine.rb
79
80
  - lib/initialjs-rails/version.rb
80
81
  - lib/initialjs-rails/view_helpers.rb
@@ -99,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  requirements: []
101
102
  rubyforge_project:
102
- rubygems_version: 2.4.6
103
+ rubygems_version: 2.4.5.1
103
104
  signing_key:
104
105
  specification_version: 4
105
106
  summary: initial.js for Rails