Skip to content

Commit 8ea7cb6

Browse files
committed
Fixed OpenLayer map dragging
1 parent 1a272b0 commit 8ea7cb6

File tree

2 files changed

+57
-38
lines changed
  • src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client

2 files changed

+57
-38
lines changed

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block.xsl

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -345,60 +345,80 @@ exclude-result-prefixes="#all"
345345
</xsl:template>
346346

347347
<!-- dragging block over other block -->
348-
348+
349349
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragover">
350-
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
351-
<ixsl:set-property name="dataTransfer.dropEffect" select="'move'" object="ixsl:event()"/>
350+
<!-- only handle if drag originated from drag-handle (has text/uri-list item) -->
351+
<xsl:variable name="items" select="ixsl:get(ixsl:get(ixsl:event(), 'dataTransfer'), 'items')"/>
352+
<xsl:variable name="has-uri-item" select="if (ixsl:get($items, 'length') > 0) then ixsl:get(ixsl:get($items, '0'), 'type') = 'text/uri-list' else false()" as="xs:boolean"/>
353+
<xsl:if test="$has-uri-item">
354+
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
355+
<ixsl:set-property name="dataTransfer.dropEffect" select="'move'" object="ixsl:event()"/>
356+
</xsl:if>
352357
</xsl:template>
353358

354359
<!-- change the style of blocks when block is dragged over them -->
355-
360+
356361
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragenter">
357-
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', true() ])[current-date() lt xs:date('2000-01-01')]"/>
362+
<!-- only handle if drag originated from drag-handle (has text/uri-list item) -->
363+
<xsl:variable name="items" select="ixsl:get(ixsl:get(ixsl:event(), 'dataTransfer'), 'items')"/>
364+
<xsl:variable name="has-uri-item" select="if (ixsl:get($items, 'length') > 0) then ixsl:get(ixsl:get($items, '0'), 'type') = 'text/uri-list' else false()" as="xs:boolean"/>
365+
<xsl:if test="$has-uri-item">
366+
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', true() ])[current-date() lt xs:date('2000-01-01')]"/>
367+
</xsl:if>
358368
</xsl:template>
359369

360370
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragleave">
361-
<xsl:variable name="related-target" select="ixsl:get(ixsl:event(), 'relatedTarget')" as="element()?"/> <!-- the element drag entered (optional) -->
371+
<!-- only handle if drag originated from drag-handle (has text/uri-list item) -->
372+
<xsl:variable name="items" select="ixsl:get(ixsl:get(ixsl:event(), 'dataTransfer'), 'items')"/>
373+
<xsl:variable name="has-uri-item" select="if (ixsl:get($items, 'length') > 0) then ixsl:get(ixsl:get($items, '0'), 'type') = 'text/uri-list' else false()" as="xs:boolean"/>
374+
<xsl:if test="$has-uri-item">
375+
<xsl:variable name="related-target" select="ixsl:get(ixsl:event(), 'relatedTarget')" as="element()?"/> <!-- the element drag entered (optional) -->
362376

363-
<!-- only remove class if the related target does not have this div as ancestor (is not its child) -->
364-
<xsl:if test="not($related-target/ancestor-or-self::div[. is current()])">
365-
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', false() ])[current-date() lt xs:date('2000-01-01')]"/>
377+
<!-- only remove class if the related target does not have this div as ancestor (is not its child) -->
378+
<xsl:if test="not($related-target/ancestor-or-self::div[. is current()])">
379+
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', false() ])[current-date() lt xs:date('2000-01-01')]"/>
380+
</xsl:if>
366381
</xsl:if>
367382
</xsl:template>
368383

369384
<!-- dropping block over other top-level block -->
370-
385+
371386
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondrop">
372-
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
373-
<xsl:variable name="block-uri" select="@about" as="xs:anyURI?"/>
374-
<xsl:variable name="drop-block-uri" select="ixsl:call(ixsl:get(ixsl:event(), 'dataTransfer'), 'getData', [ 'text/uri-list' ])" as="xs:anyURI"/>
375-
376-
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', false() ])[current-date() lt xs:date('2000-01-01')]"/>
377-
378-
<!-- only persist the change if the block is already saved and has an @about -->
379-
<xsl:if test="$block-uri">
380-
<!-- move dropped element after this element, if they're not the same -->
381-
<xsl:if test="not($block-uri = $drop-block-uri)">
382-
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>
383-
384-
<!-- TO-DO: sketchy workaround to select block-level elements only because we might have duplicate @about values -->
385-
<xsl:variable name="drop-block" select="key('element-by-about', $drop-block-uri)[contains-token(@class, 'block')]" as="element()"/>
386-
<xsl:sequence select="ixsl:call(., 'after', [ $drop-block ])"/>
387-
<!-- TO-DO: use a VALUES block instead -->
388-
<xsl:variable name="update-string" select="replace($block-swap-string, '$this', '&lt;' || ac:absolute-path(ldh:base-uri(.)) || '&gt;', 'q')" as="xs:string"/>
389-
<xsl:variable name="update-string" select="replace($update-string, '$targetBlock', '&lt;' || $block-uri || '&gt;', 'q')" as="xs:string"/>
390-
<xsl:variable name="update-string" select="replace($update-string, '$sourceBlock', '&lt;' || $drop-block-uri || '&gt;', 'q')" as="xs:string"/>
391-
<xsl:variable name="request-uri" select="ldh:href(ac:absolute-path(ldh:base-uri(.)), map{})" as="xs:anyURI"/>
392-
<xsl:variable name="request" as="item()*">
393-
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
394-
<xsl:call-template name="onBlockSwap"/>
395-
</ixsl:schedule-action>
396-
</xsl:variable>
397-
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
387+
<!-- only handle if drag originated from drag-handle (has text/uri-list item) -->
388+
<xsl:variable name="items" select="ixsl:get(ixsl:get(ixsl:event(), 'dataTransfer'), 'items')"/>
389+
<xsl:variable name="has-uri-item" select="if (ixsl:get($items, 'length') > 0) then ixsl:get(ixsl:get($items, '0'), 'type') = 'text/uri-list' else false()" as="xs:boolean"/>
390+
<xsl:if test="$has-uri-item">
391+
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
392+
<xsl:variable name="block-uri" select="@about" as="xs:anyURI?"/>
393+
<xsl:variable name="drop-block-uri" select="ixsl:call(ixsl:get(ixsl:event(), 'dataTransfer'), 'getData', [ 'text/uri-list' ])" as="xs:anyURI"/>
394+
395+
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', false() ])[current-date() lt xs:date('2000-01-01')]"/>
396+
397+
<!-- only persist the change if the block is already saved and has an @about -->
398+
<xsl:if test="$block-uri">
399+
<!-- move dropped element after this element, if they're not the same -->
400+
<xsl:if test="not($block-uri = $drop-block-uri)">
401+
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>
402+
403+
<!-- TO-DO: sketchy workaround to select block-level elements only because we might have duplicate @about values -->
404+
<xsl:variable name="drop-block" select="key('element-by-about', $drop-block-uri)[contains-token(@class, 'block')]" as="element()"/>
405+
<xsl:sequence select="ixsl:call(., 'after', [ $drop-block ])"/>
406+
<!-- TO-DO: use a VALUES block instead -->
407+
<xsl:variable name="update-string" select="replace($block-swap-string, '$this', '&lt;' || ac:absolute-path(ldh:base-uri(.)) || '&gt;', 'q')" as="xs:string"/>
408+
<xsl:variable name="update-string" select="replace($update-string, '$targetBlock', '&lt;' || $block-uri || '&gt;', 'q')" as="xs:string"/>
409+
<xsl:variable name="update-string" select="replace($update-string, '$sourceBlock', '&lt;' || $drop-block-uri || '&gt;', 'q')" as="xs:string"/>
410+
<xsl:variable name="request-uri" select="ldh:href(ac:absolute-path(ldh:base-uri(.)), map{})" as="xs:anyURI"/>
411+
<xsl:variable name="request" as="item()*">
412+
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
413+
<xsl:call-template name="onBlockSwap"/>
414+
</ixsl:schedule-action>
415+
</xsl:variable>
416+
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
417+
</xsl:if>
398418
</xsl:if>
399419
</xsl:if>
400420
</xsl:template>
401-
421+
402422
<!-- CALLBACKS -->
403423

404424
<xsl:function name="ldh:load-block" ixsl:updating="yes" as="map(*)">

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/view.xsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ exclude-result-prefixes="#all"
697697
<xsl:apply-templates select="$results" mode="bs2:Map">
698698
<xsl:with-param name="id" select="$container-id || '-map-canvas'"/>
699699
<xsl:with-param name="endpoint" select="if (not($endpoint = sd:endpoint())) then $endpoint else ()" tunnel="yes"/>
700-
<xsl:with-param name="draggable" select="true()"/>
701700
</xsl:apply-templates>
702701
</xsl:when>
703702
<xsl:when test="$active-mode = '&ac;GraphMode'">

0 commit comments

Comments
 (0)