Added a function to easily made a control which only appear on mouse move
(cherry picked from commit 8d69c50d4b6e23defd22eafe99aceeaf0e5927da)
This commit is contained in:
parent
bd705a961e
commit
732a651d6d
|
@ -1021,4 +1021,57 @@ function toggle_full_value(id) {
|
||||||
background: "black"
|
background: "black"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto hides an element and shows it
|
||||||
|
* when the user moves the mouse over the body.
|
||||||
|
*
|
||||||
|
* @param element [Element object] Element object to hide.
|
||||||
|
* @param hideTime [integer] ms of the hide timeout.
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
*/
|
||||||
|
var autoHideElement = function (element, hideTime) {
|
||||||
|
hideTime = hideTime || 3000;
|
||||||
|
var timerRef;
|
||||||
|
var isHoverElement = false;
|
||||||
|
|
||||||
|
var showElement = function () {
|
||||||
|
$(element).show();
|
||||||
|
}
|
||||||
|
var hideElement = function () {
|
||||||
|
$(element).fadeOut();
|
||||||
|
}
|
||||||
|
var startHideTimeout = function (msec) {
|
||||||
|
showElement();
|
||||||
|
timerRef = setTimeout(hideElement, msec);
|
||||||
|
}
|
||||||
|
var cancelHideTimeout = function () {
|
||||||
|
clearTimeout(timerRef);
|
||||||
|
timerRef = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var handleBodyMove = function (event) {
|
||||||
|
if (isHoverElement) return;
|
||||||
|
if (timerRef) cancelHideTimeout();
|
||||||
|
startHideTimeout(hideTime);
|
||||||
|
}
|
||||||
|
var handleElementEnter = function (event) {
|
||||||
|
isHoverElement = true;
|
||||||
|
cancelHideTimeout();
|
||||||
|
}
|
||||||
|
var handleElementLeave = function (event) {
|
||||||
|
isHoverElement = false;
|
||||||
|
startHideTimeout(hideTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind event handlers
|
||||||
|
$(element)
|
||||||
|
.mouseenter(handleElementEnter)
|
||||||
|
.mouseleave(handleElementLeave);
|
||||||
|
$('body').mousemove(handleBodyMove);
|
||||||
|
|
||||||
|
// Start hide
|
||||||
|
startHideTimeout(hideTime);
|
||||||
|
>>>>>>> 8d69c50... Added a function to easily made a control which only appear on mouse move
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue