瀏覽代碼

Patch for confirmation in non-Firefox (Chrome)

https://github.com/FreshRSS/FreshRSS/issues/739
Use standards instead of Firefox-specific explicitOriginalTarget
Alexandre Alapetite 11 年之前
父節點
當前提交
f79f2a7e98
共有 1 個文件被更改,包括 5 次插入7 次删除
  1. 5 7
      p/scripts/main.js

+ 5 - 7
p/scripts/main.js

@@ -1230,13 +1230,11 @@ function init_slider_observers() {
 }
 
 function init_configuration_alert() {
-	$(window).on('beforeunload', function(e){
-		if (e.originalEvent.explicitOriginalTarget.type === 'submit') {
-			// we don't want an alert when submitting the form with the submit button
-			return;
-		}
-		if ($(e.originalEvent.explicitOriginalTarget).attr('data-leave-validation') !== undefined) {
-			// we don't want an alert when submitting the form by pressing the enter key
+	$(window).on('submit', function(e) {
+		window.hasSubmit = true;
+	});
+	$(window).on('beforeunload', function(e) {
+		if (window.hasSubmit) {
 			return;
 		}
 		var fields = $("[data-leave-validation]");