23 "options": ["lewo", "srodek", "prawo"],
40 function PropertiesPerspective(options) {
41 let oldCallback = options.callback || function() {};
42 this.vsplitbar = 'WŁAŚCIWOŚCI';
44 options.callback = function() {
47 self.$pane = $("#side-properties");
49 $(document).on('click', '[x-node]', function(e) {
54 self.$pane.on('click', '#parents li', function(e) {
55 self.edit($(this).data('node'));
58 self.$pane.on('change', '.form-control', function() {
62 if ($input.attr('type') == 'checkbox') {
63 inputval = $input.is(':checked');
65 inputval = $input.val();
68 if ($input.data("edited")) {
69 $input.data("edited").text(inputval);
74 element: self.$edited[0],
75 success: function(xml) {
77 let $xmlelem = $($.parseXML(xml));
79 w($input.data('property'), $input.val());
80 $xmlelem.contents().attr($input.data('property'), inputval);
82 let newxml = (new XMLSerializer()).serializeToString($xmlelem[0]);
86 base: self.doc.getBase(),
87 success: function(html) {
88 let htmlElem = $(html);
89 self.$edited.replaceWith(htmlElem);
94 error: function(e) {console.log(e);},
99 oldCallback.call(this);
102 $.wiki.SidebarPerspective.call(this, options);
105 PropertiesPerspective.prototype = new $.wiki.SidebarPerspective();
107 PropertiesPerspective.prototype.edit = function(element) {
110 let $node = $(element);
111 $("#parents", self.$pane).empty();
112 $node.parents('[x-node]').each(function() {
113 let a = $("<li class='breadcrumb-item'>").text($(this).attr('x-node'));
114 a.data('node', this);
115 $("#parents", self.$pane).prepend(a)
118 node = $(element).attr('x-node');
119 $("h1", self.$pane).text(node);
121 $f = $("#properties-form", self.$pane);
123 self.$edited = $(element);
125 let nodeDef = elementDefs[node];
126 if (nodeDef && nodeDef.attributes) {
127 $.each(nodeDef.attributes, function(i, a) {
128 self.addEditField(a, $(element).attr('data-wlf-' + a.name)); // ...
133 // Only utwor can has matadata now.
134 if (node == 'utwor') {
135 // Let's find all the metadata.
136 $("> .RDF > .Description > [x-node]", $node).each(function() {
139 {"name": $meta.attr('x-node'),},
147 PropertiesPerspective.prototype.addEditField = function(defn, value, elem) {
149 let $form = $("#properties-form", self.$pane);
151 let $fg = $("<div class='form-group'>");
152 $("<label/>").attr("for", "property-" + defn.name).text(defn.name).appendTo($fg);
156 $input = $("<textarea>");
159 $input = $("<select>");
160 $.each(defn.options, function(i, e) {
161 $("<option>").text(e).appendTo($input);
165 $input = $("<input type='checkbox'>");
168 $input = $("<input>");
171 $input.addClass("form-control").attr("id", "property-" + defn.name).data("property", defn.name);
172 if ($input.attr('type') == 'checkbox') {
173 $input.prop('checked', value == 'true');
179 $input.data("edited", elem);
181 $input.appendTo($fg);
186 $.wiki.PropertiesPerspective = PropertiesPerspective;