1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 10:15:28 +02:00

Fix issue processwire/processwire-issues#202 where the leave confirm box was appearing when it shouldn't, after saving after a file had been uploaded. Also added drag/drop protection so that if you accidentially drag/drop a file outside of the specified dropzone, it gets ignored, rather than loading the file in the browser.

This commit is contained in:
Ryan Cramer
2017-03-10 08:38:16 -05:00
parent 6fe703f699
commit b899bc42e7
6 changed files with 21 additions and 8 deletions

View File

@@ -900,7 +900,6 @@ function InputfieldColumnWidths($target) {
*/
function InputfieldFormBeforeUnloadEvent(e) {
var $changes = $(".InputfieldFormConfirm:not(.InputfieldFormSubmitted) .InputfieldStateChanged");
if($changes.length == 0) $changes = $('.InputfieldStateConfirmLeave');
if($changes.length == 0) return;
var msg = $('.InputfieldFormConfirm:eq(0)').attr('data-confirm') + "\n";
$changes.each(function() {
@@ -1217,7 +1216,21 @@ function InputfieldIntentions() {
// allow submissions again once they are out of the field
$form.removeClass('nosubmit');
});
});
});
// prevent dragged in files from loading in the browser (does not interfere with other drag/drop handlers)
if($("input[type=file]").length) {
$(document).on({
dragover: function() {
if($(this).is("input[type=file]")) return;
return false;
},
drop: function() {
if($(this).is("input[type=file]")) return;
return false;
}
});
}
}
/***********************************************************************************/

File diff suppressed because one or more lines are too long