mirror of https://github.com/zulip/zulip.git
hotspots.js: Do not place_popover if icon is not visible.
Attempting to do so throws an exception if hotspot.location.element can't be found.
This commit is contained in:
parent
836a2c502e
commit
9f7b310a3e
|
@ -52,7 +52,7 @@ exports.post_hotspot_as_read = function (hotspot_name) {
|
||||||
function place_icon(hotspot) {
|
function place_icon(hotspot) {
|
||||||
if ($(hotspot.location.element).length === 0) {
|
if ($(hotspot.location.element).length === 0) {
|
||||||
$('#hotspot_' + hotspot.name + '_icon').css('display', 'none');
|
$('#hotspot_' + hotspot.name + '_icon').css('display', 'none');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var offset = {
|
var offset = {
|
||||||
|
@ -69,10 +69,11 @@ function place_icon(hotspot) {
|
||||||
!$(hotspot.location.element).is(':visible') ||
|
!$(hotspot.location.element).is(':visible') ||
|
||||||
$(hotspot.location.element).is(':hidden')) {
|
$(hotspot.location.element).is(':hidden')) {
|
||||||
$('#hotspot_' + hotspot.name + '_icon').css('display', 'none');
|
$('#hotspot_' + hotspot.name + '_icon').css('display', 'none');
|
||||||
} else {
|
return false;
|
||||||
$('#hotspot_' + hotspot.name + '_icon').css('display', 'block');
|
|
||||||
$('#hotspot_' + hotspot.name + '_icon').css(placement);
|
|
||||||
}
|
}
|
||||||
|
$('#hotspot_' + hotspot.name + '_icon').css('display', 'block');
|
||||||
|
$('#hotspot_' + hotspot.name + '_icon').css(placement);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function place_popover(hotspot) {
|
function place_popover(hotspot) {
|
||||||
|
@ -188,17 +189,18 @@ function insert_hotspot_into_DOM(hotspot) {
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('body').prepend(hotspot_icon_HTML);
|
$('body').prepend(hotspot_icon_HTML);
|
||||||
place_icon(hotspot);
|
|
||||||
|
|
||||||
$('body').prepend(hotspot_overlay_HTML);
|
$('body').prepend(hotspot_overlay_HTML);
|
||||||
place_popover(hotspot);
|
if (place_icon(hotspot)) {
|
||||||
|
place_popover(hotspot);
|
||||||
|
}
|
||||||
|
|
||||||
// reposition on any event that might update the UI
|
// reposition on any event that might update the UI
|
||||||
['resize', 'scroll', 'onkeydown', 'click']
|
['resize', 'scroll', 'onkeydown', 'click']
|
||||||
.forEach(function (event_name) {
|
.forEach(function (event_name) {
|
||||||
window.addEventListener(event_name, _.debounce(function () {
|
window.addEventListener(event_name, _.debounce(function () {
|
||||||
place_icon(hotspot);
|
if (place_icon(hotspot)) {
|
||||||
place_popover(hotspot);
|
place_popover(hotspot);
|
||||||
|
}
|
||||||
}, 10), true);
|
}, 10), true);
|
||||||
});
|
});
|
||||||
}, (hotspot.delay * 100));
|
}, (hotspot.delay * 100));
|
||||||
|
|
Loading…
Reference in New Issue