1(function (exports) { 2 const _componentStorage = {}; 3 exports.register = function (name, deps, init) { 4 if (typeof deps === 'function') { 5 init = deps; 6 deps = []; 7 } 8 9 _componentStorage[name] = { 10 deps, 11 init, 12 }; 13 }; 14 15 function runComponent(element, key) { 16 if (!_componentStorage[key]) { 17 console.warn('No component "'+key+'" found'); 18 return; 19 } 20 21 MoyaLoader.all(_componentStorage[key].deps || []).then(_componentStorage[key].init.bind(element, element, { 22 dispatch: function (name, data, bubble) { 23 const event = new CustomEvent(name, { 24 bubbles: !!bubble, 25 detail: data, 26 }); 27 element.dispatchEvent(event); 28 return event.detail; 29 } 30 })); 31 } 32 33 exports.run = function (rootElement) { 34 rootElement = rootElement || document.body; 35 if (!rootElement.querySelectorAll) { 36 return; 37 } 38 const componentElements = Array.from(rootElement.querySelectorAll('[data-moya-component]')); 39 if (rootElement.dataset.moyaComponent) { 40 componentElements.push(rootElement); 41 } 42 43 for (let i = componentElements.length - 1; i >= 0; i--) { 44 let key = componentElements[i].dataset.moyaComponent; 45 let keys = key.indexOf(';') ? key.split(';') : [key]; 46 keys.forEach(runComponent.bind(componentElements[i], componentElements[i])); 47 } 48 }; 49 50 window.addEventListener('DOMContentLoaded', () => { 51 exports.run(); 52 }); 53})(window.MoyaComponents = {}); 54 55(function () { 56 const exports = typeof window === 'undefined' ? global : window; 57 (function (exports) { 58 const _containerStorage = {}; 59 const _lazyInit = {}; 60 let _modifiers = []; 61 exports.set = function (name, obj) { 62 _containerStorage[name] = obj; 63 } 64 exports.addModifier = function (method, modifier) { 65 if (typeof method === 'function') { 66 modifier = method; 67 method = null; 68 } 69 _modifiers.push({ 70 method, 71 modifier, 72 }) 73 } 74 exports._resetModifier = function () { 75 _modifiers = []; 76 } 77 exports.register = function (name, init) { 78 if (typeof init === 'function') { 79 _lazyInit[name] = init; 80 } 81 else { 82 _containerStorage[name] = init; 83 } 84 } 85 exports.get = function (name) { 86 if (_lazyInit[name]) { 87 _containerStorage[name] = _lazyInit[name](exports); 88 delete _lazyInit[name]; 89 } 90 if (_containerStorage[name]) { 91 const obj = _containerStorage[name]; 92 if (_modifiers.length) { 93 for (let i = 0, l = _modifiers.length; i < l; i++) { 94 if (_modifiers[i].method && obj[_modifiers[i].method]) { 95 obj[_modifiers[i].method](_modifiers[i].modifier); 96 } 97 else if (typeof _modifiers[i].modifier === 'function') { 98 _modifiers[i].modifier(obj); 99 } 100 } 101 } 102 return obj; 103 } 104 } 105 })(exports.MoyaContainer = {}); 106})(); 107 108(function (exports) { 109 exports.dispatchEvent = function (event) { 110 document.dispatchEvent(event); 111 return event; 112 } 113 exports.dispatch = function (name, data) { 114 const event = new CustomEvent(name, { 115 bubbles: false, 116 detail: data, 117 }); 118 document.dispatchEvent(event); 119 return event.detail; 120 } 121 122 exports.on = function (name, clb) { 123 document.addEventListener(name, (event => { 124 clb(new Proxy(event.detail, { 125 get(obj, prop) { 126 if (prop === 'preventDefault' || prop === 'stopImmediatePropagation' || prop === 'stopPropagation') { 127 return event[prop].bind(event); 128 } 129 130 return obj[prop]; 131 } 132 })); 133 }), false); 134 } 135})(window.MoyaEventHandler = {}); 136 137(function (exports) { 138 let loadedFiles = []; 139 let loadingFiles = {}; 140 const getStaticVersionFromTheme = () => { 141 const theme = document.querySelector('link[href*="theme.css"]'); 142 if (!theme) { 143 return null; 144 } 145 const match = theme.getAttribute('href').match(/v=([^&]*)/); 146 return match ? match[1] : null; 147 }; 148 const getUrlWithStaticVersion = (url) => { 149 if (url.startsWith('http') || url.startsWith('//')) { 150 return url; 151 } 152 const staticVersion = document.body.dataset.staticVersion ?? getStaticVersionFromTheme(); 153 if (!staticVersion) { 154 return url; 155 } 156 const urlObject = new URL(url, location.origin); 157 urlObject.searchParams.set('v', staticVersion); 158 return urlObject.pathname + '?' + urlObject.searchParams.toString(); 159 }; 160 exports.js = function (src) { 161 return new Promise(function (resolve, reject) { 162 if (loadedFiles.includes(src)) { 163 return resolve(); 164 } 165 if (src in loadingFiles) { 166 loadingFiles[src].push([resolve, reject]); 167 return; 168 } 169
170 loadingFiles[src] = [[resolve, reject]]; 171 const script = document.createElement('script'); 172 script.src = getUrlWithStaticVersion(src); 173 script.type = 'text/javascript'; 174 script.charset = 'utf-8'; 175 script.addEventListener('load', () => { 176 loadedFiles.push(src); 177 loadingFiles[src].forEach(i => i[0]()); 178 }); 179 script.addEventListener('error', () => { 180 // todo better error handling 181 loadedFiles.push(src); 182 loadingFiles[src].forEach(i => i[1]()); 183 }); 184 document.body.appendChild(script); 185 }); 186 } 187 exports.css = function (src) { 188 return new Promise(function (resolve, reject) { 189 if (loadedFiles.includes(src)) { 190 return resolve(); 191 } 192 if (src in loadingFiles) { 193 loadingFiles[src].push([resolve, reject]); 194 return; 195 } 196 197 loadingFiles[src] = [[resolve, reject]]; 198 const link = document.createElement('link'); 199 link.href = getUrlWithStaticVersion(src); 200 link.type = 'text/css'; 201 link.rel = 'stylesheet'; 202 link.addEventListener('load', () => { 203 loadedFiles.push(src); 204 loadingFiles[src].forEach(i => i[0]()); 205 }); 206 link.addEventListener('error', () => { 207 // todo better error handling 208 loadedFiles.push(src); 209 loadingFiles[src].forEach(i => i[1]()); 210 }); 211 document.head.appendChild(link); 212 }); 213 } 214 exports.all = function (files) { 215 const promises = []; 216 files.forEach((file) => { 217 if (file.endsWith('.js')) { 218 promises.push(exports.js(file)); 219 } 220 else if (file.endsWith('.css')) { 221 promises.push(exports.css(file)); 222 } 223 else { 224 console.warn('Loader don\'t support file ending with "' + file + '"'); 225 } 226 }); 227 return Promise.all(promises); 228 } 229})(window.MoyaLoader = {}); 230 231/** 232 * Autogenerated file don't modify 233 */ 234(function () { 235var __bundle = (function (exports) { 236 'use strict'; 237 238 const defaultClassNames = { 239 container: 'moya-select', 240 title: 'moya-select--title', 241 list: 'moya-select--list', 242 optGroup: 'moya-select--optgroup', 243 open: 'is-open', 244 dropdown: 'moya-select--dropdown', 245 search: 'moya-select--search-input', 246 searchWrap: 'moya-select--search-wrap', 247 pseudoSelected: 'pseudo-selected', 248 }; 249 var ActionKeyCodes; 250 (function (ActionKeyCodes) { 251 ActionKeyCodes["Enter"] = "Enter"; 252 ActionKeyCodes["ArrowUp"] = "ArrowUp"; 253 ActionKeyCodes["ArrowDown"] = "ArrowDown"; 254 ActionKeyCodes["Escape"] = "Escape"; 255 ActionKeyCodes["Tab"] = "Tab"; 256 })(ActionKeyCodes || (ActionKeyCodes = {})); 257 const instances = {}; 258 document.body.addEventListener('click', (e) => { 259 for (let key in instances) { 260 if (!instances.hasOwnProperty(key)) { 261 continue; 262 } 263 let instance = instances[key]; 264 if (instance.isOpen() && !instance.getContainer().contains(e.target)) { 265 instance.close(); 266 } 267 } 268 }); 269 class CustomSelect { 270 constructor(config, classNames) { 271 var _a; 272 this.options = []; 273 this.elem = config.elem; 274 this.bubbles = (_a = config.bubbles) !== null && _a !== void 0 ? _a : false; 275 this.hasSearch = config.hasSearch; 276 this.classNames = Object.assign(defaultClassNames, classNames); 277 this.key = config.key; 278 this.labelElm = document.querySelector(`label[for="${this.elem.id}"]`); 279 if (this.labelElm) { 280 this.labelElm.id = this.labelElm.getAttribute('for') + '-label'; 281 } 282 } 283 static create(config, classNames) { 284 var _a; 285 config.key = (_a = config.key) !== null && _a !== void 0 ? _a : 'moya-select-' + config.elem.id; 286 let instance = instances[config.key]; 287 if (instance) { 288 if (instance.container.closest('body')) { 289 instance.container.innerHTML = ''; 290 instance.options = []; 291 instance.createHTML(); 292 return instance; 293 } 294 instance.container.parentElement.removeChild(instance.container); 295 } 296 instance = new CustomSelect(config, classNames); 297 instance.createContainer(); 298 instance.createHTML(); 299 instance.delegateEvents(); 300 instances[instance.key] = instance; 301 return instance; 302 } 303 toggle() { 304 if (this.container.classList.contains(this.classNames.open)) { 305 this.close(); 306 } 307 else { 308 this.open(); 309 } 310 } 311 open() { 312 this.container.classList.add(this.classNames.open); 313 this.button.setAttribute('aria-expanded', 'true'); 314 if (this.hasSearch) { 315 this.searchInput.focus(); 316 } 317 else { 318 this.button.focus(); 319 } 320 }
321 close(shouldTriggerChange) { 322 this.container.classList.remove(this.classNames.open); 323 this.button.removeAttribute('aria-expanded'); 324 if (shouldTriggerChange) { 325 const evt = new CustomEvent('change', { bubbles: this.bubbles }); 326 this.elem.dispatchEvent(evt); 327 } 328 } 329 isOpen() { 330 return this.button.hasAttribute('aria-expanded'); 331 } 332 getContainer() { 333 return this.container; 334 } 335 createHTML() { 336 this.createMainButtonHTML(); 337 this.container.appendChild(this.button); 338 if (this.hasSearch) { 339 this.createSearchHTML(); 340 } 341 this.createUlHTML(); 342 this.createOptGroupsHTML(); 343 this.createOptionsHTML(); 344 this.createDropdownHTML(); 345 this.container.appendChild(this.dropdown); 346 // custom select is ready - append it and hide the original 347 this.elem.insertAdjacentElement('afterend', this.container); 348 this.elem.style.display = 'none'; 349 } 350 createDropdownHTML() { 351 const dropdown = document.createElement('div'); 352 dropdown.classList.add(this.classNames.dropdown); 353 if (this.hasSearch) { 354 dropdown.appendChild(this.searchWrap); 355 } 356 dropdown.appendChild(this.ul); 357 this.dropdown = dropdown; 358 } 359 createSearchHTML() { 360 const input = document.createElement('input'); 361 input.classList.add(this.classNames.search); 362 input.type = 'text'; 363 input.autocomplete = 'off'; 364 input.autocapitalize = 'off'; 365 input.spellcheck = false; 366 input.setAttribute('aria-label', 'Filter'); 367 input.setAttribute('aria-expanded', 'true'); 368 input.setAttribute('aria-autocomplete', 'list'); 369 const searchWrap = document.createElement('div'); 370 searchWrap.classList.add(this.classNames.searchWrap); 371 searchWrap.appendChild(input); 372 this.searchInput = input; 373 this.searchWrap = searchWrap; 374 } 375 createContainer() { 376 this.container = document.createElement('div'); 377 this.container.className = this.classNames.container; 378 if (this.elem.id) { 379 this.container.id = this.key; 380 } 381 } 382 createMainButtonHTML() { 383 // create main button 384 this.button = document.createElement('button'); 385 this.button.className = this.classNames.title; 386 this.button.textContent = this.elem.options[0].textContent; 387 this.button.id = this.key + '-' + 'button'; 388 if (this.labelElm) { 389 this.button.setAttribute('aria-labelledby', this.labelElm.id + ' ' + this.button.id); 390 } 391 } 392 createUlHTML() { 393 // create ul 394 this.ul = document.createElement('ul'); 395 this.ul.id = this.key + '-list'; 396 this.ul.className = this.classNames.list; 397 this.ul.setAttribute('role', 'listbox'); 398 this.ul.setAttribute('tabindex', '-1'); 399 if (this.labelElm) { 400 this.ul.setAttribute('aria-labelledby', this.labelElm.id); 401 } 402 this.button.setAttribute('aria-haspopup', this.ul.id); 403 if (this.elem.getAttribute('required')) { 404 this.ul.setAttribute('aria-required', 'true'); 405 } 406 } 407 createOptGroupsHTML() { 408 if (!this.getOptGroups().length) { 409 return; 410 } 411 for (let i = 0; i < this.getOptGroups().length; i++) { 412 const div = document.createElement('div'); 413 div.innerHTML = this.getOptGroups()[i].label; 414 div.classList.add(this.classNames.optGroup); 415 this.ul.appendChild(div); 416 this.generateOptions(this.getOptGroups()[i].querySelectorAll('option')); 417 } 418 } 419 createOptionsHTML() { 420 this.generateOptions(this.elem.querySelectorAll(':not(optgroup) > option')); 421 } 422 delegateEvents() { 423 const util = MoyaContainer.get('core.util'); 424 // delegate main button click 425 util.delegate(this.container, 'click', 'button', (e) => { 426 e.preventDefault(); 427 this.toggle(); 428 }); 429 // delegate main button keydown 430 util.delegate(this.container, 'keydown', 'button', (e) => { 431 this.handleKeydownEvent(e); 432 }); 433 if (this.hasSearch) { 434 util.delegate(this.container, 'keydown', ('.' + this.classNames.search), (e) => { 435 this.handleKeydownEvent(e); 436 }); 437 util.delegate(this.container, 'keyup', ('.' + this.classNames.search), (e) => { 438 if (!(e instanceof KeyboardEvent)) { 439 return; 440 } 441 // Don't do searchInput when tab/arrow/enter was pressed 442 if (Array.from(Object.values(ActionKeyCodes)).includes(e.ke
442y)) { 443 return; 444 } 445 this.doSearch(e); 446 }); 447 } 448 // delegate option click 449 util.delegate(this.container, 'click', 'li', (e) => { 450 e.preventDefault(); 451 this.button.focus(); 452 this.updateSelection(e.delegateTarget, e); 453 this.close(true); 454 }); 455 } 456 generateOptions(options) { 457 options.forEach((option, i) => { 458 const li = document.createElement('li'); 459 li.innerHTML = option.innerHTML; 460 li.setAttribute('role', 'option'); 461 li.setAttribute('data-index', i.toString()); 462 li.setAttribute('data-value', option.value); 463 li.id = this.getOptionKey(option); 464 if (this.elem.value === option.value) { 465 li.setAttribute('aria-selected', 'true'); 466 li.classList.add('active'); 467 this.button.innerHTML = option.innerHTML; 468 this.button.setAttribute('aria-activedescendant', li.id); 469 } 470 this.options.push(li); 471 this.ul.appendChild(li); 472 }); 473 } 474 getOptionKey(option) { 475 return this.key + '-' + option.value; 476 } 477 getOptGroups() { 478 return this.elem.getElementsByTagName('optgroup'); 479 } 480 getAriaSelectedOption() { 481 const ret = this.options.filter((option) => { 482 return option.hasAttribute('aria-selected'); 483 }); 484 return ret.length ? ret[0] : null; 485 } 486 updateSelection(option, e, triggerSelect = true) { 487 if (e.type === 'keydown') { 488 option.scrollIntoView(false); 489 } 490 if (triggerSelect) { 491 // Update the value on underlying select element => Triggers change event 492 this.button.innerHTML = option.innerHTML; 493 this.elem.value = option.getAttribute('data-value'); 494 this.options.forEach((opt) => { 495 opt.classList.remove('active'); 496 }); 497 option.classList.add('active'); 498 } 499 // Mark selected option 500 this.options.forEach((option) => { 501 option.removeAttribute('aria-selected'); 502 }); 503 option.setAttribute('aria-selected', 'true'); 504 this.button.setAttribute('aria-activedescendant', option.id); 505 if (this.hasSearch) { 506 this.searchInput.setAttribute('aria-activedescendant', option.id); 507 } 508 } 509 handleKeydownEvent(e) { 510 if (!(e instanceof KeyboardEvent) || e.key === ActionKeyCodes.Tab) { 511 if (this.isOpen()) { 512 this.close(); 513 } 514 return; 515 } 516 const selectedOption = this.getAriaSelectedOption(); 517 if (e.key === ActionKeyCodes.ArrowDown || e.key === ActionKeyCodes.ArrowUp) { 518 e.preventDefault(); 519 if (this.isOpen()) { 520 let option = e.key === ActionKeyCodes.ArrowDown ? 521 selectedOption.nextElementSibling : 522 selectedOption.previousElementSibling; 523 // display none check is done because search hides options 524 while (option && option.style.display === 'none') { 525 option = e.key === ActionKeyCodes.ArrowDown ? 526 option.nextElementSibling : 527 option.previousElementSibling; 528 } 529 if (option) { 530 this.updateSelection(option, e, false); 531 } 532 } 533 else { 534 this.open(); 535 } 536 } 537 else if (e.key === ActionKeyCodes.Enter) { 538 e.preventDefault(); 539 if (this.isOpen()) { 540 const ariaSelectedOption = this.getAriaSelectedOption(); 541 if (ariaSelectedOption) { 542 this.updateSelection(ariaSelectedOption, e); 543 } 544 this.close(true); 545 this.button.focus(); 546 } 547 else { 548 this.open(); 549 } 550 } 551 else if (e.key === ActionKeyCodes.Escape) { 552 e.preventDefault(); 553 if (this.isOpen()) { 554 this.close(); 555 } 556 } 557 } 558 doSearch(e) { 559 const needle = this.searchInput.value.trim().toLowerCase(); 560 const isEmpty = needle === ''; 561 let firstOptionMatch = undefined; 562 this.options.forEach((opt) => { 563 if (isEmpty) { 564 opt.style.removeProperty('display'); 565 return; 566 } 567 const haystack = opt.textContent.trim().toLowerCase(); 568 if (haystack.includes(needle)) { 569 if (!firstOptionMatch) { 570 firstOptionMatch = opt; 571 } 572 opt.style.removeProperty('display'); 573 } 574 else { 575 opt.style.display = 'none'; 576 } 577 }); 578 if (firstOptionMatch) { 579 this.updateSelection(firstOptionMatch, e, false); 580 } 581 } 582 } 583 MoyaComponents.register('core.custom-select', [ 584 '/_moya/styles/libs/custom-select.css', 585 ], (el) => { 586 const bubbles = el.hasAttribute('data-bubbles') ? !!el.getAttribute('data-bubbles') : true; 587 const hasSearch = el.hasAttribute('data-has-search'); 588 if (el instanceof HTMLSelectElement) { 589 const customSelectConfig = { 590 elem: el, 591 bubbles: bubbles, 592 hasSearch: hasSearch, 593 }; 594 CustomSelect.create(customSelectConfig, {}); 595 } 596 else { 597 const selectElements = el.querySelectorAll('select');
598 selectElements.forEach((select) => { 599 const customSelectConfig = { 600 elem: select, 601 bubbles: bubbles, 602 hasSearch: hasSearch, 603 }; 604 CustomSelect.create(customSelectConfig, {}); 605 }); 606 } 607 }); 608 609 exports.CustomSelect = CustomSelect; 610 611 return exports; 612 613})({}); 614 615 if (typeof __bundle === 'undefined') {return;} 616 617 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 618 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 619 window.MoyaContainer.set('core.custom-select', __bundle[Object.keys(__bundle)[0]]); 620 } else { 621 window.MoyaContainer.register('core.custom-select', __bundle); 622 } 623 } 624 625})(); 626//# sourceMappingURL=custom-select.js.map 627 628/** 629 * Autogenerated file don't modify 630 */ 631(function () { 632var __bundle = (function (exports) { 633 'use strict'; 634 635 function getDocumentFromHTMLString(htmlString) { 636 return new DOMParser().parseFromString(htmlString, 'text/html'); 637 } 638 function toFetchOptions(url, method = 'GET', data) { 639 if (typeof url === 'string') { 640 return { 641 url, 642 data, 643 method, 644 }; 645 } 646 return url; 647 } 648 function fetchJson(url, method = 'GET', data) { 649 const options = toFetchOptions(url, method, data); 650 return window.fetch(options.url, { 651 method: options.method || 'GET', 652 mode: 'same-origin', 653 body: options.data, 654 headers: { 655 'Accept': 'application/json', 656 }, 657 }).then(response => response.json()); 658 } 659 function fetchHtml(url, method = 'GET', data) { 660 const options = toFetchOptions(url, method, data); 661 return window.fetch(options.url, { 662 method: options.method || 'GET', 663 mode: 'same-origin', 664 body: options.data, 665 }) 666 .then(response => response.text()) 667 .then(getDocumentFromHTMLString); 668 } 669 function fetchAndReplace(options, element) { 670 return fetchHtml(options).then((doc) => { 671 const newElement = doc.body.firstElementChild; 672 element.parentNode.replaceChild(newElement, element); 673 MoyaComponents.run(newElement); 674 return newElement; 675 }); 676 } 677 MoyaComponents.register('core.fetchLazy', function (element, dispatcher) { 678 const setupEvent = dispatcher.dispatch('fetchLazy.setup', { 679 url: element.dataset.action, 680 mode: element.dataset.mode || 'inject', 681 selector: element.dataset.selector, 682 }, false); 683 const url = setupEvent.url; 684 fetchHtml(url).then((doc) => { 685 let newElement = doc.body.firstElementChild; 686 if (setupEvent.selector) { 687 newElement = doc.querySelector(setupEvent.selector); 688 } 689 if (!newElement) { 690 throw new Error('Component(fetchLazy): Element not found in response'); 691 } 692 const renderEvent = dispatcher.dispatch('fetchLazy.render', { 693 element: newElement, 694 component: element, 695 mode: setupEvent.mode, 696 }); 697 newElement = renderEvent.element; 698 let component = element; 699 if (renderEvent.mode === 'replace') { 700 element.parentNode.replaceChild(newElement, element); 701 component = newElement; 702 } 703 else { 704 element.appendChild(newElement); 705 } 706 MoyaComponents.run(newElement); 707 dispatcher.dispatch('fetchLazy.completed', { 708 element: newElement, 709 component, 710 }); 711 }); 712 }); 713 714 exports.fetchAndReplace = fetchAndReplace; 715 exports.fetchHtml = fetchHtml; 716 exports.fetchJson = fetchJson; 717 718 return exports; 719 720})({}); 721 722 if (typeof __bundle === 'undefined') {return;} 723 724 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 725 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 726 window.MoyaContainer.set('core.fetch', __bundle[Object.keys(__bundle)[0]]); 727 } else { 728 window.MoyaContainer.register('core.fetch', __bundle); 729 } 730 } 731 732})(); 733//# sourceMappingURL=fetch.js.map 734 735/** 736 * Autogenerated file don't modify 737 */ 738(function () { 739(function () { 740 'use strict'; 741 742 MoyaComponents.register('core.file-maxsize', (el) => { 743 var _a; 744 if (!(el instanceof HTMLInputElement) || el.type !== 'file') { 745 return; 746 } 747 const maxSize = parseInt((_a = el.dataset.maxsize) !== null && _a !== void 0 ? _a : '0'); 748 if (maxSize <= 0) { 749 return; 750 } 751 el.addEventListener('change', () => { 752 var _a, _b; 753 const file = (_a = el.files.item(0)) !== null && _a !== void 0 ? _a : null;
754 const size = (_b = file === null || file === void 0 ? void 0 : file.size) !== null && _b !== void 0 ? _b : 0; 755 if (size > maxSize) { 756 const formattedSize = `${(maxSize / 1024 / 1024).toFixed(2)} MB`; 757 alert(`File size exceeds maximum allowed size (${formattedSize}).`); 758 el.value = ''; 759 } 760 }); 761 }); 762 763})(); 764 765 if (typeof __bundle === 'undefined') {return;} 766 767 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 768 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 769 window.MoyaContainer.set('core.file-maxsize', __bundle[Object.keys(__bundle)[0]]); 770 } else { 771 window.MoyaContainer.register('core.file-maxsize', __bundle); 772 } 773 } 774 775})(); 776//# sourceMappingURL=file-maxsize.js.map 777 778/** 779 * Autogenerated file don't modify 780 */ 781(function () { 782(function () { 783 'use strict'; 784 785 MoyaComponents.register('core.form.label-focus', function (el, dispatcher) { 786 const util = MoyaContainer.get('core.util'); 787 const inputTypes = [ 788 'input[type="text"]', 789 'input[type="email"]', 790 'input[type="password"]', 791 'input[type="number"]', 792 'textarea', 793 'select', 794 ]; 795 const inputTypesWithElm = inputTypes.map(type => '.elm ' + type).join(', '); 796 const inputTypesStr = inputTypes.join(', '); 797 const focusEvents = [ 798 'focusin', 799 'input' 800 ]; 801 const addFocus = (e) => { 802 const parent = e.delegateTarget.closest('.elm'); 803 parent.classList.add('focus'); 804 }; 805 focusEvents.forEach((ev) => { 806 util.delegate(el, ev, inputTypesWithElm, addFocus); 807 }); 808 util.delegate(el, 'focusout', inputTypesWithElm, (e) => { 809 const formElement = e.delegateTarget; 810 if (formElement.value === '') { 811 const parent = formElement.closest('.elm'); 812 parent.classList.remove('focus'); 813 } 814 }); 815 el.querySelectorAll(inputTypesStr).forEach((el) => { 816 if (el.value !== '') { 817 const parent = el.closest('.elm'); 818 parent.classList.add('focus'); 819 } 820 }); 821 }); 822 823})(); 824 825 if (typeof __bundle === 'undefined') {return;} 826 827 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 828 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 829 window.MoyaContainer.set('core.form', __bundle[Object.keys(__bundle)[0]]); 830 } else { 831 window.MoyaContainer.register('core.form', __bundle); 832 } 833 } 834 835})(); 836//# sourceMappingURL=form.js.map 837 838/** 839 * Autogenerated file don't modify 840 */ 841(function () { 842var __bundle = (function (exports) { 843 'use strict'; 844 845 var locales = { 846 'se': { 847 currency: { 848 symbol: 'kr', // default currency symbol is '$' 849 format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below) 850 decimal: ',', // decimal point separator 851 thousand: ' ', // thousands separator 852 precision: 2 // decimal places 853 }, 854 number: { 855 precision: 0, // default precision on numbers is 0 856 thousand: ' ', 857 decimal: ',' 858 } 859 }, 860 'is': { 861 currency: { 862 symbol: 'kr.', // default currency symbol is '$' 863 format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below) 864 decimal: ',', // decimal point separator 865 thousand: '.', // thousands separator 866 precision: 0 // decimal places 867 }, 868 number: { 869 precision: 0, // default precision on numbers is 0 870 thousand: '.', 871 decimal: ',' 872 }, 873 }, 874 }; 875 876 let _locale = 'is'; 877 function defaults(object, defs) { 878 object = object || {}; 879 defs = defs || {}; 880 // Iterate over object non-prototype properties: 881 for (let key in defs) { 882 if (defs.hasOwnProperty(key)) { 883 // Replace values with defaults only if undefined (allow empty/zero values): 884 if (object[key] == null)
885 object[key] = defs[key]; 886 } 887 } 888 return object; 889 } 890 function toFixed(value, precision) { 891 const power = Math.pow(10, precision); 892 // Multiply up by precision, round accurately, then divide and use native toFixed() 893 return (Math.round((value + 1e-8) * power) / power).toFixed(precision); 894 } 895 function setLocale(locale) { 896 if (locales[locale]) { 897 _locale = locale; 898 return true; 899 } 900 else { 901 console.warn('Configuration for locale "' + locale + '" not found'); 902 } 903 return false; 904 } 905 function formatNumber(number, precision, thousand, decimal) { 906 // Build options object from second param (if object) or all params, extending defaults: 907 const opts = defaults({ 908 precision: precision, 909 thousand: thousand, 910 decimal: decimal 911 }, locales[_locale].number), 912 // Do some calc: 913 negative = number < 0 ? "-" : "", base = parseInt(toFixed(Math.abs(number || 0), opts.precision), 10) + "", mod = base.length > 3 ? base.length % 3 : 0; 914 // Format the number: 915 return negative + 916 (mod ? base.substr(0, mod) + opts.thousand : "") + 917 base.substr(mod).replace(/(\d{3})(?=\d)/g, "$1" + opts.thousand) + 918 (opts.precision ? opts.decimal + toFixed(Math.abs(number), opts.precision).split('.')[1] : ""); 919 } 920 function formatMoney(number, symbol) { 921 // Build options object from second param (if object) or all params, extending defaults: 922 const opts = defaults((symbol && Object.prototype.toString.call(symbol) === '[object Object]' ? symbol : { symbol: symbol }), locales[_locale].currency); 923 const format = opts.format; 924 // Choose which format to use for this value: 925 const useFormat = number > 0 ? format : number < 0 ? format.replace("-", "").replace("%v", "-%v") : format; 926 // Return with currency symbol added: 927 return useFormat 928 .replace('%s', opts.symbol) 929 .replace('%v', formatNumber(Math.abs(number), opts.precision, opts.thousand, opts.decimal)); 930 } 931 function addLocale(locale, format) { 932 locales[locale] = format; 933 } 934 935 exports.addLocale = addLocale; 936 exports.formatMoney = formatMoney; 937 exports.formatNumber = formatNumber; 938 exports.setLocale = setLocale; 939 940 return exports; 941 942})({}); 943 944 if (typeof __bundle === 'undefined') {return;} 945 946 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 947 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 948 window.MoyaContainer.set('core.formatter', __bundle[Object.keys(__bundle)[0]]); 949 } else { 950 window.MoyaContainer.register('core.formatter', __bundle); 951 } 952 } 953 954})(); 955//# sourceMappingURL=formatter.js.map 956 957/** 958 * Autogenerated file don't modify 959 */ 960(function () { 961var __bundle = (function () { 962 'use strict'; 963 964 var locales = { 965 'se': { 966 currency: { 967 symbol: 'kr', // default currency symbol is '$' 968 format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below) 969 decimal: ',', // decimal point separator 970 thousand: ' ', // thousands separator 971 precision: 2 // decimal places 972 }, 973 number: { 974 precision: 0, // default precision on numbers is 0 975 thousand: ' ', 976 decimal: ',' 977 } 978 }, 979 'is': { 980 currency: { 981 symbol: 'kr.', // default currency symbol is '$' 982 format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below) 983 decimal: ',', // decimal point separator 984 thousand: '.', // thousands separator 985 precision: 0 // decimal places 986 }, 987 number: { 988 precision: 0, // default precision on numbers is 0 989 thousand: '.',
990 decimal: ',' 991 }, 992 }, 993 }; 994 995 return locales; 996 997})(); 998 999 if (typeof __bundle === 'undefined') {return;} 1000 1001 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 1002 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 1003 window.MoyaContainer.set('core.locales', __bundle[Object.keys(__bundle)[0]]); 1004 } else { 1005 window.MoyaContainer.register('core.locales', __bundle); 1006 } 1007 } 1008 1009})(); 1010//# sourceMappingURL=locales.js.map 1011 1012/** 1013 * Autogenerated file don't modify 1014 */ 1015(function () { 1016var __bundle = (function (exports) { 1017 'use strict'; 1018 1019 let els = []; 1020 function setHeight() { 1021 els.forEach(el => { 1022 if (el.style.maxHeight !== el.scrollHeight) { 1023 el.style.maxHeight = el.scrollHeight + 'px'; 1024 } 1025 }); 1026 } 1027 let timeout; 1028 window.addEventListener('resize', () => { 1029 if (timeout) { 1030 window.cancelAnimationFrame(timeout); 1031 } 1032 timeout = window.requestAnimationFrame(setHeight); 1033 }); 1034 window.addEventListener('load', setHeight); 1035 MoyaComponents.register('core.max-height', function (el) { 1036 if (el.dataset.maxHeightSelector) { 1037 els.push(...el.querySelectorAll(el.dataset.maxHeightSelector)); 1038 } 1039 else { 1040 els.push(el); 1041 } 1042 setHeight(); 1043 }); 1044 function init(selector) { 1045 els.push(...document.body.querySelectorAll(selector)); 1046 } 1047 function reset() { 1048 els = []; 1049 } 1050 1051 exports.init = init; 1052 exports.reset = reset; 1053 1054 return exports; 1055 1056})({}); 1057 1058 if (typeof __bundle === 'undefined') {return;} 1059 1060 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 1061 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 1062 window.MoyaContainer.set('core.max-height', __bundle[Object.keys(__bundle)[0]]); 1063 } else { 1064 window.MoyaContainer.register('core.max-height', __bundle); 1065 } 1066 } 1067 1068})(); 1069//# sourceMappingURL=max-height.js.map 1070 1071/** 1072 * Autogenerated file don't modify 1073 */ 1074(function () { 1075var __bundle = (function (exports) { 1076 'use strict'; 1077 1078 var OverlayStyle; 1079 (function (OverlayStyle) { 1080 OverlayStyle["DARK"] = "dark"; 1081 OverlayStyle["LIGHT"] = "light"; 1082 })(OverlayStyle || (OverlayStyle = {})); 1083 var OverlayLoading; 1084 (function (OverlayLoading) { 1085 OverlayLoading["SPINNER"] = "spinner"; 1086 OverlayLoading["NONE"] = "none"; 1087 })(OverlayLoading || (OverlayLoading = {})); 1088 ({ 1089 [OverlayLoading.SPINNER]: '<div class="lds-ring"><div></div><div></div><div></div><div></div></div>', 1090 [OverlayLoading.NONE]: '', 1091 }); 1092 1093 const fetch = MoyaContainer.get('core.fetch'); 1094 MoyaComponents.register('core.modal', [ 1095 'https://static.stefna.is/js/micromodal/0.4.10/micromodal.min.js', 1096 '/_moya/styles/libs/micromodal.css', 1097 '/_moya/styles/libs/awn.css', 1098 ], function (el, dispatcher) { 1099 if (!(el.dataset.href || el.tagName === 'A')) { 1100 console.error('Element need to have either be an a tag or have data-href attribute'); 1101 return; 1102 } 1103 const options = {}; 1104 if (el.dataset.loading) { 1105 options.loading = el.dataset.loading; 1106 } 1107 if (el.dataset.modalClass) { 1108 options.classes = el.dataset.modalClass.split(' '); 1109 } 1110 if (el.dataset.modalDelay) { 1111 options.delay = parseInt(el.dataset.modalDelay, 10); 1112 } 1113 if (el.dataset.modalPreventScroll) { 1114 options.preventBodyScroll = !!parseInt(el.dataset.modalPreventScroll, 10); 1115 } 1116 if (el.dataset.modalDisableOverlayClose) { 1117 options.disableOverlayClose = !!parseInt(el.dataset.modalDisableOverlayClose, 10); 1118 } 1119 if (el.dataset.modalClosingDelay) { 1120 options.closingDelay = parseInt(el.dataset.modalClosingDelay, 10); 1121 } 1122 el.addEventListener('click', (e) => { 1123 e.preventDefault(); 1124 const event = dispatcher.dispatch('modal.preFetch', { 1125 url: el.dataset.href || el.getAttribute('href'), 1126 options 1127 }); 1128 open(event.url, event.options).then((modal) => { 1129 dispatcher.dispatch('modal.opened', { 1130 modal 1131 }, true); 1132 }); 1133 }); 1134 }); 1135 MoyaEventHandler.on('modal.show', (e) => { 1136 if ((!e.options.hasOwnProperty('preventBodyScroll') && document.body.dataset.modalPreventScroll) || e.options.preventBodyScroll) { 1137 document.documentElement.classList.add('prevent-scroll'); 1138 } 1139 }); 1140 MoyaEventHandler.on('modal.hide', () => { 1141 document.documentElement.classList.remove('prevent-scroll'); 1142 }); 1143 const modalHtml = '<div class="moya-modal__overlay" tabindex="-1" data-micromodal-close=""><div><div class="moya-modal__container" role="dialog" aria-modal="true"><div class="moya-modal__content"></div>
1143<button aria-label="Close modal" data-micromodal-close="" class="moya-modal__close">â</button></div></div></div>'; 1144 let modalCount = 1; 1145 function createModalElement(html) { 1146 const root = document.createElement('div'); 1147 root.id = 'modal-id-' + (modalCount++); 1148 root.className = 'moya-modal moya-modal--dark'; 1149 root.innerHTML = modalHtml; 1150 root.setAttribute('aria-hidden', "true"); 1151 const content = root.querySelector('.moya-modal__content'); 1152 if (html instanceof HTMLElement) { 1153 content.appendChild(html); 1154 } 1155 else { 1156 content.innerHTML = html; 1157 } 1158 content.dataset.modal = root.id; 1159 const formControl = content.querySelector('#cancel'); 1160 if (formControl) { 1161 formControl.setAttribute('data-micromodal-close', ''); 1162 formControl.removeAttribute('onclick'); 1163 } 1164 document.body.appendChild(root); 1165 return content; 1166 } 1167 function close(modalId) { 1168 MicroModal.close(modalId); 1169 } 1170 function get(modalId) { 1171 const element = document.getElementById(modalId); 1172 if (element) { 1173 return { 1174 close: MicroModal.close.bind(this, element.dataset.modal), 1175 element: element.querySelector('.moya-modal__content'), 1176 }; 1177 } 1178 throw new Error('No modal found with id: ' + modalId); 1179 } 1180 function open(url, options) { 1181 return MoyaContainer.get('core.overlay').execute((overlay) => { 1182 overlay.show(options.loading || OverlayLoading.SPINNER); 1183 return fetch.fetchHtml(url).then((response) => { 1184 const element = createModalElement(response.body.innerHTML); 1185 if (options.classes) { 1186 element.parentElement.classList.add(...options.classes); 1187 } 1188 if (options.disableOverlayClose) { 1189 const modalOverlay = element.closest('.moya-modal__overlay'); 1190 if (modalOverlay) { 1191 modalOverlay.removeAttribute('data-micromodal-close'); 1192 } 1193 } 1194 return new Promise((resolve) => { 1195 setTimeout(() => { 1196 overlay.hide(); 1197 const modalObject = { 1198 close: MicroModal.close.bind(this, element.dataset.modal), 1199 element, 1200 }; 1201 MicroModal.show(element.dataset.modal, { 1202 onShow: () => MoyaEventHandler.dispatch('modal.show', { modal: modalObject, options }), 1203 onClose: () => { 1204 MoyaEventHandler.dispatch('modal.hide', { modal: modalObject, options }); 1205 const wrapper = document.getElementById(element.dataset.modal); 1206 if (wrapper) { 1207 if (options.closingDelay) { 1208 setTimeout(() => { 1209 wrapper.parentElement.removeChild(wrapper); 1210 }, options.closingDelay); 1211 } 1212 else { 1213 wrapper.parentElement.removeChild(wrapper); 1214 } 1215 } 1216 } 1217 }); 1218 MoyaComponents.run(element); 1219 resolve(modalObject); 1220 }, options.delay || 0); 1221 }); 1222 }); 1223 }); 1224 } 1225 function show(element, options) { 1226 return new Promise((resolve) => { 1227 MoyaContainer.get('core.overlay').execute((overlay) => { 1228 if (options.delay || 0) { 1229 overlay.show(options.loading || OverlayLoading.SPINNER); 1230 } 1231 const modal = createModalElement(element); 1232 if (options.classes) { 1233 modal.parentElement.classList.add(...options.classes); 1234 } 1235 setTimeout(() => { 1236 if (options.delay || 0) { 1237 overlay.hide(); 1238 } 1239 const modalObject = { 1240 close: MicroModal.close.bind(this, element.dataset.modal), 1241 element, 1242 }; 1243 MicroModal.show(modal.dataset.modal, { 1244 onShow: () => MoyaEventHandler.dispatch('modal.show', { modal: modalObject, options }), 1245 onClose: () => { 1246 MoyaEventHandler.dispatch('modal.hide', { modal: modalObject, options }); 1247 const wrapper = document.getElementById(modal.dataset.modal); 1248 if (wrapper) { 1249 wrapper.parentElement.removeChild(wrapper); 1250 } 1251 } 1252 }); 1253 MoyaComponents.run(modal); 1254 resolve(modalObject); 1255 }, options.delay || 0); 1256 }); 1257 }); 1258 } 1259 1260 exports.close = close; 1261 exports.get = get; 1262 exports.open = open; 1263 exports.show = show; 1264 1265 return exports; 1266 1267})({}); 1268 1269 if (typeof __bundle === 'undefined') {return;} 1270 1271 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 1272 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 1273 window.MoyaContainer.set('core.modal', __bundle[Object.keys(__bundle)[0]]); 1274 } else { 1275 window.MoyaContainer.register('core.modal', __bundle); 1276 } 1277 } 1278 1279})(); 1280//# sourceMappingURL=modal.js.map 1281 1282/** 1283 * Autogenerated file don't modify 1284 */ 1285(function () { 1286var __bundle = (function (exports) { 1287 'use strict'; 1288 1289 var Type; 1290 (function (Type) { 1291 Type["SUCCESS"] = "success"; 1292 Type["ERROR"] = "alert"; 1293 Type["WARNING"] = "warning"; 1294 Type["INFO"] = "info"; 1295 Type["TIP"] = "tip"; 1296 })(Type || (Type = {})); 1297 exports.NotificationPosition = void 0; 1298 (function (NotificationPosition) { 1299 NotificationPosition["TOP_LEFT"] = "top-left"; 1300 NotificationPosition["TOP_RIGHT"] = "top-right"; 1301 NotificationPosition["BOTTOM_LEFT"] = "bottom-left"; 1302 NotificationPosition["BOTTOM_RIGHT"] = "bottom-right"; 1303 })(exports.NotificationPosition || (exports.NotificationPosition = {})); 1304 function toAWNOptions(type, title, options) { 1305 let returnOptions = { durations: {}, labels: {}, icons: {} }; 1306 returnOptions.labels[type] = title; 1307 if (options.position) { 1308 returnOptions.position = options.position; 1309 } 1310 if (options.duration) { 1311 returnOptions.durations[type] = options.duration; 1312 } 1313 if (options.animationDuration) { 1314 returnOptions.animationDuration = options.animationDuration; 1315 } 1316 if (options.icons) { 1317 returnOptions.icons.enabled = options.icons.enabled; 1318 returnOptions.icons[type] = options.icons.icon; 1319 } 1320 return returnOptions; 1321 } 1322 function showNotification(type, title, options) { 1323 const awnOptions = toAWNOptions(type, title, options); 1324 return new AWN(awnOptions)[type](wrapMessage(options), awnOptions); 1325 } 1326 function wrapMessage(options) { 1327 if (!options.message) { 1328 return ' '; 1329 } 1330 const wrapper = document.createElement('div'); 1331 if (options.image) { 1332 const imageWrap = document.createElement('div'); 1333 imageWrap.classList.add('notification-image'); 1334 wrapper.appendChild(imageWrap); 1335 const image = document.createElement('img'); 1336 image.setAttribute('src', options.image); 1337 imageWrap.appendChild(image); 1338 } 1339 const message = document.createElement('div'); 1340 message.innerHTML = options.message; 1341 message.classList.add('notification-message'); 1342 wrapper.appendChild(message); 1343 if (options.buttons) { 1344 const buttonsWrap = document.createElement('div'); 1345 buttonsWrap.classList.add('notification-buttons'); 1346 wrapper.appendChild(buttonsWrap); 1347 options.buttons.forEach((button) => { 1348 button.tag = button.tag || 'a'; 1349 const buttonElm = document.createElement(button.tag); 1350 buttonElm.innerText = button.label; 1351 if (button.tag === 'a') { 1352 buttonElm.setAttribute('href', button.href); 1353 if (button.target) { 1354 buttonElm.setAttribute('target', button.target); 1355 } 1356 } 1357 buttonElm.classList.add('notification-button'); 1358 if (button.classes) { 1359 buttonElm.classList.add(...button.classes); 1360 } 1361 buttonsWrap.appendChild(buttonElm); 1362 }); 1363 } 1364 return wrapper.innerHTML; 1365 } 1366 function closeAll() { 1367 AWN.closeAll(); 1368 } 1369 function success(title, options = {}) { 1370 return showNotification(Type.SUCCESS, title, options); 1371 } 1372 function error(title, options = {}) { 1373 return showNotification(Type.ERROR, title, options); 1374 } 1375 function warning(title, options = {}) { 1376 return showNotification(Type.WARNING, title, options); 1377 } 1378 function info(title, options = {}) { 1379 return showNotification(Type.INFO, title, options); 1380 } 1381 1382 exports.closeAll = closeAll; 1383 exports.error = error; 1384 exports.info = info; 1385 exports.success = success; 1386 exports.warning = warning; 1387 1388 return exports; 1389 1390})({}); 1391 1392 if (typeof __bundle === 'undefined') {return;} 1393 1394 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 1395 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 1396 window.MoyaContainer.set('core.notification', __bundle[Object.keys(__bundle)[0]]); 1397 } else { 1398 window.MoyaContainer.register('core.notification', __bundle); 1399 } 1400 } 1401 1402})(); 1403//# sourceMappingURL=notification.js.map 1404 1405/** 1406 * Autogenerated file don't modify 1407 */ 1408(function () { 1409var __bundle = (function (exports) { 1410 'use strict'; 1411 1412 exports.OverlayStyle = void 0; 1413 (function (OverlayStyle) { 1414 OverlayStyle["DARK"] = "dark"; 1415 OverlayStyle["LIGHT"] = "light"; 1416 })(exports.OverlayStyle || (exports.OverlayStyle = {})); 1417 exports.OverlayLoading = void 0; 1418 (function (OverlayLoading) { 1419 OverlayLoading["SPINNER"] = "spinner"; 1420 OverlayLoading["NONE"] = "none"; 1421 })(exports.OverlayLoading || (exports.OverlayLoading = {})); 1422 const OverlayLoadingStyles = { 1423 [exports.OverlayLoading.SPINNER]: '<div class="lds-ring"><div></div><div></div><div></div><div></div></div>', 1424 [exports.OverlayLoading.NONE]: '', 1425 }; 1426 class OverlayClass { 1427 constructor(element, options = {}) { 1428 this.options = options; 1429 this.element = element; 1430 MoyaLoader.css('/_moya/styles/libs/micromodal.css'); 1431 } 1432 createOverlay() { 1433 const root = document.createElement('div'); 1434 root.setAttribute('aria-hidden', "true"); 1435 root.className = 'moya-modal'; 1436 if (this.options.style) { 1437 root.classList.add('moya-modal--' + this.options.style); 1438 } 1439 const overlayDiv = document.createElement('div'); 1440 overlayDiv.className = 'moya-modal__overlay'; 1441 overlayDiv.tabIndex = -1; 1442 if (this.options.hideOnClick) { 1443 overlayDiv.setAttribute('data-micromodal-close', ""); 1444 } 1445 root.appendChild(overlayDiv); 1446 const container = document.createElement('div'); 1447 container.className = 'moya-modal__container moya-modal__overlay-text'; 1448 container.setAttribute('role', 'dialog'); 1449 container.setAttribute('aria-modal', 'true'); 1450 overlayDiv.appendChild(container); 1451 this.element.appendChild(root);
1452 this.overlay = root; 1453 this.elementPosition = window.getComputedStyle(this.element).position; 1454 } 1455 show(message) { 1456 if (!this.overlay) { 1457 this.createOverlay(); 1458 } 1459 message = message || this.options.message; 1460 const preDefined = OverlayLoadingStyles[message] || null; 1461 if (preDefined) { 1462 message = preDefined; 1463 } 1464 this.overlay.firstElementChild.firstElementChild.innerHTML = message || ''; 1465 this.overlay.classList.add('is-open'); 1466 if (this.elementPosition === 'static') { 1467 this.element.style.position = 'relative'; 1468 } 1469 } 1470 hide() { 1471 this.overlay.classList.remove('is-open'); 1472 if (this.elementPosition === 'relative') { 1473 this.element.style.position = ''; 1474 } 1475 } 1476 } 1477 let rootOverlay; 1478 function execute(clb) { 1479 if (!rootOverlay) { 1480 rootOverlay = new OverlayClass(document.body, { hideOnClick: false }); 1481 } 1482 return clb(rootOverlay); 1483 } 1484 1485 exports.OverlayClass = OverlayClass; 1486 exports.execute = execute; 1487 1488 return exports; 1489 1490})({}); 1491 1492 if (typeof __bundle === 'undefined') {return;} 1493 1494 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 1495 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 1496 window.MoyaContainer.set('core.overlay', __bundle[Object.keys(__bundle)[0]]); 1497 } else { 1498 window.MoyaContainer.register('core.overlay', __bundle); 1499 } 1500 } 1501 1502})(); 1503//# sourceMappingURL=overlay.js.map 1504 1505/** 1506 * Autogenerated file don't modify 1507 */ 1508(function () { 1509var __bundle = (function (exports) { 1510 'use strict'; 1511 1512 const defaultOptions = { 1513 triggerClickEvent: true, 1514 closeOnBodyClick: true, 1515 closeOnEsc: true, 1516 openingDelay: 400, 1517 closingDelay: 400, 1518 openingClassPostfix: 'opening', 1519 closingClassPostfix: 'closing', 1520 closeOthers: false 1521 }; 1522 const instances = {}; 1523 class Toggle { 1524 static create(toggleElement, openElement, toggleKey, options) { 1525 if (!toggleElement || !openElement || !toggleKey) { 1526 return null; 1527 } 1528 if (instances[toggleKey] && document.body.contains(instances[toggleKey].getToggleElement())) { 1529 return instances[toggleKey]; 1530 } 1531 const toggle = new Toggle(toggleElement, openElement, toggleKey, options); 1532 instances[toggleKey] = toggle; 1533 return toggle; 1534 } 1535 constructor(toggleElement, openElement, toggleKey, options) { 1536 this.shouldStopPropagation = function (e) { 1537 const exceptionClasses = ['fancybox']; 1538 if (e.target instanceof HTMLElement) { 1539 for (let i = 0; i < exceptionClasses.length; i++) { 1540 const exceptionClassSelector = '.' + exceptionClasses[i]; 1541 if (e.target.classList.contains(exceptionClasses[i])) { 1542 return false; 1543 } 1544 else { 1545 const closest = e.target.closest(exceptionClassSelector); 1546 if (closest) { 1547 return false; 1548 } 1549 } 1550 } 1551 } 1552 return true; 1553 }; 1554 this.toggleElement = toggleElement; 1555 this.openElement = openElement; 1556 this.toggleKey = toggleKey; 1557 this.options = Object.assign({}, defaultOptions, options || {}); 1558 this.onOpen = options.onOpen || (() => { }); 1559 this.onClose = options.onClose || (() => { }); 1560 this.bodyClassOpen = toggleKey + '-open'; 1561 this.bodyClassOpening = toggleKey + '-opening'; 1562 this.bodyClassClosing = toggleKey + '-closing'; 1563 this.setupAria(); 1564 this.setupToggleElementListeners(); 1565 this.setupOpenElementListeners(); 1566 this.setupBodyListeners(); 1567 } 1568 isOpen() { 1569 return document.body.classList.contains(this.bodyClassOpen); 1570 } 1571 getToggleElement() { 1572 return this.toggleElement; 1573 } 1574 getOpenElement() { 1575 return this.openElement; 1576 } 1577 open() { 1578 if (!document.body.classList.contains(this.bodyClassOpen)) { 1579 document.body.classList.add(this.bodyClassOpen); 1580 } 1581 this.toggleElement.setAttribute('aria-expanded', 'true'); 1582 this.onOpen(this); 1583 if (this.options.openingDelay > 0) { 1584 document.body.classList.add(this.bodyClassOpening); 1585 setTimeout(() => { 1586 document.body.classList.remove(this.bodyClassOpening); 1587 }, this.options.openingDelay); 1588 } 1589 if (this.options.closeOthers === true) { 1590 Array.from(document.body.classList) 1591 .filter(className => className.endsWith('-open')) 1592 .filter(className => className !== this.bodyClassOpen) 1593 .map(className => document.body.classList.remove(className)); 1594 } 1595 } 1596 close() { 1597 document.body.classList.remove(this.bodyClassOpen); 1598 this.toggleElement.setAttribute('aria-expanded', 'false'); 1599 this.onClose(this); 1600 if (this.options.closingDelay > 0) { 1601 document.body.classList.add(this.bodyClassClosing); 1602 setTimeout(() => { 1603 document.body.classList.remove(this.bodyClassClosing); 1604 }, this.options.closingDelay); 1605 } 1606 } 1607 getDefaultOptions() { 1608 return defaultOptions; 1609 } 1610 setupBodyListeners() { 1611 if (this.options.closeOnBodyClick) { 1612 document.addEventListener('click', () => { 1613 if (this.isOpen()) { 1614 this.close(); 1615 } 1616 }); 1617 } 1618 if (this.options.closeOnEsc) { 1619 document.addEventListener('keydown', (e) => { 1620 if (e.code === 'Escape' && this.isOpen()) { 1621 this.close(); 1622 } 1623 }); 1624 } 1625 } 1626 setupOpenElementListeners() { 1627 this.openElement.addEventListener('click', (e) => { 1628 if (this.shouldStopPropagation(e)) { 1629 e.stopPropagation(); 1630 } 1631 }); 1632 } 1633 setupToggleElementListeners() { 1634 if (!this.options.triggerClickEvent) { 1635 return; 1636 } 1637 this.toggleElement.addEventListener('click', (e) => { 1638 e.preventDefault(); 1639 e.stopPropagation(); 1640 document.body.classList.toggle(this.bodyClassOpen); 1641 if (document.body.classList.contains(this.bodyClassOpen)) { 1642 this.open(); 1643 } 1644 else { 1645 this.close(); 1646 } 1647 }); 1648 } 1649 setupAria() { 1650 let openElementId = this.openElement.getAttribute('id'); 1651 if (!openElementId) { 1652 openElementId = this.toggleKey + 'OpenElement'; 1653 this.openElement.setAttribute('id', openElementId); 1654 } 1655 this.toggleElement.setAttribute('aria-haspopup', 'true'); 1656 if (this.options.triggerClickEvent) { 1657 this.toggleElement.setAttribute('aria-controls', openElementId); 1658 } 1659 else { 1660 this.toggleElement.setAttribute('aria-owns', openElementId); 1661 } 1662 } 1663 } 1664 1665 exports.Toggle = Toggle; 1666 1667 return exports; 1668 1669})({}); 1670 1671 if (typeof __bundle === 'undefined') {return;} 1672 1673 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 1674 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 1675 window.MoyaContainer.set('core.toggle', __bundle[Object.keys(__bundle)[0]]); 1676 } else { 1677 window.MoyaContainer.register('core.toggle', __bundle); 1678 } 1679 } 1680 1681})(); 1682//# sourceMappingURL=toggle.js.map 1683 1684/** 1685 * Autogenerated file don't modify 1686 */ 1687(function () { 1688var __bundle = (function (exports) { 1689 'use strict'; 1690 1691 var OverlayStyle; 1692 (function (OverlayStyle) { 1693 OverlayStyle["DARK"] = "dark"; 1694 OverlayStyle["LIGHT"] = "light"; 1695 })(OverlayStyle || (OverlayStyle = {})); 1696 var OverlayLoading; 1697 (function (OverlayLoading) { 1698 OverlayLoading["SPINNER"] = "spinner"; 1699 OverlayLoading["NONE"] = "none"; 1700 })(OverlayLoading || (OverlayLoading = {})); 1701 const OverlayLoadingStyles = { 1702 [OverlayLoading.SPINNER]: '<div class="lds-ring"><div></div><div></div><div></div><div></div></div>', 1703 [OverlayLoading.NONE]: '', 1704 }; 1705 class OverlayClass { 1706 constructor(element, options = {}) { 1707 this.options = options; 1708 this.element = element; 1709 MoyaLoader.css('/_moya/styles/libs/micromodal.css'); 1710 } 1711 createOverlay() { 1712 const root = document.createElement('div'); 1713 root.setAttribute('aria-hidden', "true"); 1714 root.className = 'moya-modal'; 1715 if (this.options.style) { 1716 root.classList.add('moya-modal--' + this.options.style); 1717 } 1718 const overlayDiv = document.createElement('div'); 1719 overlayDiv.className = 'moya-modal__overlay'; 1720 overlayDiv.tabIndex = -1; 1721 if (this.options.hideOnClick) { 1722 overlayDiv.setAttribute('data-micromodal-close', ""); 1723 } 1724 root.appendChild(overlayDiv); 1725 const container = document.createElement('div'); 1726 container.className = 'moya-modal__container moya-modal__overlay-text'; 1727 container.setAttribute('role', 'dialog'); 1728 container.setAttribute('aria-modal', 'true'); 1729 overlayDiv.appendChild(container); 1730 this.element.appendChild(root);
1731 this.overlay = root; 1732 this.elementPosition = window.getComputedStyle(this.element).position; 1733 } 1734 show(message) { 1735 if (!this.overlay) { 1736 this.createOverlay(); 1737 } 1738 message = message || this.options.message; 1739 const preDefined = OverlayLoadingStyles[message] || null; 1740 if (preDefined) { 1741 message = preDefined; 1742 } 1743 this.overlay.firstElementChild.firstElementChild.innerHTML = message || ''; 1744 this.overlay.classList.add('is-open'); 1745 if (this.elementPosition === 'static') { 1746 this.element.style.position = 'relative'; 1747 } 1748 } 1749 hide() { 1750 this.overlay.classList.remove('is-open'); 1751 if (this.elementPosition === 'relative') { 1752 this.element.style.position = ''; 1753 } 1754 } 1755 } 1756 1757 class Uploader { 1758 constructor(container, options) { 1759 this.uploadingFiles = []; 1760 this.container = container; 1761 this.options = options; 1762 this.overlay = new OverlayClass(this.container, { 1763 hideOnClick: false, 1764 message: this.options.lang.uploading, 1765 }); 1766 this.files = [...this.options.initialFiles]; 1767 this.injectStyles(); 1768 this.init(); 1769 } 1770 isValidFile(file) { 1771 return !!(file && file.data && file.data.id !== undefined && file.urls); 1772 } 1773 injectStyles() { 1774 if (Uploader.stylesInjected) 1775 return; 1776 const style = document.createElement('style'); 1777 style.textContent = ` 1778 .moya-uploader { margin-bottom: 30px; font-family: sans-serif; } 1779 .el-upload { width: 100%; cursor: pointer; } 1780 .el-upload-dragger { background-color: #fff; border: 1px dashed #d9d9d9; border-radius: 6px; box-sizing: border-box; width: 100%; height: 180px; text-align: center; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; } 1781 .el-upload-dragger:hover { border-color: #409eff; } 1782 .el-upload-dragger.is-dragover { background-color: rgba(32,159,255,.06); border: 2px dashed #409eff; } 1783 .el-icon-upload { font-size: 67px; color: #c0c4cc; margin: 20px 0 16px; line-height: 50px; } 1784 .el-icon-upload::before { content: "â"; display: block; font-size: 50px; } 1785 .el-upload__text { color: #606266; font-size: 14px; text-align: center; } 1786 .el-upload__text em { color: #409eff; font-style: normal; } 1787 .fa-bars::before { content: "â¡"; } 1788 .fa-trash::before { content: "ð"; } 1789 .file-list, .uploading-list { margin-top: 10px; } 1790 .file { position: relative; border-top: 1px solid #dedede; border-bottom: 1px solid #dedede; display: flex; margin-bottom: -1px; padding: 10px 0; background: #fff; } 1791 .file__handle { display: flex; align-items: center; justify-content: center; padding-right: 15px; padding-left: 15px; font-size: 24px; cursor: grab; } 1792 .file__image { position: relative; flex: 0 0 100px; width: 100px; height: 100px; background-position: center; background-size: cover; background-repeat: no-repeat; border: 1px solid #eee; overflow: hidden; } 1793 .file__image img { width: 100%; height: 100%; object-fit: cover; } 1794 .file__info { flex: 1; padding-left: 15px; display: flex; flex-direction: column; justify-content: center; } 1795 .file__info div { margin-bottom: 5px; font-size: 14px; } 1796 .file__controls { display: flex; align-items: center; padding: 0 15px; } 1797 .file__remove { background-color: #f56c6c; border: none; color: white; padding: 8px; border-radius: 4px; cursor: pointer; font-size: 16px; } 1798 .file__remove:hover { background-color: #f78989; } 1799 .progress-bar { width: 100%; background-color: #ebeef5; border-radius: 100px; height: 6px; margin-top: 10px; overflow: hidden; } 1800 .progress-bar-inner { height: 100%; background-color: #409eff; transition: width 0.3s; } 1801 .file--uploading .file__info { justify-content: flex-start; padding-top: 10px; } 1802 .file__exception { color: #f56c6c; font-size: 12px; margin-top: 5px; } 1803 .file.dragging { opacity: 0.5; background: #f5f7fa; } 1804 `; 1805 document.head.appendChild(style); 1806 Uploader.stylesInjected = true; 1807 } 1808 init() { 1809 this.overlay.show(OverlayLoading.SPINNER); 1810 this.buildBaseDOM(); 1811 this.setupEventListeners(); 1812 this.renderFileList(); 1813 this.overlay.hide(); 1814 } 1815 buildBaseDOM() { 1816 this.container.innerHTML = ''; 1817 const uploaderDiv = document.createElement('div'); 1818 uploaderDiv.className = 'moya-uploader'; 1819 const elUpload = document.createElement('div'); 1820 elUpload.className = 'el-upload el-upload--text'; 1821 this.dropZone = document.createElement('div'); 1822 this.dropZone.className = 'el-upload-dragger'; 1823 const icon = document.createElement('i'); 1824 icon.className = 'el-icon-upload'; 1825 const text = document.createElement('div'); 1826 text.className = 'el-upload__text'; 1827 text.innerHTML = this.options.lang.dropZoneText; 1828 this.dropZone.append(icon, text); 1829 this.fileInput = document.createElement('input'); 1830 this.fileInput.type = 'file'; 1831 this.fileInput.style.display = 'none'; 1832 this.fileInput.multiple = this.options.uploadOptions.multiple; 1833 this.fileInput.name = this.options.uploadOptions.name; 1834 elUpload.append(this.dropZone, this.fileInput); 1835 this.fileListContainer = document.createElement('div'); 1836 this.fileListContainer.className = 'file-list'; 1837 this.uploadingListContainer = document.createElement('div'); 1838 this.uploadingListContainer.className = 'uploading-list'; 1839 uploaderDiv.append(elUpload, this.fileListContainer, this.uploadingListContainer); 1840 this.container.appendChild(uploaderDiv); 1841 } 1842 setupEventListeners() { 1843 this.dropZone.addEventListener('click', () => this.fileInput.click()); 1844 this.fileInput.addEventListener('change', () => { 1845 if (this.fileInput.files) 1846 this.handleFiles(this.fileInput.files); 1847 this.fileInput.value = ''; 1848 }); 1849 this.dropZone.addEventListener('dragover', (e) => { 1850 e.preventDefault(); 1851 this.dropZone.classList.add('is-dragover'); 1852 }); 1853 this.dropZone.addEventListener('dragleave', () => this.dropZone.classList.remove('is-dragover')); 1854 this.dropZone.addEventListener('drop', (e) => { 1855 var _a; 1856 e.preventDefault(); 1857 this.dropZone.classList.remove('is-dragover'); 1858 if ((_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) 1859 this.handleFiles(e.dataTransfer.files); 1860 }); 1861 } 1862 handleFiles(fileList) { 1863 Array.from(fileList).forEach(file => this.uploadFile(file)); 1864 } 1865 uploadFile(file) { 1866 var _a; 1867 const uid = ((_a = crypto.randomUUID) === null || _a === void 0 ? void 0 : _a.call(crypto)) || Math.random().toString(36).substring(2); 1868 const blobUrl = URL.createObjectURL(file); 1869 const uploadingFile = { 1870 uid, 1871 name: file.name, 1872 percentage: 0, 1873 status: 'uploading', 1874 url: blobUrl, 1875 }; 1876 this.uploadingFiles.push(uploadingFile);
1877 this.renderUploadingList(); 1878 const formData = new FormData(); 1879 formData.append(this.options.uploadOptions.name, file); 1880 this.overlay.show(OverlayLoading.SPINNER); 1881 const xhr = new XMLHttpRequest(); 1882 xhr.open('POST', this.options.uploadUrl, true); 1883 xhr.upload.onprogress = (e) => { 1884 if (e.lengthComputable) { 1885 uploadingFile.percentage = (e.loaded / e.total) * 100; 1886 this.updateProgressUI(uid, uploadingFile.percentage); 1887 } 1888 }; 1889 xhr.onload = () => { 1890 this.overlay.hide(); 1891 if (xhr.status >= 200 && xhr.status < 300) { 1892 try { 1893 const response = JSON.parse(xhr.responseText); 1894 if (this.isValidFile(response)) { 1895 this.files.push(response); 1896 this.removeUploadingFile(uid); 1897 this.renderFileList(); 1898 return; 1899 } 1900 } 1901 catch (err) { 1902 console.error('Upload response parsing failed', { 1903 error: err, 1904 uid, 1905 status: xhr.status, 1906 responseText: xhr.responseText, 1907 }); 1908 } 1909 } 1910 this.handleUploadError(uid); 1911 }; 1912 xhr.onerror = () => { 1913 this.overlay.hide(); 1914 this.handleUploadError(uid); 1915 }; 1916 xhr.send(formData); 1917 } 1918 updateProgressUI(uid, percentage) { 1919 const bar = this.container.querySelector(`[data-uid="${uid}"] .progress-bar-inner`); 1920 if (bar) 1921 bar.style.width = `${percentage}%`; 1922 } 1923 handleUploadError(uid) { 1924 const file = this.uploadingFiles.find(f => f.uid === uid); 1925 if (file) { 1926 file.status = 'fail'; 1927 this.renderUploadingList(); 1928 } 1929 } 1930 removeUploadingFile(uid) { 1931 const index = this.uploadingFiles.findIndex(f => f.uid === uid); 1932 if (index > -1) { 1933 URL.revokeObjectURL(this.uploadingFiles[index].url); 1934 this.uploadingFiles.splice(index, 1); 1935 this.renderUploadingList(); 1936 } 1937 } 1938 renderFileList() { 1939 this.fileListContainer.innerHTML = ''; 1940 this.files.forEach((file, index) => { 1941 const row = document.createElement('div'); 1942 row.className = 'file'; 1943 row.draggable = !!this.options.sortUrl; 1944 row.dataset.id = String(file.data.id); 1945 row.dataset.index = String(index); 1946 if (this.options.sortUrl) { 1947 row.appendChild(this.createDragHandle()); 1948 } 1949 const imgContainer = document.createElement('div'); 1950 imgContainer.className = 'file__image'; 1951 const thumbUrl = this.sanitizeURL(file.urls.thumb || file.urls.xs || ''); 1952 if (thumbUrl) { 1953 const img = document.createElement('img'); 1954 img.src = thumbUrl; 1955 img.alt = file.data.title || ''; 1956 imgContainer.appendChild(img); 1957 } 1958 row.appendChild(imgContainer); 1959 const info = document.createElement('div'); 1960 info.className = 'file__info'; 1961 const fields = ['title', 'filename', 'description']; 1962 fields.forEach(field => { 1963 const value = file.data[field]; 1964 if (value) { 1965 const div = document.createElement('div'); 1966 div.textContent = String(value); 1967 info.appendChild(div); 1968 } 1969 }); 1970 row.appendChild(info); 1971 const controls = document.createElement('div'); 1972 controls.className = 'file__controls'; 1973 if (this.options.deleteUrl) { 1974 const btn = document.createElement('button'); 1975 btn.className = 'file__remove'; 1976 btn.title = this.options.lang.deleteBtnTitle; 1977 const trash = document.createElement('i');
1978 trash.className = 'fa fa-trash'; 1979 btn.appendChild(trash); 1980 btn.onclick = () => this.handleDelete(file); 1981 controls.appendChild(btn); 1982 } 1983 row.appendChild(controls); 1984 if (this.options.sortUrl) 1985 this.setupSortEvents(row); 1986 this.fileListContainer.appendChild(row); 1987 }); 1988 } 1989 createDragHandle() { 1990 const handle = document.createElement('div'); 1991 handle.className = 'file__handle'; 1992 const icon = document.createElement('i'); 1993 icon.className = 'fa fa-bars'; 1994 handle.appendChild(icon); 1995 return handle; 1996 } 1997 renderUploadingList() { 1998 this.uploadingListContainer.innerHTML = ''; 1999 this.uploadingFiles.forEach(file => { 2000 const row = document.createElement('div'); 2001 row.className = 'file file--uploading'; 2002 row.dataset.uid = file.uid; 2003 if (this.options.sortUrl) { 2004 const handle = document.createElement('div'); 2005 handle.className = 'file__handle'; 2006 const icon = document.createElement('i'); 2007 icon.className = 'fa fa-bars'; 2008 handle.appendChild(icon); 2009 row.appendChild(handle); 2010 } 2011 const imgContainer = document.createElement('div'); 2012 imgContainer.className = 'file__image'; 2013 imgContainer.style.backgroundImage = `url('${this.sanitizeURL(file.url)}')`; 2014 row.appendChild(imgContainer); 2015 const info = document.createElement('div'); 2016 info.className = 'file__info'; 2017 const progress = document.createElement('div'); 2018 progress.className = 'progress-bar'; 2019 const inner = document.createElement('div'); 2020 inner.className = 'progress-bar-inner'; 2021 inner.style.width = `${file.percentage}%`; 2022 progress.appendChild(inner); 2023 info.appendChild(progress); 2024 if (file.status === 'fail') { 2025 const err = document.createElement('div'); 2026 err.className = 'file__exception'; 2027 err.textContent = this.options.lang.uploadFailed; 2028 info.appendChild(err); 2029 } 2030 row.appendChild(info); 2031 this.uploadingListContainer.appendChild(row); 2032 }); 2033 } 2034 sanitizeURL(url) { 2035 if (!url) 2036 return ''; 2037 try { 2038 const parsed = new URL(url, window.location.origin); 2039 return ['http:', 'https:', 'blob:'].includes(parsed.protocol) ? parsed.href : ''; 2040 } 2041 catch (_a) { 2042 return ''; 2043 } 2044 } 2045 handleDelete(file) { 2046 if (!confirm(this.options.lang.deleteConfirm)) 2047 return; 2048 fetch(`${this.options.deleteUrl}/${encodeURIComponent(file.data.id)}`, { method: 'POST' }) 2049 .then(res => { 2050 if (res.ok) { 2051 this.files = this.files.filter(f => f.data.id !== file.data.id); 2052 this.renderFileList(); 2053 } 2054 }); 2055 } 2056 setupSortEvents(el) { 2057 el.addEventListener('dragstart', (e) => { 2058 var _a; 2059 (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.setData('text/plain', el.dataset.index); 2060 el.classList.add('dragging'); 2061 }); 2062 el.addEventListener('dragend', () => el.classList.remove('dragging')); 2063 el.addEventListener('dragover', (e) => { 2064 e.preventDefault(); 2065 const dragging = this.fileListContainer.querySelector('.dragging'); 2066 if (dragging && dragging !== el) { 2067 const rect = el.getBoundingClientRect(); 2068 const next = (e.clientY - rect.top) / (rect.bottom - rect.top) > 0.5; 2069 this.fileListContainer.insertBefore(dragging, next ? el.nextSibling : el); 2070 } 2071 }); 2072 el.addEventListener('drop', () => this.handleSortUpdate()); 2073 } 2074 handleSortUpdate() { 2075 const rows = Array.from(this.fileListContainer.querySelectorAll('.file')); 2076 this.files = rows.map(row => this.files.find(f => String(f.data.id) === row.dataset.id)).filter((f) => !!f); 2077 this.renderFileList(); 2078 const formData = new FormData();
2079 this.files.forEach(f => formData.append('sort[]', String(f.data.id))); 2080 fetch(this.options.sortUrl, { method: 'POST', body: formData }) 2081 .catch(err => console.error('Sort failed', err)); 2082 } 2083 } 2084 Uploader.stylesInjected = false; 2085 MoyaComponents.register('core.uploader', (el) => { 2086 const uploaderEl = el.querySelector('moya-uploader') || el; 2087 const isIcelandic = moya.lang === 'is'; 2088 const lang = { 2089 uploading: uploaderEl.getAttribute('lang-uploading') || (isIcelandic ? 'Hleð inn' : 'Uploading'), 2090 deleteConfirm: uploaderEl.getAttribute('lang-delete-confirm') || (isIcelandic ? 'Ertu viss um að þú viljir eyða þessari mynd?' : 'Are you sure you want to delete this image?'), 2091 uploadFailed: uploaderEl.getAttribute('lang-upload-failed') || (isIcelandic ? 'Gat ekki skrifað à gagnagrunn' : 'Could not write to database'), 2092 dropZoneText: uploaderEl.getAttribute('lang-dropzone-text') || (isIcelandic ? 'Dragðu skrár hingað inn eða smelltu til að velja' : 'Drop files here or click to upload.'), 2093 deleteBtnTitle: uploaderEl.getAttribute('lang-delete-btn-title') || (isIcelandic ? 'Eyða' : 'Delete'), 2094 }; 2095 const filesAttr = uploaderEl.getAttribute('initial-files'); 2096 let initialFiles = []; 2097 if (filesAttr) { 2098 try { 2099 initialFiles = JSON.parse(filesAttr); 2100 if (!Array.isArray(initialFiles)) { 2101 console.warn('Moya Uploader: "initial-files" is not a JSON array; ignoring value.', filesAttr); 2102 initialFiles = []; 2103 } 2104 } 2105 catch (e) { 2106 console.error('Moya Uploader: failed to parse the "initial-files" attribute. Expected JSON array.', e, filesAttr); 2107 initialFiles = []; 2108 } 2109 } 2110 new Uploader(uploaderEl, { 2111 uploadUrl: uploaderEl.getAttribute('upload-url') || '', 2112 deleteUrl: uploaderEl.getAttribute('delete-url') || '', 2113 sortUrl: uploaderEl.getAttribute('sort-url') || '', 2114 initialFiles, 2115 lang: lang, 2116 uploadOptions: { 2117 name: uploaderEl.getAttribute('upload-name') || 'Filedata', 2118 multiple: uploaderEl.hasAttribute('multiple'), 2119 }, 2120 }); 2121 }); 2122 2123 exports.Uploader = Uploader; 2124 2125 return exports; 2126 2127})({}); 2128 2129 if (typeof __bundle === 'undefined') {return;} 2130 2131 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 2132 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 2133 window.MoyaContainer.set('core.uploader', __bundle[Object.keys(__bundle)[0]]); 2134 } else { 2135 window.MoyaContainer.register('core.uploader', __bundle); 2136 } 2137 } 2138 2139})(); 2140//# sourceMappingURL=uploader.js.map 2141 2142/** 2143 * Autogenerated file don't modify 2144 */ 2145(function () { 2146var __bundle = (function (exports) { 2147 'use strict'; 2148 2149 function delegate(element, event, selector, callback, useCapture = false) { 2150 const listenerFn = function (e) { 2151 e.delegateTarget = e.target.closest(selector); 2152 if (e.delegateTarget) { 2153 callback.call(element, e); 2154 } 2155 }; 2156 element.addEventListener(event, listenerFn, !!useCapture); 2157 return { 2158 destroy() { 2159 element.removeEventListener(event, listenerFn, useCapture); 2160 } 2161 }; 2162 } 2163 // hack to force correct export functionallity 2164 function version() { 2165 return '1.0.0'; 2166 } 2167 2168 exports.delegate = delegate; 2169 exports.version = version; 2170 2171 return exports; 2172 2173})({}); 2174 2175 if (typeof __bundle === 'undefined') {return;} 2176 2177 if (typeof window !== 'undefined' && typeof window.MoyaContainer !== 'undefined') { 2178 if (typeof __bundle === 'object' && Object.keys(__bundle).length === 1) { 2179 window.MoyaContainer.set('core.util', __bundle[Object.keys(__bundle)[0]]); 2180 } else { 2181 window.MoyaContainer.register('core.util', __bundle); 2182 } 2183 } 2184 2185})(); 2186//# sourceMappingURL=util.js.map 2187 2188var AWN;(()=>{var e={628:(e,t,s)=>{"use strict";s.d(t,{default:()=>m});const i={maxNotifications:10,animationDuration:300,position:"bottom-right",labels:{tip:"Tip",info:"Info",success:"Success",warning:"Attention",alert:"Error",async:"Loading",confirm:"Confirmation required",confirmOk:"OK",confirmCancel:"Cancel"},icons:{tip:"question-circle",info:"info-circle",success:"check-circle",warning:"exclamation-circle",alert:"exclamation-triangle",async:"cog fa-spin",confirm:"exclamation-triangle",prefix:"<i class='fa fas fa-fw fa-",suffix:"'></i>",enabled:!0},replacements:{tip:null,info:null,success:null,warning:null,alert:null,async:null,"async-block":null,modal:null,confirm:null,general:{"<script>":"","<\/script>":""}},messages:{tip:"",info:"",success:"Action has been succeeded",warning:"",alert:"Action has been failed",confirm:"This action can't be und
2188one. Continue?",async:"Please, wait...","async-block":"Loading"},formatError(e){if(e.response){if(!e.response.data)return"500 API Server Error";if(e.response.data.errors)return e.response.data.errors.map((e=>e.detail)).join("<br>");if(e.response.statusText)return`${e.response.status} ${e.response.statusText}: ${e.response.data}`}return e.message?e.message:e},durations:{global:5e3,success:null,info:null,tip:null,warning:null,alert:null},minDurations:{async:1e3,"async-block":1e3}};class n{constructor(e={},t=i){Object.assign(this,this.defaultsDeep(t,e))}icon(e){return this.icons.enabled?`${this.icons.prefix}${this.icons[e]}${this.icons.suffix}`:""}label(e){return this.labels[e]}duration(e){let t=this.durations[e];return null===t?this.durations.global:t}toSecs(e){return e/1e3+"s"}applyReplacements(e,t){if(!e)return this.messages[t]||"";for(const s of["general",t])if(this.replacements[s])for(const t in this.replacements[s])e=e.replace(t,this.replacements[s][t]);return e}override(e){return e?new n(e,this):this}defaultsDeep(e,t){let s={};for(const i in e)t.hasOwnProperty(i)?s[i]="object"==typeof e[i]&&null!==e[i]?this.defaultsDeep(e[i],t[i]):t[i]:s[i]=e[i];return s}}const r="awn-popup",a="awn-toast",o="awn-btn",l="awn-confirm",c={prefix:a,klass:{label:`${a}-label`,content:`${a}-content`,icon:`${a}-icon`,progressBar:`${a}-progress-bar`,progressBarPause:`${a}-progress-bar-paused`},ids:{container:`${a}-container`}},d={prefix:r,klass:{buttons:"awn-buttons",button:o,successBtn:`${o}-success`,cancelBtn:`${o}-cancel`,title:`${r}-title`,body:`${r}-body`,content:`${r}-content`,dotAnimation:`${r}-loading-dots`},ids:{wrapper:`${r}-wrapper`,confirmOk:`${l}-ok`,confirmCancel:`${l}-cancel`}},h={hiding:"awn-hiding"},u=class{constructor(e,t,s,i,n){this.newNode=document.createElement("div"),t&&(this.newNode.id=t),s&&(this.newNode.className=s),i&&(this.newNode.style.cssText=i),this.parent=e,this.options=n}beforeInsert(){}afterInsert(){}insert(){return this.beforeInsert(),this.el=this.parent.appendChild(this.newNode),this.afterInsert(),this}replace(e){if(this.getElement())return this.beforeDelete().then((()=>(this.updateType(e.type),this.parent.replaceChild(e.newNode,this.el),this.el=this.getElement(e.newNode),this.afterInsert(),this)))}beforeDelete(e=this.el){let t=0;return this.start&&(t=this.options.minDurations[this.type]+this.start-Date.now(),t<0&&(t=0)),new Promise((s=>{setTimeout((()=>{e.classList.add(h.hiding),setTimeout(s,this.options.animationDuration)}),t)}))}delete(e=this.el){return this.getElement(e)?this.beforeDelete(e).then((()=>{e.remove(),this.afterDelete()})):null}afterDelete(){}getElement(e=this.el){return e?document.getElementById(e.id):null}addEvent(e,t){this.el.addEventListener(e,t)}toggleClass(e){this.el.classList.toggle(e)}updateType(e){this.type=e,this.duration=this.options.duration(this.type)}},p=class extends u{constructor(e,t,s,i){super(i,`${c.prefix}-${Math.floor(Date.now()-100*Math.random())}`,`${c.prefix} ${c.prefix}-${t}`,`animation-duration: ${s.toSecs(s.animationDuration)};`,s),this.updateType(t),this.setInnerHtml(e)}setInnerHtml(e){"alert"===this.type&&e&&(e=this.options.formatError(e)),e=this.options.applyReplacements(e,this.type),this.newNode.innerHTML=`<div class="awn-toast-wrapper">${this.progressBar}${this.label}<div class="${c.klass.content}">${e}</div><span class="${c.klass.icon}">${this.options.icon(this.type)}</span></div>`}beforeInsert(){if(this.parent.childElementCount>=this.options.maxNotifications){let e=Array.from(this.parent.getElementsByClassName(c.prefix));this.delete(e.find((e=>!this.isDeleted(e))))}}afterInsert(){if("async"==this.type)return this.start=Date.now();if(this.addEvent("click",(()=>this.delete())),!(this.duration<=0)){this.timer=new class{constructor(e,t){this.callback=e,this.remaining=t,this.resume()}pause(){this.paused=!0,window.clearTimeout(this.timerId),this.remaining-=new Date-this.start}resume(){this.paused=!1,this.start=new Date,window.clearTimeout(this.timerId),this.timerId=window.setTimeout((()=>{window.clearTimeout(this.timerId),this.callback()}),this.remaining)}toggle(){this.paused?this.resume():this.pause()}}((()=>this.delete()),this.duration);for(const e of["mouseenter","mouseleave"])this.addEvent(e,(()=>{this.isDeleted()||(this.toggleClass(c.klass.progressBarPause),this.timer.toggle(
2188))}))}}isDeleted(e=this.el){return e.classList.contains(h.hiding)}get progressBar(){return this.duration<=0||"async"===this.type?"":`<div class='${c.klass.progressBar}' style="animation-duration:${this.options.toSecs(this.duration)};"></div>`}get label(){return`<b class="${c.klass.label}">${this.options.label(this.type)}</b>`}},f=class extends u{constructor(e,t="modal",s,i,n){let r=`animation-duration: ${s.toSecs(s.animationDuration)};`;super(document.body,d.ids.wrapper,null,r,s),this[d.ids.confirmOk]=i,this[d.ids.confirmCancel]=n,this.className=`${d.prefix}-${t}`,["confirm","async-block","modal"].includes(t)||(t="modal"),this.updateType(t),this.setInnerHtml(e),this.insert()}setInnerHtml(e){let t=this.options.applyReplacements(e,this.type);switch(this.type){case"confirm":let e=[`<button class='${d.klass.button} ${d.klass.successBtn}'id='${d.ids.confirmOk}'>${this.options.labels.confirmOk}</button>`];!1!==this[d.ids.confirmCancel]&&e.push(`<button class='${d.klass.button} ${d.klass.cancelBtn}'id='${d.ids.confirmCancel}'>${this.options.labels.confirmCancel}</button>`),t=`${this.options.icon(this.type)}<div class='${d.klass.title}'>${this.options.label(this.type)}</div><div class="${d.klass.content}">${t}</div><div class='${d.klass.buttons} ${d.klass.buttons}-${e.length}'>${e.join("")}</div>`;break;case"async-block":t=`${t}<div class="${d.klass.dotAnimation}"></div>`}this.newNode.innerHTML=`<div class="${d.klass.body} ${this.className}">${t}</div>`}keyupListener(e){if("async-block"===this.type)return e.preventDefault();switch(e.code){case"Escape":e.preventDefault(),this.delete();case"Tab":if(e.preventDefault(),"confirm"!==this.type||!1===this[d.ids.confirmCancel])return!0;let t=this.okBtn;e.shiftKey?document.activeElement.id==d.ids.confirmOk&&(t=this.cancelBtn):document.activeElement.id!==d.ids.confirmCancel&&(t=this.cancelBtn),t.focus()}}afterInsert(){switch(this.listener=e=>this.keyupListener(e),window.addEventListener("keydown",this.listener),this.type){case"async-block":this.start=Date.now();break;case"confirm":this.okBtn.focus(),this.addEvent("click",(e=>{if("BUTTON"!==e.target.nodeName)return!1;this.delete(),this[e.target.id]&&this[e.target.id]()}));break;default:document.activeElement.blur(),this.addEvent("click",(e=>{e.target.id===this.newNode.id&&this.delete()}))}}afterDelete(){window.removeEventListener("keydown",this.listener)}get okBtn(){return document.getElementById(d.ids.confirmOk)}get cancelBtn(){return document.getElementById(d.ids.confirmCancel)}};class m{constructor(e={}){this.options=new n(e)}tip(e,t){return this._addToast(e,"tip",t).el}info(e,t){return this._addToast(e,"info",t).el}success(e,t){return this._addToast(e,"success",t).el}warning(e,t){return this._addToast(e,"warning",t).el}alert(e,t){return this._addToast(e,"alert",t).el}async(e,t,s,i,n){let r=this._addToast(i,"async",n);return this._afterAsync(e,t,s,n,r)}confirm(e,t,s,i){return this._addPopup(e,"confirm",i,t,s)}asyncBlock(e,t,s,i,n){let r=this._addPopup(i,"async-block",n);return this._afterAsync(e,t,s,n,r)}modal(e,t,s){return this._addPopup(e,t,s)}closeToasts(){let e=this.container;for(;e.firstChild;)e.removeChild(e.firstChild)}_addPopup(e,t,s,i,n){return new f(e,t,this.options.override(s),i,n)}_addToast(e,t,s,i){s=this.options.override(s);let n=new p(e,t,s,this.container);return i?i instanceof f?i.delete().then((()=>n.insert())):i.replace(n):n.insert()}_afterAsync(e,t,s,i,n){return e.then(this._responseHandler(t,"success",i,n),this._responseHandler(s,"alert",i,n))}_responseHandler(e,t,s,i){return n=>{switch(typeof e){case"undefined":case"string":let r="alert"===t?e||n:e;this._addToast(r,t,s,i);break;default:i.delete().then((()=>{e&&e(n)}))}}}_createContainer(){return new u(document.body,c.ids.container,`awn-${this.options.position}`).insert().el}get container(){return document.getElementById(c.ids.container)||this._createContainer()}}},612:(e,t,s)=>{e.exports=s(628).default}},t={};function s(i){var n=t[i];if(void 0!==n)return n.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,s),r.exports}s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i=s(612);AWN=i}
2188)(); 2189window.moya = window.moya || {}; 2190if (window.moya.lang) { 2191 window.moya._locale = window.moya.lang; 2192} 2193 2194Object.defineProperties(window.moya, { 2195 'lang': { 2196 get: function() { return this._locale; }, 2197 set: function(locale) { 2198 if (locale) { 2199 this._locale = locale; 2200 const event = new CustomEvent('moya.locale', {detail: locale}); 2201 document.dispatchEvent(event); 2202 } 2203 } 2204 }, 2205}); 2206 2207MoyaContainer.addModifier(function (obj) { 2208 if (obj.setLocale) { 2209 obj.setLocale(window.moya.lang || 'is'); 2210 document.addEventListener('moya.locale', (e) => obj.setLocale(e.detail)); 2211 } 2212}); 2213// always include notification styling. should probably be done in a better way 2214MoyaLoader.css('/_moya/styles/libs/awn.css');
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.