twitter_bootstrap_builder 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +18 -18
  2. data/Gemfile +4 -4
  3. data/LICENSE +21 -21
  4. data/README.md +29 -29
  5. data/Rakefile +2 -2
  6. data/app/views/kaminari/twitter_bootstrap/_first_page.html.haml +15 -15
  7. data/app/views/kaminari/twitter_bootstrap/_gap.html.haml +8 -8
  8. data/app/views/kaminari/twitter_bootstrap/_last_page.html.haml +12 -12
  9. data/app/views/kaminari/twitter_bootstrap/_next_page.html.haml +13 -13
  10. data/app/views/kaminari/twitter_bootstrap/_page.html.haml +15 -15
  11. data/app/views/kaminari/twitter_bootstrap/_paginator.html.haml +20 -20
  12. data/app/views/kaminari/twitter_bootstrap/_prev_page.html.haml +13 -13
  13. data/lib/twitter_bootstrap_builder.rb +26 -26
  14. data/lib/twitter_bootstrap_builder/builders/base.rb +19 -19
  15. data/lib/twitter_bootstrap_builder/builders/drop_down_builder.rb +19 -19
  16. data/lib/twitter_bootstrap_builder/builders/drop_down_button_builder.rb +10 -10
  17. data/lib/twitter_bootstrap_builder/builders/drop_down_link_builder.rb +10 -10
  18. data/lib/twitter_bootstrap_builder/builders/fieldset_builder.rb +116 -116
  19. data/lib/twitter_bootstrap_builder/builders/form_builder.rb +10 -10
  20. data/lib/twitter_bootstrap_builder/builders/link_button_builder.rb +14 -14
  21. data/lib/twitter_bootstrap_builder/builders/nav_bar_builder.rb +24 -24
  22. data/lib/twitter_bootstrap_builder/builders/nav_container_builder.rb +38 -38
  23. data/lib/twitter_bootstrap_builder/builders/nav_list_builder.rb +37 -37
  24. data/lib/twitter_bootstrap_builder/builders/submit_button_builder.rb +14 -14
  25. data/lib/twitter_bootstrap_builder/builders/tab_builder.rb +22 -22
  26. data/lib/twitter_bootstrap_builder/builders/table_builder.rb +77 -77
  27. data/lib/twitter_bootstrap_builder/engine.rb +16 -16
  28. data/lib/twitter_bootstrap_builder/extensions/twitter_bootstrap_markup.rb +6 -6
  29. data/lib/twitter_bootstrap_builder/helpers/buttons_helper.rb +50 -50
  30. data/lib/twitter_bootstrap_builder/helpers/commons_helper.rb +148 -114
  31. data/lib/twitter_bootstrap_builder/helpers/dropdowns_helper.rb +32 -32
  32. data/lib/twitter_bootstrap_builder/version.rb +3 -3
  33. data/twitter_bootstrap_builder.gemspec +20 -20
  34. data/vendor/assets/javascripts/bootstrap.js +1737 -1737
  35. data/vendor/assets/javascripts/twitter_bootstrap_builder.js +27 -27
  36. data/vendor/assets/stylesheets/bootstrap.css +4914 -4914
  37. data/vendor/assets/stylesheets/twitter_bootstrap_builder.css +57 -33
  38. metadata +17 -7
@@ -1,38 +1,38 @@
1
- module TwitterBootstrapBuilder
2
- module Builders
3
- class NavListBuilder < Base
4
-
5
- def to_s
6
- nav_list = NavList.new
7
- nav_list.append template.capture(self, &block) if block
8
- nav_list.to_s
9
- end
10
-
11
- def header(text)
12
- NavHeader.new(text).html_safe
13
- end
14
-
15
- def link_to(*args, &block)
16
- options = args.select { |a| a.is_a?(Hash) }.first || {}
17
- if options[:active_if].is_a?(Proc) ? options[:active_if].call : options[:active_if]
18
- active_link_to(*args, &block)
19
- else
20
- Tag.block(:li, template.link_to(*args, &block)).html_safe
21
- end
22
- end
23
-
24
- def active_link_to(*args, &block)
25
- Tag.block(:li, template.link_to(*args, &block), class: 'active').html_safe
26
- end
27
-
28
- def divider
29
- Tag.block(:li, Divider.horizontal).html_safe
30
- end
31
-
32
- def custom(&block)
33
- Tag.block(:li, template.capture(self, &block)).html_safe
34
- end
35
-
36
- end
37
- end
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class NavListBuilder < Base
4
+
5
+ def to_s
6
+ nav_list = NavList.new
7
+ nav_list.append template.capture(self, &block) if block
8
+ nav_list.to_s
9
+ end
10
+
11
+ def header(text)
12
+ NavHeader.new(text).html_safe
13
+ end
14
+
15
+ def link_to(*args, &block)
16
+ options = args.select { |a| a.is_a?(Hash) }.first || {}
17
+ if options[:active_if].is_a?(Proc) ? options[:active_if].call : options[:active_if]
18
+ active_link_to(*args, &block)
19
+ else
20
+ Tag.block(:li, template.link_to(*args, &block)).html_safe
21
+ end
22
+ end
23
+
24
+ def active_link_to(*args, &block)
25
+ Tag.block(:li, template.link_to(*args, &block), class: 'active').html_safe
26
+ end
27
+
28
+ def divider
29
+ Tag.block(:li, Divider.horizontal).html_safe
30
+ end
31
+
32
+ def custom(&block)
33
+ Tag.block(:li, template.capture(self, &block)).html_safe
34
+ end
35
+
36
+ end
37
+ end
38
38
  end
@@ -1,15 +1,15 @@
1
- module TwitterBootstrapBuilder
2
- module Builders
3
- class SubmitButtonBuilder < Base
4
-
5
- def to_s
6
- submit = block ? Submit.new(*options[:args], &Proc.new {}) : Submit.new(*options[:args])
7
- submit.send(options[:type]) if options[:type]
8
- submit.send(options[:size]) if options[:size]
9
- submit.append template.capture(self, &block) if block
10
- submit.to_s
11
- end
12
-
13
- end
14
- end
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class SubmitButtonBuilder < Base
4
+
5
+ def to_s
6
+ submit = block ? Submit.new(*options[:args], &Proc.new {}) : Submit.new(*options[:args])
7
+ submit.send(options[:type]) if options[:type]
8
+ submit.send(options[:size]) if options[:size]
9
+ submit.append template.capture(self, &block) if block
10
+ submit.to_s
11
+ end
12
+
13
+ end
14
+ end
15
15
  end
@@ -1,23 +1,23 @@
1
- module TwitterBootstrapBuilder
2
- module Builders
3
- class TabBuilder < Base
4
-
5
- def initialize(*args, &block)
6
- super
7
- @tab = Tab.new
8
- end
9
-
10
- def to_s
11
- template.capture(self, &block) if block
12
- @tab.to_s
13
- end
14
-
15
- def content_for(text, id=nil, &block)
16
- id = text.parameterize('_') unless id
17
- @tab.nav.append NavTab.new(text, "##{id}")
18
- @tab.content.append id, template.capture(self, &block) if block_given?
19
- end
20
-
21
- end
22
- end
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class TabBuilder < Base
4
+
5
+ def initialize(*args, &block)
6
+ super
7
+ @tab = Tab.new
8
+ end
9
+
10
+ def to_s
11
+ template.capture(self, &block) if block
12
+ @tab.to_s
13
+ end
14
+
15
+ def content_for(text, id=nil, &block)
16
+ id = text.parameterize('_') unless id
17
+ @tab.nav.append NavTab.new(text, "##{id}")
18
+ @tab.content.append id, template.capture(self, &block) if block_given?
19
+ end
20
+
21
+ end
22
+ end
23
23
  end
@@ -1,78 +1,78 @@
1
- module TwitterBootstrapBuilder
2
- module Builders
3
- class TableBuilder < Base
4
-
5
- def initialize(*args, &block)
6
- super
7
- @fields = {}
8
- end
9
-
10
- def to_s
11
- template.capture(self, &block) if block
12
-
13
- Tag.block(:div, class: 'table-container') do |data|
14
- data.append do |d|
15
- Tag.block(:table, class: 'table table-striped table-condensed') do |table|
16
- table.append thead
17
- table.append tbody
18
- end
19
- end
20
- data.append pager
21
- end.html_safe
22
- end
23
-
24
- def collection
25
- options[:collection]
26
- end
27
-
28
- def model_class
29
- options[:model_class] || collection.klass
30
- end
31
-
32
- def field(method, &block)
33
- @fields[method] = block
34
- nil
35
- end
36
-
37
- def actions(&block)
38
- @actions_block = block
39
- nil
40
- end
41
-
42
- private
43
-
44
- def thead
45
- Tag.block(:thead) do |thead|
46
- thead.append do |h|
47
- Tag.block(:tr) do |tr|
48
- tr.append Tag.block(:th)
49
- @fields.keys.each do |field|
50
- tr.append Tag.block(:th, model_class.human_attribute_name(field))
51
- end
52
- end
53
- end
54
- end
55
- end
56
-
57
- def tbody
58
- Tag.block(:tbody) do |tbody|
59
- collection.each do |model|
60
- tbody.append do |b|
61
- Tag.block(:tr) do |tr|
62
- tr.append Tag.block(:td, template.capture(model, &@actions_block), class: 'actions') if @actions_block
63
- @fields.each do |field, block|
64
- tr.append Tag.block(:td, (block ? template.capture(model, &block) : model.send(field)))
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
71
-
72
- def pager
73
- Tag.new(:div, template.paginate(collection, theme: :twitter_bootstrap)).pull_right if collection.respond_to?(:current_page)
74
- end
75
-
76
- end
77
- end
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class TableBuilder < Base
4
+
5
+ def initialize(*args, &block)
6
+ super
7
+ @fields = {}
8
+ end
9
+
10
+ def to_s
11
+ template.capture(self, &block) if block
12
+
13
+ Tag.block(:div, class: 'table-container') do |data|
14
+ data.append do |d|
15
+ Tag.block(:table, class: 'table table-striped table-condensed') do |table|
16
+ table.append thead
17
+ table.append tbody
18
+ end
19
+ end
20
+ data.append pager
21
+ end.html_safe
22
+ end
23
+
24
+ def collection
25
+ options[:collection]
26
+ end
27
+
28
+ def model_class
29
+ options[:model_class] || collection.klass
30
+ end
31
+
32
+ def field(method, &block)
33
+ @fields[method] = block
34
+ nil
35
+ end
36
+
37
+ def actions(&block)
38
+ @actions_block = block
39
+ nil
40
+ end
41
+
42
+ private
43
+
44
+ def thead
45
+ Tag.block(:thead) do |thead|
46
+ thead.append do |h|
47
+ Tag.block(:tr) do |tr|
48
+ tr.append Tag.block(:th)
49
+ @fields.keys.each do |field|
50
+ tr.append Tag.block(:th, model_class.human_attribute_name(field))
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def tbody
58
+ Tag.block(:tbody) do |tbody|
59
+ collection.each do |model|
60
+ tbody.append do |b|
61
+ Tag.block(:tr) do |tr|
62
+ tr.append Tag.block(:td, template.capture(model, &@actions_block), class: 'actions') if @actions_block
63
+ @fields.each do |field, block|
64
+ tr.append Tag.block(:td, (block ? template.capture(model, &block) : model.send(field)))
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ def pager
73
+ Tag.new(:div, template.paginate(collection, theme: :twitter_bootstrap)).pull_right if collection.respond_to?(:current_page)
74
+ end
75
+
76
+ end
77
+ end
78
78
  end
@@ -1,17 +1,17 @@
1
- module TwitterBootstrapBuilder
2
- class Engine < ::Rails::Engine
3
- initializer 'twitter_bootstrap_builder' do |app|
4
- ActiveSupport.on_load(:action_view) do
5
- class ActionView::Base
6
- include TwitterBootstrapBuilder::Helpers::CommonsHelper
7
- include TwitterBootstrapBuilder::Helpers::ButtonsHelper
8
- include TwitterBootstrapBuilder::Helpers::DropdownsHelper
9
- end
10
-
11
- class ActionView::Helpers::FormBuilder
12
- include TwitterBootstrapBuilder::Builders::FormBuilder
13
- end
14
- end
15
- end
16
- end
1
+ module TwitterBootstrapBuilder
2
+ class Engine < ::Rails::Engine
3
+ initializer 'twitter_bootstrap_builder' do |app|
4
+ ActiveSupport.on_load(:action_view) do
5
+ class ActionView::Base
6
+ include TwitterBootstrapBuilder::Helpers::CommonsHelper
7
+ include TwitterBootstrapBuilder::Helpers::ButtonsHelper
8
+ include TwitterBootstrapBuilder::Helpers::DropdownsHelper
9
+ end
10
+
11
+ class ActionView::Helpers::FormBuilder
12
+ include TwitterBootstrapBuilder::Builders::FormBuilder
13
+ end
14
+ end
15
+ end
16
+ end
17
17
  end
@@ -1,7 +1,7 @@
1
- module TwitterBootstrapMarkup
2
- class Tag
3
- def html_safe
4
- to_s.html_safe
5
- end
6
- end
1
+ module TwitterBootstrapMarkup
2
+ class Tag
3
+ def html_safe
4
+ to_s.html_safe
5
+ end
6
+ end
7
7
  end
@@ -1,51 +1,51 @@
1
- module TwitterBootstrapBuilder
2
- module Helpers
3
- module ButtonsHelper
4
-
5
- def link_button_to(*args, &block)
6
- Builders::LinkButtonBuilder.new(self, args: args, &block).html_safe
7
- end
8
-
9
- TwitterBootstrapMarkup::ButtonBase::TYPES.each do |type|
10
- define_method "link_button_#{type}_to" do |*args, &block|
11
- Builders::LinkButtonBuilder.new(self, args: args, type: type, &block).html_safe
12
- end
13
-
14
- TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
15
- define_method "link_button_#{type}_#{size}_to" do |*args, &block|
16
- Builders::LinkButtonBuilder.new(self, args: args, type: type, size: size, &block).html_safe
17
- end
18
- end
19
- end
20
-
21
- TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
22
- define_method "link_button_#{size}_to" do |*args, &block|
23
- Builders::LinkButtonBuilder.new(self, args: args, size: size, &block).html_safe
24
- end
25
- end
26
-
27
- def submit_button(*args, &block)
28
- Builders::SubmitButtonBuilder.new(self, args: args, &block).html_safe
29
- end
30
-
31
- TwitterBootstrapMarkup::ButtonBase::TYPES.each do |type|
32
- define_method "submit_button_#{type}" do |*args, &block|
33
- Builders::SubmitButtonBuilder.new(self, args: args, type: type, &block).html_safe
34
- end
35
-
36
- TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
37
- define_method "submit_button_#{type}_#{size}" do |*args, &block|
38
- Builders::SubmitButtonBuilder.new(self, args: args, type: type, size: size, &block).html_safe
39
- end
40
- end
41
- end
42
-
43
- TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
44
- define_method "submit_button_#{size}" do |*args, &block|
45
- Builders::SubmitButtonBuilder.new(self, args: args, size: size, &block).html_safe
46
- end
47
- end
48
-
49
- end
50
- end
1
+ module TwitterBootstrapBuilder
2
+ module Helpers
3
+ module ButtonsHelper
4
+
5
+ def link_button_to(*args, &block)
6
+ Builders::LinkButtonBuilder.new(self, args: args, &block).html_safe
7
+ end
8
+
9
+ TwitterBootstrapMarkup::ButtonBase::TYPES.each do |type|
10
+ define_method "link_button_#{type}_to" do |*args, &block|
11
+ Builders::LinkButtonBuilder.new(self, args: args, type: type, &block).html_safe
12
+ end
13
+
14
+ TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
15
+ define_method "link_button_#{type}_#{size}_to" do |*args, &block|
16
+ Builders::LinkButtonBuilder.new(self, args: args, type: type, size: size, &block).html_safe
17
+ end
18
+ end
19
+ end
20
+
21
+ TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
22
+ define_method "link_button_#{size}_to" do |*args, &block|
23
+ Builders::LinkButtonBuilder.new(self, args: args, size: size, &block).html_safe
24
+ end
25
+ end
26
+
27
+ def submit_button(*args, &block)
28
+ Builders::SubmitButtonBuilder.new(self, args: args, &block).html_safe
29
+ end
30
+
31
+ TwitterBootstrapMarkup::ButtonBase::TYPES.each do |type|
32
+ define_method "submit_button_#{type}" do |*args, &block|
33
+ Builders::SubmitButtonBuilder.new(self, args: args, type: type, &block).html_safe
34
+ end
35
+
36
+ TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
37
+ define_method "submit_button_#{type}_#{size}" do |*args, &block|
38
+ Builders::SubmitButtonBuilder.new(self, args: args, type: type, size: size, &block).html_safe
39
+ end
40
+ end
41
+ end
42
+
43
+ TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
44
+ define_method "submit_button_#{size}" do |*args, &block|
45
+ Builders::SubmitButtonBuilder.new(self, args: args, size: size, &block).html_safe
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
51
  end