Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enrollment-profile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
adi-ia
enrollment-profile
Commits
fd5eb72d
Commit
fd5eb72d
authored
6 years ago
by
David M Sibley
Browse files
Options
Downloads
Patches
Plain Diff
grab template when script loads
parent
ee14dfad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
myuw-profile.html
+11
-16
11 additions, 16 deletions
myuw-profile.html
with
11 additions
and
16 deletions
myuw-profile.html
+
11
−
16
View file @
fd5eb72d
...
@@ -125,9 +125,9 @@
...
@@ -125,9 +125,9 @@
::slotted
(
a
:hover
),
::slotted
(
a
:hover
),
::slotted
(
p
:hover
)
{
::slotted
(
p
:hover
)
{
background-color
:
rgba
(
158
,
158
,
158
,
0.2
);
background-color
:
rgba
(
158
,
158
,
158
,
0.2
);
}
}
</style>
</style>
<a
href=
"#"
id=
"myuw-profile-login"
class=
"hidden"
>
Login
</a>
<a
href=
"#"
id=
"myuw-profile-login"
class=
"hidden"
>
Login
</a>
<div
id=
"myuw-profile-wrapper"
class=
"hidden"
>
<div
id=
"myuw-profile-wrapper"
class=
"hidden"
>
...
@@ -149,19 +149,13 @@ class MyUWProfile extends HTMLElement {
...
@@ -149,19 +149,13 @@ class MyUWProfile extends HTMLElement {
constructor
()
{
constructor
()
{
super
();
super
();
// Get the script document
MyUWProfile
.
document
=
(
document
.
_currentScript
||
document
.
currentScript
).
ownerDocument
;
this
[
'
open-right
'
]
=
false
;
this
[
'
open-right
'
]
=
false
;
// Create a shadowroot for this element
// Create a shadowroot for this element
this
.
attachShadow
({
mode
:
'
open
'
});
this
.
attachShadow
({
mode
:
'
open
'
});
// Get the template and extract the HTML content
const
template
=
MyUWProfile
.
document
.
getElementById
(
'
myuw-profile-template
'
);
// Append the custom HTML to the shadowroot
// Append the custom HTML to the shadowroot
this
.
shadowRoot
.
appendChild
(
template
.
content
.
cloneNode
(
true
));
this
.
shadowRoot
.
appendChild
(
MyUWProfile
.
template
.
content
.
cloneNode
(
true
));
}
}
static
get
observedAttributes
()
{
return
[
'
login-url
'
,
'
logout-url
'
,
'
open-right
'
];
}
static
get
observedAttributes
()
{
return
[
'
login-url
'
,
'
logout-url
'
,
'
open-right
'
];
}
...
@@ -180,7 +174,7 @@ class MyUWProfile extends HTMLElement {
...
@@ -180,7 +174,7 @@ class MyUWProfile extends HTMLElement {
this
[
'
logout-url
'
]
=
this
.
getAttribute
(
'
logout-url
'
);
this
[
'
logout-url
'
]
=
this
.
getAttribute
(
'
logout-url
'
);
this
[
'
session-endpoint
'
]
=
this
.
getAttribute
(
'
session-endpoint
'
);
this
[
'
session-endpoint
'
]
=
this
.
getAttribute
(
'
session-endpoint
'
);
this
[
'
user
'
]
=
false
;
this
[
'
user
'
]
=
false
;
if
(
this
.
getAttribute
(
'
open-right
'
)
!==
null
){
if
(
this
.
getAttribute
(
'
open-right
'
)
!==
null
){
this
[
'
open-right
'
]
=
true
;
this
[
'
open-right
'
]
=
true
;
}
}
...
@@ -210,7 +204,7 @@ class MyUWProfile extends HTMLElement {
...
@@ -210,7 +204,7 @@ class MyUWProfile extends HTMLElement {
// Show login button if we couldn't get session info
// Show login button if we couldn't get session info
this
.
componentReady
();
this
.
componentReady
();
}
);
}
);
}
else
{
}
else
{
throw
Error
(
'
No session endpoint has been defiend. Please set the "session-endpoint" attribute URL into the myuw-profile element!
'
);
throw
Error
(
'
No session endpoint has been defiend. Please set the "session-endpoint" attribute URL into the myuw-profile element!
'
);
}
}
...
@@ -230,7 +224,7 @@ class MyUWProfile extends HTMLElement {
...
@@ -230,7 +224,7 @@ class MyUWProfile extends HTMLElement {
/*
/*
Add an on click event to the profile nav menu.
Add an on click event to the profile nav menu.
We need to do this in order to stop the propagation
We need to do this in order to stop the propagation
of click events on the menu specifically.
of click events on the menu specifically.
If a user clicks on the nav menu, the window on click
If a user clicks on the nav menu, the window on click
...
@@ -243,7 +237,7 @@ class MyUWProfile extends HTMLElement {
...
@@ -243,7 +237,7 @@ class MyUWProfile extends HTMLElement {
/*
/*
Add an on click event to profile bubble
Add an on click event to profile bubble
We need to make sure that we stop propagation on
We need to make sure that we stop propagation on
this event or else the window on click will always fire
this event or else the window on click will always fire
and the menu will never open.
and the menu will never open.
*/
*/
...
@@ -280,10 +274,10 @@ class MyUWProfile extends HTMLElement {
...
@@ -280,10 +274,10 @@ class MyUWProfile extends HTMLElement {
/*
/*
Function to run after the session endpoint
Function to run after the session endpoint
has been hit and the component has all the
has been hit and the component has all the
data that it needs to render.
data that it needs to render.
If user data was returned from the endpoint,
If user data was returned from the endpoint,
the profile bubble will show.
the profile bubble will show.
If not, the login button will show.
If not, the login button will show.
...
@@ -345,5 +339,6 @@ class MyUWProfile extends HTMLElement {
...
@@ -345,5 +339,6 @@ class MyUWProfile extends HTMLElement {
}
}
}
}
MyUWProfile
.
template
=
(
document
.
_currentScript
||
document
.
currentScript
).
ownerDocument
.
getElementById
(
'
myuw-profile-template
'
);
window
.
customElements
.
define
(
'
myuw-profile
'
,
MyUWProfile
);
window
.
customElements
.
define
(
'
myuw-profile
'
,
MyUWProfile
);
</script>
</script>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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