frontie 0.2.1 → 0.3.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.
- data/app/helpers/links_helper.rb +2 -4
- data/config/initializers/icon_link_to.rb +39 -0
- data/lib/frontie/version.rb +1 -1
- metadata +3 -2
data/app/helpers/links_helper.rb
CHANGED
@@ -2,10 +2,8 @@ module LinksHelper
|
|
2
2
|
|
3
3
|
# Simple method to create icon buttons
|
4
4
|
def icon_link_to text, path, icon, params = {}
|
5
|
-
icon =
|
6
|
-
link_to path, params
|
7
|
-
icon
|
8
|
-
end
|
5
|
+
params[:icon] = icon
|
6
|
+
link_to text, path, params
|
9
7
|
end
|
10
8
|
|
11
9
|
# Similar to icon_link_to but uses the <button> tag
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Patches the link_to URL Helper to allow :icon and :position parameters
|
2
|
+
# for icon links
|
3
|
+
|
4
|
+
module ActionView
|
5
|
+
module Helpers
|
6
|
+
module UrlHelper
|
7
|
+
|
8
|
+
def link_to(name = nil, options = nil, html_options = nil, &block)
|
9
|
+
html_options, options, name = options, name, block if block_given?
|
10
|
+
options ||= {}
|
11
|
+
|
12
|
+
html_options = convert_options_to_data_attributes(options, html_options)
|
13
|
+
|
14
|
+
url = url_for(options)
|
15
|
+
html_options['href'] ||= url
|
16
|
+
|
17
|
+
# If the icon option is passed then let's build the content
|
18
|
+
if html_options.present? and html_options['icon'].present?
|
19
|
+
icon = content_tag(:i, "", class: html_options['icon'])
|
20
|
+
html_options.delete('icon')
|
21
|
+
|
22
|
+
# If a position option and direciton is passed then let's use it or default
|
23
|
+
# to the position: :right
|
24
|
+
if html_options['position'].present? and html_options['position'] == :right
|
25
|
+
html_options.delete('position')
|
26
|
+
content = "#{name || url} #{icon} ".html_safe
|
27
|
+
else
|
28
|
+
content = "#{icon} #{name || url}".html_safe
|
29
|
+
end
|
30
|
+
else
|
31
|
+
content = name || url
|
32
|
+
end
|
33
|
+
|
34
|
+
content_tag(:a, content, html_options, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/frontie/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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:
|
12
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- app/helpers/meta_data_helper.rb
|
64
64
|
- app/helpers/page_title_helper.rb
|
65
65
|
- app/helpers/utility_helper.rb
|
66
|
+
- config/initializers/icon_link_to.rb
|
66
67
|
- frontie.gemspec
|
67
68
|
- lib/frontie.rb
|
68
69
|
- lib/frontie/engine.rb
|