1$.initDynamicFormUploads = function (dom_root) { 2 3 dom_root.find('div.singleFileContainer:not(.jsinit):visible').each(function () { 4 5 $(this).addClass('jsinit'); 6 7 var form = $(this).closest('form')[0]; 8 var inputname = $(this).find('input').attr('name'); 9 10 if (typeof (window.file_upload_max_size) == 'undefined') { 11 var maxFileSize = 16777216; 12 } else { 13 var maxFileSize = window.file_upload_max_size; 14 } 15 if (window.app_language == 'en_US') { 16 window.UppyLocale = window.UppyLocaleEN; 17 } else { 18 window.UppyLocale = window.UppyLocaleNL; 19 } 20 21 if (typeof ($(this).attr('data-accept')) == 'undefined' || $(this).attr('data-accept') == '') { 22 var allowedFileTypes = null; 23 } else { 24 var allowedFileTypes = $(this).attr('data-accept').split(','); 25 } 26 27 var rand_upload_id = Math.floor(Math.random() * 1000) + 1; 28 while ($('#uppy' + rand_upload_id).length > 0) { 29 var rand_upload_id = Math.floor(Math.random() * 1000) + 1; 30 } 31 var container = $(this); 32 var prefill = $(this).find('.prefill'); 33 container.html('<div id="uppy' + rand_upload_id + '"></div>').ready(function () { 34 35 if (typeof (window.uppies) == 'undefined') { 36 window.uppies = []; 37 } 38 39 window.uppies['uppy' + rand_upload_id] = new Uppy({ 40 debug: true, 41 autoProceed: true, 42 locale: window.UppyLocaleNL, 43 restrictions: { 44 maxFileSize: maxFileSize, 45 maxNumberOfFiles: 1, 46 allowedFileTypes: allowedFileTypes 47 }, 48 }); 49 window.uppies['uppy' + rand_upload_id].use(UppyDashboard, { 50 trigger: '.UppyModalOpenerBtn', 51 inline: true, 52 target: '#uppy' + rand_upload_id, 53 replaceTargetContent: true, 54 //showLinkToFileUploadResult: false, 55 proudlyDisplayPoweredByUppy: false, 56 showProgressDetails: true, 57 hideCancelButton: true, 58 hideProgressAfterFinish: true, 59 showRemoveButtonAfterComplete: true, 60 height: 350, 61 thumbnailWidth: 220, 62 autoOpenFileEditor: true, 63 metaFields: [], 64 browserBackButtonClose: false, 65 singleFileFullScreen: false 66 }); 67 68 if (typeof (container.attr('data-webcam')) != 'undefined' && container.attr('data-webcam') > 0) { 69 window.uppies['uppy' + rand_upload_id].use(UppyWebcam, { 70 target: UppyDashboard, 71 modes: [ 72 'picture' 73 ], 74 mirror: true 75 }); 76 } 77 78 window.uppies['uppy' + rand_upload_id].on('upload-success', function (fileId, data) { 79 80 $.post('/utilities/TempUploads/process_file/', 81 { 82 jquery_post: 1, 83 target: data.body.url, 84 name: fileId.name, 85 size: fileId.data.size, 86 status: 5 87 }, function (processed_file_data) { 88 89 processed_file_data = $.parseJSON(processed_file_data); 90 91 if (container.closest('.img-modal').length > 0) { 92 $.post('/utilities/TempUploads/saveUpload/' + processed_file_data['id'] + '/' + 'Temp' + '/' + '0' + '/' + 'image', function (saveupload_data) { 93 var saveupload_data = $.parseJSON(saveupload_data); 94 95 window.uppies['uppy' + rand_upload_id].getFiles().forEach(file => { 96 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('.img-wrap').css('background-image', 'url(/slir/w500/app/Uploads/' + saveupload_data.url.replaceAll(' ', '%20') + ')'); 97 }); 98 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('input[data-field="new_id"]').val(saveupload_data.id); 99 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('.open-img-modal').removeClass('mode-add').removeClass('mode-edit').addClass('mode-true-edit'); 100 }); 101 102 } else { 103 container.append('<input type="hidden" name="' + container.attr('data-original-name') + '" value="' + processed_file_data.id + '" />'); 104 } 105 106 }); 107 if (!window.uppies['uppy' + rand_upload_id].getPlugin('Dashboard').canEditFile(fileId)) { 108 container.closest('.img-modal').find('.close').trigger('click'); 109 } 110 111 }); 112 113 if (typeof (container.attr('data-crop')) != 'undefined' && container.attr('data-crop') > 0) { 114 var aspectRatio = parseInt(container.attr('data-crop-width')) / parseInt(container.attr('data-crop-height')); 115 116 container.addClass('has-crop'); 117 window.uppies['uppy' + rand_upload_id].use(UppyImageEditor, { 118 target: UppyDashboard, 119 quality: 0.8, 120 cropperOptions: { 121 viewMode: 1, 122 background: false, 123 autoCropArea: 1, 124 responsive: true, 125 aspectRatio: aspectRatio, 126 croppedCanvasOptions: {}, 127 }, 128 actions: { 129 revert: false, 130 rotate: true, 131 granularRotate: false, 132 flip: true,
133 zoomIn: false, 134 zoomOut: false, 135 cropSquare: false, 136 cropWidescreen: false, 137 cropWidescreenVertical: false, 138 }, 139 }); 140 141 window.uppies['uppy' + rand_upload_id].on('file-editor:complete', function (updatedFile) { 142 143 var file_row = $(document.getElementById('uppy_' + updatedFile.id)); 144 if (file_row.find('.uppy-Dashboard-Item-actionWrapper .uppy-eye-do-crop').length == 0) { 145 file_row.find('.uppy-Dashboard-Item-actionWrapper').prepend('<button class="uppy-u-reset uppy-Dashboard-Item-action uppy-eye-do-crop"><i class="fa fa-crop-alt"></i></button>'); 146 } 147 148 window.uppies['uppy' + rand_upload_id].retryUpload(updatedFile.id); 149 container.closest('.img-modal').find('.close').trigger('click'); 150 151 }); 152 153 } 154 155 container.on('click', '.uppy-eye-do-crop', function (e) { 156 e.preventDefault(); 157 e.stopImmediatePropagation(); 158 159 window.uppies[$(this).closest('.uppy-Root').parent().attr('id')].getPlugin('Dashboard').openFileEditor(window.uppies[$(this).closest('.uppy-Root').parent().attr('id')].getFile($(this).closest('.uppy-Dashboard-Item').attr('id').substring(5))); 160 }); 161 162 window.uppies['uppy' + rand_upload_id].on('file-removed', function (file, reason) { 163 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('.img-wrap').css('background-image', 'url(' + $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').attr('data-empty-image') + ')'); 164 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('.open-img-modal').removeClass('mode-true-edit').removeClass('mode-edit').addClass('mode-add'); 165 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('input[data-field="is_deleted"]').val('1'); 166 $('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('input[data-field="new_id"]').val('0'); 167 168 if ($('[data-img-modal="#' + container.closest('.img-modal').attr('id') + '"').find('input[data-field="new_id"]').length == 0) { 169 if ($('input[name="' + container.attr('data-original-name') + '"').length > 0) { 170 $('input[name="' + container.attr('data-original-name') + '"').val('0'); 171 } else { 172 container.append('<input type="hidden" name="' + container.attr('data-original-name') + '" value="0" />'); 173 } 174 } 175 176 }); 177 178 window.uppies['uppy' + rand_upload_id].use(UppyForm, { 179 target: form, 180 getMetaFromForm: false, 181 multipleResults: true, 182 resultName: inputname 183 }); 184 window.uppies['uppy' + rand_upload_id].use(UppyXHRUpload, { 185 endpoint: '/utilities/TempUploads/uppy_upload/', 186 method: 'post', 187 bundle: false 188 }); 189 190 window.uppies['uppy' + rand_upload_id].on('file-removed', function (file, reason) { 191 const file_amount = window.uppies['uppy' + rand_upload_id].getFiles().length; 192 193 container.find('input[data-uppy-id="' + file.id + '"]').remove(); 194 195 if (file_amount <= 0) { 196 container.parent().find('.uppyValidation').val(''); 197 } 198 }); 199 200 window.uppies['uppy' + rand_upload_id].on('file-added', function (file, reason) { 201 const file_amount = window.uppies['uppy' + rand_upload_id].getFiles().length; 202 if (file_amount > 0) { 203 container.parent().find('.uppyValidation').val(file_amount); 204 } 205 }); 206 207 window.uppies['uppy' + rand_upload_id].on('upload', function (data) { 208 container.closest('form').find(':submit').attr('disabled', 'disabled'); 209 }); 210 211 window.uppies['uppy' + rand_upload_id].on('complete', function (result) { 212 container.closest('form').find(':submit').removeAttr('disabled'); 213 }); 214 215 if (typeof (prefill) != 'undefined' && prefill.length > 0) { 216 var prefill_info = $.parseJSON(prefill.text()); 217 window.uppies['uppy' + rand_upload_id].setOptions({ 218 autoProceed: false 219 }); 220 221 if (typeof (prefill_info.show_image_url) != 'undefined') { 222 prev = '/slir/w135-h175-c135x175/app/Uploads/' + prefill_info.show_image_url; 223 } else { 224 prev = null; 225 } 226 227 fetch(prefill_info.download_url + '/1') 228 .then((response) => response.blob()) // returns a Blob 229 .then((blob) => { 230 window.uppies['uppy' + rand_upload_id].addFile({ 231 name: prefill_info.file_name + '.' + prefill_info.extension, 232 type: prefill_info.extension, 233 preview: prev, 234 data: blob, 235 isRemote: false 236 });
237 window.uppies['uppy' + rand_upload_id].getFiles().forEach(file => { 238 window.uppies['uppy' + rand_upload_id].setFileState(file.id, { 239 progress: {uploadComplete: true, uploadStarted: true} 240 }); 241 242 setTimeout(function () { 243 var row = $(document.getElementById('uppy_' + file.id)); 244 245 if (row.find('.uppy-Dashboard-Item-actionWrapper .uppy-eye-do-crop').length == 0) { 246 if (typeof (container.attr('data-crop')) != 'undefined' && container.attr('data-crop') > 0) { 247 row.find('.uppy-Dashboard-Item-actionWrapper').prepend('<button class="uppy-u-reset uppy-Dashboard-Item-action uppy-eye-do-crop"><i class="fa fa-crop-alt"></i></button>'); 248 } 249 } 250 }, 100); 251 }); 252 window.uppies['uppy' + rand_upload_id].setOptions({ 253 autoProceed: true 254 }); 255 256 }); 257 258 259 } 260 261 var elemToObserve = document.getElementById('uppy' + rand_upload_id).getElementsByClassName('uppy-Dashboard')[0]; 262 var observer = new MutationObserver(function (mutations) { 263 mutations.forEach(function (mutation) { 264 if (mutation.attributeName == "class") { 265 if (mutation.target.classList.contains('uppy-size--md', 'uppy-size-lg', 'uppy-size--xl')) { 266 mutation.target.classList.remove('uppy-size--md', 'uppy-size--lg', 'uppy-size--xl'); 267 } 268 } 269 }); 270 }); 271 observer.observe(elemToObserve, {attributes: true}); 272 }); 273 274 }); 275 276 dom_root.find('div.multiFileContainer:not(.jsinit):visible').each(function () { 277 278 $(this).addClass('jsinit'); 279 280 var form = $(this).closest('form')[0]; 281 var inputname = $(this).find('input').attr('name'); 282 283 if (typeof (window.file_upload_max_size) == 'undefined') { 284 var maxFileSize = 16777216; 285 } else { 286 var maxFileSize = window.file_upload_max_size; 287 } 288 289 if (typeof ($(this).attr('data-accept')) == 'undefined' || $(this).attr('data-accept') == '') { 290 var allowedFileTypes = null; 291 } else { 292 var allowedFileTypes = $(this).attr('data-accept').split(','); 293 } 294 295 var rand_upload_id = Math.floor(Math.random() * 1000) + 1; 296 while ($('#uppy' + rand_upload_id).length > 0) { 297 var rand_upload_id = Math.floor(Math.random() * 1000) + 1; 298 } 299 var container = $(this); 300 var prefill = $(this).find('.prefill'); 301 302 container.html('<div id="uppy' + rand_upload_id + '"></div>').ready(function () { 303 304 if (typeof (window.uppies) == 'undefined') { 305 window.uppies = []; 306 } 307 308 window.uppies['uppy' + rand_upload_id] = new Uppy({ 309 debug: true, 310 autoProceed: true, 311 locale: window.UppyLocale, 312 restrictions: { 313 maxFileSize: maxFileSize, 314 allowedFileTypes: allowedFileTypes 315 }, 316 }); 317 window.uppies['uppy' + rand_upload_id].use(UppyDashboard, { 318 trigger: '.UppyModalOpenerBtn', 319 inline: true, 320 target: '#uppy' + rand_upload_id, 321 replaceTargetContent: true, 322 showLinkToFileUploadResult: false, 323 proudlyDisplayPoweredByUppy: false, 324 showProgressDetails: true, 325 hideCancelButton: true, 326 hideProgressAfterFinish: true, 327 showRemoveButtonAfterComplete: true, 328 height: 350, 329 thumbnailWidth: 220, 330 metaFields: [], 331 browserBackButtonClose: false, 332 singleFileFullScreen: false 333 }); 334 window.uppies['uppy' + rand_upload_id].use(UppyForm, { 335 target: form, 336 getMetaFromForm: false, 337 multipleResults: true, 338 resultName: inputname 339 }); 340 window.uppies['uppy' + rand_upload_id].use(UppyXHRUpload, { 341 endpoint: '/utilities/TempUploads/uppy_upload/', 342 method: 'post', 343 bundle: false 344 }); 345 window.uppies['uppy' + rand_upload_id].on('upload-success', function (fileId, data) { 346 347 $.post('/utilities/TempUploads/process_file/', 348 { 349 jquery_post: 1, 350 target: data.body.url, 351 name: fileId.data.name, 352 size: fileId.data.size, 353 status: 5 354 }, function (processed_file_data) { 355 356 processed_file_data = $.parseJSON(processed_file_data); 357 name = container.attr('id') + '[temp_upload_ids][' + processed_file_data.id + ']'; 358 container.append('<input type="hidden" data-uppy-id="' + fileId.id + '" name="' + name + '" value="' + processed_file_data.id + '">'); 359 }); 360 361 }); 362 363 364 window.uppies['uppy' + rand_upload_id].on('file-removed', function (file, reason) { 365 const file_amount = window.uppies['uppy' + rand_upload_id].getFiles().length; 366 367 container.find('input[data-uppy-id="' + file.id + '"]').val('0'); 368 369 if (file_amount <= 0) { 370 container.parent().find('.uppyValidation').val(''); 371 } 372 }); 373 374 window.uppies['uppy' + rand_upload_id].on('file-added', function (file, reason) { 375 const file_amount = window.uppies['uppy' + rand_upload_id].getFiles().length; 376 if (file_amount > 0) { 377 container.parent().find('.uppyValidation').val(file_amount); 378 } 379 }); 380 381 window.uppies['uppy' + rand_upload_id].on('upload', function (data) { 382 container.closest('form').find(':submit').attr('disabled', 'disabled'); 383 }); 384 385 window.uppies['uppy' + rand_upload_id].on('complete', function (result) { 386 container.closest('form').find(':submit').removeAttr('disabled'); 387 }); 388 389 if (typeof (prefill) != 'undefined' && prefill.length > 0) { 390 var prefill_info_array = $.parseJSON(prefill.text()); 391 window.uppies['uppy' + rand_upload_id].setOptions({ 392 autoProceed: false 393 }); 394 395 prefill_info_array.forEach(function (prefill_info) { 396 var prev = null; 397 398 if (typeof (prefill_info.show_image_url) !== 'undefined') { 399 prev = '/slir/w135-h175-c135x175/app/Uploads/' + prefill_info.show_image_url; 400 } 401 402 fetch(prefill_info.download_url + '/1') 403 .then((response) => response.blob()) // returns a Blob 404 .then((blob) => { 405 window.uppies['uppy' + rand_upload_id].addFile({ 406 name: prefill_info.file_name + '.' + prefill_info.extension, 407 type: prefill_info.extension, 408 preview: prev, 409 data: blob, 410 isRemote: false 411 }); 412
413 window.uppies['uppy' + rand_upload_id].getFiles().forEach(file => { 414 window.uppies['uppy' + rand_upload_id].setFileState(file.id, { 415 progress: {uploadComplete: true, uploadStarted: true} 416 }); 417 }); 418 419 window.uppies['uppy' + rand_upload_id].setOptions({ 420 autoProceed: true 421 }); 422 }); 423 }); 424 425 } 426 427 var elemToObserve = document.getElementById('uppy' + rand_upload_id).getElementsByClassName('uppy-Dashboard')[0]; 428 var observer = new MutationObserver(function (mutations) { 429 mutations.forEach(function (mutation) { 430 if (mutation.attributeName == "class") { 431 if (mutation.target.classList.contains('uppy-size--md', 'uppy-size-lg', 'uppy-size--xl')) { 432 mutation.target.classList.remove('uppy-size--md', 'uppy-size--lg', 'uppy-size--xl'); 433 } 434 } 435 }); 436 }); 437 observer.observe(elemToObserve, {attributes: true}); 438 }); 439 440 }); 441 442 443}
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.