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_quick_info", [], factory); 18 else if(typeof exports === 'object') 19 exports["ext/dhtmlxgantt_quick_info"] = factory(); 20 else 21 root["ext/dhtmlxgantt_quick_info"] = 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/quick_info.js"); 107/******/ }) 108/************************************************************************/ 109/******/ ({ 110 111/***/ "./sources/ext/quick_info.js": 112/*!***********************************!*\ 113 !*** ./sources/ext/quick_info.js ***! 114 \***********************************/ 115/*! no static exports found */ 116/***/ (function(module, exports) { 117 118gantt.config.quickinfo_buttons = ["icon_delete","icon_edit"]; 119gantt.config.quick_info_detached = true; 120gantt.config.show_quick_info = true; 121 122gantt.attachEvent("onTaskClick", function(id){ 123 setTimeout(function() { 124 gantt.showQuickInfo(id); 125 }, 0); 126 127 return true; 128}); 129 130(function(){ 131 var events = ["onEmptyClick", "onViewChange", "onLightbox", "onBeforeTaskDelete", "onBeforeDrag"]; 132 var hiding_function = function(){ 133 gantt._hideQuickInfo(); 134 return true; 135 }; 136 for (var i=0; i<events.length; i++) 137 gantt.attachEvent(events[i], hiding_function); 138})(); 139 140(function () { 141 function clearQuickInfo() { 142 gantt.hideQuickInfo(true); 143 gantt._quick_info_box = null; 144 return true; 145 } 146 gantt.attachEvent("onGanttReady", clearQuickInfo); 147 gantt.attachEvent("onDestroy", clearQuickInfo); 148})(); 149 150gantt.templates.quick_info_title = function(start, end, ev){ return ev.text.substr(0,50); }; 151gantt.templates.quick_info_content = function(start, end, ev){ return ev.details || ev.text; }; 152gantt.templates.quick_info_date = function(start, end, ev){ 153 return gantt.templates.task_time(start, end, ev); 154}; 155gantt.templates.quick_info_class = function(start, end, task){ return ""; }; 156 157 158gantt.showQuickInfo = function(id){ 159 if (( 160 id == this._quick_info_box_id && 161 gantt.utils.dom.isChildOf(this._quick_info_box, document.body) 162 ) || !this.config.show_quick_info) { 163 // not show if the quick info is already displayed for this task, or if it shouldn't be displayed 164 return; 165 } 166 this.hideQuickInfo(true); 167 var offset = 6; // offset TASK <> QI-BOX in 'px' 168 var container = getContainer(); 169 var pos = this._get_event_counter_part(id, offset, container.viewport); 170 171 if (pos){ 172 this._quick_info_box = this._init_quick_info(pos, id); 173 this._quick_info_task = id; 174 this._quick_info_box.className = gantt._prepare_quick_info_classname(id); 175 176 this._fill_quick_data(id); 177 this._show_quick_info(pos, offset); 178 this.callEvent("onQuickInfo", [id]); 179 } 180}; 181gantt._hideQuickInfo = function(){ 182 gantt.hideQuickInfo(); 183}; 184gantt.hideQuickInfo = function(forced){ 185 var qi = this._quick_info_box; 186 this._quick_info_box_id = 0; 187 var taskId = this._quick_info_task; 188 this._quick_info_task = null; 189 190 if (qi && qi.parentNode){ 191 192 if (gantt.config.quick_info_detached) { 193 this.callEvent("onAfterQuickInfo", [taskId]); 194 return qi.parentNode.removeChild(qi); 195 } 196 197 qi.className += " gantt_qi_hidden"; 198 if (qi.style.right == "auto") 199 qi.style.left = "-350px"; 200 else 201 qi.style.right = "-350px"; 202 203 if (forced) { 204 qi.style.left = qi.style.right = ""; 205 qi.parentNode.removeChild(qi); 206 } 207 this.callEvent("onAfterQuickInfo", [taskId]); 208 } 209}; 210gantt.event(window, "keydown", function(e){ 211 if (e.keyCode == 27) 212 gantt.hideQuickInfo(); 213}); 214 215function getContainer() { 216 var container = gantt.$task_data; 217 if (container && container.offsetHeight && container.offsetWidth) { 218 return { 219 parent: container, 220 viewport: gantt.$task 221 }; 222 } 223 container = gantt.$grid_data; 224 if (container && container.offsetHeight && container.offsetWidth) { 225 return { 226 parent: container, 227 viewport: gantt.$grid 228 }; 229 } 230 231 return { 232 parent: gantt.$layout, 233 viewport: gantt.$layout 234 }; 235} 236 237gantt._show_quick_info = function(pos, offset){ 238 var qi = gantt._quick_info_box; 239 if (gantt.config.quick_info_detached) { 240 var container = getContainer(); 241 if (!qi.parentNode || 242 qi.parentNode.nodeName.toLowerCase() == "#document-fragment")//IE8 243 container.parent.appendChild(qi); 244 var width = qi.offsetWidth; 245 var height = qi.offsetHeight; 246 247 var scrolls = gantt.getScrollState(); 248 var viewPort = container.viewport; 249 var screenWidth = viewPort.offsetWidth + scrolls.x - width; 250 251 //pos.dy = (pos.top + height - scrolls.y > (gantt._y - gantt.config.scale_height)*0.96) ? 1 : 0; // uncomment to show QI at the bottom of task always 252 253 qi.style.left = Math.min(Math.max(scrolls.x, pos.left - pos.dx*(width - pos.width)), screenWidth) + "px"; 254 qi.style.top = pos.top - (pos.dy ? (height + pos.height + 2*offset) : 0) + "px"; 255 } else { 256 qi.style.top = 20 + "px"; 257 if (pos.dx == 1){ 258 qi.style.right = "auto"; 259 qi.style.left = "-300px"; 260 261 setTimeout(function(){ 262 qi.style.left = "10px"; 263 },1); 264 } else { 265 qi.style.left = "auto"; 266 qi.style.right = "-300px"; 267 268 setTimeout(function(){ 269 qi.style.right = "10px"; 270 },1); 271 } 272 qi.className += " gantt_qi_"+(pos.dx == 1 ? "left" : "right"); 273 gantt.$root.appendChild(qi); 274 } 275}; 276gantt._prepare_quick_info_classname = function(id){ 277 var task = gantt.getTask(id); 278 279 var css = "gantt_cal_quick_info", 280 template = this.templates.quick_info_class(task.start_date, task.end_date, task); 281 282 if(template){ 283 css += " " + template; 284 } 285 return css; 286}; 287 288gantt._init_quick_info = function(pos, id){ 289 var task = gantt.getTask(id); 290 if(typeof this._quick_info_readonly == "boolean"){ 291 if(this.isReadonly(task) !== this._quick_info_readonly){ 292 gantt.hideQuickInfo(true); 293 this._quick_info_box = null; 294 } 295 } 296 297 this._quick_info_readonly = this.isReadonly(task); 298 299 if (!this._quick_info_box){ 300 var qi = this._quick_info_box = document.createElement("div"); 301 302 this._waiAria.quickInfoAttr(qi); 303 304 305 //title 306 var ariaAttr = gantt._waiAria.quickInfoHeaderAttrString(); 307 var html = "<div class=\"gantt_cal_qi_title\" "+ariaAttr+">" + 308 "<div class=\"gantt_cal_qi_tcontent\"></div><div class=\"gantt_cal_qi_tdate\"></div>" + 309 "</div>" + 310 "<div class=\"gantt_cal_qi_content\"></div>"; 311 312 //buttons 313 html += "<div class=\"gantt_cal_qi_controls\">"; 314 var buttons = gantt.config.quickinfo_buttons; 315 316 var is_editor = {"icon_delete":true,"icon_edit":true}; 317 318 for (var i = 0; i < buttons.length; i++){ 319 if(this._quick_info_readonly && is_editor[buttons[i]]) 320 continue; 321 322 var ariaAttr = gantt._waiAria.quickInfoButtonAttrString(gantt.locale.labels[buttons[i]]); 323 324 html += "<div class=\"gantt_qi_big_icon "+buttons[i]+"\" title=\""+gantt.locale.labels[buttons[i]]+"\" " + ariaAttr +"><div class='gantt_menu_icon " + buttons[i] + "'></div><div>"+gantt.locale.labels[buttons[i]]+"</div></div>"; 325 } 326 html += "</div>"; 327 328 qi.innerHTML = html; 329 330 var buttonClick = function(ev){ 331 ev = ev || event; 332 gantt._qi_button_click(ev.target || ev.srcElement); 333 }; 334 335 gantt.event(qi, "click", buttonClick); 336 gantt.event(qi, "keypress", function(e){ 337 e = e || event; 338 var code = e.which||event.keyCode; 339 if (code == 13 || code == 32){ 340 setTimeout(function(){ 341 gantt._qi_button_click(e.target || e.srcElement); 342 },1); 343 } 344 }); 345 if (gantt.config.quick_info_detached) { 346 var container = getContainer(); 347 gantt.event(container, "scroll", function () { gantt.hideQuickInfo(); }); 348 } 349 } 350 351 return this._quick_info_box; 352}; 353 354gantt._qi_button_click = function(node){ 355 var box = gantt._quick_info_box; 356 if (!node || node == box) return; 357 358 var mask = node.className; 359 if (mask.indexOf("_icon")!=-1){ 360 var id = gantt._quick_info_box_id; 361 gantt.$click.buttons[mask.split(" ")[1].replace("icon_","")](id); 362 } else 363 gantt._qi_button_click(node.parentNode); 364}; 365gantt._get_event_counter_part = function(id, offset, viewport){ 366 var domEv = gantt.getTaskNode(id); 367 if (!domEv) { 368 domEv = gantt.getTaskRowNode(id); 369 if (!domEv) { 370 return null; 371 } 372 } 373 var left = 0; 374 var top = offset + domEv.offsetTop + domEv.offsetHeight; 375 376 var node = domEv; 377 378 if (this.utils.dom.isChildOf(node, viewport)) { 379 while (node && node !== viewport){ 380 left += node.offsetLeft; 381 node = node.offsetParent; 382 } 383 } 384 385 var scroll = this.getScrollState(); 386 387 if(node){ 388 var dx = (left + domEv.offsetWidth/2) - scroll.x > (gantt.$container.offsetWidth/2) ? 1 : 0; 389 var dy = (top + domEv.offsetHeight/2) - scroll.y > (gantt.$container.offsetHeight/2) ? 1 : 0; 390 391 return { left:left, top:top, dx:dx, dy:dy, 392 width:domEv.offsetWidth, height:domEv.offsetHeight }; 393 } 394 return null; 395}; 396 397gantt._fill_quick_data = function(id){ 398 var ev = gantt.getTask(id); 399 var qi = gantt._quick_info_box; 400 401 gantt._quick_info_box_id = id; 402 403//title content 404 405 var header = { 406 content: gantt.templates.quick_info_title(ev.start_date, ev.end_date, ev), 407 date: gantt.templates.quick_info_date(ev.start_date, ev.end_date, ev) 408 }; 409 var titleContent = qi.firstChild.firstChild; 410 titleContent.innerHTML = header.content; 411 var titleDate = titleContent.nextSibling; 412 titleDate.innerHTML = header.date; 413 414 415 gantt._waiAria.quickInfoHeader(qi, [header.content, header.date].join(" ")); 416 417//main content 418 var main = qi.firstChild.nextSibling; 419 main.innerHTML = gantt.templates.quick_info_content(ev.start_date, ev.end_date, ev); 420}; 421 422 423/***/ }) 424 425/******/ }); 426});