Changes for page InplaceEditing
From version 5.1
edited by Nazzareno Pompei
on 30/01/2023 10:31
on 30/01/2023 10:31
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-edit-ui/14.10.3]
To version 4.1
edited by Nazzareno Pompei
on 28/10/2022 08:43
on 28/10/2022 08:43
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-edit-ui/14.9]
Summary
-
Objects (1 modified, 0 added, 0 removed)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -223,7 +223,7 @@ 223 223 }; 224 224 225 225 var loadCSS = function(url) { 226 - $('<link />').attr({226 + var link = $('<link>').attr({ 227 227 type: 'text/css', 228 228 rel: 'stylesheet', 229 229 href: url ... ... @@ -695,12 +695,6 @@ 695 695 }); 696 696 }; 697 697 698 - function addToFormData(formData, inputs) { 699 - inputs.serializeArray().forEach(function(entry) { 700 - formData.append(entry.name, entry.value); 701 - }); 702 - } 703 - 704 704 // actionButtons.js expects a form so we use a fake form. Refactoring actionButtons.js is too dangerous ATM. 705 705 var fakeForm = { 706 706 action: XWiki.currentDocument.getURL('save'), ... ... @@ -731,33 +731,45 @@ 731 731 return this._getActionButtons().find(selector)[0]; 732 732 }, 733 733 serialize: function() { 734 - var formData = new FormData(); 735 - addToFormData(formData, this._getActionButtons().find(':input')); 728 + var extra = this._getActionButtons().find(':input').serializeArray().reduce(function(extra, entry) { 729 + var value = extra[entry.name] || []; 730 + value.push(entry.value); 731 + extra[entry.name] = value; 732 + return extra; 733 + }, {}); 736 736 // retrieve all input fields listing the temporary uploaded files. 735 + var uploadedFiles = $('#xwikicontent').nextAll('input[name="uploadedFiles"]').serializeArray().reduce(function(extra, entry) { 736 + var value = extra[entry.name] || []; 737 + value.push(entry.value); 738 + extra[entry.name] = value; 739 + return extra; 740 + }, {}); 737 737 var xwikiDocument = this._getActionButtons().data('xwikiDocument'); 738 - formData.set('title', xwikiDocument.rawTitle); 739 - formData.set('language', xwikiDocument.getRealLocale()); 740 - formData.set('isNew', xwikiDocument.isNew); 741 - 742 - if (xwikiDocument.content !== xwikiDocument.originalDocument.content) { 742 + var formData = { 743 + title: xwikiDocument.rawTitle, 744 + language: xwikiDocument.getRealLocale(), 745 + isNew: xwikiDocument.isNew 746 + }; 747 + if (xwikiDocument.content != xwikiDocument.originalDocument.content) { 743 743 // Submit the raw (source) content. No syntax conversion is needed in this case. 744 - formData. set('content',xwikiDocument.content);749 + formData.content = xwikiDocument.content; 745 745 } else { 746 746 // Submit the rendered content (HTML), but make sure it is converted to the document syntax on the server. 747 - formData.set('content', xwikiDocument.renderedContent); 748 - formData.set('RequiresHTMLConversion', 'content'); 749 - formData.set('content_syntax', xwikiDocument.syntax); 752 + $.extend(formData, { 753 + content: xwikiDocument.renderedContent, 754 + RequiresHTMLConversion: 'content', 755 + content_syntax: xwikiDocument.syntax 756 + }); 750 750 } 751 751 // Add the temporary uploaded files to the form. 752 - addToFormData(formData, $('#xwikicontent').nextAll('input[name="uploadedFiles"]')); 753 - 759 + $.extend(formData, uploadedFiles); 754 754 // Check for merge conflicts only if the document is not new and we know the current version. 755 755 if (!xwikiDocument.isNew && xwikiDocument.version) { 756 - formData. set('previousVersion',xwikiDocument.version);757 - formData. set('editingVersionDate',new Date(xwikiDocument.modified).getTime());762 + formData.previousVersion = xwikiDocument.version; 763 + formData.editingVersionDate = new Date(xwikiDocument.modified).getTime(); 758 758 } 759 - // Note: if youfactor, pleasemake surethatactionsButtonsinputshavethelowestpriority.760 - return formData; 765 + // Ensure that formData information has priority over extra information. 766 + return $.extend({}, extra, formData); 761 761 } 762 762 }; 763 763