debian-mirror-gitlab/app/helpers/button_helper.rb

57 lines
1.5 KiB
Ruby
Raw Normal View History

2015-12-23 02:04:40 +05:30
module ButtonHelper
# 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: "div#foo")
# # => "<button class='...' data-clipboard-target='div#foo'>...</button>"
#
# See http://clipboardjs.com/#usage
def clipboard_button(data = {})
content_tag :button,
icon('clipboard'),
class: 'btn btn-clipboard',
2015-12-23 02:04:40 +05:30
data: data,
type: :button
end
def http_clone_button(project)
2016-06-02 11:05:42 +05:30
klass = 'http-selector'
klass << ' has-tooltip' if current_user.try(:require_password?)
2015-12-23 02:04:40 +05:30
protocol = gitlab_config.protocol.upcase
2016-06-02 11:05:42 +05:30
content_tag :a, protocol,
2015-12-23 02:04:40 +05:30
class: klass,
href: project.http_url_to_repo,
2015-12-23 02:04:40 +05:30
data: {
2016-06-02 11:05:42 +05:30
html: true,
placement: 'right',
2015-12-23 02:04:40 +05:30
container: 'body',
title: "Set a password on your account<br>to pull or push via #{protocol}"
2016-06-02 11:05:42 +05:30
}
2015-12-23 02:04:40 +05:30
end
def ssh_clone_button(project)
2016-06-02 11:05:42 +05:30
klass = 'ssh-selector'
klass << ' has-tooltip' if current_user.try(:require_ssh_key?)
2015-12-23 02:04:40 +05:30
2016-06-02 11:05:42 +05:30
content_tag :a, 'SSH',
2015-12-23 02:04:40 +05:30
class: klass,
2016-06-02 11:05:42 +05:30
href: project.ssh_url_to_repo,
2015-12-23 02:04:40 +05:30
data: {
2016-06-02 11:05:42 +05:30
html: true,
placement: 'right',
2015-12-23 02:04:40 +05:30
container: 'body',
title: 'Add an SSH key to your profile<br>to pull or push via SSH.'
2016-06-02 11:05:42 +05:30
}
2015-12-23 02:04:40 +05:30
end
end