1function openPopupAjax(title, url, options) 2{ 3 if ($('#modalDialogAjax').length) 4 { 5 $('#modalDialogAjax').on('hidden.bs.modal', function (e) { 6 _openPopupAjax(title, url, options); 7 }); 8 9 closeAjaxPopup(); 10 } 11 else 12 _openPopupAjax(title, url, options); 13} 14 15function _openPopupAjax(title, url, options) 16{ 17 if (typeof(_popupRequest) != 'undefined') 18 _popupRequest.abort(); 19 20 _popupRequest = $.get(url, function(data) 21 { 22 var popupOptions = { 23 popupClass: '', 24 size: '', 25 customLayout: false, 26 preventClose: false 27 }; 28 29 if (typeof(options) != 'undefined') 30 { 31 if (typeof(options.popupClass) != 'undefined') 32 popupOptions.popupClass = options.popupClass; 33 34 if (typeof(options.customLayout) != 'undefined') 35 popupOptions.customLayout = options.customLayout; 36 37 if (typeof(options.size) != 'undefined') 38 popupOptions.size = options.size; 39 40 if (typeof(options.preventClose) != 'undefined') 41 popupOptions.preventClose = options.preventClose; 42 } 43 44 if (typeof(data.status) != 'undefined' && data.status == 'close_and_refresh_page') 45 { 46 var url = window.location.href; 47 48 var pos = url.indexOf('#'); 49 50 if (pos > 0) 51 url = url.substr(0, pos); 52 53 window.location = url; 54 55 return; 56 } 57 58 var modalClass = ''; 59 60 switch(popupOptions.size) 61 { 62 case 'large': 63 default: 64 modalClass = 'modal-lg'; 65 break; 66 case 'xlarge': 67 modalClass = 'modal-xl'; 68 break; 69 } 70 71 var html = 72 '<div id="modalDialogAjax" class="modal fade" tabindex="-1">' + 73 '<div class="modal-dialog ' + modalClass + '">' + 74 (!popupOptions.customLayout ? 75 '<form id="modalDialogAjaxForm">' + 76 '<div class="modal-content">' + 77 '<div class="modal-header">' + 78 '<h5 class="modal-title">' + title + '</h5>' + 79 (!popupOptions.preventClose ? '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>' : '') + 80 '</div>' + 81 '<div id="modalDialogAjaxContent">' : '') + 82 data.html + 83 (typeof(data.script) != 'undefined' ? '<script type="text/javascript">' + data.script + '</script>' : '') + 84 (!popupOptions.customLayout ? 85 '</div>' + 86 '</div>' + 87 '</form>' : '') + 88 '</div>' + 89 '</div>'; 90 91 $('body').append(html); 92 93 $('#modalDialogAjax').on('shown.bs.modal', function() 94 { 95 if (typeof(options) != 'undefined' && typeof(options.onShown) != 'undefined') 96 { 97 if (typeof(options.onShown) == 'function') 98 options.onShown(); 99 else 100 eval(options.onShown); 101 } 102 }); 103 104 var modal = new bootstrap.Modal($('#modalDialogAjax')[0], { backdrop: popupOptions.preventClose ? 'stats' : true, keyboard: !popupOptions.preventClose, focus: true }); 105 106 $('#modalDialogAjax').on('hidden.bs.modal', function (e) { 107 $('#modalDialogAjax').remove(); 108 }); 109 110 initPopupAjaxForm(); 111 112 modal.show(); 113 }, 'json') 114 .fail(function(jqXHR) 115 { 116 if (jqXHR.status) 117 alert('WystÄ piÅ nieoczekiwany bÅÄ d.'); 118 }); 119 120 initPopupAjaxForm = function() 121 { 122 $('#modalDialogAjaxForm').submit(function() 123 { 124 var data = $('#modalDialogAjaxForm').serialize(); 125 126 $('input[type="submit"],button[type="submit"]', $('#modalDialogAjaxForm')).attr('disabled', 'disabled'); 127 128 var callback = function(data) 129 { 130 if (typeof(data.status) != 'undefined') 131 { 132 if (data.status == 'close') 133 { 134 closeAjaxPopup(); 135 136 return; 137 } 138 else if (data.status == 'close_and_refresh_page') 139 { 140 var url = window.location.href; 141 142 var pos = url.indexOf('#'); 143 144 if (pos > 0) 145 url = url.substr(0, pos); 146 147 window.location = url; 148 149 return; 150 } 151 else if (data.status == 'redirect') 152 { 153 window.location = data.url; 154// closeAjaxPopup(); 155 return; 156 } 157 } 158 159 $('#modalDialogAjaxContent').html(data.html); 160 } 161 162 var method = typeof(options) != 'undefined' && typeof(options.method) != 'undefined' ? options.method.toLowerCase() : 'post'; 163 164 if (method == 'post') 165 { 166 $.post(url, data, callback, 'json') 167 .fail(function(jqXHR) 168 { 169 if (jqXHR.status) 170 alert('WystÄ piÅ nieoczekiwany bÅÄ d.'); 171 }); 172 } 173 else if (method == 'get') 174 { 175 $.get(url, data, callback, 'json') 176 .fail(function(jqXHR) 177 { 178 if (jqXHR.status) 179 alert('WystÄ piÅ nieoczekiwany bÅÄ d.'); 180 }); 181 } 182 183 return false; 184 }); 185 } 186} 187 188function closeAjaxPopup() 189{ 190 $('#modalDialogAjax').modal('hide'); 191}
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.