bettertabs 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +30 -0
- data/EXAMPLES.md +212 -0
- data/README.md +84 -199
- data/bettertabs.gemspec +3 -3
- data/lib/bettertabs/bettertabs_builder.rb +32 -12
- data/lib/bettertabs/bettertabs_helper.rb +47 -3
- data/lib/bettertabs/javascripts/jquery.bettertabs.coffee +5 -3
- data/lib/bettertabs/javascripts/jquery.bettertabs.js +6 -4
- data/lib/bettertabs/stylesheets/README.md +80 -0
- data/lib/bettertabs/version.rb +1 -1
- data/test/ruby_1_9/rails_3_0/Gemfile.lock +4 -4
- data/test/ruby_1_9/rails_3_0/app/views/bettertabs/_ajax.html.haml +2 -2
- data/test/ruby_1_9/rails_3_0/app/views/bettertabs/_link.html.haml +1 -1
- data/test/ruby_1_9/rails_3_0/app/views/layouts/application.html.erb +1 -1
- data/test/ruby_1_9/rails_3_0/public/javascripts/jquery.bettertabs.js +83 -0
- data/test/ruby_1_9/rails_3_0/public/stylesheets/bettertabs.css +1 -0
- data/test/ruby_1_9/rails_3_0/spec/requests/bettertabs_spec.rb +70 -9
- metadata +11 -17
- data/test/ruby_1_9/rails_3_0/public/javascripts/jquery.bettertabs.min.js +0 -4
@@ -17,6 +17,7 @@ div.bettertabs ul.tabs li a:link,
|
|
17
17
|
div.bettertabs ul.tabs li a:visited { color: #444; }
|
18
18
|
div.bettertabs ul.tabs li a:hover { color: black; }
|
19
19
|
div.bettertabs ul.tabs li a:active { color: blue; }
|
20
|
+
div.bettertabs ul.tabs li a.ajax-loading { color: #666; }
|
20
21
|
|
21
22
|
div.bettertabs div.content { padding: 1em; border: 1px solid #999; background-color: #eee; clear: left; }
|
22
23
|
div.bettertabs div.content.hidden { display: block; margin: 5px; border: 2px dashed #ccc; background-color: white; } /* display: none; to hide content */
|
@@ -1,51 +1,112 @@
|
|
1
|
+
# Some bettertabs specifications:
|
2
|
+
#
|
3
|
+
# * Should always work with javascript disabled (using the urls of the tabs links)
|
4
|
+
# * The bettertabs hepler should accept:
|
5
|
+
# * args: (bettertabs_id, options)
|
6
|
+
# * options can be:
|
7
|
+
# * :selected_tab => tab_id to select by default
|
8
|
+
# * :selected_tab should be overridden with params[:"#{bettertabs_id}_selected_tab"] if present
|
9
|
+
# * any other option is used as wrapper html_options (wrapper is the top-level widget dom element).
|
10
|
+
# * The bettertabs helper should render clear markup:
|
11
|
+
# * A wrapper with class 'bettertabs'
|
12
|
+
# * Tabs markup
|
13
|
+
# * ul.tabs > li > a
|
14
|
+
# * selected tab is ul.tabs > li.active > a
|
15
|
+
# * each a element has element attributes:
|
16
|
+
# * data-tab-type (for javascript: change click behavior depending on type "static", "link" or "ajax")
|
17
|
+
# * data-show-content-id (for javascript: element id to show when select this tab)
|
18
|
+
# * sections for each tab content.
|
19
|
+
# * use a unique html id (based on bettertabs_id and tab_id) for each Tab and Content
|
20
|
+
# * The bettertabs builder ".from" method should accept:
|
21
|
+
# * args: (tab_id, tab_name, options, &block)
|
22
|
+
# * args: (tab_id, options, &block)
|
23
|
+
# * If block_given? the block is used as content related to this tab
|
24
|
+
# * options can be:
|
25
|
+
# * :partial => to use as content. Defaults to tab_id
|
26
|
+
# * if block_given? this option can not be used (if used, raise an error)
|
27
|
+
# * :url => for the tab link, that should go to this selected tab when javascript is disabled. Defaults to { :"#{bettertabs_id}_selected_tab" => tab_id }
|
28
|
+
# * :tab_type => used in the markup as the link data-tab-type value. Can be :static, :link or :ajax (or the corresponding strings). Raise error otherwise. Defaults to :static.
|
29
|
+
# * The bettertabs builder ".static", ".link" and ".ajax" methods are only a convenient way to use ".for" method with :tab_type set to :static, :link or :ajax respectively.
|
30
|
+
# * Content is rendered only for active tab, except when tab_type is :static, where content is always rendered (ready to show when select that tab using javascript).
|
31
|
+
# * When ajax call (format.js), the bettertabs helper should return ONLY the content of the selected tab (to simplify the controller render partial calls.).
|
32
|
+
#
|
33
|
+
|
1
34
|
require 'spec_helper'
|
2
35
|
|
3
36
|
describe "Bettertabs requests" do
|
4
37
|
describe "GET /bettertabs/static" do
|
38
|
+
before(:all) { get '/bettertabs/static' }
|
39
|
+
|
5
40
|
it "has a 200 status code" do
|
6
|
-
get '/bettertabs/static'
|
7
41
|
response.status.should be(200)
|
8
42
|
end
|
9
43
|
|
10
44
|
it "should render all content even for hidden tabs" do
|
11
|
-
|
12
|
-
response.body.should include("Content for
|
13
|
-
response.body.should include("Content for tab2")
|
45
|
+
response.body.should include("Content for static_tab_1")
|
46
|
+
response.body.should include("Content for static_tab_2")
|
14
47
|
response.body.should include("tab_content partial content")
|
15
48
|
end
|
49
|
+
|
50
|
+
it "should not include the attribute data-ajax-url in static tabs" do
|
51
|
+
response.body.should_not include("data-ajax-url")
|
52
|
+
end
|
16
53
|
end
|
17
54
|
|
18
55
|
describe "GET /bettertabs/link_tab_1" do
|
56
|
+
before(:all) { get '/bettertabs/link_tab_1' }
|
19
57
|
it "has a 200 status code" do
|
20
|
-
get '/bettertabs/link_tab_1'
|
21
58
|
response.status.should be(200)
|
22
59
|
end
|
60
|
+
|
61
|
+
it "should not include the attribute data-ajax-url in link tabs" do
|
62
|
+
response.body.should_not include("data-ajax-url")
|
63
|
+
end
|
64
|
+
|
23
65
|
end
|
24
66
|
|
25
67
|
describe "GET /bettertabs/link_tab_2" do
|
68
|
+
before(:all) { get '/bettertabs/link_tab_2' }
|
26
69
|
it "has a 200 status code" do
|
27
|
-
get '/bettertabs/link_tab_2'
|
28
70
|
response.status.should be(200)
|
29
71
|
end
|
30
72
|
end
|
31
73
|
|
32
74
|
describe "GET /bettertabs/ajax" do
|
75
|
+
before(:all) { get '/bettertabs/ajax' }
|
33
76
|
it "has a 200 status code" do
|
34
|
-
get '/bettertabs/ajax'
|
35
77
|
response.status.should be(200)
|
36
78
|
end
|
79
|
+
|
80
|
+
it "should include the attribute data-ajax-url in ajax tabs" do
|
81
|
+
response.body.should include("data-ajax-url")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should include the default ajax=true extra param in the data-ajax-url" do
|
85
|
+
response.body.should include("data-ajax-url=\"/bettertabs/ajax?ajax_selected_tab=ajax_tab_2&ajax=true\"")
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should render only the selected tab content" do
|
89
|
+
response.body.should include("Content for the ajax_tab_1")
|
90
|
+
response.body.should_not include("Content for the ajax_tab_2")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should select another tab if requested in the URL" do
|
94
|
+
get '/bettertabs/ajax?ajax_selected_tab=ajax_tab_2'
|
95
|
+
response.body.should_not include("Content for the ajax_tab_1")
|
96
|
+
response.body.should include("Content for the ajax_tab_2")
|
97
|
+
end
|
37
98
|
end
|
38
99
|
|
39
100
|
describe "GET /bettertabs/mixed" do
|
101
|
+
before(:all) { get '/bettertabs/mixed' }
|
40
102
|
it "has a 200 status code" do
|
41
|
-
get '/bettertabs/mixed'
|
42
103
|
response.status.should be(200)
|
43
104
|
end
|
44
105
|
end
|
45
106
|
|
46
107
|
describe "GET /bettertabs/mixed_with_erb" do
|
108
|
+
before(:all) { get '/bettertabs/mixed_with_erb' }
|
47
109
|
it "has a 200 status code" do
|
48
|
-
get '/bettertabs/mixed_with_erb'
|
49
110
|
response.status.should be(200)
|
50
111
|
end
|
51
112
|
end
|
metadata
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bettertabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
version: "1.0"
|
4
|
+
prerelease:
|
5
|
+
version: "1.1"
|
9
6
|
platform: ruby
|
10
7
|
authors:
|
11
8
|
- Mario Izquierdo
|
@@ -13,11 +10,10 @@ autorequire:
|
|
13
10
|
bindir: bin
|
14
11
|
cert_chain: []
|
15
12
|
|
16
|
-
date: 2011-04-
|
17
|
-
default_executable:
|
13
|
+
date: 2011-04-28 00:00:00 Z
|
18
14
|
dependencies: []
|
19
15
|
|
20
|
-
description: "
|
16
|
+
description: "Bettertabs Rails helper (and jQuery plugin) defines the markup for a tabbed area in a easy and declarative way, using the appropiate JavaScript but ensuring accessibility and usability, no matter if the content is loaded statically, via ajax or the tabs are links. In the other hand, the CSS styles are up to you. "
|
21
17
|
email:
|
22
18
|
- tothemario@gmail.com
|
23
19
|
executables: []
|
@@ -28,6 +24,8 @@ extra_rdoc_files: []
|
|
28
24
|
|
29
25
|
files:
|
30
26
|
- .gitignore
|
27
|
+
- CHANGELOG
|
28
|
+
- EXAMPLES.md
|
31
29
|
- Gemfile
|
32
30
|
- Gemfile.lock
|
33
31
|
- README.md
|
@@ -40,6 +38,7 @@ files:
|
|
40
38
|
- lib/bettertabs/javascripts/jquery.bettertabs.coffee
|
41
39
|
- lib/bettertabs/javascripts/jquery.bettertabs.js
|
42
40
|
- lib/bettertabs/javascripts/jquery.bettertabs.min.js
|
41
|
+
- lib/bettertabs/stylesheets/README.md
|
43
42
|
- lib/bettertabs/version.rb
|
44
43
|
- test/README_for_TEST.txt
|
45
44
|
- test/ruby_1_9/rails_3_0/.rspec
|
@@ -78,7 +77,7 @@ files:
|
|
78
77
|
- test/ruby_1_9/rails_3_0/public/favicon.ico
|
79
78
|
- test/ruby_1_9/rails_3_0/public/images/rails.png
|
80
79
|
- test/ruby_1_9/rails_3_0/public/javascripts/jquery-1.5.2.min.js
|
81
|
-
- test/ruby_1_9/rails_3_0/public/javascripts/jquery.bettertabs.
|
80
|
+
- test/ruby_1_9/rails_3_0/public/javascripts/jquery.bettertabs.js
|
82
81
|
- test/ruby_1_9/rails_3_0/public/javascripts/rails.js
|
83
82
|
- test/ruby_1_9/rails_3_0/public/robots.txt
|
84
83
|
- test/ruby_1_9/rails_3_0/public/stylesheets/bettertabs.css
|
@@ -86,8 +85,7 @@ files:
|
|
86
85
|
- test/ruby_1_9/rails_3_0/script/rails
|
87
86
|
- test/ruby_1_9/rails_3_0/spec/requests/bettertabs_spec.rb
|
88
87
|
- test/ruby_1_9/rails_3_0/spec/spec_helper.rb
|
89
|
-
|
90
|
-
homepage: ""
|
88
|
+
homepage: https://github.com/agoragames/bettertabs
|
91
89
|
licenses: []
|
92
90
|
|
93
91
|
post_install_message:
|
@@ -100,23 +98,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
98
|
requirements:
|
101
99
|
- - ">="
|
102
100
|
- !ruby/object:Gem::Version
|
103
|
-
segments:
|
104
|
-
- 0
|
105
101
|
version: "0"
|
106
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
103
|
none: false
|
108
104
|
requirements:
|
109
105
|
- - ">="
|
110
106
|
- !ruby/object:Gem::Version
|
111
|
-
segments:
|
112
|
-
- 0
|
113
107
|
version: "0"
|
114
108
|
requirements: []
|
115
109
|
|
116
110
|
rubyforge_project: bettertabs
|
117
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.7.2
|
118
112
|
signing_key:
|
119
113
|
specification_version: 3
|
120
|
-
summary: The better (simple, accessible, usable, flexible and fast) way to split content in tabs.
|
114
|
+
summary: The better (simple, accessible, usable, flexible and fast) way to split content in tabs for Rails.
|
121
115
|
test_files: []
|
122
116
|
|
@@ -1,4 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Bettertabs jQuery plugin v1.0
|
3
|
-
*/
|
4
|
-
(function(){var e,b,d,c,a,f;e=jQuery;a="data-tab-type";c="data-show-content-id";f=function(g){return g.attr(a)};d=function(g){return g.attr(c)};b=function(g){var h;if((typeof history!="undefined"&&history!==null)&&(history.replaceState!=null)){h=g.attr("href");return history.replaceState(null,document.title,h)}};e.fn.bettertabs=function(){return this.each(function(){var k,h,j,g,i;k=e(this);h=k.find("ul.tabs > li");i=k.find("ul.tabs > li > a");g=k.children(".content");j=h.add(g);return i.click(function(o){var q,r,n,m,p,l;m=e(this);if(f(m)!=="link"){o.preventDefault();p=m.parent();if(!p.is(".active")&&!m.is(".ajax-loading")){l=g.filter("#"+(d(m)));r=h.filter(".active");n=g.filter(".active");q=function(){j.removeClass("active").addClass("hidden");p.removeClass("hidden").addClass("active");l.removeClass("hidden").addClass("active");n.trigger("bettertabs-after-deactivate");l.trigger("bettertabs-after-activate");return b(m)};n.trigger("bettertabs-before-deactivate");l.trigger("bettertabs-before-activate");if(f(m)==="ajax"&&!(m.data("content-loaded-already")!=null)){m.addClass("ajax-loading");l.trigger("bettertabs-before-ajax-loading");return l.load(m.attr("href"),function(){m.removeClass("ajax-loading");m.data("content-loaded-already",true);l.trigger("bettertabs-after-ajax-loading");return q()})}else{return q()}}}})})}}).call(this);
|