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 { ...@@ -141,7 +141,7 @@ export default {
<time-ago <time-ago
v-if="version.created_at" v-if="version.created_at"
:time="version.created_at" :time="version.created_at"
class="js-timeago js-timeago-render" class="js-timeago"
/> />
</small> </small>
</div> </div>
......
...@@ -133,44 +133,28 @@ export const getTimeago = () => { ...@@ -133,44 +133,28 @@ export const getTimeago = () => {
}; };
/** /**
* For the given element, renders a timeago instance. * For the given elements, sets a tooltip with a formatted date.
* @param {jQuery} $els * @param {JQuery} $timeagoEls
* @param {Boolean} setTimeago
*/ */
export const renderTimeago = $els => { export const localTimeAgo = ($timeagoEls, setTimeago = true) => {
const timeagoEls = $els || document.querySelectorAll('.js-timeago-render'); getTimeago().render($timeagoEls, timeagoLanguageCode);
// timeago.js sets timeouts internally for each timeago value to be updated in real time if (!setTimeago) {
getTimeago().render(timeagoEls, timeagoLanguageCode); return;
}; }
/** function addTimeAgoTooltip() {
* For the given elements, will add timeago tooltips $timeagoEls.each((i, el) => {
*/ // Recreate with custom template
export const addTimeAgoTooltip = () => { $(el).tooltip({
const timeagoEls = document.querySelectorAll('.js-timeago-render');
timeagoEls.forEach(element => {
$(element).tooltip({
template: template:
'<div class="tooltip local-timeago" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>', '<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 {Boolean} setTimeago
*/
export const localTimeAgo = ($timeagoEls, setTimeago = true) => {
$timeagoEls.each((i, el) => {
el.classList.add('js-timeago-render');
});
renderTimeago($timeagoEls);
if (setTimeago) {
requestIdleCallback(addTimeAgoTooltip); 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