-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix new year bug - Improve runner - Add warn when try to close pas
- Loading branch information
1 parent
386b7ba
commit 3c5d15a
Showing
8 changed files
with
200 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
"object-hash": "^3.0.0", | ||
"tslib": "^2.4.1" | ||
} | ||
} | ||
} |
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,133 @@ | ||
/** | ||
* Navigator | ||
* | ||
* Front TS Scrips for multiple tasks | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2023 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Dependances | ||
*/ | ||
|
||
/** | ||
* Client | ||
* | ||
* Methods for manage client navigator | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2023 Kévin Zarshenas | ||
*/ | ||
export default class Client { | ||
|
||
/** Private parameters | ||
****************************************************** | ||
*/ | ||
|
||
/** @var message:string */ | ||
private _closeMessage:string = 'Are you sure you want to leave ?'; | ||
|
||
/** @var _customCloseMessage:string */ | ||
private _customCloseMessage:string; | ||
|
||
/** Public parameters | ||
****************************************************** | ||
*/ | ||
|
||
/** @var isActive Check if event close is active */ | ||
public isPreventCloseActive = false; | ||
|
||
|
||
/** Public methods | ||
****************************************************** | ||
*/ | ||
|
||
/** | ||
* Prevent Close | ||
* | ||
* @param message | ||
* @returns {void} | ||
*/ | ||
public preventClose = (message:string = "") => { | ||
|
||
// Set message | ||
this._customCloseMessage = message ? message : this._closeMessage; | ||
|
||
// Add event listener | ||
window.addEventListener("beforeunload", this._beforeUnloadEvent); | ||
|
||
// Switch status | ||
this.isPreventCloseActive = true; | ||
|
||
} | ||
|
||
/** | ||
* Desable Close | ||
* | ||
* @param message | ||
* @returns {void} | ||
*/ | ||
public disablePreventClose = () => { | ||
|
||
// Add event listener | ||
window.removeEventListener("beforeunload", this._beforeUnloadEvent); | ||
|
||
// Switch status | ||
this.isPreventCloseActive = false; | ||
|
||
} | ||
|
||
/** Private methods | ||
****************************************************** | ||
*/ | ||
|
||
/** | ||
* Before Unload Event | ||
* | ||
* @param event | ||
* @returns {void} | ||
*/ | ||
private _beforeUnloadEvent = (event:Event):void => { | ||
|
||
// Prevent default | ||
event.preventDefault(); | ||
|
||
// | ||
// @ts-ignore | ||
event.returnValue = `Are you sure you want to leave?`; | ||
|
||
/* // check if event dialog | ||
if( | ||
"dialog" in event && | ||
typeof event.dialog === "object" && | ||
event.dialog && | ||
"setMessage" in event.dialog && | ||
typeof event.dialog.setMessage === "function" && | ||
event.dialog.setMessage && | ||
"setButtonLabel" in event.dialog && | ||
typeof event.dialog.setButtonLabel === "function" && | ||
event.dialog.setButtonLabel | ||
){ | ||
// Set message | ||
event.dialog.setMessage(this._customCloseMessage); | ||
// Set button | ||
event.dialog.setButtonLabel("Save"); | ||
// Check show | ||
if("show" in event.dialog && typeof event.dialog.show === "function") | ||
// Show dialog | ||
event.dialog.show().then(async (result) => { | ||
if (result == "Save"){ | ||
// save the document. | ||
} | ||
}); | ||
} */ | ||
} | ||
|
||
} |
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
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
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