From f2f5337902c1aede4339fa0cf001b41076f3f2bb Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Thu, 14 Apr 2016 13:16:26 +0800 Subject: [PATCH 1/2] bump rake version --- bh.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bh.gemspec b/bh.gemspec index cfbb23b..3d24961 100644 --- a/bh.gemspec +++ b/bh.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| # For development / Code coverage / Documentation spec.add_development_dependency 'bundler', '~> 1.1' spec.add_development_dependency 'rspec', '~> 3.1' - spec.add_development_dependency 'rake', '~> 10.3' + spec.add_development_dependency 'rake', '~> 11.1' spec.add_development_dependency 'yard', '~> 0.8.7' spec.add_development_dependency 'coveralls', '~> 0.8.13' spec.add_development_dependency 'activemodel' # versioned in gemfiles/ From 44b19cdae98b14d6cd09f055ac6eec8a361e6ea6 Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Thu, 14 Apr 2016 14:43:17 +0800 Subject: [PATCH 2/2] Add no_button options for modal helper --- lib/bh/classes/modal.rb | 5 +++++ lib/bh/helpers/modal_helper.rb | 5 ++++- lib/bh/views/bh/_modal.html.erb | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/bh/classes/modal.rb b/lib/bh/classes/modal.rb index 7075470..f41bb2c 100644 --- a/lib/bh/classes/modal.rb +++ b/lib/bh/classes/modal.rb @@ -34,6 +34,11 @@ def caption @options.fetch(:button, {}).fetch :caption, title end + # @return [Boolean] whether to display button of the modal dialog. + def no_button + @options.fetch :no_button, false + end + # @return [#to_s] the title to display on top of the modal dialog. def title @options.fetch :title, 'Modal' diff --git a/lib/bh/helpers/modal_helper.rb b/lib/bh/helpers/modal_helper.rb index b19ac4a..2ae23f2 100644 --- a/lib/bh/helpers/modal_helper.rb +++ b/lib/bh/helpers/modal_helper.rb @@ -15,6 +15,7 @@ module Helpers # Using this option is equivalent to passing the body as an argument. # @option options [#to_s] :size the size of the modal. Can be `:large` # (alias `:lg`) or `:small` (alias `:sm`). + # @option options [Boolean] :no_button (false) whether to display button # @option options [Hash] :button the options for the toggle button. # * :caption (#to_s) ('Modal') the caption of the toggle button. # * :context (#to_s) (:default) the contextual alternative to apply to @@ -37,7 +38,7 @@ module Helpers # end def modal(*args, &block) modal = Bh::Modal.new self, *args, &block - modal.extract! :button, :size, :body, :title, :id + modal.extract! :button, :size, :body, :no_button, :title, :id modal.extract_from :button, [:context, :size, :layout, :caption] modal.append_class_to! :button, :btn @@ -45,6 +46,8 @@ def modal(*args, &block) modal.append_class_to! :button, modal.button_size_class modal.merge! button: {caption: modal.caption} + modal.merge! no_button: modal.no_button + modal.append_class_to! :div, :'modal-dialog' modal.append_class_to! :div, modal.dialog_size_class modal.merge! div: {title: modal.title, id: modal.id} diff --git a/lib/bh/views/bh/_modal.html.erb b/lib/bh/views/bh/_modal.html.erb index ce7ea29..22e124d 100644 --- a/lib/bh/views/bh/_modal.html.erb +++ b/lib/bh/views/bh/_modal.html.erb @@ -1,4 +1,4 @@ - +<% unless no_button %><% end %>