rails-theme-helper 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module RailsTheme
2
+ module Bootstrap
3
+ module ButtonHelper
4
+ def render_btn_group tag = :div, options = {}
5
+ buttons = []
6
+ yield buttons if block_given?
7
+ text = buttons.join('').html_safe
8
+ options = {
9
+ class: 'btn-group'
10
+ }.deep_merge options
11
+ content_tag tag, text, options
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ module RailsTheme
2
+ module Bootstrap
3
+ module DropdownHelper
4
+ def dropdown_toggle text, url = '#', options = {}
5
+ text = text.html_safe << ' '
6
+ text << content_tag(:span, nil, class: 'caret')
7
+ options = {
8
+ class: 'dropdown-toggle',
9
+ data: { toggle: 'dropdown' }
10
+ }.deep_merge options
11
+ link_to text, url, options
12
+ end
13
+
14
+ def dropdown_btn text, url = '#', options = {}
15
+ options = {
16
+ class: 'btn dropdown-toggle'
17
+ }.deep_merge options
18
+ dropdown_toggle text, url, options
19
+ end
20
+
21
+ def dropdown_menu options = {}, &block
22
+ options = {
23
+ class: 'dropdown-menu'
24
+ }.deep_merge options
25
+ render_list options, &block
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ module RailsTheme
2
+ module Bootstrap
3
+ module FormHelper
4
+ def submit_button f, label = nil, options = {}
5
+ options = {
6
+ name: nil,
7
+ class: 'btn-primary'
8
+ }.deep_merge options
9
+ f.button :submit, label, options
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,54 @@
1
+ module RailsTheme
2
+ module Bootstrap
3
+ module LinkHelper
4
+ def iconed_link_to text, url, options = {}
5
+ icon_class = options.delete(:icon_class)
6
+ text = content_tag(:i, nil, class: icon_class) << ' ' << text
7
+ link_to text, url, options
8
+ end
9
+
10
+ def link_to_show url, options = {}
11
+ icon_class = options.delete(:icon_class) || 'icon-eye-open'
12
+ options = {
13
+ class: 'btn',
14
+ icon_class: icon_class,
15
+ title: t('helpers.show')
16
+ }.deep_merge options
17
+ default_options = { }
18
+ iconed_link_to nil, url, options
19
+ end
20
+
21
+ def link_to_new url, options = {}
22
+ icon_class = options.delete(:icon_class) || 'icon-plus'
23
+ options = {
24
+ class: 'btn',
25
+ icon_class: icon_class,
26
+ title: t('helpers.new')
27
+ }.deep_merge options
28
+ iconed_link_to nil, url, options
29
+ end
30
+
31
+ def link_to_edit url, options = {}
32
+ icon_class = options.delete(:icon_class) || 'icon-edit'
33
+ options = {
34
+ class: 'btn',
35
+ icon_class: icon_class,
36
+ title: t('helpers.edit')
37
+ }.deep_merge options
38
+ iconed_link_to nil, url, options
39
+ end
40
+
41
+ def link_to_destroy url, options = {}
42
+ icon_class = options.delete(:icon_class) || 'icon-trash'
43
+ options = {
44
+ method: :delete,
45
+ data: { confirm: t('helpers.are_you_sure') },
46
+ class: 'btn',
47
+ icon_class: icon_class,
48
+ title: t('helpers.destroy')
49
+ }.deep_merge options
50
+ iconed_link_to nil, url, options
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,62 @@
1
+ module RailsTheme
2
+ module Bootstrap
3
+ module ModalHelper
4
+ def link_to_modal text, url, modal_id, options = {}
5
+ options = {
6
+ remote: true,
7
+ data: {
8
+ toggle: 'modal',
9
+ target: modal_id,
10
+ type: 'html'
11
+ },
12
+ class: 'modal-open'
13
+ }.deep_merge options
14
+ link_to text, url, options
15
+ end
16
+
17
+ def link_to_open_modal text, url, modal_id, options = {}
18
+ options = {
19
+ remote: true,
20
+ data: {
21
+ toggle: 'modal',
22
+ target: modal_id,
23
+ type: 'html'
24
+ },
25
+ class: 'modal-open'
26
+ }.deep_merge options
27
+ iconed_link_to text, url, options
28
+ end
29
+
30
+ def link_to_edit_modal url, modal_id, options = {}
31
+ options = {
32
+ remote: true,
33
+ data: {
34
+ toggle: 'modal',
35
+ target: modal_id,
36
+ type: 'html'
37
+ },
38
+ class: 'modal-open btn'
39
+ }.deep_merge options
40
+ link_to_edit url, options
41
+ end
42
+
43
+ def link_to_close_button
44
+ options = {
45
+ data: { dismiss: 'modal' },
46
+ class: 'btn'
47
+ }
48
+ link_to t('helpers.close'), '#', options
49
+ end
50
+
51
+ def modal_close_button
52
+ options = {
53
+ type: 'button',
54
+ name: nil,
55
+ data: { dismiss: 'modal' },
56
+ class: 'close'
57
+ }
58
+ button_tag 'x', options
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,57 @@
1
+ module RailsTheme
2
+ module Bootstrap
3
+ module TabHelper
4
+ def link_to_tab text, tab_pane_id, options = {}
5
+ options = {
6
+ data: {
7
+ toggle: 'tab',
8
+ target: tab_pane_id
9
+ }
10
+ }.deep_merge options
11
+ link_to text, tab_pane_id, options
12
+ end
13
+
14
+ def link_to_remote_tab text, url, tab_pane_id, options = {}
15
+ options = {
16
+ remote: true,
17
+ data: {
18
+ toggle: 'tab',
19
+ target: tab_pane_id,
20
+ type: 'html'
21
+ }
22
+ }.deep_merge options
23
+ link_to text, url, options
24
+ end
25
+
26
+ def nav_tab text, tag_id, default
27
+ active = tag_id == default
28
+ li_class = 'active' if active
29
+ [ link_to_tab(text, "##{tag_id}"), { class: li_class } ]
30
+ end
31
+
32
+ def tab_pane tag_id, default
33
+ active = tag_id == default
34
+ tab_class = 'tab-pane fade'
35
+ tab_class << ' active in' if active
36
+ content_tag :div, class: tab_class, id: tag_id do
37
+ yield
38
+ end
39
+ end
40
+
41
+ def remote_nav_tab text, url, tag_id, default
42
+ active = current_page?(url) || tag_id == default
43
+ li_class = 'active' if active
44
+ [ link_to_remote_tab(text, url, "##{tag_id}"), { class: li_class } ]
45
+ end
46
+
47
+ def remote_tab_pane url, tag_id, default, partial, locals
48
+ active = current_page?(url) || tag_id == default
49
+ tab_class = 'tab-pane fade'
50
+ tab_class << ' active in' if active
51
+ content_tag :div, class: tab_class, id: tag_id do
52
+ render partial, locals if active
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsThemeHelper
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/rails_theme.rb CHANGED
@@ -1,11 +1,4 @@
1
- require 'rails-i18n'
2
-
3
1
  require 'rails_theme/engine'
4
2
 
5
- if defined? ::WillPaginate
6
- require 'will_paginate/array'
7
- require 'rails_theme/bootstrap/link_renderer'
8
- end
9
-
10
3
  module RailsTheme
11
4
  end
@@ -2,3 +2,10 @@ module RailsTheme
2
2
  class Engine < ::Rails::Engine
3
3
  end
4
4
  end
5
+
6
+ require 'rails-i18n'
7
+
8
+ if defined? ::WillPaginate
9
+ require 'will_paginate/array'
10
+ require 'rails_theme/bootstrap/link_renderer'
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-theme-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2012-12-17 00:00:00.000000000 Z
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -72,7 +72,12 @@ files:
72
72
  - README.md
73
73
  - Rakefile
74
74
  - app/assets/stylesheets/rails_theme/simple_layout.css.sass
75
- - app/helpers/rails_theme/bootstrap_helper.rb
75
+ - app/helpers/rails_theme/bootstrap/button_helper.rb
76
+ - app/helpers/rails_theme/bootstrap/dropdown_helper.rb
77
+ - app/helpers/rails_theme/bootstrap/form_helper.rb
78
+ - app/helpers/rails_theme/bootstrap/link_helper.rb
79
+ - app/helpers/rails_theme/bootstrap/modal_helper.rb
80
+ - app/helpers/rails_theme/bootstrap/tab_helper.rb
76
81
  - app/helpers/rails_theme/layout_helper.rb
77
82
  - app/views/application/_chromeframe.html.erb
78
83
  - app/views/application/_flash_messages.html.erb
@@ -101,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
106
  version: '0'
102
107
  segments:
103
108
  - 0
104
- hash: 592579811214293105
109
+ hash: 2562249329077646014
105
110
  required_rubygems_version: !ruby/object:Gem::Requirement
106
111
  none: false
107
112
  requirements:
@@ -110,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
115
  version: '0'
111
116
  segments:
112
117
  - 0
113
- hash: 592579811214293105
118
+ hash: 2562249329077646014
114
119
  requirements: []
115
120
  rubyforge_project:
116
121
  rubygems_version: 1.8.24
@@ -1,86 +0,0 @@
1
- module RailsTheme
2
- module BootstrapHelper
3
- def dropdown_toggle(text, url = '#')
4
- link_to url, class: 'dropdown-toggle', :'data-toggle' => 'dropdown' do
5
- text.html_safe << ' ' << content_tag(:b, nil, class: 'caret')
6
- end
7
- end
8
-
9
- def dropdown_btn(text, url = '#')
10
- link_to url, class: 'btn dropdown-toggle', :'data-toggle' => 'dropdown' do
11
- text.html_safe << ' ' << content_tag(:span, nil, class: 'caret')
12
- end
13
- end
14
-
15
- def iconed_link_to(text, url, options = {})
16
- icon_class = options.delete(:icon_class)
17
- link_to url, options do
18
- content_tag(:i, nil, class: icon_class) << ' ' << text
19
- end
20
- end
21
-
22
- def link_to_show(url, options = {})
23
- icon_class = options.delete(:icon_class) || 'icon-eye-open'
24
- default_options = { title: t('helpers.show'), class: 'btn', icon_class: icon_class }
25
- iconed_link_to nil, url, default_options.deep_merge(options)
26
- end
27
-
28
- def link_to_new(url, options = {})
29
- icon_class = options.delete(:icon_class) || 'icon-plus'
30
- default_options = { title: t('helpers.new'), class: 'btn', icon_class: icon_class }
31
- iconed_link_to nil, url, default_options.deep_merge(options)
32
- end
33
-
34
- def link_to_edit(url, options = {})
35
- icon_class = options.delete(:icon_class) || 'icon-edit'
36
- default_options = { title: t('helpers.edit'), class: 'btn', icon_class: icon_class }
37
- iconed_link_to nil, url, default_options.deep_merge(options)
38
- end
39
-
40
- def link_to_destroy(url, options = {})
41
- icon_class = options.delete(:icon_class) || 'icon-trash'
42
- default_options = { method: :delete, data: { confirm: t('helpers.are_you_sure') }, title: t('helpers.destroy'), class: 'btn', icon_class: icon_class }
43
- iconed_link_to nil, url, default_options.deep_merge(options)
44
- end
45
-
46
- def link_to_open_modal(text, url, modal_id, options = {})
47
- default_options = { remote: true, data: { target: modal_id, toggle: 'modal', type: 'html' }, class: 'modal-open' }
48
- iconed_link_to text, url, default_options.deep_merge(options)
49
- end
50
-
51
- def link_to_edit_modal(url, modal_id)
52
- default_options = { remote: true, data: { target: modal_id, toggle: 'modal', type: 'html' }, class: 'btn modal-open' }
53
- link_to_edit url, default_options
54
- end
55
-
56
- def link_to_close_button
57
- link_to t('helpers.close'), '#', data: { dismiss: 'modal' }, class: 'btn'
58
- end
59
-
60
- def modal_close_button
61
- button_tag 'x', type: 'button', name: nil, class: 'close', data: { dismiss: 'modal' }
62
- end
63
-
64
- def submit_button(f, label = nil, options = {})
65
- default_options = { name: nil, class: 'btn-primary' }
66
- f.button :submit, label, default_options.deep_merge(options)
67
- end
68
-
69
- def render_btn_group(tag = :div, options = {})
70
- buttons = []
71
- yield buttons if block_given?
72
- default_options = { class: 'btn-group' }
73
- content_tag tag, buttons.join('').html_safe, default_options.deep_merge(options)
74
- end
75
-
76
- def link_to_tab(text, tab_pane_id, options = {})
77
- default_options = { data: { toggle: 'tab', target: tab_pane_id} }
78
- link_to text, tab_pane_id, default_options.deep_merge(options)
79
- end
80
-
81
- def link_to_remote_tab(text, url, tab_pane_id, options = {})
82
- default_options = { remote: true, data: { toggle: 'tab', target: tab_pane_id, type: 'html' } }
83
- link_to text, url, default_options.deep_merge(options)
84
- end
85
- end
86
- end