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) {
50 if (!e.redakcja_edited) {
51 e.redakcja_edited = true;
56 self.$pane.on('click', '#parents li', function(e) {
57 self.edit($(this).data('node'));
60 self.$pane.on('change', '.form-control', function() {
64 if ($input.attr('type') == 'checkbox') {
65 inputval = $input.is(':checked');
67 inputval = $input.val();
70 if ($input.data("edited")) {
71 $input.data("edited").text(inputval);
76 element: self.$edited[0],
77 success: function(xml) {
79 let $xmlelem = $($.parseXML(xml));
81 w($input.data('property'), $input.val());
82 $xmlelem.contents().attr($input.data('property'), inputval);
84 let newxml = (new XMLSerializer()).serializeToString($xmlelem[0]);
88 base: self.doc.getBase(),
89 success: function(html) {
90 let htmlElem = $(html);
91 self.$edited.replaceWith(htmlElem);
96 error: function(e) {console.log(e);},
101 oldCallback.call(this);
104 $.wiki.SidebarPerspective.call(this, options);
107 PropertiesPerspective.prototype = new $.wiki.SidebarPerspective();
109 PropertiesPerspective.prototype.edit = function(element) {
112 let $node = $(element);
113 $("#parents", self.$pane).empty();
114 $node.parents('[x-node]').each(function() {
115 let a = $("<li class='breadcrumb-item'>").text($(this).attr('x-node'));
116 a.data('node', this);
117 $("#parents", self.$pane).prepend(a)
120 node = $(element).attr('x-node');
121 $("h1", self.$pane).text(node);
123 $f = $("#properties-form", self.$pane);
125 self.$edited = $(element);
127 let nodeDef = elementDefs[node];
128 if (nodeDef && nodeDef.attributes) {
129 $.each(nodeDef.attributes, function(i, a) {
130 self.addEditField(a, $(element).attr('data-wlf-' + a.name)); // ...
135 // Only utwor can has matadata now.
136 if (node == 'utwor') {
137 // Let's find all the metadata.
138 $("> .RDF > .Description > [x-node]", $node).each(function() {
141 {"name": $meta.attr('x-node'),},
149 PropertiesPerspective.prototype.addEditField = function(defn, value, elem) {
151 let $form = $("#properties-form", self.$pane);
153 let $fg = $("<div class='form-group'>");
154 $("<label/>").attr("for", "property-" + defn.name).text(defn.name).appendTo($fg);
158 $input = $("<textarea>");
161 $input = $("<select>");
162 $.each(defn.options, function(i, e) {
163 $("<option>").text(e).appendTo($input);
167 $input = $("<input type='checkbox'>");
170 $input = $("<input>");
173 $input.addClass("form-control").attr("id", "property-" + defn.name).data("property", defn.name);
174 if ($input.attr('type') == 'checkbox') {
175 $input.prop('checked', value == 'true');
181 $input.data("edited", elem);
183 $input.appendTo($fg);
188 $.wiki.PropertiesPerspective = PropertiesPerspective;