-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
src/Butil/Bit.Butil/Internals/JsInterops/WindowJsInterop.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.JSInterop; | ||
|
||
namespace Bit.Butil; | ||
|
||
internal static class WindowJsInterop | ||
{ | ||
internal static async Task AddBeforeUnload(this IJSRuntime js) | ||
{ | ||
await js.InvokeVoidAsync("BitButil.window.addBeforeUnload"); | ||
} | ||
|
||
internal static async Task RemoveBeforeUnload(this IJSRuntime js) | ||
{ | ||
await js.InvokeVoidAsync("BitButil.window.removeBeforeUnload"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var BitButil = BitButil || {}; | ||
|
||
(function (butil: any) { | ||
butil.window = { | ||
addBeforeUnload, | ||
removeBeforeUnload | ||
}; | ||
|
||
function addBeforeUnload() { | ||
window.onbeforeunload = e => { | ||
e.preventDefault(); | ||
e.returnValue = true; | ||
return true; | ||
}; | ||
} | ||
|
||
function removeBeforeUnload() { | ||
window.onbeforeunload = null; | ||
} | ||
}(BitButil)); |