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