diff options
author | azul <azul@riseup.net> | 2014-04-25 16:25:16 +0200 |
---|---|---|
committer | azul <azul@riseup.net> | 2014-04-25 16:25:16 +0200 |
commit | b7dc6ee5220a2d7865bdd86eb86e1fbed4ca28d3 (patch) | |
tree | 9d15194f4cd765a7866e93b1b3eb30c9c52ffda4 /lib | |
parent | 76ad25ba0ee344f185f8e8cdfe066685cd3b0447 (diff) | |
parent | ed3575856276f25b7c8253e302646dc7684a5da8 (diff) |
Merge pull request #150 from azul/bugfix/5542-capitalize-loading
Bugfix/5542 capitalize loading
Diffstat (limited to 'lib')
-rw-r--r-- | lib/extensions/simple_form.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/extensions/simple_form.rb b/lib/extensions/simple_form.rb new file mode 100644 index 0000000..f28e18f --- /dev/null +++ b/lib/extensions/simple_form.rb @@ -0,0 +1,28 @@ +module WrappedButton + def wrapped_button(*args, &block) + template.content_tag :div, :class => "form-actions" do + options = args.extract_options! + options[:class] = ['btn-primary', options[:class]].compact + args.unshift :loading + args << options + if cancel = options.delete(:cancel) + cancel_link = template.link_to I18n.t('simple_form.buttons.cancel'), + cancel, class: :btn + button(*args, &block) + ' ' + cancel_link + else + button(*args, &block) + end + end + end +end +SimpleForm::FormBuilder.send :include, WrappedButton + +module LoadingButton + def loading_button(*args, &block) + options = args.extract_options! + options[:"data-loading-text"] = I18n.t('simple_form.buttons.loading') + args << options + button_button(*args, &block) + end +end +SimpleForm::FormBuilder.send :include, LoadingButton |