diff --git a/examples/middleman/source/index.html.erb b/examples/middleman/source/index.html.erb index 7a71962..6a0a633 100644 --- a/examples/middleman/source/index.html.erb +++ b/examples/middleman/source/index.html.erb @@ -50,7 +50,7 @@ <%= modal 'Do what you want!', button: {size: :small, context: :info} %> - <% modal size: :large, id: 'modal', button: {class: :en} do %> + <% modal size: :large, id: 'modal', button: {class: :en}, animated: false do %> <% end %> @@ -155,4 +155,4 @@ <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' %> <%= javascript_include_tag bootstrap_js %> - \ No newline at end of file + diff --git a/examples/padrino/app/views/index.html.erb b/examples/padrino/app/views/index.html.erb index 00da322..88c0594 100644 --- a/examples/padrino/app/views/index.html.erb +++ b/examples/padrino/app/views/index.html.erb @@ -47,7 +47,7 @@ <%= modal 'Do what you want!', button: {size: :small, context: :info} %> - <% modal title: 'Terms of service', size: :large, id: 'modal', button: {class: :en} do %> + <% modal title: 'Terms of service', size: :large, id: 'modal', button: {class: :en}, animated: false do %> <% end %> @@ -152,4 +152,4 @@ <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' %> <%= javascript_include_tag bootstrap_js %> - \ No newline at end of file + diff --git a/examples/rails/app/views/application/index.html.erb b/examples/rails/app/views/application/index.html.erb index 15def25..1b3a44f 100644 --- a/examples/rails/app/views/application/index.html.erb +++ b/examples/rails/app/views/application/index.html.erb @@ -47,7 +47,7 @@ <%= modal 'Do what you want!', button: {size: :small, context: :info} %> - <%= modal title: 'Terms of service', size: :large, id: 'modal', button: {class: :en} do %> + <%= modal title: 'Terms of service', size: :large, id: 'modal', button: {class: :en}, animated: false do %> <% end %> @@ -157,4 +157,4 @@ <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' %> <%= javascript_include_tag bootstrap_js %> - \ No newline at end of file + diff --git a/lib/bh/classes/modal.rb b/lib/bh/classes/modal.rb index 7075470..32ca4d9 100644 --- a/lib/bh/classes/modal.rb +++ b/lib/bh/classes/modal.rb @@ -29,6 +29,11 @@ def dialog_size_class Modal.dialog_sizes[@options[:size]] end + # @return [#to_s] the animation-related class to assign to the modal. + def animation_class + Modal.animation_class if @options.fetch :animated, true + end + # @return [#to_s] the caption for the modal button. def caption @options.fetch(:button, {}).fetch :caption, title @@ -56,6 +61,11 @@ def self.dialog_sizes end end + # @return [#to_s] the class that defines the modal's animation. + def self.animation_class + 'fade' + end + def extract_content_from(*args, &block) if block_given? super @@ -65,4 +75,4 @@ def extract_content_from(*args, &block) end end end -end \ No newline at end of file +end diff --git a/lib/bh/helpers/modal_helper.rb b/lib/bh/helpers/modal_helper.rb index b19ac4a..9b332d4 100644 --- a/lib/bh/helpers/modal_helper.rb +++ b/lib/bh/helpers/modal_helper.rb @@ -24,6 +24,8 @@ module Helpers # (alias `:xs`), `:large` (alias `:lg`) or `:small` (alias `:sm`). # * :layout (#to_s) if set to `:block`, span the button for the full # width of the parent. + # @option options [Boolean] :animated (true) option for disabling the + # default modal animation. # @example Display a simple modal toggled by a blue button. # modal 'You clicked me!', title: 'Click me', button: {context: :info} # @overload modal(options = {}, &block) @@ -37,7 +39,9 @@ module Helpers # end def modal(*args, &block) modal = Bh::Modal.new self, *args, &block - modal.extract! :button, :size, :body, :title, :id + modal.extract! :animated, :button, :size, :body, :title, :id + + modal.append_class_to! :animation, modal.animation_class modal.extract_from :button, [:context, :size, :layout, :caption] modal.append_class_to! :button, :btn @@ -52,4 +56,4 @@ def modal(*args, &block) modal.render_partial 'modal' end end -end \ No newline at end of file +end diff --git a/lib/bh/views/bh/_modal.html.erb b/lib/bh/views/bh/_modal.html.erb index ce7ea29..2fd19b8 100644 --- a/lib/bh/views/bh/_modal.html.erb +++ b/lib/bh/views/bh/_modal.html.erb @@ -1,5 +1,5 @@ -