Skip to content

Commit 89be1df

Browse files
committed
Add possibility to prevent navigation away from current domain or page
1 parent e4ec3de commit 89be1df

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Facades/Window.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @method static void maximize($id = null)
1919
* @method static void minimize($id = null)
2020
* @method static void zoomFactor(float $zoomFactor = 1.0)
21+
* @method static void preventLeaveDomain(bool $preventLeaveDomain = true)
22+
* @method static void preventLeavePage(bool $preventLeavePage = true): self
2123
*/
2224
class Window extends Facade
2325
{

src/Windows/Window.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class Window
7070

7171
protected float $zoomFactor = 1.0;
7272

73+
protected bool $preventLeaveDomain = false;
74+
75+
protected bool $preventLeavePage = false;
76+
7377
public function __construct(string $id)
7478
{
7579
$this->id = $id;
@@ -342,6 +346,20 @@ public function zoomFactor(float $zoomFactor = 1.0): self
342346
return $this;
343347
}
344348

349+
public function preventLeaveDomain(bool $preventLeaveDomain = true): self
350+
{
351+
$this->preventLeaveDomain = $preventLeaveDomain;
352+
353+
return $this;
354+
}
355+
356+
public function preventLeavePage(bool $preventLeavePage = true): self
357+
{
358+
$this->preventLeavePage = $preventLeavePage;
359+
360+
return $this;
361+
}
362+
345363
public function toArray()
346364
{
347365
return [
@@ -381,6 +399,8 @@ public function toArray()
381399
'transparent' => $this->transparent,
382400
'webPreferences' => $this->webPreferences,
383401
'zoomFactor' => $this->zoomFactor,
402+
'preventLeaveDomain' => $this->preventLeaveDomain,
403+
'preventLeavePage' => $this->preventLeavePage,
384404
];
385405
}
386406

0 commit comments

Comments
 (0)