twitter-bootstrap-rails 2.2.8 → 3.2.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 +7 -0
- data/README.md +82 -119
- data/Rakefile +4 -6
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +471 -366
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/javascripts/twitter/bootstrap.js +12 -13
- data/app/assets/javascripts/twitter/bootstrap/affix.js +137 -0
- data/app/assets/javascripts/twitter/bootstrap/alert.js +88 -0
- data/app/assets/javascripts/twitter/bootstrap/button.js +107 -0
- data/app/assets/javascripts/twitter/bootstrap/carousel.js +205 -0
- data/app/assets/javascripts/twitter/bootstrap/collapse.js +170 -0
- data/app/assets/javascripts/twitter/bootstrap/dropdown.js +147 -0
- data/app/assets/javascripts/twitter/bootstrap/modal.js +243 -0
- data/app/assets/javascripts/twitter/bootstrap/popover.js +110 -0
- data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +153 -0
- data/app/assets/javascripts/twitter/bootstrap/tab.js +125 -0
- data/app/assets/javascripts/twitter/bootstrap/tooltip.js +399 -0
- data/app/assets/javascripts/twitter/bootstrap/transition.js +48 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -890
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +4 -787
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -146
- data/app/helpers/bootstrap_flash_helper.rb +7 -5
- data/app/helpers/form_errors_helper.rb +22 -0
- data/app/helpers/glyph_helper.rb +8 -6
- data/app/helpers/modal_helper.rb +29 -21
- data/app/helpers/navbar_helper.rb +42 -30
- data/app/helpers/twitter_breadcrumbs_helper.rb +3 -2
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +4 -4
- data/lib/generators/bootstrap/install/install_generator.rb +3 -2
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +7 -8
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +5 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +22 -43
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +16 -31
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +10 -25
- data/lib/generators/bootstrap/partial/templates/_login.html.erb +2 -3
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +25 -8
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +7 -7
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +7 -7
- data/lib/generators/bootstrap/themed/templates/index.html.erb +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.haml +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.slim +2 -2
- data/lib/generators/bootstrap/themed/templates/show.html.erb +5 -7
- data/lib/generators/bootstrap/themed/templates/show.html.haml +4 -4
- data/lib/generators/bootstrap/themed/templates/show.html.slim +5 -6
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +5 -5
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +3 -3
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +4 -4
- data/lib/generators/bootstrap/themed/themed_generator.rb +2 -2
- data/lib/twitter/bootstrap/rails/{twitter-bootstrap-breadcrumbs.rb → breadcrumbs.rb} +24 -8
- data/lib/twitter/bootstrap/rails/engine.rb +5 -2
- data/lib/twitter/bootstrap/rails/version.rb +2 -2
- data/spec/lib/breadcrumbs_spec.rb +74 -0
- data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +4 -2
- data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +15 -15
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +157 -173
- data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +18 -16
- data/spec/spec_helper.rb +7 -1
- data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5797 -0
- data/vendor/static-source/bootstrap.less +0 -1
- data/vendor/static-source/fontawesome.less +0 -1
- data/vendor/static-source/sprites.less +1 -1
- data/vendor/toolkit/fontawesome/bordered-pulled.less +16 -0
- data/vendor/toolkit/fontawesome/core.less +9 -126
- data/vendor/toolkit/fontawesome/fixed-width.less +6 -0
- data/vendor/toolkit/fontawesome/font-awesome.less +9 -25
- data/vendor/toolkit/fontawesome/icons.less +503 -378
- data/vendor/toolkit/fontawesome/larger.less +13 -0
- data/vendor/toolkit/fontawesome/list.less +19 -0
- data/vendor/toolkit/fontawesome/mixins.less +14 -42
- data/vendor/toolkit/fontawesome/path.less +1 -1
- data/vendor/toolkit/fontawesome/rotated-flipped.less +9 -0
- data/vendor/toolkit/fontawesome/spinning.less +32 -0
- data/vendor/toolkit/fontawesome/stacked.less +20 -0
- data/vendor/toolkit/fontawesome/variables.less +511 -731
- data/vendor/toolkit/twitter/bootstrap/alerts.less +47 -58
- data/vendor/toolkit/twitter/bootstrap/badges.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +27 -39
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +11 -9
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +168 -152
- data/vendor/toolkit/twitter/bootstrap/buttons.less +101 -170
- data/vendor/toolkit/twitter/bootstrap/carousel.less +150 -65
- data/vendor/toolkit/twitter/bootstrap/close.less +20 -19
- data/vendor/toolkit/twitter/bootstrap/code.less +38 -30
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +12 -3
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +115 -148
- data/vendor/toolkit/twitter/bootstrap/forms.less +401 -547
- data/vendor/toolkit/twitter/bootstrap/glyphicons.less +233 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +74 -11
- data/vendor/toolkit/twitter/bootstrap/input-groups.less +166 -0
- data/vendor/toolkit/twitter/bootstrap/jumbotron.less +48 -0
- data/vendor/toolkit/twitter/bootstrap/labels.less +64 -0
- data/vendor/toolkit/twitter/bootstrap/list-group.less +132 -0
- data/vendor/toolkit/twitter/bootstrap/media.less +8 -7
- data/vendor/toolkit/twitter/bootstrap/mixins.less +36 -699
- data/vendor/toolkit/twitter/bootstrap/mixins/alerts.less +14 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/background-variant.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/border-radius.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/buttons.less +52 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/center-block.less +7 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/clearfix.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/forms.less +85 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/gradients.less +59 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid-framework.less +91 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid.less +122 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/hide-text.less +21 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/image.less +33 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/labels.less +12 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/list-group.less +29 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-divider.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-vertical-align.less +9 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/opacity.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/pagination.less +23 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/panels.less +24 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/progress-bar.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/reset-filter.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/resize.less +6 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/responsive-visibility.less +15 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/size.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/tab-focus.less +9 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/table-row.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-emphasis.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-overflow.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/vendor-prefixes.less +224 -0
- data/vendor/toolkit/twitter/bootstrap/modals.less +109 -54
- data/vendor/toolkit/twitter/bootstrap/navbar.less +542 -384
- data/vendor/toolkit/twitter/bootstrap/navs.less +192 -359
- data/vendor/toolkit/twitter/bootstrap/normalize.less +425 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +46 -34
- data/vendor/toolkit/twitter/bootstrap/pagination.less +70 -105
- data/vendor/toolkit/twitter/bootstrap/panels.less +248 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +61 -61
- data/vendor/toolkit/twitter/bootstrap/print.less +101 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +51 -73
- data/vendor/toolkit/twitter/bootstrap/responsive-embed.less +34 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +177 -42
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +120 -23
- data/vendor/toolkit/twitter/bootstrap/tables.less +171 -182
- data/vendor/toolkit/twitter/bootstrap/theme.less +260 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +26 -43
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +49 -24
- data/vendor/toolkit/twitter/bootstrap/type.less +208 -147
- data/vendor/toolkit/twitter/bootstrap/utilities.less +33 -7
- data/vendor/toolkit/twitter/bootstrap/variables.less +761 -215
- data/vendor/toolkit/twitter/bootstrap/wells.less +7 -7
- metadata +128 -138
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +0 -117
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +0 -99
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-button.js +0 -105
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +0 -207
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +0 -167
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +0 -169
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +0 -247
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +0 -114
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +0 -162
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +0 -144
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +0 -361
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +0 -60
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +0 -335
- data/test/lib/breadcrumbs_test.rb +0 -75
- data/test/test_helper.rb +0 -11
- data/vendor/toolkit/fontawesome/bootstrap.less +0 -84
- data/vendor/toolkit/fontawesome/extras.less +0 -93
- data/vendor/toolkit/fontawesome/font-awesome-ie7.less +0 -1953
- data/vendor/toolkit/twitter/bootstrap/accordion.less +0 -34
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +0 -25
- data/vendor/toolkit/twitter/bootstrap/labels-badges.less +0 -84
- data/vendor/toolkit/twitter/bootstrap/layouts.less +0 -16
- data/vendor/toolkit/twitter/bootstrap/reset.less +0 -216
- data/vendor/toolkit/twitter/bootstrap/responsive-1200px-min.less +0 -28
- data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +0 -193
- data/vendor/toolkit/twitter/bootstrap/responsive-768px-979px.less +0 -19
- data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +0 -189
- data/vendor/toolkit/twitter/bootstrap/responsive.less +0 -48
- data/vendor/toolkit/twitter/bootstrap/sprites.less +0 -197
|
@@ -19,9 +19,9 @@ table class="table table-striped"
|
|
|
19
19
|
<%- end -%>
|
|
20
20
|
td=l <%= resource_name %>.created_at
|
|
21
21
|
td
|
|
22
|
-
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-
|
|
22
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
|
|
23
23
|
'
|
|
24
|
-
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-
|
|
24
|
+
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger'
|
|
25
25
|
|
|
26
26
|
= link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
|
|
27
27
|
|
|
@@ -10,14 +10,12 @@
|
|
|
10
10
|
<%- end -%>
|
|
11
11
|
</dl>
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
|
13
|
+
<%%= link_to t('.back', :default => t("helpers.links.back")),
|
|
14
|
+
<%= controller_routing_path %>_path, :class => 'btn btn-default' %>
|
|
15
|
+
<%%= link_to t('.edit', :default => t("helpers.links.edit")),
|
|
16
|
+
edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default' %>
|
|
17
|
+
<%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
|
19
18
|
<%= singular_controller_routing_path %>_path(@<%= resource_name %>),
|
|
20
19
|
:method => 'delete',
|
|
21
20
|
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
|
22
21
|
:class => 'btn btn-danger' %>
|
|
23
|
-
</div>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
= @<%= resource_name %>.<%= column.name %>
|
|
10
10
|
<%- end -%>
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
|
14
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
|
|
15
|
+
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
|
@@ -9,9 +9,8 @@ p
|
|
|
9
9
|
= @<%= resource_name %>.<%= column.name %>
|
|
10
10
|
<%- end -%>
|
|
11
11
|
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
|
12
|
+
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
|
13
|
+
'
|
|
14
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
|
|
15
|
+
'
|
|
16
|
+
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<%%= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
|
|
2
2
|
<%- columns.each do |column| -%>
|
|
3
3
|
<%%= f.input :<%= column.name %> %>
|
|
4
|
+
<%%= error_span(@<%= resource_name %>[:<%= column.name %>]) %>
|
|
4
5
|
<%- end -%>
|
|
5
6
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
|
6
7
|
<%%= f.button :wrapped, :cancel => <%= controller_routing_path %>_path %>
|
|
7
8
|
<%- else -%>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<%= controller_routing_path %>_path, :class => 'btn' %>
|
|
12
|
-
</div>
|
|
9
|
+
|
|
10
|
+
<%%= f.button :submit, :class => 'btn-primary' %>
|
|
11
|
+
<%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
|
12
|
+
<%= controller_routing_path %>_path, :class => 'btn btn-default' %>
|
|
13
13
|
<%- end -%>
|
|
14
14
|
<%% end %>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
|
|
2
2
|
<%- columns.each do |column| -%>
|
|
3
3
|
= f.input :<%= column.name %>
|
|
4
|
+
= error_span(@<%= resource_name %>[:<%= column.name %>])
|
|
4
5
|
<%- end -%>
|
|
5
6
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
|
6
7
|
= f.button :wrapped, :cancel => <%= controller_routing_path %>_path
|
|
7
8
|
<%- else -%>
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
|
|
9
|
+
= f.button :submit, :class => 'btn-primary'
|
|
10
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
|
11
11
|
<%- end -%>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
= simple_form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
|
|
2
2
|
<%- columns.each do |column| -%>
|
|
3
3
|
= f.input :<%= column.name %>
|
|
4
|
+
= error_span(@<%= resource_name %>[:<%= column.name %>])
|
|
4
5
|
<%- end -%>
|
|
5
6
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
|
6
7
|
= f.button :wrapped, :cancel => <%= controller_routing_path %>_path
|
|
7
8
|
<%- else -%>
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
|
|
9
|
+
= f.button :submit, :class => 'btn-primary'
|
|
10
|
+
'
|
|
11
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
|
12
12
|
<%- end -%>
|
|
@@ -31,11 +31,11 @@ module Bootstrap
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def controller_routing_path
|
|
34
|
-
@
|
|
34
|
+
ActiveModel::Naming.route_key(@model_name.constantize)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def singular_controller_routing_path
|
|
38
|
-
@
|
|
38
|
+
ActiveModel::Naming.singular_route_key(@model_name.constantize)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def model_name
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
module Twitter
|
|
2
2
|
module Bootstrap
|
|
3
|
-
module
|
|
3
|
+
module Breadcrumbs
|
|
4
4
|
def self.included(base)
|
|
5
5
|
base.extend(ClassMethods)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
module ClassMethods
|
|
9
|
-
def add_breadcrumb(name, url, options = {})
|
|
10
|
-
|
|
9
|
+
def add_breadcrumb(name, url = '', options = {})
|
|
10
|
+
options.merge! :klass => self.name
|
|
11
11
|
before_filter options do |controller|
|
|
12
|
-
|
|
13
|
-
controller.send :add_breadcrumb, name, url
|
|
12
|
+
controller.send :add_breadcrumb, name, url, options
|
|
14
13
|
end
|
|
15
14
|
end
|
|
16
15
|
end
|
|
@@ -19,9 +18,26 @@ module Twitter
|
|
|
19
18
|
|
|
20
19
|
def add_breadcrumb(name, url = '', options = {})
|
|
21
20
|
@breadcrumbs ||= []
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
|
|
22
|
+
class_name = options.delete(:klass) || self.class.name
|
|
23
|
+
|
|
24
|
+
if name.is_a? Symbol
|
|
25
|
+
if url.blank?
|
|
26
|
+
url_helper = :"#{name}_path"
|
|
27
|
+
url = url_helper if respond_to?(url_helper)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
name = translate_breadcrumb name, class_name
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
unless name.is_a? String
|
|
34
|
+
url = polymorphic_path name if url.blank?
|
|
35
|
+
name = name.to_s
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
url = eval(url.to_s) if url.is_a?(Symbol) && url =~ /_path|_url|@/
|
|
39
|
+
|
|
40
|
+
@breadcrumbs << {:name => name, :url => url, :options => options}
|
|
25
41
|
end
|
|
26
42
|
|
|
27
43
|
def translate_breadcrumb(name, class_name)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
require 'rails'
|
|
2
2
|
|
|
3
|
-
require File.dirname(__FILE__) + '/
|
|
3
|
+
require File.dirname(__FILE__) + '/breadcrumbs.rb'
|
|
4
4
|
require File.dirname(__FILE__) + '/../../../../app/helpers/flash_block_helper.rb'
|
|
5
5
|
require File.dirname(__FILE__) + '/../../../../app/helpers/modal_helper.rb'
|
|
6
6
|
require File.dirname(__FILE__) + '/../../../../app/helpers/navbar_helper.rb'
|
|
7
|
+
require File.dirname(__FILE__) + '/../../../../app/helpers/bootstrap_flash_helper.rb'
|
|
7
8
|
|
|
8
9
|
module Twitter
|
|
9
10
|
module Bootstrap
|
|
@@ -19,8 +20,10 @@ module Twitter
|
|
|
19
20
|
|
|
20
21
|
initializer 'twitter-bootstrap-rails.setup_helpers' do |app|
|
|
21
22
|
app.config.to_prepare do
|
|
22
|
-
ActionController::Base.send :include,
|
|
23
|
+
ActionController::Base.send :include, Breadcrumbs
|
|
23
24
|
ActionController::Base.send :helper, FlashBlockHelper
|
|
25
|
+
ActionController::Base.send :helper, BootstrapFlashHelper
|
|
26
|
+
ActionController::Base.send :helper, FormErrorsHelper
|
|
24
27
|
ActionController::Base.send :helper, ModalHelper
|
|
25
28
|
ActionController::Base.send :helper, NavbarHelper
|
|
26
29
|
ActionController::Base.send :helper, BadgeLabelHelper
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Bootstrap::Breadcrumbs do
|
|
4
|
+
class TestModel
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
|
|
7
|
+
def to_s
|
|
8
|
+
"test_model"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class BaseTestController < AbstractController::Base
|
|
13
|
+
include Twitter::Bootstrap::Breadcrumbs
|
|
14
|
+
include AbstractController::Callbacks
|
|
15
|
+
include AbstractController::UrlFor
|
|
16
|
+
|
|
17
|
+
add_breadcrumb 'base', '/base'
|
|
18
|
+
add_breadcrumb :base_i18n, '/base_i18n'
|
|
19
|
+
|
|
20
|
+
def breadcrumbs
|
|
21
|
+
@breadcrumbs
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class TestController < BaseTestController
|
|
26
|
+
add_breadcrumb 'class', '/class'
|
|
27
|
+
add_breadcrumb :class_i18n, '/class_i18n'
|
|
28
|
+
|
|
29
|
+
def show
|
|
30
|
+
add_breadcrumb 'instance', '/instance'
|
|
31
|
+
add_breadcrumb :instance_i18n, '/instance_i18n'
|
|
32
|
+
|
|
33
|
+
test_model = TestModel.new
|
|
34
|
+
add_breadcrumb test_model
|
|
35
|
+
|
|
36
|
+
add_breadcrumb :symbolized
|
|
37
|
+
add_breadcrumb :show
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def symbolized_path
|
|
41
|
+
'/symbolized'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_models_path
|
|
45
|
+
'/test_model'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
before do
|
|
50
|
+
options = { :scope => [:breadcrumbs, 'test'] }
|
|
51
|
+
[:class_i18n, :instance_i18n, :show, :symbolized].each do |name|
|
|
52
|
+
I18n.expects(:t).with(name, options).returns(name.to_s)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
name = :base_i18n
|
|
56
|
+
options = { :scope => [:breadcrumbs, 'base_test'] }
|
|
57
|
+
I18n.expects(:t).with(name, options).returns(name)
|
|
58
|
+
|
|
59
|
+
@controller = TestController.new
|
|
60
|
+
@controller.process(:show)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "have breadcrumbs" do
|
|
64
|
+
[:base, :base_i18n, :class, :class_i18n, :instance, :instance_i18n, :test_model, :symbolized].each do |name|
|
|
65
|
+
path = "/#{name}"
|
|
66
|
+
idx = @controller.breadcrumbs.index { |b| b[:name] == name.to_s && b[:url] == path }
|
|
67
|
+
idx.should be, -> { name }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
idx = @controller.breadcrumbs.index { |b| b[:name] == "show" && b[:url] == '' }
|
|
71
|
+
idx.should be
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
@@ -10,11 +10,13 @@ include BadgeLabelHelper
|
|
|
10
10
|
|
|
11
11
|
describe BadgeLabelHelper, :type => :helper do
|
|
12
12
|
it "should return a basic bootstrap badge" do
|
|
13
|
-
badge('test').gsub(/\s/, '').downcase
|
|
13
|
+
expect(badge('test').gsub(/\s/, '').downcase)
|
|
14
|
+
.to eql(BASIC_BADGE.gsub(/\s/, '').downcase)
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
it "should return a bootstrap badge with class" do
|
|
17
|
-
badge('waning', :warning).gsub(/\s/, '').downcase
|
|
18
|
+
expect(badge('waning', :warning).gsub(/\s/, '').downcase)
|
|
19
|
+
.to eql(BADGE_WITH_CLASS.gsub(/\s/, '').downcase)
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
@@ -11,49 +11,49 @@ describe ModalHelper, :type => :helper do
|
|
|
11
11
|
header_without_close = { :show_close => false, :title => 'Modal header' }
|
|
12
12
|
options = { :id => "modal",
|
|
13
13
|
:header => header_with_close,
|
|
14
|
-
:body => 'This is the body',
|
|
15
|
-
:footer => content_tag(:button, 'Save', :class => 'btn')
|
|
14
|
+
:body => { content: 'This is the body' },
|
|
15
|
+
:footer => { content: content_tag(:button, 'Save', :class => 'btn') }
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
it 'returns a complete modal' do
|
|
19
|
-
modal_dialog(options).gsub(/\n/, "").
|
|
19
|
+
expect(modal_dialog(options).gsub(/\n/, "")).to eql BASIC_MODAL.gsub(/\n/, "")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it 'returns a modal header with a close button if show_close is true' do
|
|
23
|
-
modal_header(header_with_close).gsub(/\n/, "").
|
|
23
|
+
expect(modal_header(header_with_close).gsub(/\n/, "")).to eql MODAL_HEADER_WITH_CLOSE.gsub(/\n/, "")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it 'renders a modal header without a close button' do
|
|
27
|
-
|
|
27
|
+
expect(modal_header(header_without_close).gsub(/\n/, "")).to eql MODAL_HEADER_WITHOUT_CLOSE.gsub(/\n/, "")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'renders a close button' do
|
|
31
|
-
close_button('modal').
|
|
31
|
+
expect(close_button('modal')).to eql "<button class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it 'renders a modal toggle button' do
|
|
35
|
-
|
|
35
|
+
expect(modal_toggle('Save', :href => "#modal").gsub(/\n/, "")).to eql MODAL_TOGGLE.gsub(/\n/, "")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
it 'renders a cancel button' do
|
|
39
|
+
expect(modal_cancel_button("Cancel", :href => "#modal", :data => {:dismiss => 'modal'}).gsub(/\n/, "")).to eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
|
|
40
|
+
end
|
|
42
41
|
end
|
|
42
|
+
|
|
43
43
|
BASIC_MODAL = <<-HTML
|
|
44
|
-
<div class=\"bootstrap-modal modal
|
|
44
|
+
<div class=\"bootstrap-modal modal fade\" id=\"modal\"><div class=\"modal-dialog \"><div class=\"modal-content\"><div class=\"modal-header\"><button class=\"close\" data-dismiss=\"true\" aria-hidden=\"true\">×</button><h4 class=\"modal-title\"></h4></div><div class=\"modal-body\"></div><div class=\"modal-footer\"></div></div></div></div>
|
|
45
45
|
HTML
|
|
46
46
|
|
|
47
47
|
MODAL_HEADER_WITHOUT_CLOSE = <<-HTML
|
|
48
|
-
<div class="modal-header"><
|
|
48
|
+
<div class="modal-header"><h4 class=\"modal-title\">Modal header</h4></div>
|
|
49
49
|
HTML
|
|
50
50
|
|
|
51
51
|
MODAL_HEADER_WITH_CLOSE = <<-HTML
|
|
52
|
-
<div class="modal-header"><button class="close" data-dismiss="modal">×</button><
|
|
52
|
+
<div class="modal-header"><button class="close" data-dismiss="modal" aria-hidden=\"true\">×</button><h4 class=\"modal-title\">Modal header</h4></div>
|
|
53
53
|
HTML
|
|
54
54
|
|
|
55
55
|
MODAL_TOGGLE = <<-HTML
|
|
56
|
-
<a class="btn" data-toggle="modal" href="#modal">Save</a>
|
|
56
|
+
<a class="btn btn-default" data-toggle="modal" href="#modal">Save</a>
|
|
57
57
|
HTML
|
|
58
58
|
|
|
59
59
|
MODAL_CANCEL_BUTTON = <<-HTML
|
|
@@ -11,161 +11,182 @@ include NavbarHelper
|
|
|
11
11
|
|
|
12
12
|
describe NavbarHelper, :type => :helper do
|
|
13
13
|
before do
|
|
14
|
-
self.
|
|
15
|
-
self.
|
|
14
|
+
allow(self).to receive(:uri_state) { :inactive }
|
|
15
|
+
allow(self).to receive(:root_url) { '/' }
|
|
16
16
|
end
|
|
17
17
|
describe "nav_bar" do
|
|
18
18
|
it "should return a basic bootstrap navbar" do
|
|
19
|
-
nav_bar.gsub(/\s/, '').downcase
|
|
19
|
+
expect(nav_bar.gsub(/\s/, '').downcase)
|
|
20
|
+
.to eql(BASIC_NAVBAR.gsub(/\s/, '').downcase)
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
it "should set the fixed position to top" do
|
|
23
|
-
nav_bar(:fixed => :top).gsub(/\s/, '').downcase
|
|
24
|
+
expect(nav_bar(:fixed => :top).gsub(/\s/, '').downcase)
|
|
25
|
+
.to eql(FIXED_TOP_NAVBAR.gsub(/\s/, '').downcase)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
it "should set the static position to top" do
|
|
27
|
-
nav_bar(:static => :top).gsub(/\s/, '').downcase
|
|
29
|
+
expect(nav_bar(:static => :top).gsub(/\s/, '').downcase)
|
|
30
|
+
.to eql(STATIC_TOP_NAVBAR.gsub(/\s/, '').downcase)
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
it "should set the fixed position to bottom" do
|
|
31
|
-
nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase
|
|
34
|
+
expect(nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase)
|
|
35
|
+
.to eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/, '').downcase)
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
it "should set the style to inverse" do
|
|
35
|
-
nav_bar(:inverse => true).gsub(/\s/, '').downcase
|
|
39
|
+
expect(nav_bar(:inverse => true).gsub(/\s/, '').downcase)
|
|
40
|
+
.to eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
it "should add the brand name and link it to the home page" do
|
|
39
|
-
nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase
|
|
44
|
+
expect(nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase)
|
|
45
|
+
.to eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
it "should be able to set the brand link url" do
|
|
43
|
-
nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/, '').downcase
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
it "should set the container to fluid" do
|
|
47
|
-
nav_bar(:fluid => :true).gsub(/\s/, '').downcase.should eql(BASIC_NAVBAR_FLUID.gsub(/\s/, '').downcase)
|
|
49
|
+
expect(nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/, '').downcase)
|
|
50
|
+
.to eql(NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/, '').downcase)
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
it "should add the buttons etc for a responsive layout with no block passed" do
|
|
51
|
-
nav_bar(:responsive => true).gsub(/\s/, '').downcase.
|
|
54
|
+
expect(nav_bar(:responsive => true).gsub(/\s/, '').downcase).to eql(RESPONSIVE_NAVBAR.gsub(/\s/, '').downcase)
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
it "should add the buttons etc for a responsive layout with block passed" do
|
|
55
|
-
nav_bar(:responsive => true) do
|
|
58
|
+
ele = nav_bar(:responsive => true) do
|
|
56
59
|
"<p>Passing a block</p>".html_safe
|
|
57
|
-
end
|
|
60
|
+
end
|
|
61
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
|
|
58
62
|
end
|
|
59
63
|
|
|
60
64
|
it "should render contained items" do
|
|
61
|
-
nav_bar do
|
|
65
|
+
ele = nav_bar do
|
|
62
66
|
menu_group do
|
|
63
67
|
menu_item("Home", "/") + menu_item("Products", "/products")
|
|
64
68
|
end
|
|
65
|
-
end
|
|
69
|
+
end
|
|
70
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
|
|
66
71
|
end
|
|
67
72
|
|
|
68
73
|
it "should still render the brand name even with other options turned on" do
|
|
69
|
-
nav_bar(:brand => "Something") do
|
|
74
|
+
ele = nav_bar(:brand => "Something") do
|
|
70
75
|
menu_group do
|
|
71
76
|
menu_item "Home", "/"
|
|
72
77
|
end
|
|
73
|
-
end
|
|
78
|
+
end
|
|
79
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
|
|
74
80
|
end
|
|
75
81
|
end
|
|
76
82
|
|
|
77
83
|
describe "menu_group" do
|
|
78
84
|
it "should return a ul with the class 'nav'" do
|
|
79
|
-
menu_group do
|
|
85
|
+
ele = menu_group do
|
|
80
86
|
menu_item("Home", "/") + menu_item("Products", "/products")
|
|
81
|
-
end
|
|
87
|
+
end
|
|
88
|
+
expect(ele).to eql '<ul class="nav navbar-nav "><li><a href="/">Home</a></li><li><a href="/products">Products</a></li></ul>'
|
|
82
89
|
end
|
|
83
90
|
|
|
84
|
-
it "should return a ul with class .
|
|
85
|
-
menu_group(:pull => :left) do
|
|
91
|
+
it "should return a ul with class .navbar-left when passed the {:pull => :left} option" do
|
|
92
|
+
ele = menu_group(:pull => :left) do
|
|
86
93
|
menu_item("Home", "/")
|
|
87
|
-
end
|
|
94
|
+
end
|
|
95
|
+
expect(ele).to eql('<ul class="nav navbar-nav navbar-left"><li><a href="/">Home</a></li></ul>')
|
|
88
96
|
end
|
|
89
97
|
end
|
|
90
98
|
|
|
91
99
|
describe "menu_item" do
|
|
92
100
|
it "should return a link within an li tag" do
|
|
93
|
-
self.
|
|
94
|
-
menu_item("Home", "/").
|
|
101
|
+
allow(self).to receive(:current_page?) { false }
|
|
102
|
+
expect(menu_item("Home", "/")).to eql('<li><a href="/">Home</a></li>')
|
|
95
103
|
end
|
|
96
104
|
it "should return the link with class 'active' if on current page" do
|
|
97
|
-
self.
|
|
98
|
-
menu_item("Home", "/").
|
|
105
|
+
allow(self).to receive(:uri_state) { :active }
|
|
106
|
+
expect(menu_item("Home", "/")).to eql('<li class="active"><a href="/">Home</a></li>')
|
|
99
107
|
end
|
|
100
108
|
it "should pass any other options through to the link_to method" do
|
|
101
|
-
self.stub
|
|
102
|
-
menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete).
|
|
109
|
+
self.stub("uri_state").and_return(:active)
|
|
110
|
+
expect(menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete)).to eql('<li class="active"><a class="home_link" data-method="delete" href="/users/sign_out" rel="nofollow">Log out</a></li>')
|
|
103
111
|
end
|
|
104
112
|
it "should pass a block but no name if a block is present" do
|
|
105
|
-
self.
|
|
106
|
-
menu_item("/"){content_tag("i", "", :class => "icon-home") + " Home"}.
|
|
113
|
+
allow(self).to receive(:current_page?) { false }
|
|
114
|
+
expect(menu_item("/"){content_tag("i", "", :class => "icon-home") + " Home"}).to eql('<li><a href="/"><i class="icon-home"></i> Home</a></li>')
|
|
107
115
|
end
|
|
108
116
|
it "should work with just a block" do
|
|
109
|
-
self.
|
|
110
|
-
menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }.
|
|
117
|
+
allow(self).to receive(:current_page?) { false }
|
|
118
|
+
expect(menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }).to eql('<li><a href="#"><i class="icon-home"></i> Home</a></li>')
|
|
111
119
|
end
|
|
112
120
|
it "should return the link with class 'active' if on current page with a block" do
|
|
113
|
-
self.
|
|
114
|
-
menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }.
|
|
121
|
+
allow(self).to receive(:uri_state) { :active }
|
|
122
|
+
expect(menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }).to eql('<li class="active"><a href="/"><i class="icon-home"></i> Home</a></li>')
|
|
115
123
|
end
|
|
116
124
|
end
|
|
117
125
|
|
|
118
126
|
describe "drop_down" do
|
|
119
127
|
it "should do render the proper drop down code" do
|
|
120
|
-
drop_down "Products" do
|
|
128
|
+
ele = drop_down "Products" do
|
|
121
129
|
menu_item "Latest", "/"
|
|
122
|
-
end
|
|
130
|
+
end
|
|
131
|
+
expect(ele).to have_tag(:li, with: {class: 'dropdown'})
|
|
132
|
+
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
|
123
133
|
end
|
|
124
134
|
end
|
|
125
135
|
|
|
126
136
|
describe "drop_down_with_submenu" do
|
|
127
137
|
it "should do render the proper drop down code" do
|
|
128
|
-
drop_down_with_submenu "Products" do
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
ele = drop_down_with_submenu "Products" do
|
|
139
|
+
drop_down_submenu "Latest" do
|
|
140
|
+
menu_item "Option1", "/"
|
|
141
|
+
end
|
|
131
142
|
end
|
|
132
|
-
|
|
143
|
+
expect(ele).to have_tag(:li, with: {class: 'dropdown'})
|
|
144
|
+
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
|
145
|
+
expect(ele).to have_tag(:ul, with: {class: 'dropdown-menu'})
|
|
133
146
|
end
|
|
134
147
|
end
|
|
135
148
|
|
|
136
149
|
describe "menu_divider" do
|
|
137
150
|
it "should render <li class='divider-vertical'></li>" do
|
|
138
|
-
menu_divider.
|
|
151
|
+
expect(menu_divider).to match '<li class="divider-vertical"></li>'
|
|
139
152
|
end
|
|
140
153
|
end
|
|
141
154
|
|
|
142
155
|
describe "menu_text" do
|
|
143
156
|
it "should render text within p tags with class 'navbar-text" do
|
|
144
|
-
menu_text("Strapline!").
|
|
157
|
+
expect(menu_text("Strapline!")).to match("<p class=\"navbar-text\">Strapline!</p>")
|
|
145
158
|
end
|
|
146
159
|
|
|
147
160
|
it "should be able to be pulled right or left" do
|
|
148
|
-
menu_text("I am being pulled right", :pull => :right).
|
|
161
|
+
expect(menu_text("I am being pulled right", :pull => :right)).to match("<p class=\"pull-right navbar-text\">I am being pulled right</p>")
|
|
149
162
|
end
|
|
150
163
|
|
|
151
164
|
it "should be able to cope with arbitrary options being passed to the p tag" do
|
|
152
|
-
menu_text("I am classy!", :class => "classy", :id => "classy_text").
|
|
165
|
+
expect(menu_text("I am classy!", :class => "classy", :id => "classy_text")).to match("<p class=\"classy navbar-text\" id=\"classy_text\">I am classy!</p>")
|
|
153
166
|
end
|
|
154
167
|
|
|
155
168
|
it "should be able to cope with a block too" do
|
|
156
|
-
menu_text
|
|
157
|
-
|
|
158
|
-
|
|
169
|
+
ele = menu_text("I have been rendered programmatically!")
|
|
170
|
+
expect(ele).to have_tag(:p, with: {class: "navbar-text"})
|
|
171
|
+
expect(ele).to match "I have been rendered programmatically!"
|
|
159
172
|
end
|
|
160
173
|
end
|
|
161
174
|
|
|
162
175
|
describe "rendering forms ok" do
|
|
163
176
|
it "should not escape anything unexpectedly" do
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
177
|
+
expect(
|
|
178
|
+
nav_bar do
|
|
179
|
+
form_tag "/", :method => 'get' do |f|
|
|
180
|
+
f.text_field :search, "stub"
|
|
181
|
+
end
|
|
167
182
|
end
|
|
168
|
-
|
|
183
|
+
).to have_tag(:form)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
describe "default navbar" do
|
|
188
|
+
it "renders a navbar" do
|
|
189
|
+
expect(nav_bar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-default', role: 'navigation' }, text: /foo/)
|
|
169
190
|
end
|
|
170
191
|
end
|
|
171
192
|
|
|
@@ -174,167 +195,132 @@ end
|
|
|
174
195
|
# HTML output
|
|
175
196
|
|
|
176
197
|
BASIC_NAVBAR = <<-HTML
|
|
177
|
-
<
|
|
178
|
-
<div class="
|
|
179
|
-
<div class="container">
|
|
180
|
-
</div>
|
|
198
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
199
|
+
<div class="container">
|
|
181
200
|
</div>
|
|
182
|
-
</
|
|
201
|
+
</nav>
|
|
183
202
|
HTML
|
|
184
203
|
|
|
185
204
|
FIXED_TOP_NAVBAR = <<-HTML
|
|
186
|
-
<
|
|
187
|
-
<div class="
|
|
188
|
-
<div class="container">
|
|
189
|
-
</div>
|
|
205
|
+
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
|
206
|
+
<div class="container">
|
|
190
207
|
</div>
|
|
191
|
-
</
|
|
208
|
+
</nav>
|
|
192
209
|
HTML
|
|
193
210
|
|
|
194
211
|
STATIC_TOP_NAVBAR = <<-HTML
|
|
195
|
-
<
|
|
196
|
-
<div class="
|
|
197
|
-
<div class="container">
|
|
198
|
-
</div>
|
|
212
|
+
<nav class="navbar navbar-default navbar-static-top" role="navigation">
|
|
213
|
+
<div class="container">
|
|
199
214
|
</div>
|
|
200
|
-
</
|
|
215
|
+
</nav>
|
|
201
216
|
HTML
|
|
202
217
|
|
|
203
218
|
FIXED_BOTTOM_NAVBAR = <<-HTML
|
|
204
|
-
<
|
|
205
|
-
<div class="
|
|
206
|
-
<div class="container">
|
|
207
|
-
</div>
|
|
219
|
+
<nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
|
|
220
|
+
<div class="container">
|
|
208
221
|
</div>
|
|
209
|
-
</
|
|
222
|
+
</nav>
|
|
210
223
|
HTML
|
|
211
224
|
|
|
212
225
|
INVERSE_NAVBAR = <<-HTML
|
|
213
|
-
<
|
|
214
|
-
<div class="
|
|
215
|
-
<div class="container">
|
|
216
|
-
</div>
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
HTML
|
|
220
|
-
|
|
221
|
-
BASIC_NAVBAR_FLUID= <<-HTML
|
|
222
|
-
<div class="navbar">
|
|
223
|
-
<div class="navbar-inner">
|
|
224
|
-
<div class="container-fluid">
|
|
225
|
-
</div>
|
|
226
|
+
<nav class="navbar navbar-default navbar-inverse" role="navigation">
|
|
227
|
+
<div class="container">
|
|
226
228
|
</div>
|
|
227
|
-
</
|
|
229
|
+
</nav>
|
|
228
230
|
HTML
|
|
229
231
|
|
|
230
232
|
NAVBAR_WITH_BRAND = <<-HTML
|
|
231
|
-
<
|
|
232
|
-
<div class="
|
|
233
|
-
<
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
</a>
|
|
237
|
-
</div>
|
|
233
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
234
|
+
<div class="container">
|
|
235
|
+
<a class="navbar-brand" href="/">
|
|
236
|
+
Ninety Ten
|
|
237
|
+
</a>
|
|
238
238
|
</div>
|
|
239
|
-
</
|
|
239
|
+
</nav>
|
|
240
240
|
HTML
|
|
241
241
|
|
|
242
242
|
NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
|
|
243
|
-
<
|
|
244
|
-
<div class="
|
|
245
|
-
<
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
</a>
|
|
249
|
-
</div>
|
|
243
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
244
|
+
<div class="container">
|
|
245
|
+
<a class="navbar-brand" href="http://www.ninetyten.com">
|
|
246
|
+
Ninety Ten
|
|
247
|
+
</a>
|
|
250
248
|
</div>
|
|
251
|
-
</
|
|
249
|
+
</nav>
|
|
252
250
|
HTML
|
|
253
251
|
|
|
254
252
|
RESPONSIVE_NAVBAR = <<-HTML
|
|
255
|
-
<
|
|
256
|
-
<div class="
|
|
257
|
-
<div class="
|
|
258
|
-
<
|
|
253
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
254
|
+
<div class="container">
|
|
255
|
+
<div class="navbar-header">
|
|
256
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
|
257
|
+
<span class="sr-only">Toggle Navigation</span>
|
|
259
258
|
<span class="icon-bar"></span>
|
|
260
259
|
<span class="icon-bar"></span>
|
|
261
260
|
<span class="icon-bar"></span>
|
|
262
|
-
</
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
</button>
|
|
262
|
+
</div>
|
|
263
|
+
<div class="navbar-collapse collapse">
|
|
265
264
|
</div>
|
|
266
265
|
</div>
|
|
267
|
-
</
|
|
266
|
+
</nav>
|
|
268
267
|
HTML
|
|
269
268
|
|
|
270
269
|
RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
|
|
271
|
-
<
|
|
272
|
-
<div class="
|
|
273
|
-
<div class="
|
|
274
|
-
<
|
|
270
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
271
|
+
<div class="container">
|
|
272
|
+
<div class="navbar-header">
|
|
273
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
|
274
|
+
<span class="sr-only">Toggle Navigation</span>
|
|
275
275
|
<span class="icon-bar"></span>
|
|
276
276
|
<span class="icon-bar"></span>
|
|
277
277
|
<span class="icon-bar"></span>
|
|
278
|
-
</
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
</button>
|
|
279
|
+
</div>
|
|
280
|
+
<div class="navbar-collapse collapse">
|
|
281
|
+
<p>Passing a block</p>
|
|
282
282
|
</div>
|
|
283
283
|
</div>
|
|
284
|
-
</
|
|
284
|
+
</nav>
|
|
285
285
|
HTML
|
|
286
286
|
|
|
287
287
|
PLAIN_NAVBAR_WITH_ITEM = <<-HTML
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
</div>
|
|
301
|
-
</div>
|
|
288
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
289
|
+
<div class="container">
|
|
290
|
+
<ul class="nav navbar-nav">
|
|
291
|
+
<li>
|
|
292
|
+
<a href="/">Home</a>
|
|
293
|
+
</li>
|
|
294
|
+
<li>
|
|
295
|
+
<a href="/products">Products</a>
|
|
296
|
+
</li>
|
|
297
|
+
</ul>
|
|
298
|
+
</div>
|
|
299
|
+
</nav>
|
|
302
300
|
HTML
|
|
303
301
|
|
|
304
302
|
BRANDED_NAVBAR_WITH_ITEM = <<-HTML
|
|
305
|
-
<
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
</div>
|
|
318
|
-
</div>
|
|
303
|
+
<nav class="navbar navbar-default" role="navigation">
|
|
304
|
+
<div class="container">
|
|
305
|
+
<a class="navbar-brand" href="/">
|
|
306
|
+
Something
|
|
307
|
+
</a>
|
|
308
|
+
<ul class="nav navbar-nav">
|
|
309
|
+
<li>
|
|
310
|
+
<a href="/">Home</a>
|
|
311
|
+
</li>
|
|
312
|
+
</ul>
|
|
313
|
+
</div>
|
|
314
|
+
</nav>
|
|
319
315
|
HTML
|
|
320
316
|
|
|
321
317
|
DROPDOWN_MENU = <<-HTML
|
|
322
|
-
<li class="dropdown">
|
|
323
|
-
<a href="#"
|
|
324
|
-
class="dropdown-toggle"
|
|
325
|
-
data-toggle="dropdown">
|
|
326
|
-
Products
|
|
327
|
-
<b class="caret"></b>
|
|
328
|
-
</a>
|
|
329
|
-
<ul class="dropdown-menu">
|
|
330
|
-
<li><a href="/">Latest</a></li>
|
|
331
|
-
</ul>
|
|
332
|
-
</li>
|
|
318
|
+
<li class="dropdown"> <a class="dropdown-toggle"data-toggle="dropdown"href="#"> Products <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><a href="/">Latest</a></li> </ul> </li>
|
|
333
319
|
HTML
|
|
334
320
|
|
|
335
321
|
DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
|
|
336
322
|
<li class="dropdown">
|
|
337
|
-
<a
|
|
323
|
+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Products <b class="caret"></b></a>
|
|
338
324
|
<ul class="dropdown-menu">
|
|
339
325
|
<li class="dropdown-submenu">
|
|
340
326
|
<a href="">Latest</a>
|
|
@@ -347,16 +333,14 @@ DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
|
|
|
347
333
|
HTML
|
|
348
334
|
|
|
349
335
|
PLAIN_NAVBAR_WITH_FORM = <<-HTML
|
|
350
|
-
<
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
</div>
|
|
361
|
-
</div>
|
|
336
|
+
<nav class=\"navbar navbar-default\"role=\"navigation\">
|
|
337
|
+
<div class=\"container\">
|
|
338
|
+
<form accept-charset=\"utf-8\" action=\"/\" method=\"get\">
|
|
339
|
+
<div style=\"display:none\">
|
|
340
|
+
<input name=\"utf8\" type=\"hidden\" value=\"✓\"/>
|
|
341
|
+
</div>
|
|
342
|
+
<input id=\"search_stub\" name=\"search[stub]\" type=\"text\"/>
|
|
343
|
+
</form>
|
|
344
|
+
</div>
|
|
345
|
+
</nav>
|
|
362
346
|
HTML
|