--- /dev/null
+(function($){
+
+ let w = function() {};
+ w = console.log;
+
+ const elementDefs = {
+ "ilustr": {
+ "attributes": [
+ {
+ "name": "src",
+ },
+ {
+ "name": "alt",
+ "type": "text",
+ },
+ ],
+ },
+ "ref": {
+ "attributes": [
+ {
+ "name": "href",
+ },
+ ],
+ }
+ };
+
+ function PropertiesPerspective(options) {
+ let oldCallback = options.callback || function() {};
+ this.vsplitbar = 'WŁAŚCIWOŚCI';
+
+ options.callback = function() {
+ let self = this;
+
+ self.$pane = $("#side-properties");
+
+ $(document).on('click', '[x-node]', function(e) {
+ e.stopPropagation();
+ self.edit(this);
+ });
+
+ self.$pane.on('click', '#parents li', function(e) {
+ self.edit($(this).data('node'));
+ });
+
+ self.$pane.on('change', '.form-control', function() {
+ let $input = $(this);
+
+ if ($input.data("edited")) {
+ $input.data("edited").text($input.val());
+ return;
+ }
+
+ html2text({
+ element: self.$edited[0],
+ success: function(xml) {
+ w(222)
+ let $xmlelem = $($.parseXML(xml));
+ w(333, $xmlelem)
+ $xmlelem.contents().attr($input.data('property'), $input.val());
+ w(444, $xmlelem)
+ let newxml = (new XMLSerializer()).serializeToString($xmlelem[0]);
+ w(555, newxml)
+ xml2html({
+ xml: newxml,
+ base: self.doc.getBase(),
+ success: function(html) {
+ let htmlElem = $(html);
+ self.$edited.replaceWith(htmlElem);
+ self.edit(htmlElem);
+ }
+ });
+ },
+ error: function(e) {console.log(e);},
+ });
+ self.$edited;
+ });
+
+ oldCallback.call(this);
+ };
+
+ $.wiki.SidebarPerspective.call(this, options);
+ }
+
+ PropertiesPerspective.prototype = new $.wiki.SidebarPerspective();
+
+ PropertiesPerspective.prototype.edit = function(element) {
+ let self = this;
+
+ let $node = $(element);
+ $("#parents", self.$pane).empty();
+ $node.parents('[x-node]').each(function() {
+ let a = $("<li class='breadcrumb-item'>").text($(this).attr('x-node'));
+ a.data('node', this);
+ $("#parents", self.$pane).prepend(a)
+ })
+ // It's a tag.
+ node = $(element).attr('x-node');
+ $("h1", self.$pane).text(node);
+
+ $f = $("#properties-form", self.$pane);
+ $f.empty();
+ self.$edited = $(element);
+
+ let nodeDef = elementDefs[node];
+ if (nodeDef && nodeDef.attributes) {
+ $.each(nodeDef.attributes, function(i, a) {
+ self.addEditField(a.name, a.type, $(element).attr('data-wlf-' + a.name)); // ...
+ })
+ }
+
+
+ // Only utwor can has matadata now.
+ if (node == 'utwor') {
+ // Let's find all the metadata.
+ $("> .RDF > .Description > [x-node]", $node).each(function() {
+ $meta = $(this);
+ self.addEditField(
+ $meta.attr('x-node'),
+ null,
+ $meta.text(),
+ $meta,
+ );
+ });
+ }
+ };
+
+ PropertiesPerspective.prototype.addEditField = function(name, type, value, elem) {
+ let self = this;
+ let $form = $("#properties-form", self.$pane);
+
+ let $fg = $("<div class='form-group'>");
+ $("<label/>").attr("for", "property-" + name).text(name).appendTo($fg);
+ let $input;
+ if (type == 'text') {
+ $input = $("<textarea>");
+ } else {
+ $input = $("<input>")
+ }
+ // val?
+ $input.addClass("form-control").attr("id", "property-" + name).data("property", name).val(value);
+ if (elem) {
+ $input.data("edited", elem);
+ }
+ $input.appendTo($fg);
+
+ $fg.appendTo($form);
+ }
+
+ $.wiki.PropertiesPerspective = PropertiesPerspective;
+
+})(jQuery);
+
if (!xml2htmlStylesheet) {
$.blockUI({message: 'Ładowanie arkuszy stylów...'});
$.ajax({
- url: STATIC_URL + 'xsl/wl2html_client.xsl?20201110',
- dataType: 'xml',
- timeout: 10000,
- success: function(data) {
+ url: STATIC_URL + 'xsl/wl2html_client.xsl?210129',
+ dataType: 'xml',
+ timeout: 10000,
+ success: function(data) {
xml2htmlStylesheet = createXSLT(data);
$.unblockUI();
- code_block();
-
+ code_block();
},
- error: onError
+ error: onError
})
}
- else {
- code_block();
- }
+ else {
+ code_block();
+ }
}
source.text('');
options.error(error.text(), source_text);
} else {
+ let galleryUrl = new URL(
+ options.base,
+ window.location.href
+ );
+ $("img", $(doc.childNodes)).each(function() {
+ $(this).attr(
+ 'src',
+ new URL(
+ $(this).attr('src'),
+ galleryUrl
+ )
+ );
+ })
+
options.success(doc.childNodes);
$.themes.withCanon(function(canonThemes) {
{% endblock %}
{% block tabs-right %}
- {% include "wiki/tabs/gallery_view_item.html" %}
- {% include "wiki/tabs/annotations_view_item.html" %}
- {% include "wiki/tabs/search_view_item.html" %}
+ {% include "wiki/tabs/gallery_view_item.html" %}
+ {% include "wiki/tabs/annotations_view_item.html" %}
+ {% include "wiki/tabs/properties_view_item.html" %}
+ {% include "wiki/tabs/search_view_item.html" %}
{% endblock %}
{% block splitter-extra %}
<p class="vsplitbar-title"></p>
</div>
<div id="sidebar">
- {% include "wiki/tabs/gallery_view.html" %}
- {% include "wiki/tabs/annotations_view.html" %}
- {% include "wiki/tabs/search_view.html" %}
+ {% include "wiki/tabs/gallery_view.html" %}
+ {% include "wiki/tabs/annotations_view.html" %}
+ {% include "wiki/tabs/properties_view.html" %}
+ {% include "wiki/tabs/search_view.html" %}
</div>
<div id="drag-layer"></div>
{% endblock %}