quiz_question.html.twig 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <div class="text-center">
  2. <p>{{ 'YouNeedToIdentifyYourselfToAnswerThisQuestion'|get_plugin_lang('WhispeakAuthPlugin') }}</p>
  3. <button type="button" class="btn btn-info" id="whispeak-question-{{ question }}" data-loading-text="{{ 'PleaseWaitWhileLoading'|get_plugin_lang('WhispeakAuthPlugin')|escape('html') }}">
  4. {{ 'IdentifyMe'|get_plugin_lang('WhispeakAuthPlugin') }}
  5. </button>
  6. </div>
  7. <script>
  8. $(function () {
  9. function loadAuth() {
  10. var $btnTrigger = $('#whispeak-question-{{ question }}'),
  11. originalText = $btnTrigger.text(),
  12. $modal = $('#global-modal'),
  13. $modalTitle = $modal.find('.modal-title'),
  14. $modalBody = $modal.find('.modal-body'),
  15. $originalLoadingText = $btnTrigger.data('loading-text');
  16. $btnTrigger.text($originalLoadingText).prop('disabled', true);
  17. $modalTitle.text($originalLoadingText);
  18. $modalBody.html('');
  19. $modal.modal('show');
  20. $
  21. .ajax({
  22. url: _p.web_plugin + 'whispeakauth/authentify.php'
  23. })
  24. .then(function (response) {
  25. $modalBody.html(response);
  26. $modalTitle.text('{{ 'plugin_title'|get_plugin_lang('WhispeakAuthPlugin') }}');
  27. $btnTrigger.text(originalText).prop('disabled', false);
  28. });
  29. }
  30. $('#whispeak-question-{{ question }}').on('click', function (e) {
  31. e.preventDefault();
  32. loadAuth();
  33. });
  34. loadAuth();
  35. });
  36. </script>