Sha256: b6797905a96bd930b41baaec359a4d9a0d97177d3d2a6853bca03e4689d9f3c8

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

---
layout: null
---

(function ($) {
  var $comments = $('.js-comments');

  $('#new_comment').submit(function () {
    var form = this;

    $(form).addClass('disabled');

    {% assign sm = site.staticman -%}
    var endpoint = '{{ sm.endpoint | default: "https://staticman3.herokuapp.com/v3/entry/github/" }}';
    var repository = '{{ sm.repository }}';
    var branch = '{{ sm.branch }}';

    $.ajax({
      type: $(this).attr('method'),
      url: endpoint + repository + '/' + branch + '/comments',
      data: $(this).serialize(),
      contentType: 'application/x-www-form-urlencoded',
      success: function (data) {
        $('#comment-form-submit').addClass('d-none');
        $('#comment-form-submitted').removeClass('d-none');
        $('.page__comments-form .js-notice').removeClass('alert-danger');
        $('.page__comments-form .js-notice').addClass('alert-success');
        showAlert('success');
      },
      error: function (err) {
        console.log(err);
        $('#comment-form-submitted').addClass('d-none');
        $('#comment-form-submit').removeClass('d-none');
        $('.page__comments-form .js-notice').removeClass('alert-success');
        $('.page__comments-form .js-notice').addClass('alert-danger');
        showAlert('failure');
        $(form).removeClass('disabled');
      }
    });

    return false;
  });

  function showAlert(message) {
    $('.page__comments-form .js-notice').removeClass('d-none');
    if (message == 'success') {
      $('.page__comments-form .js-notice-text-success').removeClass('d-none');
      $('.page__comments-form .js-notice-text-failure').addClass('d-none');
    } else {
      $('.page__comments-form .js-notice-text-success').addClass('d-none');
      $('.page__comments-form .js-notice-text-failure').removeClass('d-none');
    }
  }
})(jQuery);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
beautiful-jekyll-theme-5.0.0 assets/js/staticman.js
beautiful-jekyll-theme-4.1.0 assets/js/staticman.js
beautiful-jekyll-theme-4.0.1 assets/js/staticman.js