Skip to content

Commit

Permalink
Moved rest of JS to seperate file + fixed load icon path
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed Apr 25, 2017
1 parent e9f43aa commit 1b2eb4f
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@

JHtml::_('jquery.framework');
JHtml::_('bootstrap.tooltip');
JHtml::_('script', 'com_joomlaupdate/default.js', array('version' => 'auto', 'relative' => true));

JFactory::getDocument()->addScriptDeclaration("
jQuery(document).ready(function($) {
$('#extraction_method').change(function(e){
extractionMethodHandler('#extraction_method', 'row_ftp');
});
$('#upload_method').change(function(e){
extractionMethodHandler('#upload_method', 'upload_ftp');
});
JHtml::_('behavior.core');
JText::script('COM_INSTALLER_MSG_INSTALL_PLEASE_SELECT_A_PACKAGE', true);

$('button.submit').on('click', function() {
$('div.download_message').show();
});
});");
JHtml::_('script', 'com_joomlaupdate/default.min.js', array('version' => 'auto', 'relative' => true));
?>

<div id="joomlaupdate-wrapper">
Expand Down Expand Up @@ -71,7 +61,7 @@
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
<?php endif; ?>

<div class="download_message" style="display:none">
<div id="download-message" style="display:none">
<p class="nowarning"><?php echo JText::_('COM_JOOMLAUPDATE_VIEW_DEFAULT_DOWNLOAD_IN_PROGRESS'); ?></p>
<div class="joomlaupdate_spinner"></div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,13 @@

/** @var JoomlaupdateViewDefault $this */

$errSelectPackage = JText::_('COM_INSTALLER_MSG_INSTALL_PLEASE_SELECT_A_PACKAGE', true);
$js = <<< JS
Joomla.submitbuttonUpload = function() {
var form = document.getElementById("uploadForm");
// do field validation
if (form.install_package.value == "") {
alert("$errSelectPackage");
}
else
{
var loading = document.getElementById("loading");
if (loading)
{
loading.style.display = "block";
}
form.submit();
}
};
// Add spindle-wheel for installations:
jQuery(document).ready(function($) {
var outerDiv = $("#joomlaupdate-wrapper");
$("#loading")
.css("top", outerDiv.position().top - $(window).scrollTop())
.css("left", "0")
.css("width", "100%")
.css("height", "100%")
.css("display", "none")
.css("margin-top", "-10px");
});
JS;

JFactory::getDocument()->addScriptDeclaration($js);

$ajaxLoaderImage = JHtml::_('image', 'jui/ajax-loader.gif', '', null, true, true);
$css = <<< CSS
#loading {
background: rgba(255, 255, 255, .8) url('$ajaxLoaderImage') 50% 15% no-repeat;
position: fixed;
opacity: 1;
overflow: hidden;
}
CSS;
JFactory::getDocument()->addStyleDeclaration($css);
JHtml::_('behavior.core');
JText::script('COM_INSTALLER_MSG_INSTALL_PLEASE_SELECT_A_PACKAGE', true);
?>

<div class="alert alert-info">
<p>
<span class="icon icon-info"></span>
<span class="icon icon-info" aria-hidden="true"></span>
<?php echo JText::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO', 'https://downloads.joomla.org/latest'); ?>
</p>
</div>
Expand Down Expand Up @@ -156,7 +110,7 @@
<tr>
<td>&nbsp;</td>
<td>
<button class="btn btn-primary" type="button" onclick="Joomla.submitbuttonUpload()"><?php echo JText::_('COM_INSTALLER_UPLOAD_AND_INSTALL'); ?></button>
<button id="uploadButton" class="btn btn-primary" type="button" onclick="Joomla.submitbuttonUpload()"><?php echo JText::_('COM_INSTALLER_UPLOAD_AND_INSTALL'); ?></button>
</td>
</tr>
</tfoot>
Expand Down
2 changes: 1 addition & 1 deletion media/com_installer/css/installer.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#loading {
position: fixed;
background-image: url(../../jui/img/ajax-loader.gif);
background-image: url(../../system/images/ajax-loader.gif);
background-color: rgba(255,255,255,.8);
background-repeat: no-repeat;
background-position: center center;
Expand Down
18 changes: 17 additions & 1 deletion media/com_installer/js/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

(function() {
"use strict";
'use strict';

document.addEventListener('DOMContentLoaded', function() {

Expand Down Expand Up @@ -68,6 +70,20 @@
}
};

Joomla.submitbuttonUpload = function() {
var form = document.getElementById('uploadForm');

// do field validation
if (form.install_package.value == '') {
alert(Joomla.JText._('COM_INSTALLER_MSG_INSTALL_PLEASE_SELECT_A_PACKAGE'), true);
}
else {
Joomla.displayLoader();

form.submit();
}
};

Joomla.submitbuttonInstallWebInstaller = function() {
document.getElementById('adminForm').install_url.value = 'https://appscdn.joomla.org/webapps/jedapps/webinstaller.xml';

Expand Down
2 changes: 1 addition & 1 deletion media/com_installer/js/installer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 55 additions & 6 deletions media/com_joomlaupdate/js/default.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,62 @@
function extractionMethodHandler(target, prefix)
{
jQuery(function ($) {
$em = $(target);
displayStyle = ($em.val() === 'direct') ? 'none' : 'table-row';
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

(function() {
'use strict';

Joomla.extractionMethodHandler = function(element, prefix) {
var displayStyle = element.value === 'direct' ? 'none' : 'table-row';

document.getElementById(prefix + '_hostname').style.display = displayStyle;
document.getElementById(prefix + '_port').style.display = displayStyle;
document.getElementById(prefix + '_username').style.display = displayStyle;
document.getElementById(prefix + '_password').style.display = displayStyle;
document.getElementById(prefix + '_directory').style.display = displayStyle;
}

Joomla.submitbuttonUpload = function() {
var form = document.getElementById('uploadForm');

// do field validation
if (form.install_package.value == '') {
alert(Joomla.JText._('COM_INSTALLER_MSG_INSTALL_PLEASE_SELECT_A_PACKAGE'), true);
}
else {
form.submit();
}
};

document.addEventListener('DOMContentLoaded', function() {

var extractionMethod = document.getElementById('extraction_method'),
uploadMethod = document.getElementById('upload_method'),
uploadButton = document.getElementById('uploadButton'),
downloadMsg = document.getElementById('downloadMessage');

if (extractionMethod) {
extractionMethod.addEventListener('change', function(event) {
Joomla.extractionMethodHandler(extractionMethod, 'row_ftp');
});
}

if (uploadMethod) {
uploadMethod.addEventListener('change', function(event) {
Joomla.extractionMethodHandler(uploadMethod, 'upload_ftp');
});
}

if (uploadButton) {
uploadButton.addEventListener('click', function(event) {
if (downloadMsg) {
downloadMsg.style.display = 'block';
}
});
}

});
}

})();
2 changes: 1 addition & 1 deletion media/com_joomlaupdate/js/default.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b2eb4f

Please sign in to comment.