mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-18 11:10:56 +01:00
Merge branch 'feature/fix-alert-unsaved-changes' into develop
This commit is contained in:
@@ -113,6 +113,9 @@
|
||||
scanToggleable(this);
|
||||
scan(this);
|
||||
this.scanned = true;
|
||||
|
||||
//Refresh root.currentValues as toggleables have been initialized
|
||||
root.currentValues = getState();
|
||||
};
|
||||
|
||||
Form.factories = {};
|
||||
|
||||
@@ -11,9 +11,12 @@ var getState = function(){
|
||||
};
|
||||
|
||||
$(function(){
|
||||
var root = window || {};
|
||||
root = root.GravJS = root.GravJS || {};
|
||||
|
||||
var currentValues = getState(),
|
||||
clickedLink;
|
||||
//Make it global because used by ./forms/form.js
|
||||
root.currentValues = getState();
|
||||
var clickedLink;
|
||||
|
||||
// selectize
|
||||
$('input.page-filter').selectize({
|
||||
@@ -209,7 +212,7 @@ $(function(){
|
||||
var value = $(this).val(),
|
||||
uri = $(this).data('leave-url');
|
||||
|
||||
if (currentValues == getState()) {
|
||||
if (root.currentValues == getState()) {
|
||||
setTimeout(function(){
|
||||
window.location.href = uri;
|
||||
}, 200)
|
||||
@@ -242,7 +245,7 @@ $(function(){
|
||||
});
|
||||
|
||||
$('a[href]:not([href^=#])').on('click', function(e){
|
||||
if (currentValues != getState()){
|
||||
if (root.currentValues != getState()){
|
||||
e.preventDefault();
|
||||
|
||||
clickedLink = $(this).attr('href');
|
||||
@@ -284,7 +287,7 @@ $(function(){
|
||||
});
|
||||
|
||||
$(window).on('beforeunload', function(){
|
||||
if (currentValues != getState()){
|
||||
if (root.currentValues != getState()){
|
||||
return "You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will lose your unsaved changes";
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user