Skip to content

Commit

Permalink
Merge pull request #3300 from bromagosa/noExitWarning-option
Browse files Browse the repository at this point in the history
add noExitWarning to IDE config options
  • Loading branch information
jmoenig authored Feb 12, 2024
2 parents a1f95cd + 98aa9f3 commit 6a962a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ You can configure the looks and behavior of the IDE by passing it a configuratio
|noRingify: |bool |disable/enable "ringify" / "unringify" in context menus|
|noUserSettings: |bool |disable/enable persistent user preferences|
|noDevWarning: |bool |ignore development version incompatibility warning|
|noExitWarning: |bool |do not show a browser warning when closing the IDE with unsaved changes|
|blocksZoom: |num |zoom factor for blocks, e.g. `1.5`|
|blocksFade: |num |fading percentage for blocks, e.g. `85`|
|zebra: |num |contrast percentage for nesting same-color blocks|
Expand Down
7 changes: 6 additions & 1 deletion src/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ IDE_Morph.prototype.openIn = function (world) {
window.onbeforeunload = nop;
}
if (dict.noExitWarning) {
window.onbeforeunload = nop;
window.onbeforeunload = window.cachedOnbeforeunload;
}
if (dict.blocksZoom) {
myself.savingPreferences = false;
Expand Down Expand Up @@ -897,6 +897,11 @@ IDE_Morph.prototype.applyConfigurations = function () {
if (cnf.noCloud) {
this.cloud.disable();
}

// disable onbeforeunload close warning
if (cnf.noExitWarning) {
window.onbeforeunload = window.cachedOnbeforeunload;
}
};

IDE_Morph.prototype.applyPaneHidingConfigurations = function () {
Expand Down
4 changes: 4 additions & 0 deletions src/morphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12469,7 +12469,11 @@ WorldMorph.prototype.initEventListeners = function () {
false
);

window.cachedOnbeforeunload = window.onbeforeunload;
window.onbeforeunload = (evt) => {
if (window.cachedOnbeforeunload) {
window.cachedOnbeforeunload.call(null, evt);
}
var e = evt || window.event,
msg = "Are you sure you want to leave?";
// For IE and Firefox
Expand Down

0 comments on commit 6a962a7

Please sign in to comment.