X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/05a64b9314fac5f613133332d7d0b5b568ab8afc..2de0fde86873c879961365b4b9ce3904a158e84f:/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..204a4dec 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": { @@ -33,20 +46,37 @@ self.$pane = $("#side-properties"); - $(document).on('click', '[x-node]', function(e) { - e.stopPropagation(); - self.edit(this); + $("#simple-editor").on('click', '[x-node]', function(e) { + if (!e.redakcja_edited) { + e.redakcja_edited = true; + self.edit(this); + } }); self.$pane.on('click', '#parents li', function(e) { self.edit($(this).data('node')); }); + $(document).on('click', '#bubbles .badge', function(e) { + self.edit($(this).data('node')); + }); + 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()); + if ($input.data("edited-attr")) { + $input.data("edited").attr($input.data("edited-attr"), inputval); + } else { + $input.data("edited").text(inputval); + } return; } @@ -56,7 +86,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) @@ -74,6 +105,60 @@ }); self.$edited; }); + + + self.$pane.on('click', '.meta-add', function() { + // create a metadata item + let $fg = $(this).parent(); + let ns = $fg.data('ns'); + let tag = $fg.data('tag'); + let field = $fg.data('field'); + let span = $(''); + span.attr('x-node', tag); + span.attr('x-ns', ns) + if (field.value_type.hasLanguage) { + span.attr('x-a-xml-lang', 'pl'); + } + + rdf = $("> [x-node='RDF']", self.$edited); + if (!rdf.length) { + rdf = $(""); + self.$edited.prepend(rdf); + self.$edited.prepend('\n '); + + } + rdfdesc = $("> [x-node='Description']", rdf); + if (!rdfdesc.length) { + rdfdesc = $(""); + rdf.prepend(rdfdesc); + rdf.prepend('\n '); + rdfdesc.append('\n '); + rdf.append('\n '); + } + span.appendTo(rdfdesc); + rdfdesc.append('\n '); + + self.displayMetaProperty($fg); + + return false; + }); + + self.$pane.on('click', '.meta-delete', function() { + let $fg = $(this).closest('.form-group'); + $('input', $fg).data('edited').remove(); + self.displayMetaProperty($fg); + return false; + }); + + + + self.$pane.on('click', '.current-convert', function() { + self.convert($(this).attr('data-to')); + }); + self.$pane.on('click', '#current-delete', function() { + self.delete(); + }); + oldCallback.call(this); }; @@ -86,58 +171,194 @@ 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 = $("
").text($node.attr('x-node')); + b.data('node', element); + $("#bubbles").append(b); + $node.parents('[x-node]').each(function() { let a = $("
  • " ) + .append( "
    " + t + "
    " ) + .appendTo( ul ); + }; + } + } + $aninput.data('edited', $(element)) + $aninput.val( + $(element).text() + ); + $aninput.appendTo(ig); + + let ap = $("
    "); + ap.appendTo(ig); + $("").appendTo(ap); - PropertiesPerspective.prototype.addEditField = function(name, type, value, elem) { + // lang + }; + + + PropertiesPerspective.prototype.displayMetaProperty = function($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); + }); + + count = $('.c > .input-group', $fg).length; + if (field.required) { + if (!count) { + $('
    WYMAGANE
    ').appendTo($('.c', $fg)); + } + } + }; + + + + PropertiesPerspective.prototype.addEditField = function(defn, value, elem) { let self = this; let $form = $("#properties-form", self.$pane); let $fg = $("
    "); - $("