X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/05a64b9314fac5f613133332d7d0b5b568ab8afc..7f7c1a7c88445631554da09df583944307ce6ef7:/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..32a7101b 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": { @@ -45,8 +58,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 +76,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 +125,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 +136,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 +144,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 = $("
"); - $("