twitter-bootstrap3-rails 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +708 -0
  3. data/Rakefile +46 -0
  4. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  5. data/app/assets/fonts/fontawesome-webfont.svg +399 -0
  6. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  7. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  8. data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  9. data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  10. data/app/assets/javascripts/twitter/bootstrap.js +12 -0
  11. data/app/assets/javascripts/twitter/bootstrap/affix.js +126 -0
  12. data/app/assets/javascripts/twitter/bootstrap/alert.js +98 -0
  13. data/app/assets/javascripts/twitter/bootstrap/button.js +109 -0
  14. data/app/assets/javascripts/twitter/bootstrap/carousel.js +217 -0
  15. data/app/assets/javascripts/twitter/bootstrap/collapse.js +179 -0
  16. data/app/assets/javascripts/twitter/bootstrap/dropdown.js +154 -0
  17. data/app/assets/javascripts/twitter/bootstrap/modal.js +244 -0
  18. data/app/assets/javascripts/twitter/bootstrap/popover.js +117 -0
  19. data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +158 -0
  20. data/app/assets/javascripts/twitter/bootstrap/tab.js +135 -0
  21. data/app/assets/javascripts/twitter/bootstrap/tooltip.js +382 -0
  22. data/app/assets/javascripts/twitter/bootstrap/transition.js +56 -0
  23. data/app/assets/javascripts/twitter/bootstrap_ujs.js +11 -0
  24. data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5579 -0
  25. data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +787 -0
  26. data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +146 -0
  27. data/app/helpers/badge_label_helper.rb +16 -0
  28. data/app/helpers/bootstrap_flash_helper.rb +29 -0
  29. data/app/helpers/flash_block_helper.rb +17 -0
  30. data/app/helpers/glyph_helper.rb +17 -0
  31. data/app/helpers/modal_helper.rb +59 -0
  32. data/app/helpers/navbar_helper.rb +195 -0
  33. data/app/helpers/twitter_breadcrumbs_helper.rb +10 -0
  34. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +12 -0
  35. data/lib/generators/bootstrap/install/install_generator.rb +82 -0
  36. data/lib/generators/bootstrap/install/templates/application.css +7 -0
  37. data/lib/generators/bootstrap/install/templates/application.js +10 -0
  38. data/lib/generators/bootstrap/install/templates/bootstrap.coffee +3 -0
  39. data/lib/generators/bootstrap/install/templates/bootstrap.js +4 -0
  40. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.css +7 -0
  41. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +29 -0
  42. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +18 -0
  43. data/lib/generators/bootstrap/layout/layout_generator.rb +20 -0
  44. data/lib/generators/bootstrap/layout/templates/layout.html.erb +85 -0
  45. data/lib/generators/bootstrap/layout/templates/layout.html.haml +50 -0
  46. data/lib/generators/bootstrap/layout/templates/layout.html.slim +52 -0
  47. data/lib/generators/bootstrap/partial/partial_generator.rb +20 -0
  48. data/lib/generators/bootstrap/partial/templates/_login.html.erb +28 -0
  49. data/lib/generators/bootstrap/themed/templates/_form.html.erb +16 -0
  50. data/lib/generators/bootstrap/themed/templates/_form.html.haml +9 -0
  51. data/lib/generators/bootstrap/themed/templates/_form.html.slim +10 -0
  52. data/lib/generators/bootstrap/themed/templates/edit.html.erb +5 -0
  53. data/lib/generators/bootstrap/themed/templates/edit.html.haml +4 -0
  54. data/lib/generators/bootstrap/themed/templates/edit.html.slim +4 -0
  55. data/lib/generators/bootstrap/themed/templates/index.html.erb +40 -0
  56. data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
  57. data/lib/generators/bootstrap/themed/templates/index.html.slim +27 -0
  58. data/lib/generators/bootstrap/themed/templates/new.html.erb +5 -0
  59. data/lib/generators/bootstrap/themed/templates/new.html.haml +4 -0
  60. data/lib/generators/bootstrap/themed/templates/new.html.slim +4 -0
  61. data/lib/generators/bootstrap/themed/templates/show.html.erb +21 -0
  62. data/lib/generators/bootstrap/themed/templates/show.html.haml +15 -0
  63. data/lib/generators/bootstrap/themed/templates/show.html.slim +16 -0
  64. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +13 -0
  65. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +10 -0
  66. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +11 -0
  67. data/lib/generators/bootstrap/themed/themed_generator.rb +148 -0
  68. data/lib/twitter-bootstrap-rails.rb +10 -0
  69. data/lib/twitter/bootstrap/rails/bootstrap.rb +2 -0
  70. data/lib/twitter/bootstrap/rails/engine.rb +33 -0
  71. data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +42 -0
  72. data/lib/twitter/bootstrap/rails/version.rb +7 -0
  73. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +22 -0
  74. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +62 -0
  75. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +331 -0
  76. data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +47 -0
  77. data/spec/spec_helper.rb +11 -0
  78. data/test/lib/breadcrumbs_test.rb +75 -0
  79. data/test/test_helper.rb +11 -0
  80. data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5579 -0
  81. data/vendor/static-source/bootstrap.less +1 -0
  82. data/vendor/static-source/fontawesome.less +9 -0
  83. data/vendor/static-source/sprites.less +6 -0
  84. data/vendor/toolkit/fontawesome/bootstrap.less +84 -0
  85. data/vendor/toolkit/fontawesome/core.less +129 -0
  86. data/vendor/toolkit/fontawesome/extras.less +93 -0
  87. data/vendor/toolkit/fontawesome/font-awesome-ie7.less +1953 -0
  88. data/vendor/toolkit/fontawesome/font-awesome.less +33 -0
  89. data/vendor/toolkit/fontawesome/icons.less +381 -0
  90. data/vendor/toolkit/fontawesome/mixins.less +48 -0
  91. data/vendor/toolkit/fontawesome/path.less +14 -0
  92. data/vendor/toolkit/fontawesome/variables.less +735 -0
  93. data/vendor/toolkit/twitter/bootstrap/alerts.less +71 -0
  94. data/vendor/toolkit/twitter/bootstrap/badges.less +51 -0
  95. data/vendor/toolkit/twitter/bootstrap/bootstrap.less +63 -0
  96. data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +23 -0
  97. data/vendor/toolkit/twitter/bootstrap/button-groups.less +244 -0
  98. data/vendor/toolkit/twitter/bootstrap/buttons.less +159 -0
  99. data/vendor/toolkit/twitter/bootstrap/carousel.less +204 -0
  100. data/vendor/toolkit/twitter/bootstrap/close.less +33 -0
  101. data/vendor/toolkit/twitter/bootstrap/code.less +56 -0
  102. data/vendor/toolkit/twitter/bootstrap/component-animations.less +29 -0
  103. data/vendor/toolkit/twitter/bootstrap/dropdowns.less +176 -0
  104. data/vendor/toolkit/twitter/bootstrap/forms.less +332 -0
  105. data/vendor/toolkit/twitter/bootstrap/grid.less +340 -0
  106. data/vendor/toolkit/twitter/bootstrap/input-groups.less +127 -0
  107. data/vendor/toolkit/twitter/bootstrap/jumbotron.less +29 -0
  108. data/vendor/toolkit/twitter/bootstrap/labels.less +54 -0
  109. data/vendor/toolkit/twitter/bootstrap/list-group.less +88 -0
  110. data/vendor/toolkit/twitter/bootstrap/media.less +56 -0
  111. data/vendor/toolkit/twitter/bootstrap/mixins.less +693 -0
  112. data/vendor/toolkit/twitter/bootstrap/modals.less +133 -0
  113. data/vendor/toolkit/twitter/bootstrap/navbar.less +559 -0
  114. data/vendor/toolkit/twitter/bootstrap/navs.less +228 -0
  115. data/vendor/toolkit/twitter/bootstrap/normalize.less +396 -0
  116. data/vendor/toolkit/twitter/bootstrap/pager.less +55 -0
  117. data/vendor/toolkit/twitter/bootstrap/pagination.less +72 -0
  118. data/vendor/toolkit/twitter/bootstrap/panels.less +128 -0
  119. data/vendor/toolkit/twitter/bootstrap/popovers.less +133 -0
  120. data/vendor/toolkit/twitter/bootstrap/print.less +100 -0
  121. data/vendor/toolkit/twitter/bootstrap/progress-bars.less +99 -0
  122. data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +149 -0
  123. data/vendor/toolkit/twitter/bootstrap/scaffolding.less +111 -0
  124. data/vendor/toolkit/twitter/bootstrap/tables.less +211 -0
  125. data/vendor/toolkit/twitter/bootstrap/thumbnails.less +42 -0
  126. data/vendor/toolkit/twitter/bootstrap/tooltip.less +95 -0
  127. data/vendor/toolkit/twitter/bootstrap/type.less +238 -0
  128. data/vendor/toolkit/twitter/bootstrap/utilities.less +42 -0
  129. data/vendor/toolkit/twitter/bootstrap/variables.less +607 -0
  130. data/vendor/toolkit/twitter/bootstrap/wells.less +29 -0
  131. data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
  132. metadata +297 -0
@@ -0,0 +1,146 @@
1
+ .clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:"";line-height:0;}
2
+ .clearfix:after{clear:both;}
3
+ .hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0;}
4
+ .input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}
5
+ [class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("<%= asset_path 'twitter/bootstrap/glyphicons-halflings.png' %>");background-position:14px 14px;background-repeat:no-repeat;margin-top:1px;}
6
+ .icon-white,.nav-pills>.active>a>[class^="icon-"],.nav-pills>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^="icon-"],.nav-list>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^="icon-"],.navbar-inverse .nav>.active>a>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^="icon-"],.dropdown-menu>li>a:focus>[class^="icon-"],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>li>a:focus>[class*=" icon-"],.dropdown-menu>.active>a>[class^="icon-"],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^="icon-"],.dropdown-submenu:focus>a>[class^="icon-"],.dropdown-submenu:hover>a>[class*=" icon-"],.dropdown-submenu:focus>a>[class*=" icon-"]{background-image:url("<%= asset_path 'twitter/bootstrap/glyphicons-halflings-white.png' %>");}
7
+ .icon-glass{background-position:0 0;}
8
+ .icon-music{background-position:-24px 0;}
9
+ .icon-search{background-position:-48px 0;}
10
+ .icon-envelope{background-position:-72px 0;}
11
+ .icon-heart{background-position:-96px 0;}
12
+ .icon-star{background-position:-120px 0;}
13
+ .icon-star-empty{background-position:-144px 0;}
14
+ .icon-user{background-position:-168px 0;}
15
+ .icon-film{background-position:-192px 0;}
16
+ .icon-th-large{background-position:-216px 0;}
17
+ .icon-th{background-position:-240px 0;}
18
+ .icon-th-list{background-position:-264px 0;}
19
+ .icon-ok{background-position:-288px 0;}
20
+ .icon-remove{background-position:-312px 0;}
21
+ .icon-zoom-in{background-position:-336px 0;}
22
+ .icon-zoom-out{background-position:-360px 0;}
23
+ .icon-off{background-position:-384px 0;}
24
+ .icon-signal{background-position:-408px 0;}
25
+ .icon-cog{background-position:-432px 0;}
26
+ .icon-trash{background-position:-456px 0;}
27
+ .icon-home{background-position:0 -24px;}
28
+ .icon-file{background-position:-24px -24px;}
29
+ .icon-time{background-position:-48px -24px;}
30
+ .icon-road{background-position:-72px -24px;}
31
+ .icon-download-alt{background-position:-96px -24px;}
32
+ .icon-download{background-position:-120px -24px;}
33
+ .icon-upload{background-position:-144px -24px;}
34
+ .icon-inbox{background-position:-168px -24px;}
35
+ .icon-play-circle{background-position:-192px -24px;}
36
+ .icon-repeat{background-position:-216px -24px;}
37
+ .icon-refresh{background-position:-240px -24px;}
38
+ .icon-list-alt{background-position:-264px -24px;}
39
+ .icon-lock{background-position:-287px -24px;}
40
+ .icon-flag{background-position:-312px -24px;}
41
+ .icon-headphones{background-position:-336px -24px;}
42
+ .icon-volume-off{background-position:-360px -24px;}
43
+ .icon-volume-down{background-position:-384px -24px;}
44
+ .icon-volume-up{background-position:-408px -24px;}
45
+ .icon-qrcode{background-position:-432px -24px;}
46
+ .icon-barcode{background-position:-456px -24px;}
47
+ .icon-tag{background-position:0 -48px;}
48
+ .icon-tags{background-position:-25px -48px;}
49
+ .icon-book{background-position:-48px -48px;}
50
+ .icon-bookmark{background-position:-72px -48px;}
51
+ .icon-print{background-position:-96px -48px;}
52
+ .icon-camera{background-position:-120px -48px;}
53
+ .icon-font{background-position:-144px -48px;}
54
+ .icon-bold{background-position:-167px -48px;}
55
+ .icon-italic{background-position:-192px -48px;}
56
+ .icon-text-height{background-position:-216px -48px;}
57
+ .icon-text-width{background-position:-240px -48px;}
58
+ .icon-align-left{background-position:-264px -48px;}
59
+ .icon-align-center{background-position:-288px -48px;}
60
+ .icon-align-right{background-position:-312px -48px;}
61
+ .icon-align-justify{background-position:-336px -48px;}
62
+ .icon-list{background-position:-360px -48px;}
63
+ .icon-indent-left{background-position:-384px -48px;}
64
+ .icon-indent-right{background-position:-408px -48px;}
65
+ .icon-facetime-video{background-position:-432px -48px;}
66
+ .icon-picture{background-position:-456px -48px;}
67
+ .icon-pencil{background-position:0 -72px;}
68
+ .icon-map-marker{background-position:-24px -72px;}
69
+ .icon-adjust{background-position:-48px -72px;}
70
+ .icon-tint{background-position:-72px -72px;}
71
+ .icon-edit{background-position:-96px -72px;}
72
+ .icon-share{background-position:-120px -72px;}
73
+ .icon-check{background-position:-144px -72px;}
74
+ .icon-move{background-position:-168px -72px;}
75
+ .icon-step-backward{background-position:-192px -72px;}
76
+ .icon-fast-backward{background-position:-216px -72px;}
77
+ .icon-backward{background-position:-240px -72px;}
78
+ .icon-play{background-position:-264px -72px;}
79
+ .icon-pause{background-position:-288px -72px;}
80
+ .icon-stop{background-position:-312px -72px;}
81
+ .icon-forward{background-position:-336px -72px;}
82
+ .icon-fast-forward{background-position:-360px -72px;}
83
+ .icon-step-forward{background-position:-384px -72px;}
84
+ .icon-eject{background-position:-408px -72px;}
85
+ .icon-chevron-left{background-position:-432px -72px;}
86
+ .icon-chevron-right{background-position:-456px -72px;}
87
+ .icon-plus-sign{background-position:0 -96px;}
88
+ .icon-minus-sign{background-position:-24px -96px;}
89
+ .icon-remove-sign{background-position:-48px -96px;}
90
+ .icon-ok-sign{background-position:-72px -96px;}
91
+ .icon-question-sign{background-position:-96px -96px;}
92
+ .icon-info-sign{background-position:-120px -96px;}
93
+ .icon-screenshot{background-position:-144px -96px;}
94
+ .icon-remove-circle{background-position:-168px -96px;}
95
+ .icon-ok-circle{background-position:-192px -96px;}
96
+ .icon-ban-circle{background-position:-216px -96px;}
97
+ .icon-arrow-left{background-position:-240px -96px;}
98
+ .icon-arrow-right{background-position:-264px -96px;}
99
+ .icon-arrow-up{background-position:-289px -96px;}
100
+ .icon-arrow-down{background-position:-312px -96px;}
101
+ .icon-share-alt{background-position:-336px -96px;}
102
+ .icon-resize-full{background-position:-360px -96px;}
103
+ .icon-resize-small{background-position:-384px -96px;}
104
+ .icon-plus{background-position:-408px -96px;}
105
+ .icon-minus{background-position:-433px -96px;}
106
+ .icon-asterisk{background-position:-456px -96px;}
107
+ .icon-exclamation-sign{background-position:0 -120px;}
108
+ .icon-gift{background-position:-24px -120px;}
109
+ .icon-leaf{background-position:-48px -120px;}
110
+ .icon-fire{background-position:-72px -120px;}
111
+ .icon-eye-open{background-position:-96px -120px;}
112
+ .icon-eye-close{background-position:-120px -120px;}
113
+ .icon-warning-sign{background-position:-144px -120px;}
114
+ .icon-plane{background-position:-168px -120px;}
115
+ .icon-calendar{background-position:-192px -120px;}
116
+ .icon-random{background-position:-216px -120px;width:16px;}
117
+ .icon-comment{background-position:-240px -120px;}
118
+ .icon-magnet{background-position:-264px -120px;}
119
+ .icon-chevron-up{background-position:-288px -120px;}
120
+ .icon-chevron-down{background-position:-313px -119px;}
121
+ .icon-retweet{background-position:-336px -120px;}
122
+ .icon-shopping-cart{background-position:-360px -120px;}
123
+ .icon-folder-close{background-position:-384px -120px;width:16px;}
124
+ .icon-folder-open{background-position:-408px -120px;width:16px;}
125
+ .icon-resize-vertical{background-position:-432px -119px;}
126
+ .icon-resize-horizontal{background-position:-456px -118px;}
127
+ .icon-hdd{background-position:0 -144px;}
128
+ .icon-bullhorn{background-position:-24px -144px;}
129
+ .icon-bell{background-position:-48px -144px;}
130
+ .icon-certificate{background-position:-72px -144px;}
131
+ .icon-thumbs-up{background-position:-96px -144px;}
132
+ .icon-thumbs-down{background-position:-120px -144px;}
133
+ .icon-hand-right{background-position:-144px -144px;}
134
+ .icon-hand-left{background-position:-168px -144px;}
135
+ .icon-hand-up{background-position:-192px -144px;}
136
+ .icon-hand-down{background-position:-216px -144px;}
137
+ .icon-circle-arrow-right{background-position:-240px -144px;}
138
+ .icon-circle-arrow-left{background-position:-264px -144px;}
139
+ .icon-circle-arrow-up{background-position:-288px -144px;}
140
+ .icon-circle-arrow-down{background-position:-312px -144px;}
141
+ .icon-globe{background-position:-336px -144px;}
142
+ .icon-wrench{background-position:-360px -144px;}
143
+ .icon-tasks{background-position:-384px -144px;}
144
+ .icon-filter{background-position:-408px -144px;}
145
+ .icon-briefcase{background-position:-432px -144px;}
146
+ .icon-fullscreen{background-position:-456px -144px;}
@@ -0,0 +1,16 @@
1
+ module BadgeLabelHelper
2
+ def badge(*args)
3
+ badge_label(:badge, *args)
4
+ end
5
+
6
+ def tag_label(*args)
7
+ badge_label(:label, *args)
8
+ end
9
+
10
+ private
11
+ def badge_label(what, value, type = nil)
12
+ klass = [what]
13
+ klass << "#{what}-#{type}" if type.present?
14
+ content_tag :span, value, :class => "#{klass.join(' ')}"
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ module BootstrapFlashHelper
2
+ ALERT_TYPES = [:success, :info, :warning, :danger]
3
+
4
+ def bootstrap_flash
5
+ flash_messages = []
6
+ flash.each do |type, message|
7
+ # Skip empty messages, e.g. for devise messages set to nothing in a locale file.
8
+ next if message.blank?
9
+
10
+ type = :success if type == :notice
11
+ type = :danger if type == :alert
12
+ type = :danger if type == :error
13
+ next unless ALERT_TYPES.include?(type)
14
+
15
+ Array(message).each do |msg|
16
+ text = content_tag(:div,
17
+ content_tag(:button, raw("&times;"),
18
+ :class => "close",
19
+ "data-dismiss" => "alert",
20
+ "aria-hidden" => "true",
21
+ "type" => "button") +
22
+ msg.html_safe,
23
+ :class => "alert fade in alert-#{type} alert-dismissable")
24
+ flash_messages << text if msg
25
+ end
26
+ end
27
+ flash_messages.join("\n").html_safe
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module FlashBlockHelper
2
+ def flash_block
3
+ output = ''
4
+ flash.each do |type, message|
5
+ output += flash_container(type, message)
6
+ end
7
+
8
+ raw(output)
9
+ end
10
+
11
+ def flash_container(type, message)
12
+ raw(content_tag(:div, :class => "alert alert-#{type}") do
13
+ content_tag(:a, raw("&times;"),:class => 'close', :data => {:dismiss => 'alert'}) +
14
+ message
15
+ end)
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module GlyphHelper
2
+ # ==== Examples
3
+ # glyph(:share_alt)
4
+ # # => <i class="icon-share-alt"></i>
5
+ # glyph(:lock, :white)
6
+ # # => <i class="icon-lock icon-white"></i>
7
+ # glyph(:thumbs_up, :pull_left)
8
+ # # => <i class="icon-thumbs-up pull-left"></i>
9
+
10
+ def glyph(*names)
11
+ names.map! { |name| name.to_s.gsub('_','-') }
12
+ names.map! do |name|
13
+ name =~ /pull-(?:left|right)/ ? name : "icon-#{name}"
14
+ end
15
+ content_tag :i, nil, :class => names
16
+ end
17
+ end
@@ -0,0 +1,59 @@
1
+ module ModalHelper
2
+
3
+ #modals have a header, a body, a footer for options.
4
+ def modal_dialog(options = {}, &block)
5
+ content_tag :div, :id => options[:id], :class => "modal fade" do
6
+ content_tag :div, :class => "modal-dialog" do
7
+ content_tag :div, :class => "modal-content" do
8
+ modal_header(options[:header]) +
9
+ modal_body(options[:body]) +
10
+ modal_footer(options[:footer])
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ def modal_header(options = {}, &block)
17
+ content_tag :div, :class => 'modal-header' do
18
+ if options[:show_close]
19
+ close_button(options[:dismiss]) +
20
+ content_tag(:h4, options[:title], :class => 'modal-title', &block)
21
+ else
22
+ content_tag(:h4, options[:title], :class => 'modal-title', &block)
23
+ end
24
+ end
25
+ end
26
+
27
+ def modal_body(options = {}, &block)
28
+ content_tag :div, options, :class => 'modal-body', &block
29
+ end
30
+
31
+ def modal_footer(options = {}, &block)
32
+ content_tag :div, options, :class => 'modal-footer', &block
33
+ end
34
+
35
+ def close_button(dismiss)
36
+ #It doesn't seem to like content_tag, so we do this instead.
37
+ raw("<button class=\"close\" data-dismiss=\"#{dismiss}\" aria-hidden=\"true\">&times;</button>")
38
+ end
39
+
40
+ def modal_toggle(content_or_options = nil, options = {}, &block)
41
+ if block_given?
42
+ options = content_or_options if content_or_options.is_a?(Hash)
43
+ default_options = { :class => 'btn btn-default', "data-toggle" => "modal", "href" => options[:dialog] }.merge(options)
44
+
45
+ content_tag :a, nil, default_options, true, &block
46
+ else
47
+ default_options = { :class => 'btn btn-default', "data-toggle" => "modal", "href" => options[:dialog] }.merge(options)
48
+ content_tag :a, content_or_options, default_options, true
49
+ end
50
+ end
51
+
52
+ def modal_cancel_button content, options = {}
53
+ default_options = { :class => "btn bootstrap-modal-cancel-button" }
54
+
55
+ content_tag_string "a", content, default_options.merge(options)
56
+ end
57
+
58
+ end
59
+
@@ -0,0 +1,195 @@
1
+ #Credit for this goes to https://github.com/julescopeland/Rails-Bootstrap-Navbar
2
+ module NavbarHelper
3
+ def nav_bar(options={}, &block)
4
+ nav_bar_nav(options) do
5
+ container_div(options[:brand], options[:brand_link], options[:responsive], options[:fluid]) do
6
+ yield if block_given?
7
+ end
8
+ end
9
+ end
10
+
11
+ def menu_group(options={}, &block)
12
+ pull_class = "pull-#{options[:pull].to_s}" if options[:pull].present?
13
+ content_tag(:ul, :class => "nav navbar-nav #{pull_class}", &block)
14
+ end
15
+
16
+ def menu_item(name=nil, path="#", *args, &block)
17
+ path = name || path if block_given?
18
+ options = args.extract_options!
19
+ content_tag :li, :class => is_active?(path, options) do
20
+ name, path = path, options if block_given?
21
+ link_to name, path, options, &block
22
+ end
23
+ end
24
+
25
+ def drop_down(name)
26
+ content_tag :li, :class => "dropdown" do
27
+ drop_down_link(name) + drop_down_list { yield }
28
+ end
29
+ end
30
+
31
+ def drop_down_with_submenu(name, &block)
32
+ content_tag :li, :class => "dropdown" do
33
+ drop_down_link(name) + drop_down_sublist(&block)
34
+ end
35
+ end
36
+
37
+ def drop_down_sublist(&block)
38
+ content_tag :ul, :class => "dropdown-menu", &block
39
+ end
40
+
41
+ def drop_down_submenu(name, &block)
42
+ content_tag :li, :class => "dropdown-submenu" do
43
+ link_to(name, "") + drop_down_list(&block)
44
+ end
45
+ end
46
+
47
+ def drop_down_divider
48
+ content_tag :li, "", :class => "divider"
49
+ end
50
+
51
+ def drop_down_header(text)
52
+ content_tag :li, text, :class => "nav-header"
53
+ end
54
+
55
+ def menu_divider
56
+ content_tag :li, "", :class => "divider-vertical"
57
+ end
58
+
59
+ def menu_text(text=nil, options={}, &block)
60
+ pull = options.delete(:pull)
61
+ pull_class = pull.present? ? "pull-#{pull.to_s}" : nil
62
+ options.append_merge!(:class, pull_class)
63
+ options.append_merge!(:class, "navbar-text")
64
+ content_tag :p, options do
65
+ text || yield
66
+ end
67
+ end
68
+
69
+ # Returns current url or path state (useful for buttons).
70
+ # Example:
71
+ # # Assume we'r currently at blog/categories/test
72
+ # uri_state('/blog/categories/test', {}) # :active
73
+ # uri_state('/blog/categories', {}) # :chosen
74
+ # uri_state('/blog/categories/test', {method: delete}) # :inactive
75
+ # uri_state('/blog/categories/test/3', {}) # :inactive
76
+ def uri_state(uri, options={})
77
+ root_url = request.host_with_port + '/'
78
+ root = uri == '/' || uri == root_url
79
+
80
+ request_uri = if uri.start_with?(root_url)
81
+ request.url
82
+ else
83
+ request.path
84
+ end
85
+
86
+ if !options[:method].nil? || !options["data-method"].nil?
87
+ :inactive
88
+ elsif uri == request_uri
89
+ :active
90
+ else
91
+ if request_uri.start_with?(uri) and not(root)
92
+ :chosen
93
+ else
94
+ :inactive
95
+ end
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def nav_bar_nav(options, &block)
102
+
103
+ position = "static-#{options[:static].to_s}" if options[:static]
104
+ position = "fixed-#{options[:fixed].to_s}" if options[:fixed]
105
+ inverse = (options[:inverse].present? && options[:inverse] == true) ? true : false
106
+
107
+ content_tag :nav, :class => nav_bar_css_class(position, inverse), :role => "navigation" do
108
+ yield
109
+ end
110
+ end
111
+
112
+ def container_div(brand, brand_link, responsive, fluid, &block)
113
+ content_tag :div, :class => "container" do
114
+ container_div_with_block(brand, brand_link, responsive, &block)
115
+ end
116
+ end
117
+
118
+ def container_div_with_block(brand, brand_link, responsive, &block)
119
+ output = []
120
+ if responsive == true
121
+ output << responsive_nav_header(brand, brand_link)
122
+ output << responsive_div { capture(&block) }
123
+ else
124
+ output << brand_link(brand, brand_link)
125
+ output << capture(&block)
126
+ end
127
+ output.join("\n").html_safe
128
+ end
129
+
130
+ def responsive_nav_header(brand, brand_link)
131
+ content_tag(:div, :class => "navbar-header") do
132
+ output = []
133
+ output << responsive_button
134
+ output << brand_link(brand, brand_link)
135
+ output.join("\n").html_safe
136
+ end
137
+ end
138
+
139
+ def nav_bar_css_class(position, inverse = false)
140
+ css_class = ["navbar", "navbar-default"]
141
+ css_class << "navbar-#{position}" if position.present?
142
+ css_class << "navbar-inverse" if inverse
143
+ css_class.join(" ")
144
+ end
145
+
146
+ def brand_link(name, url)
147
+ return "" if name.blank?
148
+ url ||= root_url
149
+ link_to(name, url, :class => "navbar-brand")
150
+ end
151
+
152
+ def responsive_button
153
+ %{<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
154
+ <span class="sr-only">Toggle navigation</span>
155
+ <span class="icon-bar"></span>
156
+ <span class="icon-bar"></span>
157
+ <span class="icon-bar"></span>
158
+ </button>}
159
+ end
160
+
161
+ def responsive_div(&block)
162
+ content_tag(:div, :class => "navbar-collapse collapse", &block)
163
+ end
164
+
165
+ def is_active?(path, options={})
166
+ "active" if uri_state(path, options).in?([:active, :chosen])
167
+ end
168
+
169
+ def name_and_caret(name)
170
+ "#{name} #{content_tag(:b, :class => "caret") {}}".html_safe
171
+ end
172
+
173
+ def drop_down_link(name)
174
+ link_to(name_and_caret(name), "#", :class => "dropdown-toggle", "data-toggle" => "dropdown")
175
+ end
176
+
177
+ def drop_down_list(&block)
178
+ content_tag :ul, :class => "dropdown-menu", &block
179
+ end
180
+ end
181
+
182
+ class Hash
183
+ # appends a string to a hash key's value after a space character (Good for merging CSS classes in options hashes)
184
+ def append_merge!(key, value)
185
+ # just return self if value is blank
186
+ return self if value.blank?
187
+
188
+ current_value = self[key]
189
+ # just merge if it doesn't already have that key
190
+ self[key] = value and return if current_value.blank?
191
+ # raise error if we're trying to merge into something that isn't a string
192
+ raise ArgumentError, "Can only merge strings" unless current_value.is_a?(String)
193
+ self[key] = [current_value, value].compact.join(" ")
194
+ end
195
+ end