* @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::_('bootstrap.tooltip'); JHtml::_('jquery.token'); JText::script('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_UNKNOWN'); JText::script('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_EMPTY'); JText::script('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG'); JFactory::getDocument()->addScriptDeclaration(' Joomla.submitbuttonpackage = function() { var form = document.getElementById("adminForm"); // do field validation if (form.install_package.value == "") { alert("' . JText::_('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE', true) . '"); } else if (form.install_package.files[0].size > form.max_upload_size.value) { alert("' . JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG', true) . '"); } else { JoomlaInstaller.showLoading(); form.installtype.value = "upload" form.submit(); } }; '); // Drag and Drop installation scripts $token = JSession::getFormToken(); $return = JFactory::getApplication()->input->getBase64('return'); // Drag-drop installation JFactory::getDocument()->addScriptDeclaration( << fileSizeMax) { alert(Joomla.JText._('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG'), true); return; } data.append('install_package', file); data.append('installtype', 'upload'); dragZone.attr('data-state', 'uploading'); uploading = true; $.ajax({ url: url, data: data, type: 'post', processData: false, cache: false, contentType: false, xhr: function () { var xhr = new window.XMLHttpRequest(); progressBar.css('width', 0); progressBar.attr('aria-valuenow', 0); percentage.text(0); // Upload progress xhr.upload.addEventListener("progress", function (evt) { if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; var number = Math.round(percentComplete * 100); progressBar.css('width', number + '%'); progressBar.attr('aria-valuenow', number); percentage.text(number); if (number === 100) { dragZone.attr('data-state', 'installing'); } } }, false); return xhr; } }) .done(function (res) { // Handle extension fatal error if (!res || (!res.success && !res.data)) { showError(res); return; } // Always redirect that can show message queue from session if (res.data.redirect) { location.href = res.data.redirect; } else { location.href = 'index.php?option=com_installer&view=install'; } }).error(function (error) { uploading = false; if (error.status === 200) { var res = error.responseText || error.responseJSON; showError(res); } else { showError(error.statusText); } }); function showError(res) { dragZone.attr('data-state', 'pending'); var message = Joomla.JText._('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_UNKNOWN'); if (res == null) { message = Joomla.JText._('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_EMPTY'); } else if (typeof res === 'string') { // Let's remove unnecessary HTML message = res.replace(/(<([^>]+)>|\s+)/g, ' '); } else if (res.message) { message = res.message; } Joomla.renderMessages({error: [message]}); } }); }); JS ); JFactory::getDocument()->addStyleDeclaration( <<

0%