cd2_tabs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +34 -0
- data/app/assets/stylesheets/tabs.sass +43 -0
- data/lib/cd2_tabs/engine.rb +4 -0
- data/lib/cd2_tabs/tab_helper.rb +59 -0
- data/lib/cd2_tabs/version.rb +3 -0
- data/lib/cd2_tabs.rb +7 -0
- data/lib/tasks/cd2_tabs_tasks.rake +4 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 116a6ed00e6e13930e3532aa63d4f5b1bb7b490c
|
4
|
+
data.tar.gz: fb460e005cab7f54cdf9cbb63999884238841124
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01d419ba771ed2c40c99178d8dddb7624f2c75aadd0ab4e137f2ebba844e8275366a43e7cbcdd1ea3a108104d1993520190d61fcd1759a5bec1947f38ee3ca26
|
7
|
+
data.tar.gz: 044e1dcbbe94badfcbd9796fc28bca5e0cd2211fb9f1c272c73f88f8341dcf2e29817d4b487e1b7173fcb2fd1321dd158611d5124fca7058cba498d1f35049e8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Cd2Tabs
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'cd2_tabs'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install cd2_tabs
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Cd2Tabs'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,43 @@
|
|
1
|
+
.tabs_container
|
2
|
+
input[type='radio'].tab_controller
|
3
|
+
display: none
|
4
|
+
@for $i from 1 through 10
|
5
|
+
&:nth-child(#{$i}):checked ~
|
6
|
+
.tab_heads_container
|
7
|
+
label:nth-child(#{$i})
|
8
|
+
border-bottom: 2px solid #aaa
|
9
|
+
color: black
|
10
|
+
.sub_tabs_container &
|
11
|
+
color: white
|
12
|
+
font-weight: 800
|
13
|
+
.tab_panels_container
|
14
|
+
> .tab_panel:nth-child(#{$i})
|
15
|
+
display: block
|
16
|
+
|
17
|
+
.tab_panel
|
18
|
+
display: none
|
19
|
+
|
20
|
+
.tab_heads_container
|
21
|
+
border-bottom: 1px solid #d1d5d7
|
22
|
+
padding: 0 20px
|
23
|
+
.sub_tabs_container &
|
24
|
+
background: #aaa
|
25
|
+
label
|
26
|
+
display: inline-block
|
27
|
+
padding: 28px 0 16px
|
28
|
+
margin: 0 10px
|
29
|
+
cursor: pointer
|
30
|
+
font-weight: 400
|
31
|
+
text-transform: none
|
32
|
+
color: #999
|
33
|
+
font-size: 14px
|
34
|
+
transition: color 0.3s
|
35
|
+
.sub_tabs_container &
|
36
|
+
padding: 10px 0
|
37
|
+
color: white
|
38
|
+
|
39
|
+
.tab_panel
|
40
|
+
background: white
|
41
|
+
padding: 24px
|
42
|
+
&.sub_tabs_container
|
43
|
+
padding: 0
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module TabHelper
|
2
|
+
|
3
|
+
def tab_controller control_name, checked=nil
|
4
|
+
checked ||= true if !content_for?("tab_controllers_#{@tab_group_name.last}")
|
5
|
+
content = radio_button_tag("tab_#{@tab_group_name.last}", control_name, (checked || params[:tab]==control_name.to_s), class: 'tab_controller')
|
6
|
+
content_for "tab_controllers_#{@tab_group_name.last}", content
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def tab_head control_name, text=nil
|
11
|
+
text ||= control_name.to_s.humanize
|
12
|
+
content_for "tab_heads_#{@tab_group_name.last}", label_tag("tab_#{@tab_group_name.last}_#{control_name}", text, class: control_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def tab control_name, *args, &block
|
16
|
+
opts = args.extract_options!
|
17
|
+
|
18
|
+
tab_name = opts.delete(:tab_head) { args[0] }
|
19
|
+
checked = opts.delete(:checked) { args[1] }
|
20
|
+
condition = opts.delete(:if) { args[2] }
|
21
|
+
|
22
|
+
return if condition.present? && condition.call==false
|
23
|
+
|
24
|
+
if checked.nil? && !!tab_name==tab_name
|
25
|
+
checked, tab_name = tab_name, nil
|
26
|
+
end
|
27
|
+
|
28
|
+
tab_controller control_name, checked
|
29
|
+
tab_head control_name, tab_name
|
30
|
+
|
31
|
+
opts[:class] ||= []
|
32
|
+
opts[:class] = [opts[:class]].flatten(1)
|
33
|
+
opts[:class].push('tab_panel')
|
34
|
+
|
35
|
+
content = capture(&block) if block
|
36
|
+
content_for "tab_panels_#{@tab_group_name.last}", content_tag(:div, content, opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
def tabs group_name=nil, &block
|
40
|
+
@tab_group_name ||= []
|
41
|
+
@tab_group_name.push group_name || rand
|
42
|
+
content = capture &block if block
|
43
|
+
|
44
|
+
tab_controllers = @view_flow.content.delete "tab_controllers_#{@tab_group_name.last}"
|
45
|
+
tab_heads = @view_flow.content.delete "tab_heads_#{@tab_group_name.last}"
|
46
|
+
tab_panels = @view_flow.content.delete "tab_panels_#{@tab_group_name.last}"
|
47
|
+
|
48
|
+
@tab_group_name.pop
|
49
|
+
|
50
|
+
return unless tab_controllers
|
51
|
+
|
52
|
+
content_tag :div, class: 'tabs_container' do
|
53
|
+
tab_controllers +
|
54
|
+
content_tag(:div, tab_heads, class: 'tab_heads_container') +
|
55
|
+
content_tag(:div, tab_panels, class: 'tab_panels_container')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/lib/cd2_tabs.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cd2_tabs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CD2
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.0.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 5.0.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.0.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sass-rails
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '5.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: Generates tabs using css
|
62
|
+
email:
|
63
|
+
- hello@cd2solutions.co.uk
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- MIT-LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- app/assets/stylesheets/tabs.sass
|
72
|
+
- lib/cd2_tabs.rb
|
73
|
+
- lib/cd2_tabs/engine.rb
|
74
|
+
- lib/cd2_tabs/tab_helper.rb
|
75
|
+
- lib/cd2_tabs/version.rb
|
76
|
+
- lib/tasks/cd2_tabs_tasks.rake
|
77
|
+
homepage: https://cd2solutions.co.uk
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.5.1
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Generates tabs using css
|
101
|
+
test_files: []
|