Commit bd91bf1e authored by Lukas Eipert's avatar Lukas Eipert

Remove reference to unused js-timeago-render class

Apparently the `.js-timeago-render` class serves no real purpose. All
functions that used it, directly pass a list of elements. Only one Vue
component had an (unnecessary) reference to the class. No styles are
applied.
parent 636c36bb
......@@ -141,7 +141,7 @@ export default {
<time-ago
v-if="version.created_at"
:time="version.created_at"
class="js-timeago js-timeago-render"
class="js-timeago"
/>
</small>
</div>
......
......@@ -132,45 +132,29 @@ export const getTimeago = () => {
return timeagoInstance;
};
/**
* For the given element, renders a timeago instance.
* @param {jQuery} $els
*/
export const renderTimeago = $els => {
const timeagoEls = $els || document.querySelectorAll('.js-timeago-render');
// timeago.js sets timeouts internally for each timeago value to be updated in real time
getTimeago().render(timeagoEls, timeagoLanguageCode);
};
/**
* For the given elements, will add timeago tooltips
*/
export const addTimeAgoTooltip = () => {
const timeagoEls = document.querySelectorAll('.js-timeago-render');
timeagoEls.forEach(element => {
$(element).tooltip({
template:
'<div class="tooltip local-timeago" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',
});
});
};
/**
* For the given elements, sets a tooltip with a formatted date.
* @param {jQuery}
* @param {JQuery} $timeagoEls
* @param {Boolean} setTimeago
*/
export const localTimeAgo = ($timeagoEls, setTimeago = true) => {
$timeagoEls.each((i, el) => {
el.classList.add('js-timeago-render');
});
getTimeago().render($timeagoEls, timeagoLanguageCode);
renderTimeago($timeagoEls);
if (!setTimeago) {
return;
}
if (setTimeago) {
requestIdleCallback(addTimeAgoTooltip);
function addTimeAgoTooltip() {
$timeagoEls.each((i, el) => {
// Recreate with custom template
$(el).tooltip({
template:
'<div class="tooltip local-timeago" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',
});
});
}
requestIdleCallback(addTimeAgoTooltip);
};
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment