Skip to content

Commit b2f7ce5

Browse files
Add possibility to prevent navigation away from current domain or page (#686)
* Add possibility to prevent navigation away from current domain or page * add missing return after merge conflict --------- Co-authored-by: Willem Leuverink <willem@leuver.ink>
1 parent 1c120f9 commit b2f7ce5

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
* @method static void suppressNewWindows()
2224
*/
2325
class Window extends Facade

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
protected bool $suppressNewWindows = false;
7478

7579
public function __construct(string $id)
@@ -344,6 +348,20 @@ public function zoomFactor(float $zoomFactor = 1.0): self
344348
return $this;
345349
}
346350

351+
public function preventLeaveDomain(bool $preventLeaveDomain = true): self
352+
{
353+
$this->preventLeaveDomain = $preventLeaveDomain;
354+
355+
return $this;
356+
}
357+
358+
public function preventLeavePage(bool $preventLeavePage = true): self
359+
{
360+
$this->preventLeavePage = $preventLeavePage;
361+
362+
return $this;
363+
}
364+
347365
public function suppressNewWindows(): self
348366
{
349367
$this->suppressNewWindows = true;
@@ -390,6 +408,8 @@ public function toArray()
390408
'transparent' => $this->transparent,
391409
'webPreferences' => $this->webPreferences,
392410
'zoomFactor' => $this->zoomFactor,
411+
'preventLeaveDomain' => $this->preventLeaveDomain,
412+
'preventLeavePage' => $this->preventLeavePage,
393413
'suppressNewWindows' => $this->suppressNewWindows,
394414
];
395415
}

0 commit comments

Comments
 (0)