Skip to content

Commit

Permalink
js fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrammatiko committed Aug 23, 2017
1 parent 9974ee5 commit 0a43128
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions installation/template/js/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ Joomla.installation = function(_container, _base) {
view = '';

// Merge options from the session storage
Joomla.extend(this.options, sessionStorage.getItem('installation-data'));
if (sessionStorage && sessionStorage.getItem('installation-data')) {
Joomla.extend(this.options, sessionStorage.getItem('installation-data'));
}

Joomla.pageInit();
var el = document.querySelector('.nav-steps.hidden');
Expand Down Expand Up @@ -271,15 +273,22 @@ Joomla.checkFormField = function(fields) {

Joomla.checkInputs = function() {
document.getElementById('jform_admin_password2').value = document.getElementById('jform_admin_password').value;
document.getElementById('jform_db_prefix').value = Joomla.makeRandomDbPrefix();
Joomla.makeRandomDbPrefix();

var inputs = [].slice.call(document.querySelectorAll('input[type="password"], input[type="text"], input[type="email"], select')),
state = true;
inputs.forEach(function(item) {
if (!item.valid) state = false;
});

// Reveal everything
document.getElementById('installStep1').classList.add('active');
document.getElementById('installStep2').classList.add('active');
document.getElementById('installStep3').classList.add('active');


if (Joomla.checkFormField(['#jform_site_name', '#jform_admin_user', '#jform_admin_email', '#jform_admin_password', '#jform_db_type', '#jform_db_host', '#jform_db_user', '#jform_db_name'])) {
console.log('hdfgh')
Install.checkDbCredentials();
}
};
Expand Down Expand Up @@ -335,7 +344,6 @@ window.Install = new Joomla.installation(
document.getElementById('installStep2').classList.add('active');
document.getElementById('step1').parentNode.removeChild(document.getElementById('step1'));
document.getElementById('installStep1').classList.remove('active');
document.querySelector('li[data-step="2"]').classList.add('active');
Joomla.scrollTo(document.getElementById('installStep2'), document.getElementById('installStep2').offsetTop);

// Focus to the next field
Expand All @@ -356,7 +364,6 @@ window.Install = new Joomla.installation(
document.getElementById('installStep3').classList.add('active');
document.getElementById('step2').parentNode.removeChild(document.getElementById('step2'));
document.getElementById('installStep2').classList.remove('active');
document.querySelector('li[data-step="3"]').classList.add('active');
Joomla.scrollTo(document.getElementById('installStep3'), document.getElementById('installStep3').offsetTop);
document.getElementById('setupButton').style.display = 'block';

Expand All @@ -367,6 +374,11 @@ window.Install = new Joomla.installation(
}
}
})

document.getElementById('setupButton').addEventListener('click', function(e) {
e.preventDefault();
Joomla.checkInputs();
})
}

})();
2 changes: 1 addition & 1 deletion installation/template/js/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Joomla.installation = Joomla.installation || {};

// Initialize the FTP installation data
if (sessionStorage.getItem('installData')) {
if (sessionStorage && sessionStorage.getItem('installation-data')) {
var data = sessionStorage.getItem('installData').split(',');
Joomla.installation.data = {
ftpUsername: data[0],
Expand Down
2 changes: 1 addition & 1 deletion installation/view/setup/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<?php echo $this->form->getInput('db_old'); ?>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" id="setupButton" onclick="Joomla.checkInputs()"><?php echo JText::_('INSTL_INSTALL_JOOMLA'); ?> <span class="fa fa-chevron-right" aria-hidden="true"></span></button>
<button class="btn btn-primary btn-block" id="setupButton"><?php echo JText::_('INSTL_INSTALL_JOOMLA'); ?> <span class="fa fa-chevron-right" aria-hidden="true"></span></button>
</div>
</div>
</div>
Expand Down

0 comments on commit 0a43128

Please sign in to comment.