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
Boxiang Sun
gitlab-ce
Commits
0488d44c
Commit
0488d44c
authored
Mar 21, 2018
by
Luke Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add popover
parent
a5ab6722
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
app/assets/javascripts/shared/popover.js
app/assets/javascripts/shared/popover.js
+84
-0
No files found.
app/assets/javascripts/shared/popover.js
0 → 100644
View file @
0488d44c
export
default
class
Popover
{
constructor
(
trigger
,
content
)
{
this
.
isOpen
=
false
;
this
.
$popover
=
$
(
trigger
).
popover
({
content
,
html
:
true
,
placement
:
'
bottom
'
,
trigger
:
'
manual
'
,
});
}
init
()
{
this
.
registerClickOpenListener
();
}
openPopover
()
{
if
(
this
.
isOpen
)
return
;
this
.
$popover
.
popover
(
'
show
'
);
this
.
$popover
.
one
(
'
shown.bs.popover
'
,
this
.
enableClose
.
bind
(
this
));
this
.
isOpen
=
true
;
}
closePopover
()
{
if
(
!
this
.
isOpen
)
return
;
this
.
$popover
.
popover
(
'
hide
'
);
this
.
disableClose
();
this
.
isOpen
=
false
;
}
closePopoverClick
(
event
)
{
const
$target
=
$
(
event
.
target
);
if
(
$target
.
is
(
this
.
$popover
)
||
$target
.
is
(
'
.popover
'
)
||
$target
.
parents
(
'
.popover
'
).
length
>
0
)
return
;
this
.
closePopover
();
}
closePopoverMouseleave
()
{
setTimeout
(()
=>
{
if
(
this
.
$popover
.
is
(
'
:hover
'
)
||
(
this
.
$popover
.
siblings
(
'
.popover
'
).
length
>
0
&&
this
.
$popover
.
siblings
(
'
.popover
'
).
is
(
'
:hover
'
)))
return
;
this
.
closePopover
();
},
1500
);
}
registerClickOpenListener
()
{
this
.
$popover
.
on
(
'
click.glPopover.open
'
,
this
.
openPopover
.
bind
(
this
));
}
registerClickCloseListener
()
{
$
(
document
.
body
).
on
(
'
click.glPopover.close
'
,
this
.
closePopoverClick
.
bind
(
this
));
}
registerMouseleaveCloseListener
()
{
this
.
$popover
.
on
(
'
mouseleave.glPopover.close
'
,
this
.
closePopoverMouseleave
.
bind
(
this
));
this
.
$popover
.
siblings
(
'
.popover
'
).
on
(
'
mouseleave.glPopover.close
'
,
this
.
closePopoverMouseleave
.
bind
(
this
));
}
destroyMouseleaveCloseListener
()
{
this
.
$popover
.
off
(
'
mouseleave.glPopover.close
'
);
this
.
$popover
.
siblings
(
'
.popover
'
).
on
(
'
mouseleave.glPopover.close
'
);
}
enableClose
()
{
this
.
registerClickCloseListener
();
this
.
registerMouseleaveCloseListener
();
}
disableClose
()
{
Popover
.
destroyClickCloseListener
();
this
.
destroyMouseleaveCloseListener
();
}
static
destroyClickCloseListener
()
{
$
(
document
.
body
).
off
(
'
click.glPopover.close
'
);
}
}
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