Dotclear

source: plugins/themeEditor/script.js @ 2905:a7a0df6048be

Revision 2905:a7a0df6048be, 1.2 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Do not prompt for unsaved changes if everything is saved
Closes #2025

RevLine 
[0]1$(function() {
[2663]2     // Cope with saving
[0]3     var msg = false;
[2905]4     $('#file-form input[name="write"]').click(function(e) {
[0]5          var f = this.form;
[2566]6
[0]7          var data = {
[948]8               file_content: (!dotclear.colorsyntax ? $(f).find('#file_content').get(0).value : editor.getValue()),
[0]9               xd_check: $(f).find('input[name="xd_check"]').get(0).value,
10               write: 1
11          };
[2566]12
[0]13          if (msg == false) {
14               msg = $('<p style="font-weight:bold; color:red;"></p>');
15               $('#file_content').parent().after(msg);
16          }
[2566]17
[0]18          msg.text(dotclear.msg.saving_document);
[2566]19
[0]20          $.post(document.location.href,data,function(res,status) {
21               var err = $(res).find('div.error li:first');
22               if (err.length > 0) {
23                    msg.text(dotclear.msg.error_occurred + ' ' + err.text());
24                    return;
25               } else {
26                    msg.text(dotclear.msg.document_saved);
27                    $('#file-chooser').empty();
28                    $(res).find('#file-chooser').children().appendTo('#file-chooser');
[2902]29
[2905]30                    if ($.isFunction(confirmClosePage['getCurrentForms'])) {
31                         confirmClosePage.forms = [];
32                         confirmClosePage.getCurrentForms();
33                    }
[0]34               }
35          });
[2566]36
[2905]37          e.preventDefault();
[0]38     });
[2663]39
40     // Confirm for deleting current file
41     $('#file-form input[name="delete"]').click(function() {
42          return window.confirm(dotclear.msg.confirm_reset_file);
43     });
44
[2566]45});
Note: See TracBrowser for help on using the repository browser.

Sites map