From: zuber Date: Wed, 30 Dec 2009 14:28:43 +0000 (+0100) Subject: Poprawienie serializacji X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/605e54d1303b67d8cabc742ec1e7df45ff0d9102?ds=inline Poprawienie serializacji --- diff --git a/platforma/static/js/main.js b/platforma/static/js/main.js index ff0d626b..c1af60a5 100644 --- a/platforma/static/js/main.js +++ b/platforma/static/js/main.js @@ -1,7 +1,58 @@ +var MARGIN = { + dramat_wierszowany_l: 4, + dramat_wierszowany_lp: 4, + dramat_wspolczesny: 4, + wywiad: 4, + opowiadanie: 4, + powiesc: 4, + liryka_l: 4, + liryka_lp: 4, + naglowek_czesc: 4, + naglowek_akt: 4, + naglowek_rozdzial: 4, + naglowek_osoba: 4, + lista_osob: 4, + + akap: 3, + akap_cd: 3, + akap_dialog: 3, + strofa: 3, + motto: 3, + miejsce_czas: 3, + + autor_utworu: 2, + nazwa_utworu: 2, + dzielo_nadrzedne: 2, + didaskalia: 2, + motto_podpis: 2, + naglowek_listy: 2, + + kwestia: 1, + lista_osoba: 1 +} + +MARGIN['rdf:RDF'] = 3; +MARGIN['rdf:Description'] = 2; + +function elementType(element) { + if ($.inArray(element.tagName, ['akap', 'akap_cd', 'akap_dialog', 'strofa', 'didaskalia', 'wers', 'wers_cd', 'wers_akap', 'wers_wciety', 'autor_utworu', 'nazwa_utworu', 'dzielo_nadrzedne', 'podpis'])) { + return 'inline'; + } else { + return 'block'; + } +} // Serializuje XML, wstawiając odpowiednie ilości białych znaków między elementami -function serialize(element) { +function serialize(element, mode) { + if (!mode) { + mode = 'block'; + } + if (element.nodeType == 3) { // tekst - return [$.trim(element.nodeValue)]; + if (mode == 'block') { + return [$.trim(element.nodeValue)]; + } else { + return [element.nodeValue]; + } } else if (element.nodeType != 1) { // pomijamy węzły nie będące elementami XML ani tekstem return []; } @@ -9,6 +60,14 @@ function serialize(element) { var result = []; var hasContent = false; + if (MARGIN[element.tagName]) { + for (var i=0; i < MARGIN[element.tagName]; i++) { + result.push('\n'); + }; + } else if (element.tagName.indexOf('dc:') != -1) { + result.push('\n'); + } + result.push('<'); result.push(element.tagName); @@ -40,7 +99,8 @@ function serialize(element) { result.push('>'); for (var i=0; i < element.childNodes.length; i++) { - result = result.concat(serialize(element.childNodes[i])); + result = result.concat(serialize(element.childNodes[i], + mode == 'inline' ? 'inline' : elementType(element.childNodes[i]))); } result.push(''); } - if (element.tagName == 'akap' || element.tagName == 'akap_dialog' || element.tagName == 'akap_cd' || element.tagName == 'strofa') { - result.push('\n\n\n'); - } else if (element.tagName == 'naglowek_rozdzial') { - result.push('\n\n'); - } else if (element.tagName == 'rdf:RDF') { - result.push('\n\n\n\n\n'); - } else if (element.tagName.indexOf('dc:') != -1) { - result.push('\n'); - } - return result; }; @@ -274,17 +324,60 @@ function html(element) { var range = document.createRange(); var s = $(".motyw[theme-class='"+themeId+"']")[0]; var e = $(".end[theme-class='"+themeId+"']")[0]; - // console.log('Selecting range:', themeId, range, s, e); if(s && e) { range.setStartAfter(s); range.setEndBefore(e); selection.addRange(range); - // highlight('yellow'); - // selection.removeAllRanges(); } }; + // function openForEdit($origin) + // { + // // if(this.currentOpen && this.currentOpen != $origin) { + // // this.closeWithSave(this.currentOpen); + // // } + // + // var $box = null + // + // // annotations overlay their sub box - not their own box // + // if($origin.is(".annotation-inline-box")) + // $box = $("*[x-annotation-box]", $origin); + // else + // $box = $origin; + // + // var x = $box[0].offsetLeft; + // var y = $box[0].offsetTop; + // var w = $box.outerWidth(); + // var h = $box.innerHeight(); + // + // console.log("Edit origin:", $origin, " box:", $box); + // console.log("offsetParent:", $box[0].offsetParent); + // console.log("Dimensions: ", x, y, w , h); + // + // // start edition on this node + // var $overlay = $('
'); + // + // h = Math.max(h - 20, 2*parseInt($box.css('line-height'))); + // + // console.log(h); + // + // $overlay.css({ + // position: 'absolute', + // height: h, + // left: x, + // top: y, + // right: 0 + // }); + // + // $($box[0].offsetParent).append($overlay); + // console.log($overlay); + // } + // + // $('.edit-button').live('click', function() { + // openForEdit($(this).parent()); + // }); + // var button = $(''); $(element).bind('mousemove', function(event) { var editable = $(event.target).closest('*[x-editable]'); diff --git a/platforma/static/xsl/html2wl_client.xsl b/platforma/static/xsl/html2wl_client.xsl index 76602938..4a5ab968 100755 --- a/platforma/static/xsl/html2wl_client.xsl +++ b/platforma/static/xsl/html2wl_client.xsl @@ -7,7 +7,7 @@ xmlns:dc="http://purl.org/dc/elements/1.1/" > - + diff --git a/platforma/static/xsl/wl2html_client.xsl b/platforma/static/xsl/wl2html_client.xsl index 8cd780ed..fa3665bf 100755 --- a/platforma/static/xsl/wl2html_client.xsl +++ b/platforma/static/xsl/wl2html_client.xsl @@ -680,7 +680,7 @@ - + diff --git a/platforma/templates/wiki/document_details.html b/platforma/templates/wiki/document_details.html index e5c9d0c0..6d4823b5 100644 --- a/platforma/templates/wiki/document_details.html +++ b/platforma/templates/wiki/document_details.html @@ -54,9 +54,9 @@ -