Sha256: 07da77a39a88798728016df080ddec5fe4f028a72dd6f0eb42c0cafe77ff8ee6

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

var mumuki = mumuki || {};

mumuki.load(function () {
  var $newDiscussionModal = $('.new-discussion-modal');
  var $newDiscussion = $('.discussion-create');

  $newDiscussion.click(function () {
    $newDiscussionModal.modal({
      backdrop: 'static',
      keyboard: false
    });
  });

  var $subscriptionSpans = $('.discussion-subscription > span');
  var $upvoteSpans = $('.discussion-upvote > span');

  var Forum = {
    toggleButton: function (spans) {
      spans.toggleClass('hidden');
    },
    token: new mumuki.CsrfToken(),
    discussionSubscription: function (url) {
      Forum.discussionPostAndToggle(url, $subscriptionSpans)
    },
    discussionUpvote: function (url) {
      Forum.discussionPostAndToggle(url, $upvoteSpans)
    },
    discussionPostAndToggle: function (url, elem) {
      Forum.tokenRequest({
        url: url,
        method: 'POST',
        success: Forum.toggleButton(elem),
        xhrFields: {withCredentials: true}
      })
    },
    tokenRequest: function (data) {
      $.ajax(Forum.token.newRequest(data))
    }
  };

  mumuki.Forum = Forum;

});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mumuki-laboratory-5.6.3 app/assets/javascripts/application/discussions.js
mumuki-laboratory-5.6.2 app/assets/javascripts/application/discussions.js
mumuki-laboratory-5.6.1 app/assets/javascripts/application/discussions.js
mumuki-laboratory-5.6.0 app/assets/javascripts/application/discussions.js