Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
confirm_leave-3293391
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
confirm_leave-3293391
Commits
c67b864e
Commit
c67b864e
authored
6 years ago
by
Mike Priscella
Browse files
Options
Downloads
Patches
Plain Diff
Using a more reliable method to determine whether the form has been updated
parent
d1cd896e
No related branches found
Branches containing commit
Tags
1.0.0-beta2
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
confirm_leave.module
+7
-0
7 additions, 0 deletions
confirm_leave.module
js/confirm-leave.js
+4
-2
4 additions, 2 deletions
js/confirm-leave.js
with
11 additions
and
2 deletions
confirm_leave.module
+
7
−
0
View file @
c67b864e
...
...
@@ -13,3 +13,10 @@ use Drupal\Core\Form\FormStateInterface;
function
confirm_leave_form_node_form_alter
(
&
$form
,
FormStateInterface
$form_state
)
{
$form
[
'#attached'
][
'library'
][]
=
'confirm_leave/confirm-leave'
;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function
confirm_leave_form_node_edit_form_alter
(
&
$form
,
FormStateInterface
$form_state
)
{
$form
[
'#attached'
][
'library'
][]
=
'confirm_leave/confirm-leave'
;
}
This diff is collapsed.
Click to expand it.
js/confirm-leave.js
+
4
−
2
View file @
c67b864e
...
...
@@ -14,14 +14,16 @@
*/
Drupal
.
behaviors
.
confirmLeave
=
{
attach
:
function
(
context
,
settings
)
{
$
(
'
form :input
'
).
on
(
'
change
'
,
function
(
e
)
{
$
(
'
.form-item
'
).
on
(
'
formUpdated
'
,
function
(
e
)
{
$
(
'
form
'
).
addClass
(
'
form-updated
'
);
window
.
onbeforeunload
=
function
(
e
)
{
let
dialogText
=
'
Are you sure?
'
;
e
.
returnValue
=
dialogText
;
return
dialogText
;
}
$
(
'
.form
-submit
'
).
on
(
'
click
'
,
function
(
e
)
{
$
(
'
#edit
-submit
'
).
on
(
'
click
'
,
function
(
e
)
{
window
.
onbeforeunload
=
null
;
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment