X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/05a64b9314fac5f613133332d7d0b5b568ab8afc..57a3ad0520284210f945b0e2f91f67233e49d07e:/src/redakcja/static/js/wiki/view_properties.js diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 571dac00..e6ad1ca2 100644 --- a/src/redakcja/static/js/wiki/view_properties.js +++ b/src/redakcja/static/js/wiki/view_properties.js @@ -13,6 +13,19 @@ "name": "alt", "type": "text", }, + { + "name": "szer", + "type": "percent", + }, + { + "name": "wyrownanie", + "type": "select", + "options": ["lewo", "srodek", "prawo"], + }, + { + "name": "oblew", + "type": "bool", + }, ], }, "ref": { @@ -34,8 +47,10 @@ self.$pane = $("#side-properties"); $(document).on('click', '[x-node]', function(e) { - e.stopPropagation(); - self.edit(this); + if (!e.redakcja_edited) { + e.redakcja_edited = true; + self.edit(this); + } }); self.$pane.on('click', '#parents li', function(e) { @@ -45,8 +60,15 @@ self.$pane.on('change', '.form-control', function() { let $input = $(this); + let inputval; + if ($input.attr('type') == 'checkbox') { + inputval = $input.is(':checked'); + } else { + inputval = $input.val(); + } + if ($input.data("edited")) { - $input.data("edited").text($input.val()); + $input.data("edited").text(inputval); return; } @@ -56,7 +78,8 @@ w(222) let $xmlelem = $($.parseXML(xml)); w(333, $xmlelem) - $xmlelem.contents().attr($input.data('property'), $input.val()); + w($input.data('property'), $input.val()); + $xmlelem.contents().attr($input.data('property'), inputval); w(444, $xmlelem) let newxml = (new XMLSerializer()).serializeToString($xmlelem[0]); w(555, newxml) @@ -104,7 +127,7 @@ 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)); // ... + self.addEditField(a, $(element).attr('data-wlf-' + a.name)); // ... }) } @@ -115,8 +138,7 @@ $("> .RDF > .Description > [x-node]", $node).each(function() { $meta = $(this); self.addEditField( - $meta.attr('x-node'), - null, + {"name": $meta.attr('x-node'),}, $meta.text(), $meta, ); @@ -124,20 +146,37 @@ } }; - PropertiesPerspective.prototype.addEditField = function(name, type, value, elem) { + PropertiesPerspective.prototype.addEditField = function(defn, value, elem) { let self = this; let $form = $("#properties-form", self.$pane); let $fg = $("
"); - $("