* Przypisy w tekście
*/
-.htmlview .annotation-inline-box {
- &:hover > span[x-annotation-box] {
- display: block;
+.htmlview .annotation-inline-box,
+.htmlview .reference-inline-box {
+ &:hover {
+ > span[x-annotation-box],
+ > span[x-preview]
+ {
+ display: block;
+ }
}
- > span[x-annotation-box] {
+ > span[x-annotation-box],
+ > span[x-preview]
+ {
display: none;
width: 300px;
font-size: 10pt;
element: source,
stripOuter: true,
success: function(text){
- $('textarea', $overlay).val($.trim(text));
+ let ttext = $.trim(text);
+ $('textarea', $overlay).val(ttext);
setTimeout(function(){
$('textarea', $overlay).elastic().focus();
$('*[x-annotation-box]', editable).css({
}).show();
}
+ if (editable.is('.reference-inline-box')) {
+ let preview = $('*[x-preview]', editable);
+ preview.show();
+ let link = $("a", preview);
+ let href = link.attr('href');
+ if (link.attr('title') == '?' && href.startsWith('https://www.wikidata.org/wiki/')) {
+ link.attr('title', '…');
+ let qid = href.split('/').reverse()[0];
+ $.ajax({
+ url: 'https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/' + qid + '?_fields=labels',
+ dataType: "json",
+ success: function(data) {
+ link.attr(
+ 'title',
+ data['labels']['pl'] || data['labels']['en']
+ );
+ },
+ });
+ }
+ }
});
self.caret = new Caret(element);
<xsl:with-param name="extra-class" select="'reference-inline-box'" />
</xsl:call-template>
<a class="reference">📌</a>
+ <span x-preview="true" x-pass-thru="true">
+ <a target="wiki" title="?">
+ <xsl:attribute name="href">
+ <xsl:value-of select="@href" />
+ </xsl:attribute>
+ <xsl:value-of select="@href" />
+ </a>
+ </span>
</span>
</xsl:template>