1(function webpackUniversalModuleDefinition(root, factory) { 2 if(typeof exports === 'object' && typeof module === 'object') 3 module.exports = factory(); 4 else if(typeof define === 'function' && define.amd) 5 define([], factory); 6 else if(typeof exports === 'object') 7 exports["Datepickk"] = factory(); 8 else 9 root["Datepickk"] = factory(); 10})(this, function() { 11return /******/ (function(modules) { // webpackBootstrap 12/******/ // The module cache 13/******/ var installedModules = {}; 14/******/ 15/******/ // The require function 16/******/ function __webpack_require__(moduleId) { 17/******/ 18/******/ // Check if module is in cache 19/******/ if(installedModules[moduleId]) { 20/******/ return installedModules[moduleId].exports; 21/******/ } 22/******/ // Create a new module (and put it into the cache) 23/******/ var module = installedModules[moduleId] = { 24/******/ i: moduleId, 25/******/ l: false, 26/******/ exports: {} 27/******/ }; 28/******/ 29/******/ // Execute the module function 30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31/******/ 32/******/ // Flag the module as loaded 33/******/ module.l = true; 34/******/ 35/******/ // Return the exports of the module 36/******/ return module.exports; 37/******/ } 38/******/ 39/******/ 40/******/ // expose the modules object (__webpack_modules__) 41/******/ __webpack_require__.m = modules; 42/******/ 43/******/ // expose the module cache 44/******/ __webpack_require__.c = installedModules; 45/******/ 46/******/ // define getter function for harmony exports 47/******/ __webpack_require__.d = function(exports, name, getter) { 48/******/ if(!__webpack_require__.o(exports, name)) { 49/******/ Object.defineProperty(exports, name, { 50/******/ configurable: false, 51/******/ enumerable: true, 52/******/ get: getter 53/******/ }); 54/******/ } 55/******/ }; 56/******/ 57/******/ // getDefaultExport function for compatibility with non-harmony modules 58/******/ __webpack_require__.n = function(module) { 59/******/ var getter = module && module.__esModule ? 60/******/ function getDefault() { return module['default']; } : 61/******/ function getModuleExports() { return module; }; 62/******/ __webpack_require__.d(getter, 'a', getter); 63/******/ return getter; 64/******/ }; 65/******/ 66/******/ // Object.prototype.hasOwnProperty.call 67/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 68/******/ 69/******/ // __webpack_public_path__ 70/******/ __webpack_require__.p = ""; 71/******/ 72/******/ // Load entry module and return exports 73/******/ return __webpack_require__(__webpack_require__.s = 0); 74/******/ }) 75/************************************************************************/ 76/******/ ([ 77/* 0 */ 78/***/ (function(module, exports, __webpack_require__) { 79 80"use strict"; 81 82 83Object.defineProperty(exports, "__esModule", { 84 value: true 85}); 86 87__webpack_require__(1); 88 89function Datepickk(args) { 90 Datepickk.numInstances = (Datepickk.numInstances || 0) + 1; 91 var that = this; 92 var eventName = 'click'; 93 var selectedDates = []; 94 95 var currentYear = new Date().getFullYear(); 96 var currentMonth = new Date().getMonth() + 1; 97 98 var languages = { 99 no: { 100 monthNames: ['Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember'], 101 dayNames: ['sø', 'ma', 'ti', 'on', 'to', 'fr', 'lø'], 102 weekStart: 1 103 }, 104 se: { 105 monthNames: ['januari', 'februari', 'mars', 'april', 'maj', 'juni', 'juli', 'augusti', 'september', 'oktober', 'november', 'december'], 106 dayNames: ['sö', 'mÃ¥', 'ti', 'on', 'to', 'fr', 'lö'], 107 weekStart: 1 108 }, 109 ru: { 110 monthNames: ['ЯнваÑÑ', 'ФевÑалÑ', 'ÐаÑÑ', 'ÐпÑелÑ', 'Ðай', 'ÐÑнÑ', 'ÐÑлÑ', 'ÐвгÑÑÑ', 'СенÑÑбÑÑ', 'ÐкÑÑбÑÑ', 'ÐоÑбÑÑ', 'ÐекабÑÑ'], 111 dayNames: ['вÑ', 'пн', 'вÑ', 'ÑÑ', 'ÑÑ', 'пÑ', 'Ñб'], 112 weekStart: 1 113 }, 114 en: { 115 year: 'Year', 116 month: 'Month', 117 monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 118 dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 119 weekStart: 0 120 }, 121 de: { 122 monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], 123 dayNames: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'], 124 weekStart: 1 125 }, 126 ko: { 127 year: 'ë ë', 128 month: 'ì', 129 monthNames: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'], 130 dayNames: ['ì¼', 'ì', 'í', 'ì', '목', 'ê¸', 'í '], 131 weekStart: 0 132 }, 133 }; 134 135 /*Language aliases*/ 136 languages.nb = languages.no; 137 languages.nn = languages.no; 138 139 var range = false;
140 var maxSelections = null; 141 var container = document.body; 142 var opened = false; 143 var months = 1; 144 var closeOnSelect = false; 145 var button = null; 146 var title = null; 147 var onNavigation = null; 148 var onClose = null; 149 var onConfirm = null; 150 var closeOnClick = true; 151 var inline = false; 152 var lang = 'ko'; 153 var onSelect = null; 154 var disabledDates = []; 155 var disabledDays = []; 156 var highlight = []; 157 var daynames = true; 158 var today = true; 159 var startDate = null; 160 var minDate = null; 161 var maxDate = null; 162 var weekStart = null; 163 var locked = false; 164 var exp = false; 165 166 var clickCheck = 0; 167 var firstCheck = false; 168 var startCheckPoint = true; 169 var startCheck = true; 170 var endCheckPoint = true; 171 var endCheck = true; 172 173 function generateDaynames() { 174 that.el.days.innerHTML = ''; 175 var ws = (weekStart !== null) ? weekStart : languages[lang].weekStart; 176 if(daynames){ 177 for(var x = 0;x<months && x<3;x++){ 178 var weekEl = document.createElement('div'); 179 weekEl.setAttribute('class','d-week'); 180 for(var i = 0; i < 7;i++){ 181 var dayNameIndex = (i + ws > languages[lang].dayNames.length - 1) ? i + ws - languages[lang].dayNames.length : i + ws; 182 183 var dayEl = document.createElement('div'); 184 var dayTextEl = document.createElement('p'); 185 dayTextEl.innerHTML = languages[lang].dayNames[dayNameIndex]; 186 187 dayEl.appendChild(dayTextEl); 188 weekEl.appendChild(dayEl); 189 } 190 191 that.el.days.appendChild(weekEl); 192 } 193 } 194 } 195 196 function generateYears() { 197 [].slice.call(that.el.yearPicker.childNodes).forEach(function (node, index) { 198 node.innerHTML = "'" + (currentYear + parseInt(node.getAttribute('data-year'))).toString().substring(2, 4); 199 }); 200 201 var minYear = new Date().getFullYear(); 202 var maxYear = new Date().getFullYear(); 203 var minMonth = new Date().getMonth() + 1; 204 var maxMonth = new Date().getMonth() + 1; 205 206 if(that.minDate && that.maxDate) { 207 minYear = new Date(that.minDate).getFullYear(); 208 maxYear = new Date(that.maxDate).getFullYear(); 209 minMonth = new Date(that.minDate).getMonth() + 1; 210 maxMonth = new Date(that.maxDate).getMonth() + 1; 211 } 212 213 [].slice.call(that.el.newYearPicker.childNodes).forEach(function (node, index) { 214 var y = (CURRENT_YEAR + parseInt(node.getAttribute('data-year'))).toString(); 215 if(that.minDate && that.maxDate) { 216 if(parseInt(y) < minYear || parseInt(y) > maxYear) { 217 $(node).addClass('hide'); 218 } 219 } 220 node.innerHTML = y; 221 node.setAttribute('data-fullYear', y); 222 }); 223 224 [].slice.call(that.el.newMonthPicker.childNodes).forEach(function (node, index) { 225 if(that.minDate && that.maxDate) { 226 var cMonth = Number($(node).attr('data-month')); 227 if(minYear == maxYear) { 228 if(cMonth < minMonth || cMonth > maxMonth) { 229 $(node).addClass('hide'); 230 } 231 } else { 232 if(currentYear == minYear) { 233 if(cMonth < minMonth) { 234 $(node).addClass('hide'); 235 } else { 236 $(node).removeClass('hide'); 237 } 238 } else if(currentYear == maxYear) { 239 if (cMonth > maxMonth) { 240 $(node).addClass('hide'); 241 } else { 242 $(node).removeClass('hide'); 243 } 244 } else { 245 $(node).removeClass('hide'); 246 } 247 } 248 } 249 }); 250 } 251 252 function generateInputs(exp, range) { 253 if(typeof exp == "undefined") exp = false; 254 if(typeof range == "undefined") range = false; 255 that.el.tables.innerHTML = ''; 256 var blocklang = $('.term-setting').attr('data-blocklang'); 257 if(blocklang === undefined || !blocklang) blocklang = 'ko'; 258 for (var x = 0; x < months; x++) { 259 var container = document.createElement('div'); 260 container.setAttribute('class', 'd-table'); 261 for (var i = 0; i < 42; i++) { 262 var input = document.createElement('input'); 263 input.type = 'checkbox'; 264 input.name = 'checkbox[]'; 265 input.classList.add('term-calendar'); 266 input.id = Datepickk.numInstances + '-' + x + '-d-day-' + i; 267 input.classList.add('date-pick-input'); 268 var label = document.createElement('label'); 269 label.setAttribute("for", Datepickk.numInstances + '-' + x + '-d-day-' + i); 270 271 var text = document.createElement('text'); 272 273 container.appendChild(input); 274 container.appendChild(label); 275 276 label.appendChild(text); 277 278 input.addEventListener(eventName, function (event) { 279 if(range) { 280 $('.term-calendar-box .d-tables input').removeClass('inRange'); 281 if (clickCheck == 0) { 282 checkBoxAllFalse(); 283 firstCheck = true; 284 this.checked = true; 285 this.classList.add('etc-active'); 286 document.querySelector('#etc-start-date-txt').value = this.dataset.term_date; 287 clickCheck++; 288 289 var checkStartDate = this.dataset.term_date.split('.'); 290 var checkStart = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
291 $('.term-setting .start-date').text(''); 292 $('.term-setting .end-date').text(''); 293 $('.term-setting').removeClass('hide'); 294 // console.log('blocklang', blocklang); 295 if(blocklang == 'ko') { 296 $('.term-setting .start-date').text(checkStartDate[0]+'ë '+checkStartDate[1]+'ì '+checkStartDate[2]+' ì¼'); 297 } else { 298 $('.term-setting .start-date').text(checkStartDate[1]+'/'+checkStartDate[2]+'/'+checkStartDate[0]); 299 } 300 return false; 301 } else if (clickCheck == 1) { 302 clickCheck = -1; 303 this.checked = true; 304 var termCalendar = document.querySelectorAll('.term-calendar'); 305 for (var i=0;i<termCalendar.length;i++) { 306 var ele = termCalendar[i]; 307 308 if (ele.classList.contains('etc-active') === true) { 309 ele.classList.add('etc-start-active'); 310 ele.classList.add('etc-select-active'); 311 ele.classList.remove('etc-active'); 312 } 313 314 if (ele.classList.contains('etc-end-active') === true) { 315 ele.classList.remove('etc-select-active'); 316 ele.classList.remove('etc-end-active'); 317 } 318 } 319 320 this.classList.add('etc-select-active'); 321 this.classList.add('etc-end-active'); 322 323 document.querySelector('#etc-end-date-txt').value = this.dataset.term_date; 324 325 var startDate = document.querySelector('#etc-start-date-txt').value; 326 var endDate = document.querySelector('#etc-end-date-txt').value; 327 var checkStartDate = startDate.split('.'); 328 var checkEndDate = endDate.split('.'); 329 var checkStart = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]); 330 var checkEnd = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]); 331 var temp = ''; 332 if (checkStart.getTime() > checkEnd.getTime()) { 333 temp = document.querySelector('#etc-start-date-txt').value; 334 document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-end-date-txt').value; 335 document.querySelector('#etc-end-date-txt').value = temp; 336 337 var termCalendar = document.querySelectorAll('.term-calendar') 338 for (var i=0;i<termCalendar.length;i++) { 339 var ele = termCalendar[i]; 340 if (ele.classList.contains('etc-start-active') === true) { 341 ele.classList.add('etc-end-active'); 342 ele.classList.remove('etc-start-active'); 343 } else if (ele.classList.contains('etc-end-active') === true) { 344 ele.classList.add('etc-start-active'); 345 ele.classList.remove('etc-end-active'); 346 } 347 } 348 349 startDate = document.querySelector('#etc-start-date-txt').value; 350 endDate = document.querySelector('#etc-end-date-txt').value; 351 checkStartDate = startDate.split('.'); 352 checkEndDate = endDate.split('.'); 353 } 354 355 if(startDate && endDate) { 356 var startDateObj = new Date(startDate.replace(/\./g,'/')); 357 var endDateObj = new Date(endDate.replace(/\./g,'/')); 358 359 $('.term-calendar-box .d-tables input').each(function (i, v) { 360 var dateObj = new Date($(v).attr('data-term_date').replace(/\./g,'/')); 361 // console.log(startDateObj, endDateObj, dateObj) 362 if(dateObj > startDateObj && dateObj < endDateObj && !$(v).is(':disabled')) $(v).addClass('inRange'); 363 }); 364 } 365 366 $('.term-setting').removeClass('hide'); 367 if(blocklang == 'ko') { 368 $('.term-setting .start-date').text(checkStartDate[0]+'ë '+checkStartDate[1]+'ì '+checkStartDate[2]+' ì¼'); 369 $('.term-setting .end-date').text(checkEndDate[0]+'ë '+checkEndDate[1]+'ì '+checkEndDate[2]+' ì¼'); 370 } else { 371 $('.term-setting .start-date').text(checkStartDate[1]+'/'+checkStartDate[2]+'/'+checkStartDate[0]); 372 $('.term-setting .end-date').text(checkEndDate[1]+'/'+checkEndDate[2]+'/'+checkEndDate[0]); 373 } 374 } else clickCheck = 0; 375 clickCheck++; 376 } else { 377 if(exp == false) { 378 dataCheck(); 379 console.log(this) 380 this.classList.add('active'); 381 this.checked = true; 382 var selectedDate = this.dataset.term_date; 383 if(document.querySelector('#select-date-ymd')) { 384 document.querySelector('#select-date-ymd').value = selectedDate; 385 var isLang = document.querySelector('#clang'); 386 if(isLang) { 387 getDateTimeStr(blocklang, 'calendar', isLang.value); 388 } else { 389 getDateTimeStr(blocklang, 'calendar'); 390 } 391 } 392 } else { 393 this.classList.toggle('active'); 394 } 395 396 var date = this.dataset.date; 397 var startCheck = this.parentNode.parentNode.parentNode.parentNode.parentNode.classList.contains('etc-start-date-picker'), 398 endCheck = this.parentNode.parentNode.parentNode.parentNode.parentNode.classList.contains('etc-end-date-picker'); 399 400 // document.querySelector('#etc-start-date-txt').classList.remove('active'); 401 // document.querySelector('#etc-end-date-txt').classList.remove('active'); 402 403 if (startCheck) { 404 document.querySelector('#etc-start-date-txt').value = date; 405 document.querySelector('#etc-start-date-picker').style.display = 'none'; 406 document.querySelector('#etc-end-date-picker').style.display = 'block'; 407 // if(typeof exceptPicker != "undefined") 408 // exceptPicker.generateDates(true); 409 checkCalendarClick = false;
410 411 setSelectedDates(date,'start'); 412 var i = 0; 413 var width = 0; 414 $('#etc-end-date-picker .Datepickk .d-table input + label').each(function () { 415 if (i == 0) width = $(this).width(); 416 $(this).css('height', width+'px'); 417 i++; 418 }); 419 var i = 0; 420 var width = 0; 421 $('#etc-start-date-picker .Datepickk .d-table input + label').each(function () { 422 if (i == 0) width = $(this).width(); 423 $(this).css('height', width+'px'); 424 i++; 425 }); 426 } else if(endCheck) { 427 document.querySelector('#etc-end-date-txt').value = date; 428 document.querySelector('#etc-end-date-picker').style.display = 'none'; 429 // if(typeof exceptPicker != "undefined") 430 // exceptPicker.generateDates(true); 431 checkCalendarClick = true; 432 setSelectedDates(date,'end'); 433 } else { 434 if(this.nextElementSibling.classList == 'exp') { 435 getSelectedDates(date); 436 checkCalendarClick = false; 437 } else { 438 return false; 439 } 440 } 441 442 var startDate = $('#etc-start-date-txt').val(); 443 var endDate = $('#etc-end-date-txt').val(); 444 445 var checkStartDate = startDate.split('.'); 446 var checkEndDate = endDate.split('.'); 447 var checkStart = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]); 448 var checkEnd = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]); 449 if (checkStart.getTime() > checkEnd.getTime()) { 450 $('#etc-end-date-txt').val(startDate); 451 if(typeof exceptPicker != "undefined") 452 exceptPicker.generateDates(true); 453 setSelectedDates(startDate,'end'); 454 //return false; 455 } 456 457 458 } 459 }); 460 } 461 462 that.el.tables.appendChild(container); 463 } 464 465 that.el.tables.addEventListener('mouseover', highlightLegend); 466 that.el.tables.addEventListener('mouseout', highlightLegend); 467 468 function highlightLegend(e) { 469 if (e.target.nodeName !== 'LABEL') return; 470 471 var legendIds = e.target.getAttribute('data-legend-id') ? e.target.getAttribute('data-legend-id').split(' ') : []; 472 if (!legendIds.length) return; 473 474 legendIds.forEach(function (legendId) { 475 var element = that.el.legend.querySelector('[data-legend-id="' + legendId + '"]'); 476 if (e.type == 'mouseover' && element) { 477 var color = element.getAttribute('data-color') ? hexToRgb(element.getAttribute('data-color')) : null; 478 element.setAttribute('style', 'background-color:rgba(' + color.r + ',' + color.g + ',' + color.b + ',0.35);'); 479 } else if (element) { 480 element.removeAttribute('style'); 481 } 482 }); 483 484 function hexToRgb(hex) { 485 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 486 return result ? { 487 r: parseInt(result[1], 16), 488 g: parseInt(result[2], 16), 489 b: parseInt(result[3], 16) 490 } : null; 491 } 492 } 493 } 494 495 function dataCheck () { 496 var date = document.querySelectorAll('.date-pick-input'); 497 for (var i=0; i<date.length;i++) { 498 var ele = date[i]; 499 ele.classList.remove('active'); 500 ele.checked = false; 501 } 502 } 503 504 function checkBoxAllFalse () {
505 var termCalendar = document.querySelectorAll('.term-calendar') 506 for (var i=0;i<termCalendar.length;i++) { 507 var ele = termCalendar[i]; 508 ele.classList.remove('etc-active'); 509 ele.classList.remove('etc-start-active'); 510 ele.classList.remove('etc-end-active'); 511 ele.checked = false; 512 } 513 } 514 515 function generateLegends() { 516 var start = new Date(that.el.tables.childNodes[0].childNodes[0].getAttribute('data-date')); 517 var end = new Date(that.el.tables.childNodes[months - 1].childNodes[82].getAttribute('data-date')); 518 var _highlights = highlight.filter(function (x) { 519 for (var m = 0; m < x.dates.length; m++) { 520 if (x.dates[m].start < end && x.dates[m].end > start) { 521 return true; 522 } 523 } 524 return false; 525 }); 526 var legends = []; 527 for (var l = 0; l < _highlights.length; l++) { 528 if ('legend' in _highlights[l] && _highlights[l].legend) { 529 var oldLegend = container.querySelector('.d-legend-item[data-legend="' + _highlights[l].legend + '"][data-color="' + _highlights[l].backgroundColor + '"]'); 530 if (oldLegend == null) { 531 var legendItem = document.createElement('p'); 532 legendItem.setAttribute('class', 'd-legend-item'); 533 legendItem.setAttribute('data-legend', _highlights[l].legend); 534 legendItem.setAttribute('data-legend-id', highlight.indexOf(_highlights[l])); 535 legendItem.setAttribute('data-color', _highlights[l].backgroundColor); 536 var legendItemPoint = document.createElement('span'); 537 legendItemPoint.setAttribute('style', 'background-color:' + _highlights[l].backgroundColor); 538 legendItem.appendChild(legendItemPoint); 539 that.el.legend.appendChild(legendItem); 540 legendItem.addEventListener('mouseover', hoverLegend); 541 legendItem.addEventListener('mouseout', hoverLegend); 542 legends.push(legendItem); 543 } else { 544 legends.push(oldLegend); 545 } 546 } 547 } 548 [].slice.call(that.el.legend.querySelectorAll('.d-legend-item')).forEac
548h(function (item) { 549 if (legends.indexOf(item) < 0) { 550 item.removeEventListener('mouseover', hoverLegend); 551 item.removeEventListener('mouseout', hoverLegend); 552 that.el.legend.removeChild(item); 553 } 554 }); 555 556 function hoverLegend(e) { 557 [].slice.call(that.el.tables.querySelectorAll('[data-legend-id*="' + this.getAttribute('data-legend-id') + '"]')).forEach(function (element) { 558 if (e.type == 'mouseover') element.classList.add('legend-hover');else element.classList.remove('legend-hover'); 559 }); 560 } 561 } 562 563 function parseMonth(month) { 564 if (month > 11) month -= 12; 565 else if (month < 0) month += 12; 566 return month; 567 } 568 569 function generateDates(year, month, type) { 570 dataCheck(); 571 var selectCanlendar = document.querySelector('#select-calendar'); 572 var dateTime = document.querySelector('#etc-start-date-txt').value; 573 if (selectCanlendar.value == 'etc-end-date') dateTime = document.querySelector('#etc-end-date-txt').value; 574 575 if (!type) { 576 var dateAry = dateTime.split('.'); 577 year = (dateAry[0] * 1); 578 month = (dateAry[1] * 1); 579 currentYear = (dateAry[0] * 1); 580 currentMonth = (dateAry[1] * 1); 581 setDate(); 582 583 dataCheck(); 584 } 585 586 var monthElements = that.el.querySelectorAll('.d-table'); 587 var ws = weekStart !== null ? weekStart : languages[lang].weekStart; 588 589 var userStartDate = $('#etc-start-date-txt').val(), 590 userEndDate = $('#etc-end-date-txt').val(); 591
592 [].slice.call(that.el.querySelectorAll('.d-table')).forEach(function (element, index) { 593 var days = new Date(year, month + index, 0).getDate(); 594 var daysLast = new Date(year, month + index - 1, 0).getDate(); 595 var startDay = new Date(year, month + index - 1, 1).getDay(); 596 var startDate = null; 597 var endDate = null; 598 if (startDay - ws < 0) { 599 startDay = 7 - ws; 600 } else { 601 startDay -= ws; 602 } 603 var monthText = languages[lang].monthNames[parseMonth(month - 1 + index)]; 604 element.setAttribute('data-month', monthText); 605 606 [].slice.call(element.querySelectorAll('.d-table input')).forEach(function (inputEl, i) { 607 var labelEl = inputEl.nextSibling; 608 609 inputEl.checked = false; 610 inputEl.removeAttribute('disabled'); 611 labelEl.removeAttribute('style'); 612 labelEl.removeAttribute('data-legend-id'); 613 labelEl.className = ''; 614 615 var date = null; 616 var dateFormat = null; 617 if (i < startDay) { 618 labelEl.childNodes[0].innerHTML = daysLast - (startDay - i - 1); 619 if (index == 0) { 620 date = new Date(year, month + index - 2, daysLast - (startDay - i - 1)); 621 dateFormat = new Date(year, month + index - 2, daysLast - (startDay - i - 1)).format('yyyy.MM.dd'); 622 labelEl.className = 'prev'; 623 } else { 624 date = ''; 625 labelEl.className = 'd-hidden'; 626 inputEl.setAttribute('disabled', true); 627 } 628 } else if (i < days + startDay) { 629 date = new Date(year, month + index - 1, i - startDay + 1); 630 dateFormat = new Date(year, month + index - 1, i - startDay + 1).format('yyyy.MM.dd'); 631 labelEl.childNodes[0].innerHTML = i - startDay + 1; 632 labelEl.className = ''; 633 } else { 634 labelEl.childNodes[0].innerHTML = i - days - startDay + 1; 635 if (index == monthElements.length - 1) { 636 date = new Date(year, month + index, i - days - startDay + 1); 637 dateFormat = new Date(year, month + index, i - days - startDay + 1).format('yyyy.MM.dd'); 638 labelEl.className = 'next'; 639 } else { 640 date = ''; 641 labelEl.className = 'd-hidden'; 642 inputEl.setAttribute('disabled', true); 643 } 644 } 645 646 if(args.exp == true) { 647 var dayEnabled = refreshDays(dateFormat,userStartDate,userEndDate); 648 labelEl.className = (dayEnabled) ? 'exp' : 'disabled'; 649 } 650 labelEl.setAttribute('label-date', dateFormat); 651 652 if (date instanceof Date) { 653 inputEl.setAttribute('data-date', dateFormat); 654 inputEl.setAttribute('data-term_date', dateFormat); 655 656 if (disabledDates.indexOf(date.getTime()) != -1 || disabledDays.indexOf(date.getDay()) != -1) { 657 inputEl.setAttribute('disabled', true); 658 } 659 660 if (minDate && date < minDate || maxDate && date > maxDate) { 661 inputEl.setAttribute('disabled', true); 662 labelEl.className = 'd-hidden'; 663 } 664 665 var _highlights = highlight.filter(function (x) { 666 for (var m = 0; m < x.dates.length; m++) { 667 if (date.getTime() >= x.dates[m].start.getTime() && date.getTime() <= x.dates[m].end.getTime()) { 668 return true; 669 } 670 } 671 return false; 672 }); 673 674 if (_highlights.length > 0) { 675 var bgColor = ''; 676 var legendIds = ''; 677 678 if (_highlights.length > 1) { 679 var percent = Math.round(100 / _highlights.length); 680 bgColor = 'background: linear-gradient(-45deg,'; 681 for (var z = 0; z < _highlights.length; z++) { 682 legendIds += highlight.indexOf(_highlights[z]); 683 if (z !== _highlights.length - 1) { 684 legendIds += ' '; 685 } 686 bgColor += _highlights[z].backgroundColor + ' ' + percent * z + '%'; 687 if (z != _highlights.length - 1) { 688 bgColor += ','; 689 bgColor += _highlights[z].backgroundColor + ' ' + percent * (z + 1) + '%,'; 690 } 691 } 692 bgColor += ');'; 693 } else { 694 bgColor = _highlights[0].backgroundColor ? 'background:' + _highlights[0].backgroundColor + ';' : ''; 695 legendIds += highlight.indexOf(_highlights[0]); 696 } 697 var Color = _highlights[0].color ? 'color:' + _highlights[0].color + ';' : ''; 698 labelEl.setAttribute('style', bgColor + Color); 699 labelEl.setAttribute('data-legend-id', legendIds); 700 } 701 } 702 }); 703 }); 704 705 generateLegends(); 706 707 var width = 0; 708 $('#etc-except-date-picker.etc-except-date-picker .Datepickk .d-table input + label').each(function (idx, item) { 709 if (idx == 0) width = $(this).width(); 710 $(this).css('height', width+'px'); 711 }); 712 }; 713 714 function setDate() { 715 if (!that.el.tables.childNodes.length || !that.el.tables.childNodes[0].childNodes.length) return; 716
717 resetCalendar(); 718 719 if (currentMonth > 12 || currentMonth < 1) { 720 if (currentMonth > 12) { 721 currentYear += 1; 722 currentMonth -= 12; 723 } else { 724 currentYear -= 1; 725 currentMonth += 12; 726 } 727 } 728 if (maxDate && new Date(currentYear, currentMonth - 1 + months - 1, 1) >= new Date(maxDate).setDate(1)) { 729 currentYear = maxDate.getFullYear(); 730 currentMonth = maxDate.getMonth() + 1 - months + 1; 731 that.el.header.childNodes[3].setAttribute('style', 'visibility:hidden'); 732 that.el.header.childNodes[4].setAttribute('style', 'visibility:hidden'); 733 } else { 734 that.el.header.childNodes[3].removeAttribute('style'); 735 that.el.header.childNodes[4].removeAttribute('style'); 736 } 737 if (minDate && new Date(currentYear, currentMonth - 1, 1) <= new Date(minDate).setDate(1)) { 738 currentYear = minDate.getFullYear(); 739 currentMonth = minDate.getMonth() + 1; 740 that.el.header.childNodes[0].setAttribute('style', 'visibility:hidden'); 741 that.el.header.childNodes[1].setAttribute('style', 'visibility:hidden'); 742 } else { 743 that.el.header.childNodes[0].removeAttribute('style'); 744 that.el.header.childNodes[1].removeAttribute('style'); 745 } 746 for (var c = 0; c < months; c++) { 747 var index = currentMonth - 1 + c; 748 if (index > 11) { 749 index -= 12; 750 } else if (index < 0) { 751 index += 12; 752 } 753 754 // that.el.monthPicker.childNodes[index].classList.add('current'); 755 that.el.newMonthPicker.childNodes[index].classList.add('current'); 756 } 757 758 generateDates(currentYear, currentMonth, 'new'); 759 generateYears(); 760 var startmonth = languages[lang].monthNames[currentMonth - 1]; 761 var endmonth = ''; 762 if (months > 1) { 763 endmonth += ' - '; 764 var monthint = currentMonth - 1 + months - 1; 765 if (monthint > 11) { 766 monthint -= 12; 767 } else if (monthint < 0) { 768 monthint += 12; 769 } 770 endmonth += languages[lang].monthNames[monthint]; 771 } 772 var yearname = currentMonth - 1 + months - 1 > 11 ? currentYear.toString() + '/' + (currentYear + 1).toString() : currentYear.toString(); 773 774 that.el.header.childNodes[2].childNodes[1].innerHTML = (lang == 'ko')? startmonth + endmonth : yearname; 775 that.el.header.childNodes[2].childNodes[0].innerHTML = (lang == 'ko')? yearname+'.' : startmonth + endmonth; 776 777 that.el.yearPicker.querySelector('[data-year="0"]').classList.add('current'); 778 that.el.newYearPicker.querySelector('[data-fullYear="'+currentYear+'"]').classList.add('current'); 779 if (currentMonth - 1 + months - 1 > 11) { 780 that.el.yearPicker.querySelector('[data-year="1"]').classList.add('current'); 781 that.el.monthYearPicker.querySelector('[data-year="1"]').classList.add('current'); 782 } 783 784 // var i = 0; 785 // var width = 0; 786 // $('#etc-end-date-picker .Datepickk .d-table input + label').each(function () { 787 // if (i == 0) width = $(this).width(); 788 // $(this).css('height', width+'px'); 789 // i++; 790 // }); 791 // var i = 0; 792 // var width = 0; 793 // $('#etc-start-date-picker .Datepickk .d-table input + label').each(function () { 794 // if (i == 0) width = $(this).width(); 795 // $(this).css('height', width+'px'); 796 // i++; 797 // }); 798 // var i = 0; 799 // var width = 0; 800 // $('#etc-except-date-picker.etc-except-date-picker .Datepickk .d-table input + label').each(function () { 801 // if (i == 0) width = $(this).width(); 802 // $(this).css('height', width+'px'); 803 // i++; 804 // }); 805 806 renderSelectedDates(); 807 if (onNavigation) onNavigation.call(that); 808 checkBoxAllFalse(); 809 810 var startDate = document.querySelector('#etc-start-date-txt'); 811 var endDate = document.querySelector('#etc-end-date-txt'); 812 813 if(args.range) { 814 if (startDate.value) { 815 var termCalendar = document.querySelectorAll('.term-calendar'); 816 for (var i=0;i<termCalendar.length;i++) { 817 var ele = termCalendar[i]; 818 if (ele.dataset.term_date == startDate.value) { 819 ele.classList.add('etc-start-active'); 820 ele.checked = true; 821 if (ele.dataset.term_date == endDate.value) { 822 ele.classList.add('etc-end-active'); 823 ele.checked = true; 824 } 825 } else if (ele.dataset.term_date == endDate.value) { 826 ele.classList.add('etc-end-active'); 827 ele.checked = true; 828 } 829 } 830 } 831 832 if (endDate.value) { 833 document.querySelectorAll('.term-calendar').forEach(function (ele) { 834 if (ele.dataset.term_date == endDate.value) { 835 ele.classList.add('etc-end-active'); 836 ele.checked = true; 837 } 838 }); 839 } 840 841 $('.term-calendar-box .d-tables input').removeClass('inRange'); 842 if(startDate.value && endDate.value) { 843 var startDateObj = new Date(startDate.value.replace(/\./g,'/')); 844 var endDateObj = new Date(endDate.value.replace(/\./g,'/')); 845 $('.term-calendar-box .d-tables input').each(function (i, v) { 846 var dateObj = new Date($(v).attr('data-term_date').replace(/\./g,'/')); 847 if(dateObj > startDateObj && dateObj < endDateObj && !$(v).is(':disabled')) $(v).addClass('inRange'); 848 }); 849 } 850 } 851 852 }; 853
854 function renderSelectedDates() { 855 selectedDates.forEach(function (date) { 856 date = new Date(date); 857 var el = that.el.querySelector('[data-date="' + date.toJSON() + '"]'); 858 if (el) { 859 el.checked = true; 860 } 861 }); 862 863 that.el.tables.classList.remove('before'); 864 if (range && selectedDates.length > 1) { 865 var currentDate = new Date(currentYear, currentMonth - 1, 1); 866 var sorted = selectedDates.sort(function (a, b) { 867 return a.getTime() - b.getTime(); 868 }); 869 var first = that.el.querySelector('[data-date="' + sorted[0].toJSON() + '"]'); 870 if (!first && currentDate >= new Date(sorted[0].getFullYear(), sorted[0].getMonth(), 1) && currentDate <= new Date(sorted[1].getFullYear(), sorted[1].getMonth(), 1)) { 871 that.el.tables.classList.add('before'); 872 } 873 } 874 }; 875 876 function resetCalendar() { 877 [].slice.call(that.el.querySelectorAll('.d-table input')).forEach(function (inputEl) { 878 inputEl.checked = false; 879 }); 880 881 [].slice.call(that.el.monthPicker.querySelectorAll('.current')).forEach(function (monthPickEl) { 882 monthPickEl.classList.remove('current'); 883 }); 884 885 [].slice.call(that.el.yearPicker.querySelectorAll('.current')).forEach(function (yearPickEl) { 886 yearPickEl.classList.remove('current'); 887 }); 888 889 [].slice.call(that.el.newMonthPicker.querySelectorAll('.current')).forEach(function (monthPickEl) { 890 monthPickEl.classList.remove('current'); 891 }); 892 893 [].slice.call(that.el.newYearPicker.querySelectorAll('.current')).forEach(function (yearPickEl) { 894 yearPickEl.classList.remove('current'); 895 }); 896 }; 897 898 function nextMonth() { 899 currentMonth += months; 900 dataCheck(); 901 setDate(); 902 displaySelectedDates(); 903 }; 904 905 function prevMonth() { 906 if(currentYear > 1900 || (currentYear == 1900 && currentMonth > 1)) currentMonth -= months; 907 dataCheck(); 908 setDate(); 909 displaySelectedDates(); 910 }; 911 912 function nextYear() { 913 currentYear += 1; 914 dataCheck(); 915 setDate(); 916 displaySelectedDates(); 917 }; 918 919 function prevYear() { 920 if(currentYear > 1900) currentYear -= 1; 921 dataCheck(); 922 setDate(); 923 displaySelectedDates(); 924 }; 925 926 function selectDate(date, ignoreOnSelect) { 927 date = new Date(date); 928 date.setHours(0, 0, 0, 0); 929 var year = date.getFullYear(); 930 var month = date.getMonth()+ 1; 931 var date = date.getDate(); 932 if(parseInt(month) < 10) month = "0" + month; 933 if(parseInt(date) < 10) date = "0" + date; 934 935 var newDate = year + '.' + month + '.' + date; 936 // var el = that.el.querySelector('[data-date="' + date.toJSON() + '"]'); 937 var el = that.el.querySelector('[data-date="' + newDate + '"]'); 938 939 if (range && el && el.checked) { 940 el.classList.add('single'); 941 } 942 943 if (el && !el.checked) { 944 el.checked = true; 945 } 946 947 selectedDates.push(date); 948 949 if (onSelect && !ignoreOnSelect) { 950 onSelect.apply(date, [true]); 951 } 952 }; 953 954 function unselectDate(date, ignoreOnSelect) { 955 date = new Date(date); 956 date.setHours(0, 0, 0, 0); 957 var el = that.el.querySelector('[data-date="' + date.toJSON() + '"]'); 958 if (el) { 959 el.classList.remove('single'); 960 if (el.checked) { 961 el.checked = false; 962 } 963 } 964 965 selectedDates = selectedDates.filter(function (x) { 966 x = new Date(x.replace(/\./g, '/')); 967 return x.getTime() != date.getTime(); 968 }); 969 970 if (onSelect && !ignoreOnSelect) { 971 onSelect.call(date, false); 972 } 973 }; 974 975 function unselectAll(ignoreOnSelect) { 976 if(!selectedDates || selectedDates.length == 0) { 977 selectedDates = exceptPicker.selectedDates; 978 } 979 980 selectedDates.forEach(function (date) { 981 unselectDate(date, ignoreOnSelect); 982 }); 983 }; 984 985 function unselectExceptDate(date, ignoreOnSelect) { 986 date = new Date(date.replace(/\./g, '/')); 987 date.setHours(0, 0, 0, 0); 988 989 var el = that.el.querySelector('[data-date="' + date.format('yyyy.MM.dd') + '"]'); 990 if (el) { 991 el.classList.remove('active'); 992 if (el.checked) { 993 el.checked = false; 994 } 995 } 996 997 selectedDates = selectedDates.filter(function (x) { 998 x = new Date(x.replace(/\./g, '/')); 999 return x.getTime() != date.getTime(); 1000 }); 1001 1002 var str = selectedDates.join(','); 1003 document.querySelector('#select-except-date').value = str; 1004 }; 1005 1006 function unselectExceptAll(ignoreOnSelect) { 1007 selectedDates = exceptPicker.selectedDates; 1008
1009 selectedDates.forEach(function (date) { 1010 unselectExceptDate(date, ignoreOnSelect); 1011 }); 1012 }; 1013 1014 function inputChange(e) { 1015 var input = this; 1016 var date = new Date(input.getAttribute('data-date')); 1017 input.classList.remove('single'); 1018 if (locked) { 1019 return; 1020 } 1021 if (range) { 1022 that.el.tables.classList.remove('before'); 1023 } 1024 if (input.checked) { 1025 if (maxSelections && selectedDates.length > maxSelections - 1) { 1026 var length = selectedDates.length; 1027 for (length; length > maxSelections - 1; length--) { 1028 unselectDate(selectedDates[0]); 1029 } 1030 } 1031 1032 if (range && selectedDates.length) { 1033 var first = that.el.querySelector('[data-date="' + selectedDates[0].toJSON() + '"]'); 1034 if (!first && date > selectedDates[0]) { 1035 that.el.tables.classList.add('before'); 1036 } 1037 } 1038 1039 selectedDates.push(date); 1040 1041 if (closeOnSelect) { 1042 that.hide(); 1043 } 1044 } else { 1045 if (range && selectedDates.length == 1 && selectedDates[0].getTime() == date.getTime()) { 1046 selectDate(date); 1047 input.classList.add('single'); 1048 } else { 1049 selectedDates = selectedDates.filter(function (x) { 1050 return x.getTime() != date.getTime(); 1051 }); 1052 } 1053 } 1054 1055 if (onSelect) { 1056 onSelect.call(date, input.checked); 1057 } 1058 }; 1059 1060 function setRange(val) { 1061 if (val) { 1062 range = true; 1063 that.el.tables.classList.add('range'); 1064 } else { 1065 range = false; 1066 that.el.tables.classList.remove('range'); 1067 } 1068 }; 1069 1070 function show(properties) { 1071 if (!that.inline && that.container === document.body) { 1072 document.body.classList.add('d-noscroll'); 1073 } 1074 setArgs(properties); 1075 var handler = function handler() { 1076 that.el.classList.remove('d-show'); 1077 that.el.calendar.removeEventListener(whichAnimationEvent(), handler); 1078 }; 1079 that.el.calendar.addEventListener(whichAnimationEvent(), handler); 1080 that.el.classList.add('d-show'); 1081 container.appendChild(that.el); 1082 opened = true; 1083 if (startDate) { 1084 currentMonth = startDate.getMonth() + 1; 1085 currentYear = startDate.getFullYear(); 1086 } 1087 setDate(); 1088 }; 1089 1090 function hide() { 1091 document.body.classList.remove('d-noscroll'); 1092 var handler = function handler() { 1093 that.el.parentNode.removeChild(that.el); 1094 opened = false; 1095 that.el.classList.remove('d-hide'); 1096 if (typeof onClose == 'function') { 1097 onClose.apply(that); 1098 } 1099 that.el.removeEventListener(whichAnimationEvent(), handler); 1100 }; 1101 that.el.addEventListener(whichAnimationEvent(), handler); 1102 that.el.classList.add('d-hide'); 1103 }; 1104 1105 function bindEvents() { 1106 that.el.header.childNodes[0].addEventListener(eventName, prevYear); 1107 that.el.header.childNodes[1].addEventListener(eventName, prevMonth); 1108 that.el.header.childNodes[3].addEventListener(eventName, nextMonth); 1109 that.el.header.childNodes[4].addEventListener(eventName, nextYear); 1110 // that.el.header.childNodes[2].childNodes[0].addEventListener(eventName,function(){ 1111 // generateYears(); 1112 // if(that.el.yearPicker.classList.contains('d-show')){ 1113 // that.el.yearPicker.classList.remove('d-show'); 1114 // }else{ 1115 // that.el.yearPicker.classList.add('d-show'); 1116 // } 1117 // that.el.monthPicker.classList.remove('d-show'); 1118 // }); 1119 // that.el.header.childNodes[2].childNodes[1].addEventListener(eventName,function(){ 1120 // if(that.el.monthPicker.classList.contains('d-show')){ 1121 // that.el.monthPicker.classList.remove('d-show'); 1122 // }else{ 1123 // that.el.monthPicker.classList.add('d-show'); 1124 // } 1125 // that.el.yearPicker.classList.remove('d-show'); 1126 // }); 1127 that.el.overlay.addEventListener(eventName, function () { 1128 if (closeOnClick) { 1129 that.hide(); 1130 } 1131 }); 1132 1133 [].slice.call(that.el.monthPicker.childNodes).forEach(function (monthPicker) { 1134 monthPicker.addEventListener(eventName, function () { 1135 currentMonth = parseInt(this.getAttribute('data-month')); 1136 setDate(); 1137 that.el.monthPicker.classList.remove('d-show'); 1138 }); 1139 }); 1140 1141 [].slice.call(that.el.yearPicker.childNodes).forEach(function (yearPicker) { 1142 yearPicker.addEventListener(eventName, function () { 1143 currentYear += parseInt(this.getAttribute('data-year')); 1144 setDate(); 1145 that.el.yearPicker.classList.remove('d-show'); 1146 }); 1147 }); 1148
1149 [].slice.call(that.el.newMonthPicker.childNodes).forEach(function (monthPicker) { 1150 monthPicker.addEventListener(eventName, function () { 1151 currentMonth = parseInt(this.getAttribute('data-month')); 1152 setDate(); 1153 that.el.monthYearPicker.classList.remove('d-show'); 1154 displaySelectedDates(); 1155 }); 1156 }); 1157 1158 [].slice.call(that.el.newYearPicker.childNodes).forEach(function (yearPicker) { 1159 yearPicker.addEventListener(eventName, function () { 1160 currentYear = parseInt(this.getAttribute('data-fullYear')); 1161 setDate(); 1162 displaySelectedDates(); 1163 }); 1164 }); 1165 1166 that.el.monthYearPicker.querySelector('.close-picker').addEventListener(eventName, function() { 1167 that.el.monthYearPicker.classList.remove('d-show'); 1168 }); 1169 1170 var startX = 0; 1171 var distance = 0; 1172 that.el.calendar.addEventListener('touchstart', function (e) { 1173 startX = e.changedTouches[0].clientX || e.originalEvent.changedTouches[0].clientX; 1174 //e.preventDefault(); 1175 }); 1176 1177 that.el.calendar.addEventListener('touchmove', function (e) { 1178 distance = e.changedTouches[0].clientX - startX || e.originalEvent.changedTouches[0].clientX - startX; 1179 e.preventDefault(); 1180 }); 1181 1182 that.el.calendar.addEventListener('touchend', function (e) { 1183 if (distance > 50) { 1184 prevMonth(); 1185 } else if (distance < -50) { 1186 nextMonth(); 1187 } 1188 distance = 0; 1189 }); 1190 }; 1191 1192 function setArgs(x) { 1193 for (var key in x) { 1194 if (key in that) { 1195 that[key] = x[key]; 1196 } 1197 }; 1198 }; 1199 1200 function init() { 1201 that.el = document.createElement('div'); 1202 that.el.classList.add('Datepickk'); 1203 that.el.classList.add(getBrowserVersion().type); 1204 that.el.innerHTML = template; 1205 that.el.calendar = that.el.childNodes[1]; 1206 that.el.titleBox = that.el.childNodes[0]; 1207 that.el.button = that.el.childNodes[3]; 1208 that.el.header = that.el.calendar.childNodes[0]; 1209 that.el.monthPicker = that.el.calendar.childNodes[1]; 1210 that.el.yearPicker = that.el.calendar.childNodes[2]; 1211 that.el.tables = that.el.calendar.childNodes[5]; 1212 that.el.days = that.el.calendar.childNodes[4]; 1213 that.el.overlay = that.el.childNodes[4]; 1214 that.el.legend = that.el.childNodes[2]; 1215 1216 that.el.monthYearPicker = that.el.calendar.childNodes[3]; 1217 that.el.newMonthPicker = that.el.monthYearPicker.childNodes[1].childNodes[1]; 1218 that.el.newYearPicker = that.el.monthYearPicker.childNodes[1].childNodes[0]; 1219 1220 setArgs(args); 1221 generateInputs(args.exp, args.range); 1222 generateDaynames(); 1223 bindEvents(); 1224 1225 if (inline) { 1226 show(); 1227 } 1228 } 1229 1230 that.show = show; 1231 that.hide = hide; 1232 that.selectDate = selectDate; 1233 that.unselectAll = unselectAll; 1234 that.unselectDate = unselectDate; 1235 that.unselectExceptAll = unselectExceptAll; 1236 that.unselectExceptDate = unselectExceptDate; 1237 that.generateDates = generateDates; 1238 that.setSelectedDates = setSelectedDates; 1239 1240 function currentDateGetter() { 1241 return new Date(currentYear, currentMonth - 1, 1); 1242 } 1243 function currentDateSetter(x) { 1244 x = new Date(x); 1245 currentMonth = x.getMonth() + 1; 1246 currentYear = x.getFullYear(); 1247 setDate(); 1248 } 1249 1250 function setSelectedDates(date, type) { 1251 var dp = moment(date.replace(/\./g, '/')), sdate, 1252 selected = document.querySelector('#select-except-date').value, 1253 reset = [], 1254 startDate = document.querySelector('#etc-start-date-txt').value, 1255 endDate = document.querySelector('#etc-end-date-txt').value; 1256 selected = (selected == '-')? '':selected; 1257 if(selected) { 1258 // console.log(selected); 1259 var dates = selected.split(','); 1260 document.querySelector('#etc-except-date').value = dates[0]; 1261 dates.forEach(function(v,i,el) { 1262 sdate = moment(v.replace(/\./g, '/')); 1263 var exceptPickerDate = exceptPicker.container.querySelector('[data-date="' + v + '"]'); 1264 var exceptPickerDateDisabled = (exceptPickerDate == null || typeof exceptPickerDate == 'undefined')? '':exceptPickerDate.getAttribute('disabled'); 1265 1266 if(type == 'start') { 1267 if(dp <= sdate && exceptPickerDateDisabled != 'true') { 1268 reset.push(v); 1269 //exceptPicker.container.querySelector('[data-date="' + v + '"]').classList.add('active'); 1270 } 1271 } else if(type == 'end') { 1272 if(dp >= sdate && exceptPickerDateDisabled != 'true') { 1273 reset.push(v); 1274 //exceptPicker.container.querySelector('[data-date="' + v + '"]').classList.add('active'); 1275 } 1276 } else { 1277 if(exceptPickerDateDisabled != 'true'){ 1278 reset.push(v); 1279 } 1280 } 1281 }); 1282 1283 var reSelected = reset.join(','); 1284 1285 if(startDate == endDate || reset.length == 0) { 1286 document.querySelector('#etc-except-date').value = '-'; 1287 document.querySelector('#select-except-date').value = ''; 1288 reSelected = ''; 1289 } 1290 1291 document.querySelector('#select-except-date').value = reSelected; 1292 } 1293 1294 } 1295 1296 function getSelectedDates(date) { 1297 var selected = [], 1298 cal = args.container, 1299 checked = cal.querySelectorAll('input.active'); 1300 1301 if(cal.id != 'etc-except-date-picker') return; 1302 1303 var userStartDate = document.querySelector('#etc-start-date-txt').value, 1304 userEndDate = document.querySelector('#etc-end-date-txt').value, 1305 currentDates = document.querySelector('#select-except-date').value, 1306 etcDateWeek = document.querySelector('#etc-date-week').value, 1307 termDays = (document.querySelector('#term-days'))? document.querySelector('#term-days').value:''; 1308 var exceptPickerContainer = document.querySelector('#etc-except-date-picker'); 1309 var exceptPickerDate = exceptPickerContainer.querySelector('[data-date="' + date + '"]'); 1310 var exceptPickerDateDisabled = (exceptPickerDate == null || typeof exceptPickerDate == 'undefined')? '':exceptPickerDate.getAttribute('disabled'); 1311 var termDaysArr = new Array(); 1312 var enableDays = new Array(); 1313 1314 if(termDays) { 1315 termDaysArr = termDays.split('|'); 1316 var daysObj = { 1317 'sun': 0, 1318 'mon': 1, 1319 'tue': 2, 1320 'wed': 3, 1321 'thu': 4, 1322 'fri': 5,
1323 'sat': 6, 1324 } 1325 1326 if(termDaysArr.length > 0) { 1327 $.each(termDaysArr, function(i, v){ 1328 enableDays.push(daysObj[v]); 1329 }); 1330 } 1331 } 1332 1333 userStartDate = new Date(userStartDate.replace(/\./g, '/')); 1334 userEndDate = new Date(userEndDate.replace(/\./g, '/')); 1335 currentDates = (currentDates == '-')? '':currentDates; 1336 1337 var elapsedMSec = userEndDate.getTime() - userStartDate.getTime(); // 172800000 1338 var elapsedDates = 0; 1339 1340 if(etcDateWeek == 'A') { 1341 elapsedDates = (elapsedMSec / 1000 / 60 / 60 / 24) + 1; 1342 } else { 1343 while(true) { 1344 var temp_date = userStartDate; 1345 if(temp_date.getTime() > userEndDate.getTime()) { 1346 break; 1347 } else { 1348 var tmp = temp_date.getDay(); 1349 if(termDaysArr.length > 0) { 1350 if(enableDays.indexOf(tmp) > -1) elapsedDates++; 1351 } else { 1352 if(etcDateWeek == 'W') { //ì£¼ì¤ 1353 if(tmp != 0 && tmp != 6) elapsedDates++; 1354 } else { //ì£¼ë§ 1355 if(tmp == 0 || tmp == 6) elapsedDates++; 1356 } 1357 } 1358 1359 temp_date.setDate(userStartDate.getDate() + 1); 1360 } 1361 } 1362 } 1363 // console.log("count : " + elapsedDates); 1364 // console.log(currentDates); 1365 1366 selected = (currentDates != '')? currentDates.split(','):[]; 1367 if(typeof date != 'undefined'){ 1368 if(!selected.includes(date)) { 1369 selected.push(date); 1370 } else { 1371 selected.splice(selected.indexOf(date), 1); 1372 } 1373 } 1374 // console.log(selected, date); 1375 if(elapsedDates == selected.length) { 1376 selected.splice(selected.indexOf(date), 1); 1377 exceptPickerContainer.querySelector('[data-date="' + date + '"]').classList.remove('active'); 1378 exceptPickerContainer.querySelector('input[data-term_date="' + date + '"]').checked = false; 1379 alert($.lang[LANG]['config.form.date.excludeDate.all']); 1380 } 1381 1382 // console.log(selected); 1383 var str = selected.sort().join(','); 1384 var selectedArr = selected.sort(); 1385 document.querySelector('#select-except-date').value = str; 1386 document.querySelector('#etc-except-date').value = (selectedArr[0])? selectedArr[0]:'-'; 1387 1388 if(document.querySelector('.etc-except-date-status') != null) { 1389 if(selected.length > 1) { 1390 document.querySelector('.etc-except-date-status').innerText = 'ì¸ '+(selected.length-1)+'ê±´' 1391 } else { 1392 document.querySelector('.etc-except-date-status').innerText = ''; 1393 } 1394 } 1395 1396 if(selected.length > 0) { 1397 $('.unselect-all').removeClass('disabled'); 1398 } else { 1399 $('.unselect-all').addClass('disabled'); 1400 } 1401 1402 return selected; 1403 } 1404 1405 Object.defineProperties(that, { 1406 "selectedDates": { 1407 get: function get() { 1408 return getSelectedDates(); 1409 // return selectedDates.sort(function (a, b) { 1410 // return a.getTime() - b.getTime(); 1411 // }); 1412 } 1413 }, 1414 "range": { 1415 get: function get() { 1416 return range; 1417 }, 1418 set: function set(x) { 1419 setRange(x); 1420 if (x) { 1421 maxSelections = 2; 1422 } 1423 } 1424 }, 1425 "button": { 1426 get: function get() { 1427 return button; 1428 }, 1429 set: function set(x) { 1430 if (typeof x == 'string') { 1431 button = x; 1432 } else { 1433 button = null; 1434 } 1435 that.el.button.innerHTML = button ? button : ''; 1436 } 1437 }, 1438 "title": { 1439 get: function get() { 1440 return title; 1441 }, 1442 set: function set(x) { 1443 if (typeof x == 'string') { 1444 title = x; 1445 } else { 1446 title = null; 1447 } 1448 that.el.titleBox.innerText = title ? title : ''; 1449 } 1450 }, 1451 "lang": { 1452 get: function get() { 1453 return lang; 1454 }, 1455 set: function set(x) { 1456 if (x in languages) { 1457 lang = x; 1458 generateDaynames(); 1459 setDate(); 1460 } else { 1461 console.error('Language not found'); 1462 } 1463 } 1464 }, 1465 "weekStart": { 1466 get: function get() { 1467 return weekStart !== null ? weekStart : languages[lang].weekStart; 1468 }, 1469 set: function set(x) { 1470 if (typeof x == 'number' && x > -1 && x < 7) { 1471 weekStart = x; 1472 generateDaynames(); 1473 setDate(); 1474 } else { 1475 console.error('weekStart must be a number between 0 and 6'); 1476 } 1477 } 1478 }, 1479 "months": { 1480 get: function get() { 1481 return months; 1482 }, 1483 set: function set(x) { 1484 if (typeof x == 'number' && x > 0) { 1485 months = x; 1486 generateDaynames(); 1487 generateInputs(args.exp, args.range); 1488 setDate(); 1489 1490 if (months == 1) { 1491 that.el.classList.remove('multi'); 1492 } else { 1493 that.el.classList.add('multi'); 1494 } 1495 } else { 1496 console.error('months must be a number > 0'); 1497 } 1498 } 1499 }, 1500 "isOpen": { 1501 get: function get() { 1502 return opened; 1503 } 1504 }, 1505 "closeOnSelect": { 1506 get: function get() { 1507 return closeOnSelect; 1508 },
1509 set: function set(x) { 1510 if (x) { 1511 closeOnSelect = true; 1512 } else { 1513 closeOnSelect = false; 1514 } 1515 } 1516 }, 1517 "disabledDays": { 1518 get: function get() { 1519 return disabledDays; 1520 }, 1521 set: function set(x) { 1522 if (x instanceof Array) { 1523 for (var i = 0; i < x.length; i++) { 1524 if (typeof x[i] == 'number') { 1525 disabledDays.push(x[i]); 1526 } 1527 } 1528 } else if (typeof x == 'number') { 1529 disabledDays = [x]; 1530 } else if (!x) { 1531 disabledDays = []; 1532 } 1533 setDate(); 1534 } 1535 }, 1536 "disabledDates": { 1537 get: function get() { 1538 return disabledDates.map(function (x) { 1539 return new Date(x); 1540 }); 1541 }, 1542 set: function set(x) { 1543 if (x instanceof Array) { 1544 x.forEach(function (date) { 1545 if (date instanceof Date) { 1546 disabledDates.push(new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime()); 1547 } 1548 }); 1549 } else if (x instanceof Date) { 1550 disabledDates = [new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime()]; 1551 } else if (!x) { 1552 disabledDates = []; 1553 } 1554 setDate(); 1555 } 1556 }, 1557 "highlight": { 1558 get: function get() { 1559 return highlight; 1560 }, 1561 set: function set(x) { 1562 if (x instanceof Array) { 1563 x.forEach(function (hl) { 1564 if (hl instanceof Object) { 1565 var highlightObj = {}; 1566 highlightObj.dates = []; 1567 1568 if ('start' in hl) { 1569 highlightObj.dates.push({ 1570 start: new Date(hl.start.getFullYear(), hl.start.getMonth(), hl.start.getDate()), 1571 end: 'end' in hl ? new Date(hl.end.getFullYear(), hl.end.getMonth(), hl.end.getDate()) : new Date(hl.start.getFullYear(), hl.start.getMonth(), hl.start.getDate()) 1572 }); 1573 } else if ('dates' in hl && hl.dates instanceof Array) { 1574 hl.dates.forEach(function (hlDate) { 1575 highlightObj.dates.push({ 1576 start: new Date(hlDate.start.getFullYear(), hlDate.start.getMonth(), hlDate.start.getDate()), 1577 end: 'end' in hlDate ? new Date(hlDate.end.getFullYear(), hlDate.end.getMonth(), hlDate.end.getDate()) : new Date(hlDate.start.getFullYear(), hlDate.start.getMonth(), hlDate.start.getDate()) 1578 }); 1579 }); 1580 } 1581 1582 highlightObj.color = hl.color; 1583 highlightObj.backgroundColor = hl.backgroundColor; 1584 highlightObj.legend = 'legend' in hl ? hl.legend : null; 1585 1586 highlight.push(highlightObj); 1587 } 1588 }); 1589 } else if (x instanceof Object) { 1590 var highlightObj = {}; 1591 highlightObj.dates = []; 1592 1593 if ('start' in x) { 1594 highlightObj.dates.push({ 1595 start: new Date(x.start.getFullYear(), x.start.getMonth(), x.start.getDate()), 1596 end: 'end' in x ? new Date(x.end.getFullYear(), x.end.getMonth(), x.end.getDate()) : new Date(x.start.getFullYear(), x.start.getMonth(), x.start.getDate()) 1597 }); 1598 } else if ('dates' in x && x.dates instanceof Array) { 1599 x.dates.forEach(function (hlDate) { 1600 highlightObj.dates.push({ 1601 start: new Date(hlDate.start.getFullYear(), hlDate.start.getMonth(), hlDate.start.getDate()), 1602 end: 'end' in hlDate ? new Date(hlDate.end.getFullYear(), hlDate.end.getMonth(), hlDate.end.getDate()) : new Date(hlDate.start.getFullYear(), hlDate.start.getMonth(), hlDate.start.getDate()) 1603 }); 1604 }); 1605 } 1606 1607 highlightObj.color = x.color; 1608 highlightObj.backgroundColor = x.backgroundColor; 1609 highlightObj.legend = 'legend' in x ? x.legend : null; 1610 1611 highlight.push(highlightObj); 1612 } else if (!x) { 1613 highlight = []; 1614 } 1615 1616 setDate(); 1617 } 1618 }, 1619 "onClose": { 1620 set: function set(callback) { 1621 onClose = callback; 1622 } 1623 }, 1624 "onSelect": { 1625 set: function set(callback) { 1626 onSelect = callback; 1627 } 1628 }, 1629 "today": { 1630 get: function get() { 1631 return today; 1632 }, 1633 set: function set(x) { 1634 if (x) { 1635 today = true; 1636 } else { 1637 today = false; 1638 } 1639 } 1640 }, 1641 "daynames": { 1642 get: function get() { 1643 return daynames; 1644 }, 1645 set: function set(x) { 1646 if (x) { 1647 daynames = true; 1648 } else { 1649 daynames = false; 1650 } 1651 generateDaynames(); 1652 } 1653 }, 1654 "fullscreen": { 1655 get: function get() { 1656 return that.el.classList.contains('fullscreen'); 1657 },
1658 set: function set(x) { 1659 if (x) { 1660 that.el.classList.add('fullscreen'); 1661 } else { 1662 that.el.classList.remove('fullscreen'); 1663 } 1664 } 1665 }, 1666 "locked": { 1667 get: function get() { 1668 return locked; 1669 }, 1670 set: function set(x) { 1671 if (x) { 1672 locked = true; 1673 that.el.tables.classList.add('locked'); 1674 } else { 1675 locked = false; 1676 that.el.tables.classList.remove('locked'); 1677 } 1678 } 1679 }, 1680 "maxSelections": { 1681 get: function get() { 1682 return maxSelections; 1683 }, 1684 set: function set(x) { 1685 if (typeof x == 'number' && !range) { 1686 maxSelections = x; 1687 } else { 1688 if (range) { 1689 maxSelections = 2; 1690 } else { 1691 maxSelections = null; 1692 } 1693 } 1694 } 1695 }, 1696 "onConfirm": { 1697 set: function set(callback) { 1698 if (typeof callback == 'function') { 1699 onConfirm = callback.bind(that); 1700 that.el.button.addEventListener(eventName, onConfirm); 1701 } else if (!callback) { 1702 that.el.button.removeEventListener(eventName, onConfirm); 1703 onConfirm = null; 1704 } 1705 } 1706 }, 1707 "onNavigation": { 1708 set: function set(callback) { 1709 if (typeof callback == 'function') { 1710 onNavigation = callback.bind(that); 1711 } else if (!callback) { 1712 onNavigation = null; 1713 } 1714 } 1715 }, 1716 "closeOnClick": { 1717 get: function get() { 1718 return closeOnClick; 1719 }, 1720 set: function set(x) { 1721 if (x) { 1722 closeOnClick = true; 1723 } else { 1724 closeOnClick = false; 1725 } 1726 } 1727 }, 1728 "currentDate": { 1729 get: currentDateGetter, 1730 set: currentDateSetter 1731 }, 1732 "setDate": { 1733 set: currentDateSetter 1734 }, 1735 "startDate": { 1736 get: function get() { 1737 return startDate; 1738 }, 1739 set: function set(x) { 1740 if (x) { 1741 startDate = new Date(x); 1742 } else { 1743 startDate = null; 1744 currentYear = new Date().getFullYear(); 1745 currentMonth = new Date().getMonth() + 1; 1746 } 1747 setDate(); 1748 } 1749 }, 1750 "minDate": { 1751 get: function get() { 1752 return minDate; 1753 }, 1754 set: function set(x) { 1755 minDate = x ? new Date(x) : null; 1756 setDate(); 1757 } 1758 }, 1759 "maxDate": { 1760 get: function get() { 1761 return maxDate; 1762 }, 1763 set: function set(x) { 1764 maxDate = x ? new Date(x) : null; 1765 setDate(); 1766 } 1767 }, 1768 "container": { 1769 get: function get() { 1770 return container; 1771 }, 1772 set: function set(x) { 1773 if (x instanceof String) { 1774 var y = document.querySelector(x); 1775 if (y) { 1776 container = y; 1777 if (container != document.body) { 1778 that.el.classList.add('wrapped'); 1779 } else { 1780 that.el.classList.remove('wrapped'); 1781 } 1782 } else { 1783 console.error("Container doesn't exist"); 1784 } 1785 } else if (x instanceof HTMLElement) { 1786 container = x; 1787 if (container != document.body) { 1788 that.el.classList.add('wrapped'); 1789 } else { 1790 that.el.classList.remove('wrapped'); 1791 } 1792 } else { 1793 console.error("Invalid type"); 1794 } 1795 } 1796 }, 1797 "inline": { 1798 get: function get() { 1799 return inline; 1800 }, 1801 set: function set(x) { 1802 if (x) { 1803 inline = true; 1804 that.el.classList.add('inline'); 1805 } else { 1806 inline = false; 1807 that.el.classList.remove('inline'); 1808 } 1809 } 1810 }, 1811 "exp": { 1812 get: function get() { 1813 return exp; 1814 }, 1815 set: function set(x) { 1816 if (x) { 1817 exp = true; 1818 that.el.tables.classList.add('exp'); 1819 } else { 1820 exp = false; 1821 that.el.tables.classList.remove('exp'); 1822 } 1823 } 1824 }, 1825 1826 }); 1827 1828 init(); 1829 setDate(); 1830 1831 return Object.freeze(that); 1832} /*! 1833 * Datepickk 1834 * Docs & License: https://crsten.github.com/datepickk 1835 * (c) 2017 Carsten Jacobsen 1836 */ 1837 1838; 1839 1840function whichAnimationEvent() { 1841 var t; 1842 var el = document.createElement('fakeelement'); 1843 var transitions = { 1844 'animation': 'animationend', 1845 'OAnimation': 'oanimationend', 1846 'MozAnimation': 'animationend', 1847 'WebkitAnimation': 'webkitAnimationEnd', 1848 '': 'MSAnimationEnd' 1849 }; 1850 1851 for (t in transitions) { 1852 if (el.style[t] !== undefined) { 1853 return transitions[t]; 1854 } 1855 } 1856} 1857 1858var CURRENT_YEAR = new Date().getFullYear(); 1859var yearList = ''; 1860for(var i = 1900-CURRENT_YEAR; i <= 15; i++) { 1861 yearList += '<div data-year="'+i+'"></div>'; 1862} 1863var monthList = '<div data-month="1">1</div>' + 1864'<div data-month="2">
18642</div>' + 1865'<div data-month="3">3</div>' + 1866'<div data-month="4">4</div>' + 1867'<div data-month="5">5</div>' + 1868'<div data-month="6">6</div>' + 1869'<div data-month="7">7</div>' + 1870'<div data-month="8">8</div>' + 1871'<div data-month="9">9</div>' + 1872'<div data-month="10">10</div>' + 1873'<div data-month="11">11</div>' + 1874'<div data-month="12">12</div>'; 1875 1876var template = '<div class="d-title"></div><div class="d-calendar"><div class="d-header"><i id="dy-previous"><svg viewBox="0 0 14 14" width="14" height="14"><polygon points="8 2 7 1 1 7 7 13 8 12 3 7 "></polygon><polygon points="13 2 12 1 6 7 12 13 13 12 8 7 "></polygon></svg></i><i id="d-previous"><svg viewBox="0 0 14 14" width="14" height="14"><polygon points="9 1 10 2 5 7 10 12 9 13 3 7 "></polygon></svg></i><p><span class="d-year"></span><span class="d-month"></span></p><i id="d-next"><svg viewBox="0 0 14 14" width="14" height="14"><polygon points="5 1 4 2 9 7 4 12 5 13 11 7 "></polygon></svg></i><i id="dy-next"><svg viewBox="0 0 14 14" width="14" height="14"><polygon points="7 1 6 2 11 7 6 12 7 13 13 7 "></polygon><polygon points="2 1 1 2 6 7 1 12 2 13 8 7 "></polygon></svg></i></div>'+ 1877'<div class="d-month-picker">' + monthList + '</div>' + 1878'<div class="d-year-picker">' + yearList + '</div>'+ 1879'<div class="d-month-year-picker">'+ 1880 '<div class="pick-header display-flex align-items-center"><div class="year">'+$.lang[LANG]['config.form.date.year']+'</div><div class="month">'+$.lang[LANG]['config.form.date.month']+'<span class="close-picker hand"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="10" height="10"><path d="M8.71 8l7.15-7.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L8 7.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L7.29 8l-7.15 7.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 15.95 0.37 16 0.5 16s0.26-0.05 0.35-0.15L8 8.71l7.15 7.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L8.71 8z"></path></svg></span></div></div>' + 1881 '<div class="pick-body display-flex">'+ 1882 '<div class="year-picker">' + yearList + '</div>'+ 1883 '<div class="month-picker">' + monthList + '</div>' + 1884 '</div>'+ 1885'</div>' + 1886'<div class="d-weekdays"></div>' + 1887'<div class="d-tables"></div>' + 1888'</div>' + 1889'<div class="d-legend"></div>' + 1890'<button class="d-confirm"></button>' + 1891'<div class="d-overlay"></div>'; 1892 1893var getBrowserVersion = function getBrowserVersion() { 1894 var browser = { 1895 type: null, 1896 version: null 1897 }; 1898 1899 var ua = navigator.userAgent, 1900 tem, 1901 ios, 1902 M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; 1903 ios = ua.match(/(iphone|ipad)\s+OS\s+([\d+_]+\d+)/i) || []; 1904 if (/trident/i.test(M[1])) { 1905 tem = /\brv[ :]+(\d+)/g.exec(ua) || []; 1906 browser.type = 'MSIE'; 1907 browser.version = parseInt(tem[1]); 1908 return browser; 1909 } 1910 if (M[1] === 'Chrome') { 1911 tem = ua.match(/\bOPR\/(\d+)/); 1912 if (tem != null) return 'Opera ' + tem[1]; 1913 } 1914 if (ios[1]) { 1915 return browser = { 1916 type: 'iOS', 1917 version: ios[2] 1918 }; 1919 } 1920 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; 1921 if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]); 1922 browser.type = M[0]; 1923 browser.version = parseInt(M[1]); 1924 1925 return browser; 1926}; 1927 1928exports.default = Datepickk; 1929 1930/***/ }), 1931/* 1 */ 1932/***/ (function(module, exports) { 1933 1934// removed by extract-text-webpack-plugin 1935 1936/***/ }) 1937/******/ ])["default"]; 1938}); 1939 1940Date.prototype.format = function (f) { 1941 if (!this.valueOf()) return " "; 1942 1943 var weekName = ["ì¼ìì¼", "ììì¼", "íìì¼", "ììì¼", "목ìì¼", "ê¸ìì¼", "í ìì¼"]; 1944 var d = this; 1945 1946 return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function(da) { 1947 switch (da) { 1948 case "yyyy": return d.getFullYear(); 1949 case "yy": return (d.getFullYear() % 1000).zf(2); 1950 case "MM": return (d.getMonth() + 1).zf(2); 1951 case "dd": return d.getDate().zf(2); 1952 case "E": return weekName[d.getDay()]; 1953 case "HH": return d.getHours().zf(2); 1954 case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2); 1955 case "mm": return d.getMinutes().zf(2); 1956 case "ss": return d.getSeconds().zf(2); 1957 case "a/p": return d.getHours() < 12 ? "ì¤ì " : "ì¤í"; 1958 default: return da; 1959 } 1960 }); 1961}; 1962 1963String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;}; 1964String.prototype.zf = function(len){return "0".string(len - this.length) + this;}; 1965Number.prototype.zf = function(len){return this.toString().zf(len);}; 1966 1967var checkCalendarClick = true; 1968if(document.querySelector('.prod-modal') !== null) { 1969 document.querySelector('.prod-modal').addEventListener('click', function (e) { 1970 dataCheck(e.target.parentNode); 1971 if (checkCalendarClick && $('#etc-start-date-txt').length) { 1972 displaySelectedDates(); 1973 document.querySelector('#etc-start-date-txt').classList.remove('active'); 1974 document.querySelector('#etc-end-date-txt').classList.remove('active'); 1975 document.querySelector('#etc-except-date').classList.remove('active'); 1976 document.querySelector('#etc-start-date-picker').style.display = 'none'; 1977 document.querySelector('#etc-end-date-picker').style.display = 'none'; 1978 document.querySelector('#etc-except-date-picker').style.display = 'none'; 1979 } 1980 }); 1981} 1982 1983function dataCheck (ele) { 1984 if (ele.classList == 'pace-disable') { 1985 checkCalendarClick = true; 1986 // document.querySelector('#etc-start-date-txt').classList.remove('active'); 1987 // document.querySelector('#etc-end-date-txt').classList.remove('active'); 1988 // document.querySelector('#etc-except-date').classList.remove('active'); 1989 return false;
1990 } else if (ele.classList == 'd-header' || 1991 ele.classList == 'd-next' || 1992 ele.classList == 'd-previous') { 1993 checkCalendarClick = false; 1994 setTimeout(function () { 1995 checkCalendarClick = true; 1996 }, 300); 1997 return false; 1998 } else if (ele.classList == 'etc-date' || ele.classList == 'etc-content') { 1999 checkCalendarClick = true; 2000 return false; 2001 } 2002 2003 var classCheck = ele.parentNode.classList; 2004 if (classCheck == 'd-header' || 2005 classCheck == 'd-next' || 2006 classCheck == 'd-previous') { 2007 checkCalendarClick = false; 2008 setTimeout(function () { 2009 checkCalendarClick = true; 2010 }, 300); 2011 return false; 2012 } else if (classCheck == 'etc-date' || classCheck == 'etc-content') { 2013 displaySelectedDates(); 2014 switch(ele.children[0].id) { 2015 case "etc-start-date": 2016 document.querySelector('#etc-end-date-txt').classList.remove('active'); 2017 document.querySelector('#etc-except-date').classList.remove('active'); 2018 document.querySelector('#etc-end-date-picker').style.display = 'none'; 2019 document.querySelector('#etc-except-date-picker').style.display = 'none'; 2020 break; 2021 2022 case "etc-end-date": 2023 document.querySelector('#etc-start-date-txt').classList.remove('active'); 2024 document.querySelector('#etc-except-date').classList.remove('active'); 2025 document.querySelector('#etc-start-date-picker').style.display = 'none'; 2026 document.querySelector('#etc-except-date-picker').style.display = 'none'; 2027 break; 2028 2029 case "etc-except-date": 2030 document.querySelector('#etc-start-date-txt').classList.remove('active'); 2031 document.querySelector('#etc-end-date-txt').classList.remove('active'); 2032 document.querySelector('#etc-start-date-picker').style.display = 'none'; 2033 document.querySelector('#etc-end-date-picker').style.display = 'none'; 2034 break; 2035 2036 default: 2037 document.querySelector('#etc-start-date-txt').classList.remove('active'); 2038 document.querySelector('#etc-end-date-txt').classList.remove('active'); 2039 document.querySelector('#etc-except-date').classList.remove('active'); 2040 document.querySelector('#etc-start-date-picker').style.display = 'none'; 2041 document.querySelector('#etc-end-date-picker').style.display = 'none'; 2042 document.querySelector('#etc-except-date-picker').style.display = 'none'; 2043 2044 break; 2045 } 2046 checkCalendarClick = false; 2047 return false; 2048 } else if (classCheck == 'pace-disable') { 2049 checkCalendarClick = true; 2050 return false; 2051 } else { 2052 dataCheck(ele.parentNode); 2053 } 2054} 2055function displaySelectedDates() { 2056 var selectedExceptDate = (document.querySelector('#select-except-date'))? document.querySelector('#select-except-date').value:''; 2057 selectedExceptDate = (selectedExceptDate == '-')? '':selectedExceptDate; 2058 var selecteDateYMD = document.querySelector('#select-date-ymd'); 2059 2060 if(selectedExceptDate.length > 0) { 2061 var dates = selectedExceptDate.split(','); 2062 var exceptPickerContainer = document.querySelector('#etc-except-date-picker'); 2063 dates.forEach(function(v,i,el) { 2064 var exceptPickerDate = exceptPickerContainer.querySelector('[data-date="' + v + '"]'); 2065 var exceptPickerDate2 = exceptPickerContainer.querySelector('[data-term_date="' + v + '"]:not(disabled)'); 2066 if(exceptPickerDate) { 2067 exceptPickerDate.classList.add('active'); 2068 if(exceptPickerDate.getAttribute('disabled') == 'true') { 2069 exceptPickerDate.classList.remove('active'); 2070 } 2071 } 2072 if(exceptPickerDate2) exceptPickerDate2.checked = true; 2073 }); 2074 2075 $('.unselect-all').removeClass('disabled'); 2076 } else { 2077 if(document.querySelector('.etc-except-date-status')) document.querySelector('.etc-except-date-status').innerText = ''; 2078 $('.unselect-all').addClass('disabled'); 2079 } 2080 2081 if(selecteDateYMD){ 2082 var activeDate = selecteDateYMD.value; 2083 $('.Datepickk input[data-term_date="'+activeDate+'"]').addClass('active').prop('checked', true); 2084 } 2085} 2086function setExceptPicker() { 2087 var $days = $('#etc-except-date-picker .date-pick-input'), 2088 userStartDate = $('#etc-start-date-txt').val(), 2089 userEndDate = $('#etc-end-date-txt').val(), 2090 dateWeek = $('#etc-date-week').val(); 2091 exceptPicker.disabledDays = null; 2092 if(dateWeek == 'W') { 2093 exceptPicker.disabledDays = [0, 6]; 2094 } else if(dateWeek == 'K') { 2095 exceptPicker.disabledDays = [1, 2, 3, 4, 5]; 2096 } else { 2097 exceptPicker.disabledDays = null; 2098 } 2099 $.each($days, function(i,v) { 2100 // console.log($(this)); 2101 var s = $(this).attr('data-date'), 2102 c = refreshDays(s,userStartDate,userEndDate); 2103 (c) ? $(this).next().removeClass('disabled').addClass('exp') : $(this).next().removeClass('exp').addClass('disabled'); 2104 }); 2105 2106 displaySelectedDates(); 2107} 2108 2109function refreshDays(d,s,e) { 2110 var _start = s.replace(/\./g, '-'), 2111 _end = e.replace(/\./g, '-'), 2112 _day = d.replace(/\./g, '-'); 2113 2114 var dp = moment(_day), 2115 start = moment(_start), 2116 end = moment(_end); 2117 2118 return (dp < start || dp > end) ? false : true; 2119}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.