Ensure answerboxes on profiles can properly attach sharing functionality
This commit is contained in:
parent
016f369ba2
commit
aa9fc54ad2
|
@ -68,7 +68,7 @@
|
|||
padding-top: 10px;
|
||||
|
||||
@include media-breakpoint-up('sm') {
|
||||
justify-content: unset;
|
||||
justify-content: flex-end;
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,8 @@ export default (): void => {
|
|||
const entries: NodeList = document.querySelectorAll('.answerbox:not(.js-initialized)');
|
||||
|
||||
entries.forEach((element: HTMLElement) => {
|
||||
console.log(element)
|
||||
registerEvents([
|
||||
{ type: 'click', target: element.querySelector('[data-action=ab-share]'), handler: createShareEvent(element) }
|
||||
{ type: 'click', target: element.querySelector('[name=ab-share]'), handler: createShareEvent(element) }
|
||||
]);
|
||||
|
||||
element.classList.add('js-initialized');
|
||||
|
|
|
@ -3,7 +3,7 @@ import noop from 'retrospring/utilities/noop';
|
|||
export function createShareEvent(answerbox: HTMLElement): () => void {
|
||||
return function (): void {
|
||||
navigator.share({
|
||||
url: answerbox.querySelector<HTMLAnchorElement>('.answerbox__answer-date > a').href
|
||||
url: answerbox.querySelector<HTMLAnchorElement>('.answerbox__answer-date > a, a.answerbox__permalink').href
|
||||
})
|
||||
.then(noop)
|
||||
.catch(noop)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export default () => void {
|
||||
export default (): void => {
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
.row
|
||||
.col-md-6.text-left.text-muted
|
||||
%i.fa.fa-clock-o
|
||||
= link_to(raw(t('views.answerbox.time', time: time_tooltip(a))), show_user_answer_path(a.user.screen_name, a.id))
|
||||
= link_to(raw(t('views.answerbox.time', time: time_tooltip(a))), show_user_answer_path(a.user.screen_name, a.id), class: 'answerbox__permalink')
|
||||
.col-md-6.d-md-flex.answerbox__actions
|
||||
= render 'answerbox/actions', a: a, display_all: display_all
|
||||
.card-footer{ id: "ab-comments-section-#{a.id}", style: display_all.nil? ? 'display: none' : nil }
|
||||
|
|
Loading…
Reference in New Issue