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 +4 -4
- data/README.md +6 -6
- data/lib/initialjs-rails/version.rb +1 -1
- data/lib/initialjs-rails/view_helpers.rb +4 -2
- data/vendor/assets/javascripts/initial.js +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaec29f6115d7a669d6f1f8a79ea6cc2f60b6e2f
|
4
|
+
data.tar.gz: 00f03e6c5834a487550eb588e235e2ef2c62fed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
|
@@ -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
|
-
|
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)
|
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.
|
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-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|