Konwersja HTML do XML przed zapisaniem XML na serwer.
authorzuber <marek@stepniowski.com>
Fri, 15 Jan 2010 00:05:55 +0000 (01:05 +0100)
committerzuber <marek@stepniowski.com>
Fri, 15 Jan 2010 00:05:55 +0000 (01:05 +0100)
platforma/static/js/main.js
platforma/templates/base.html

index de84835..a19dc14 100644 (file)
@@ -253,7 +253,7 @@ function transform(editor) {
 };
 
 
-function reverseTransform(editor) {
+function reverseTransform(editor, cont) {
     var serializer = new XMLSerializer();
     if ($('#html-view .error').length > 0) {
         return;
@@ -265,6 +265,9 @@ function reverseTransform(editor) {
             success: function(text) {
                 editor.setCode(text);
                 $.unblockUI();
+                if (cont) {
+                    cont();
+                }
             }, error: function(text) {
                 $('#source-editor').html('<p>Wystąpił błąd:</p><pre>' + text + '</pre>');
                 $.unblockUI();
@@ -410,41 +413,49 @@ $(function() {
             $('#save-ok').click(function() {
                 $.blockUI({message: 'Zapisywanie...'});
                 
-                var metaComment = '<!--';
-                $('#document-meta div').each(function() {
-                    metaComment += '\n\t' + $(this).attr('class') + ': ' + $(this).html();
-                });
-                metaComment += '\n-->'
-                
-                var data = {
-                    name: $('#document-name').html(),
-                    text: metaComment + editor.getCode(),
-                    revision: $('#document-revision').html(),
-                    author: 'annonymous',
-                    comment: $('#komentarz').val()
-                };
-                
-                console.log(data);
+                function doSave (argument) {
+                    var metaComment = '<!--';
+                    $('#document-meta div').each(function() {
+                        metaComment += '\n\t' + $(this).attr('class') + ': ' + $(this).html();
+                    });
+                    metaComment += '\n-->'
+
+                    var data = {
+                        name: $('#document-name').html(),
+                        text: metaComment + editor.getCode(),
+                        revision: $('#document-revision').html(),
+                        author: 'annonymous',
+                        comment: $('#komentarz').val()
+                    };
+
+                    console.log(data);
+
+                    $.ajax({
+                        url: document.location.href,
+                        type: "POST",
+                        dataType: "json",
+                        data: data,                
+                        success: function(data) {
+                            if (data.text) {
+                                editor.setCode(data.text);
+                                $('#document-revision').html(data.revision);
+                            } else {
+                                console.log(data.errors);
+                                alert(data.errors);
+                            }
+                            $.unblockUI();
+                        },
+                        error: function(xhr, textStatus, errorThrown) {
+                            alert('error: ' + textStatus + ' ' + errorThrown);
+                        },
+                    })
+                }
                 
-                $.ajax({
-                    url: document.location.href,
-                    type: "POST",
-                    dataType: "json",
-                    data: data,                
-                    success: function(data) {
-                        if (data.text) {
-                            editor.setCode(data.text);
-                            $('#document-revision').html(data.revision);
-                        } else {
-                            console.log(data.errors);
-                            alert(data.errors);
-                        }
-                        $.unblockUI();
-                    },
-                    error: function(xhr, textStatus, errorThrown) {
-                        alert('error: ' + textStatus + ' ' + errorThrown);
-                    },
-                })
+                if ('#simple-view-tab.active') {
+                    reverseTransform(editor, doSave);
+                } else {
+                    doSave();
+                }
             });
             
             $('#save-cancel').click(function() {
index 4819b7c..750cf7b 100755 (executable)
@@ -4,7 +4,8 @@
     <head>
         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
         <title>{% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%}</title>
-        <script src="{{ STATIC_URL }}js/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
+        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
+        {# <script src="{{ STATIC_URL }}js/lib/jquery.js" type="text/javascript" charset="utf-8"></script> #}
         {% block extrahead %}
         {% endblock %}
     </head>