* Fixed infinite loop in HTMLSerializer.
authorŁukasz Rekucki <lrekucki@gmail.com>
Fri, 12 Mar 2010 12:52:36 +0000 (13:52 +0100)
committerŁukasz Rekucki <lrekucki@gmail.com>
Fri, 12 Mar 2010 12:52:36 +0000 (13:52 +0100)
* Added styles for indented verses, notes and new annotation styles.

platforma/static/css/html.css
platforma/static/js/main.js
platforma/static/js/xslt.js
platforma/static/xsl/wl2html_client.xsl

index fc8988f..e3d9a4a 100644 (file)
@@ -15,6 +15,7 @@
 
 .htmlview * {
     position: relative;
+       overflow: visibl;
 }
 
 .htmlview div {
     margin: 1.5em 0 0 auto;    
 }
 
+/* wersy */
+.htmlview .strofa .wers_wciety, .htmlview .strofa .wers_wciety[data-wlf-typ='1'] {
+       margin-left: 1em;
+}
+
+.htmlview .strofa .wers_wciety[data-wlf-typ='2'] {
+       margin-left: 2em;
+}
+
+.htmlview .strofa .wers_wciety[data-wlf-typ='3'] {
+       margin-left: 3em;
+}
+
+.htmlview .strofa .wers_wciety[data-wlf-typ='4'] {
+       margin-left: 4em;
+}
+
+.htmlview .strofa .wers_wciety[data-wlf-typ='5'] {
+       margin-left: 5em;
+}
+
+.htmlview .strofa .wers_wciety[data-wlf-typ='6'] {
+       margin-left: 6em;
+}
+
+/* błędne wersy */
+.htmlview *:not(.strofa) > *[x-verse]::after {
+       content: "Ten wers znajduje się poza strofą.";
+       display: inline;
+       background: red;
+       font-size: 8pt;
+       border: 1px solid black;
+       -moz-border-radius: 10px;
+       -webkit-border-radius: 10px;
+       padding: 1px 1em;
+       margin-left: 1em;
+       vertical-align: super;
+}
+
+
 .htmlview .kwestia .strofa {
     margin: 0;
 }
     margin: 1.5em 0 0;
 }
 
-.htmlview p.motto {
+.htmlview .motto {
     text-align: justify;
     font-style: italic;
     margin: 1.5em 0 0;
     font-weight: bold;
 }
 
+/* Uwaga/Extra */
+
+.htmlview .uwaga {
+       background-color: #96e0e4;
+       border: 1px solid black;
+       -moz-border-radius: 10px;
+       -webkit-border-radius: 10px;
+       display: block;
+       font-size: 10pt;
+       line-height: 12pt;
+       padding: 2px 1em;
+       float: right;   
+       max-width: 20%;
+       max-height: 24pt;
+       margin-left: 0.5em;
+       overflow: hidden;
+}
+
+.utwor > .uwaga {
+       float: none;
+       padding: 0.5em 1em;
+       margin: 1em;
+       max-width: 100%;
+       max-height: 100%;
+}
+
+.htmlview .uwaga:hover {
+       max-height: 100%;
+}
+
 
 /* Motywy */
 /* ======================== */
 }
 
 .htmlview .annotation:hover {
-    background-color: #dfdfdf;
+    background-color: #96e0e4;
 }
 
 *.htmlview *.annotation-inline-box {
      display: none;
      position: absolute;
 
-     max-width: 36em;
+     width: 300px;      
      
-     font-size: 8pt;
+     font-size: 10pt;  
      line-height: 12pt;
      font-weight: normal;
      font-style: normal;
 
-     background: white;
-     border-color: gray;
-     border-width: 2px;
-     border-style: outset;
+     background: #fffe93;
+     border-color: black;
+     border-width: 1px;
+     border-style: solid;
+        border-radius: 10px;
+        -moz-border-radius: 10px;
+        -webkit-border-radius: 10px;
+        
      padding: 3px 5px;
 
      text-decoration: none;
+        
      z-index: 1000;
  }
  
 /*    background-color: ivory;*/
 }
 
-.out-of-flow-text {
-    border: 1px solid #BEBEBE;
-    background-color: #E2E2E1;
-    white-space: pre-line;
-    font-family: monospace;
-}
-
-.out-of-flow-text[x-editable] {
-    background-color: #E2E2E1;    
+.htmlview .out-of-flow-text {
+       display: block;
+       font-face: monospace;
+    border: 2px solid red !important;
+    white-space: pre-line;    
+}
+
+.htmlview .out-of-flow-text::before {
+       content: "Tekst w tej ramce nie jest otagowany!";
+       background-color: #ff6c6c;
+       color: black;
+       
+       font-size: 10pt;
+       line-height: 12pt;
+       border: 1px solid black;
+       -moz-border-radius: 10px;
+       -webkit-border-radius: 10px;
+       padding: 5px 1em;
+       margin: 0em;
+       margin-left: 1em;
+       
+       text-align: justify;
+       
+       display: inline;
+       float: right;
+       max-width: 25%;
 }
 
 .unknown-tag {
index b98e1c2..270e3cc 100644 (file)
@@ -661,7 +661,7 @@ function html(element) {
         }
         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();
index 6cc545a..f5af909 100644 (file)
@@ -124,10 +124,10 @@ const PADDING = {
     lista_osoba: 1,
        
        "podpis": 1,    
-       "wers": 1,
-       "wers_cd": 1,
-       "wers_akap": 1,
-       "wers_wciety": 1,       
+       "wers": 0,
+       "wers_cd": 0,
+       "wers_akap": 0,
+       "wers_wciety": 0,       
        
        "rdf:RDF": 3,
        "rdf:Description": 1,   
@@ -182,12 +182,11 @@ HTMLSerializer.prototype._pushTagEnd = function(tagName) {
 HTMLSerializer.prototype._verseBefore = function(node) {
        var prev = node.previousSibling;
        
-       while(prev) {
-               if(prev.nodeType == ELEMENT_NODE && prev.hasAttribute('x-verse'))
-                       return true;
-       }
-       
-       return false;
+       while((prev !== null) && (prev.nodeType != ELEMENT_NODE)) {
+               prev = prev.previousSibling;
+       }       
+               
+       return (prev !== null) && prev.hasAttribute('x-verse');
 }
 
 HTMLSerializer.prototype.serialize = function(rootElement, stripOuter) 
index 2326d26..c65eabf 100644 (file)
 
     <xsl:template match="wers_cd|wers_akap|wers_wciety">
         <xsl:param name="mixed" />
-        <p x-verse="true">
-            <xsl:call-template name="standard-attributes" />
-            <xsl:apply-templates select="child::node()">
-                <xsl:with-param name="mixed" select="true()" />
-            </xsl:apply-templates>
-        </p>
+               <!-- <xsl:choose>
+               <xsl:when test="ancestor::*[0]/self::strofa"> -->
+               <p x-verse="true">
+               <xsl:call-template name="standard-attributes" />
+               <xsl:apply-templates select="child::node()">
+                       <xsl:with-param name="mixed" select="true()" />
+               </xsl:apply-templates>
+               </p>
+               <!-- </xsl:when> 
+               <xsl:choose> -->
     </xsl:template>
 
     <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
     <xsl:template match="extra|uwaga">
         <span>
             <xsl:call-template name="standard-attributes" />
-            <xsl:apply-templates select="node()" />
+            <xsl:apply-templates select="child::node()">
+                <xsl:with-param name="mixed" select="true()" />
+            </xsl:apply-templates>
         </span>
     </xsl:template>
 
     </xsl:template>
 
     <xsl:template match="*[name() != local-name()]">
-        <div>
+        <span>
             <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
-        </div>
+        </span>
     </xsl:template>
+       
+       <!-- 
+               Earlier versions of html2wl introduced a BUG, that 'causes "out-of-flow-text" tag to appear.
+               Instead of marking it as "unknown", just pass thru it
+       -->
+       <xsl:template match="out-of-flow-text">
+               <xsl:param name="mixed" />
+               <xsl:apply-templates select="child::node()">
+                <xsl:with-param name="mixed" select="$mixed" />
+            </xsl:apply-templates>
+       </xsl:template> 
 
     <xsl:template match="*">
-        <div class="unknown-tag" x-node="{name()}">
+        <span class="unknown-tag" x-node="{name()}">
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>        
-        </div>
+        </span>
     </xsl:template>
 
     <xsl:template name="context-menu">
             <xsl:variable name="id" select="generate-id()" />
             <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
             <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
-            <xsl:if test="namespace-uri()">
+            <xsl:choose>
+               <xsl:when test="namespace-uri()">
                 <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
-            </xsl:if>               
+                               </xsl:when>
+                               <!-- if the element belongs to default namespace and attribut has no namespace -->
+               <xsl:when test="not(namespace-uri(.))">
+                               <xsl:attribute name="data-wlf-{local-name()}"><xsl:value-of select="."/></xsl:attribute>
+                               </xsl:when>
+                       </xsl:choose>               
         </xsl:for-each>
     </xsl:template>