Skip to content
Snippets Groups Projects
Unverified Commit bd91bf1e authored by Lukas Eipert's avatar Lukas Eipert
Browse files

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
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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>
Loading
Loading
Loading
Loading
@@ -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);
};
 
/**
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment