X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ed7cd4d7271acd67bf366e4d320f9c49f07a50ea..28866d0f2520b7515f3c06e9b61bcce4f44d53b1:/src/redakcja/static/js/wiki/view_properties.js?ds=sidebyside diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 3495197c..e38a7d07 100644 --- a/src/redakcja/static/js/wiki/view_properties.js +++ b/src/redakcja/static/js/wiki/view_properties.js @@ -8,6 +8,7 @@ "attributes": [ { "name": "src", + "type": "media", }, { "name": "alt", @@ -119,9 +120,24 @@ if (field.value_type.hasLanguage) { span.attr('x-a-xml-lang', 'pl'); } - span.appendTo( - $("> [x-node='RDF'] > [x-node='Description']", self.$edited) - ); + + rdf = $("> [x-node='RDF']", self.$edited); + if (!rdf.length) { + rdf = $(""); + self.$edited.prepend(rdf); + self.$edited.prepend('\n '); + + } + rdfdesc = $("> [x-node='Description']", rdf); + if (!rdfdesc.length) { + rdfdesc = $(""); + rdf.prepend(rdfdesc); + rdf.prepend('\n '); + rdfdesc.append('\n '); + rdf.append('\n '); + } + span.appendTo(rdfdesc); + rdfdesc.append('\n '); self.displayMetaProperty($fg); @@ -136,6 +152,27 @@ }); + $('#media-chooser').on('show.bs.modal', function (event) { + var input = $("input", $(event.relatedTarget).parent()); + var modal = $(this); + modal.data('target-input', input); + var imglist = modal.find('.modal-body'); + imglist.html(''); + $.each(self.doc.galleryImages, (i, imgItem) => { + img = $("").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() { + imglist.find('img').removeClass('active'); + $(this).addClass('active'); + }); + imglist.append(img); + }); + }) + $('#media-chooser .ctrl-ok').on('click', function (event) { + $('#media-chooser').data('target-input') + .val( + (new URL($('#media-chooser .active').data('url'), document.baseURI)).href + ).trigger('change'); + $('#media-chooser').modal('hide'); + }); self.$pane.on('click', '.current-convert', function() { self.convert($(this).attr('data-to')); @@ -156,10 +193,18 @@ PropertiesPerspective.prototype.edit = function(element) { let self = this; - let $node = $(element); $("#parents", self.$pane).empty(); $("#bubbles").empty(); + $f = $("#properties-form", self.$pane); + $f.empty(); + + if (element === null) { + self.$edited = null; + return; + } + + let $node = $(element); let b = $("
").text($node.attr('x-node')); b.data('node', element); $("#bubbles").append(b); @@ -178,8 +223,6 @@ node = $(element).attr('x-node'); $("h1", self.$pane).text(node); - $f = $("#properties-form", self.$pane); - $f.empty(); self.$edited = $(element); let nodeDef = elementDefs[node]; @@ -252,7 +295,15 @@ } else { $aninput = $(""); if (field.value_type.autocomplete) { - $aninput.autocomplete(field.value_type.autocomplete); + let autoOptions = field.value_type.autocomplete; + $aninput.autocomplete(autoOptions).autocomplete('instance')._renderItem = function(ul, item) { + let t = item.label; + if (item.name) t += '
' + item.name + ''; + if (item.description) t += '
' + item.description + ''; + return $( "
  • " ) + .append( "
    " + t + "
    " ) + .appendTo( ul ); + }; } } $aninput.data('edited', $(element)) @@ -305,22 +356,28 @@ let $fg = $("
    "); $("