summaryrefslogtreecommitdiff
path: root/lib/extensions/simple_form.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-16 08:42:36 +0200
committerAzul <azul@leap.se>2014-05-16 08:42:36 +0200
commit8fbbb8717f0578536b97c2dc0883c632f120e976 (patch)
tree17aeb2b48ada703ac916a9a65fbf3c75a5dadb86 /lib/extensions/simple_form.rb
parent81555ec6244ed76f92e3629880f68104b8705817 (diff)
parenta4f7a410c536d88c91c834cab6ee950c71005ddd (diff)
Merge remote-tracking branch 'origin/develop'
Conflicts: app/assets/javascripts/srp test/nagios/soledad_sync.py test/nagios/webapp_login.py
Diffstat (limited to 'lib/extensions/simple_form.rb')
-rw-r--r--lib/extensions/simple_form.rb28
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