initialjs-rails 0.1.0 → 0.2.0

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: 238b306c59ac0a4dddd0e0e302bfcb884c25fce4
4
- data.tar.gz: 09edb2d474028817ba72089d9c2324a218432c8d
3
+ metadata.gz: eaec29f6115d7a669d6f1f8a79ea6cc2f60b6e2f
4
+ data.tar.gz: 00f03e6c5834a487550eb588e235e2ef2c62fed2
5
5
  SHA512:
6
- metadata.gz: 509fbca21bc9c178345e0f7e1e599ee012a0c1f54094b90fa9eb3938a099ed138efa146e1c9716f870bf21da6f63612f9cd2516e72d7851778593e3106f52df2
7
- data.tar.gz: 343d2bda9a88e4bfd0b3e3b228cdc15673023b8154980f561cf6df895b5fb2316b6e26ec8da4ae24d5414da9a7234e069e20b2450f8f0f5fa907374f454dfe16
6
+ metadata.gz: a23481a0db57bc645eac6f6ea0cf38f8141963bb7915c2661317972f2374577c9961624cd9ba08b71c4e3e80e5a291f81dce8f123bb2bc51bbd9568f2199dce2
7
+ data.tar.gz: 30874d7150c0cb4a591444029439a6f514f3fc61bb91a187ef12b2c836c606ce781215534907d7d95224542e5a88dbdccf4fe982a3158f8b05d6bd8886633584
data/README.md CHANGED
@@ -28,18 +28,18 @@ 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).
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.
32
32
 
33
33
  Enjoy.
34
34
 
35
- ## ActionView Graph Helper
35
+ ## ActionView Helper
36
36
 
37
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:
38
38
 
39
- avatar_image(user) # => 100x100 image with round corners
40
- avatar_image(user, size: 32) # => 32x32 image with round corners
41
- avatar_image(user, class: 'extra_class') # => add an extra CSS class to <img/> tag
42
- avatar_image(user, round_corners: false) # => disable round corners
39
+ avatar_image(user) # => 100x100 image with round corners
40
+ avatar_image(user, size: 32) # => 32x32 image with round corners
41
+ avatar_image(user, class: 'extra_class') # => add an extra CSS class to <img/> tag
42
+ avatar_image(user, round_corners: false) # => disable round corners
43
43
 
44
44
  ## Development
45
45
 
@@ -1,3 +1,3 @@
1
1
  module InitialjsRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -6,15 +6,17 @@ module InitialjsRails
6
6
  size = options.fetch(:size) { 100 }
7
7
  klass = options.fetch(:class) { '' }
8
8
  round_corners = options.fetch(:round_corners) { true }
9
+ seed = options.fetch(:seed) { 0 }
9
10
 
10
11
  data_attributes = { name: avatarable.name,
12
+ seed: seed,
11
13
  height: size,
12
14
  width: size,
13
- "font-size" => (size * 0.6) }
15
+ "font-size" => (size * 0.6) }
14
16
 
15
17
  data_attributes.merge!(radius: (size * 0.13).round) if round_corners
16
18
 
17
- content_tag :img, nil, class: "initialjs-avatar #{klass}", data: data_attributes
19
+ content_tag :img, nil, class: "initialjs-avatar #{klass}".strip, data: data_attributes
18
20
  end
19
21
  end
20
22
  end
@@ -10,6 +10,7 @@
10
10
  var settings = $.extend({
11
11
  // Default settings
12
12
  name: 'Name',
13
+ seed: 0,
13
14
  charCount: 1,
14
15
  textColor: '#ffffff',
15
16
  height: 100,
@@ -37,7 +38,7 @@
37
38
  'font-size': settings.fontSize+'px',
38
39
  });
39
40
 
40
- var colorIndex = Math.floor((c.charCodeAt(0) - 65) % colors.length);
41
+ var colorIndex = Math.floor((c.charCodeAt(0) + settings.seed) % colors.length);
41
42
 
42
43
  var svg = $('<svg></svg>').attr({
43
44
  'xmlns': 'http://www.w3.org/2000/svg',
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.1.0
4
+ version: 0.2.0
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-08-12 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties