twitter-bootstrap-rails 2.2.6 → 2.2.7

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.
Files changed (74) hide show
  1. data/README.md +319 -18
  2. data/Rakefile +9 -1
  3. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  4. data/app/assets/fonts/fontawesome-webfont.svg +339 -0
  5. data/{vendor → app}/assets/fonts/fontawesome-webfont.ttf +0 -0
  6. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  7. data/{vendor → app}/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  8. data/{vendor → app}/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  9. data/{vendor → app}/assets/javascripts/twitter/bootstrap.js +0 -0
  10. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +0 -0
  11. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +0 -0
  12. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-button.js +0 -0
  13. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +0 -0
  14. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +0 -0
  15. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +0 -0
  16. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +0 -0
  17. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +0 -0
  18. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +0 -0
  19. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +0 -0
  20. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +0 -0
  21. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +0 -0
  22. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +0 -0
  23. data/{vendor → app}/assets/javascripts/twitter/bootstrap_ujs.js +0 -0
  24. data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +889 -0
  25. data/{vendor → app}/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +134 -16
  26. data/{vendor → app}/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +2 -2
  27. data/app/helpers/badge_label_helper.rb +16 -0
  28. data/app/helpers/bootstrap_flash_helper.rb +1 -1
  29. data/app/helpers/modal_helper.rb +29 -16
  30. data/app/helpers/navbar_helper.rb +189 -0
  31. data/app/helpers/twitter_breadcrumbs_helper.rb +7 -2
  32. data/lib/generators/bootstrap/install/install_generator.rb +10 -6
  33. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +8 -9
  34. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +1 -0
  35. data/lib/generators/bootstrap/layout/templates/layout.html.erb +4 -4
  36. data/lib/generators/bootstrap/layout/templates/layout.html.haml +5 -5
  37. data/lib/generators/bootstrap/layout/templates/layout.html.slim +7 -5
  38. data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -1
  39. data/lib/generators/bootstrap/themed/templates/edit.html.haml +1 -1
  40. data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
  41. data/lib/generators/bootstrap/themed/templates/index.html.erb +1 -1
  42. data/lib/generators/bootstrap/themed/templates/index.html.haml +1 -1
  43. data/lib/generators/bootstrap/themed/templates/index.html.slim +1 -1
  44. data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -1
  45. data/lib/generators/bootstrap/themed/templates/new.html.haml +1 -1
  46. data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
  47. data/lib/generators/bootstrap/themed/templates/show.html.erb +1 -1
  48. data/lib/generators/bootstrap/themed/templates/show.html.haml +1 -1
  49. data/lib/generators/bootstrap/themed/templates/show.html.slim +1 -1
  50. data/lib/twitter-bootstrap-rails.rb +4 -4
  51. data/lib/twitter/bootstrap/rails/engine.rb +3 -0
  52. data/lib/twitter/bootstrap/rails/version.rb +1 -1
  53. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +22 -0
  54. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +62 -0
  55. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +350 -0
  56. data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +40 -0
  57. data/spec/spec_helper.rb +11 -0
  58. data/test/lib/breadcrumbs_test.rb +2 -2
  59. data/test/test_helper.rb +3 -0
  60. data/vendor/static-source/fontawesome.less +8 -6
  61. data/vendor/toolkit/fontawesome/bootstrap.less +78 -0
  62. data/vendor/toolkit/fontawesome/core.less +132 -0
  63. data/vendor/toolkit/fontawesome/extras.less +79 -0
  64. data/vendor/toolkit/{fontawesome-ie7.less → fontawesome/font-awesome-ie7.less} +80 -17
  65. data/vendor/toolkit/fontawesome/font-awesome.less +32 -0
  66. data/vendor/toolkit/{fontawesome.less → fontawesome/icons.less} +69 -271
  67. data/vendor/toolkit/fontawesome/mixins.less +34 -0
  68. data/vendor/toolkit/fontawesome/path.less +14 -0
  69. data/vendor/toolkit/fontawesome/variables.less +9 -0
  70. metadata +80 -29
  71. data/lib/generators/bootstrap/partial/templates/_navbar.html.erb +0 -13
  72. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  73. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  74. data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +0 -889
@@ -1,5 +1,10 @@
1
1
  module TwitterBreadcrumbsHelper
2
- def render_breadcrumbs(divider = '/')
3
- render :partial => 'twitter-bootstrap/breadcrumbs', :locals => { :divider => divider }
2
+ def render_breadcrumbs(divider = '/', &block)
3
+ content = render :partial => 'twitter-bootstrap/breadcrumbs', :layout => false, :locals => { :divider => divider }
4
+ if block_given?
5
+ capture(content, &block)
6
+ else
7
+ content
8
+ end
4
9
  end
5
10
  end
@@ -10,20 +10,24 @@ module Bootstrap
10
10
 
11
11
  def add_assets
12
12
 
13
- if File.exist?('app/assets/javascripts/application.js')
14
- insert_into_file "app/assets/javascripts/application.js", "//= require twitter/bootstrap\n", :after => "jquery_ujs\n"
13
+ js_manifest = 'app/assets/javascripts/application.js'
14
+
15
+ if File.exist?(js_manifest)
16
+ insert_into_file js_manifest, "//= require twitter/bootstrap\n", :after => "jquery_ujs\n"
15
17
  else
16
- copy_file "application.js", "app/assets/javascripts/application.js"
18
+ copy_file "application.js", js_manifest
17
19
  end
18
20
 
19
- if File.exist?('app/assets/stylesheets/application.css')
21
+ css_manifest = 'app/assets/stylesheets/application.css'
22
+
23
+ if File.exist?(css_manifest)
20
24
  # Add our own require:
21
- content = File.read("app/assets/stylesheets/application.css")
25
+ content = File.read(css_manifest)
22
26
  if content.match(/require_tree\s+\.\s*$/)
23
27
  # Good enough - that'll include our bootstrap_and_overrides.css.less
24
28
  else
25
29
  style_require_block = " *= require bootstrap_and_overrides\n"
26
- insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
30
+ insert_into_file css_manifest, style_require_block, :after => "require_self\n"
27
31
  end
28
32
  else
29
33
  copy_file "application.css", "app/assets/stylesheets/application.css"
@@ -2,19 +2,18 @@
2
2
  @import "twitter/bootstrap/responsive";
3
3
 
4
4
  // Set the correct sprite paths
5
- @iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings.png");
6
- @iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white.png");
5
+ @iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings");
6
+ @iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white");
7
7
 
8
8
  // Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
9
- // Note: If you use asset_path() here, your compiled bootstrap_and_overrides.css will not
10
- // have the proper paths. So for now we use the absolute path.
11
- @fontAwesomeEotPath: asset-path("fontawesome-webfont.eot?v=3.0.2");
12
- @fontAwesomeEotPath_iefix: asset-path("fontawesome-webfont.eot?#iefix&v=3.0.2");
13
- @fontAwesomeWoffPath: asset-path("fontawesome-webfont.woff?v=3.0.2");
14
- @fontAwesomeTtfPath: asset-path("fontawesome-webfont.ttf?v=3.0.2");
9
+ @fontAwesomeEotPath: asset-url("fontawesome-webfont.eot");
10
+ @fontAwesomeEotPath_iefix: asset-url("fontawesome-webfont.eot#iefix");
11
+ @fontAwesomeWoffPath: asset-url("fontawesome-webfont.woff");
12
+ @fontAwesomeTtfPath: asset-url("fontawesome-webfont.ttf");
13
+ @fontAwesomeSvgPath: asset-url("fontawesome-webfont.svg#fontawesomeregular");
15
14
 
16
15
  // Font Awesome
17
- @import "fontawesome";
16
+ @import "fontawesome/font-awesome";
18
17
 
19
18
  // Glyphicons
20
19
  //@import "twitter/bootstrap/sprites.less";
@@ -10,6 +10,7 @@ en:
10
10
  confirm: "Are you sure?"
11
11
  destroy: "Delete"
12
12
  new: "New"
13
+ edit: "Edit"
13
14
  titles:
14
15
  edit: "Edit"
15
16
  save: "Save"
@@ -16,19 +16,19 @@
16
16
 
17
17
  <!-- For third-generation iPad with high-resolution Retina display: -->
18
18
  <!-- Size should be 144 x 144 pixels -->
19
- <%%= favicon_link_tag 'images/apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
19
+ <%%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
20
20
 
21
21
  <!-- For iPhone with high-resolution Retina display: -->
22
22
  <!-- Size should be 114 x 114 pixels -->
23
- <%%= favicon_link_tag 'images/apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
23
+ <%%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
24
24
 
25
25
  <!-- For first- and second-generation iPad: -->
26
26
  <!-- Size should be 72 x 72 pixels -->
27
- <%%= favicon_link_tag 'images/apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
27
+ <%%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
28
28
 
29
29
  <!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
30
30
  <!-- Size should be 57 x 57 pixels -->
31
- <%%= favicon_link_tag 'images/apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
31
+ <%%= favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
32
32
 
33
33
  <!-- For all other devices -->
34
34
  <!-- Size should be 32 x 32 pixels -->
@@ -10,11 +10,11 @@
10
10
  /[if lt IE 9]
11
11
  = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js"
12
12
  = stylesheet_link_tag "application", :media => "all"
13
- %link(href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144")
14
- %link(href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114")
15
- %link(href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72")
16
- %link(href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed")
17
- %link(href="favicon.ico" rel="shortcut icon")
13
+ = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144'
14
+ = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114'
15
+ = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72'
16
+ = favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png'
17
+ = favicon_link_tag 'favicon.ico', :rel => 'shortcut icon'
18
18
 
19
19
 
20
20
  %body
@@ -11,11 +11,13 @@ html lang="en"
11
11
  /[if lt IE 9]
12
12
  = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js"
13
13
  = stylesheet_link_tag "application", :media => "all"
14
- link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
15
- link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
16
- link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
17
- link href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
18
- link href="favicon.ico" rel="shortcut icon"
14
+ = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144'
15
+ = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114'
16
+ = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72'
17
+ = favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png'
18
+ = favicon_link_tag 'favicon.ico', :rel => 'shortcut icon'
19
+
20
+
19
21
 
20
22
  body
21
23
  .navbar.navbar-<%= layout_type %>-top
@@ -1,5 +1,5 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human %></h1>
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize %></h1>
4
4
  </div>
5
5
  <%%= render :partial => 'form' %>
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human
3
+ %h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human
3
+ h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,6 +1,6 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
4
4
  </div>
5
5
  <table class="table table-striped">
6
6
  <thead>
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => model_class.model_name.human.pluralize
3
+ %h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
4
  %table.table.table-striped
5
5
  %thead
6
6
  %tr
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => model_class.model_name.human.pluralize
3
+ h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
4
  table class="table table-striped"
5
5
  thead
6
6
  tr
@@ -1,5 +1,5 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human %></h1>
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize %></h1>
4
4
  </div>
5
5
  <%%= render :partial => 'form' %>
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human
3
+ %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human
3
+ h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,6 +1,6 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => model_class.model_name.human %></h1>
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.titleize %></h1>
4
4
  </div>
5
5
 
6
6
  <dl class="dl-horizontal">
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => model_class.model_name.human
3
+ %h1=t '.title', :default => model_class.model_name.human.titleize
4
4
 
5
5
  <%- columns.each do |column| -%>
6
6
  %p
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => model_class.model_name.human
3
+ h1=t '.title', :default => model_class.model_name.human.titleize
4
4
 
5
5
  <%- columns.each do |column| -%>
6
6
  p
@@ -1,9 +1,9 @@
1
1
  module Twitter
2
2
  module Bootstrap
3
- module Rails
4
- require 'twitter/bootstrap/rails/engine' if defined?(Rails)
5
- end
6
- end
3
+ module Rails
4
+ require 'twitter/bootstrap/rails/engine' if defined?(Rails)
5
+ end
6
+ end
7
7
  end
8
8
 
9
9
  #require 'less-rails'
@@ -3,6 +3,7 @@ require 'rails'
3
3
  require File.dirname(__FILE__) + '/twitter-bootstrap-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
+ require File.dirname(__FILE__) + '/../../../../app/helpers/navbar_helper.rb'
6
7
 
7
8
  module Twitter
8
9
  module Bootstrap
@@ -21,6 +22,8 @@ module Twitter
21
22
  ActionController::Base.send :include, BreadCrumbs
22
23
  ActionController::Base.send :helper, FlashBlockHelper
23
24
  ActionController::Base.send :helper, ModalHelper
25
+ ActionController::Base.send :helper, NavbarHelper
26
+ ActionController::Base.send :helper, BadgeLabelHelper
24
27
  #ActionController::Base.send :helper_method, :render_breadcrumbs
25
28
  end
26
29
  end
@@ -1,7 +1,7 @@
1
1
  module Twitter
2
2
  module Bootstrap
3
3
  module Rails
4
- VERSION = "2.2.6"
4
+ VERSION = "2.2.7"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'action_view'
4
+ require 'active_support'
5
+ require_relative '../../../app/helpers/badge_label_helper'
6
+
7
+ include ActionView::Helpers
8
+ include ActionView::Context
9
+ include BadgeLabelHelper
10
+
11
+ describe BadgeLabelHelper, :type => :helper do
12
+ it "should return a basic bootstrap badge" do
13
+ badge('test').gsub(/\s/, '').downcase.should eql(BASIC_BADGE.gsub(/\s/, '').downcase)
14
+ end
15
+
16
+ it "should return a bootstrap badge with class" do
17
+ badge('waning', :warning).gsub(/\s/, '').downcase.should eql(BADGE_WITH_CLASS.gsub(/\s/, '').downcase)
18
+ end
19
+ end
20
+
21
+ BASIC_BADGE = %{<span class="badge">test</span>}
22
+ BADGE_WITH_CLASS = %{<span class="badge badge-warning">waning</span>}
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require_relative '../../../app/helpers/modal_helper'
4
+
5
+ include ActionView::Helpers
6
+ include ActionView::Context
7
+ include ModalHelper
8
+
9
+ describe ModalHelper, :type => :helper do
10
+ header_with_close = { :show_close => true, :dismiss => 'modal', :title => 'Modal header' }
11
+ header_without_close = { :show_close => false, :title => 'Modal header' }
12
+ options = { :id => "modal",
13
+ :header => header_with_close,
14
+ :body => 'This is the body',
15
+ :footer => content_tag(:button, 'Save', :class => 'btn')
16
+ }
17
+
18
+ it 'returns a complete modal' do
19
+ modal_dialog(options).gsub(/\n/, "").should eql BASIC_MODAL.gsub(/\n/, "")
20
+ end
21
+
22
+ it 'returns a modal header with a close button if show_close is true' do
23
+ modal_header(header_with_close).gsub(/\n/, "").should eql MODAL_HEADER_WITH_CLOSE.gsub(/\n/, "")
24
+ end
25
+
26
+ it 'renders a modal header without a close button' do
27
+ modal_header(header_without_close).gsub(/\n/, "").should eql MODAL_HEADER_WITHOUT_CLOSE.gsub(/\n/, "")
28
+ end
29
+
30
+ it 'renders a close button' do
31
+ close_button('modal').should eql "<button class=\"close\" data-dismiss=\"modal\">&times;</button>"
32
+ end
33
+
34
+ it 'renders a modal toggle button' do
35
+ modal_toggle('Save', :href => "#modal").gsub(/\n/, "").should eql MODAL_TOGGLE.gsub(/\n/, "")
36
+ end
37
+
38
+ it 'renders a cancel button' do
39
+ modal_cancel_button("Cancel", :href => "#modal", :data => {:dismiss => 'modal'}).gsub(/\n/, "").should eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
40
+ end
41
+
42
+ end
43
+ BASIC_MODAL = <<-HTML
44
+ <div class=\"bootstrap-modal modal hide fade\" id="modal"><div class=\"modal-header\"><button class=\"close\" data-dismiss=\"modal\">&times;</button><h3>Modal header</h3></div><div class=\"modal-body\">This is the body</div><div class=\"modal-footer\"><button class=\"btn\">Save</button></div></div>
45
+ HTML
46
+
47
+ MODAL_HEADER_WITHOUT_CLOSE = <<-HTML
48
+ <div class="modal-header"><h3>Modal header</h3></div>
49
+ HTML
50
+
51
+ MODAL_HEADER_WITH_CLOSE = <<-HTML
52
+ <div class="modal-header"><button class="close" data-dismiss="modal">&times;</button><h3>Modal header</h3></div>
53
+ HTML
54
+
55
+ MODAL_TOGGLE = <<-HTML
56
+ <a class="btn" data-toggle="modal" href="#modal">Save</a>
57
+ HTML
58
+
59
+ MODAL_CANCEL_BUTTON = <<-HTML
60
+ <a class="btn bootstrap-modal-cancel-button" data-dismiss="modal" href="#modal">Cancel</a>
61
+ HTML
62
+
@@ -0,0 +1,350 @@
1
+ # encoding: utf-8
2
+ #Credit for this goes to https://github.com/julescopeland/Rails-Bootstrap-Navbar
3
+ require 'spec_helper'
4
+ require 'action_view'
5
+ require 'active_support'
6
+ require_relative '../../../app/helpers/navbar_helper'
7
+
8
+ include ActionView::Helpers
9
+ include ActionView::Context
10
+ include NavbarHelper
11
+
12
+ describe NavbarHelper, :type => :helper do
13
+ before do
14
+ self.stub!("uri_state").and_return(:inactive)
15
+ self.stub!("root_url").and_return("/")
16
+ end
17
+ describe "nav_bar" do
18
+ it "should return a basic bootstrap navbar" do
19
+ nav_bar.gsub(/\s/, '').downcase.should eql(BASIC_NAVBAR.gsub(/\s/, '').downcase)
20
+ end
21
+
22
+ it "should set the fixed position to top" do
23
+ nav_bar(:fixed => :top).gsub(/\s/, '').downcase.should eql(FIXED_TOP_NAVBAR.gsub(/\s/, '').downcase)
24
+ end
25
+
26
+ it "should set the static position to top" do
27
+ nav_bar(:static => :top).gsub(/\s/, '').downcase.should eql(STATIC_TOP_NAVBAR.gsub(/\s/, '').downcase)
28
+ end
29
+
30
+ it "should set the fixed position to bottom" do
31
+ nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase.should eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/, '').downcase)
32
+ end
33
+
34
+ it "should set the style to inverse" do
35
+ nav_bar(:inverse => true).gsub(/\s/, '').downcase.should eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
36
+ end
37
+
38
+ it "should add the brand name and link it to the home page" do
39
+ nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase.should eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
40
+ end
41
+
42
+ 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.should eql(NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/, '').downcase)
44
+ end
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)
48
+ end
49
+
50
+ it "should add the buttons etc for a responsive layout with no block passed" do
51
+ nav_bar(:responsive => true).gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR.gsub(/\s/, '').downcase)
52
+ end
53
+
54
+ it "should add the buttons etc for a responsive layout with block passed" do
55
+ nav_bar(:responsive => true) do
56
+ "<p>Passing a block</p>".html_safe
57
+ end.gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
58
+ end
59
+
60
+ it "should render contained items" do
61
+ nav_bar do
62
+ menu_group do
63
+ menu_item("Home", "/") + menu_item("Products", "/products")
64
+ end
65
+ end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
66
+ end
67
+
68
+ it "should still render the brand name even with other options turned on" do
69
+ nav_bar(:brand => "Something") do
70
+ menu_group do
71
+ menu_item "Home", "/"
72
+ end
73
+ end.gsub(/\s/, '').downcase.should eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
74
+ end
75
+ end
76
+
77
+ describe "menu_group" do
78
+ it "should return a ul with the class 'nav'" do
79
+ menu_group do
80
+ menu_item("Home", "/") + menu_item("Products", "/products")
81
+ end.should eql '<ul class="nav "><li><a href="/">Home</a></li><li><a href="/products">Products</a></li></ul>'
82
+ end
83
+
84
+ it "should return a ul with class .pull-left when passed the {:pull => :left} option" do
85
+ menu_group(:pull => :left) do
86
+ menu_item("Home", "/")
87
+ end.should eql('<ul class="nav pull-left"><li><a href="/">Home</a></li></ul>')
88
+ end
89
+ end
90
+
91
+ describe "menu_item" do
92
+ it "should return a link within an li tag" do
93
+ self.stub!("current_page?").and_return(false)
94
+ menu_item("Home", "/").should eql('<li><a href="/">Home</a></li>')
95
+ end
96
+ it "should return the link with class 'active' if on current page" do
97
+ self.stub!("uri_state").and_return(:active)
98
+ menu_item("Home", "/").should eql('<li class="active"><a href="/">Home</a></li>')
99
+ end
100
+ it "should pass any other options through to the link_to method" do
101
+ self.stub!("uri_state").and_return(:active)
102
+ menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete).should eql('<li class="active"><a href="/users/sign_out" class="home_link" data-method="delete" rel="nofollow">Log out</a></li>')
103
+ end
104
+ end
105
+
106
+ describe "drop_down" do
107
+ it "should do render the proper drop down code" do
108
+ drop_down "Products" do
109
+ menu_item "Latest", "/"
110
+ end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU.gsub(/\s/, '').downcase)
111
+ end
112
+ end
113
+
114
+ describe "drop_down_with_submenu" do
115
+ it "should do render the proper drop down code" do
116
+ drop_down_with_submenu "Products" do
117
+ drop_down_submenu "Latest" do
118
+ menu_item "Option1", "/"
119
+ end
120
+ end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU_WITH_SUBMENU.gsub(/\s/, '').downcase)
121
+ end
122
+ end
123
+
124
+ describe "menu_divider" do
125
+ it "should render <li class='divider-vertical'></li>" do
126
+ menu_divider.should eql '<li class="divider-vertical"></li>'
127
+ end
128
+ end
129
+
130
+ describe "menu_text" do
131
+ it "should render text within p tags with class 'navbar-text" do
132
+ menu_text("Strapline!").should eql("<p class=\"navbar-text\">Strapline!</p>")
133
+ end
134
+
135
+ it "should be able to be pulled right or left" do
136
+ menu_text("I am being pulled right", :pull => :right).should eql("<p class=\"pull-right navbar-text\">I am being pulled right</p>")
137
+ end
138
+
139
+ it "should be able to cope with arbitrary options being passed to the p tag" do
140
+ menu_text("I am classy!", :class => "classy", :id => "classy_text").should eql("<p class=\"classy navbar-text\" id=\"classy_text\">I am classy!</p>")
141
+ end
142
+
143
+ it "should be able to cope with a block too" do
144
+ menu_text do
145
+ "I have been rendered programmatically!"
146
+ end.should eql("<p class=\"navbar-text\">I have been rendered programmatically!</p>")
147
+ end
148
+ end
149
+
150
+ describe "rendering forms ok" do
151
+ it "should not escape anything unexpectedly" do
152
+ nav_bar do
153
+ form_tag "/", :method => 'get' do |f|
154
+ f.text_field :search, "stub"
155
+ end
156
+ end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_FORM.gsub(/\s/, '').downcase)
157
+ end
158
+ end
159
+
160
+ end
161
+
162
+ # HTML output
163
+
164
+ BASIC_NAVBAR = <<-HTML
165
+ <div class="navbar">
166
+ <div class="navbar-inner">
167
+ <div class="container">
168
+ </div>
169
+ </div>
170
+ </div>
171
+ HTML
172
+
173
+ FIXED_TOP_NAVBAR = <<-HTML
174
+ <div class="navbar navbar-fixed-top">
175
+ <div class="navbar-inner">
176
+ <div class="container">
177
+ </div>
178
+ </div>
179
+ </div>
180
+ HTML
181
+
182
+ STATIC_TOP_NAVBAR = <<-HTML
183
+ <div class="navbar navbar-static-top">
184
+ <div class="navbar-inner">
185
+ <div class="container">
186
+ </div>
187
+ </div>
188
+ </div>
189
+ HTML
190
+
191
+ FIXED_BOTTOM_NAVBAR = <<-HTML
192
+ <div class="navbar navbar-fixed-bottom">
193
+ <div class="navbar-inner">
194
+ <div class="container">
195
+ </div>
196
+ </div>
197
+ </div>
198
+ HTML
199
+
200
+ INVERSE_NAVBAR = <<-HTML
201
+ <div class="navbar navbar-inverse">
202
+ <div class="navbar-inner">
203
+ <div class="container">
204
+ </div>
205
+ </div>
206
+ </div>
207
+ HTML
208
+
209
+ BASIC_NAVBAR_FLUID= <<-HTML
210
+ <div class="navbar">
211
+ <div class="navbar-inner">
212
+ <div class="container-fluid">
213
+ </div>
214
+ </div>
215
+ </div>
216
+ HTML
217
+
218
+ NAVBAR_WITH_BRAND = <<-HTML
219
+ <div class="navbar">
220
+ <div class="navbar-inner">
221
+ <div class="container">
222
+ <a href="/" class="brand">
223
+ Ninety Ten
224
+ </a>
225
+ </div>
226
+ </div>
227
+ </div>
228
+ HTML
229
+
230
+ NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
231
+ <div class="navbar">
232
+ <div class="navbar-inner">
233
+ <div class="container">
234
+ <a href="http://www.ninetyten.com" class="brand">
235
+ Ninety Ten
236
+ </a>
237
+ </div>
238
+ </div>
239
+ </div>
240
+ HTML
241
+
242
+ RESPONSIVE_NAVBAR = <<-HTML
243
+ <div class="navbar">
244
+ <div class="navbar-inner">
245
+ <div class="container">
246
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
247
+ <span class="icon-bar"></span>
248
+ <span class="icon-bar"></span>
249
+ <span class="icon-bar"></span>
250
+ </a>
251
+ <div class="nav-collapse">
252
+ </div>
253
+ </div>
254
+ </div>
255
+ </div>
256
+ HTML
257
+
258
+ RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
259
+ <div class="navbar">
260
+ <div class="navbar-inner">
261
+ <div class="container">
262
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
263
+ <span class="icon-bar"></span>
264
+ <span class="icon-bar"></span>
265
+ <span class="icon-bar"></span>
266
+ </a>
267
+ <div class="nav-collapse">
268
+ <p>Passing a block</p>
269
+ </div>
270
+ </div>
271
+ </div>
272
+ </div>
273
+ HTML
274
+
275
+ PLAIN_NAVBAR_WITH_ITEM = <<-HTML
276
+ <div class="navbar">
277
+ <div class="navbar-inner">
278
+ <div class="container">
279
+ <ul class="nav">
280
+ <li>
281
+ <a href="/">Home</a>
282
+ </li>
283
+ <li>
284
+ <a href="/products">Products</a>
285
+ </li>
286
+ </ul>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ HTML
291
+
292
+ BRANDED_NAVBAR_WITH_ITEM = <<-HTML
293
+ <div class="navbar">
294
+ <div class="navbar-inner">
295
+ <div class="container">
296
+ <a href="/" class="brand">
297
+ Something
298
+ </a>
299
+ <ul class="nav">
300
+ <li>
301
+ <a href="/">Home</a>
302
+ </li>
303
+ </ul>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ HTML
308
+
309
+ DROPDOWN_MENU = <<-HTML
310
+ <li class="dropdown">
311
+ <a href="#"
312
+ class="dropdown-toggle"
313
+ data-toggle="dropdown">
314
+ Products
315
+ <b class="caret"></b>
316
+ </a>
317
+ <ul class="dropdown-menu">
318
+ <li><a href="/">Latest</a></li>
319
+ </ul>
320
+ </li>
321
+ HTML
322
+
323
+ DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
324
+ <li class="dropdown">
325
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
326
+ <ul class="dropdown-menu">
327
+ <li class="dropdown-submenu">
328
+ <a href="">Latest</a>
329
+ <ul class="dropdown-menu">
330
+ <li><a href="/">Option1</a></li>
331
+ </ul>
332
+ </li>
333
+ </ul>
334
+ </li>
335
+ HTML
336
+
337
+ PLAIN_NAVBAR_WITH_FORM = <<-HTML
338
+ <div class="navbar">
339
+ <div class="navbar-inner">
340
+ <div class="container">
341
+ <form accept-charset="utf-8" action="/" method="get">
342
+ <div style="margin:0;padding:0;display:inline">
343
+ <input name="utf8" type="hidden" value="&#x2713;"/>
344
+ </div>
345
+ <input id="search_stub" name="search[stub]" size="30" type="text"/>
346
+ </form>
347
+ </div>
348
+ </div>
349
+ </div>
350
+ HTML