From c0f0e1ba8e74d5f22be9664740a4dc51aa824bf6 Mon Sep 17 00:00:00 2001 From: volchek2 Date: Fri, 3 Nov 2017 23:31:56 -0500 Subject: Allow raw and upload popups to be closed with escape key and clicking outside of them --- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 31 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Web/wwwroot/Content/js/log-parser.js') diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index 8e30ae12..7a4d2d60 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -37,6 +37,14 @@ smapi.logParser = function(sectionUrl, pasteID) { $("#input").val(""); $("#popup-upload").fadeIn(); }); + + var closeUploadPopUp = function () { + $("#popup-upload").fadeOut(400, function () { + $("#input").val(memory); + memory = ""; + }); + }; + $("#popup-upload").on({ 'dragover dragenter': function(e) { e.preventDefault(); @@ -58,6 +66,10 @@ smapi.logParser = function(sectionUrl, pasteID) { }, this, file, $("#input")); reader.readAsText(file); } + }, + 'click': function (e) { + if (e.target.id === "popup-upload") + closeUploadPopUp(); } }); @@ -91,15 +103,24 @@ smapi.logParser = function(sectionUrl, pasteID) { $("#uploader").fadeOut(); } }); - $("#cancel").on("click", function() { - $("#popup-upload").fadeOut(400, function() { - $("#input").val(memory); - memory = ""; - }); + + $(document).on("keydown", function (e) { + if (e.which == 27) { + closeUploadPopUp(); + $("#popup-raw").fadeOut(400); + } }); + $("#cancel").on("click", closeUploadPopUp); + $("#closeraw").on("click", function() { $("#popup-raw").fadeOut(400); }); + + $("#popup-raw").on("click", function (e) { + if (e.target.id === "popup-raw") + $("#popup-raw").fadeOut(400); + }); + if (pasteID) { getData(pasteID); } -- cgit From 99278f0be19c63a32a7d5eba94d7a0cd88dd288c Mon Sep 17 00:00:00 2001 From: volchek2 Date: Fri, 3 Nov 2017 23:32:52 -0500 Subject: Fix braces --- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/Content/js/log-parser.js') diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index 7a4d2d60..c6073f31 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -117,8 +117,9 @@ smapi.logParser = function(sectionUrl, pasteID) { }); $("#popup-raw").on("click", function (e) { - if (e.target.id === "popup-raw") + if (e.target.id === "popup-raw") { $("#popup-raw").fadeOut(400); + } }); if (pasteID) { -- cgit From 31002a7e52f7360e0979d9ddf1380c55451311eb Mon Sep 17 00:00:00 2001 From: volchek2 Date: Sat, 4 Nov 2017 00:28:59 -0500 Subject: check whether the popup is open before closing it with esc --- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/Content/js/log-parser.js') diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index c6073f31..19287c24 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -106,7 +106,10 @@ smapi.logParser = function(sectionUrl, pasteID) { $(document).on("keydown", function (e) { if (e.which == 27) { - closeUploadPopUp(); + if ($("#popup-upload").css("display") !== "none" && $("#popup-upload").css("opacity") == 1) { + closeUploadPopUp(); + } + $("#popup-raw").fadeOut(400); } }); -- cgit