edit: replace save confirmation by page close protection
[minimedit.git] / edit.js
diff --git a/edit.js b/edit.js
index 3fd8230e4a78783ac3fb50d3c1b8feab6b63b75f..dfa4a6d099eee90f3cad28bd6f02e34933607eae 100644 (file)
--- a/edit.js
+++ b/edit.js
@@ -19,7 +19,7 @@ CKEDITOR.plugins.add('inlinesave', {
                                        if (ajaxpost.status != 200)
                                                alert('Foutcode '+ajaxpost.status+' bij opslaan: '+ajaxpost.responseText);
                                        else
-                                               alert('Pagina is goed opgeslagen');
+                                               editor.resetDirty();
                                };
                                ajaxpost.send(data);
                        },
@@ -56,11 +56,11 @@ CKEDITOR.on('instanceCreated', function (event) {
                config.forcePasteAsPlainText = true;
                config.contentsCss = document.styleSheets[0].href;
                config.toolbar = [
-                       ['Inlinesave', '-', 'ShowBlocks', 'Sourcedialog', '-', 'Undo', 'Redo'],
-                       ['Format'],
-                       ['BulletedList', 'NumberedList', '-', 'Blockquote'],
-                       ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', '-', 'Anchor', 'Link'],
-                       ['HorizontalRule', 'Table', 'Image', 'CreatePlaceholder'],
+                       ['Inlinesave', '-', 'Undo', 'Redo'],
+                       ['Format', 'BulletedList', 'NumberedList', 'Blockquote'],
+                       ['Bold', 'Italic', 'Link'],
+                       ['HorizontalRule', 'Table', 'Image'],
+                       ['CreatePlaceholder', 'Sourcedialog'],
                ];
                config.toolbarCanCollapse = true;
                config.floatSpacePreferRight = true;
@@ -70,6 +70,12 @@ CKEDITOR.on('instanceCreated', function (event) {
                config.disableObjectResizing = true;
                document.execCommand('enableObjectResizing', false, false); // workaround in inline mode; ff bug?
        });
+
+       window.onbeforeunload = function () {
+               if (editor.checkDirty()) {
+                       return 'Pagina verlaten zonder wijzigingen op te slaan?'; // message ignored in modern browsers
+               }
+       };
 });
 
        CKEDITOR.disableAutoInline = true;