Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Commits
4511473a
Commit
4511473a
authored
6 years ago
by
Tim Zallmann
Browse files
Options
Downloads
Patches
Plain Diff
Moved not so important initialisation functions into idleCallBack Calls
parent
ffb384cb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/assets/javascripts/header.js
+5
-1
5 additions, 1 deletion
app/assets/javascripts/header.js
app/assets/javascripts/main.js
+50
-42
50 additions, 42 deletions
app/assets/javascripts/main.js
with
55 additions
and
43 deletions
app/assets/javascripts/header.js
+
5
−
1
View file @
4511473a
...
...
@@ -23,7 +23,7 @@ export default function initTodoToggle() {
});
}
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
function
initStatusTriggers
()
{
const
setStatusModalTriggerEl
=
document
.
querySelector
(
'
.js-set-status-modal-trigger
'
);
const
setStatusModalWrapperEl
=
document
.
querySelector
(
'
.js-set-status-modal-wrapper
'
);
...
...
@@ -72,4 +72,8 @@ document.addEventListener('DOMContentLoaded', () => {
},
});
}
}
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
requestIdleCallback
(
initStatusTriggers
);
});
This diff is collapsed.
Click to expand it.
app/assets/javascripts/main.js
+
50
−
42
View file @
4511473a
...
...
@@ -66,15 +66,11 @@ gl.lazyLoader = new LazyLoader({
observerNode
:
'
#content-body
'
,
});
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
// Put all initialisations here that can also wait after everything is rendered and ready
function
deferredInitialisation
()
{
const
$body
=
$
(
'
body
'
);
const
$document
=
$
(
document
);
const
$window
=
$
(
window
);
const
$sidebarGutterToggle
=
$
(
'
.js-sidebar-toggle
'
);
let
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
initBreadcrumbs
();
initLayoutNav
();
initImporterStatus
();
initTodoToggle
();
initLogoAnimation
();
...
...
@@ -84,34 +80,6 @@ document.addEventListener('DOMContentLoaded', () => {
if
(
document
.
querySelector
(
'
.search
'
))
initSearchAutocomplete
();
if
(
document
.
querySelector
(
'
#js-peek
'
))
initPerformanceBar
({
container
:
'
#js-peek
'
});
// Set the default path for all cookies to GitLab's root directory
Cookies
.
defaults
.
path
=
gon
.
relative_url_root
||
'
/
'
;
// `hashchange` is not triggered when link target is already in window.location
$body
.
on
(
'
click
'
,
'
a[href^="#"]
'
,
function
clickHashLinkCallback
()
{
const
href
=
this
.
getAttribute
(
'
href
'
);
if
(
href
.
substr
(
1
)
===
getLocationHash
())
{
setTimeout
(
handleLocationHash
,
1
);
}
});
if
(
bootstrapBreakpoint
===
'
xs
'
)
{
const
$rightSidebar
=
$
(
'
aside.right-sidebar, .layout-page
'
);
$rightSidebar
.
removeClass
(
'
right-sidebar-expanded
'
).
addClass
(
'
right-sidebar-collapsed
'
);
}
// prevent default action for disabled buttons
$
(
'
.btn
'
).
click
(
function
clickDisabledButtonCallback
(
e
)
{
if
(
$
(
this
).
hasClass
(
'
disabled
'
))
{
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
return
false
;
}
return
true
;
});
addSelectOnFocusBehaviour
(
'
.js-select-on-focus
'
);
$
(
'
.remove-row
'
).
on
(
'
ajax:success
'
,
function
removeRowAjaxSuccessCallback
()
{
...
...
@@ -164,6 +132,48 @@ document.addEventListener('DOMContentLoaded', () => {
viewport
:
'
.layout-page
'
,
});
loadAwardsHandler
();
}
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
$body
=
$
(
'
body
'
);
const
$document
=
$
(
document
);
const
$window
=
$
(
window
);
const
$sidebarGutterToggle
=
$
(
'
.js-sidebar-toggle
'
);
let
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
initLayoutNav
();
// Set the default path for all cookies to GitLab's root directory
Cookies
.
defaults
.
path
=
gon
.
relative_url_root
||
'
/
'
;
// `hashchange` is not triggered when link target is already in window.location
$body
.
on
(
'
click
'
,
'
a[href^="#"]
'
,
function
clickHashLinkCallback
()
{
const
href
=
this
.
getAttribute
(
'
href
'
);
if
(
href
.
substr
(
1
)
===
getLocationHash
())
{
setTimeout
(
handleLocationHash
,
1
);
}
});
if
(
bootstrapBreakpoint
===
'
xs
'
)
{
const
$rightSidebar
=
$
(
'
aside.right-sidebar, .layout-page
'
);
$rightSidebar
.
removeClass
(
'
right-sidebar-expanded
'
).
addClass
(
'
right-sidebar-collapsed
'
);
}
// prevent default action for disabled buttons
$
(
'
.btn
'
).
click
(
function
clickDisabledButtonCallback
(
e
)
{
if
(
$
(
this
).
hasClass
(
'
disabled
'
))
{
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
return
false
;
}
return
true
;
});
localTimeAgo
(
$
(
'
abbr.timeago, .js-timeago
'
),
true
);
// Form submitter
$
(
'
.trigger-submit
'
).
on
(
'
change
'
,
function
triggerSubmitCallback
()
{
$
(
this
)
...
...
@@ -171,8 +181,6 @@ document.addEventListener('DOMContentLoaded', () => {
.
submit
();
});
localTimeAgo
(
$
(
'
abbr.timeago, .js-timeago
'
),
true
);
// Disable form buttons while a form is submitting
$body
.
on
(
'
ajax:complete, ajax:beforeSend, submit
'
,
'
form
'
,
function
ajaxCompleteCallback
(
e
)
{
const
$buttons
=
$
(
'
[type="submit"], .js-disable-on-submit
'
,
this
);
...
...
@@ -195,6 +203,10 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
$
(
'
.navbar-toggler
'
).
on
(
'
click
'
,
()
=>
{
$
(
'
.header-content
'
).
toggleClass
(
'
menu-expanded
'
);
});
// Commit show suppressed diff
$document
.
on
(
'
click
'
,
'
.diff-content .js-show-suppressed-diff
'
,
function
showDiffCallback
()
{
const
$container
=
$
(
this
).
parent
();
...
...
@@ -202,10 +214,6 @@ document.addEventListener('DOMContentLoaded', () => {
$container
.
remove
();
});
$
(
'
.navbar-toggler
'
).
on
(
'
click
'
,
()
=>
{
$
(
'
.header-content
'
).
toggleClass
(
'
menu-expanded
'
);
});
// Show/hide comments on diff
$body
.
on
(
'
click
'
,
'
.js-toggle-diff-comments
'
,
function
toggleDiffCommentsCallback
(
e
)
{
const
$this
=
$
(
this
);
...
...
@@ -250,8 +258,6 @@ document.addEventListener('DOMContentLoaded', () => {
$window
.
on
(
'
resize.app
'
,
fitSidebarForSize
);
loadAwardsHandler
();
$
(
'
form.filter-form
'
).
on
(
'
submit
'
,
function
filterFormSubmitCallback
(
event
)
{
const
link
=
document
.
createElement
(
'
a
'
);
link
.
href
=
this
.
action
;
...
...
@@ -274,4 +280,6 @@ document.addEventListener('DOMContentLoaded', () => {
// initialize field errors
$
(
'
.gl-show-field-errors
'
).
each
((
i
,
form
)
=>
new
GlFieldErrors
(
form
));
requestIdleCallback
(
deferredInitialisation
);
});
This diff is collapsed.
Click to expand it.
Paul Slaughter
@pslaughter
mentioned in merge request
!62430 (closed)
·
3 years ago
mentioned in merge request
!62430 (closed)
mentioned in merge request !62430
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment