tab_builder 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjU1NmQxNjJiZTRkYmE2Mzk0NWJkZmVmOTUzMTNkZGE1Y2JhZGMxYg==
5
+ data.tar.gz: !binary |-
6
+ MzY4YzI0OWE4MGJjM2U1ZGZmYmM5MGNhNDcyNzUxNGM3ZDE3OGE0ZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZGQyZTE3ZWI4M2E2MzdkOGMzZThkOWY5ZGQyZDI3ZTZiOGJiZmI0NjQ5ZDc1
10
+ YTc5YzE4NmE4YWMxOGQ5MDI1MTQ1MWFlZmQ0YTU4NDA0ZmUzMTkzMmJiNWI4
11
+ ZmYyNzVlMTQxYzY1MDFiMmRkMWNhN2RmMDYwYmIyZTM2MmIwNDM=
12
+ data.tar.gz: !binary |-
13
+ NDAwYWFiMjRjZDhmMGY4MmU1OTg4YzIwNGVhZWRhMTFhN2JmYTUxM2Y3ZTRi
14
+ NjA3NjIyNDgxMzY4Y2UxNGI4MjNjZDg4YTJlYTdmYjM0ZDNhNTdhYjY4OGY2
15
+ MjdiODE1ZDRlY2MwZjRjZTRjMDI4OWIxYTU2ZDU4MDdlNTBmMjY=
@@ -0,0 +1,107 @@
1
+ /*
2
+ * Sub Tabs (Within Main)
3
+ */
4
+
5
+ @import "compass/css3/border-radius";
6
+
7
+ $tab_color: #EEE;
8
+ $current_tab_color: #006EB6;
9
+
10
+ #main {
11
+ .tabstrip {
12
+ background-color: #FFFFFF;
13
+ width: 100%;
14
+ padding-top: 10px;
15
+ min-height: 30px;
16
+ border-bottom: 3px solid $current_tab_color;
17
+
18
+ ul.tabs {
19
+ list-style-type: none;
20
+ padding: 0;
21
+ margin: 0;
22
+ vertical-align: middle;
23
+
24
+ li.tab {
25
+ float: left;
26
+ padding: 0;
27
+ margin: 0;
28
+ min-height: 30px;
29
+ min-width: 80px;
30
+ margin-left: 4px;
31
+
32
+ text-decoration: none;
33
+ text-align: center;
34
+ font-family: "Arial";
35
+ font-weight: bold;
36
+ font-size: 14px;
37
+
38
+ background: $tab_color;
39
+
40
+ @include border-top-radius(8px);
41
+
42
+ a, a:hover, span {
43
+ text-decoration: none;
44
+ display: block;
45
+ padding: 5px 5px 5px 5px;
46
+ color: #000000;
47
+ }
48
+
49
+ .accessible_tooltip
50
+ {
51
+ a, span
52
+ {
53
+ padding: 0;
54
+ display: inherit;
55
+ }
56
+
57
+ a
58
+ {
59
+ display: inline-block;
60
+ position: relative;
61
+ top: 2px;
62
+
63
+ img.small-icon
64
+ {
65
+ position: relative;
66
+ top: 1px;
67
+ }
68
+ }
69
+
70
+ span.label
71
+ {
72
+ font-weight: bold;
73
+ cursor: pointer;
74
+ }
75
+
76
+ span.tooltip
77
+ {
78
+ color: inherit;
79
+ position: absolute;
80
+ text-align: left;
81
+ padding: 10px;
82
+ padding-left: 25px;
83
+ margin-left: 5px;
84
+ }
85
+ }
86
+
87
+ &.current {
88
+ background: $current_tab_color;
89
+
90
+ span {
91
+ color: #FFFFFF;
92
+
93
+ &.label
94
+ {
95
+ cursor: inherit;
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ .tab_content
104
+ {
105
+ padding-top: 15px;
106
+ }
107
+ }
@@ -0,0 +1,69 @@
1
+ module TabBuilder
2
+ class TabPresenter
3
+ attr_reader :tab
4
+ delegate :name, :options, to: :tab
5
+
6
+ def initialize(template, tab)
7
+ @tab = tab
8
+ @template = template
9
+ end
10
+
11
+ def classes
12
+ (current? ? %w(tab current) : %w(tab)).join(" ")
13
+ end
14
+
15
+ def title
16
+ tab.tooltip ? tooltip : label
17
+ end
18
+
19
+ private
20
+
21
+ def label
22
+ current? ? content_tag(:span, name) : link_to(name, url)
23
+ end
24
+
25
+ def tooltip
26
+ t = tab.options[:tooltip]
27
+ options = t.slice(:title, :icon)
28
+ options[:label] = content_tag(:span, name)
29
+
30
+ unless current?
31
+ options[:link] = { onclick: nil }
32
+ options[:url] = url
33
+ end
34
+
35
+ accessible_tooltip(t.fetch(:type, :help), options) { t[:text] }
36
+ end
37
+
38
+ def url
39
+ tab.root.url if tab.root
40
+ end
41
+
42
+ def method_missing(*args, &block)
43
+ return @template.send(*args, &block) if @template.respond_to?(args.first)
44
+ super
45
+ end
46
+
47
+ def respond_to_missing?(*args)
48
+ return true if @template.respond_to?(*args)
49
+ super
50
+ end
51
+
52
+ def current?
53
+ if !tab.current.nil?
54
+ current = (tab.current.call === true)
55
+ else
56
+ tab.paths.each do |path|
57
+ if p = Rails.application.routes.recognize_path(path.url, method: path[:method])
58
+ current = (p[:controller] == params[:controller] and p[:action] == params[:action])
59
+ break if current
60
+ end
61
+ end
62
+
63
+ current = (tab.controller == params[:controller]) unless current
64
+ end
65
+
66
+ current
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,3 @@
1
+ - TabBuilder::TabPresenter.new(self, tab).tap do |t|
2
+ %li{ class: t.classes }
3
+ = t.title
@@ -0,0 +1,4 @@
1
+ .tabstrip
2
+ %ul.tabs
3
+ - tabs.each do |tab|
4
+ = render partial: 'tab_builder/tab', locals: { tab: tab }
@@ -4,47 +4,16 @@ module TabBuilder
4
4
  @context = context
5
5
 
6
6
  content_for :style do
7
- stylesheet_link_tag "tabbed"
7
+ stylesheet_link_tag 'tab_builder'
8
8
  end
9
9
 
10
10
  out = ActiveSupport::SafeBuffer.new
11
- out << content_tag(:div, :class => 'tabstrip') do
12
- content_tag(:ul, :class => 'tabs') do
13
- tabset.inject(ActiveSupport::SafeBuffer.new) do |html, tab|
14
- current = false
11
+ out << render(partial: 'tab_builder/tab_strip', locals: { tabs: tabset })
15
12
 
16
- if !tab.current.nil?
17
- current = (tab.current.call === true)
18
- else
19
- tab.paths.each do |path|
20
- if p = Rails.application.routes.recognize_path(path.url, :method => path[:method])
21
- current = (p[:controller] == params[:controller] and p[:action] == params[:action])
22
- break if current
23
- end
24
- end
25
-
26
- current = (tab.controller == params[:controller]) unless current
27
- end
28
-
29
- if current
30
- html << content_tag(:li, :class => "tab current") do
31
- content_tag(:span, tab.name)
32
- end
33
- else
34
- html << content_tag(:li, :class => "tab") do
35
- link_to(tab.name, tab.root.url)
36
- end
37
- end
38
-
39
- html
40
- end
41
- end
42
- end
43
-
44
13
  out << content_tag(:div, :class => "tab_content") do
45
14
  content_tag(:div, :class => 'tab_content_inner') { @context.capture(&block) }
46
15
  end if block_given?
47
-
16
+
48
17
  out
49
18
  end
50
19
 
@@ -0,0 +1,8 @@
1
+ module TabBuilder
2
+ class Engine < ::Rails::Engine
3
+ initializer :assets do |config|
4
+ Rails.application.config.assets.precompile += %w{ tab_builder.css }
5
+ Rails.application.config.assets.paths << root.join("app", "assets", "stylesheets")
6
+ end
7
+ end
8
+ end
@@ -1,12 +1,10 @@
1
1
  module TabBuilder
2
2
  class Tab
3
- attr_accessor :paths, :controller
3
+ attr_accessor :paths, :controller, :options
4
4
 
5
- delegate :options, :to => :@tabset
6
-
7
- def initialize(tabset, name, context, &block)
8
- @tabset = tabset
5
+ def initialize(name, options, context, &block)
9
6
  @name = name
7
+ @options = options
10
8
  @context = context
11
9
  @current = nil
12
10
 
@@ -48,6 +46,10 @@ module TabBuilder
48
46
  @current
49
47
  end
50
48
 
49
+ def tooltip
50
+ @options[:tooltip]
51
+ end
52
+
51
53
  def method_missing(name, *args, &block)
52
54
  # Pass methods along to the context, if it responds to them (allows for helpers, etc. to be used):
53
55
  if @context.respond_to? name
@@ -31,7 +31,8 @@ module TabBuilder
31
31
  end
32
32
 
33
33
  def method_missing(name, *args, &block)
34
- tab = Tab.new(self, name, @context, &block)
34
+ options = args.extract_options!
35
+ tab = Tab.new(name, @options.merge(options), @context, &block)
35
36
  self << tab
36
37
  end
37
38
  end
@@ -1,3 +1,3 @@
1
1
  module TabBuilder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/tab_builder.rb CHANGED
@@ -1,6 +1,7 @@
1
- require "open_hash"
2
- require "tab_builder/version"
3
- require "tab_builder/tab_set"
4
- require "tab_builder/tab"
5
- require "tab_builder/builder"
6
- require "tab_builder/drawer"
1
+ require 'open_hash'
2
+ require 'tab_builder/engine'
3
+ require 'tab_builder/version'
4
+ require 'tab_builder/tab_set'
5
+ require 'tab_builder/tab'
6
+ require 'tab_builder/builder'
7
+ require 'tab_builder/drawer'
data/tab_builder.gemspec CHANGED
@@ -17,8 +17,12 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency "i18n"
21
- gem.add_dependency "activesupport", "> 3.0.0"
22
- gem.add_dependency "actionpack", "> 3.0.0"
23
- gem.add_dependency "railties", "> 3.0.0"
20
+ gem.add_dependency 'i18n'
21
+ gem.add_dependency 'activesupport', '> 3.0.0'
22
+ gem.add_dependency 'actionpack', '> 3.0.0'
23
+ gem.add_dependency 'railties', '> 3.0.0'
24
+ gem.add_dependency 'haml', '~> 4.0.0'
25
+ gem.add_dependency 'sass-rails'
26
+ gem.add_dependency 'compass-rails'
27
+ gem.add_dependency 'accessible_tooltip'
24
28
  end
metadata CHANGED
@@ -1,80 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tab_builder
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Vandersluis
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-23 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- prerelease: false
16
14
  type: :runtime
15
+ prerelease: false
16
+ name: i18n
17
17
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
18
  requirements:
20
19
  - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
21
  version: '0'
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
- none: false
25
23
  requirements:
26
24
  - - ! '>='
27
25
  - !ruby/object:Gem::Version
28
26
  version: '0'
29
- name: i18n
30
27
  - !ruby/object:Gem::Dependency
31
- prerelease: false
32
28
  type: :runtime
29
+ prerelease: false
30
+ name: activesupport
33
31
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
32
  requirements:
36
33
  - - ! '>'
37
34
  - !ruby/object:Gem::Version
38
35
  version: 3.0.0
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
- none: false
41
37
  requirements:
42
38
  - - ! '>'
43
39
  - !ruby/object:Gem::Version
44
40
  version: 3.0.0
45
- name: activesupport
46
41
  - !ruby/object:Gem::Dependency
47
- prerelease: false
48
42
  type: :runtime
43
+ prerelease: false
44
+ name: actionpack
49
45
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
47
  - - ! '>'
53
48
  - !ruby/object:Gem::Version
54
49
  version: 3.0.0
55
50
  version_requirements: !ruby/object:Gem::Requirement
56
- none: false
57
51
  requirements:
58
52
  - - ! '>'
59
53
  - !ruby/object:Gem::Version
60
54
  version: 3.0.0
61
- name: actionpack
62
55
  - !ruby/object:Gem::Dependency
63
- prerelease: false
64
56
  type: :runtime
57
+ prerelease: false
58
+ name: railties
65
59
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
60
  requirements:
68
61
  - - ! '>'
69
62
  - !ruby/object:Gem::Version
70
63
  version: 3.0.0
71
64
  version_requirements: !ruby/object:Gem::Requirement
72
- none: false
73
65
  requirements:
74
66
  - - ! '>'
75
67
  - !ruby/object:Gem::Version
76
68
  version: 3.0.0
77
- name: railties
69
+ - !ruby/object:Gem::Dependency
70
+ type: :runtime
71
+ prerelease: false
72
+ name: haml
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 4.0.0
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 4.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ type: :runtime
85
+ prerelease: false
86
+ name: sass-rails
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ type: :runtime
99
+ prerelease: false
100
+ name: compass-rails
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ type: :runtime
113
+ prerelease: false
114
+ name: accessible_tooltip
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
78
125
  description: DSL for building tabbed containers in Rails
79
126
  email:
80
127
  - dvandersluis@selfmgmt.com
@@ -87,37 +134,41 @@ files:
87
134
  - LICENSE.txt
88
135
  - README.md
89
136
  - Rakefile
137
+ - app/assets/stylesheets/tab_builder.css.scss
138
+ - app/classes/tab_builder/tab_presenter.rb
139
+ - app/views/tab_builder/_tab.haml
140
+ - app/views/tab_builder/_tab_strip.haml
90
141
  - lib/open_hash.rb
91
142
  - lib/tab_builder.rb
92
143
  - lib/tab_builder/builder.rb
93
144
  - lib/tab_builder/drawer.rb
145
+ - lib/tab_builder/engine.rb
94
146
  - lib/tab_builder/tab.rb
95
147
  - lib/tab_builder/tab_set.rb
96
148
  - lib/tab_builder/version.rb
97
149
  - tab_builder.gemspec
98
150
  homepage: https://github.com/dvandersluis/tab_builder
99
151
  licenses: []
152
+ metadata: {}
100
153
  post_install_message:
101
154
  rdoc_options: []
102
155
  require_paths:
103
156
  - lib
104
157
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
158
  requirements:
107
159
  - - ! '>='
108
160
  - !ruby/object:Gem::Version
109
161
  version: '0'
110
162
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
163
  requirements:
113
164
  - - ! '>='
114
165
  - !ruby/object:Gem::Version
115
166
  version: '0'
116
167
  requirements: []
117
168
  rubyforge_project:
118
- rubygems_version: 1.8.24
169
+ rubygems_version: 2.1.5
119
170
  signing_key:
120
- specification_version: 3
171
+ specification_version: 4
121
172
  summary: DSL for building tabbed containers in Rails
122
173
  test_files: []
123
174
  has_rdoc: