Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
636c36bb
Commit
636c36bb
authored
Jan 15, 2019
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved Performance by delaying Tooltip setup for localtimeago
parent
227ce776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+18
-8
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
636c36bb
...
@@ -125,6 +125,7 @@ export const getTimeago = () => {
...
@@ -125,6 +125,7 @@ export const getTimeago = () => {
timeago
.
register
(
timeagoLanguageCode
,
locale
);
timeago
.
register
(
timeagoLanguageCode
,
locale
);
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
localeRemaining
);
timeago
.
register
(
`
${
timeagoLanguageCode
}
-remaining`
,
localeRemaining
);
timeagoInstance
=
timeago
();
timeagoInstance
=
timeago
();
}
}
...
@@ -142,6 +143,19 @@ export const renderTimeago = $els => {
...
@@ -142,6 +143,19 @@ export const renderTimeago = $els => {
getTimeago
().
render
(
timeagoEls
,
timeagoLanguageCode
);
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.
* For the given elements, sets a tooltip with a formatted date.
* @param {jQuery}
* @param {jQuery}
...
@@ -149,18 +163,14 @@ export const renderTimeago = $els => {
...
@@ -149,18 +163,14 @@ export const renderTimeago = $els => {
*/
*/
export
const
localTimeAgo
=
(
$timeagoEls
,
setTimeago
=
true
)
=>
{
export
const
localTimeAgo
=
(
$timeagoEls
,
setTimeago
=
true
)
=>
{
$timeagoEls
.
each
((
i
,
el
)
=>
{
$timeagoEls
.
each
((
i
,
el
)
=>
{
if
(
setTimeago
)
{
// Recreate with custom template
$
(
el
).
tooltip
({
template
:
'
<div class="tooltip local-timeago" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>
'
,
});
}
el
.
classList
.
add
(
'
js-timeago-render
'
);
el
.
classList
.
add
(
'
js-timeago-render
'
);
});
});
renderTimeago
(
$timeagoEls
);
renderTimeago
(
$timeagoEls
);
if
(
setTimeago
)
{
requestIdleCallback
(
addTimeAgoTooltip
);
}
};
};
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment