Add share option to answers
This commit is contained in:
parent
49c33486dd
commit
a13322dcee
|
@ -62,3 +62,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
body:not(.cap-web-share) {
|
||||
.answerbox__action[name="ab-share"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import $ from 'jquery';
|
||||
|
||||
export default (): void => {
|
||||
document.addEventListener('turbolinks:load', function () {
|
||||
if (navigator.share) {
|
||||
document.body.classList.add('cap-web-share')
|
||||
$(document).on('click', 'button[name=ab-share]', function () {
|
||||
const card = $(this).closest('.card')
|
||||
|
||||
navigator.share({
|
||||
url: card.find('.answerbox__answer-date a')[0].href
|
||||
}).then(() => {
|
||||
// do nothing, prevents exception from being thrown
|
||||
}).catch(() => {
|
||||
// do nothing, prevents exception from being thrown
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
|
@ -16,6 +16,8 @@
|
|||
%button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-comments', data: { a_id: a.id, state: :hidden } }
|
||||
%i.fa.fa-fw.fa-comments
|
||||
%span{ id: "ab-comment-count-#{a.id}" }= a.comment_count
|
||||
%button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-share'}
|
||||
%i.fa.fa-fw.fa-share-alt{ title: 'Share' }
|
||||
- if user_signed_in?
|
||||
.btn-group
|
||||
%button.btn.btn-default.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
|
||||
|
|
Loading…
Reference in New Issue