diff --git a/elements/radicalmultifieldtreecatalog.php b/elements/radicalmultifieldtreecatalog.php index b15f5ce..c2bcd0a 100644 --- a/elements/radicalmultifieldtreecatalog.php +++ b/elements/radicalmultifieldtreecatalog.php @@ -152,7 +152,10 @@ public function getInput($only_directories = false) Text::script('PLG_RADICAL_MULTI_FIELD_BUTTON_LIST'); Text::script('PLG_RADICAL_MULTI_FIELD_BUTTON_SELECTALL'); - $app = Factory::getApplication(); + // Add the root url as JS var + Factory::getDocument()->addScriptDeclaration("let siteUrl = '".JUri::root()."';"); + + $app = Factory::getApplication(); // get attributes $importfield = $this->getAttribute('importfield'); diff --git a/media/core/js/import.js b/media/core/js/import.js index 93996b4..11d52a6 100644 --- a/media/core/js/import.js +++ b/media/core/js/import.js @@ -111,7 +111,7 @@ jQuery(function(){ list.find('.av-folderlist-label').removeClass('selected'); jQuery(this).addClass('selected'); listfiles.html(''); - jQuery.get("/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=json&type=get_files&directory=" + encodeURIComponent(self.attr('path')) + + jQuery.get(siteUrl + "/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=json&type=get_files&directory=" + encodeURIComponent(self.attr('path')) + "&importfieldpath=" + encodeURIComponent(importfieldpath) + "&importfield=" + encodeURIComponent(importfield) ).done(function (response) { @@ -290,7 +290,7 @@ jQuery(function(){ callback: function (value) { let newName = value; if (newName) { - jQuery.get("/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=raw&type=create_directory&name=" + + jQuery.get(siteUrl + "/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=raw&type=create_directory&name=" + encodeURIComponent(newName) + "&path=" + encodeURIComponent(active.find('.av-folderlist-label').attr('path')) + "&importfieldpath=" + encodeURIComponent(importfieldpath) + @@ -315,7 +315,7 @@ jQuery(function(){ jQuery('.modal-import-file .tree-reload').on('click', function() { let lastActive = active.find('.av-folderlist-label').attr('path'); let bufferScrollTop = jQuery('.av-folderlist').scrollTop(); - jQuery.get("/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=raw&type=get_directories" + + jQuery.get(siteUrl + "/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=raw&type=get_directories" + "&importfieldpath=root" + "&importfield=" + encodeURIComponent(importfield) ).done(function (response) { @@ -660,7 +660,7 @@ jQuery(function(){ } - let url = "/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=json&type=upload_file" + let url = siteUrl + "/administrator/index.php?option=com_ajax&plugin=radicalmultifield&group=fields&format=json&type=upload_file" + "&importfieldpath=" + encodeURIComponent(importfieldpath) + "&importfield=" + encodeURIComponent(importfield); let xhr = new XMLHttpRequest();