bettertabs 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d5e79ce335fbcdf9f066d26895489c7ba7a9a618
4
+ data.tar.gz: 66ffe69bc3cce378572156a6387f36bdc4c0bd45
5
+ SHA512:
6
+ metadata.gz: 0df7a14d5b0ab4499619abca8ebb0e104ab229947caf5c6dfadc3769f83fc39366b04ef78c64a4f04d0ba1548fd9b6279f95118234f40ce2f6916ff01ff07041
7
+ data.tar.gz: 42f2ed91ee5c4b6ecc215c9f54edb1c7c3aed6e1655d6f5078b1fb71f84ecc3df646147ca73e418f69731c60c45e44f0d5fce81c272efa5217950310a17b7878
@@ -1,6 +1,10 @@
1
1
  Bettertabs Changelog
2
2
  ====================
3
3
 
4
+ ### v1.4.2 (2014-11-10)
5
+
6
+ * Add option :list_item_html_options to specify the attributes on the rendered li elements for tabs. Thanks (@jskinner-arpc).
7
+
4
8
  ### v1.4.1 (2013-02-27)
5
9
 
6
10
  * Ensure BettertabsHelper is included even if config.action_controller.include_all_helpers is false, https://github.com/agoragames/bettertabs/pull/13
@@ -1,4 +1,4 @@
1
- Copyright 2013 Mario Izquierdo
1
+ Copyright 2013-2014 Mario Izquierdo
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,24 +1,30 @@
1
1
  Bettertabs for Rails
2
2
  ====================
3
3
 
4
- We know that splitting content into several tabs is easy, but doing well, clean, DRY, accessible, usable, fast and testable is not so simple after all.
4
+ We know that splitting content into several tabs is easy, but doing it well, clean, DRY, accessible, usable, testable and fast is not so simple after all.
5
5
 
6
- Bettertabs is a simple `Rails 3.1+ Engine` that includes a **helper** and a **jquery plugin** to render the needed markup and javascript for a section with tabs in a easy and declarative way, forcing you to keep things simple and ensuring accessibility and usability, no matter if the content is loaded statically or via ajax.
6
+ Bettertabs is a `Rails 3.1+ Engine` that includes a **helper** and a **jquery plugin** to render the needed markup and javascript for a section with tabs in a declarative way, forcing you to [KISS](http://en.wikipedia.org/wiki/KISS_principle), ensuring accessibility and usability, whether the content is loaded statically or via ajax.
7
7
 
8
+ [Try demo app online](http://bettertabs-demo.herokuapp.com)
8
9
 
9
10
  ## Features ##
10
11
 
11
- Having to worry only on a few aspects like putting the content in the right site, you will have a site with tabs that:
12
+ Bettertabs allows for a site with tabs that:
12
13
 
13
14
  * Works with tabs for static, links or ajax loaded content
14
- * Works without javascript, so you can click on a tab before the whole page was loaded and it will work. Also it's usually much more easy to test.
15
- * It changes the URL (in HTML5 browsers, using [history.replaceState()](https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history)), so when you use the browser's back button, you'll land in the last selected tab. Also selected tabs can be permalinked.
15
+ * Works without javascript
16
+ * SEO-friendly, specially good for ajax loaded tabs, because search engines can access and index the content anyway
17
+ * Progressive enhancement, obviously it works in devices without JavaScript
18
+ * Click on a tab before the whole page was loaded and it still works
19
+ * Allows to open the content in a new window if neccessary
20
+ * Easy to test
21
+ * It changes the URL (in HTML5 browsers, using [history.replaceState()](https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history)), so when you use the browser's back button, you'll land in the last selected tab, and selected tabs can be permalinked.
16
22
  * Declarative code, that helps you to have your view code more readable and DRY
17
23
  * It has some basic error handling (like for example if the ajax loaded content returns an error, it redirects to the error page)
18
24
  * If you need more control in the javascript behavior, you can use some predefined jQuery events (for example: `$('#tabs').bind('bettertabs-before-ajax-loading', show_loading_clock);`)
19
25
  * The gem does not include any stylesheet, because each project has a different way of showing the tabs styles. Anyway the generated HTML is easy to style (see the [CSS Reference Guide](https://github.com/agoragames/bettertabs/blob/master/doc/STYLESHEETS-GUIDE.md))
20
26
 
21
- ## Try it out ##
27
+ ## Demo Test app ##
22
28
 
23
29
  The bettertabs gem includes a dummy test app, that is used for development (to execute rspec tests) and that can be easily launched to play with.
24
30
 
@@ -32,7 +38,7 @@ The bettertabs gem includes a dummy test app, that is used for development (to e
32
38
 
33
39
 
34
40
  ## Requirements: ##
35
- * Ruby 1.9
41
+ * Ruby 1.9 or higher
36
42
  * Rails 3.1 or higher
37
43
  * jQuery 1.3 or higher (but bettertabs also works without javascript)
38
44
 
@@ -1,12 +1,12 @@
1
1
  (function() {
2
2
  /*!
3
3
  jQuery Bettertabs Plugin
4
- version: 1.4.1 (Mar-12-2012)
4
+ version: 1.4.2 (Nov-10-2014)
5
5
  @requires jQuery v1.3 or later
6
6
 
7
7
  Examples and documentation at: https://github.com/agoragames/bettertabs
8
8
 
9
- Copyright (c) 2011 Mario Izquierdo (tothemario@gmail.com)
9
+ Copyright (c) 2011-2014 Mario Izquierdo (tothemario@gmail.com)
10
10
  Dual licensed under the MIT and GPL licenses:
11
11
  http://www.opensource.org/licenses/mit-license.php
12
12
  http://www.gnu.org/licenses/gpl.html
@@ -1,11 +1,11 @@
1
1
  ###!
2
2
  jQuery Bettertabs Plugin
3
- version: 1.4.1 (Mar-12-2012)
3
+ version: 1.4.2 (Nov-10-2014)
4
4
  @requires jQuery v1.3 or later
5
5
 
6
6
  Examples and documentation at: https://github.com/agoragames/bettertabs
7
7
 
8
- Copyright (c) 2011 Mario Izquierdo (tothemario@gmail.com)
8
+ Copyright (c) 2011-2014 Mario Izquierdo (tothemario@gmail.com)
9
9
  Dual licensed under the MIT and GPL licenses:
10
10
  http://www.opensource.org/licenses/mit-license.php
11
11
  http://www.gnu.org/licenses/gpl.html
@@ -1,12 +1,12 @@
1
1
  (function(){
2
2
  /*!
3
3
  jQuery Bettertabs Plugin
4
- version: 1.4.1 (Mar-12-2012)
4
+ version: 1.4.2 (Nov-10-2014)
5
5
  @requires jQuery v1.3 or later
6
6
 
7
7
  Examples and documentation at: https://github.com/agoragames/bettertabs
8
8
 
9
- Copyright (c) 2011 Mario Izquierdo (tothemario@gmail.com)
9
+ Copyright (c) 2011-2014 Mario Izquierdo (tothemario@gmail.com)
10
10
  Dual licensed under the MIT and GPL licenses:
11
11
  http://www.opensource.org/licenses/mit-license.php
12
12
  http://www.gnu.org/licenses/gpl.html
@@ -20,8 +20,10 @@ module BettertabsHelper
20
20
  # * :render_only_active_content => if true, this helper renders only the selected tab contents (no wrapper, no tabs, only content).
21
21
  # Default to true only if controller.request.xhr? or params[:ajax].present? (true when its an ajax request).
22
22
  # * :attach_jquery_bettertabs_inline => this helper includes a little inline script to apply the Bettertabs jQuery plugin to this widget. If false, do not render that inline script.
23
+ # * :list_html_options => html attributes on the <ul> element (list) for the tabs (added to 'tabs' that is automatically assigned)
24
+ # * :list_item_html_options => html attributes on the <li> elements (list items) for the tabs (added to 'tab' or 'tab active' class that is automatically assigned)
23
25
  # * :class => html class attribute of the wrapper element. By default is 'bettertabs'
24
- # * :id => html id attribute of the wrapper element. By default is the bettertabs_id
26
+ # * :id => html id attribute of the wrapper element. By default is the same value as `bettertabs_id` option.
25
27
  # * Any other option will be used as wrapper elmenet html attribute.
26
28
  #
27
29
  # ==== tab builder arguments
@@ -13,12 +13,13 @@ Gem::Specification.new do |s|
13
13
  s.homepage = "https://github.com/agoragames/bettertabs"
14
14
  s.summary = %q{Just a simple, accessible, usable, flexible and fast way to split view content in tabs in a rails application.}
15
15
  s.description = %q{Bettertabs is a Rails 3.1+ engine that adds a helper and jQuery plugin to define the markup and behavior 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 just with links. }
16
+ s.license = 'MIT'
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
-
19
+
19
20
  s.add_dependency "rails", ">= 3.1.0"
20
21
  s.add_dependency "jquery-rails"
21
-
22
+
22
23
  s.add_development_dependency 'rspec-rails'
23
24
  s.add_development_dependency 'haml-rails'
24
25
  end
@@ -8,6 +8,7 @@ class BettertabsBuilder
8
8
  @template = template
9
9
  @selected_tab_id = selected_tab_id
10
10
  @list_html_options = options.delete(:list_html_options) # sets html_options on the :ul element
11
+ @list_item_html_options = options.delete(:list_item_html_options) # sets html_options on the :li elements
11
12
  @render_only_active_content = options.delete(:render_only_active_content) # used in ajax calls
12
13
  @wrapper_html_options = options
13
14
 
@@ -110,21 +111,26 @@ class BettertabsBuilder
110
111
  content_tag(:div, @wrapper_html_options) do
111
112
 
112
113
  # Tabs list
113
- @list_html_options ||= {}
114
- @list_html_options[:class] ||= ''
115
- @list_html_options[:class] += @list_html_options[:class].empty? ? 'tabs' : ' tabs'
116
- content_tag(:ul, @list_html_options) do
117
- @tabs.map do |tab|
118
- content_tag(:li, class: ('active' if tab[:active]), id: tab_html_id_for(tab[:tab_id])) do
119
- tab[:html_options][:"data-tab-type"] ||= tab[:tab_type] # for javascript: change click behavior depending on type :static, :link or :ajax
120
- tab[:html_options][:"data-show-content-id"] ||= content_html_id_for(tab[:tab_id]) # for javascript: element id to show when select this tab
121
- tab[:html_options][:"data-ajax-url"] ||= tab[:ajax_url] if tab[:tab_type] == :ajax # for javascript: url to make ajax call
122
- tab[:html_options][:class] ||= ''
123
- tab[:html_options][:class] += 'active' if tab[:active]
124
- @template.link_to(tab[:text], tab[:url], tab[:html_options])
125
- end
126
- end.join.html_safe
127
- end +
114
+ @list_html_options ||= {}
115
+ @list_html_options[:class] ||= ''
116
+ @list_html_options[:class] += @list_html_options[:class].empty? ? 'tabs' : ' tabs'
117
+
118
+ @list_item_html_options ||= {}
119
+ @list_item_html_options[:class] ||= ''
120
+ @list_item_html_options[:class] += @list_item_html_options[:class].empty? ? 'tab' : ' tab'
121
+
122
+ content_tag(:ul, @list_html_options) do
123
+ @tabs.map do |tab|
124
+ content_tag(:li, tab_li_options(tab)) do
125
+ tab[:html_options][:"data-tab-type"] ||= tab[:tab_type] # for javascript: change click behavior depending on type :static, :link or :ajax
126
+ tab[:html_options][:"data-show-content-id"] ||= content_html_id_for(tab[:tab_id]) # for javascript: element id to show when select this tab
127
+ tab[:html_options][:"data-ajax-url"] ||= tab[:ajax_url] if tab[:tab_type] == :ajax # for javascript: url to make ajax call
128
+ tab[:html_options][:class] ||= ''
129
+ tab[:html_options][:class] += 'active' if tab[:active]
130
+ @template.link_to(tab[:text], tab[:url], tab[:html_options])
131
+ end
132
+ end.join.html_safe
133
+ end +
128
134
 
129
135
  # Content sections
130
136
  @contents.map do |content|
@@ -188,4 +194,12 @@ class BettertabsBuilder
188
194
  end
189
195
  end
190
196
 
197
+ # Gets the the html_options for the tab list_item element
198
+ def tab_li_options(tab)
199
+ options = @list_item_html_options.clone
200
+ options[:class] += ' active' if tab[:active]
201
+ options[:id] = tab_html_id_for(tab[:tab_id])
202
+ options
203
+ end
204
+
191
205
  end
@@ -1,3 +1,3 @@
1
1
  module Bettertabs
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
@@ -4,9 +4,10 @@
4
4
  # * The bettertabs hepler should accept:
5
5
  # * args: (bettertabs_id, options)
6
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
7
+ # * :selected_tab => tab_id to select by default.
8
+ # It is be overridden with request params[:"#{bettertabs_id}_selected_tab"] if present.
9
9
  # * :list_html_options => html_options for the :ul element
10
+ # * :list_item_html_options => html_options for the :li elements (each tab )
10
11
  # * any other option is used as wrapper html_options (wrapper is the top-level widget dom element).
11
12
  # * The bettertabs helper should render clear markup:
12
13
  # * A wrapper with class 'bettertabs'
@@ -79,6 +80,10 @@ describe "Bettertabs requests" do
79
80
  it "has a 200 status code" do
80
81
  response.status.should be(200)
81
82
  end
83
+
84
+ it 'should contain active on a list-item element' do
85
+ response.body.should have_selector("#tab2_link_tab[class*='active']")
86
+ end
82
87
  end
83
88
 
84
89
  describe "GET /bettertabs/ajax" do
@@ -91,6 +96,10 @@ describe "Bettertabs requests" do
91
96
  response.body.should include("data-ajax-url")
92
97
  end
93
98
 
99
+ it 'should include the default class=tab for the list_item' do
100
+ response.body.should have_selector("li.tab")
101
+ end
102
+
94
103
  it "should include the default ajax=true extra param in the data-ajax-url" do
95
104
  response.body.should include("data-ajax-url=\"/bettertabs/ajax/ajax_tab_2?ajax=true\"")
96
105
  end
metadata CHANGED
@@ -1,81 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bettertabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
5
- prerelease:
4
+ version: 1.4.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mario Izquierdo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-27 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.1.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.1.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: jquery-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: haml-rails
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
- description: ! 'Bettertabs is a Rails 3.1+ engine that adds a helper and jQuery plugin
69
+ description: 'Bettertabs is a Rails 3.1+ engine that adds a helper and jQuery plugin
79
70
  to define the markup and behavior for a tabbed area in a easy and declarative way,
80
71
  using the appropiate JavaScript but ensuring accessibility and usability, no matter
81
72
  if the content is loaded statically, via ajax or just with links. '
@@ -152,34 +143,28 @@ files:
152
143
  - spec/requests/bettertabs_spec.rb
153
144
  - spec/spec_helper.rb
154
145
  homepage: https://github.com/agoragames/bettertabs
155
- licenses: []
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
156
149
  post_install_message:
157
150
  rdoc_options: []
158
151
  require_paths:
159
152
  - lib
160
153
  required_ruby_version: !ruby/object:Gem::Requirement
161
- none: false
162
154
  requirements:
163
- - - ! '>='
155
+ - - '>='
164
156
  - !ruby/object:Gem::Version
165
157
  version: '0'
166
- segments:
167
- - 0
168
- hash: 3598349345553857565
169
158
  required_rubygems_version: !ruby/object:Gem::Requirement
170
- none: false
171
159
  requirements:
172
- - - ! '>='
160
+ - - '>='
173
161
  - !ruby/object:Gem::Version
174
162
  version: '0'
175
- segments:
176
- - 0
177
- hash: 3598349345553857565
178
163
  requirements: []
179
164
  rubyforge_project:
180
- rubygems_version: 1.8.23
165
+ rubygems_version: 2.0.14
181
166
  signing_key:
182
- specification_version: 3
167
+ specification_version: 4
183
168
  summary: Just a simple, accessible, usable, flexible and fast way to split view content
184
169
  in tabs in a rails application.
185
170
  test_files: []