- let $fg = $("<div class='form-group'>");
- $("<label/>").attr("for", "property-" + defn.name).text(defn.name).appendTo($fg);
- let $input;
- switch (defn.type) {
- case 'text':
- $input = $("<textarea>");
- break;
- case 'select':
- $input = $("<select>");
- $.each(defn.options, function(i, e) {
- $("<option>").text(e).appendTo($input);
+ $fg.appendTo( $("#properties-form", self.$pane));
+ });
+ }
+
+ // check node type, find relevant tags
+ if ($node[0].nodeName == 'DIV') {
+ $("#current-convert").attr("data-current-type", "div");
+ } else if ($node[0].nodeName == 'EM') {
+ $("#current-convert").attr("data-current-type", "span");
+ }
+ }
+
+ addMetaInput(cont, field, element) {
+ let self = this;
+
+ let ig = $('<div class="input-group">');
+ //ig.data('edited', element);
+ ig.appendTo(cont);
+
+ if (field.value_type.hasLanguage) {
+ let pp = $("<div class='input-group-prepend'>");
+ let lang_input = $("<input class='form-control' size='1' class='lang'>");
+ lang_input.data('edited', $(element));
+ lang_input.data('edited-attr', 'x-a-xml-lang');
+ lang_input.val(
+ $(element).attr('x-a-xml-lang')
+ );
+ lang_input.appendTo(pp);
+ pp.appendTo(ig);
+ }
+
+ 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()
+ );
+ $aninput.appendTo(ig);
+
+ let ap = $("<div class='input-group-append'>");
+ ap.appendTo(ig);
+ $("<button class='meta-delete btn btn-outline-secondary'>x</button>").appendTo(ap);
+
+ // lang
+ }
+
+ displayMetaProperty($fg) {
+ let self = this;
+ let ns = $fg.data('ns');
+ let tag = $fg.data('tag');
+ let field = $fg.data('field');
+
+ // clear container
+ $('.c', $fg).empty();
+
+ 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);