diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-11-25 02:35:24 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-11-25 03:12:03 +0300 |
commit | 7dab8ed739359bc579d8bc4d3de61816993ca57d (patch) | |
tree | 9271059f8a674f36c9d49617e288087aba9c040b /app/helpers/button_helper.rb | |
parent | acc0f162c864d2a061461467473fca8761b6611f (diff) |
Rework the copy_to_clipboard logic
It needed to be more flexible in how we set the target text or element.
Diffstat (limited to 'app/helpers/button_helper.rb')
-rw-r--r-- | app/helpers/button_helper.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index bbb35afca89..b9bb1ac8d88 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -1,8 +1,24 @@ module ButtonHelper - def clipboard_button + # Output a "Copy to Clipboard" button + # + # data - Data attributes passed to `content_tag` + # + # Examples: + # + # # Define the clipboard's text + # clipboard_button(clipboard_text: "Foo") + # # => "<button class='...' data-clipboard-text='Foo'>...</button>" + # + # # Define the target element + # clipboard_button(clipboard_target: "#foo") + # # => "<button class='...' data-clipboard-target='#foo'>...</button>" + # + # See http://clipboardjs.com/#usage + def clipboard_button(data = {}) content_tag :button, icon('clipboard'), - class: 'btn btn-xs btn-clipboard js-clipboard-trigger', + class: 'btn btn-xs btn-clipboard', + data: data, type: :button end |