Skip to content

Commit

Permalink
rebuild assets
Browse files Browse the repository at this point in the history
  • Loading branch information
deniak committed Sep 27, 2023
1 parent a02be03 commit 00fe62f
Show file tree
Hide file tree
Showing 21 changed files with 686 additions and 675 deletions.
72 changes: 36 additions & 36 deletions public/dist/assets/js/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "translate": () => (/* binding */ translate)
/* harmony export */ });
const translate = {
var translate = {
'translations': {
//microcopy translations
'ar': {
Expand Down Expand Up @@ -188,8 +188,8 @@ const translate = {
//languageCode = code of the target language
//injection = object of values to inject into the string if interpolation is required, object keys should match references in the translations snippets,
// e.g. 'Slide {x} of {y} requires an object with keys x and y.
'translate': function (snippetReference, languageCode) {
let injections = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
'translate': function translate(snippetReference, languageCode) {
var injections = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
//without a snippet reference, we don't know what to translate
if (snippetReference === undefined || snippetReference === null || snippetReference.length < 1) {
return;
Expand Down Expand Up @@ -279,17 +279,17 @@ __webpack_require__.r(__webpack_exports__);
/**
* Replaces comment dates with their equivalent time difference (xx hours/days ago)
*/
let commentsTimeDiff = function () {
var commentsTimeDiff = function () {
document.querySelectorAll(".comment__author time").forEach(function (time) {
time.setAttribute('title', time.innerHTML.trim());
const date = new Date(time.getAttribute("datetime"));
const deltaSeconds = Math.round((date.getTime() - Date.now()) / 1000);
const deltaMinutes = Math.round(deltaSeconds / 60);
const deltaHours = Math.round(deltaSeconds / (60 * 60));
const deltaDays = Math.round(deltaSeconds / (60 * 60 * 24));
const deltaMonths = Math.round(deltaSeconds / (60 * 60 * 24 * 30));
const deltaYears = Math.round(deltaSeconds / (60 * 60 * 24 * 365));
const formatter = new Intl.RelativeTimeFormat(document.documentElement.lang, {
var date = new Date(time.getAttribute("datetime"));
var deltaSeconds = Math.round((date.getTime() - Date.now()) / 1000);
var deltaMinutes = Math.round(deltaSeconds / 60);
var deltaHours = Math.round(deltaSeconds / (60 * 60));
var deltaDays = Math.round(deltaSeconds / (60 * 60 * 24));
var deltaMonths = Math.round(deltaSeconds / (60 * 60 * 24 * 30));
var deltaYears = Math.round(deltaSeconds / (60 * 60 * 24 * 365));
var formatter = new Intl.RelativeTimeFormat(document.documentElement.lang, {
numeric: "auto"
});
if (deltaYears != 0) {
Expand All @@ -314,32 +314,32 @@ let commentsTimeDiff = function () {

window.addComment = function (window) {
// Avoid scope lookups on commonly used variables.
let document = window.document;
let commentReplyTitle = document.querySelector('[data-title="reply"]');
var document = window.document;
var commentReplyTitle = document.querySelector('[data-title="reply"]');
if (!commentReplyTitle) {
return;
}
let origReplyTitle = commentReplyTitle.textContent;
let commentForm = document.getElementById('comment-form');
var origReplyTitle = commentReplyTitle.textContent;
var commentForm = document.getElementById('comment-form');

// I18N
let cancelText = _main_translations__WEBPACK_IMPORTED_MODULE_0__.translate.translate('cancelReply', document.documentElement.lang);
var cancelText = _main_translations__WEBPACK_IMPORTED_MODULE_0__.translate.translate('cancelReply', document.documentElement.lang);
function changeLinksToBtns() {
let linksArray = Array.prototype.slice.call(document.querySelectorAll('[data-replylink]'));
var linksArray = Array.prototype.slice.call(document.querySelectorAll('[data-replylink]'));
linksArray.forEach(function (link) {
let attributes = link.dataset;
let btn = document.createElement('button');
var attributes = link.dataset;
var btn = document.createElement('button');
btn.setAttribute('class', 'button button--ghost');
btn.innerHTML = link.innerHTML;
for (let key in attributes) {
for (var key in attributes) {
btn.setAttribute('data-' + key, attributes[key]);
}
link.parentNode.replaceChild(btn, link);
});
}
function addPlaceHolder(respondElement) {
let temporaryFormId = 'js-temp-form-div';
let temporaryElement = document.getElementById(temporaryFormId);
var temporaryFormId = 'js-temp-form-div';
var temporaryElement = document.getElementById(temporaryFormId);
if (temporaryElement) {
// The element already exists, no need to recreate.
return;
Expand All @@ -350,25 +350,25 @@ window.addComment = function (window) {
respondElement.parentNode.insertBefore(temporaryElement, respondElement);
}
function addCancelBtn(respondElement) {
let cancelBtnId = 'js-cancel-reply';
let cancelBtn = document.getElementById(cancelBtnId);
var cancelBtnId = 'js-cancel-reply';
var cancelBtn = document.getElementById(cancelBtnId);
if (cancelBtn) {
cancelBtn.style.display = '';
return;
}
let targetDiv = respondElement.querySelector('div');
var targetDiv = respondElement.querySelector('div');
cancelBtn = document.createElement('button');
cancelBtn.setAttribute('id', cancelBtnId);
cancelBtn.setAttribute('class', 'button button--ghost');
cancelBtn.textContent = cancelText;
targetDiv.appendChild(cancelBtn);
}
function moveForm(addBelowId, commentId) {
let addBelowElement = document.getElementById(addBelowId);
let respondElement = document.querySelector('[data-respondelement]');
var addBelowElement = document.getElementById(addBelowId);
var respondElement = document.querySelector('[data-respondelement]');

// Get the hidden fields
let parentIdField = commentForm.querySelector('input[name="parent"]');
var parentIdField = commentForm.querySelector('input[name="parent"]');
parentIdField.value = commentId;
addPlaceHolder(respondElement);
addCancelBtn(respondElement);
Expand All @@ -383,19 +383,19 @@ window.addComment = function (window) {
commentForm.querySelector('[type="submit"]').nextElementSibling.style.display = 'none';
document.addEventListener('click', function (event) {
if (event.target.matches('[data-replylink]')) {
let replyLink = event.target;
let newReplyTitle = replyLink.getAttribute('data-replyto');
let commentId = replyLink.getAttribute('data-belowelement');
let parentId = replyLink.getAttribute('data-commentid');
let postId = replyLink.getAttribute('data-postid');
var replyLink = event.target;
var newReplyTitle = replyLink.getAttribute('data-replyto');
var commentId = replyLink.getAttribute('data-belowelement');
var parentId = replyLink.getAttribute('data-commentid');
var postId = replyLink.getAttribute('data-postid');
if (!commentId || !parentId || !postId) return;
event.preventDefault();
commentReplyTitle.textContent = newReplyTitle;
moveForm(commentId, parentId, postId);
}
if (event.target.matches('#js-cancel-reply')) {
let temporaryElement = document.getElementById('js-temp-form-div');
let respondElement = document.querySelector('[data-respondelement]');
var temporaryElement = document.getElementById('js-temp-form-div');
var respondElement = document.querySelector('[data-respondelement]');
commentReplyTitle.textContent = origReplyTitle;
temporaryElement.parentNode.replaceChild(respondElement, temporaryElement);
respondElement.querySelector('input[name="parent"]').value = '';
Expand Down
Loading

0 comments on commit 00fe62f

Please sign in to comment.