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 = $("<span x-node='RDF' x-ns='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>");
+ self.$edited.prepend(rdf);
+ self.$edited.prepend('\n ');
+
+ }
+ rdfdesc = $("> [x-node='Description']", rdf);
+ if (!rdfdesc.length) {
+ rdfdesc = $("<span x-node='Description' x-ns='http://www.w3.org/1999/02/22-rdf-syntax-ns#' x-a-rdf-about='" + self.doc.fullUri + "'>");
+ rdf.prepend(rdfdesc);
+ rdf.prepend('\n ');
+ rdfdesc.append('\n ');
+ rdf.append('\n ');
+ }
+ span.appendTo(rdfdesc);
+ rdfdesc.append('\n ');
self.displayMetaProperty($fg);
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 = $("<div class='badge badge-primary'></div>").text($node.attr('x-node'));
b.data('node', element);
$("#bubbles").append(b);
node = $(element).attr('x-node');
$("h1", self.$pane).text(node);
- $f = $("#properties-form", self.$pane);
- $f.empty();
self.$edited = $(element);
let nodeDef = elementDefs[node];
pp.appendTo(ig);
}
- let $aninput = $("<input class='form-control'>");
+ let $aninput;
+ if (field.value_type.widget == 'select') {
+ $aninput = $("<select class='form-control'>");
+ $.each(field.value_type.options, function() {
+ $("<option>").text(this).appendTo($aninput);
+ })
+ } else {
+ $aninput = $("<input class='form-control'>");
+ if (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 += '<br><small><strong>' + item.name + '</strong></small>';
+ if (item.description) t += '<br><small><em>' + item.description + '</em></small>';
+ return $( "<li>" )
+ .append( "<div>" + t + "</div>" )
+ .appendTo( ul );
+ };
+ }
+ }
$aninput.data('edited', $(element))
$aninput.val(
$(element).text()
// clear container
$('.c', $fg).empty();
-
- $("> [x-node='RDF'] > [x-node='Description'] > [x-node='"+tag+"'][x-ns='"+ns+"']", self.$edited).each(function() {
+
+ let selector = "> [x-node='RDF'] > [x-node='Description'] > [x-node='"+tag+"']";
+ if (ns) {
+ selector += "[x-ns='"+ns+"']";
+ }
+ $(selector, self.$edited).each(function() {
self.addMetaInput(
$('.c', $fg),
field,
this.edit(p);
}
+ PropertiesPerspective.prototype.onEnter = function(success, failure){
+ var self = this;
+ $.wiki.SidebarPerspective.prototype.onEnter.call(this);
+
+ if ($.wiki.activePerspective() != 'VisualPerspective')
+ $.wiki.switchToTab('#VisualPerspective');
+
+ self.edit($('[x-node="utwor"]')[0]);
+ };
+
$.wiki.PropertiesPerspective = PropertiesPerspective;
})(jQuery);