- if ($input.data("edited")) {
- $input.data("edited").text($input.val());
- return;
- }
-
- html2text({
- element: self.$edited[0],
- success: function(xml) {
- w(222)
- let $xmlelem = $($.parseXML(xml));
- w(333, $xmlelem)
- $xmlelem.contents().attr($input.data('property'), $input.val());
- w(444, $xmlelem)
- let newxml = (new XMLSerializer()).serializeToString($xmlelem[0]);
- w(555, newxml)
- xml2html({
- xml: newxml,
- base: self.doc.getBase(),
- success: function(html) {
- let htmlElem = $(html);
- self.$edited.replaceWith(htmlElem);
- self.edit(htmlElem);
- }
+ $(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")) {
+ if ($input.data("edited-attr")) {
+ $input.data("edited").attr($input.data("edited-attr"), inputval);
+ } else {
+ $input.data("edited").text(inputval);
+ }
+ $.wiki.perspectives.VisualPerspective.flush();
+ return;
+ }
+
+ html2text({
+ element: self.$edited[0],
+ success: function(xml) {
+ w(222)
+ let $xmlelem = $($.parseXML(xml));
+ w(333, $xmlelem)
+ 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)
+ xml2html({
+ xml: newxml,
+ base: self.doc.getBase(),
+ success: function(html) {
+ let htmlElem = $(html);
+ self.$edited.replaceWith(htmlElem);
+ self.edit(htmlElem);
+ $.wiki.activePerspective().flush();
+ }
+ });
+ },
+ error: function(e) {console.log(e);},
+ });
+ 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/>');
+ span.attr('x-node', tag);
+ span.attr('x-ns', ns)
+ if (field.value_type.hasLanguage) {
+ span.attr('x-a-xml-lang', 'pl');
+ }
+
+ let rdf = $("> [x-node='RDF']", self.$edited);
+ if (!rdf.length) {
+ rdf = $("<span x-node='RDF' x-ns='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>");
+ self.$edited.prepend(rdf);
+ self.$edited.prepend('\n ');
+
+ }
+ let rdfdesc = $("> [x-node='Description']", rdf);
+ if (!rdfdesc.length) {
+ rdfdesc = $("<span x-node='Description' x-ns='http://www.w3.org/1999/02/22-rdf-syntax-ns#' x-a-rdf-about='" + self.doc.fullUri + "'>");
+ 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');
+ let $ig = $(this).closest('.input-group');
+ $('input', $ig).data('edited').remove();
+ self.displayMetaProperty($fg);
+ $.wiki.perspectives.VisualPerspective.flush();
+ return false;
+ });
+
+ $('#media-chooser').on('show.bs.modal', function (event) {
+ var input = $("input", $(event.relatedTarget).parent());
+ var modal = $(this);
+ modal.data('target-input', input);
+ var imglist = modal.find('.modal-body');
+ imglist.html('');
+ $.each(self.doc.galleryImages, (i, imgItem) => {
+ img = $("<img>").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() {
+ imglist.find('img').removeClass('active');
+ $(this).addClass('active');