jenkins-bot has submitted this change and it was merged.
Change subject: Remove jQuery dependency during banner injection
......................................................................
Remove jQuery dependency during banner injection
jQuery isn't always loaded before banner injection,
so remove the need for it altogether.
Bug: T116821
Change-Id: I2574b5e77b855691d825a5f5f9fe8d56646075a4
---
M includes/ZeroSpecialPage.php
1 file changed, 15 insertions(+), 3 deletions(-)
Approvals:
Yurik: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/ZeroSpecialPage.php b/includes/ZeroSpecialPage.php
index a88102f..5f14a31 100644
--- a/includes/ZeroSpecialPage.php
+++ b/includes/ZeroSpecialPage.php
@@ -397,7 +397,14 @@
}
/**
- * Render raw HTML snippet or GIF image content for unified design JS
inclusion
+ * Render raw HTML snippet or GIF image content for unified design JS
inclusion.
+ *
+ * To test banners generated by the echoBanner method, do the following:
+ * - In your browser, spoof the "X-CS" header to "ON", and
"X-SUBDOMAIN" to "M"
+ * - In mediawiki/includes/WebRequest.php, change the "headers"
variable to "public"
+ * - Add the following line to the top of the "execute" method
+ * $this->getRequest()->headers['X-CS'] =
'<your-zero-config-name>';
+ *
* @param PageRendering $state
* @param string $zcmd
* @return bool
@@ -462,9 +469,14 @@
$cfg = PageRendering::getJsConfigBlock(
$this, $xcs, $config, false );
}
if ( $banner ) {
- $banner = '$(\'body\').prepend(' .
Xml::encodeJsVar( $banner ) . ');';
+ $bannerElem = 'var
el=document.createElement("div");';
+ $bannerElem .= 'el.innerHTML="' .
addslashes( $banner ) . '";';
+ // This assumes the raw banner HTML is
a single DOM element
+ $bannerElem .=
'document.body.insertBefore(el.firstChild,document.body.firstChild);';
+ } else {
+ $bannerElem = '';
}
- $banner = $cfg . $banner;
+ $banner = '(function(){' . $cfg . $bannerElem .
'})();';
}
} else {
//
--
To view, visit https://gerrit.wikimedia.org/r/249902
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2574b5e77b855691d825a5f5f9fe8d56646075a4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroBanner
Gerrit-Branch: wmf/1.27.0-wmf.3
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: Jhobs <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits