weloveiconfonts_rails 1.0.0
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.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7ad903a1cee946861028edde166ad1fdc6bbec4b
|
4
|
+
data.tar.gz: 3cc7b2719ad5add2d0ee41f81cffc44aae162d4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d41a997abe6600e88888600563c164d07d95df3609f5fdfb974c97a500c4948abfa266f65d07caaf63a31772bcaa01fd1baa7ebd292e33982f2535303b76b070
|
7
|
+
data.tar.gz: 9583c3aebced730adc7990374ba79aaf59d07b8de9498e3697c3daac609c0e2ae2c886391ba177b12c5e32e6aa635acd5348090a34680237af214ce629de53a4
|
@@ -0,0 +1,47 @@
|
|
1
|
+
function weloveiconfonts() {
|
2
|
+
function rgb2hex(rgb) {
|
3
|
+
rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d\.]+))?\)$/);
|
4
|
+
function hex(x) { return ("0" + parseInt(x).toString(16)).slice(-2); }
|
5
|
+
return (hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3])).toUpperCase();
|
6
|
+
};
|
7
|
+
|
8
|
+
function mix(color_1, color_2, weight) {
|
9
|
+
function d2h(d) { return d.toString(16); }
|
10
|
+
function h2d(h) { return parseInt(h, 16); }
|
11
|
+
weight = (typeof(weight) !== 'undefined') ? weight : 50;
|
12
|
+
var color = "#";
|
13
|
+
for(var i = 0; i <= 5; i += 2) {
|
14
|
+
var v1 = h2d(color_1.substr(i, 2)),
|
15
|
+
v2 = h2d(color_2.substr(i, 2)),
|
16
|
+
val = d2h(Math.floor(v2 + (v1 - v2) * (weight / 100.0)));
|
17
|
+
while(val.length < 2) { val = '0' + val; }
|
18
|
+
color += val;
|
19
|
+
}
|
20
|
+
return color;
|
21
|
+
};
|
22
|
+
|
23
|
+
var iconBackgroundColor;
|
24
|
+
$('.weloveiconfonts__icon.hoverable').hover(
|
25
|
+
function(){
|
26
|
+
iconBackgroundColor = this.style.backgroundColor;
|
27
|
+
this.style.backgroundColor = mix($(this).attr('shade').substr(1), rgb2hex(iconBackgroundColor), 30);
|
28
|
+
}, function() {
|
29
|
+
this.style.backgroundColor = iconBackgroundColor;
|
30
|
+
}
|
31
|
+
);
|
32
|
+
|
33
|
+
var iconForegroundColor;
|
34
|
+
$(".weloveiconfonts__content.hoverable").hover(
|
35
|
+
function() {
|
36
|
+
iconForegroundColor = this.parentElement.style.color;
|
37
|
+
this.parentElement.style.color = mix($(this.parentElement).attr('shade').substr(1), rgb2hex(iconForegroundColor), 30);
|
38
|
+
},
|
39
|
+
function() {
|
40
|
+
this.parentElement.style.color = iconForegroundColor;
|
41
|
+
}
|
42
|
+
);
|
43
|
+
};
|
44
|
+
|
45
|
+
$(document).ready(function() {
|
46
|
+
weloveiconfonts();
|
47
|
+
});
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
@import url(http://weloveiconfonts.com/api/?family=brandico|entypo|fontawesome|fontelico|iconicfill|iconicstroke|maki|openwebicons|typicons|zocial);
|
3
|
+
|
4
|
+
/* brandico */
|
5
|
+
[class*="brandico-"]:before {
|
6
|
+
font-family: 'brandico', sans-serif;
|
7
|
+
}
|
8
|
+
|
9
|
+
/* entypo */
|
10
|
+
[class*="entypo-"]:before {
|
11
|
+
font-family: 'entypo', sans-serif;
|
12
|
+
}
|
13
|
+
|
14
|
+
/* fontawesome */
|
15
|
+
[class*="fontawesome-"]:before {
|
16
|
+
font-family: 'FontAwesome', sans-serif;
|
17
|
+
}
|
18
|
+
|
19
|
+
/* fontelico */
|
20
|
+
[class*="fontelico-"]:before {
|
21
|
+
font-family: 'fontelico', sans-serif;
|
22
|
+
}
|
23
|
+
|
24
|
+
/* iconicfill */
|
25
|
+
[class*="iconicfill-"]:before {
|
26
|
+
font-family: 'IconicFill', sans-serif;
|
27
|
+
}
|
28
|
+
|
29
|
+
/* iconicstroke */
|
30
|
+
[class*="iconicstroke-"]:before {
|
31
|
+
font-family: 'IconicStroke', sans-serif;
|
32
|
+
}
|
33
|
+
|
34
|
+
/* maki */
|
35
|
+
[class*="maki-"]:before {
|
36
|
+
font-family: 'maki', sans-serif;
|
37
|
+
}
|
38
|
+
|
39
|
+
/* openwebicons */
|
40
|
+
[class*="openwebicons-"]:before {
|
41
|
+
font-family: 'OpenWeb Icons', sans-serif;
|
42
|
+
}
|
43
|
+
|
44
|
+
/* typicons */
|
45
|
+
[class*="typicons-"]:before {
|
46
|
+
font-family: 'Typicons', sans-serif;
|
47
|
+
}
|
48
|
+
|
49
|
+
/* zocial */
|
50
|
+
[class*="zocial-"]:before {
|
51
|
+
font-family: 'zocial', sans-serif;
|
52
|
+
}
|
53
|
+
|
54
|
+
.weloveiconfonts__item {
|
55
|
+
display: table-cell;
|
56
|
+
text-align: center;
|
57
|
+
vertical-align: middle;
|
58
|
+
padding: 5px;
|
59
|
+
|
60
|
+
.weloveiconfonts__icon {
|
61
|
+
display: table-cell;
|
62
|
+
text-align: center;
|
63
|
+
vertical-align: middle;
|
64
|
+
width: inherit;
|
65
|
+
height: inherit;
|
66
|
+
font-size: inherit;
|
67
|
+
|
68
|
+
text-decoration: inherit;
|
69
|
+
color: inherit;
|
70
|
+
.weloveiconfonts__content {
|
71
|
+
display: inline-block;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
.weloveiconfonts__icon.round {
|
76
|
+
border-radius: 100%;
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module WeLoveIconFonts
|
2
|
+
module Base
|
3
|
+
def iconfont(icon, options = {})
|
4
|
+
@options = option_defaults(options)
|
5
|
+
method = options[:link].present? ? :create_link : :create_icon
|
6
|
+
|
7
|
+
@input_html = generate_input_html(options[:input_html])
|
8
|
+
@html_attributes = generate_html_attributes(options)
|
9
|
+
@icon_classes = generate_icon_classes(options)
|
10
|
+
@content_classes = generate_content_classes(options)
|
11
|
+
@icon = icon
|
12
|
+
|
13
|
+
"
|
14
|
+
<div class=\"weloveiconfonts__item\">
|
15
|
+
#{send method}
|
16
|
+
</div>
|
17
|
+
".html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def option_defaults(options)
|
23
|
+
options ||= {}
|
24
|
+
options[:link] ||= ''
|
25
|
+
options[:hoverable] = options[:link].present? if options[:hoverable].nil?
|
26
|
+
options[:foreground] ||= '#000000'
|
27
|
+
options[:round] ||= false
|
28
|
+
options[:shade] ||= :bright
|
29
|
+
options[:size] = 100 if options[:size].nil?
|
30
|
+
options[:font_size] = options[:size] / 2 + 5
|
31
|
+
options[:input_html] ||= {}
|
32
|
+
options
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_input_html(html_options)
|
36
|
+
input_html = ''
|
37
|
+
html_options.keys.each do |key|
|
38
|
+
input_html << " #{key}=\""
|
39
|
+
input_html << "#{html_options[key]}\""
|
40
|
+
end
|
41
|
+
input_html.strip!
|
42
|
+
end
|
43
|
+
|
44
|
+
def generate_html_attributes(options)
|
45
|
+
html_attributes = "shade=" + (options[:shade] == :dark ? '"#000000"' : '"#ffffff"')
|
46
|
+
|
47
|
+
html_attributes << ' style = "color: '
|
48
|
+
html_attributes << "#{options[:foreground]};"
|
49
|
+
html_attributes << " background-color: #{options[:background]};" unless options[:background].nil?
|
50
|
+
html_attributes << " width: #{options[:size]}px; height: #{options[:size]}px;"
|
51
|
+
html_attributes << " font-size: #{options[:font_size]}px;"
|
52
|
+
html_attributes << '"'
|
53
|
+
|
54
|
+
html_attributes.strip
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_icon_classes(options)
|
58
|
+
icon_classes = ''
|
59
|
+
icon_classes << 'hoverable ' if options[:hoverable] && !options[:background].nil?
|
60
|
+
icon_classes << 'round ' if options[:round]
|
61
|
+
icon_classes.strip
|
62
|
+
end
|
63
|
+
|
64
|
+
def generate_content_classes(options)
|
65
|
+
content_classes = ''
|
66
|
+
content_classes << 'hoverable ' if options[:hoverable] && options[:background].nil?
|
67
|
+
content_classes.strip
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_icon
|
71
|
+
"
|
72
|
+
<div #{@input_html} class=\"weloveiconfonts__icon #{@icon_classes}\" #{@html_attributes}>
|
73
|
+
#{send :create_content}
|
74
|
+
</div>
|
75
|
+
"
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_link
|
79
|
+
"
|
80
|
+
<a #{@input_html} class=\"weloveiconfonts__icon #{@icon_classes}\" href=\"#{@options[:link]}\" #{@html_attributes}>
|
81
|
+
#{send :create_content}
|
82
|
+
</a>
|
83
|
+
"
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_content
|
87
|
+
"
|
88
|
+
<div class=\"weloveiconfonts__content #{@icon} #{@content_classes}\">
|
89
|
+
</div>
|
90
|
+
"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: weloveiconfonts_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Herman Zvonimir Došilović
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jquery-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: We must stop here, this is icon fonts country for Rails!
|
56
|
+
email: hermanz.dosilovic@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- app/assets/javascript/weloveiconfonts_rails.js
|
62
|
+
- app/assets/stylesheets/weloveiconfonts_rails.css.scss
|
63
|
+
- app/helpers/we_love_icon_fonts_helper.rb
|
64
|
+
- lib/we_love_icon_fonts/base.rb
|
65
|
+
- lib/weloveiconfonts_rails.rb
|
66
|
+
homepage: https://github.com/hermanzdosilovic/weloveiconfonts_rails
|
67
|
+
licenses:
|
68
|
+
- None
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.4.5
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: We Love Icon Fonts
|
90
|
+
test_files: []
|
91
|
+
has_rdoc:
|