diff --git a/app/assets/javascripts/question.coffee b/app/assets/javascripts/question.coffee index d07cb337..49b5f57d 100644 --- a/app/assets/javascripts/question.coffee +++ b/app/assets/javascripts/question.coffee @@ -1,15 +1,15 @@ -$(document).on "keydown", "textarea#q-answer", (evt) -> +$(document).on "keydown", "textarea#q-answer-text", (evt) -> qid = $(this)[0].dataset.id if evt.keyCode == 13 and evt.ctrlKey # trigger warning: - $("button#q-answer").trigger 'click' + $("button#q-answer-btn").trigger 'click' -$(document).on "click", "button#q-answer", -> +$(document).on "click", "button#q-answer-btn", -> btn = $(this) btn.button "loading" qid = btn[0].dataset.qId - $("textarea#q-answer").attr "readonly", "readonly" + $("textarea#q-answer-text").attr "readonly", "readonly" shareTo = [] ($ "input[type=checkbox][name=share][data-q-id=#{qid}]:checked").each (i, share) -> @@ -21,7 +21,7 @@ $(document).on "click", "button#q-answer", -> dataType: 'json' data: id: qid - answer: $("textarea#q-answer[data-id=#{qid}]").val() + answer: $("textarea#q-answer-text[data-id=#{qid}]").val() share: JSON.stringify shareTo inbox: false success: (data, status, jqxhr) -> @@ -34,4 +34,4 @@ $(document).on "click", "button#q-answer", -> showNotification translate('frontend.error.message'), false complete: (jqxhr, status) -> btn.button "reset" - $("textarea#q-answer").removeAttr "readonly" + $("textarea#q-answer-text").removeAttr "readonly" diff --git a/app/views/question/_question.haml b/app/views/question/_question.haml index 045ef6d2..8f9a28c7 100644 --- a/app/views/question/_question.haml +++ b/app/views/question/_question.haml @@ -1,24 +1,28 @@ -.card.question--fixed{class: if hidden then 'question--hidden' end, tabindex: if hidden then '-1' end, aria: { hidden: if hidden then :true end }} +.card.question--fixed{ class: if hidden then 'question--hidden' end, tabindex: hidden ? '-1' : '', aria: { hidden: hidden } } .container .card-body .media - unless question.author_is_anonymous - %a.pull-left{href: unless hidden then show_user_profile_path(question.user.screen_name) end} - %img.answerbox__question-user-avatar.avatar-md{src: question.user.profile_picture.url(:medium)} + %a.pull-left{ href: unless hidden then show_user_profile_path(question.user.screen_name) end } + %img.answerbox__question-user-avatar.avatar-md{ src: question.user.profile_picture.url(:medium) } .media-body - if user_signed_in? .pull-right .btn-group - %button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} + %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %span.caret - unless hidden - .dropdown-menu.dropdown-menu-right{role: :menu} - - if current_user.mod? or question.user == current_user - %a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: question.id, redirect: if question.author_is_anonymous? then "/" else show_user_questions_path(question.user.screen_name) end }} + .dropdown-menu.dropdown-menu-right{ role: :menu } + - if current_user.mod? || question.user == current_user + %a.dropdown-item.text-danger{ href: '#', + tabindex: -1, + data: { action: 'ab-question-destroy', + q_id: question.id, + redirect: question.author_is_anonymous? ? '/' : show_user_questions_path(question.user.screen_name) } } %i.fa.fa-trash-o = t 'views.actions.delete' - unless question.user == current_user - %a.dropdown-item{href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id }} + %a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id } } %i.fa.fa-exclamation-triangle = t 'views.actions.report' %h6.text-muted.media-heading.answerbox__question-user diff --git a/app/views/question/show.haml b/app/views/question/show.haml index bb460154..329f50a2 100644 --- a/app/views/question/show.haml +++ b/app/views/question/show.haml @@ -9,18 +9,18 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @answers_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @answers_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @answers_last_id } } Load more - if user_signed_in? && !current_user.answered?(@question) && current_user != @question.user && @question.user&.privacy_allow_stranger_answers .card#q-answer-box .card-header= t('views.question.title') .card-body - %textarea#q-answer.form-control{placeholder: t('views.placeholder.inbox'), data: { id: @question.id }} + %textarea.form-control#q-answer-text{ placeholder: t('views.placeholder.inbox'), data: { id: @question.id } } %br/ - %button#q-answer.btn.btn-success{data: { q_id: @question.id }} + %button.btn.btn-success#q-answer-btn{ data: { q_id: @question.id } } = t('views.actions.answer') - current_user.services.each do |service| %label - %input{type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider }} + %input{ type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider } } = t('views.inbox.entry.sharing.post', service: service.provider.capitalize)