src/cm/templates/site/text_edit.html
changeset 0 40c8f766c9b8
child 66 7842b011403a
equal deleted inserted replaced
-1:000000000000 0:40c8f766c9b8
       
     1 {% extends "site/layout/base_text.html" %}
       
     2 {% load i18n %}
       
     3 {% load com %}
       
     4 
       
     5 {% block head %}
       
     6 <script type="text/javascript">
       
     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 %}
       
    85 
       
    86 {% block main %}
       
    87     {% include "site/macros/text_editor.html" %}
       
    88 
       
    89 <script type="text/javascript">
       
    90 <!--
       
    91 tb_conf['current_tab'] = 'edit';
       
    92 // keep get parameters!! 
       
    93 tb_conf['pre_edit_url'] = '{% url text-preedit text.key %}?{{ request.GET.urlencode }}';
       
    94 -->
       
    95 </script>
       
    96 
       
    97 <div style="display: none;">
       
    98     <div id="check_save_dialog"></div>
       
    99 </div>
       
   100 
       
   101 <div id="text_edit" class="tab-meta">
       
   102 <form id="edit_form" class="text-form wizard-form" action="." method="post">
       
   103     <table class="wide_form">
       
   104         <tbody>
       
   105             {% include "site/macros/form_fields.html" %}
       
   106     <tr>
       
   107         <td style="vertical-align: top; width: 20%; text-align:right;">
       
   108         </td>
       
   109         <td>
       
   110             <label></label>
       
   111             <input name="save" id="save" type="button" value="{% blocktrans %}Save{% endblocktrans %}"/>            
       
   112         </td>
       
   113     </tr>
       
   114         </tbody>
       
   115     </table>
       
   116 </form>
       
   117 </div>
       
   118 
       
   119 {% endblock %}