aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2019-04-12 11:07:41 -0400
committerBrian Evans <grknight@gentoo.org>2019-04-12 11:07:41 -0400
commitbc50c26e13210251598bc77b60e8bb237a08d58c (patch)
tree8c359a642198b76d7d732abf9976508bdb444089
parentUtilitze the ResourceLoader to create the script for bootstrap js (diff)
downloadskin-tyrian-bc50c26e13210251598bc77b60e8bb237a08d58c.tar.gz
skin-tyrian-bc50c26e13210251598bc77b60e8bb237a08d58c.tar.bz2
skin-tyrian-bc50c26e13210251598bc77b60e8bb237a08d58c.zip
Always ensure that jQuery is loaded before Bootstrap is
Signed-off-by: Brian Evans <grknight@gentoo.org>
-rw-r--r--SkinTyrian.php16
-rw-r--r--TyrianTemplate.php1
2 files changed, 16 insertions, 1 deletions
diff --git a/SkinTyrian.php b/SkinTyrian.php
index eddc5fd..69fdd05 100644
--- a/SkinTyrian.php
+++ b/SkinTyrian.php
@@ -39,4 +39,20 @@ class SkinTyrian extends SkinTemplate {
$out->addMeta('theme-color', '#54487a');
return true;
}
+
+ public function initPage( OutputPage $out ) {
+ parent::initPage( $out );
+ $cdnURL = self::CDN_URL . 'bootstrap.min.js';
+ $script = <<<EOS
+function defer(method) {
+ if (window.jQuery) {
+ method();
+ } else {
+ setTimeout(function() { defer(method) }, 50);
+ }
+}
+defer(function() { mw.loader.load( '$cdnURL'); });
+EOS;
+ $out->addInlineScript($script);
+ }
}
diff --git a/TyrianTemplate.php b/TyrianTemplate.php
index eb6b660..3623321 100644
--- a/TyrianTemplate.php
+++ b/TyrianTemplate.php
@@ -65,7 +65,6 @@ class TyrianTemplate extends BaseTemplate {
<?php
$this->footer();
- echo ResourceLoader::makeInlineScript('mw.loader.load("https://assets.gentoo.org/tyrian/bootstrap.min.js");');
$this->printTrail();
echo Html::closeElement( 'body' );
echo Html::closeElement( 'html' );