Skip to content

Commit

Permalink
Remove inline scripts from some layouts (joomla#57)
Browse files Browse the repository at this point in the history
* Remove inline scripts from some layouts

* Remove jQuery call

* remove submenu JS file
  • Loading branch information
C-Lodder authored and dneukirchen committed Mar 11, 2018
1 parent 2f4dd8e commit fb9c89e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 53 deletions.
23 changes: 3 additions & 20 deletions layouts/joomla/html/batch/adminlanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,13 @@
* None
*/

Factory::getDocument()->addScriptDeclaration(
'
jQuery(document).ready(function($){
if ($("#batch-category-id").length){var batchSelector = $("#batch-category-id");}
if ($("#batch-menu-id").length){var batchSelector = $("#batch-menu-id");}
if ($("#batch-position-id").length){var batchSelector = $("#batch-position-id");}
if ($("#batch-copy-move").length && batchSelector) {
$("#batch-copy-move").hide();
batchSelector.on("change", function(){
if (batchSelector.val() != 0 || batchSelector.val() != "") {
$("#batch-copy-move").show();
} else {
$("#batch-copy-move").hide();
}
});
}
});
'
);
HTMLHelper::_('script', 'system/fields/batch-language.min.js', ['version' => 'auto', 'relative' => true]);

?>
<label id="batch-language-lbl" for="batch-language-id" class="modalTooltip" title="<?php echo HTMLHelper::_('tooltipText', 'JLIB_HTML_BATCH_LANGUAGE_LABEL', 'JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC'); ?>">
<?php echo Text::_('JLIB_HTML_BATCH_LANGUAGE_LABEL'); ?>
</label>
<select name="batch[language_id]" class="inputbox" id="batch-language-id">
<select name="batch[language_id]" class="custom-select" id="batch-language-id">
<option value=""><?php echo Text::_('JLIB_HTML_BATCH_LANGUAGE_NOCHANGE'); ?></option>
<?php echo HTMLHelper::_('select.options', HTMLHelper::_('adminlanguage.existing', true, true), 'value', 'text'); ?>
</select>
21 changes: 2 additions & 19 deletions layouts/joomla/html/batch/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,8 @@
* None
*/

Factory::getDocument()->addScriptDeclaration(
'
jQuery(document).ready(function($){
if ($("#batch-category-id").length){var batchSelector = $("#batch-category-id");}
if ($("#batch-menu-id").length){var batchSelector = $("#batch-menu-id");}
if ($("#batch-position-id").length){var batchSelector = $("#batch-position-id");}
if ($("#batch-copy-move").length && batchSelector) {
$("#batch-copy-move").hide();
batchSelector.on("change", function(){
if (batchSelector.val() != 0 || batchSelector.val() != "") {
$("#batch-copy-move").show();
} else {
$("#batch-copy-move").hide();
}
});
}
});
'
);
HTMLHelper::_('script', 'system/fields/batch-language.min.js', ['version' => 'auto', 'relative' => true]);

?>
<label id="batch-language-lbl" for="batch-language-id" class="modalTooltip" title="<?php echo HTMLHelper::_('tooltipText', 'JLIB_HTML_BATCH_LANGUAGE_LABEL', 'JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC'); ?>">
<?php echo Text::_('JLIB_HTML_BATCH_LANGUAGE_LABEL'); ?>
Expand Down
15 changes: 1 addition & 14 deletions layouts/joomla/sidebars/submenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,7 @@
use Joomla\CMS\Language\Text;
use Joomla\Filter\OutputFilter;

HTMLHelper::_('jquery.framework');
HTMLHelper::_('behavior.core');

Factory::getDocument()->addScriptDeclaration('
jQuery(document).ready(function($) {
if (window.toggleSidebar) {
toggleSidebar(true);
}
else {
$("#j-toggle-sidebar-header").css("display", "none");
$("#j-toggle-button-wrapper").css("display", "none");
}
});
');
?>
<?php if ($displayData->displayMenu || $displayData->displayFilters) : ?>
<div id="j-toggle-sidebar-wrapper">
Expand Down Expand Up @@ -76,4 +63,4 @@
</div>
<div id="j-toggle-sidebar"></div>
</div>
<?php endif; ?>
<?php endif; ?>
38 changes: 38 additions & 0 deletions media/system/js/fields/batch-language.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

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

var batchSelector;

var batchCategory = document.getElementById('batch-category-id');
if (batchCategory) {
batchSelector = batchCategory;
}

var batchMenu = document.getElementById('batch-menu-id');
if (batchMenu) {
batchSelector = batchMenu;
}

var batchPosition = document.getElementById('batch-position-id');
if (batchPosition) {
batchSelector = batchPosition;
}

var batchCopyMove = document.getElementById('batch-copy-move');
if (batchCopyMove) {
batchSelector.addEventListener('change', function(){
if (batchSelector.value != 0 || batchSelector.value !== '') {
batchCopyMove.style.display = 'block';
} else {
batchCopyMove.style.display = 'none';
}
});
}

});
})();

0 comments on commit fb9c89e

Please sign in to comment.