Browse Source

Предотвращаем публикацию, если не нажата кнопка проверки в ВК #43

pull/45/head
Artur Galyamov 2 years ago
parent
commit
e1a9a13d75
  1. 13
      cms/templates/articles/new.html

13
cms/templates/articles/new.html

@ -19,6 +19,7 @@
<button <button
class="btn btn-primary" class="btn btn-primary"
type="submit" type="submit"
disabled="disabled"
> >
Продвинуть Продвинуть
</button> </button>
@ -35,8 +36,13 @@
{% endblock content %} {% endblock content %}
{% block extra_scripts %} {% block extra_scripts %}
<script type="text/javascript"> <script type="text/javascript">
const main = () => { let submitBtn = null
const enableSubmitBtn = () => {
submitBtn.disabled = false
}
const appendShare = (e) => { const appendShare = (e) => {
submitBtn.disabled = true
const articleLink = e.target.value; const articleLink = e.target.value;
const gen = { const gen = {
url: articleLink url: articleLink
@ -46,7 +52,12 @@
text: '<img src="https://vk.com/images/share_32_2x.png" width="32" height="32" alt="share icon" />' text: '<img src="https://vk.com/images/share_32_2x.png" width="32" height="32" alt="share icon" />'
} }
document.getElementById('vkShare').innerHTML = VK.Share.button(gen, buttonType) document.getElementById('vkShare').innerHTML = VK.Share.button(gen, buttonType)
const vkButtons = document.querySelectorAll('a[href^="//vk.com/"]')
vkButtons.forEach((vkBtn) => vkBtn.addEventListener('click', enableSubmitBtn))
} }
const main = () => {
submitBtn = document.querySelector('button[type="submit"]')
const linkInput = document.querySelector('[name="link"]'); const linkInput = document.querySelector('[name="link"]');
linkInput.addEventListener('input', appendShare) linkInput.addEventListener('input', appendShare)
linkInput.addEventListener('paste', appendShare) linkInput.addEventListener('paste', appendShare)

Loading…
Cancel
Save