twitter_bootstrap_builder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ -# Link to the "First" page
2
+ - available local variables
3
+ url: url to the first page
4
+ current_page: a page object for the currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -
9
+ %li{:class => '.first' + (current_page.first? ? ' active' : '')}
10
+ - if current_page.first?
11
+ %a= raw(t 'views.pagination.first')
12
+ - else
13
+ = link_to raw(t 'views.pagination.first'), url, :remote => remote
14
+
15
+
@@ -0,0 +1,9 @@
1
+ -# Non-link tag that stands for skipped pages...
2
+ - available local variables
3
+ current_page: a page object for the currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
7
+ -
8
+ %li.page.gap
9
+ %a= raw(t 'views.pagination.truncate')
@@ -0,0 +1,13 @@
1
+ -# Link to the "Last" page
2
+ - available local variables
3
+ url: url to the last page
4
+ current_page: a page object for the currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -
9
+ %li{:class => 'last' + (current_page.last? ? ' active' : '')}
10
+ - if current_page.last?
11
+ %a= raw(t 'views.pagination.last')
12
+ - else
13
+ = link_to raw(t 'views.pagination.last'), url, {:remote => remote}
@@ -0,0 +1,13 @@
1
+ -# Link to the "Next" page
2
+ - available local variables
3
+ url: url to the next page
4
+ current_page: a page object for the currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -
9
+ %li{:class => 'next' + (current_page.last? ? ' active' : '')}
10
+ - if current_page.last?
11
+ %a= raw(t 'views.pagination.next')
12
+ - else
13
+ = link_to raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
@@ -0,0 +1,15 @@
1
+ -# Link showing page number
2
+ - available local variables
3
+ page: a page object for "this" page
4
+ url: url to this page
5
+ current_page: a page object for the currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
9
+ -
10
+ %li{:class => 'page' + (page.current? ? ' active' : '')}
11
+ - if page.current?
12
+ %a= page
13
+ - else
14
+ = link_to page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
15
+
@@ -0,0 +1,20 @@
1
+ -# The container tag
2
+ - available local variables
3
+ current_page: a page object for the currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
7
+ paginator: the paginator that renders the pagination tags inside
8
+ -
9
+ = paginator.render do
10
+ %nav.pagination
11
+ %ul
12
+ = first_page_tag
13
+ = prev_page_tag
14
+ - each_page do |page|
15
+ - if page.left_outer? || page.right_outer? || page.inside_window?
16
+ = page_tag page
17
+ - elsif !page.was_truncated?
18
+ = gap_tag
19
+ = next_page_tag
20
+ = last_page_tag
@@ -0,0 +1,13 @@
1
+ -# Link to the "Previous" page
2
+ - available local variables
3
+ url: url to the previous page
4
+ current_page: a page object for the currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -
9
+ %li{:class => 'prev' + (current_page.first? ? ' active' : '')}
10
+ - if current_page.first?
11
+ %a= raw(t 'views.pagination.previous')
12
+ - else
13
+ = link_to raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote
@@ -6,9 +6,12 @@ require 'kaminari'
6
6
 
7
7
  require 'twitter_bootstrap_builder/helpers/commons_helper'
8
8
  require 'twitter_bootstrap_builder/helpers/buttons_helper'
9
+ require 'twitter_bootstrap_builder/helpers/dropdowns_helper'
9
10
 
10
11
  require 'twitter_bootstrap_builder/builders/base'
12
+ require 'twitter_bootstrap_builder/builders/drop_down_builder'
11
13
  require 'twitter_bootstrap_builder/builders/drop_down_link_builder'
14
+ require 'twitter_bootstrap_builder/builders/drop_down_button_builder'
12
15
  require 'twitter_bootstrap_builder/builders/fieldset_builder'
13
16
  require 'twitter_bootstrap_builder/builders/form_builder'
14
17
  require 'twitter_bootstrap_builder/builders/link_button_builder'
@@ -0,0 +1,20 @@
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class DropDownBuilder < Base
4
+
5
+ def to_s
6
+ dropdown = self.dropdown_class.new(options[:text])
7
+ dropdown.append template.capture(self, &block) if block
8
+ dropdown.send(options[:type]) if options[:type] && dropdown.respond_to?(options[:type])
9
+ dropdown.send(options[:size]) if options[:size] && dropdown.respond_to?(options[:size])
10
+ dropdown.as_nav_item if dropdown.respond_to? :as_nav_item
11
+ dropdown.to_s
12
+ end
13
+
14
+ def link_to(*args, &block)
15
+ Tag.block(:li, template.link_to(*args, &block)).to_s.html_safe
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class DropDownButtonBuilder < DropDownBuilder
4
+
5
+ def dropdown_class
6
+ DropdownButton
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -1,15 +1,9 @@
1
1
  module TwitterBootstrapBuilder
2
2
  module Builders
3
- class DropDownLinkBuilder < Base
3
+ class DropDownLinkBuilder < DropDownBuilder
4
4
 
5
- def to_s
6
- dropdown_link = DropdownLink.new(options[:text])
7
- dropdown_link.append template.capture(self, &block) if block
8
- dropdown_link.as_nav_item.to_s
9
- end
10
-
11
- def link_to(*args, &block)
12
- Tag.block(:li, template.link_to(*args, &block)).to_s.html_safe
5
+ def dropdown_class
6
+ DropdownLink
13
7
  end
14
8
 
15
9
  end
@@ -82,6 +82,24 @@ module TwitterBootstrapBuilder
82
82
  end.to_s.html_safe
83
83
  end
84
84
 
85
+ def date_select(method, options={}, html_options={})
86
+ ControlGroup.new(model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
87
+ cg.append form_builder.date_select(method, form_builder.send('objectify_options', options), html_options)
88
+ end.to_s.html_safe
89
+ end
90
+
91
+ def time_select(method, options={}, html_options={})
92
+ ControlGroup.new(model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
93
+ cg.append form_builder.time_select(method, form_builder.send('objectify_options', options), html_options)
94
+ end.to_s.html_safe
95
+ end
96
+
97
+ def datetime_select(method, options={}, html_options={})
98
+ ControlGroup.new(model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
99
+ cg.append form_builder.datetime_select(method, form_builder.send('objectify_options', options), html_options)
100
+ end.to_s.html_safe
101
+ end
102
+
85
103
  def custom_field(label, options={}, &block)
86
104
  ControlGroup.new(label, options) do |cg|
87
105
  cg.append template.capture(self, &block) if block
@@ -45,7 +45,7 @@ module TwitterBootstrapBuilder
45
45
  Tag.block(:thead) do |thead|
46
46
  thead.append do |h|
47
47
  Tag.block(:tr) do |tr|
48
- tr.append Tag.block(:th, class: 'span2')
48
+ tr.append Tag.block(:th)
49
49
  @fields.each do |field|
50
50
  tr.append Tag.block(:th, model_class.human_attribute_name(field))
51
51
  end
@@ -59,7 +59,7 @@ module TwitterBootstrapBuilder
59
59
  collection.each do |model|
60
60
  tbody.append do |b|
61
61
  Tag.block(:tr) do |tr|
62
- tr.append Tag.block(:td, template.capture(model, &@actions_block))
62
+ tr.append Tag.block(:td, template.capture(model, &@actions_block), class: 'actions') if @actions_block
63
63
  @fields.each do |field|
64
64
  tr.append Tag.block(:td, model.send(field))
65
65
  end
@@ -70,7 +70,7 @@ module TwitterBootstrapBuilder
70
70
  end
71
71
 
72
72
  def pager
73
- Tag.new(:div, template.paginate(collection)).pull_right if collection.respond_to?(:current_page)
73
+ Tag.new(:div, template.paginate(collection, theme: :twitter_bootstrap)).pull_right if collection.respond_to?(:current_page)
74
74
  end
75
75
 
76
76
  end
@@ -5,6 +5,7 @@ module TwitterBootstrapBuilder
5
5
  class ActionView::Base
6
6
  include TwitterBootstrapBuilder::Helpers::CommonsHelper
7
7
  include TwitterBootstrapBuilder::Helpers::ButtonsHelper
8
+ include TwitterBootstrapBuilder::Helpers::DropdownsHelper
8
9
  end
9
10
 
10
11
  class ActionView::Helpers::FormBuilder
@@ -78,10 +78,6 @@ module TwitterBootstrapBuilder
78
78
  Builders::FieldsetBuilder.new(self, &block).html_safe
79
79
  end
80
80
 
81
- def dropdown_link(text, &block)
82
- Builders::DropDownLinkBuilder.new(self, text: text, &block).html_safe
83
- end
84
-
85
81
  def icon(name)
86
82
  TwitterBootstrapMarkup::Icon.new(name).to_s.html_safe
87
83
  end
@@ -0,0 +1,33 @@
1
+ module TwitterBootstrapBuilder
2
+ module Helpers
3
+ module DropdownsHelper
4
+
5
+ def dropdown_link(text, &block)
6
+ Builders::DropDownLinkBuilder.new(self, text: text, &block).html_safe
7
+ end
8
+
9
+ def dropdown_button(text, &block)
10
+ Builders::DropDownButtonBuilder.new(self, text: text, &block).html_safe
11
+ end
12
+
13
+ TwitterBootstrapMarkup::ButtonBase::TYPES.each do |type|
14
+ define_method "dropdown_button_#{type}" do |text, &block|
15
+ Builders::DropDownButtonBuilder.new(self, text: text, type: type, &block).html_safe
16
+ end
17
+
18
+ TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
19
+ define_method "dropdown_button_#{type}_#{size}" do |text, &block|
20
+ Builders::DropDownButtonBuilder.new(self, text: text, type: type, size: size, &block).html_safe
21
+ end
22
+ end
23
+ end
24
+
25
+ TwitterBootstrapMarkup::ButtonBase::SIZES.each do |size|
26
+ define_method "dropdown_button_#{size}" do |text, &block|
27
+ Builders::DropDownButtonBuilder.new(self, text: text, size: size, &block).html_safe
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module TwitterBootstrapBuilder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_bootstrap_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twitter_bootstrap_markup
16
- requirement: &26340648 !ruby/object:Gem::Requirement
16
+ requirement: &21113640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *26340648
24
+ version_requirements: *21113640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: kaminari
27
- requirement: &26340048 !ruby/object:Gem::Requirement
27
+ requirement: &21113208 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *26340048
35
+ version_requirements: *21113208
36
36
  description: Set of helpers to extend Rails for implement Twitter Bootstrap markup
37
37
  email:
38
38
  - gabynaiman@gmail.com
@@ -45,8 +45,17 @@ files:
45
45
  - LICENSE
46
46
  - README.md
47
47
  - Rakefile
48
+ - app/views/kaminari/twitter_bootstrap/_first_page.html.haml
49
+ - app/views/kaminari/twitter_bootstrap/_gap.html.haml
50
+ - app/views/kaminari/twitter_bootstrap/_last_page.html.haml
51
+ - app/views/kaminari/twitter_bootstrap/_next_page.html.haml
52
+ - app/views/kaminari/twitter_bootstrap/_page.html.haml
53
+ - app/views/kaminari/twitter_bootstrap/_paginator.html.haml
54
+ - app/views/kaminari/twitter_bootstrap/_prev_page.html.haml
48
55
  - lib/twitter_bootstrap_builder.rb
49
56
  - lib/twitter_bootstrap_builder/builders/base.rb
57
+ - lib/twitter_bootstrap_builder/builders/drop_down_builder.rb
58
+ - lib/twitter_bootstrap_builder/builders/drop_down_button_builder.rb
50
59
  - lib/twitter_bootstrap_builder/builders/drop_down_link_builder.rb
51
60
  - lib/twitter_bootstrap_builder/builders/fieldset_builder.rb
52
61
  - lib/twitter_bootstrap_builder/builders/form_builder.rb
@@ -59,6 +68,7 @@ files:
59
68
  - lib/twitter_bootstrap_builder/engine.rb
60
69
  - lib/twitter_bootstrap_builder/helpers/buttons_helper.rb
61
70
  - lib/twitter_bootstrap_builder/helpers/commons_helper.rb
71
+ - lib/twitter_bootstrap_builder/helpers/dropdowns_helper.rb
62
72
  - lib/twitter_bootstrap_builder/version.rb
63
73
  - twitter_bootstrap_builder.gemspec
64
74
  - vendor/assets/images/glyphicons-halflings-white.png