1/* 2@license 3 4dhtmlxGantt v.6.3.5 Standard 5 6This version of dhtmlxGantt is distributed under GPL 2.0 license and can be legally used in GPL projects. 7 8To use dhtmlxGantt in non-GPL projects (and get Pro version of the product), please obtain Commercial/Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxGantt/#licensing or contact us at sales@dhtmlx.com 9 10(c) XB Software Ltd. 11 12*/ 13(function webpackUniversalModuleDefinition(root, factory) { 14 if(typeof exports === 'object' && typeof module === 'object') 15 module.exports = factory(); 16 else if(typeof define === 'function' && define.amd) 17 define("ext/dhtmlxgantt_drag_timeline", [], factory); 18 else if(typeof exports === 'object') 19 exports["ext/dhtmlxgantt_drag_timeline"] = factory(); 20 else 21 root["ext/dhtmlxgantt_drag_timeline"] = factory(); 22})(window, function() { 23return /******/ (function(modules) { // webpackBootstrap 24/******/ // The module cache 25/******/ var installedModules = {}; 26/******/ 27/******/ // The require function 28/******/ function __webpack_require__(moduleId) { 29/******/ 30/******/ // Check if module is in cache 31/******/ if(installedModules[moduleId]) { 32/******/ return installedModules[moduleId].exports; 33/******/ } 34/******/ // Create a new module (and put it into the cache) 35/******/ var module = installedModules[moduleId] = { 36/******/ i: moduleId, 37/******/ l: false, 38/******/ exports: {} 39/******/ }; 40/******/ 41/******/ // Execute the module function 42/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 43/******/ 44/******/ // Flag the module as loaded 45/******/ module.l = true; 46/******/ 47/******/ // Return the exports of the module 48/******/ return module.exports; 49/******/ } 50/******/ 51/******/ 52/******/ // expose the modules object (__webpack_modules__) 53/******/ __webpack_require__.m = modules; 54/******/ 55/******/ // expose the module cache 56/******/ __webpack_require__.c = installedModules; 57/******/ 58/******/ // define getter function for harmony exports 59/******/ __webpack_require__.d = function(exports, name, getter) { 60/******/ if(!__webpack_require__.o(exports, name)) { 61/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 62/******/ } 63/******/ }; 64/******/ 65/******/ // define __esModule on exports 66/******/ __webpack_require__.r = function(exports) { 67/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 68/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 69/******/ } 70/******/ Object.defineProperty(exports, '__esModule', { value: true }); 71/******/ }; 72/******/ 73/******/ // create a fake namespace object 74/******/ // mode & 1: value is a module id, require it 75/******/ // mode & 2: merge all properties of value into the ns 76/******/ // mode & 4: return value when already ns object 77/******/ // mode & 8|1: behave like require 78/******/ __webpack_require__.t = function(value, mode) { 79/******/ if(mode & 1) value = __webpack_require__(value); 80/******/ if(mode & 8) return value; 81/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 82/******/ var ns = Object.create(null); 83/******/ __webpack_require__.r(ns); 84/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 85/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 86/******/ return ns; 87/******/ }; 88/******/ 89/******/ // getDefaultExport function for compatibility with non-harmony modules 90/******/ __webpack_require__.n = function(module) { 91/******/ var getter = module && module.__esModule ? 92/******/ function getDefault() { return module['default']; } : 93/******/ function getModuleExports() { return module; }; 94/******/ __webpack_require__.d(getter, 'a', getter); 95/******/ return getter; 96/******/ }; 97/******/ 98/******/ // Object.prototype.hasOwnProperty.call 99/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 100/******/ 101/******/ // __webpack_public_path__ 102/******/ __webpack_require__.p = "/codebase/sources/"; 103/******/ 104/******/ 105/******/ // Load entry module and return exports 106/******/ return __webpack_require__(__webpack_require__.s = "./sources/ext/drag_timeline/index.ts"); 107/******/ }) 108/************************************************************************/ 109/******/ ({ 110 111/***/ "./sources/ext/drag_timeline/eventsManager.ts": 112/*!****************************************************!*\ 113 !*** ./sources/ext/drag_timeline/eventsManager.ts ***! 114 \****************************************************/ 115/*! no static exports found */ 116/***/ (function(module, exports, __webpack_require__) { 117 118"use strict"; 119 120Object.defineProperty(exports, "__esModule", { value: true }); 121var helpers_1 = __webpack_require__(/*! ../../utils/helpers */ "./sources/utils/helpers.js"); 122var EventsManager = /** @class */ (function () { 123 function EventsManager() { 124 var _this = this; 125 this._mouseDown = false; 126 this._calculateDirectionVector = function () { 127 var traceSteps = 10; 128 if (_this._trace.length >= traceSteps) { 129 var dots = _this._trace.slice(_this._trace.length - traceSteps); 130 var vectors = []; 131 for (var i = 1; i < dots.length; i++) { 132 vectors.push({ 133 x: dots[i].x - dots[i - 1].x, 134 y: dots[i].y - dots[i - 1].y 135 }); 136 } 137 var resultVector_1 = { x: 0, y: 0 }; 138 vectors.forEach(function (vector) { 139 resultVector_1.x += vector.x; 140 resultVector_1.y += vector.y; 141 }); 142 var magnitude = Math.sqrt(resultVector_1.x * resultVector_1.x + resultVector_1.y * resultVector_1.y); 143 var angleDegrees = Math.atan2(Math.abs(resultVector_1.y), Math.abs(resultVector_1.x)) * 180 / Math.PI; 144 return { 145 magnitude: magnitude, 146 angleDegrees: angleDegrees 147 }; 148 } 149 return null; 150 }; 151 this._applyDndReadyStyles = function () { 152 _this._timeline.$task.classList.add("gantt_timeline_move_available"); 153 }; 154 this._clearDndReadyStyles = function () { 155 _this._timeline.$task.classList.remove("gantt_timeline_move_available"); 156 }; 157 this._getScrollPosition = function (timeline) { 158 return { 159 x: gantt.$ui.getView(timeline.$config.scrollX).getScrollState().position, 160 y: gantt.$ui.getView(timeline.$config.scrollY).getScrollState().position 161 }; 162 }; 163 this._countNewScrollPosition = function (coords) { 164 var vector = _this._calculateDirectionVector(); 165 var shiftX = _this._startPoint.x - coords.x; 166 var shiftY = _this._startPoint.y - coords.y; 167 if (vector) { 168 if (vector.angleDegrees < 15) { 169 shiftY = 0; 170 } 171 else if (vector.angleDegrees > 75) { 172 shiftX = 0; 173 } 174 } 175 var result = { 176 x: _this._scrollState.x + shiftX, 177 y: _this._scrollState.y + shiftY 178 }; 179 return result; 180 }; 181 this._setScrollPosition = function (timeline, coords) { 182 helpers_1.requestAnimationFrame(function () { 183 gantt.$ui.getView(timeline.$config.scrollX).scroll(coords.x); 184 gantt.$ui.getView(timeline.$config.scrollY).scroll(coords.y); 185 }); 186 }; 187 this._stopDrag = function (event) { 188 _this._trace = []; 189 gantt.$root.classList.remove("gantt_noselect"); 190 if (_this._originalReadonly !== undefined) { 191 gantt.config.readonly = _this._originalReadonly; 192 } 193 if (_this._originAutoscroll !== undefined) { 194 gantt.config.autoscroll = _this._originAutoscroll; 195 } 196 if (gantt.config.drag_timeline) { 197 var useKey = gantt.config.drag_timeline.useKey; 198 if (useKey && event[useKey] !== true) { 199 return; 200 } 201 } 202 _this._mouseDown = false; 203 }; 204 this._startDrag = function (event) { 205 _this._originAutoscroll = gantt.config.autoscroll; 206 gantt.config.autoscroll = false; 207 gantt.$root.classList.add("gantt_noselect"); 208 _this._originalReadonly = gantt.config.readonly; 209 gantt.config.readonly = true; 210 _this._trace = []; 211 _this._mouseDown = true; 212 var _a = _this._getScrollPosition(_this._timeline), x = _a.x, y = _a.y; 213 _this._scrollState = { x: x, y: y }; 214 _this._startPoint = { x: event.clientX, y: event.clientY }; 215 _this._trace.push(_this._startPoint); 216 }; 217 this._domEvents = gantt._createDomEventScope(); 218 this._trace = []; 219 } 220 EventsManager.create = function () { 221 return new EventsManager(); 222 }; 223 EventsManager.prototype.destructor = function () { 224 this._domEvents.detachAll(); 225 }; 226 EventsManager.prototype.attach = function (timeline) { 227 var _this = this; 228 this._timeline = timeline; 229 this._domEvents.attach(timeline.$task, "mousedown", function (event) { 230 if (!gantt.config.drag_timeline) { 231 return; 232 } 233 var _a = gantt.config.drag_timeline, useKey = _a.useKey, ignore = _a.ignore, enabled = _a.enabled; 234 if (enabled === false) { 235 return; 236 } 237 var filterTargets = ".gantt_task_line, .gantt_task_link"; 238 if (ignore !== undefined) { 239 if (ignore instanceof Array) { 240 filterTargets = ignore.join(", "); 241 } 242 else { 243 filterTargets = ignore; 244 } 245 } 246 if (filterTargets) { 247 if (gantt.utils.dom.closest(event.target, filterTargets)) { 248 return; 249 } 250 } 251 if (useKey && event[useKey] !== true) { 252 return; 253 } 254 _this._startDrag(event); 255 }); 256 this._domEvents.attach(document, "keydown", function (event) { 257 if (!gantt.config.drag_timeline) { 258 return; 259 } 260 var useKey = gantt.config.drag_timeline.useKey; 261 if (useKey && event[useKey] === true) { 262 _this._applyDndReadyStyles(); 263 } 264 }); 265 this._domEvents.attach(document, "keyup", function (event) { 266 if (!gantt.config.drag_timeline) { 267 return; 268 } 269 var useKey = gantt.config.drag_timeline.useKey; 270 if (useKey && event[useKey] === false) { 271 _this._clearDndReadyStyles(); 272 _this._stopDrag(event); 273 } 274 }); 275 this._domEvents.attach(document, "mouseup", function (event) { 276 _this._stopDrag(event); 277 }); 278 this._domEvents.attach(gantt.$root, "mouseup", function (event) { 279 _this._stopDrag(event); 280 }); 281 this._domEvents.attach(document, "mouseleave", function (event) { 282 _this._stopDrag(event); 283 }); 284 this._domEvents.attach(gantt.$root, "mouseleave", function (event) { 285 _this._stopDrag(event); 286 }); 287 this._domEvents.attach(gantt.$root, "mousemove", function (event) { 288 if (!gantt.config.drag_timeline) { 289 return; 290 } 291 var useKey = gantt.config.drag_timeline.useKey; 292 if (useKey && event[useKey] !== true) { 293 return; 294 } 295 if (_this._mouseDown === true) { 296 _this._trace.push({ x: event.clientX, y: event.clientY }); 297 var scrollPosition = _this._countNewScrollPosition({ x: event.clientX, y: event.clientY }); 298 _this._setScrollPosition(timeline, scrollPosition); 299 _this._scrollState = scrollPosition; 300 _this._startPoint = { x: event.clientX, y: event.clientY }; 301 } 302 }); 303 }; 304 return EventsManager; 305}()); 306exports.EventsManager = EventsManager; 307 308 309/***/ }), 310 311/***/ "./sources/ext/drag_timeline/index.ts": 312/*!********************************************!*\ 313 !*** ./sources/ext/drag_timeline/index.ts ***! 314 \********************************************/ 315/*! no static exports found */ 316/***/ (function(module, exports, __webpack_require__) { 317 318"use strict"; 319 320Object.defineProperty(exports, "__esModule", { value: true }); 321var eventsManager_1 = __webpack_require__(/*! ./eventsManager */ "./sources/ext/drag_timeline/eventsManager.ts"); 322if (!gantt.ext) { 323 gantt.ext = {}; 324} 325gantt.ext.dragTimeline = { 326 create: function () { return eventsManager_1.EventsManager.create(); } 327}; 328gantt.config.drag_timeline = { 329 enabled: true 330}; 331 332 333/***/ }), 334 335/***/ "./sources/utils/helpers.js": 336/*!**********************************!*\ 337 !*** ./sources/utils/helpers.js ***! 338 \**********************************/ 339/*! no static exports found */ 340/***/ (function(module, exports) { 341 342var units = { 343 "second": 1, 344 "minute": 60, 345 "hour": 60 * 60, 346 "day": 60 * 60 * 24, 347 "week": 60 * 60 * 24 * 7, 348 "month": 60 * 60 * 24 * 30, 349 "quarter": 60 * 60 * 24 * 30 * 3, 350 "year": 60 * 60 * 24 * 365 351}; 352function getSecondsInUnit(unit){ 353 return units[unit] || units.hour; 354} 355 356function forEach(arr, callback) { 357 if (arr.forEach) { 358 arr.forEach(callback); 359 } else { 360 var workArray = arr.slice(); 361 for (var i = 0; i < workArray.length; i++) { 362 callback(workArray[i], i); 363 } 364 } 365} 366 367function arrayMap(arr, callback) { 368 if (arr.map) { 369 return arr.map(callback); 370 } else { 371 var workArray = arr.slice(); 372 var resArray = []; 373 374 for (var i = 0; i < workArray.length; i++) { 375 resArray.push(callback(workArray[i], i)); 376 } 377 return resArray; 378 } 379} 380 381 382function arrayFind(arr, callback) { 383 if (arr.find) { 384 return arr.find(callback); 385 } else { 386 for (var i = 0; i < arr.length; i++) { 387 if (callback(arr[i], i)) { 388 return arr[i]; 389 } 390 } 391 } 392} 393 394// iframe-safe array type check instead of using instanceof 395function isArray(obj){ 396 if(Array.isArray){ 397 return Array.isArray(obj); 398 }else{ 399 // close enough 400 return (obj && obj.length !== undefined && obj.pop && obj.push); 401 } 402} 403 404// non-primitive string object, e.g. new String("abc") 405function isStringObject(obj){ 406 return obj && typeof obj === "object" 407 && Function.prototype.toString.call(obj.constructor) === "function String() { [native code] }"; 408} 409 410// non-primitive number object, e.g. new Number(5) 411function isNumberObject(obj){ 412 return obj && typeof obj === "object" 413 && Function.prototype.toString.call(obj.constructor) === "function Number() { [native code] }"; 414} 415 416// non-primitive number object, e.g. new Boolean(true) 417function isBooleanObject(obj){ 418 return obj && typeof obj === "object" 419 && Function.prototype.toString.call(obj.constructor) === "function Boolean() { [native code] }"; 420} 421 422function isDate(obj) { 423 if (obj && typeof obj === "object") { 424 return !!(obj.getFullYear && obj.getMonth && obj.getDate); 425 } else { 426 return false; 427 } 428} 429 430function isValidDate(obj){ 431 return isDate(obj) && !isNaN(obj.getTime()); 432} 433 434function arrayFilter(arr, callback) { 435 var result = []; 436 437 if (arr.filter) { 438 return arr.filter(callback); 439 } else { 440 for (var i = 0; i < arr.length; i++) { 441 if (callback(arr[i], i)) { 442 result[result.length] = arr[i]; 443 } 444 } 445 return result; 446 } 447} 448 449function hashToArray(hash) { 450 var result = []; 451 452 for (var key in hash) { 453 if (hash.hasOwnProperty(key)) { 454 result.push(hash[key]); 455 } 456 } 457 458 return result; 459} 460 461function arraySome(arr, callback) { 462 if (arr.length === 0) return false; 463 464 for (var i = 0; i < arr.length; i++) { 465 if (callback(arr[i], i, arr)) { 466 return true; 467 } 468 } 469 return false; 470} 471 472function arrayDifference(arr, callback) { 473 return arrayFilter(arr, function(item, i) { 474 return !callback(item, i); 475 }); 476} 477 478function throttle (callback, timeout) { 479 var wait = false; 480 481 return function () { 482 if (!wait) { 483 callback.apply(null, arguments); 484 wait = true; 485 setTimeout(function () { 486 wait = false; 487 }, timeout); 488 } 489 }; 490} 491 492function delay (callback, timeout){ 493 var timer; 494 495 var result = function() { 496 result.$cancelTimeout(); 497 callback.$pending = true; 498 var args = Array.prototype.slice.call(arguments); 499 timer = setTimeout(function(){ 500 callback.apply(this, args); 501 result.$pending = false; 502 }, timeout); 503 }; 504 505 result.$pending = false; 506 result.$cancelTimeout = function(){ 507 clearTimeout(timer); 508 callback.$pending = false; 509 }; 510 result.$execute = function(){ 511 callback(); 512 callback.$cancelTimeout(); 513 }; 514 515 return result; 516} 517 518function sortArrayOfHash(arr, field, desc) { 519 var compare = function(a, b) { 520 return a < b; 521 }; 522 523 arr.sort(function(a, b) { 524 if (a[field] === b[field]) return 0; 525 526 return desc ? compare(a[field], b[field]) : compare(b[field], a[field]); 527 }); 528} 529 530function objectKeys(obj) { 531 if (Object.keys) { 532 return Object.keys(obj); 533 } 534 var result = []; 535 var key; 536 for (key in obj) { 537 if (Object.prototype.hasOwnProperty.call(obj, key)) { 538 result.push(key); 539 } 540 } 541 return result; 542} 543 544function requestAnimationFrame(callback) { 545 var w = window; 546 var foundRequestAnimationFrame = w.requestAnimationFrame 547 || w.webkitRequestAnimationFrame 548 || w.msRequestAnimationFrame 549 || w.mozRequestAnimationFrame 550 || w.oRequestAnimationFrame 551 || function(cb) { setTimeout(cb, 1000/60); }; 552 return foundRequestAnimationFrame(callback); 553} 554 555function isEventable(obj) { 556 return obj.attachEvent && obj.detachEvent; 557} 558 559module.exports = { 560 getSecondsInUnit: getSecondsInUnit, 561 forEach: forEach, 562 arrayMap: arrayMap, 563 arrayFind: arrayFind, 564 arrayFilter: arrayFilter, 565 arrayDifference: arrayDifference, 566 arraySome: arraySome, 567 hashToArray: hashToArray, 568 sortArrayOfHash: sortArrayOfHash, 569 throttle: throttle, 570 isArray: isArray, 571 isDate: isDate, 572 isValidDate: isValidDate, 573 isStringObject: isStringObject, 574 isNumberObject: isNumberObject, 575 isBooleanObject: isBooleanObject, 576 delay: delay, 577 objectKeys: objectKeys, 578 requestAnimationFrame: requestAnimationFrame, 579 isEventable: isEventable 580}; 581 582/***/ }) 583 584/******/ }); 585});