Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
8ce9a26b
Commit
8ce9a26b
authored
10 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
tooltip: Show tooltip only on visible elements
Auto-close toop tip box when element goes away
parent
81906787
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scp/js/tips.js
+32
-18
32 additions, 18 deletions
scp/js/tips.js
with
32 additions
and
18 deletions
scp/js/tips.js
+
32
−
18
View file @
8ce9a26b
jQuery
(
function
()
{
var
showtip
=
function
(
url
,
elem
,
xoffset
)
{
// If element is no longer visible
if
(
!
elem
.
is
(
'
:visible
'
))
return
;
var
pos
=
elem
.
offset
();
var
y_pos
=
pos
.
top
-
12
;
var
x_pos
=
pos
.
left
+
(
xoffset
||
(
elem
.
width
()
+
16
));
...
...
@@ -9,20 +13,25 @@ jQuery(function() {
var
tip_box
=
$
(
'
<div>
'
).
addClass
(
'
tip_box
'
);
var
tip_shadow
=
$
(
'
<div>
'
).
addClass
(
'
tip_shadow
'
);
var
tip_content
=
$
(
'
<div>
'
).
addClass
(
'
tip_content
'
).
load
(
url
,
function
()
{
tip_content
.
prepend
(
'
<a href="#" class="tip_close"><i class="icon-remove-circle"></i></a>
'
).
append
(
tip_arrow
);
var
width
=
$
(
window
).
width
(),
rtl
=
$
(
'
html
'
).
hasClass
(
'
rtl
'
),
size
=
tip_content
.
outerWidth
(),
left
=
the_tip
.
position
().
left
,
left_room
=
left
-
size
,
right_room
=
width
-
size
-
left
,
flip
=
rtl
?
(
left_room
>
0
&&
left_room
>
right_room
)
:
(
right_room
<
0
&&
left_room
>
right_room
);
if
(
flip
)
{
the_tip
.
css
({
'
left
'
:
x_pos
-
tip_content
.
outerWidth
()
-
elem
.
width
()
-
32
+
'
px
'
});
tip_box
.
addClass
(
'
right
'
);
tip_arrow
.
addClass
(
'
flip-x
'
);
if
(
elem
.
is
(
'
:visible
'
))
{
tip_content
.
prepend
(
'
<a href="#" class="tip_close"><i class="icon-remove-circle"></i></a>
'
).
append
(
tip_arrow
);
var
width
=
$
(
window
).
width
(),
rtl
=
$
(
'
html
'
).
hasClass
(
'
rtl
'
),
size
=
tip_content
.
outerWidth
(),
left
=
the_tip
.
position
().
left
,
left_room
=
left
-
size
,
right_room
=
width
-
size
-
left
,
flip
=
rtl
?
(
left_room
>
0
&&
left_room
>
right_room
)
:
(
right_room
<
0
&&
left_room
>
right_room
);
if
(
flip
)
{
the_tip
.
css
({
'
left
'
:
x_pos
-
tip_content
.
outerWidth
()
-
elem
.
width
()
-
32
+
'
px
'
});
tip_box
.
addClass
(
'
right
'
);
tip_arrow
.
addClass
(
'
flip-x
'
);
}
}
else
{
// Self close if the element is gone
$
(
'
.tip_box
'
).
remove
();
}
});
...
...
@@ -31,11 +40,16 @@ jQuery(function() {
"
top
"
:
y_pos
+
"
px
"
,
"
left
"
:
x_pos
+
"
px
"
}).
addClass
(
elem
.
data
(
'
id
'
));
// Close any open tips
$
(
'
.tip_box
'
).
remove
();
$
(
'
body
'
).
append
(
the_tip
.
hide
().
fadeIn
());
$
(
'
.
'
+
elem
.
data
(
'
id
'
)
+
'
.tip_shadow
'
).
css
({
"
height
"
:
$
(
'
.
'
+
elem
.
data
(
'
id
'
)).
height
()
+
5
});
// Only show the tip if the element is still visible.
if
(
elem
.
is
(
'
:visible
'
))
{
$
(
'
body
'
).
append
(
the_tip
.
hide
().
fadeIn
());
$
(
'
.
'
+
elem
.
data
(
'
id
'
)
+
'
.tip_shadow
'
).
css
({
"
height
"
:
$
(
'
.
'
+
elem
.
data
(
'
id
'
)).
height
()
+
5
});
}
},
getHelpTips
=
(
function
()
{
var
dfd
,
cache
=
{};
...
...
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