1document.addEventListener('change', function (e) { 2 var s = e.target.closest && e.target.closest('select.auto-submit'); 3 if (!s || !s.form) return; 4 if (s.dataset.formAction) s.form.action = s.dataset.formAction; 5 s.form.submit(); 6}); 7 8function _bindColorPicker() { 9 var pickers = document.querySelectorAll('input[data-color-picker]:not([data-color-picker-done])'); 10 if (!pickers.length) return; 11 if (!window.jQuery || typeof window.jQuery.fn.jPicker !== 'function') { 12 console.warn('jPicker (jQuery) not available; color picker not initialized'); 13 return; 14 } 15 pickers.forEach(function (el) { 16 el.setAttribute('data-color-picker-done', '1'); 17 window.jQuery(el).jPicker({ 18 window: { updateInputColor: false, position: { x: 'left', y: 'bottom' }, effects: { type: 'slide', speed: { show: 'fast', hide: 'fast' } } }, 19 images: { clientPath: el.getAttribute('data-color-picker-images') } 20 }); 21 }); 22} 23 24function _bindChosenSelect() { 25 var selects = document.querySelectorAll('.chosen-select'); 26 if (!selects.length) return; 27 if (!window.jQuery || typeof window.jQuery.fn.chosen !== 'function') { 28 console.warn('chosen (jQuery) not available; chosen selects not initialized'); 29 return; 30 } 31 window.jQuery(selects).chosen({ 32 default_text_default: '', 33 no_results_text: '---' 34 }); 35} 36 37var _wizardBeforeUnloadInstalled = false; 38function _bindWizard() { 39 var form = document.getElementById('wizard'); 40 if (!form || form.dataset.wizardBound) return; 41 form.dataset.wizardBound = '1'; 42 43 window.wizardIsDirty = false; 44 window.wizardIsDirtyBypass = false; 45 46 form.querySelectorAll('input, textarea, select, button').forEach(function (el) { 47 el.addEventListener('change', function () { window.wizardIsDirty = true; }); 48 el.addEventListener('input', function () { window.wizardIsDirty = true; }); 49 }); 50 form.querySelectorAll('input[type=submit], input[type=image], button[type=submit]').forEach(function (el) { 51 el.addEventListener('click', function () { window.wizardIsDirtyBypass = true; }); 52 }); 53 54 if (!_wizardBeforeUnloadInstalled) { 55 _wizardBeforeUnloadInstalled = true; 56 window.addEventListener('beforeunload', function (event) { 57 if (!window.wizardIsDirty || window.wizardIsDirtyBypass) return; 58 var current = document.getElementById('wizard'); 59 var msg = current && current.getAttribute('data-leave-confirm'); 60 if (!msg) return; 61 event.preventDefault(); 62 event.returnValue = msg; 63 return msg; 64 }); 65 } 66} 67 68function _formInitBindings() { 69 _bindColorPicker(); 70 _bindChosenSelect(); 71 _bindWizard(); 72} 73 74if (document.readyState === 'loading') { 75 document.addEventListener('DOMContentLoaded', _formInitBindings); 76} else { 77 _formInitBindings(); 78} 79document.addEventListener('ariadne:bind', _formInitBindings); 80 81if (window.jQuery) { 82 // jQuery 1.x .trigger() for custom events doesn't fire native DOM listeners, 83 // so also subscribe via jQuery for producers that use $(document).trigger(). 84 window.jQuery(document).on('ariadne:bind', _formInitBindings); 85 // jQuery's ajaxSuccess has no vanilla equivalent; keep it gated. 86 window.jQuery(document).ajaxSuccess(_bindChosenSelect); 87}
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.