\n \n
' + comment.body_html + '
\n
\n ';
- var likeButton = commentItem.querySelector('.gitment-comment-like-btn');
- var likedReaction = commentReactions[comment.id] && commentReactions[comment.id].find(function (reaction) {
- return reaction.content === 'heart' && reaction.user.login === user.login;
- });
- if (likedReaction) {
- likeButton.classList.add('liked');
- likeButton.onclick = function () {
- return instance.unlikeAComment(comment.id);
- };
- } else {
- likeButton.classList.remove('liked');
- likeButton.onclick = function () {
- return instance.likeAComment(comment.id);
- };
- }
-
- // dirty
- // use a blank image to trigger height calculating when element rendered
- var imgTrigger = document.createElement('img');
- var markdownBody = commentItem.querySelector('.gitment-comment-body');
- imgTrigger.className = 'gitment-hidden';
- imgTrigger.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
- imgTrigger.onload = function () {
- if (markdownBody.clientHeight > instance.maxCommentHeight) {
- markdownBody.classList.add('gitment-comment-body-folded');
- markdownBody.style.maxHeight = instance.maxCommentHeight + 'px';
- markdownBody.title = 'Click to Expand';
- markdownBody.onclick = function () {
- markdownBody.classList.remove('gitment-comment-body-folded');
- markdownBody.style.maxHeight = '';
- markdownBody.title = '';
- markdownBody.onclick = null;
- };
- }
- };
- commentItem.appendChild(imgTrigger);
-
- commentsList.appendChild(commentItem);
- });
-
- container.appendChild(commentsList);
-
- if (meta) {
- var pageCount = Math.ceil(meta.comments / instance.perPage);
- if (pageCount > 1) {
- var pagination = document.createElement('ul');
- pagination.className = 'gitment-comments-pagination';
-
- if (currentPage > 1) {
- var previousButton = document.createElement('li');
- previousButton.className = 'gitment-comments-page-item';
- previousButton.innerText = 'Previous';
- previousButton.onclick = function () {
- return instance.goto(currentPage - 1);
- };
- pagination.appendChild(previousButton);
- }
-
- var _loop = function _loop(i) {
- var pageItem = document.createElement('li');
- pageItem.className = 'gitment-comments-page-item';
- pageItem.innerText = i;
- pageItem.onclick = function () {
- return instance.goto(i);
- };
- if (currentPage === i) pageItem.classList.add('gitment-selected');
- pagination.appendChild(pageItem);
- };
-
- for (var i = 1; i <= pageCount; i++) {
- _loop(i);
- }
-
- if (currentPage < pageCount) {
- var nextButton = document.createElement('li');
- nextButton.className = 'gitment-comments-page-item';
- nextButton.innerText = 'Next';
- nextButton.onclick = function () {
- return instance.goto(currentPage + 1);
- };
- pagination.appendChild(nextButton);
- }
-
- container.appendChild(pagination);
- }
- }
-
- return container;
-}
-
-function renderEditor(_ref3, instance) {
- var user = _ref3.user,
- error = _ref3.error;
-
- var container = document.createElement('div');
- container.lang = "en-US";
- container.className = 'gitment-container gitment-editor-container';
-
- var shouldDisable = user.login && !error ? '' : 'disabled';
- var disabledTip = user.login ? '' : 'Login to Comment';
- container.innerHTML = '\n ' + (user.login ? '