Skip to content

Commit

Permalink
added preview popovers for work relators
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Feb 6, 2018
1 parent 3982c82 commit 50deaa7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
36 changes: 30 additions & 6 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ declare function app:createUrlForDoc($doc as document-node(), $lang as xs:string
: @param $lang the language switch (en, de)
: @param $attributes a sequence of attribute-value-pairs, e.g. ('class=xy', 'style=display:block')
:)
declare function app:createDocLink($doc as document-node(), $content as xs:string, $lang as xs:string, $attributes as xs:string*) as element() {
declare function app:createDocLink($doc as document-node(), $content as xs:string, $lang as xs:string, $attributes as xs:string*) as element(xhtml:a) {
let $href := app:createUrlForDoc($doc, $lang)
let $docID := $doc/root()/*/@xml:id
return
Expand All @@ -75,6 +75,26 @@ declare function app:createDocLink($doc as document-node(), $content as xs:strin
}
};

(:~
: Creates an xhtml:a link to a WeGA document with popover preview
: This is a shortcut version of the 3-arity function app:createDocLink()
:
: @author Peter Stadler
: @param $doc the document to create the link for
: @param $content the string content for the xhtml a element
: @param $lang the language switch (en, de)
: @param $attributes a sequence of attribute-value-pairs, e.g. ('class=xy', 'style=display:block')
: @param $popover whether to add class attributes for popovers
: @return a html:a element
:)
declare function app:createDocLink($doc as document-node(), $content as xs:string, $lang as xs:string, $attributes as xs:string*, $popover as xs:boolean) as element(xhtml:a) {
if($popover) then
let $docID := $doc/*/data(@xml:id)
let $docType := config:get-doctype-by-id($docID)
return app:createDocLink($doc,$content, $lang, ($attributes, string-join(('class=preview', $docType, $docID), ' ')))
else app:createDocLink($doc,$content, $lang, $attributes)
};

declare
%templates:wrap
function app:documentFooter($node as node(), $model as map(*)) as map(*) {
Expand Down Expand Up @@ -512,6 +532,7 @@ declare function app:set-facet-checkbox($node as node(), $model as map(*), $key
(:~
: Wrapper for dispatching various document types (in analogy to search:dispatch-preview())
: Simply redirects to the right fragment from 'templates/includes'
: Used by templates/ajax/popover.html
:
:)
declare function app:popover($node as node(), $model as map(*)) as map(*)* {
Expand Down Expand Up @@ -1596,12 +1617,15 @@ declare


declare
%templates:wrap
%templates:default("lang", "en")
function app:preview-relator-name($node as node(), $model as map(*), $lang as xs:string) as xs:string {
if($model('relator')/@dbkey) then query:title($model('relator')/@dbkey)
else if($model('relator')/@key) then query:title($model('relator')/@key)
else str:normalize-space($model('relator'))
%templates:default("popover", "false")
function app:preview-relator-name($node as node(), $model as map(*), $lang as xs:string, $popover as xs:string) as element() {
let $key := $model('relator')/@dbkey | $model('relator')/@key
return
if($key and $popover=('true', '1')) then app:createDocLink(core:doc($key), query:title($key), $lang, (), true())
else element span {
str:normalize-space($model('relator'))
}
};

declare
Expand Down
2 changes: 1 addition & 1 deletion templates/work.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2 data-template="lang:translate">basic_data</h2>
<li><span data-template="app-shared:output" data-template-key="title">Ein Titel</span></li>
</ol>
<ol class="media" data-template="app-shared:each" data-template-from="relators" data-template-to="relator">
<li><strong data-template="app:preview-relator-role"/>: <span data-template="app:preview-relator-name"/></li>
<li><strong data-template="app:preview-relator-role"/>: <span data-template="app:preview-relator-name" data-template-popover="true"/></li>
</ol>
</div>
<div class="col-md-4 col-sm-12 iconographie">
Expand Down

0 comments on commit 50deaa7

Please sign in to comment.