Dotclear

source: plugins/themeEditor/js/script.js @ 3709:c88e69474c34

Revision 3709:c88e69474c34, 1.3 KB checked in by franck <carnet.franck.paul@…>, 8 years ago (diff)

use strict and no more linter warnings/errors as far as possible, switch from inline js to separate loaded file

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

Sites map