tabulous 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +18 -1
- data/lib/generators/tabs/templates/tabulous.rb +23 -7
- data/lib/tabulous/options.rb +6 -0
- data/lib/tabulous/tabulous.rb +57 -5
- data/lib/tabulous/version.rb +1 -1
- metadata +11 -14
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.2.0 (February 8, 2012)
|
2
|
+
* Added support for Twitter Bootstrap (version 2).
|
3
|
+
* Noted in the documentation that tabulous works with Rails 3.2.
|
4
|
+
|
1
5
|
== 1.1.0 (January 10, 2012)
|
2
6
|
* Deprecated the raise_error_if_no_tab_found configuration setting. Replaced it with
|
3
7
|
config.when_action_has_no_tab.
|
data/README.rdoc
CHANGED
@@ -6,7 +6,7 @@ Tabulous provides an easy way to add tabs to your Rails application.
|
|
6
6
|
|
7
7
|
== Requirements
|
8
8
|
|
9
|
-
Tabulous
|
9
|
+
Tabulous works with Rails 3.0, 3.1 and 3.2. It has been tested on Ruby 1.8.7 and 1.9.2.
|
10
10
|
|
11
11
|
== Usage
|
12
12
|
|
@@ -66,6 +66,23 @@ There is a tutorial at http://techiferous.com/2011/03/tutorial-for-adding-tabs-t
|
|
66
66
|
Also, look in this gem's test/applications directory to find working example applications.
|
67
67
|
Look at their app/tabs/tabulous.rb and app/layouts/application.html.erb files.
|
68
68
|
|
69
|
+
== Twitter Bootstrap
|
70
|
+
|
71
|
+
To get tabulous to work with Twitter Bootstrap version 2, make sure the
|
72
|
+
following values are set in app/tabs/tabulous.rb:
|
73
|
+
|
74
|
+
* config.css.scaffolding = false
|
75
|
+
* config.tabs_ul_class = "nav nav-pills" # or whatever Bootstrap class you want
|
76
|
+
* config.bootstrap_style_subtabs = true
|
77
|
+
* config.active_tab_clickable = true
|
78
|
+
|
79
|
+
When config.bootstrap_style_subtabs is set to true, the subtabs are rendered
|
80
|
+
inside the tab markup, so you only need to call the tabs helper in your
|
81
|
+
layout, not the subtabs helper.
|
82
|
+
|
83
|
+
Also note that if you use Twitter Bootstrap, you lose the ability to disable
|
84
|
+
individual subtabs.
|
85
|
+
|
69
86
|
== Contributing
|
70
87
|
|
71
88
|
Developers are encouraged to contribute ideas or code.
|
@@ -122,9 +122,9 @@ Tabulous.setup do |config|
|
|
122
122
|
s << ' end'
|
123
123
|
Tabulous::Formatter.format(s).join("\n") %>
|
124
124
|
|
125
|
-
|
126
|
-
# OPTIONS
|
127
|
-
|
125
|
+
#---------------------
|
126
|
+
# GENERAL OPTIONS
|
127
|
+
#---------------------
|
128
128
|
|
129
129
|
# By default, you cannot click on the active tab.
|
130
130
|
config.active_tab_clickable = false
|
@@ -140,13 +140,28 @@ Tabulous.setup do |config|
|
|
140
140
|
# config.when_action_has_no_tab = :render # the tab navigation HTML will be generated,
|
141
141
|
# but no tab or subtab will be active
|
142
142
|
|
143
|
+
#--------------------
|
144
|
+
# MARKUP OPTIONS
|
145
|
+
#--------------------
|
146
|
+
|
143
147
|
# By default, div elements are used in the tab markup. When html5 is
|
144
148
|
# true, nav elements are used instead.
|
145
149
|
config.html5 = false
|
146
150
|
|
147
|
-
|
148
|
-
#
|
149
|
-
|
151
|
+
# This gives you control over what class the <ul> element that wraps the tabs
|
152
|
+
# will have. Good for interfacing with third-party code like Twitter
|
153
|
+
# Bootstrap.
|
154
|
+
# config.tabs_ul_class = "nav nav-pills"
|
155
|
+
|
156
|
+
# Set this to true to have subtabs rendered in markup that Twitter Bootstrap
|
157
|
+
# understands. If this is set to true, you don't need to call subtabs in
|
158
|
+
# your layout, just tabs.
|
159
|
+
# config.bootstrap_style_subtabs = true
|
160
|
+
|
161
|
+
|
162
|
+
#-------------------
|
163
|
+
# STYLE OPTIONS
|
164
|
+
#-------------------
|
150
165
|
#
|
151
166
|
# The markup that is generated has the following properties:
|
152
167
|
#
|
@@ -161,7 +176,8 @@ Tabulous.setup do |config|
|
|
161
176
|
# Some styles will be generated for you to get you off to a good start.
|
162
177
|
# Scaffolded styles are not meant to be used in production as they
|
163
178
|
# generate invalid HTML markup. They are merely meant to give you a
|
164
|
-
# head start or an easy way to prototype quickly.
|
179
|
+
# head start or an easy way to prototype quickly. Set this to false if
|
180
|
+
# you are using Twitter Bootstrap.
|
165
181
|
#
|
166
182
|
config.css.scaffolding = true
|
167
183
|
|
data/lib/tabulous/options.rb
CHANGED
@@ -34,6 +34,12 @@ module Tabulous
|
|
34
34
|
mattr_accessor :html5
|
35
35
|
@@html5 = false
|
36
36
|
|
37
|
+
mattr_accessor :tabs_ul_class
|
38
|
+
@@tabs_ul_class = nil
|
39
|
+
|
40
|
+
mattr_accessor :bootstrap_style_subtabs
|
41
|
+
@@bootstrap_style_subtabs = false
|
42
|
+
|
37
43
|
def self.raise_error_if_no_tab_found=(value)
|
38
44
|
msg = "DEPRECATION WARNING: Tabulous's config.raise_error_if_no_tab_found "
|
39
45
|
msg << "has been replaced by config.when_action_has_no_tab. "
|
data/lib/tabulous/tabulous.rb
CHANGED
@@ -20,13 +20,29 @@ module Tabulous
|
|
20
20
|
active_tab = active_tab(view)
|
21
21
|
active_tab_name = (active_tab ? active_tab.name : nil);
|
22
22
|
html << (@@html5 ? '<nav id="tabs">' : '<div id="tabs">')
|
23
|
-
|
23
|
+
if @@tabs_ul_class
|
24
|
+
html << %Q{<ul class="#{@@tabs_ul_class}">}
|
25
|
+
else
|
26
|
+
html << '<ul>'
|
27
|
+
end
|
24
28
|
for tab in main_tabs
|
25
29
|
next if !tab.visible?(view)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
if @@bootstrap_style_subtabs
|
31
|
+
subtabs = tab.subtabs.select{|subtab| subtab.visible?(view)}
|
32
|
+
end
|
33
|
+
if @@bootstrap_style_subtabs && !subtabs.empty?
|
34
|
+
html << render_dropdown_tab(view,
|
35
|
+
:text => tab.text(view),
|
36
|
+
:path => tab.path(view),
|
37
|
+
:active => (active_tab_name && tab.name == active_tab_name),
|
38
|
+
:enabled => tab.enabled?(view),
|
39
|
+
:subtabs => subtabs)
|
40
|
+
else
|
41
|
+
html << render_tab(:text => tab.text(view),
|
42
|
+
:path => tab.path(view),
|
43
|
+
:active => (active_tab_name && tab.name == active_tab_name),
|
44
|
+
:enabled => tab.enabled?(view))
|
45
|
+
end
|
30
46
|
end
|
31
47
|
html << '</ul>'
|
32
48
|
html << (@@html5 ? '</nav>' : '</div>')
|
@@ -34,6 +50,12 @@ module Tabulous
|
|
34
50
|
end
|
35
51
|
|
36
52
|
def self.render_subtabs(view)
|
53
|
+
if @@bootstrap_style_subtabs
|
54
|
+
raise TabulousError,
|
55
|
+
"You should not call the subtabs view helper when config.bootstrap_style_subtabs " +
|
56
|
+
"is set to true. Simply call the tabs helper and the subtabs will be " +
|
57
|
+
"automatically rendered."
|
58
|
+
end
|
37
59
|
initialize_tabs(view)
|
38
60
|
return if !tab_defined?(view) && @@when_action_has_no_tab == :do_not_render
|
39
61
|
controller = view.controller_name.to_sym
|
@@ -73,6 +95,36 @@ module Tabulous
|
|
73
95
|
html
|
74
96
|
end
|
75
97
|
|
98
|
+
# markup spefically tailored for Twitter Bootstrap
|
99
|
+
def self.render_dropdown_tab(view, options)
|
100
|
+
html = ''
|
101
|
+
klass = 'dropdown'
|
102
|
+
klass << (options[:active] ? ' active' : ' inactive')
|
103
|
+
klass << (options[:enabled] ? ' enabled' : ' disabled')
|
104
|
+
html << %Q{<li class="#{klass}">}
|
105
|
+
if (options[:active] && !@@active_tab_clickable) || options[:enabled] == false
|
106
|
+
html << %Q{<span class="tab">#{options[:text]}</span>}
|
107
|
+
else
|
108
|
+
html << %Q{<a class="dropdown-toggle tab"}
|
109
|
+
html << %Q{ data-toggle="dropdown"}
|
110
|
+
html << %Q{ href="#">}
|
111
|
+
html << %Q{#{options[:text]}<b class="caret"></b></a>}
|
112
|
+
end
|
113
|
+
html << '<ul class="dropdown-menu">'
|
114
|
+
for subtab in options[:subtabs]
|
115
|
+
if subtab.enabled?(view)
|
116
|
+
html << '<li class="enabled">'
|
117
|
+
else
|
118
|
+
html << '<li class="disabled">'
|
119
|
+
end
|
120
|
+
html << %Q{<a href="#{subtab.path(view)}">#{subtab.text(view)}</a>}
|
121
|
+
html << '</li>'
|
122
|
+
end
|
123
|
+
html << '</ul>'
|
124
|
+
html << '</li>'
|
125
|
+
html
|
126
|
+
end
|
127
|
+
|
76
128
|
def self.initialize_tabs(view)
|
77
129
|
if view.respond_to? :instance_exec # for Ruby 1.9
|
78
130
|
self.tabs = view.instance_exec(&@@tabs_block)
|
data/lib/tabulous/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tabulous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Wyatt Greene
|
@@ -10,10 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-07 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: colored
|
17
|
+
prerelease: false
|
17
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
18
19
|
none: false
|
19
20
|
requirements:
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
- !ruby/object:Gem::Version
|
22
23
|
version: 1.2.0
|
23
24
|
type: :runtime
|
24
|
-
prerelease: false
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rails
|
28
|
+
prerelease: false
|
28
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
30
|
none: false
|
30
31
|
requirements:
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: "3.0"
|
34
35
|
type: :runtime
|
35
|
-
prerelease: false
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
+
prerelease: false
|
39
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
40
41
|
none: false
|
41
42
|
requirements:
|
@@ -43,10 +44,10 @@ dependencies:
|
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: 1.0.10
|
45
46
|
type: :development
|
46
|
-
prerelease: false
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: capybara
|
50
|
+
prerelease: false
|
50
51
|
requirement: &id004 !ruby/object:Gem::Requirement
|
51
52
|
none: false
|
52
53
|
requirements:
|
@@ -54,10 +55,10 @@ dependencies:
|
|
54
55
|
- !ruby/object:Gem::Version
|
55
56
|
version: 1.1.2
|
56
57
|
type: :development
|
57
|
-
prerelease: false
|
58
58
|
version_requirements: *id004
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rake
|
61
|
+
prerelease: false
|
61
62
|
requirement: &id005 !ruby/object:Gem::Requirement
|
62
63
|
none: false
|
63
64
|
requirements:
|
@@ -65,10 +66,10 @@ dependencies:
|
|
65
66
|
- !ruby/object:Gem::Version
|
66
67
|
version: 0.8.7
|
67
68
|
type: :development
|
68
|
-
prerelease: false
|
69
69
|
version_requirements: *id005
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: launchy
|
72
|
+
prerelease: false
|
72
73
|
requirement: &id006 !ruby/object:Gem::Requirement
|
73
74
|
none: false
|
74
75
|
requirements:
|
@@ -76,10 +77,10 @@ dependencies:
|
|
76
77
|
- !ruby/object:Gem::Version
|
77
78
|
version: "0"
|
78
79
|
type: :development
|
79
|
-
prerelease: false
|
80
80
|
version_requirements: *id006
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: diffy
|
83
|
+
prerelease: false
|
83
84
|
requirement: &id007 !ruby/object:Gem::Requirement
|
84
85
|
none: false
|
85
86
|
requirements:
|
@@ -87,10 +88,10 @@ dependencies:
|
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: "0"
|
89
90
|
type: :development
|
90
|
-
prerelease: false
|
91
91
|
version_requirements: *id007
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: sqlite3-ruby
|
94
|
+
prerelease: false
|
94
95
|
requirement: &id008 !ruby/object:Gem::Requirement
|
95
96
|
none: false
|
96
97
|
requirements:
|
@@ -98,10 +99,10 @@ dependencies:
|
|
98
99
|
- !ruby/object:Gem::Version
|
99
100
|
version: 1.3.3
|
100
101
|
type: :development
|
101
|
-
prerelease: false
|
102
102
|
version_requirements: *id008
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: sqlite3
|
105
|
+
prerelease: false
|
105
106
|
requirement: &id009 !ruby/object:Gem::Requirement
|
106
107
|
none: false
|
107
108
|
requirements:
|
@@ -109,7 +110,6 @@ dependencies:
|
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: 1.3.4
|
111
112
|
type: :development
|
112
|
-
prerelease: false
|
113
113
|
version_requirements: *id009
|
114
114
|
description: Tabulous provides an easy way to add tabs to your Rails application.
|
115
115
|
email:
|
@@ -715,9 +715,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
715
715
|
requirements:
|
716
716
|
- - ">="
|
717
717
|
- !ruby/object:Gem::Version
|
718
|
-
hash: 3134524414411715253
|
719
|
-
segments:
|
720
|
-
- 0
|
721
718
|
version: "0"
|
722
719
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
723
720
|
none: false
|