Skip to content

Commit

Permalink
Fixes to external JS CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
severdia committed Aug 25, 2020
1 parent 9ba991c commit 766c75a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 57 deletions.
50 changes: 21 additions & 29 deletions atomic/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<?php $doc = JFactory::getDocument();
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery.min.js']); ?>
<?php else : ?>
<?php echo $jquerycdn ?>
<script src="https://<?php echo $jquerycdn ?>"></script>
<?php endif; ?>

<jdoc:include type="head" />
Expand All @@ -110,10 +110,11 @@
unset($doc->_scripts[JURI::root(true) . '/media/system/js/core.js']);
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/bootstrap.min.js']);
if (isset($this->_script['text/javascript'])) {
$this->_script['text/javascript'] = preg_replace('%window\.addEvent\ (\'load\',\s*function\(\)\s*{\s*new\s*JCaption\(\'img.caption\'\);\s*}\);\s*%', '', $this->_script['text/javascript']);
if (empty($this->_script['text/javascript']))
$this->_script['text/javascript'] = preg_replace('/jQuery\(window\).on\(\'load\'\, function\(\) \{(.*);/is', '', $this->_script['text/javascript']);
if (empty($this->_script['text/javascript'])) {
unset($this->_script['text/javascript']);
}
}
?>
<?php endif; ?>

Expand All @@ -130,7 +131,7 @@
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery-migrate.min.js']);
?>
<?php elseif($jqmigrate = 1) : ?>
<script defer src="https://code.jquery.com/jquery-migrate-3.1.0.min.js" crossorigin="anonymous"></script>
<script defer src="https://code.jquery.com/jquery-migrate-3.3.1.min.js" crossorigin="anonymous"></script>
<?php endif; ?>

<?php // Remove Joomla CSS file (Modal styles)
Expand All @@ -150,7 +151,7 @@

<?php // Load remote Bootstrap 4.5 CSS framework from CDN
if(($bootstrapcdn == null) && ($bootstrapsource == 1)) : ?>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<?php elseif(($bootstrapcdn == null) && ($bootstrapsource == 2)) : ?>
<?php echo $bootstrapcdn ?>
<?php else : ?>
Expand All @@ -171,7 +172,7 @@
<?php elseif($fontawesome == 4) : ?>
<script defer src="<?php echo $fontawesomecdn; ?>"></script>
<?php endif; ?>

<?php // Load Google Fonts ?>
<?php if(($headerfont == 1) && ($bodyfont == 1) && ($headerfontname != null) && ($bodyfontname != null)) : ?>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=<?php echo $headerfontname; ?>|<?php echo $bodyfontname; ?>">
Expand Down Expand Up @@ -207,15 +208,6 @@
</style>
<?php endif; ?>

<?php // Add any custom dark mode CSS from the configuration.
if($customcsscode != null) : ?>
<style>
@media(prefers-color-scheme:dark) {
<?php echo $customdarkcsscode ?>
}
</style>
<?php endif; ?>

<?php // Load template favicons, loaded by default
if($loadfavicons == 1) : ?>
<link rel="apple-touch-icon" sizes="180x180" href="/templates/<?php echo $this->template ?>/favicons/apple-touch-icon.png">
Expand Down Expand Up @@ -248,7 +240,7 @@

<?php // Add Google Analytics tag if configured.
if($gacode != null) : ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-504090-1"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gacode; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
Expand All @@ -265,7 +257,7 @@ function gtag(){dataLayer.push(arguments);}

</head>

<?php /* Add the menu item alias to the body ID, class, or both */ ?>
<?php // Add the menu item alias to the body ID, class, or both. // ?>
<?php if($bodymenu == 1) : ?>
<body class="<?php echo $active->alias; ?> component-only ">
<?php elseif($bodymenu == 2) : ?>
Expand All @@ -276,13 +268,13 @@ function gtag(){dataLayer.push(arguments);}
<body class="component-only">
<?php endif; ?>

<?php // Add custom code after opening body tag
<?php // Add custom code after opening body tag
if($codeafterbody != null) : ?>
<?php echo $codeafterbody;
?>
<?php endif; ?>

<?php // Choose either a fixed or fluid width container
<?php // Choose either a fixed or fluid width container
if($fluidcontainer == 1) : ?>
<div class="container-fluid">
<?php else : ?>
Expand All @@ -303,31 +295,31 @@ function gtag(){dataLayer.push(arguments);}

<?php // Use jQuery Migrate 3.0.1
if($jqmigrate == 1) : ?>
<script src="https://code.jquery.com/jquery-migrate-3.0.1.min.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-migrate-3.3.1.min.js" crossorigin="anonymous"></script>
<?php endif; ?>

<?php // Load the local or remote Bootstrap 3 or 4 JavaScript dependency
// If CDN empty and load BS 3 remotely
<?php // Load the local or remote Bootstrap 3 or 4 JavaScript dependency
// If CDN empty and load BS 3 remotely
if(($bootstrapcdn == null) && ($bootstrapsource == 1)) : ?>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

<?php // If CDN empty and load BS 4 remotely
elseif(($bootstrapcdn == null) && ($bootstrapsource == 3)) : ?>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

<?php // If CDN empty and load BS 4 remotely, but full jQuery 3 is loaded
elseif(($bootstrapcdn == null) && ($bootstrapsource == 3) && ($jqlibrary == 2)) : ?>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<?php else : ?>
<?php endif; ?>

<?php // Add custom code before closing body tag
if($codebeforebody != null) : ?>
<?php echo $codebeforebody;
?>
<?php echo $codebeforebody; ?>
<?php endif; ?>

<?php // Use Instant.page
Expand Down
47 changes: 20 additions & 27 deletions atomic/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<?php $doc = JFactory::getDocument();
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery.min.js']); ?>
<?php else : ?>
<?php echo $jquerycdn ?>
<script src="https://<?php echo $jquerycdn ?>"></script>
<?php endif; ?>

<jdoc:include type="head" />
Expand All @@ -109,10 +109,8 @@
unset($doc->_scripts[JURI::root(true) . '/media/modals/js/script.min.js']);
unset($doc->_scripts[JURI::root(true) . '/media/system/js/core.js']);
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/bootstrap.min.js']);

if (isset($this->_script['text/javascript'])) {
$this->_script['text/javascript'] = preg_replace('/jQuery\(window\).on\(\'load\'\, function\(\) \{(.*);/is', '', $this->_script['text/javascript']);

if (empty($this->_script['text/javascript'])) {
unset($this->_script['text/javascript']);
}
Expand All @@ -133,7 +131,7 @@
unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery-migrate.min.js']);
?>
<?php elseif($jqmigrate = 1) : ?>
<script defer src="https://code.jquery.com/jquery-migrate-3.1.0.min.js" crossorigin="anonymous"></script>
<script defer src="https://code.jquery.com/jquery-migrate-3.3.1.min.js" crossorigin="anonymous"></script>
<?php endif; ?>

<?php // Remove Joomla CSS file (Modal styles)
Expand All @@ -153,7 +151,7 @@

<?php // Load remote Bootstrap 4.5 CSS framework from CDN
if(($bootstrapcdn == null) && ($bootstrapsource == 1)) : ?>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<?php elseif(($bootstrapcdn == null) && ($bootstrapsource == 2)) : ?>
<?php echo $bootstrapcdn ?>
<?php else : ?>
Expand Down Expand Up @@ -387,7 +385,6 @@ function gtag(){dataLayer.push(arguments);}
<?php if($protopositions == 1) : ?><jdoc:include type="modules" name="position-2" style="none" /><?php endif; ?>
</div>
<?php endif; ?>

</div>

<?php if($footer == 1) : ?>
Expand All @@ -405,47 +402,43 @@ function gtag(){dataLayer.push(arguments);}
</div>
</footer>
<?php endif; ?>


<?php if ($this->countModules( 'alertbar' )) : ?>
<?php if($alertbar == 1) : ?>
<div id="alertbar"><jdoc:include type="modules" name="alertbar" style="none" /></div>
<?php endif; ?>
<?php endif; ?>

<?php if ($this->countModules( 'alertbar' )) : ?>
<?php if($alertbar == 1) : ?>
<div id="alertbar"><jdoc:include type="modules" name="alertbar" style="none" /></div>
<?php endif; ?>
<?php endif; ?>

<jdoc:include type="modules" name="debug" style="basic" />

<jdoc:include type="modules" name="debug" style="basic" />
</div>

<?php // Use jQuery Migrate 3.0.1
if($jqmigrate == 1) : ?>
<script src="https://code.jquery.com/jquery-migrate-3.0.1.min.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-migrate-3.3.1.min.js" crossorigin="anonymous"></script>
<?php endif; ?>

<?php // Load the local or remote Bootstrap 3 or 4 JavaScript dependency
// If CDN empty and load BS 3 remotely
<?php // Load the local or remote Bootstrap 3 or 4 JavaScript dependency
// If CDN empty and load BS 3 remotely
if(($bootstrapcdn == null) && ($bootstrapsource == 1)) : ?>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

<?php // If CDN empty and load BS 4 remotely
elseif(($bootstrapcdn == null) && ($bootstrapsource == 3)) : ?>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

<?php // If CDN empty and load BS 4 remotely, but full jQuery 3 is loaded
elseif(($bootstrapcdn == null) && ($bootstrapsource == 3) && ($jqlibrary == 2)) : ?>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<?php else : ?>
<?php endif; ?>

<?php // Add custom code before closing body tag
if($codebeforebody != null) : ?>
<?php echo $codebeforebody;
?>
<?php echo $codebeforebody; ?>
<?php endif; ?>

<?php // Use Instant.page
Expand Down
2 changes: 1 addition & 1 deletion atomic/language/en-GB/en-GB.tpl_atomic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TPL_ATOMIC_JQUERY_LABEL="Load jQuery source"
TPL_ATOMIC_JQUERY_DESC="Choose a version other than the default loaded by Joomla. If you you load Bootstrap, you should choose the version that supports the version you have enabled. Be very careful with this option."

TPL_ATOMIC_JQUERYCDN_LABEL="Custom jQuery CDN"
TPL_ATOMIC_JQUERYCDN_DESC="Load a custom version of jQuery from the CDN. Paste in the code from code.jquery.com here. This will override your selection for jQuery source."
TPL_ATOMIC_JQUERYCDN_DESC="Load a custom version of jQuery from the CDN. Paste in the URL only from code.jquery.com here without the HTTPS://. This will override your selection for jQuery source."

TPL_ATOMIC_JQUERY_DEFAULT="jQuery 1.12.4 Local (Joomla 3 Default)"
TPL_ATOMIC_JQUERY_2="jQuery 2.2.4 Remote CDN"
Expand Down

0 comments on commit 766c75a

Please sign in to comment.