1 {% extends "site/layout/base_text.html" %} |
1 {% extends "site/layout/base_text.html" %} |
2 {% load i18n %} |
2 {% load i18n %} |
3 {% load com %} |
3 {% load com %} |
4 |
4 |
5 {% block head %} |
5 {% block head %} |
6 <script type="text/javascript"> |
6 <script type="text/javascript" src="{{ MEDIA_URL }}js/site/text_edit.js"></script> |
7 <!-- |
|
8 |
|
9 function check_save(){ |
|
10 needToConfirm = false; |
|
11 |
|
12 var newVersion = $('#id_new_version').attr('checked') ; |
|
13 var commentsKept = $('#id_keep_comments').attr('checked') ; |
|
14 |
|
15 var new_content = $('#id_content').val() |
|
16 var new_format = $('#id_format').val() |
|
17 |
|
18 if (commentsKept) { |
|
19 var pre_edit_url = tb_conf['pre_edit_url'] ; |
|
20 |
|
21 $.ajax({ |
|
22 url: pre_edit_url, |
|
23 type:'POST', |
|
24 dataType:"json", |
|
25 data: { "new_content": new_content, "new_format": new_format}, |
|
26 success: function(obj){ |
|
27 nb_removed = obj['nb_removed']; |
|
28 if (newVersion) { |
|
29 if (nb_removed == 0) { |
|
30 $('#edit_form').submit(); |
|
31 } |
|
32 else { |
|
33 var message = "{% blocktrans %}{nb_comments} comment(s) will be removed because the text they apply to has been changed. Do you want to continue?{% endblocktrans %}".replace("{nb_comments}", ""+nb_removed); |
|
34 $('#check_save_dialog').html(message) ; |
|
35 $('#check_save_dialog').dialog('open') ; |
|
36 } |
|
37 } |
|
38 else { |
|
39 if (nb_removed == 0) { |
|
40 $('#edit_form').submit(); |
|
41 } |
|
42 else { |
|
43 var message = "{% blocktrans %}{nb_comments} comment(s) will be lost, do you want to continue?{% endblocktrans %}".replace("{nb_comments}", ""+nb_removed); |
|
44 message = message + "<br />" + "({% blocktrans %}We suggest you create a new version{% endblocktrans %})" ; |
|
45 $('#check_save_dialog').html(message) ; |
|
46 $('#check_save_dialog').dialog('open') ; |
|
47 } |
|
48 } |
|
49 }, |
|
50 error: function(msg){ |
|
51 alert("error: " + msg); |
|
52 } |
|
53 }); |
|
54 } |
|
55 else { |
|
56 if (!newVersion) { |
|
57 var message = "{% blocktrans %}Since you chose not to create a new version all comments will be deleted, do you want to continue?{% endblocktrans %}" ; |
|
58 $('#check_save_dialog').html(message) ; |
|
59 $('#check_save_dialog').dialog('open') ; |
|
60 } |
|
61 else { |
|
62 $('#edit_form').submit(); |
|
63 } |
|
64 } |
|
65 } |
|
66 |
|
67 $(function() { |
|
68 var buttons = {}; |
|
69 buttons[gettext('No')] = function() {$(this).dialog('close');} ; |
|
70 buttons[gettext('Yes')] = function() {$(this).dialog('close');$('#edit_form').submit();} ; |
|
71 |
|
72 $('#check_save_dialog').dialog({ |
|
73 bgiframe: true, |
|
74 autoOpen: false, |
|
75 title :gettext('Warning'), |
|
76 modal: true, |
|
77 buttons:buttons |
|
78 }) ; |
|
79 |
|
80 $("#save").click(function() { check_save() ;}) ; |
|
81 }) ; |
|
82 --> |
|
83 </script> |
|
84 {% endblock %} |
7 {% endblock %} |
85 |
8 |
86 {% block main %} |
9 {% block main %} |
87 {% include "site/macros/text_editor.html" %} |
10 {% include "site/macros/text_editor.html" %} |
88 |
11 |