1var method = Base.prototype; 2 3function Base(config) { 4 moment.locale('de'); 5 6 this._body = $("body"); 7 this._config = config; 8 9 this._setup_selected_model = null; 10 this._setup_selected_hour_rate = 0; 11 this._countries = {}; 12 13 this._sound_goat = $("#timegoat-audio"); 14 15 this.initClickEvents(); 16 this.initChangeEvents(); 17 18 this.initSubmitHandler(); 19 this.initTooltips(); 20 this.initDatepicker(); 21 this.initEditors(); 22 this.initSelect2s(); 23 24 this.setMasks(); 25 26 this.setSetup(); 27} 28 29method.initClickEvents = function () { 30 var self = this; 31 32 self._body 33 .off("click", '[data-toggle="tooltip"]') 34 .on("click", '[data-toggle="tooltip"]', function () { 35 $(this).tooltip("hide"); 36 }); 37 38 self._body 39 .off("click", '[data-toggle="tooltip"]') 40 .on("click", '[data-toggle="tooltip"]', function () { 41 $(this).tooltip("hide"); 42 }); 43 44 self._body 45 .off("click", '.label-fake') 46 .on("click", '.label-fake', function () { 47 var target = $(this).attr("data-target"); 48 49 if (target !== undefined) { 50 $("label[for='" + target + "']").trigger("click"); 51 } 52 }); 53 54 self._body 55 .off('click', '.switch-lang') 56 .on('click', '.switch-lang', function (ev) { 57 ev.preventDefault(); 58 59 var lang = $(this).attr('data-lang'); 60 Cookies.set('lang', lang, {expires: 365, sameSite: 'strict'}); 61 62 window.location.href = self._config.BASE_ADMIN_URL + "prices"; 63 }); 64 65 self._body 66 .off("click", '.timepicker-container .link-add-hour') 67 .on("click", '.timepicker-container .link-add-hour', function () { 68 var target = $($(this).attr("data-target")); 69 var value = parseInt(target.val()); 70 71 if (isNaN(value)) { 72 value = 0; 73 } 74 75 var new_value = value + 1; 76 77 if (new_value > 23) { 78 new_value = 0; 79 } 80 81 target.val(String('00' + new_value).slice(-2)); 82 }); 83 84 self._body 85 .off("click", '.timepicker-container .link-sub-hour') 86 .on("click", '.timepicker-container .link-sub-hour', function () { 87 var target = $($(this).attr("data-target")); 88 var value = parseInt(target.val()); 89 90 if (isNaN(value)) { 91 value = 0; 92 } 93 94 var new_value = value - 1; 95 if (new_value < 0) { 96 new_value = 23; 97 } 98 99 target.val(String('00' + new_value).slice(-2)); 100 }); 101 102 self._body 103 .off("click", '.timepicker-container .link-add-minute') 104 .on("click", '.timepicker-container .link-add-minute', function () { 105 var target = $($(this).attr("data-target")); 106 107 var value = parseInt(target.val()); 108 if (isNaN(value)) { 109 value = 0; 110 } 111 112 var new_value = value + 1; 113 if (new_value > 59) { 114 new_value = 0; 115 } 116 117 target.val(String('00' + new_value).slice(-2)); 118 }); 119 120 self._body 121 .off("click", '.timepicker-container .link-sub-minute') 122 .on("click", '.timepicker-container .link-sub-minute', function () { 123 var target = $($(this).attr("data-target")); 124 var value = parseInt(target.val()); 125 126 if (isNaN(value)) { 127 value = 0; 128 } 129 130 var new_value = value - 1; 131 if (new_value < 0) { 132 new_value = 59; 133 } 134 135 target.val(String('00' + new_value).slice(-2)); 136 }); 137 138 self._body 139 .off("click", ".link-del") 140 .on("click", ".link-del", function () { 141 var id = $(this).attr("data-id"); 142 var action = $(this).attr("data-form-action"); 143 var do_action = $(this).attr("data-form-do-action"); 144 if (action !== undefined) { 145 $("#form-del").attr("action", action); 146 } else { 147 $("#form-del").attr("action", ""); 148 } 149 150 if (do_action === undefined) { 151 $("#form-del").find("input[name='doAction']").val("doDelete"); 152 } else { 153 $("#form-del").find("input[name='doAction']").val(do_action); 154 } 155 156 $("#form-del input[name='id']").val(id); 157 }); 158 159 self._body 160 .off("click", "a[data-action]") 161 .on("click", "a[data-action]", function (ev) { 162 ev.preventDefault(); 163 var id = $(this).attr("data-id"); 164 var action = $(this).attr("data-action"); 165 var route = $(this).attr("href"); 166 167 var form = $('<form>', { 168 'method': 'post', 169 'action': (route === undefined || route === '#' || route === '') ? '' : route 170 }) 171 .append($("<input>", { 172 'name': 'doAction', 173 'value': action, 174 'type': 'hidden' 175 })) 176 .append($("<input>", { 177 'name': 'id', 178 'value': id, 179 'type': 'hidden' 180 })); 181 182 form.appendTo('body').submit().remove(); 183 }); 184 185 self._body 186 .off("click", ".open-img") 187 .on("click", ".open-img", function () { 188 var id = $(this).attr("data-gallery"); 189 190 if (id === undefined) { 191 self.openPhotoSwipe(this, 0, false); 192 } else { 193 self.openPhotoSwipe(".open-img[data-gallery='" + id + "']", $(this).index(".open-img[data-gallery='" + id + "']"), true); 194 } 195 }); 196 197 self._body 198 .off("click", "[data-setup-type]") 199 .on("click", "[data-setup-type]", function (ev) { 200 var type = $(this).attr("data-setup-type"); 201 var current_step_container = $('.setup-nav').find('[data-setup-state="current"]'); 202 var current_content_container = $('.setup-content').find('[data-setup-state="current"]'); 203 204 var new_content_container = null; 205 var new_step_container = null; 206 207 var btn_submit = $(".setup-content").find(".mod-submit"); 208 209 if (type === "action-prev") { 210 new_step_container = current_step_container.prev(); 211 new_content_container = current_content_container.prev(); 212 213 if (new_step_container !== null && new_content_container !== null && new_step_container.length !== 0) { 214 current_step_container.attr('data-setup-state', 'pending'); 215 new_step_container.attr('data-setup-state', 'current'); 216 217 current_content_container.removeAttr('data-setup-state'); 218 new_content_container.attr('data-setup-state', 'current'); 219 220 var prev_new_step_container = new_step_container.prev(); 221 if (prev_new_step_container.length === 0) { 222 $('[data-setup-type="action-prev"]').addClass("invisible"); 223 } else { 224 $('[data-setup-type="action-prev"]').removeClass("invisible"); 225 } 226 } 227 228 $('[data-setup-type="action-next"]').removeClass("d-none"); 229 btn_submit.addClass("d-none"); 230 231 } else if (type === "action-next") { 232 new_step_container = current_step_container.next(); 233 new_content_container = current_content_container.next(); 234 235 if (new_step_container !== null && new_content_container !== null && new_step_container.length !== 0) { 236 current_step_container.attr('data-setup-state', 'done'); 237 new_step_container.attr('data-setup-state', 'current'); 238 239 current_content_container.removeAttr('data-setup-state'); 240 new_content_container.attr('data-setup-state', 'current'); 241 242 $('button[data-setup-type="action-prev"]').removeClass("invisible"); 243 244 var new_new_step_container = new_step_container.next(); 245 if (new_new_step_container.length === 0) { 246 $('[data-setup-type="action-next"]').addClass("d-none"); 247 btn_submit.removeClass("d-none"); 248 } 249 } 250 } 251 }); 252 253 self._body 254 .off("click", ".model_selection_container") 255 .on("click", ".model_selection_container", function () { 256 var container = $(this); 257 self._setup_selected_model = parseInt(container.attr("data-model")); 258 259 $(".model_selection_container").removeClass("active"); 260 container.addClass("active"); 261 $('button[data-setup-type="action-next"]').slideDown(); 262 $('.required-text').slideUp(); 263 }); 264 265 self._body 266 .off("click", ".hour_rate_selection_container") 267 .on("click", ".hour_rate_selection_container", function () { 268 var container = $(this); 269 self._setup_selected_hour_rate = parseInt(container.attr("data-hour-rate")); 270 271 $(".hour_rate_selection_container").removeClass("active"); 272 container.addClass("active"); 273 }); 274 275 self._body 276 .off("change", "#setup_countries") 277 .on("change", "#setup_countries", function () { 278 var country = $(this).val(); 279 var setup_regions_element = $("#setup_regions"); 280 var region_container = $(".setup_region_container"); 281 282 var html = ''; 283 if (self._countries[country] !== undefined) { 284 if (self._countries[country]["sub_divisions"].length === 0) { 285 setup_regions_element.html(html); 286 setup_regions_element.selectpicker("refresh"); 287 288 region_container.slideUp(); 289 } else { 290 291 for (var key in self._countries[country]["sub_divisions"]) { 292 var region = self._countries[country]["sub_divisions"][key]; 293 294 html += '<option value="' + region.lookup_key + '">' + region.name + '</option>'; 295 } 296 297 setup_regions_element.html(html); 298 setup_regions_element.selectpicker("refresh"); 299 300 region_container.slideDown(); 301 } 302 } else { 303 region_container.slideUp(); 304 } 305 }); 306 307 self._body 308 .off("click", ".setup-content .mod-submit") 309 .on("click", ".setup-content .mod-submit", function (ev) { 310 ev.preventDefault(); 311 312 var form = $(this).closest("form"); 313 314 var data = form.serializeArray(); 315 data.push({ 316 "name": "model", 317 "value": self._setup_selected_model 318 }); 319 320 data.push({ 321 "name": "hour_rate", 322 "value": self._setup_selected_hour_rate 323 }); 324 325 self.getAjaxData(data, function (resp) { 326 if (resp.error_messages !== undefined && resp.error_messages.length === 0) { 327 window.location.href = window.location; 328 } 329 }, true, false); 330 }); 331 332 self._body 333 .off("click", ".play-sound") 334 .on("click", ".play-sound", function () { 335 self.playSound(); 336 }); 337}; 338
339method.initChangeEvents = function () { 340 var self = this; 341}; 342 343method.setSetup = function () { 344 var self = this; 345 346 if (self._config.SETUP_COMPLETED !== undefined && parseInt(self._config.SETUP_COMPLETED) === 0) { 347 348 self.doFetchCountries($("#setup_countries")) 349 .then( 350 function () { 351 var modal = $("#mod-setup"); 352 modal.modal("show"); 353 }, 354 function (err) { 355 self.addNotification("danger", err); 356 } 357 ); 358 } 359}; 360 361method.doFetchCountries = function (select_element) { 362 var self = this; 363 364 return new Promise(function (fulfill, reject) { 365 var data = { 366 "doAction": "doGetCountries" 367 }; 368 369 self.getAjaxData(data, function (resp) { 370 if (resp.error_messages !== undefined && resp.error_messages.length === 0) { 371 self._countries = {}; 372 373 for (var key in resp.countries) { 374 var country = resp.countries[key]; 375 self._countries[country.lookup_key] = country; 376 377 var html = '<option value="' + country.lookup_key + '">'; 378 html += country.name; 379 html += '</option>'; 380 381 select_element.append(html); 382 } 383 384 select_element.selectpicker("refresh"); 385 386 fulfill(); 387 } else { 388 reject(); 389 } 390 }); 391 }); 392} 393 394method.setMasks = function () { 395 $(".mask-numeric").each(function () { 396 var digits = 2; 397 var prefix = ""; 398 var suffix = ""; 399 var allow_minus = true; 400 var right_align = false; 401 402 if ($(this).attr("data-digits") !== undefined) { 403 digits = parseInt($(this).attr("data-digits")); 404 } 405 406 if ($(this).attr("data-prefix") !== undefined) { 407 prefix = $(this).attr("data-prefix"); 408 } 409 410 if ($(this).attr("data-suffix") !== undefined) { 411 suffix = $(this).attr("data-suffix"); 412 } 413 414 if ($(this).attr("data-allow-minus") !== undefined) { 415 allow_minus = $(this).attr("data-allow-minus") === "true"; 416 } 417 418 if ($(this).attr("data-right") !== undefined) { 419 right_align = $(this).attr("data-right") === "true"; 420 } 421 422 var options = { 423 radixPoint: ',', 424 groupSeparator: '.', 425 autoGroup: true, 426 prefix: prefix, 427 suffix: suffix, 428 digits: digits, 429 enforceDigitsOnBlur: true, 430 removeMaskOnSubmit: true, 431 autoUnmask: true, 432 allowMinus: allow_minus, 433 rightAlign: right_align, 434 inputType: "number" 435 }; 436 437 $(this).inputmask("decimal", options); 438 }); 439 440 $(".mask-numeric-euro").each(function () { 441 var digits = 2; 442 var prefix = "⬠"; 443 var suffix = ""; 444 var allow_minus = true; 445 var right_align = false; 446 447 if ($(this).attr("data-digits") !== undefined) { 448 digits = parseInt($(this).attr("data-digits")); 449 } 450 451 if ($(this).attr("data-prefix") !== undefined) { 452 prefix = $(this).attr("data-prefix"); 453 } 454 455 if ($(this).attr("data-suffix") !== undefined) { 456 suffix = $(this).attr("data-suffix"); 457 } 458 459 if ($(this).attr("data-allow-minus") !== undefined) { 460 allow_minus = $(this).attr("data-allow-minus") === "true"; 461 } 462 463 if ($(this).attr("data-right") !== undefined) { 464 right_align = $(this).attr("data-right") === "true"; 465 } 466 467 var options = { 468 radixPoint: ',', 469 groupSeparator: '.', 470 autoGroup: true, 471 prefix: prefix, 472 suffix: suffix, 473 digits: digits, 474 removeMaskOnSubmit: true, 475 autoUnmask: true, 476 enforceDigitsOnBlur: true, 477 allowMinus: allow_minus, 478 rightAlign: right_align, 479 inputType: "number" 480 }; 481 482 $(this).inputmask("decimal", options); 483 }); 484 485 $('.mask-time').each(function () { 486 var placeholder = "hh:mm"; 487 var input_format = "HH:MM"; 488 var max = null; 489 490 if ($(this).attr("data-format") !== undefined) { 491 input_format = $(this).attr("data-format"); 492 } 493 494 if ($(this).attr("data-placeholder") !== undefined) { 495 placeholder = $(this).attr("data-placeholder"); 496 } 497 498 if ($(this).attr("data-max") !== undefined) { 499 max = $(this).attr("data-max"); 500 } 501 502 if (input_format.substr(input_format.length - 1) === "T") { 503 placeholder = "hh:mm XM"; 504 } 505 506 var options = { 507 removeMaskOnSubmit: true, 508 autoUnmask: false, 509 placeholder: placeholder, 510 inputFormat: input_format, 511 max: max 512 }; 513 514 $(this).inputmask('datetime', options); 515 }); 516}; 517 518method.initDatepicker = function () { 519 var self = this; 520 521 $.fn.datepicker.dates.de = { 522 days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], 523 daysShort: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"], 524 daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"], 525 months: ["Jänner", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "
525November", "Dezember"], 526 monthsShort: ["Jän", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"], 527 today: "Heute", 528 clear: "Zurücksetzen", 529 titleFormat: "MM yyyy" 530 } 531 532 $(".datepicker").each(function () { 533 var format = "dd.mm.yyyy"; 534 535 if ($(this).attr("data-format") !== undefined) { 536 format = $(this).attr("data-format"); 537 } 538 539 $(this).datepicker({ 540 autoclose: true, 541 todayHighlight: true, 542 orientation: "bottom left", 543 format: format, 544 language: 'de', 545 weekStart: 1, 546 templates: { 547 leftArrow: '<i class="la la-angle-left"></i>', 548 rightArrow: '<i class="la la-angle-right"></i>' 549 } 550 }); 551 }); 552}; 553 554method.initEditors = function () { 555 var self = this; 556 557 $('.summernote').each(function () { 558 var height = $(this).attr('data-height'); 559 height = height === undefined ? 300 : parseInt(height); 560 561 let $editor = $(this); 562 $(this).summernote({ 563 lang: 'de-DE', 564 height: height, 565 disableDragAndDrop: true, 566 styleWithSpan: false, 567 toolbar: [ 568 ['toolbar', ['bold', 'italic', 'underline', 'ul', 'ol', 'codeview']] 569 ], 570 onfocus: function (e) { 571 $('body').addClass('overlay-disabled'); 572 }, 573 onblur: function (e) { 574 $('body').removeClass('overlay-disabled'); 575 }, 576 callbacks: { 577 // Clear all formatting of the pasted text 578 onPaste: function (e) { 579 var bufferText = ((e.originalEvent || e).clipboardData || 580 window.clipboardData).getData('Text'); 581 e.preventDefault(); 582 setTimeout(function () { 583 document.execCommand('insertText', false, bufferText); 584 }, 10); 585 }, 586 onFocus: function (contents) { 587 if ($editor.summernote('isEmpty')) { 588 $editor.html(''); 589 } 590 } 591 } 592 }); 593 594 }); 595}; 596 597method.initSelect2s = function () { 598 var self = this; 599 600 $('.select2').each(function () { 601 $(this).select2({ 602 width: '100%', 603 minimumResultsForSearch: ($(this).attr('data-disable-search') === 'true' ? -1 : 1), 604 language: { 605 'noResults': function () { 606 return "Keine Einträge gefunden"; 607 }, 608 'searching': function () { 609 return "Suche..."; 610 } 611 } 612 }); 613 }); 614}; 615 616method.initUserSelect = function (element, do_action, parent) { 617 var self = this; 618 619 if (parent === undefined) { 620 parent = $('body'); 621 } else { 622 parent = $(parent); 623 } 624 625 if (element === undefined) { 626 element = $('#user-select'); 627 } else { 628 element = $(element); 629 } 630 631 element.select2({ 632 dropdownParent: parent, 633 width: '100%', 634 language: { 635 'noResults': function () { 636 return "Keine Einträge gefunden"; 637 }, 638 'searching': function () { 639 return "Suche..."; 640 }, 641 loadingMore: function () { 642 return "Lade..."; 643 } 644 }, 645 ajax: { 646 dataType: 'json', 647 type: 'POST', 648 quietMillis: 50, 649 data: function (term) { 650 return { 651 'doAction': do_action === undefined ? 'doGetUsers' : do_action, 652 'term': term 653 }; 654 }, 655 processResults: function (response, params) { 656 params.page = params.page || 1; 657 658 var map = $.map(response.results, function (item) { 659 return { 660 text: item.fullname_reverse + " (" + item.email + ")", 661 id: item.id 662 }; 663 }); 664 665 var allow_empty = element.attr('data-allow-empty'); 666 var allow_empty_text = element.attr('data-allow-empty-text'); 667 if (allow_empty !== undefined && allow_empty === 'true' && params.page === 1) { 668 map.unshift({ 669 text: allow_empty_text === undefined ? '-' : allow_empty_text, 670 id: -1 671 }); 672 673 response.count_filtered++; 674 } 675 676 return { 677 results: map, 678 pagination: { 679 more: (params.page * 10) < response.count_filtered 680 } 681 }; 682 } 683 } 684 }); 685}; 686
687method.initCalendarSelect = function (element, user_id_element, parent) { 688 var self = this; 689 690 if (parent === undefined) { 691 parent = $('body'); 692 } else { 693 parent = $(parent); 694 } 695 696 if (element === undefined) { 697 element = $('#calendar-select'); 698 } else { 699 element = $(element); 700 } 701 702 element.select2({ 703 dropdownParent: parent, 704 width: '100%', 705 language: { 706 'noResults': function () { 707 return "Keine Einträge gefunden"; 708 }, 709 'searching': function () { 710 return "Suche..."; 711 }, 712 loadingMore: function () { 713 return "Lade..."; 714 } 715 }, 716 ajax: { 717 dataType: 'json', 718 type: 'POST', 719 quietMillis: 50, 720 data: function (term) { 721 var data = { 722 doAction: 'doGetCalendars', 723 term: term 724 }; 725 726 if (user_id_element !== undefined && $(user_id_element).length) { 727 data.user_id = $(user_id_element).val(); 728 } 729 730 return data; 731 }, 732 processResults: function (response, params) { 733 params.page = params.page || 1; 734 735 var map = $.map(response.results, function (item) { 736 return { 737 id: item.id, 738 text: item.title 739 }; 740 }); 741 742 var allow_empty = element.attr('data-allow-empty'); 743 var allow_empty_text = element.attr('data-allow-empty-text'); 744 if (allow_empty !== undefined && allow_empty === 'true' && params.page === 1) { 745 map.unshift({ 746 text: allow_empty_text === undefined ? '-' : allow_empty_text, 747 id: -1 748 }); 749 750 response.count_filtered++; 751 } 752 753 return { 754 results: map, 755 pagination: { 756 more: (params.page * 10) < response.count_filtered 757 } 758 }; 759 } 760 } 761 }); 762}; 763 764method.initLicenseSelect = function (element, user_id, parent) { 765 var self = this; 766 767 if (parent === undefined) { 768 parent = $('body'); 769 } else { 770 parent = $(parent); 771 } 772 773 if (element === undefined) { 774 element = $('#license-select'); 775 } else { 776 element = $(element); 777 } 778 779 element.select2({ 780 dropdownParent: parent, 781 width: '100%', 782 language: { 783 'noResults': function () { 784 return "Keine Einträge gefunden"; 785 }, 786 'searching': function () { 787 return "Suche..."; 788 }, 789 loadingMore: function () { 790 return "Lade..."; 791 } 792 }, 793 ajax: { 794 dataType: 'json', 795 type: 'POST', 796 quietMillis: 50, 797 data: function (term) { 798 var data = { 799 'doAction': 'doGetLicenses', 800 term: term 801 }; 802 803 if (user_id !== undefined) { 804 data.user_id = user_id; 805 } 806 807 return data; 808 }, 809 processResults: function (response, params) { 810 params.page = params.page || 1; 811 812 var map = $.map(response.results, function (item) { 813 var disabled = item.user_idf !== null; 814 var text = item.name; 815 816 if (disabled) { 817 text += " (Zugewiesen: " + item.user_email + ")"; 818 } 819 820 return { 821 id: item.id, 822 text: text, 823 disabled: disabled 824 }; 825 }); 826 827 var allow_empty = element.attr('data-allow-empty'); 828 var allow_empty_text = element.attr('data-allow-empty-text'); 829 if (allow_empty !== undefined && allow_empty === 'true' && params.page === 1) { 830 map.unshift({ 831 text: allow_empty_text === undefined ? '-' : allow_empty_text, 832 id: -1 833 }); 834 835 response.count_filtered++; 836 } 837 838 return { 839 results: map, 840 pagination: { 841 more: (params.page * 10) < response.count_filtered 842 } 843 }; 844 } 845 } 846 }); 847}; 848 849method.initTooltips = function () { 850 var self = this; 851 var element = $('[data-toggle="tooltip"]'); 852 853 if ($.fn.tooltip) { 854 element.tooltip('disable'); 855 element.tooltip('dispose'); 856 element.tooltip( 857 { 858 html: true, 859 animation: false 860 } 861 ); 862 } 863 864 if ($.fn.tooltipster) { 865 $('.dynamic-tooltip').tooltipster({ 866 contentCloning: true, 867 trigger: 'hover', 868 contentAsHTML: true, 869 content: '<div class="text-center"><i class="fa fa-spin fa-circle-o-notch"></i></div>', 870 plugins: ['follower'], 871 anchor: 'bottom-left', 872 minWidth: 300, 873 functionBefore: function (instance, helper) { 874 var origin = $(helper.origin); 875 876 if (origin.data('loaded') !== true) { 877 var data = { 878 "doAction": "doGetFileInfo", 879 "link": origin.attr("data-highres") 880 }; 881 882 self.getAjaxData(data, function (resp) { 883 if (resp.error_messages !== undefined && resp.error_messages.length === 0) { 884 instance.content(resp.html); 885 } else { 886 instance.content('<div class="text-center small">Inhalt konnte nicht geladen werden.</div>') 887 } 888 889 origin.data('loaded', true); 890 }, false, false, false); 891 } 892 } 893 }); 894 } 895}; 896 897method.playSound = function () { 898 var self = this; 899 900 var promise = self._sound_goat.get(0).play(); 901 902 if (promise !== undefined) { 903 promise.then(_ => { 904 // Autoplay started! 905 }).catch(e => { 906 console.log(e); 907 // Autoplay was prevented. 908 // Show a "Play" button so that user can start playback. 909 }); 910 } 911}; 912 913method.initSubmitHandler = function () { 914 var self = this; 915 var body = $("body"); 916 917 body 918 .off("click", "button[type='submit'], input[type='submit']") 919 .on("click", "button[type='submit'], input[type='submit']", function (ev) { 920 var form = $(this).closest("form"); 921 922 var rules = {}; 923 var messages = {}; 924 925 /* 926 Minimum 6 characters at least 1 Alphabet and 1 Number: 927 "^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$" 928 929 Minimum 6 characters at least 1 Alphabet, 1 Number and 1 Special Character: 930 "^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&\.])[A-Za-z\d$@$!%*#?&\.]{6,}$" 931 932 Minimum 6 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet and 1 Number: 933 "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,}$" 934 935 Minimum 6 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character: 936 "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&\.])[A-Za-z\d$@$!%*?&\.]{6,}" 937 */ 938 $.validator.addMethod("validPassword", function (value, element) {
939 var requirement_container = $(element).closest("form").find('.requirements'); 940 941 if (value === "") { 942 $(requirement_container).addClass("d-none"); 943 return true; 944 } else { 945 var regex = new RegExp(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&\.])[A-Za-z\d$@$!%*#?&\.]{6,}$/); 946 var check = regex.test(value); 947 948 if (!check && requirement_container.hasClass("d-none")) { 949 $(requirement_container).removeClass("d-none"); 950 } else if (check && !requirement_container.hasClass("d-none")) { 951 $(requirement_container).addClass("d-none"); 952 } 953 954 return check; 955 } 956 }, ""); 957 958 $(form).find('input, select, textarea').each(function () { 959 if ($(this).attr("type") === "password") { 960 if ($(this).attr("name") === "password") { 961 rules[$(this).attr("name")] = { 962 required: $(this).prop("required"), 963 validPassword: $(this).hasClass("val
963idate-password") 964 }; 965 966 messages[$(this).attr("name")] = { 967 required: "Bitte ein Passwort eingeben" 968 } 969 } else if ($(this).attr("name") === "password-confirm") { 970 rules[$(this).attr("name")] = { 971 required: $(this).prop("required"), 972 equalTo: "#password" 973 }; 974 975 messages[$(this).attr("name")] = { 976 required: 'Bitte das Passwort bestätigen', 977 equalTo: 'Passwörter stimmen nicht überein' 978 } 979 } 980 } else { 981 rules[$(this).attr("name")] = { 982 required: $(this).prop("required"), 983 email: $(this).hasClass("validate-email") 984 }; 985 986 messages[$(this).attr("name")] = { 987 required: "Bitte dieses Pflichtfeld ausfüllen",
988 email: $(this).hasClass("validate-email") ? "Bitte eine gültige E-Mail Adresse eingeben" : "" 989 }; 990 } 991 }); 992 993 form.validate({ 994 rules: rules, 995 messages: messages, 996 submitHandler: function (form) { 997 self.submitForm(form) 998 } 999 }); 1000 }); 1001}; 1002 1003method.submitForm = function (form) { 1004 var self = this; 1005 var body = $("body"); 1006 1007 var is_ajax = parseInt($(form).attr("data-ajax")) === 1; 1008 1009 if (!is_ajax) { 1010 form.submit(); 1011 } else { 1012 var route = $(form).attr("action"); 1013 var form_data = new FormData(); 1014 1015 $(form).find('input, select, textarea').each(function () { 1016 if ($(this).is("input")) { 1017 if ($(this).attr("type") === "text") { 1018 form_data.append($(this).attr("name"), $(this).val()); 1019 } else if ($(this).attr("type") === "checkbox") { 1020 form_data.append($(this).attr("name"), $(this).is(":checked")); 1021 } else if ($(this).attr("type") === "file") { 1022 form_data.append($(this).attr("name"), $(this)[0].files[0]); 1023 } else if ($(this).attr("type") === "password") { 1024 form_data.append($(this).attr("name"), $(this).val()); 1025 } else if ($(this).attr("type") === "hidden") { 1026 form_data.append($(this).attr("name"), $(this).val()); 1027 } 1028 } else if ($(this).is("textarea")) { 1029 form_data.append($(this).attr("name"), $(this).val()); 1030 } else if ($(this).is("select")) { 1031 form_data.append($(this).attr("name"), $(this).val()); 1032 } 1033 }); 1034 1035 $.ajax({ 1036 url: route !== undefined ? route : '', 1037 type: 'POST', 1038 dataType: 'json', 1039 contentType: false, 1040 cache: false, 1041 processData: false, 1042 data: form_data, 1043 beforeSend: function () { 1044 self.startLoading(); 1045 }, 1046 error: function (resp) { 1047 self.stopLoading(); 1048 self.addNotification("danger", "Interner Fehler, bitte wenden Sie sich an den Administrator."); 1049 var modal = $('.modal'); 1050 if (modal.hasClass('show')) { 1051 modal.modal("hide"); 1052 } 1053 }, 1054 success: function (resp) { 1055 self.stopLoading(); 1056 self.setNotifications(resp.success_messages, resp.error_messages, resp.warning_messages, resp.info_messages); 1057 1058 if (typeof self.ajaxFinished === "function") { 1059 self.ajaxFinished(resp); 1060 } else { 1061 var modal = $('.modal'); 1062 if (modal.hasClass('show')) { 1063 modal.modal("hide"); 1064 } 1065 } 1066 } 1067 }); 1068 } 1069}; 1070 1071method.getAjaxData = function (data, callback, loading, hide_modals, show_notifications) { 1072 var self = this; 1073 $.ajax({ 1074 type: 'POST', 1075 dataType: 'json', 1076 data: data, 1077 beforeSend: function () { 1078 if (loading === true || loading === undefined) { 1079 self.startLoading(); 1080 } 1081 }, 1082 error: function (resp) { 1083 if (loading === true || loading === undefined) { 1084 self.stopLoading(); 1085 } 1086 1087 if (show_notifications === true || show_notifications === undefined) { 1088 self.addNotification("danger", "Interner Fehler, bitte wenden Sie sich an den Administrator."); 1089 } 1090 1091 if (hide_modals === true || hide_modals === undefined) { 1092 $(".modal").each(function () { 1093 if ($(this).hasClass('show')) { 1094 $(this).modal("hide"); 1095 } 1096 }); 1097 } 1098 1099 callback(resp); 1100 }, 1101 success: function (resp) { 1102 if (loading === true || loading === undefined) { 1103 self.stopLoading(); 1104 } 1105 1106 if (show_notifications === true || show_notifications === undefined) { 1107 self.setNotifications(resp.success_messages, resp.error_messages, resp.warning_messages, resp.info_messages); 1108 } 1109 1110 callback(resp); 1111 1112 if (hide_modals === true || hide_modals === undefined) { 1113 $(".modal").each(function () { 1114 if ($(this).hasClass('show') && resp.error_messages.length === 0) { 1115 $(this).modal("hide"); 1116 } 1117 }); 1118 } 1119 } 1120 }); 1121}; 1122 1123method.startLoading = function (text) { 1124 var loader = $(".ajax-loading"); 1125 loader.removeClass("d-none"); 1126 1127 if (text !== undefined) { 1128 loader.find("h3").html(text); 1129 } 1130}; 1131 1132method.stopLoading = function (delay) { 1133 var loader = $(".ajax-loading"); 1134
1135 delay = delay === undefined ? 0 : delay; 1136 1137 setTimeout(function () { 1138 loader.addClass("d-none"); 1139 loader.find("h3").html(""); 1140 }, delay); 1141}; 1142 1143method.setNotifications = function (success, error, warnings, infos) { 1144 var self = this; 1145 1146 success.reverse(); 1147 error.reverse(); 1148 warnings.reverse(); 1149 infos.reverse(); 1150 1151 setTimeout(function () { 1152 for (var key in success) { 1153 self.addNotification("success", success[key]); 1154 } 1155 1156 for (var key in error) { 1157 self.addNotification("danger", error[key]); 1158 } 1159 1160 for (var key in warnings) { 1161 self.addNotification("warning", warnings[key]); 1162 } 1163 1164 for (var key in infos) { 1165 self.addNotification("info", infos[key]); 1166 } 1167 }, 500); 1168}; 1169 1170method.addNotification = function (type, message) { 1171 var timeout = 0; 1172 if (type === "success") { 1173 message = '<strong>Erfolgreich: </strong>' + message; 1174 timeout = 1500; 1175 } else if (type === "danger") { 1176 message = '<strong>Fehler: </strong>' + message; 1177 } else if (type === "warning") { 1178 message = '<strong>Warnung: </strong>' + message; 1179 } else if (type === "info") { 1180 message = '<strong>Info: </strong>' + message; 1181 } 1182 1183 if ($.fn.pgNotification) { 1184 $('body').pgNotification({ 1185 style: 'simple', 1186 message: message, 1187 position: "top-right", 1188 timeout: timeout, 1189 type: type 1190 }).show(); 1191 } else if ($.notify) { 1192 $.notify({ 1193 message: message 1194 }, { 1195 type: type, 1196 delay: timeout, 1197 z_index: 9999 1198 }); 1199 } else { 1200 alert("FAIL"); 1201 } 1202}; 1203 1204method.openPhotoSwipe = function (selector, index_photo, is_gallery) { 1205 var pswpElement = document.querySelectorAll('.pswp')[0]; 1206 1207 var images = []; 1208 1209 $(selector).each(function (index) { 1210 images.push({ 1211 src: $(this).data("highres"), 1212 w: 0, 1213 h: 0 1214 }); 1215 1216 if (!is_gallery) { 1217 return false; 1218 } 1219 }); 1220 1221 var options = { 1222 shareEl: false, 1223 loop: false, 1224 bgOpacity: 0.8, 1225 index: index_photo, 1226 getThumbBoundsFn: function (index) { 1227 if ($(selector).length !== 0) { 1228 var thumbnail = $(selector).get(index); 1229 1230 var pageYScroll = window.pageYOffset || document.documentElement.scrollTop; 1231 var rect = thumbnail.getBoundingClientRect(); 1232 return {x: rect.left, y: rect.top + pageYScroll, w: rect.width}; 1233 } 1234 } 1235 }; 1236 1237 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images, options); 1238 gallery.listen('gettingData', function (index, item) { 1239 if (item.w < 1 || item.h < 1) { // unknown size 1240 var img = new Image(); 1241 img.onload = function () { // will get size after load 1242 item.w = this.width; // set image width 1243 item.h = this.height; // set image height 1244 gallery.invalidateCurrItems(); // reinit Items 1245 gallery.updateSize(true); // reinit Items 1246 }; 1247 img.src = item.src; // let's download image 1248 } 1249 }); 1250 gallery.init(); 1251}; 1252 1253method.isValidEmail = function (emailAddress) { 1254 var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i); 1255 return pattern.test(emailAddress); 1256}; 1257 1258method.toCamelCase = function (string) { 1259 var camel_case = string.replace(/-./g, (m) => m[1].toUpperCase()); 1260 1261 var first_char = camel_case.substring(0, 1).toUpperCase(); 1262 var tail = camel_case.substring(1); 1263 1264 return first_char + tail; 1265}; 1266 1267 1268 1269
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.