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.
This commit is contained in:
Lukas Eipert 2019-01-22 00:10:30 +01:00
parent 636c36bbbf
commit bd91bf1ea8
No known key found for this signature in database
GPG key ID: 148BEA37CB35B2AC
2 changed files with 17 additions and 33 deletions

View file

@ -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>

View file

@ -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) {
requestIdleCallback(addTimeAgoTooltip);
if (!setTimeago) {
return;
}
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);
};
/**