Skip to content

Commit

Permalink
Attempt to handle .btn-cancel with a single template in form.xsl
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Nov 17, 2024
1 parent 8fc67d4 commit 042e35b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ exclude-result-prefixes="#all"

<!-- XHTML block cancel onclick - prioritize over resource content -->

<xsl:template match="div[@typeof = '&ldh;XHTML']//button[contains-token(@class, 'btn-cancel')]" mode="ixsl:onclick" priority="2">
<!-- <xsl:template match="div[@typeof = '&ldh;XHTML']//button[contains-token(@class, 'btn-cancel')]" mode="ixsl:onclick" priority="2">
<xsl:variable name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
<xsl:variable name="container" select="ancestor::div[@typeof][1]" as="element()"/>
<xsl:message>XHTML block cancel onclick</xsl:message>
<xsl:choose>
<!-- restore existing block -->
restore existing block
<xsl:when test="$block/@about">
<xsl:variable name="textarea" select="ancestor::div[contains-token(@class, 'main')]//textarea[contains-token(@class, 'wymeditor')]" as="element()"/>
<xsl:variable name="old-xhtml-string" select="string($textarea)" as="xs:string"/>
Expand All @@ -276,44 +276,44 @@ exclude-result-prefixes="#all"
</xsl:result-document>
</xsl:for-each>
</xsl:when>
<!-- remove block that hasn't been saved yet -->
remove block that hasn't been saved yet
<xsl:otherwise>
<xsl:for-each select="$block">
<xsl:sequence select="ixsl:call(., 'remove', [])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:template>-->

<!-- resource content/SPARQL content cancel onclick -->

<xsl:template match="div[@typeof = ('&ldh;View', '&ldh;Object')]//button[contains-token(@class, 'btn-cancel')]" mode="ixsl:onclick" priority="1"> <!-- prioritize over form.xsl -->
<!-- <xsl:template match="div[@typeof = ('&ldh;View', '&ldh;Object')]//button[contains-token(@class, 'btn-cancel')]" mode="ixsl:onclick" priority="1"> prioritize over form.xsl
<xsl:variable name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
<!-- <xsl:variable name="container" select="ancestor::div[@typeof][1]" as="element()"/>-->
<xsl:variable name="container" select="ancestor::div[@typeof][1]" as="element()"/>
<xsl:message>resource block</xsl:message>
<xsl:choose>
<!-- updating existing block -->
updating existing block
<xsl:when test="$block/@about">
<xsl:for-each select="$block">
<xsl:variable name="doc" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(xs:anyURI(ixsl:location())) || '`'), 'results')" as="document-node()"/>
<!-- TO-DO: restore block HTML from cache -->
<!--
TO-DO: restore block HTML from cache
<xsl:apply-templates select="." mode="ldh:LoadBlock">
<xsl:with-param name="doc" select="$doc"/>
</xsl:apply-templates>
-->
</xsl:for-each>
</xsl:when>
<!-- remove content that hasn't been saved yet -->
remove content that hasn't been saved yet
<xsl:otherwise>
<xsl:for-each select="$block">
<xsl:sequence select="ixsl:call(., 'remove', [])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:template>-->

<!-- start dragging content (or its descendants) -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ exclude-result-prefixes="#all"

<!-- disable inline editing form (do nothing if the button is disabled) -->

<xsl:template match="div[@about][@typeof = ('&ldh;ResultSetChart', '&ldh;GraphChart')]//button[contains-token(@class, 'btn-cancel')][not(contains-token(@class, 'disabled'))]" mode="ixsl:onclick" priority="1">
<!-- <xsl:template match="div[@about][@typeof = ('&ldh;ResultSetChart', '&ldh;GraphChart')]//button[contains-token(@class, 'btn-cancel')][not(contains-token(@class, 'disabled'))]" mode="ixsl:onclick" priority="1">
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
<xsl:variable name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
<xsl:variable name="container" select="ancestor::div[@typeof][1]" as="element()"/>
Expand All @@ -569,7 +569,7 @@ exclude-result-prefixes="#all"
<xsl:message>ldh:base-uri(.): <xsl:value-of select="ldh:base-uri(.)"/></xsl:message>
<xsl:message>ixsl:location(): <xsl:value-of select="ixsl:location()"/></xsl:message>
<!-- not using ldh:base-uri(.) because it goes stale when DOM is replaced -->
not using ldh:base-uri(.) because it goes stale when DOM is replaced
<xsl:variable name="doc" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(xs:anyURI(ixsl:location())) || '`'), 'results')" as="document-node()"/>
<xsl:variable name="chart" select="key('resources', $about, $doc)" as="element()"/>
Expand All @@ -578,7 +578,7 @@ exclude-result-prefixes="#all"
</xsl:apply-templates>
<ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>
</xsl:template>
</xsl:template>-->

<!-- CALLBACKS -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,8 @@ WHERE

<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>

<xsl:message>ixsl:get(., 'baseURI'): <xsl:value-of select="ixsl:get(., 'baseURI')"/></xsl:message>
<xsl:message>ldh:base-uri(.): <xsl:value-of select="ldh:base-uri(.)"/></xsl:message>
<xsl:message>ixsl:location(): <xsl:value-of select="ixsl:location()"/></xsl:message>

<!-- retrieve HTML stored before editing mode was enabled -->
<xsl:variable name="block-html" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || $about || '`'), 'block-html')" as="element()"/>
<xsl:message>$block: <xsl:value-of select="serialize($block)"/></xsl:message>
<xsl:message>$block-html: <xsl:value-of select="serialize($block-html)"/></xsl:message>

<!-- restore snapshot of block HTML that was captured before entering editing mode -->
<xsl:for-each select="$block">
Expand Down

0 comments on commit 042e35b

Please sign in to comment.