{"version":3,"file":"dhtmlxgantt.js","sources":["../sources/core/ui/utils/dom_helpers.js","../sources/utils/global.js","../sources/ext/click_drag/eventsManager.ts","../sources/utils/eventable.js","../sources/utils/helpers.js","../sources/ext/click_drag/selectedRegion.ts","../sources/ext/drag_timeline/eventsManager.ts","../sources/ext/keyboard_navigation/modals.js","../sources/ext/quick_info/quickInfo.ts","../sources/utils/utils.js","../sources/core/ui/utils/dom_event_scope.js","../sources/ext/tooltip/tooltip.ts","../sources/ext/tooltip/tooltipManager.ts","../sources/ext/undo/monitor.ts","../sources/ext/undo/undo.ts","../sources/ext/extensions_gpl.ts","../sources/ext/click_drag/index.ts","../sources/ext/drag_timeline/index.ts","../sources/ext/fullscreen/index.ts","../sources/ext/keyboard_navigation.js","../sources/ext/keyboard_navigation/common/keyboard_shortcuts.js","../sources/ext/keyboard_navigation/common/eventhandler.js","../sources/ext/keyboard_navigation/common/trap_modal_focus.js","../sources/ext/keyboard_navigation/elements/gantt_node.js","../sources/ext/keyboard_navigation/elements/nav_node.js","../sources/ext/keyboard_navigation/elements/header_cell.js","../sources/ext/keyboard_navigation/elements/task_row.js","../sources/ext/keyboard_navigation/elements/task_cell.js","../sources/ext/keyboard_navigation/core.js","../sources/ext/quick_info/index.ts","../sources/ext/tooltip/index.ts","../sources/ext/undo/index.ts","../sources/ext/marker.js","../sources/ext/multiselect.js","../sources/ext/export_api/index.ts","../sources/constants/index.js","../sources/ext/extension_manager.ts","../sources/core/common/config.ts","../sources/utils/env.js","../sources/core/common/serialize.ts","../sources/core/common/ajax.js","../sources/core/common/date_parsers/fast_version.ts","../sources/core/common/date_parsers/csp_compliant_version.ts","../sources/core/common/date.js","../node_modules/remote-client/dist/remote.es6.js","../sources/core/remote/remote_events.js","../sources/utils/timeout.js","../sources/core/common/state.js","../sources/utils/promise.js","../sources/core/facades/datastore_tasks.js","../sources/core/datastore/power_array.js","../sources/utils/placeholder_task.js","../sources/core/datastore/datastore.js","../sources/core/datastore/treedatastore.js","../sources/utils/is_headless.js","../sources/core/datastore/datastore_render.js","../sources/core/facades/datastore.js","../sources/core/datastore/select.js","../sources/core/facades/datastore_links.js","../sources/core/ui/timeline/scales.js","../sources/core/gantt_data_range.js","../sources/utils/task_tree_helpers.js","../sources/core/dataprocessor/data_processor_events.ts","../sources/core/dataprocessor/simple_storage.ts","../sources/core/dataprocessor/data_processor.ts","../sources/core/dataprocessor/extend_gantt.ts","../sources/core/dataprocessor/index.js","../sources/core/plugins/batch_update.js","../sources/core/plugins/wbs.js","../sources/core/plugins/resources.js","../sources/core/plugins/resource_assignments.js","../sources/core/plugins/new_task_placeholder.js","../sources/core/plugins/auto_task_types.js","../sources/core/common/duration_formatter_numeric.ts","../sources/core/common/link_formatter_simple.ts","../sources/core/plugins/formatters.js","../sources/core/plugins/empty_state_screen.ts","../sources/core/ui/render/baseline_helper.js","../sources/core/plugins/baselines.js","../sources/core/loading/parsing.js","../sources/core/worktime/calendar_arguments_helper.js","../sources/core/worktime/strategy/work_calendar_merger.js","../sources/core/worktime/strategy/work_unit_cache/workunit_map_cache.ts","../sources/core/worktime/strategy/work_unit_cache/workunit_object_cache.ts","../sources/core/worktime/strategy/work_unit_cache/larger_units_helper.ts","../sources/core/worktime/strategy/work_unit_cache/date_duration_cache.ts","../sources/core/worktime/strategy/calendar_strategy.js","../sources/core/worktime/strategy/work_unit_cache/index.ts","../sources/core/worktime/legacy_resource_config.js","../sources/core/worktime/calendar_manager.js","../sources/core/worktime/dynamic_resource_calendars.js","../sources/core/worktime/strategy/no_work_time.js","../sources/core/worktime/time_calculator.js","../sources/core/facades/worktime_calendars.js","../sources/core/data.js","../sources/core/ui/resize_listener.js","../sources/core/gantt_core.js","../sources/core/common/assert.js","../sources/locale/locale_ar.ts","../sources/locale/locale_be.ts","../sources/locale/locale_ca.ts","../sources/locale/locale_cn.ts","../sources/locale/locale_cs.ts","../sources/locale/locale_da.ts","../sources/locale/locale_de.ts","../sources/locale/locale_el.ts","../sources/locale/locale_en.ts","../sources/locale/locale_es.ts","../sources/locale/locale_fa.ts","../sources/locale/locale_fi.ts","../sources/locale/locale_fr.ts","../sources/locale/locale_he.ts","../sources/locale/locale_hr.ts","../sources/locale/locale_hu.ts","../sources/locale/locale_id.ts","../sources/locale/locale_it.ts","../sources/locale/locale_jp.ts","../sources/locale/locale_kr.ts","../sources/locale/locale_manager.ts","../sources/locale/locale_nb.ts","../sources/locale/locale_nl.ts","../sources/locale/locale_no.ts","../sources/locale/locale_pl.ts","../sources/locale/locale_pt.ts","../sources/locale/locale_ro.ts","../sources/locale/locale_ru.ts","../sources/locale/locale_si.ts","../sources/locale/locale_sk.ts","../sources/locale/locale_sv.ts","../sources/locale/locale_tr.ts","../sources/locale/locale_ua.ts","../sources/factory/make_instance_common.js","../sources/core/common/services.js","../sources/core/common/dnd.js","../sources/core/common/templates.js","../sources/core/datastore/datastore_hooks.js","../sources/core/plugins/index.js","../sources/core/grid_column_api.gpl.js","../sources/core/tasks.js","../sources/core/worktime/work_time.js","../sources/core/data_task_types.gpl.js","../sources/core/cached_functions.js","../sources/core/destructor.js","../sources/locale/index.ts","../sources/core/ui/message.js","../sources/core/ui/configurable.js","../sources/core/ui/ui_factory.js","../sources/core/ui/mouse.js","../sources/core/ui/render/viewport/is_in_viewport.js","../sources/core/ui/render/is_legacy_smart_render.js","../sources/core/ui/render/viewport/get_grid_row_rectangle.js","../sources/core/ui/render/viewport/get_visible_bars_range.js","../sources/core/ui/render/render_factory.js","../sources/core/ui/render/layer_engine.js","../sources/core/ui/render/viewport/get_bar_rectangle.js","../sources/core/ui/render/viewport/factory/get_visible_link_range.js","../sources/core/ui/render/viewport/get_link_rectangle.js","../sources/core/ui/render/viewport/is_link_in_viewport.js","../sources/core/ui/gantt_layers.js","../sources/core/ui/layout/cell.js","../sources/utils/extends.js","../sources/core/ui/layout/layout.js","../sources/core/ui/layout/view_layout.js","../sources/core/ui/layout/view_cell.js","../sources/core/ui/layout/scrollbar_cell.js","../sources/core/ui/row_position_mixin.js","../sources/core/ui/row_position_fixed_height.js","../sources/core/ui/timeline/tasks_canvas_render.gpl.js","../sources/core/ui/timeline/timeline.js","../sources/core/ui/timeline/timeline_layers_gpl.js","../sources/core/ui/plugins/column_grid_dnd/scrollable_grid.ts","../sources/core/ui/plugins/column_grid_dnd/column_grid_dnd.ts","../sources/core/ui/mouse_event_container.js","../sources/core/ui/grid/grid.js","../sources/core/ui/grid/grid_resize.gpl.js","../sources/core/ui/grid/task_grid_row_resize.js","../sources/core/ui/grid/editors/keyboard_mappings/default.js","../sources/core/ui/grid/editors/keyboard_mappings/keyboard_navigation.js","../sources/core/ui/grid/editors/editors/base.js","../sources/core/ui/grid/editors/editors/text.js","../sources/core/ui/grid/editors/editors/number.js","../sources/core/ui/grid/editors/editors/select.js","../sources/core/ui/grid/editors/editors/date.js","../sources/core/ui/grid/editors/editors/predecessor.js","../sources/core/ui/grid/editors/editors/duration.js","../sources/core/ui/grid/editors/linked_properties.js","../sources/core/ui/grid/editors/controller.js","../sources/core/ui/grid/editors/keyboard_mappings.js","../sources/core/ui/render/viewport/is_bar_in_viewport.js","../sources/core/ui/render/task_bar_render.js","../sources/core/ui/render/task_bar_smart_render.js","../sources/core/ui/render/dummy_layer.js","../sources/core/ui/render/viewport/get_bg_row_rectangle.js","../sources/core/ui/render/viewport/get_visible_cells_range.js","../sources/core/ui/render/viewport/is_column_visible.js","../sources/core/ui/render/prerender/task_bg_placeholder.js","../sources/core/ui/render/link_render.js","../sources/core/ui/render/viewport/is_grid_row_in_viewport.js","../sources/core/resource_timetable_builder.js","../sources/core/ui/grid/tasks_grid_dnd.js","../sources/core/ui/grid/tasks_grid_dnd_marker_helpers/drop_target.js","../sources/core/ui/grid/tasks_grid_dnd_marker_helpers/locked_level.js","../sources/core/ui/grid/tasks_grid_dnd_marker_helpers/highlight.js","../sources/core/ui/grid/tasks_grid_dnd_marker.js","../sources/core/ui/grid/tasks_grid_dnd_marker_helpers/multi_level.js","../sources/core/ui/grid/main_grid_initializer.js","../sources/core/ui/timeline/tasks_dnd.js","../sources/core/ui/timeline/links_dnd.js","../sources/core/ui/timeline/main_timeline_initializer.js","../sources/core/ui/main_layout_initializer.js","../sources/core/ui/index.js","../sources/core/ui/layout/resizer_cell.gpl.js","../sources/core/ui/render/task_grid_line_render.js","../sources/core/ui/render/task_bg_render.js","../sources/core/ui/render/task_rollup_render.js","../sources/core/ui/render/resource_matrix_render.js","../sources/core/ui/render/task_grid_row_resize_render.js","../sources/core/ui/skin.js","../sources/core/ui/plugins/autoscroll.js","../sources/core/ui/plugins/jquery_hooks.js","../sources/core/ui/plugins/dhtmlx_hooks.js","../sources/core/ui/plugins/timeline_zoom.ts","../sources/core/ui/touch.js","../sources/core/ui/lightbox/controls/base_control.js","../sources/core/ui/utils/html_helpers.js","../sources/core/ui/lightbox/controls/select_control.js","../sources/core/ui/lightbox/controls/parent_control.js","../sources/core/ui/lightbox/index.js","../sources/core/ui/lightbox/controls/template_control.js","../sources/core/ui/lightbox/controls/textarea_control.js","../sources/core/ui/lightbox/controls/time_control.js","../sources/core/ui/lightbox/controls/checkbox_control.js","../sources/core/ui/lightbox/controls/radio_control.js","../sources/core/ui/lightbox/controls/duration_control.js","../sources/core/ui/lightbox/controls/constraint_control.js","../sources/core/ui/lightbox/controls/typeselect_control.js","../sources/core/ui/lightbox/controls/baseline_control.js","../sources/core/ui_core.js","../sources/core/data_task_layers.gpl.js","../sources/core/facades/layout.js","../sources/css/skins/skyblue.js","../sources/css/skins/dark.js","../sources/css/skins/meadow.js","../sources/css/skins/terrace.js","../sources/css/skins/broadway.js","../sources/css/skins/material.js","../sources/css/skins/contrast_black.js","../sources/css/skins/contrast_white.js","../sources/core/ui/plugins/index.js","../sources/core/ui/lightbox/lightbox_optional_time.js","../sources/core/ui/wai_aria.js","../sources/dhtmlxgantt.gpl.ts","../sources/factory/make_instance_web.js","../sources/core/loading/ajax_loading.js"],"sourcesContent":["//returns position of html element on the page\r\nfunction getNodePosition(elem) {\r\n\tvar top=0, left=0, right=0, bottom=0;\r\n\tif (elem.getBoundingClientRect) { //HTML5 method\r\n\t\tvar box = elem.getBoundingClientRect();\r\n\t\tvar body = document.body;\r\n\t\tvar docElem = (document.documentElement ||\r\n\t\t\tdocument.body.parentNode ||\r\n\t\t\tdocument.body);\r\n\r\n\t\tvar scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;\r\n\t\tvar scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;\r\n\t\tvar clientTop = docElem.clientTop || body.clientTop || 0;\r\n\t\tvar clientLeft = docElem.clientLeft || body.clientLeft || 0;\r\n\t\ttop = box.top + scrollTop - clientTop;\r\n\t\tleft = box.left + scrollLeft - clientLeft;\r\n\r\n\t\tright = document.body.offsetWidth - box.right;\r\n\t\tbottom = document.body.offsetHeight - box.bottom;\r\n\t} else { //fallback to naive approach\r\n\t\twhile(elem) {\r\n\t\t\ttop = top + parseInt(elem.offsetTop,10);\r\n\t\t\tleft = left + parseInt(elem.offsetLeft,10);\r\n\t\t\telem = elem.offsetParent;\r\n\t\t}\r\n\r\n\t\tright = document.body.offsetWidth - elem.offsetWidth - left;\r\n\t\tbottom = document.body.offsetHeight - elem.offsetHeight - top;\r\n\t}\r\n\treturn { y: Math.round(top), x: Math.round(left), width:elem.offsetWidth, height:elem.offsetHeight, right: Math.round(right), bottom: Math.round(bottom) };\r\n}\r\n\r\nfunction isVisible(node){\r\n\tvar display = false,\r\n\t\tvisibility = false;\r\n\tif(window.getComputedStyle){\r\n\t\tvar style = window.getComputedStyle(node, null);\r\n\t\tdisplay = style[\"display\"];\r\n\t\tvisibility = style[\"visibility\"];\r\n\t}else if(node.currentStyle){\r\n\t\tdisplay = node.currentStyle[\"display\"];\r\n\t\tvisibility = node.currentStyle[\"visibility\"];\r\n\t}\r\n\treturn (display != \"none\" && visibility != \"hidden\");\r\n}\r\n\r\nfunction hasNonNegativeTabIndex(node){\r\n\treturn !isNaN(node.getAttribute(\"tabindex\")) && (node.getAttribute(\"tabindex\")*1 >= 0);\r\n}\r\n\r\nfunction hasHref(node){\r\n\tvar canHaveHref = {\"a\": true, \"area\": true};\r\n\tif(canHaveHref[node.nodeName.loLowerCase()]){\r\n\t\treturn !!node.getAttribute(\"href\");\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nfunction isEnabled(node){\r\n\tvar canDisable = {\"input\":true, \"select\":true, \"textarea\":true, \"button\":true, \"object\":true};\r\n\tif(canDisable[node.nodeName.toLowerCase()]){\r\n\t\treturn !node.hasAttribute(\"disabled\");\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\nfunction getFocusableNodes(root){\r\n\tvar nodes = root.querySelectorAll([\r\n\t\t\"a[href]\",\r\n\t\t\"area[href]\",\r\n\t\t\"input\",\r\n\t\t\"select\",\r\n\t\t\"textarea\",\r\n\t\t\"button\",\r\n\t\t\"iframe\",\r\n\t\t\"object\",\r\n\t\t\"embed\",\r\n\t\t\"[tabindex]\",\r\n\t\t\"[contenteditable]\"\r\n\t].join(\", \"));\r\n\r\n\tvar nodesArray = Array.prototype.slice.call(nodes, 0);\r\n\t\r\n\tfor(var i = 0; i < nodesArray.length; i++){\r\n\t\tnodesArray[i].$position = i;\r\n\t\t// we remember original nodes order, \r\n\t\t// so when we sort them by tabindex we ensure order of nodes with same tabindex is preserved, \r\n\t\t// since some browsers do unstable sort\r\n\t}\r\n\t\r\n\t// use tabindex to sort focusable nodes\r\n\tnodesArray.sort(function(a, b) {\r\n\t\tif(a.tabIndex === 0 && b.tabIndex !== 0){\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t\tif(a.tabIndex !== 0 && b.tabIndex === 0){\r\n\t\t\treturn -1;\r\n\t\t}\r\n\t\t\r\n\t\tif (a.tabIndex === b.tabIndex){\r\n\t\t\t// ensure we do stable sort\r\n\t\t\treturn a.$position - b.$position;\r\n\t\t}\r\n\t\tif (a.tabIndex < b.tabIndex) {\r\n\t\t\treturn -1;\r\n\t\t}\r\n\t\treturn 1;\r\n\t});\r\n\t\r\n\tfor(var i = 0; i < nodesArray.length; i++){\r\n\t\tvar node = nodesArray[i];\r\n\t\tvar isValid = (hasNonNegativeTabIndex(node) || isEnabled(node) || hasHref(node)) && isVisible(node);\r\n\t\tif(!isValid){\r\n\t\t\tnodesArray.splice(i, 1);\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\treturn nodesArray;\r\n}\r\n\r\nfunction getScrollSize(){\r\n\tvar div = document.createElement(\"div\");\r\n\tdiv.style.cssText=\"visibility:hidden;position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;height:110px;min-height:100px;overflow-y:scroll;\";\r\n\r\n\tdocument.body.appendChild(div);\r\n\tvar width = div.offsetWidth-div.clientWidth;\r\n\tdocument.body.removeChild(div);\r\n\r\n\treturn Math.max(width, 15);\r\n}\r\n\r\nfunction getClassName(node){\r\n\tif(!node) return \"\";\r\n\r\n\tvar className = node.className || \"\";\r\n\tif(className.baseVal)//'className' exist but not a string - IE svg element in DOM\r\n\t\tclassName = className.baseVal;\r\n\r\n\tif(!className.indexOf)\r\n\t\tclassName = \"\";\r\n\r\n\treturn _trimString(className);\r\n}\r\n\r\nfunction addClassName(node, className){\r\n\tif (className && node.className.indexOf(className) === -1) {\r\n\t\tnode.className += \" \" + className;\r\n\t}\r\n}\r\n\r\nfunction removeClassName(node, name) {\r\n\tname = name.split(\" \");\r\n\tfor (var i = 0; i < name.length; i++) {\r\n\t\tvar regEx = new RegExp(\"\\\\s?\\\\b\" + name[i] + \"\\\\b(?![-_.])\", \"\");\r\n\t\tnode.className = node.className.replace(regEx, \"\");\r\n\t}\r\n}\r\n\r\nfunction hasClass(element, className){\r\n\tif ('classList' in element) {\r\n\t\treturn element.classList.contains(className);\r\n\t} else { \r\n\t\treturn new RegExp(\"\\\\b\" + className + \"\\\\b\").test(element.className);\r\n\t}\r\n}\r\n\r\nfunction toNode(node) {\r\n\tif (typeof node === \"string\") {\r\n\t\treturn (document.getElementById(node) || document.querySelector(node) || document.body);\r\n\t}\r\n\treturn node || document.body;\r\n}\r\n\r\nvar _slave;\r\nfunction insertNode(node, newone) {\r\n\tif(!_slave){\r\n\t\t_slave = document.createElement(\"div\");\r\n\t}\r\n\t_slave.innerHTML = newone;\r\n\tvar child = _slave.firstChild;\r\n\tnode.appendChild(child);\r\n\treturn child;\r\n}\r\n\r\nfunction removeNode(node) {\r\n\tif (node && node.parentNode) {\r\n\t\tnode.parentNode.removeChild(node);\r\n\t}\r\n}\r\n\r\nfunction getChildNodes(node, css) {\r\n\tvar ch = node.childNodes;\r\n\tvar len = ch.length;\r\n\tvar out = [];\r\n\tfor (var i = 0; i < len; i++) {\r\n\t\tvar obj = ch[i];\r\n\t\tif (obj.className && obj.className.indexOf(css) !== -1) {\r\n\t\t\tout.push(obj);\r\n\t\t}\r\n\t}\r\n\treturn out;\r\n}\r\n\r\nfunction getTargetNode(e) {\r\n\tvar trg;\r\n\tif (e.tagName)\r\n\t\ttrg = e;\r\n\telse {\r\n\t\te = e || window.event;\r\n\t\ttrg = e.target || e.srcElement;\r\n\t\tif (trg.shadowRoot && e.composedPath) {\r\n\t\t\ttrg = e.composedPath()[0];\r\n\t\t}\r\n\t}\r\n\treturn trg;\r\n}\r\n\r\nfunction locateAttribute(e, attribute) {\r\n\tif(!attribute) return;\r\n\r\n\tvar trg = getTargetNode(e);\r\n\r\n\twhile (trg){\r\n\t\tif (trg.getAttribute){\t//text nodes has not getAttribute\r\n\t\t\tvar test = trg.getAttribute(attribute);\r\n\t\t\tif (test) return trg;\r\n\t\t}\r\n\t\ttrg=trg.parentNode;\r\n\t}\r\n\treturn null;\r\n}\r\n\r\nfunction _trimString(str){\r\n\tvar func = String.prototype.trim || function(){ return this.replace(/^\\s+|\\s+$/g, \"\"); };\r\n\treturn func.apply(str);\r\n}\r\n\r\nfunction locateClassName(e, classname, strict){\r\n\tvar trg = getTargetNode(e);\r\n\tvar css = \"\";\r\n\r\n\tif(strict === undefined)\r\n\t\tstrict = true;\r\n\r\n\twhile (trg){\r\n\t\tcss = getClassName(trg);\r\n\t\tif(css){\r\n\t\t\tvar ind = css.indexOf(classname);\r\n\t\t\tif (ind >= 0){\r\n\t\t\t\tif (!strict)\r\n\t\t\t\t\treturn trg;\r\n\r\n\t\t\t\t//check that we have exact match\r\n\t\t\t\tvar left = (ind === 0) || (!_trimString(css.charAt(ind - 1)));\r\n\t\t\t\tvar right = ((ind + classname.length >= css.length)) || (!_trimString(css.charAt(ind + classname.length)));\r\n\r\n\t\t\t\tif (left && right)\r\n\t\t\t\t\treturn trg;\r\n\t\t\t}\r\n\t\t}\r\n\t\ttrg=trg.parentNode;\r\n\t}\r\n\treturn null;\r\n}\r\n\r\n/*\r\nevent position relatively to DOM element\r\n */\r\nfunction getRelativeEventPosition(ev, node){\r\n\tvar d = document.documentElement;\r\n\tvar box = getNodePosition(node);\r\n\r\n\treturn {\r\n\t\tx: ev.clientX + d.scrollLeft - d.clientLeft - box.x + node.scrollLeft,\r\n\t\ty: ev.clientY + d.scrollTop - d.clientTop - box.y + node.scrollTop\r\n\t};\r\n}\r\n\r\nfunction getRelativeNodePosition(child, parent){\r\n\tconst childPos = getNodePosition(child);\r\n\tconst parentPos = getNodePosition(parent);\r\n\treturn {\r\n\t\tx: childPos.x - parentPos.x,\r\n\t\ty: childPos.y - parentPos.y\r\n\t};\r\n}\r\n\r\nfunction isChildOf(child, parent){\r\n\tif(!child || !parent){\r\n\t\treturn false;\r\n\t}\r\n\r\n\twhile(child && child != parent) {\r\n\t\tchild = child.parentNode;\r\n\t}\r\n\r\n\treturn child === parent;\r\n}\r\n\r\nfunction closest(element, selector){\r\n\tif(element.closest){\r\n\t\treturn element.closest(selector);\r\n\t}else if(element.matches || element.msMatchesSelector || element.webkitMatchesSelector){\r\n\t\tvar el = element;\r\n\t\tif (!document.documentElement.contains(el)) return null;\r\n\t\tdo {\r\n\t\t\tvar method = el.matches || el.msMatchesSelector || el.webkitMatchesSelector;\r\n\r\n\t\t\tif (method.call(el, selector)) return el;\r\n\t\t\tel = el.parentElement || el.parentNode;\r\n\t\t} while (el !== null && el.nodeType === 1); \r\n\t\treturn null;\r\n\t}else{\r\n\t\t// eslint-disable-next-line no-console\r\n\t\tconsole.error(\"Your browser is not supported\");\r\n\t\treturn null;\r\n\t}\r\n}\r\n\r\nfunction getClosestSizedElement(element) {\r\n\twhile (element) {\r\n\t\tif (element.offsetWidth > 0 && element.offsetHeight > 0) {\r\n\t\t\treturn element;\r\n\t\t}\r\n\t\telement = element.parentElement;\r\n\t}\r\n\treturn null;\r\n}\r\n\r\nfunction isShadowDomSupported() {\r\n\treturn document.head.createShadowRoot || document.head.attachShadow;\r\n}\r\n\r\n/**\r\n * Returns element that has the browser focus, or null if no element has focus.\r\n * Works with shadow DOM, so it's prefereed to use this function instead of document.activeElement directly.\r\n * @returns HTMLElement\r\n */\r\nfunction getActiveElement(){\r\n\tvar activeElement = document.activeElement;\r\n\tif (activeElement.shadowRoot) {\r\n\t\tactiveElement = activeElement.shadowRoot.activeElement;\r\n\t}\r\n\tif (activeElement === document.body && document.getSelection) {\r\n\t\tactiveElement = document.getSelection().focusNode || document.body;\r\n\t}\r\n\r\n\treturn activeElement;\r\n}\r\n\r\n/**\r\n * Returns document.body or the host node of the ShadowRoot, if the element is attached to ShadowDom\r\n * @param {HTMLElement} element \r\n * @returns HTMLElement\r\n */\r\nfunction getRootNode(element) {\r\n\tif (!element) {\r\n\t\treturn document.body;\r\n\t}\r\n\tif (!isShadowDomSupported()) {\r\n\t\treturn document.body;\r\n\t}\r\n\twhile (element.parentNode && (element = element.parentNode)) {\r\n\t\tif (element instanceof ShadowRoot) {\r\n\t\t\treturn element.host;\r\n\t\t}\r\n\t}\r\n\treturn document.body;\r\n}\r\n\r\nfunction hasShadowParent(element) {\r\n\treturn !!getRootNode(element);\r\n}\r\n\r\nexport {\r\n\tgetNodePosition,\r\n\tgetFocusableNodes,\r\n\tgetScrollSize,\r\n\tgetClassName,\r\n\taddClassName,\r\n\tremoveClassName,\r\n\tinsertNode,\r\n\tremoveNode,\r\n\tgetChildNodes,\r\n\ttoNode,\r\n\tlocateClassName,\r\n\tlocateAttribute,\r\n\tgetTargetNode,\r\n\tgetRelativeEventPosition,\r\n\tisChildOf,\r\n\thasClass,\r\n\tclosest,\r\n\tgetRootNode,\r\n\thasShadowParent,\r\n\tisShadowDomSupported,\r\n\tgetActiveElement,\r\n\tgetRelativeNodePosition,\r\n\tgetClosestSizedElement\r\n};","\r\n/* eslint-disable no-restricted-globals */\r\nvar globalScope;\r\nif(typeof window !== \"undefined\"){\r\n\tglobalScope = window;\r\n}else{\r\n\tglobalScope = global;\r\n}\r\n/* eslint-enable no-restricted-globals */\r\n\r\nexport default globalScope;","import * as domHelpers from \"../../core/ui/utils/dom_helpers\";\r\nimport global from \"../../utils/global\";\r\nimport { SelectedRegion } from \"./selectedRegion\";\r\n\r\nexport class EventsManager {\r\n\tprivate _mouseDown: boolean = false;\r\n\tprivate _domEvents: any;\r\n\tprivate _originPosition: string;\r\n\tprivate _gantt: any;\r\n\tprivate _restoreOriginPosition: () => void;\r\n\tconstructor(gantt: any) {\r\n\t\tthis._gantt = gantt;\r\n\t\tthis._domEvents = gantt._createDomEventScope();\r\n\t}\r\n\r\n\tattach(selectedRegion: SelectedRegion, useKey?: \"shiftKey\" | \"ctrlKey\" | \"altKey\", ignore?: any): void {\r\n\t\tconst gantt = this._gantt;\r\n\t\tconst _target = selectedRegion.getViewPort();\r\n\t\tthis._originPosition = global.getComputedStyle(_target).display;\r\n\t\tthis._restoreOriginPosition = () => {\r\n\t\t\t_target.style.position = this._originPosition;\r\n\t\t};\r\n\t\tif (this._originPosition === \"static\") {\r\n\t\t\t_target.style.position = \"relative\";\r\n\t\t}\r\n\t\tconst state = gantt.$services.getService(\"state\");\r\n\t\tstate.registerProvider(\"clickDrag\", () => {\r\n\t\t\tconst result = { autoscroll: false };\r\n\t\t\treturn result;\r\n\t\t});\r\n\r\n\r\n\t\tlet scheduledDndCoordinates = null;\r\n\t\tconst startDragAndDrop = () => {\r\n\t\t\tif (!scheduledDndCoordinates) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseDown = true;\r\n\t\t\tselectedRegion.setStart(gantt.copy(scheduledDndCoordinates));\r\n\t\t\tselectedRegion.setPosition(gantt.copy(scheduledDndCoordinates));\r\n\t\t\tselectedRegion.setEnd(gantt.copy(scheduledDndCoordinates));\r\n\t\t\tscheduledDndCoordinates = null;\r\n\t\t};\r\n\r\n\t\tthis._domEvents.attach(_target, \"mousedown\", (event) => {\r\n\t\t\tscheduledDndCoordinates = null;\r\n\t\t\tlet filterTargets = \".gantt_task_line, .gantt_task_link\";\r\n\t\t\tif (ignore !== undefined) {\r\n\t\t\t\tif (ignore instanceof Array) {\r\n\t\t\t\t\tfilterTargets = ignore.join(\", \");\r\n\t\t\t\t} else {\r\n\t\t\t\t\tfilterTargets = ignore;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (filterTargets) {\r\n\t\t\t\tif (gantt.utils.dom.closest(event.target, filterTargets)) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tstate.registerProvider(\"clickDrag\", () => {\r\n\t\t\t\tconst result = { autoscroll: this._mouseDown };\r\n\t\t\t\treturn result;\r\n\t\t\t});\r\n\r\n\t\t\tif (useKey && event[useKey] !== true) { return; }\r\n\t\t\tscheduledDndCoordinates = this._getCoordinates(event, selectedRegion);\r\n\t\t});\r\n\t\tconst eventElement = domHelpers.getRootNode(gantt.$root) || document.body;\r\n\t\tthis._domEvents.attach(eventElement, \"mouseup\", (event) => {\r\n\t\t\tscheduledDndCoordinates = null;\r\n\t\t\tif (useKey && event[useKey] !== true) { return; }\r\n\t\t\tif (this._mouseDown === true) {\r\n\t\t\t\tthis._mouseDown = false;\r\n\t\t\t\tconst coordinates = this._getCoordinates(event, selectedRegion);\r\n\t\t\t\tselectedRegion.dragEnd(coordinates);\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._domEvents.attach(_target, \"mousemove\", (event) => {\r\n\t\t\tif (useKey && event[useKey] !== true) { return; }\r\n\t\t\t// GS-854. If we don't have useKey for the click_drag extension,\r\n\t\t\t// check the drag_timeline to not simultaneously use both extensions\r\n\t\t\tconst dragTimeline = this._gantt.ext.clickDrag;\r\n\t\t\tconst dragTimelineUseKey = (this._gantt.config.drag_timeline || {}).useKey;\r\n\t\t\tif (dragTimeline && dragTimelineUseKey) {\r\n\t\t\t\tif (!useKey && event[dragTimelineUseKey]) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tlet coordinates = null;\r\n\t\t\tif(!this._mouseDown && scheduledDndCoordinates){\r\n\t\t\t\tcoordinates = this._getCoordinates(event, selectedRegion);\r\n\t\t\t\tif(Math.abs(scheduledDndCoordinates.relative.left - coordinates.relative.left) > 5){\r\n\t\t\t\t\t// add small threshold not to start dnd on simple click\r\n\t\t\t\t\tstartDragAndDrop();\r\n\t\t\t\t}\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tif (this._mouseDown === true) {\r\n\t\t\t\tcoordinates = this._getCoordinates(event, selectedRegion);\r\n\t\t\t\tselectedRegion.setEnd(coordinates);\r\n\t\t\t\tselectedRegion.render();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tdetach(): void {\r\n\t\tconst gantt = this._gantt;\r\n\t\tthis._domEvents.detachAll();\r\n\t\tif(this._restoreOriginPosition){\r\n\t\t\tthis._restoreOriginPosition();\r\n\t\t}\r\n\r\n\t\tconst state = gantt.$services.getService(\"state\");\r\n\t\tstate.unregisterProvider(\"clickDrag\");\r\n\t}\r\n\r\n\tdestructor(): void {\r\n\t\tthis.detach();\r\n\t}\r\n\r\n\tprivate _getCoordinates(event: MouseEvent, selectedRegion: SelectedRegion) {\r\n\t\tconst viewPort = selectedRegion.getViewPort();\r\n\t\tconst viewPortBounds = viewPort.getBoundingClientRect();\r\n\t\tconst { clientX, clientY } = event;\r\n\t\tconst result = {\r\n\t\t\tabsolute: {\r\n\t\t\t\tleft: clientX,\r\n\t\t\t\ttop: clientY\r\n\t\t\t},\r\n\t\t\trelative: {\r\n\t\t\t\tleft: clientX - viewPortBounds.left + viewPort.scrollLeft,\r\n\t\t\t\ttop: clientY - viewPortBounds.top + viewPort.scrollTop\r\n\t\t\t}\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n}","var EventHost = function(){\r\n\tthis._silent_mode = false;\r\n\tthis.listeners = {};\r\n};\r\n\r\nEventHost.prototype = {\r\n\t_silentStart: function() {\r\n\t\tthis._silent_mode = true;\r\n\t},\r\n\t_silentEnd: function() {\r\n\t\tthis._silent_mode = false;\r\n\t}\r\n};\r\n\r\nvar\tcreateEventStorage = function(obj) {\r\n\tvar handlers = {};\r\n\tvar index = 0;\r\n\tvar eventStorage = function(){\r\n\t\tvar combinedResult = true;\r\n\t\tfor(var i in handlers){\r\n\t\t\tvar handlerResult = handlers[i].apply(obj, arguments);\r\n\t\t\tcombinedResult=combinedResult && handlerResult;\r\n\t\t}\r\n\t\treturn combinedResult;\r\n\t};\r\n\teventStorage.addEvent=function(handler, settings){\r\n\t\tif (typeof (handler) == \"function\"){\r\n\t\t\tvar handlerId;\r\n\t\t\tif(settings && settings.id){\r\n\t\t\t\thandlerId = settings.id;\r\n\t\t\t}else{\r\n\t\t\t\thandlerId = index;\r\n\t\t\t\tindex++;\r\n\t\t\t}\r\n\r\n\t\t\tif(settings && settings.once){\r\n\t\t\t\tvar originalHandler = handler;\r\n\t\t\t\thandler = function(){\r\n\t\t\t\t\toriginalHandler();\r\n\t\t\t\t\teventStorage.removeEvent(handlerId);\r\n\t\t\t\t};\r\n\t\t\t}\r\n\r\n\t\t\thandlers[handlerId] = handler;\r\n\t\t\treturn handlerId;\r\n\t\t}\r\n\t\treturn false;\r\n\t};\r\n\teventStorage.removeEvent=function(id){\r\n\t\tdelete handlers[id];\r\n\t};\r\n\r\n\teventStorage.clear = function(){\r\n\t\thandlers = {};\r\n\t};\r\n\r\n\treturn eventStorage;\r\n};\r\n\r\nfunction makeEventable(obj){\r\n\r\n\tvar eventHost = new EventHost();\r\n\tobj.attachEvent=function(eventName, handler, settings){\r\n\t\teventName = 'ev_'+eventName.toLowerCase();\r\n\t\tif (!eventHost.listeners[eventName]){\r\n\t\t\teventHost.listeners[eventName] = createEventStorage(this);\r\n\t\t}\r\n\r\n\t\tif(settings && settings.thisObject){\r\n\t\t\thandler = handler.bind(settings.thisObject);\r\n\t\t}\r\n\r\n\t\tvar innerId = eventHost.listeners[eventName].addEvent(handler, settings);\r\n\r\n\t\tvar handlerId = (eventName+':'+innerId); //return ID (ev_eventname:1)\r\n\t\tif(settings && settings.id){\r\n\t\t\thandlerId = settings.id;\r\n\t\t}\r\n\t\treturn handlerId;\r\n\t};\r\n\r\n\tobj.attachAll = function(callback){\r\n\t\tthis.attachEvent('listen_all', callback);\r\n\t};\r\n\r\n\tobj.callEvent=function(name, eventArguments){\r\n\t\tif (eventHost._silent_mode) return true;\r\n\r\n\t\tvar handlerName = 'ev_'+name.toLowerCase();\r\n\r\n\t\tvar listeners = eventHost.listeners;\r\n\t\tif (listeners['ev_listen_all']){\r\n\t\t\tlisteners['ev_listen_all'].apply(this, [name].concat(eventArguments));\r\n\t\t}\r\n\r\n\t\tif (listeners[handlerName])\r\n\t\t\treturn listeners[handlerName].apply(this, eventArguments);\r\n\t\treturn true;\r\n\t};\r\n\r\n\tobj.checkEvent=function(name){\r\n\t\tvar listeners = eventHost.listeners;\r\n\t\treturn (!!listeners['ev_'+name.toLowerCase()]);\r\n\t};\r\n\r\n\tobj.detachEvent=function(id){\r\n\t\tif (id){\r\n\t\t\tvar listeners = eventHost.listeners;\r\n\t\t\tfor(var i in listeners){\r\n\t\t\t\tlisteners[i].removeEvent(id); //remove event\r\n\t\t\t}\r\n\r\n\t\t\tvar list = id.split(':');//get EventName and ID\r\n\t\t\tvar listeners = eventHost.listeners;\r\n\t\t\tif(list.length === 2){\r\n\t\t\t\tvar eventName = list[0];\r\n\t\t\t\tvar eventId = list[1];\r\n\t\t\t\tif(listeners[eventName]){\r\n\t\t\t\t\tlisteners[eventName].removeEvent(eventId); //remove event\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\tobj.detachAllEvents = function(){\r\n\t\tfor (var name in eventHost.listeners) {\r\n\t\t\teventHost.listeners[name].clear();\r\n\t\t}\r\n\t};\r\n\r\n}\r\n\r\nexport default makeEventable;","var units = {\r\n\t\"second\": 1,\r\n\t\"minute\": 60,\r\n\t\"hour\": 60 * 60,\r\n\t\"day\": 60 * 60 * 24,\r\n\t\"week\": 60 * 60 * 24 * 7,\r\n\t\"month\": 60 * 60 * 24 * 30,\r\n\t\"quarter\": 60 * 60 * 24 * 30 * 3,\r\n\t\"year\": 60 * 60 * 24 * 365\r\n};\r\nfunction getSecondsInUnit(unit){\r\n\treturn units[unit] || units.hour;\r\n}\r\n\r\nfunction forEach(arr, callback) {\r\n\tif (arr.forEach) {\r\n\t\tarr.forEach(callback);\r\n\t} else {\r\n\t\tvar workArray = arr.slice();\r\n\t\tfor (var i = 0; i < workArray.length; i++) {\r\n\t\t\tcallback(workArray[i], i);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction arrayMap(arr, callback) {\r\n\tif (arr.map) {\r\n\t\treturn arr.map(callback);\r\n\t} else {\r\n\t\tvar workArray = arr.slice();\r\n\t\tvar resArray = [];\r\n\r\n\t\tfor (var i = 0; i < workArray.length; i++) {\r\n\t\t\tresArray.push(callback(workArray[i], i));\r\n\t\t}\r\n\t\treturn resArray;\r\n\t}\r\n}\r\n\r\n\r\nfunction arrayFind(arr, callback) {\r\n\tif (arr.find) {\r\n\t\treturn arr.find(callback);\r\n\t} else {\r\n\t\tfor (var i = 0; i < arr.length; i++) {\r\n\t\t\tif (callback(arr[i], i)) {\r\n\t\t\t\treturn arr[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction arrayIncludes(arr, item) {\r\n\tif(arr.includes){\r\n\t\treturn arr.includes(item);\r\n\t}else{\r\n\t\tfor (var i = 0; i < arr.length; i++) {\r\n\t\t\tif (arr[i] === item) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\n// iframe-safe array type check instead of using instanceof\r\nfunction isArray(obj){\r\n\tif(Array.isArray){\r\n\t\treturn Array.isArray(obj);\r\n\t}else{\r\n\t\t// close enough\r\n\t\treturn (obj && obj.length !== undefined && obj.pop && obj.push);\r\n\t}\r\n}\r\n\r\n// non-primitive string object, e.g. new String(\"abc\")\r\nfunction isStringObject(obj){\r\n\treturn obj && typeof obj === \"object\"\r\n\t\t&& Function.prototype.toString.call(obj.constructor) === \"function String() { [native code] }\";\r\n}\r\n\r\n// non-primitive number object, e.g. new Number(5)\r\nfunction isNumberObject(obj){\r\n\treturn obj && typeof obj === \"object\"\r\n\t\t&& Function.prototype.toString.call(obj.constructor) === \"function Number() { [native code] }\";\r\n}\r\n\r\n// non-primitive number object, e.g. new Boolean(true)\r\nfunction isBooleanObject(obj){\r\n\treturn obj && typeof obj === \"object\"\r\n\t\t&& Function.prototype.toString.call(obj.constructor) === \"function Boolean() { [native code] }\";\r\n}\r\n\r\nfunction isDate(obj) {\r\n\tif (obj && typeof obj === \"object\") {\r\n\t\treturn !!(obj.getFullYear && obj.getMonth && obj.getDate);\r\n\t} else {\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\nfunction isValidDate(obj){\r\n\treturn isDate(obj) && !isNaN(obj.getTime());\r\n}\r\n\r\nfunction arrayFilter(arr, callback) {\r\n\tvar result = [];\r\n\r\n\tif (arr.filter) {\r\n\t\treturn arr.filter(callback);\r\n\t} else {\r\n\t\tfor (var i = 0; i < arr.length; i++) {\r\n\t\t\tif (callback(arr[i], i)) {\r\n\t\t\t\tresult[result.length] = arr[i];\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n}\r\n\r\nfunction hashToArray(hash) {\r\n\tvar result = [];\r\n\r\n\tfor (var key in hash) {\r\n\t\tif (hash.hasOwnProperty(key)) {\r\n\t\t\tresult.push(hash[key]);\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\nfunction arraySome(arr, callback) {\r\n\tif (arr.length === 0) return false;\r\n\r\n\tfor (var i = 0; i < arr.length; i++) {\r\n\t\tif (callback(arr[i], i, arr)) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nfunction arrayDifference(arr, callback) {\r\n\treturn arrayFilter(arr, function(item, i) {\r\n\t\treturn !callback(item, i);\r\n\t});\r\n}\r\n\r\nfunction throttle (callback, timeout) {\r\n\tvar wait = false;\r\n\r\n\treturn function () {\r\n\t\tif (!wait) {\r\n\t\t\tcallback.apply(null, arguments);\r\n\t\t\twait = true;\r\n\t\t\tsetTimeout(function () {\r\n\t\t\t\twait = false;\r\n\t\t\t}, timeout);\r\n\t\t}\r\n\t};\r\n}\r\n\r\nfunction delay (callback, timeout){\r\n\tvar timer;\r\n\r\n\tvar result = function() {\r\n\t\tresult.$cancelTimeout();\r\n\t\tresult.$pending = true;\r\n\t\tvar args = Array.prototype.slice.call(arguments);\r\n\t\ttimer = setTimeout(function(){\r\n\t\t\tcallback.apply(this, args);\r\n\t\t\tresult.$pending = false;\r\n\t\t}, timeout);\r\n\t};\r\n\r\n\tresult.$pending = false;\r\n\tresult.$cancelTimeout = function(){\r\n\t\tclearTimeout(timer);\r\n\t\tresult.$pending = false;\r\n\t};\r\n\tresult.$execute = function(){\r\n\t\tvar args = Array.prototype.slice.call(arguments);\r\n\t\tcallback.apply(this, args);\r\n\t\tresult.$cancelTimeout();\r\n\t};\r\n\r\n\treturn result;\r\n}\r\n\r\nfunction sortArrayOfHash(arr, field, desc) {\r\n\tvar compare = function(a, b) {\r\n\t\treturn a < b;\r\n\t};\r\n\r\n\tarr.sort(function(a, b) {\r\n\t\tif (a[field] === b[field]) return 0;\r\n\r\n\t\treturn desc ? compare(a[field], b[field]) : compare(b[field], a[field]);\r\n\t});\r\n}\r\n\r\nfunction objectKeys(obj) {\r\n\tif (Object.keys) {\r\n\t\treturn Object.keys(obj);\r\n\t}\r\n\tvar result = [];\r\n\tvar key;\r\n\tfor (key in obj) {\r\n\t\tif (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n\t\t\tresult.push(key);\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nfunction isEventable(obj) {\r\n\treturn obj.attachEvent && obj.detachEvent;\r\n}\r\n\r\n//GS-1090: A task should be able to have the id = 0\r\nfunction replaceValidZeroId(id, rootId) {\r\n\tif (checkZeroId(id) && !checkZeroId(rootId)){\r\n\t\tid = \"0\";\r\n\t}\r\n\treturn id;\r\n}\r\n\r\nfunction checkZeroId(id) {\r\n\tif (id === 0){\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nfunction findBinary(array, target) {\r\n\t// modified binary search, target value not exactly match array elements, looking for closest one\r\n\r\n\tvar low = 0, high = array.length - 1, i, item, prev;\r\n\twhile (low <= high) {\r\n\r\n\t\ti = Math.floor((low + high) / 2);\r\n\t\titem = +array[i];\r\n\t\tprev = +array[i - 1];\r\n\t\tif (item < target) {\r\n\t\t\tlow = i + 1;\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tif (item > target) {\r\n\t\t\tif (!(!isNaN(prev) && prev < target)) {\r\n\t\t\t\thigh = i - 1;\r\n\t\t\t\tcontinue;\r\n\t\t\t} else {\r\n\t\t\t\t// if target is between 'i' and 'i-1' return 'i - 1'\r\n\t\t\t\treturn i - 1;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\twhile (+array[i] == +array[i + 1]) i++;\r\n\r\n\t\treturn i;\r\n\t}\r\n\treturn array.length - 1;\r\n}\r\n\r\nexport {\r\n\tgetSecondsInUnit,\r\n\tforEach,\r\n\tarrayMap,\r\n\tarrayIncludes,\r\n\tarrayFind,\r\n\tarrayFilter,\r\n\tarrayDifference,\r\n\tarraySome,\r\n\thashToArray,\r\n\tsortArrayOfHash,\r\n\tthrottle,\r\n\tisArray,\r\n\tisDate,\r\n\tisValidDate,\r\n\tisStringObject,\r\n\tisNumberObject,\r\n\tisBooleanObject,\r\n\tdelay,\r\n\tobjectKeys,\r\n\tisEventable,\r\n\treplaceValidZeroId,\r\n\tcheckZeroId,\r\n\tfindBinary\r\n};","import eventable from \"../../utils/eventable\";\r\nimport { isEventable } from \"../../utils/helpers\";\r\n\r\nexport interface ISelectedRegionConfig {\r\n\tclassName?: string;\r\n\trender?: (startPoint: IPoint, endPoint: IPoint) => HTMLElement;\r\n\tviewPort?: HTMLElement;\r\n\tuseRequestAnimationFrame: boolean;\r\n\tcallback?: (startPoint: IPoint, endPoint: IPoint, startDate: Date, endDate: Date, tasksByDate: any[], tasksByIndex: any[]) => void;\r\n\tsingleRow: boolean;\r\n}\r\n\r\ninterface ICoordinates {\r\n\tleft: number;\r\n\ttop: number;\r\n}\r\n\r\nexport interface IPoint {\r\n\tabsolute: ICoordinates;\r\n\trelative: ICoordinates;\r\n}\r\n\r\nexport class SelectedRegion {\r\n\trender: () => void;\r\n\tprivate _viewPort: HTMLElement & eventable;\r\n\tprivate _el: HTMLElement = document.createElement(\"div\");\r\n\tprivate _callback: (startPoint: IPoint, endPoint: IPoint, startDate: Date, endDate: Date, tasksByDate: any[], tasksByIndex: any[]) => void;\r\n\tprivate _startPoint: IPoint;\r\n\tprivate _endPoint: IPoint;\r\n\tprivate _positionPoint: IPoint;\r\n\tprivate _useRequestAnimationFrame: boolean;\r\n\tprivate _startDate: Date;\r\n\tprivate _endDate: Date;\r\n\tprivate _singleRow: boolean;\r\n\tprivate _gantt: any;\r\n\tprivate _view: any;\r\n\r\n\tconstructor(config: ISelectedRegionConfig, gantt: any, view: any) {\r\n\t\tthis._gantt = gantt;\r\n\t\tthis._view = view;\r\n\t\tthis._viewPort = config.viewPort;\r\n\t\tthis._el.classList.add(config.className);\r\n\t\tif (typeof config.callback === \"function\") {\r\n\t\t\tthis._callback = config.callback;\r\n\t\t}\r\n\r\n\t\tthis.render = () => {\r\n\t\t\tlet node;\r\n\t\t\tif(config.render){\r\n\t\t\t\tnode = config.render(this._startPoint, this._endPoint);\r\n\t\t\t}else{\r\n\t\t\t\tnode = this.defaultRender(this._startPoint, this._endPoint);\r\n\t\t\t}\r\n\r\n\t\t\tif(node !== this._el){\r\n\t\t\t\tif(this._el && this._el.parentNode){\r\n\t\t\t\t\tthis._el.parentNode.removeChild(this._el);\r\n\t\t\t\t}\r\n\t\t\t\tthis._el = node;\r\n\t\t\t}\r\n\r\n\t\t\tif (config.className !== \"\") {\r\n\t\t\t\tthis._el.classList.add(config.className);\r\n\t\t\t}\r\n\t\t\tthis.draw();\r\n\t\t};\r\n\r\n\t\tif (!isEventable(this._viewPort)) {\r\n\t\t\teventable(this._viewPort);\r\n\t\t}\r\n\t\tthis._singleRow = config.singleRow;\r\n\t\tthis._useRequestAnimationFrame = config.useRequestAnimationFrame;\r\n\t}\r\n\r\n\tdefaultRender = (start: IPoint, end: IPoint) => {\r\n\t\tif(!this._el){\r\n\t\t\tthis._el = document.createElement(\"div\");\r\n\t\t}\r\n\t\tconst node = this._el;\r\n\t\t// const gantt = this._gantt;\r\n\r\n\t\tconst top = Math.min(start.relative.top, end.relative.top);\r\n\t\tconst bottom = Math.max(start.relative.top, end.relative.top);\r\n\t\tconst left = Math.min(start.relative.left, end.relative.left);\r\n\t\tconst right = Math.max(start.relative.left, end.relative.left);\r\n\r\n\t\tif (this._singleRow) {\r\n\t\t\tconst pos = this._getTaskPositionByTop(this._startPoint.relative.top);\r\n\t\t\tnode.style.height = pos.height + \"px\";\r\n\t\t\tnode.style.top = pos.top + \"px\";\r\n\t\t} else {\r\n\t\t\tnode.style.height = Math.abs(bottom - top) + \"px\";\r\n\t\t\tnode.style.top = top + \"px\";\r\n\t\t}\r\n\t\tnode.style.width = Math.abs(right - left) + \"px\";\r\n\t\tnode.style.left = left + \"px\";\r\n\t\treturn node;\r\n\t};\r\n\r\n\tdraw() {\r\n\t\tif (this._useRequestAnimationFrame) {\r\n\t\t\treturn requestAnimationFrame(() => {\r\n\t\t\t\tthis._viewPort.appendChild(this.getElement());\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tthis._viewPort.appendChild(this.getElement());\r\n\t\t}\r\n\t}\r\n\r\n\tclear() {\r\n\t\tif (this._useRequestAnimationFrame) {\r\n\t\t\treturn requestAnimationFrame(() => {\r\n\t\t\t\tif (!this._el.parentNode) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tthis._viewPort.removeChild(this._el);\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tif (!this._el.parentNode) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tthis._viewPort.removeChild(this._el);\r\n\t\t}\r\n\t}\r\n\r\n\tgetElement() {\r\n\t\treturn this._el;\r\n\t}\r\n\r\n\tgetViewPort() {\r\n\t\treturn this._viewPort;\r\n\t}\r\n\r\n\tsetStart(startPoint: IPoint) {\r\n\t\tconst gantt = this._gantt;\r\n\t\tthis._startPoint = startPoint;\r\n\t\tthis._startDate = gantt.dateFromPos(this._startPoint.relative.left);\r\n\t\tthis._viewPort.callEvent(\"onBeforeDrag\", [this._startPoint]);\r\n\t}\r\n\r\n\tsetEnd(endPoint: IPoint) {\r\n\t\tconst gantt = this._gantt;\r\n\t\tthis._endPoint = endPoint;\r\n\t\tif (this._singleRow) {\r\n\t\t\tconst pos = this._getTaskPositionByTop(this._startPoint.relative.top);\r\n\t\t\tthis._endPoint.relative.top = pos.top;\r\n\t\t}\r\n\t\tthis._endDate = gantt.dateFromPos(this._endPoint.relative.left);\r\n\t\tif (this._startPoint.relative.left > this._endPoint.relative.left) {\r\n\t\t\tthis._positionPoint = {\r\n\t\t\t\trelative: { left: this._endPoint.relative.left, top: this._positionPoint.relative.top },\r\n\t\t\t\tabsolute: { left: this._endPoint.absolute.left, top: this._positionPoint.absolute.top }\r\n\t\t\t};\r\n\t\t}\r\n\t\tif (this._startPoint.relative.top > this._endPoint.relative.top) {\r\n\t\t\tthis._positionPoint = {\r\n\t\t\t\trelative: { left: this._positionPoint.relative.left, top: this._endPoint.relative.top },\r\n\t\t\t\tabsolute: { left: this._positionPoint.absolute.left, top: this._endPoint.absolute.top }\r\n\t\t\t};\r\n\t\t}\r\n\r\n\r\n\t\tthis._viewPort.callEvent(\"onDrag\", [this._startPoint, this._endPoint]);\r\n\t}\r\n\r\n\tsetPosition(positionPoint: IPoint) {\r\n\t\tthis._positionPoint = positionPoint;\r\n\t}\r\n\r\n\tdragEnd(endPoint: IPoint) {\r\n\t\tconst gantt = this._gantt;\r\n\t\tif(endPoint.relative.left < 0){\r\n\t\t\tendPoint.relative.left = 0;\r\n\t\t}\r\n\t\tthis._viewPort.callEvent(\"onBeforeDragEnd\", [this._startPoint, endPoint]);\r\n\t\tthis.setEnd(endPoint);\r\n\t\t// GS-1422. The endDate can be null if we drag the mouse outside the Gantt container\r\n\t\tthis._endDate = this._endDate || gantt.getState().max_date;\r\n\r\n\t\tif (this._startDate.valueOf() > this._endDate.valueOf()) {\r\n\t\t\t[ this._startDate, this._endDate ] = [ this._endDate, this._startDate ];\r\n\t\t}\r\n\t\tthis.clear();\r\n\t\tconst tasksByTime = gantt.getTaskByTime(this._startDate, this._endDate);\r\n\t\tconst tasksByIndex = this._getTasksByTop(this._startPoint.relative.top, this._endPoint.relative.top);\r\n\r\n\t\tthis._viewPort.callEvent(\"onDragEnd\", [this._startPoint, this._endPoint]);\r\n\t\tif (this._callback) {\r\n\t\t\tthis._callback(this._startPoint, this._endPoint, this._startDate, this._endDate, tasksByTime, tasksByIndex);\r\n\t\t}\r\n\t}\r\n\r\n\tgetInBounds() {\r\n\t\treturn this._singleRow;\r\n\t}\r\n\r\n\tprivate _getTasksByTop(start: number, end:number) {\r\n\t\tconst gantt = this._gantt;\r\n\t\tlet startValue = start;\r\n\t\tlet endValue = end;\r\n\t\tif (start > end) {\r\n\t\t\tstartValue = end;\r\n\t\t\tendValue = start;\r\n\t\t}\r\n\t\tconst startIndex = this._getTaskPositionByTop(startValue).index;\r\n\t\tconst endIndex = this._getTaskPositionByTop(endValue).index;\r\n\t\tconst result = [];\r\n\t\tfor (let i = startIndex; i <= endIndex; i++) {\r\n\t\t\tconst task = gantt.getTaskByIndex(i);\r\n\t\t\tif (task) {\r\n\t\t\t\tresult.push(gantt.getTaskByIndex(i));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\tprivate _getTaskPositionByTop(top: number){\r\n\t\tconst gantt = this._gantt;\r\n\t\tconst view = this._view;\r\n\t\tconst index = view.getItemIndexByTopPosition(top);\r\n\t\tconst task = gantt.getTaskByIndex(index);\r\n\t\tif(task){\r\n\t\t\tconst height = view.getItemHeight(task.id);\r\n\t\t\tconst itemTop = view.getItemTop(task.id);\r\n\t\t\treturn {\r\n\t\t\t\ttop: itemTop || 0,\r\n\t\t\t\theight: height || 0,\r\n\t\t\t\tindex\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tconst dataHeight = view.getTotalHeight();\r\n\t\t\treturn {\r\n\t\t\t\ttop: top > dataHeight ? dataHeight : 0,\r\n\t\t\t\theight: gantt.config.row_height,\r\n\t\t\t\tindex: top > dataHeight ? gantt.getTaskCount() : 0\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n}","interface IPoint {\r\n\tx: number;\r\n\ty: number;\r\n}\r\n\r\nexport class EventsManager {\r\n\tstatic create(gantt: any) {\r\n\t\treturn new EventsManager(gantt);\r\n\t}\r\n\tprivate _mouseDown: boolean = false;\r\n\tprivate _startPoint: IPoint;\r\n\tprivate _scrollState: IPoint;\r\n\tprivate _originAutoscroll: boolean;\r\n\tprivate _domEvents: any;\r\n\tprivate _timeline: any;\r\n\tprivate _gantt: any;\r\n\tprivate _trace: IPoint[];\r\n\tprivate _originalReadonly: boolean;\r\n\r\n\tconstructor(gantt: any) {\r\n\t\tthis._gantt = gantt;\r\n\t\tthis._domEvents = gantt._createDomEventScope();\r\n\t\tthis._trace = [];\r\n\t}\r\n\r\n\tdestructor() {\r\n\t\tthis._domEvents.detachAll();\r\n\t}\r\n\r\n\tattach(timeline: any): void {\r\n\t\tthis._timeline = timeline;\r\n\t\tconst gantt = this._gantt;\r\n\t\tthis._domEvents.attach(timeline.$task, \"mousedown\", (event) => {\r\n\t\t\tif (!gantt.config.drag_timeline) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tconst { useKey,ignore, enabled } = gantt.config.drag_timeline;\r\n\t\t\tif(enabled === false) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tlet filterTargets = \".gantt_task_line, .gantt_task_link\";\r\n\t\t\tif(ignore !== undefined) {\r\n\t\t\t\tif(ignore instanceof Array){\r\n\t\t\t\t\tfilterTargets = ignore.join(\", \");\r\n\t\t\t\t} else {\r\n\t\t\t\t\tfilterTargets = ignore;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (filterTargets) {\r\n\t\t\t\tif (gantt.utils.dom.closest(event.target, filterTargets)) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (useKey && event[useKey] !== true) { return; }\r\n\r\n\t\t\tthis._startDrag(event);\r\n\t\t});\r\n\r\n\t\tthis._domEvents.attach(document, \"keydown\", (event) => {\r\n\t\t\tif (!gantt.config.drag_timeline) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tconst { useKey } = gantt.config.drag_timeline;\r\n\t\t\tif (useKey && event[useKey] === true) {\r\n\t\t\t\tthis._applyDndReadyStyles();\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._domEvents.attach(document, \"keyup\", (event) => {\r\n\t\t\tif (!gantt.config.drag_timeline) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tconst { useKey } = gantt.config.drag_timeline;\r\n\t\t\tif (useKey && event[useKey] === false) {\r\n\t\t\t\tthis._clearDndReadyStyles();\r\n\t\t\t\tthis._stopDrag(event);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis._domEvents.attach(document, \"mouseup\", (event) => {\r\n\t\t\tthis._stopDrag(event);\r\n\t\t});\r\n\t\tthis._domEvents.attach(gantt.$root, \"mouseup\", (event) => {\r\n\t\t\tthis._stopDrag(event);\r\n\t\t});\r\n\t\tthis._domEvents.attach(document, \"mouseleave\", (event) => {\r\n\t\t\tthis._stopDrag(event);\r\n\t\t});\r\n\t\tthis._domEvents.attach(gantt.$root, \"mouseleave\", (event) => {\r\n\t\t\tthis._stopDrag(event);\r\n\t\t});\r\n\r\n\t\tthis._domEvents.attach(gantt.$root, \"mousemove\", (event) => {\r\n\t\t\tif (!gantt.config.drag_timeline) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tconst { useKey } = gantt.config.drag_timeline;\r\n\t\t\tif (useKey && event[useKey] !== true) { return; }\r\n\t\t\t// GS-854. If we don't have useKey for the drag_timeline extension,\r\n\t\t\t// check the click_drag to not simultaneously use both extensions\r\n\t\t\tconst clickDrag = this._gantt.ext.clickDrag;\r\n\t\t\tconst clickDragUseKey = (this._gantt.config.click_drag || {}).useKey;\r\n\t\t\tif (clickDrag && clickDragUseKey) {\r\n\t\t\t\tif (!useKey && event[clickDragUseKey]) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (this._mouseDown === true) {\r\n\t\t\t\tthis._trace.push({ x: event.clientX, y: event.clientY });\r\n\t\t\t\tconst scrollPosition: IPoint = this._countNewScrollPosition({ x: event.clientX, y: event.clientY });\r\n\t\t\t\tthis._setScrollPosition(timeline, scrollPosition);\r\n\t\t\t\tthis._scrollState = scrollPosition;\r\n\t\t\t\tthis._startPoint = { x: event.clientX, y: event.clientY };\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tprivate _calculateDirectionVector = () => {\r\n\t\tconst traceSteps = 10;\r\n\t\tif(this._trace.length >= traceSteps) {\r\n\t\t\tconst dots = this._trace.slice(this._trace.length - traceSteps);\r\n\r\n\t\t\tconst vectors = [];\r\n\t\t\tfor(let i = 1; i < dots.length; i++) {\r\n\t\t\t\tvectors.push({\r\n\t\t\t\t\tx: dots[i].x - dots[i - 1].x,\r\n\t\t\t\t\ty: dots[i].y - dots[i - 1].y\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\tconst resultVector = {x:0, y:0};\r\n\r\n\t\t\tvectors.forEach((vector) => {\r\n\t\t\t\tresultVector.x += vector.x;\r\n\t\t\t\tresultVector.y += vector.y;\r\n\t\t\t});\r\n\r\n\t\t\tconst magnitude = Math.sqrt(resultVector.x*resultVector.x + resultVector.y*resultVector.y);\r\n\t\t\tconst angleDegrees = Math.atan2(Math.abs(resultVector.y), Math.abs(resultVector.x)) * 180 / Math.PI;\r\n\r\n\t\t\treturn {\r\n\t\t\t\tmagnitude,\r\n\t\t\t\tangleDegrees\r\n\t\t\t};\r\n\r\n\t\t}\r\n\t\treturn null;\r\n\t};\r\n\r\n\tprivate _applyDndReadyStyles = (): void => {\r\n\t\tthis._timeline.$task.classList.add(\"gantt_timeline_move_available\");\r\n\t};\r\n\r\n\tprivate _clearDndReadyStyles = (): void => {\r\n\t\tthis._timeline.$task.classList.remove(\"gantt_timeline_move_available\");\r\n\t};\r\n\r\n\tprivate _getScrollPosition = (timeline: any): IPoint => {\r\n\t\tconst gantt = this._gantt;\r\n\t\treturn {\r\n\t\t\tx: gantt.$ui.getView(timeline.$config.scrollX).getScrollState().position,\r\n\t\t\ty: gantt.$ui.getView(timeline.$config.scrollY).getScrollState().position\r\n\t\t};\r\n\t};\r\n\tprivate _countNewScrollPosition = (coords: IPoint): IPoint => {\r\n\t\tconst vector = this._calculateDirectionVector();\r\n\t\tlet shiftX = this._startPoint.x - coords.x;\r\n\t\tlet shiftY = this._startPoint.y - coords.y;\r\n\t\tif(vector){\r\n\t\t\tif(vector.angleDegrees < 15){\r\n\t\t\t\tshiftY = 0;\r\n\t\t\t} else if(vector.angleDegrees > 75){\r\n\t\t\t\tshiftX = 0;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst result = {\r\n\t\t\tx: this._scrollState.x + shiftX,\r\n\t\t\ty: this._scrollState.y + shiftY\r\n\t\t};\r\n\t\treturn result;\r\n\t};\r\n\tprivate _setScrollPosition = (timeline: any, coords: IPoint): void => {\r\n\t\tconst gantt = this._gantt;\r\n\t\trequestAnimationFrame(() => {\r\n\t\t\tgantt.scrollLayoutCell(timeline.$id, coords.x, coords.y);\r\n\t\t});\r\n\t};\r\n\tprivate _stopDrag = (event: Event): void => {\r\n\t\tconst gantt = this._gantt;\r\n\t\tthis._trace = [];\r\n\t\tgantt.$root.classList.remove(\"gantt_noselect\");\r\n\r\n\t\tif(this._originalReadonly !== undefined){\r\n\t\t\tgantt.config.readonly = this._originalReadonly;\r\n\t\t\tif(this._mouseDown && gantt.config.drag_timeline && gantt.config.drag_timeline.render){\r\n\t\t\t\tgantt.render();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(this._originAutoscroll !== undefined){\r\n\t\t\tgantt.config.autoscroll = this._originAutoscroll;\r\n\t\t}\r\n\r\n\t\tif(gantt.config.drag_timeline){\r\n\t\t\tconst { useKey } = gantt.config.drag_timeline;\r\n\t\t\tif (useKey && event[useKey] !== true) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._mouseDown = false;\r\n\t};\r\n\r\n\tprivate _startDrag = (event: any) : void => {\r\n\t\tconst gantt = this._gantt;\r\n\t\tthis._originAutoscroll = gantt.config.autoscroll;\r\n\t\tgantt.config.autoscroll = false;\r\n\r\n\t\tgantt.$root.classList.add(\"gantt_noselect\");\r\n\t\tthis._originalReadonly = gantt.config.readonly;\r\n\t\tgantt.config.readonly = true;\r\n\r\n\t\tif(gantt.config.drag_timeline && gantt.config.drag_timeline.render){\r\n\t\t\tgantt.render();\r\n\t\t}\r\n\r\n\t\tthis._trace = [];\r\n\t\tthis._mouseDown = true;\r\n\t\tconst { x, y } = this._getScrollPosition(this._timeline);\r\n\t\tthis._scrollState = { x, y };\r\n\t\tthis._startPoint = { x: event.clientX, y: event.clientY };\r\n\t\tthis._trace.push(this._startPoint);\r\n\t};\r\n}","export default function(gantt) {\r\n\r\n\t(function () {\r\n\t\tvar modalsStack = [];\r\n\r\n\t\tfunction isModal() {\r\n\t\t\treturn !!modalsStack.length;\r\n\t\t}\r\n\r\n\t\tfunction afterPopup(box) {\r\n\t\t\tsetTimeout(function () {\r\n\t\t\t\tif (!isModal()){\r\n\t\t\t\t\tif(!gantt.$destroyed){\r\n\t\t\t\t\t\tgantt.focus();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}, 1);\r\n\t\t}\r\n\r\n\t\tfunction startModal(box) {\r\n\t\t\tgantt.eventRemove(box, \"keydown\", trapFocus);\r\n\t\t\tgantt.event(box, \"keydown\", trapFocus);\r\n\t\t\tmodalsStack.push(box);\r\n\t\t\t//gantt.$keyboardNavigation.dispatcher.disable();\r\n\t\t}\r\n\r\n\t\tfunction endModal() {\r\n\t\t\tvar box = modalsStack.pop();\r\n\t\t\tif (box) {\r\n\t\t\t\tgantt.eventRemove(box, \"keydown\", trapFocus);\r\n\t\t\t}\r\n\t\t\tafterPopup(box);\r\n\r\n\t\t}\r\n\r\n\r\n\t\tfunction isTopModal(box) {\r\n\t\t\treturn box == modalsStack[modalsStack.length - 1];\r\n\t\t}\r\n\r\n\t\tfunction trapFocus(event) {\r\n\t\t\tvar target = event.currentTarget;\r\n\t\t\tif (!isTopModal(target)) return;\r\n\r\n\t\t\tgantt.$keyboardNavigation.trapFocus(target, event);\r\n\t\t}\r\n\r\n\t\tfunction traceLightbox() {\r\n\t\t\tstartModal(gantt.getLightbox());\r\n\t\t}\r\n\r\n\t\tgantt.attachEvent(\"onLightbox\", traceLightbox);\r\n\t\tgantt.attachEvent(\"onAfterLightbox\", endModal);\r\n\t\tgantt.attachEvent(\"onLightboxChange\", function () {\r\n\t\t\tendModal();\r\n\t\t\ttraceLightbox();\r\n\t\t});\r\n\r\n\r\n\t\tgantt.attachEvent(\"onAfterQuickInfo\", function () {\r\n\t\t\tafterPopup();\r\n\t\t});\r\n\r\n\t\tgantt.attachEvent(\"onMessagePopup\", function (box) {\r\n\t\t\tsaveFocus();\r\n\t\t\tstartModal(box);\r\n\t\t});\r\n\t\tgantt.attachEvent(\"onAfterMessagePopup\", function () {\r\n\t\t\tendModal();\r\n\t\t\trestoreFocus();\r\n\t\t});\r\n\r\n\t\tvar focusElement = null;\r\n\r\n\t\tfunction saveFocus() {\r\n\t\t\tfocusElement = gantt.utils.dom.getActiveElement();\r\n\t\t}\r\n\r\n\t\tfunction restoreFocus() {\r\n\t\t\tsetTimeout(function () {\r\n\t\t\t\tif (focusElement) {\r\n\t\t\t\t\tfocusElement.focus();\r\n\t\t\t\t\tfocusElement = null;\r\n\t\t\t\t}\r\n\t\t\t}, 1);\r\n\t\t}\r\n\r\n\t\tgantt.$keyboardNavigation.isModal = isModal;\r\n\r\n\r\n\t})();\r\n\r\n};","\r\ninterface IQuickInfoContainer{\r\n\tparent: HTMLElement;\r\n\txViewport: HTMLElement;\r\n\tyViewport: HTMLElement;\r\n}\r\n\r\nexport class QuickInfo {\r\n\tprivate _quickInfoTask: TaskID;\r\n\tprivate _quickInfoBoxId: number | string;\r\n\tprivate _quickInfoBox: HTMLElement;\r\n\tprivate _quickInfoReadonly: boolean | null;\r\n\tprivate _container: HTMLElement;\r\n\tprivate _gantt: any;\r\n\r\n\tconstructor(gantt: any) {\r\n\t\tthis._gantt = gantt;\r\n\t}\r\n\r\n\t// show at coordinates:\r\n\t// show(x: number, y: number)\r\n\t// show for a task:\r\n\t// show(id: TaskID)\r\n\tshow : {\r\n\t\t(x: number, y: number) : void;\r\n\t\t(id: TaskID) : void;\r\n\t} = (id: TaskID | number, y? : number) : void => {\r\n\t\tif (y === undefined) {\r\n\t\t\tthis._showForTask(id);\r\n\t\t} else {\r\n\t\t\tthis._showAtCoordinates(id as number, y);\r\n\t\t}\r\n\t};\r\n\r\n\thide = (forced?: boolean) : any => {\r\n\t\tconst gantt = this._gantt;\r\n\t\tconst qi = this._quickInfoBox;\r\n\t\tthis._quickInfoBoxId = 0;\r\n\t\tconst taskId = this._quickInfoTask;\r\n\t\tthis._quickInfoTask = null;\r\n\r\n\t\tif (qi && qi.parentNode){\r\n\r\n\t\t\tif (gantt.config.quick_info_detached) {\r\n\t\t\t\tgantt.callEvent(\"onAfterQuickInfo\", [taskId]);\r\n\t\t\t\treturn qi.parentNode.removeChild(qi);\r\n\t\t\t}\r\n\r\n\t\t\tqi.className += \" gantt_qi_hidden\";\r\n\t\t\tif (qi.style.right === \"auto\"){\r\n\t\t\t\tqi.style.left = \"-350px\";\r\n\t\t\t} else {\r\n\t\t\t\tqi.style.right = \"-350px\";\r\n\t\t\t}\r\n\r\n\t\t\tif (forced) {\r\n\t\t\t\tqi.style.left = qi.style.right = \"\";\r\n\t\t\t\tqi.parentNode.removeChild(qi);\r\n\t\t\t}\r\n\t\t\tgantt.callEvent(\"onAfterQuickInfo\", [taskId]);\r\n\t\t}\r\n\t};\r\n\r\n\tgetNode = (): HTMLElement => {\r\n\t\tif(this._quickInfoBox) {\r\n\t\t\treturn this._quickInfoBox;\r\n\t\t}\r\n\t\treturn null;\r\n\t};\r\n\r\n\tsetContainer = (container: string|HTMLElement): void => {\r\n\t\tif(container){\r\n\t\t\tthis._container = typeof container === \"string\" ? document.getElementById(container) : container;\r\n\t\t}\r\n\t};\r\n\r\n\tsetContent = (content?: IQuickInfoContent) => {\r\n\t\tconst gantt = this._gantt;\r\n\r\n\t\tconst defaultContent = {\r\n\t\t\ttaskId: null,\r\n\t\t\theader: {\r\n\t\t\t\ttitle: \"\",\r\n\t\t\t\tdate: \"\"\r\n\t\t\t},\r\n\t\t\tcontent: \"\",\r\n\t\t\tbuttons: gantt.config.quickinfo_buttons\r\n\t\t};\r\n\r\n\t\tif(!content){\r\n\t\t\tcontent = defaultContent;\r\n\t\t}\r\n\r\n\t\tif(!content.taskId){\r\n\t\t\tcontent.taskId = defaultContent.taskId;\r\n\t\t}\r\n\r\n\t\tif(!content.header){\r\n\t\t\tcontent.header = defaultContent.header;\r\n\t\t}\r\n\r\n\t\tif(!content.header.title){\r\n\t\t\tcontent.header.title = defaultContent.header.title;\r\n\t\t}\r\n\t\tif(!content.header.date){\r\n\t\t\tcontent.header.date = defaultContent.header.date;\r\n\t\t}\r\n\t\tif(!content.content){\r\n\t\t\tcontent.content = defaultContent.content;\r\n\t\t}\r\n\t\tif(!content.buttons){\r\n\t\t\tcontent.buttons = defaultContent.buttons;\r\n\t\t}\r\n\r\n\r\n\t\tlet qi = this.getNode();\r\n\t\tif(!qi){\r\n\t\t\tqi = this._createQuickInfoElement();\r\n\t\t}\r\n\r\n\t\tif(content.taskId){\r\n\t\t\tthis._quickInfoBoxId = content.taskId;\r\n\t\t}\r\n\r\n\t\tconst titleBox = qi.querySelector(\".gantt_cal_qi_title\") as HTMLElement;\r\n\t\tconst titleContent = titleBox.querySelector(\".gantt_cal_qi_tcontent\");\r\n\t\tconst titleDate = titleBox.querySelector(\".gantt_cal_qi_tdate\");\r\n\t\tconst main = qi.querySelector(\".gantt_cal_qi_content\");\r\n\t\tconst controls = qi.querySelector(\".gantt_cal_qi_controls\") as HTMLElement;\r\n\r\n\t\tgantt._waiAria.quickInfoHeader(qi, [content.header.title, content.header.date].join(\" \"));\r\n\r\n\t\ttitleContent.innerHTML = content.header.title;\r\n\t\ttitleDate.innerHTML = content.header.date;\r\n\r\n\t\tif(!content.header.title && !content.header.date){\r\n\t\t\ttitleBox.style.display = \"none\";\r\n\t\t}else{\r\n\t\t\ttitleBox.style.display = \"\";\r\n\t\t}\r\n\t\tmain.innerHTML = content.content;\r\n\r\n\t\tconst buttons = content.buttons;\r\n\t\tif(!buttons.length){\r\n\t\t\tcontrols.style.display = \"none\";\r\n\t\t}else{\r\n\t\t\tcontrols.style.display = \"\";\r\n\t\t}\r\n\t\tlet html = \"\";\r\n\t\tfor (let i = 0; i < buttons.length; i++){\r\n\r\n\t\t\tconst ariaAttr = gantt._waiAria.quickInfoButtonAttrString(gantt.locale.labels[buttons[i]]);\r\n\r\n\t\t\thtml += `