Removed the global evil.
[redakcja.git] / platforma / static / js / main.js
index a044b87..f94e04e 100644 (file)
@@ -328,9 +328,8 @@ function reverseTransform(editor, cont, errorCont, dontBlock) {
         $.blockUI({message: 'Ładowanie...'});
     }
     setTimeout(function() {
         $.blockUI({message: 'Ładowanie...'});
     }
     setTimeout(function() {
-        html2xml({
-                       htmlElement: $('#html-view div').get(0),
-            /* xml: serializer.serializeToString($('#html-view div').get(0)), */
+        html2text({
+                       element: $('#html-view div').get(0),            
             success: function(text) {
                 editor.setCode(text);
                 if (!dontBlock) {
             success: function(text) {
                 editor.setCode(text);
                 if (!dontBlock) {
@@ -399,7 +398,7 @@ function html(element) {
         return true;
     }
        
         return true;
     }
        
-       var ANNOT_ALLOWED = ['wyroznienie'];
+       var ANNOT_ALLOWED = ['wyroznienie', 'slowo_obce', 'osoba'];
        
        function html2plainText(fragment) {
                var text = "";
        
        function html2plainText(fragment) {
                var text = "";
@@ -596,9 +595,9 @@ function html(element) {
         
         var serializer = new XMLSerializer();
         
         
         var serializer = new XMLSerializer();
         
-        html2xml({
-            xml: serializer.serializeToString($box[0]),
-            inner: true,
+        html2text({
+            element: $box[0],
+            stripOuter: true,
             success: function(text) {
                 $('textarea', $overlay).val($.trim(text));
                 
             success: function(text) {
                 $('textarea', $overlay).val($.trim(text));
                 
@@ -617,7 +616,7 @@ function html(element) {
                     xml2html({
                         xml: '<' + nodeName + '>' + insertedText + '</' + nodeName + '>',
                         success: function(element) {
                     xml2html({
                         xml: '<' + nodeName + '>' + insertedText + '</' + nodeName + '>',
                         success: function(element) {
-                            $box.html($(element).html());
+                            $origin.html($(element).html());
                             $overlay.remove();
                         },
                         error: function(text) {
                             $overlay.remove();
                         },
                         error: function(text) {
@@ -662,7 +661,7 @@ function html(element) {
         }
         if (editable.is('.annotation-inline-box')) {
             $('*[x-annotation-box]', editable)
         }
         if (editable.is('.annotation-inline-box')) {
             $('*[x-annotation-box]', editable)
-                .css({width: 300, position: 'absolute', left: event.clientX - editable.offset().left + 5, top: event.clientY - editable.offset().top + 5})
+                .css({position: 'absolute', left: event.clientX - editable.offset().left + 5, top: event.clientY - editable.offset().top + 5})
                 .show();
         } else {
             $('*[x-annotation-box]').hide();
                 .show();
         } else {
             $('*[x-annotation-box]').hide();
@@ -716,7 +715,7 @@ function refreshHistory(callback){
                                        +'<td>'+ this[1]+'</td></tr>')                  
                        });                                                     
                        $.unblockUI();  
                                        +'<td>'+ this[1]+'</td></tr>')                  
                        });                                                     
                        $.unblockUI();  
-                       callback();
+                       if(callback) callback();
                }
        });
 };
                }
        });
 };
@@ -764,13 +763,14 @@ $(function() {
     CodeMirror.fromTextArea('id_text', {
         parserfile: 'parsexml.js',
         path: STATIC_URL + "js/lib/codemirror/",
     CodeMirror.fromTextArea('id_text', {
         parserfile: 'parsexml.js',
         path: STATIC_URL + "js/lib/codemirror/",
-        stylesheet: STATIC_URL + "css/xmlcolors.css",
+        stylesheet: STATIC_URL + "css/xmlcolors_15032010.css",
         parserConfig: {
             useHTMLKludges: false
         },
         parserConfig: {
             useHTMLKludges: false
         },
-        iframeClass: 'xml-iframe',
+        iframeClass: 'xml-iframe',             
         textWrapping: true,
         textWrapping: true,
-               /* lineNumbers: true, */
+               lineNumbers: true, 
+               width: "100%",
         tabMode: 'spaces',
         indentUnit: 0,
         initCallback: function(editor) {
         tabMode: 'spaces',
         indentUnit: 0,
         initCallback: function(editor) {
@@ -887,15 +887,18 @@ $(function() {
     $('.vsplitbar').click(function() {
         if ($('#sidebar').width() == 0) {
             $('#sidebar').width(480).css({right: 0}).show();
     $('.vsplitbar').click(function() {
         if ($('#sidebar').width() == 0) {
             $('#sidebar').width(480).css({right: 0}).show();
-            $('#source-editor, #simple-editor').css({right: 495});
+            $('#editor .editor').css({right: 495});
             $('.vsplitbar').css({right: 480}).addClass('active');
         } else {
             $('#sidebar').width(0).hide();
             $('.vsplitbar').css({right: 480}).addClass('active');
         } else {
             $('#sidebar').width(0).hide();
-            $('#source-editor, #simple-editor').css({right: 15});
+            $('#editor .editor').css({right: 15});
             $('.vsplitbar').css({right: 0}).removeClass('active');
         }
         $(window).resize();
     });
             $('.vsplitbar').css({right: 0}).removeClass('active');
         }
         $(window).resize();
     });
-                
+       
+       $(window).bind('beforeunload', function(event) {
+               return "Na stronie mogą być niezapisane zmiany.";                                                             
+       });                
 
 });
 
 });