various helper modules
var tooltips = gantt.ext.tooltips;
tooltips.tooltipFor({
selector: ".gantt_scale_cell",
html: function (event, node) {
const domHelper = gantt.utils.dom;
const pos = domHelper.getRelativeEventPosition(event, gantt.$task_scale);
return gantt.templates.task_date(gantt.dateFromPos(pos.x));
}
});
Currently the module contains only the helper for DOM operations available at gantt.utils.dom
var domHelpers = gantt.utils.dom;
Which have following methods:
getNodePosition (node): object - returns position of the element on the screen in the format of {x:number, y:number,width:number, height:number}
object
getRelativeEventPosition (e, node): object - returns mouse coordinates relatively to the DOM element in the format of {x:number, y:number}
object
gantt.message({
expire: -1,
text: "<span id='pointer-date'></span>"
});
const formatDate = gantt.date.date_to_str("%Y-%m-%d %H:%i");
gantt.attachEvent("onMouseMove", function (id, e){
const helper = gantt.utils.dom;
if(helper.isChildOf(e.target, gantt.$task_data)){
const textContainer = document.querySelector("#pointer-date");
const pos = helper.getRelativeEventPosition(e, gantt.$task_data);
const pointerDate = gantt.dateFromPos(pos.x);
textContainer.innerText = formatDate(pointerDate);
}
});
isChildOf (child, parent): boolean - returns true
if the node provided as the first argument is DOM child of the node provided as the second argument
hasClass (node, className): boolean - returns true
if the class list of the provided node
contains a specified css class
closest (node, cssSelector): HTMLElement> - returns the first node that matches the provided css selector, starting from the node
attribute, up to its DOM parents' branch.
gantt.attachEvent("onEmptyClick", function (e) {
const domHelpers = gantt.utils.dom;
if(!domHelpers.closest(e.target, `[${gantt.config.link_attribute}]`)){
gantt.message("not a link");
}else{
gantt.message("link!");
}
});
Back to top