Skip to content

Commit ff5204b

Browse files
committed
notify user if there are any unsaved changes
1 parent 1847d5e commit ff5204b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/assets/EditorAsset.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use yii\bootstrap\BootstrapAsset;
1414
use yii\web\AssetBundle;
15+
use yii\web\JqueryAsset;
1516

1617
/**
1718
* @package dmstr\modules\prototype\assets
@@ -29,6 +30,7 @@ class EditorAsset extends AssetBundle
2930
];
3031

3132
public $depends = [
32-
BootstrapAsset::class
33+
BootstrapAsset::class,
34+
JqueryAsset::class
3335
];
3436
}

src/assets/web/editor/js/editor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ $(function(){
1919
}
2020

2121
if (window.location.pathname.indexOf('new') > -1) {
22-
console.log('YES');
2322
tabEl = $('.editor-top-navigation a[data-target="#tab-9999999"]');
2423
}
2524

@@ -31,5 +30,10 @@ $(function(){
3130
var newActiveHash = $(e.target).data('target');
3231
window.location.hash = newActiveHash;
3332
localStorage.setItem(localStorageKey, newActiveHash);
34-
})
33+
});
34+
35+
// remember user to save stuff
36+
window.onbeforeunload = function() {
37+
return true;
38+
};
3539
});

0 commit comments

Comments
 (0)