Jhobs has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/249874

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, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroBanner 
refs/changes/74/249874/1

diff --git a/includes/ZeroSpecialPage.php b/includes/ZeroSpecialPage.php
index a88102f..34ed350 100644
--- a/includes/ZeroSpecialPage.php
+++ b/includes/ZeroSpecialPage.php
@@ -30,6 +30,12 @@
         * @param null|string $par parameter passed to the special page or null
         */
        public function execute( $par ) {
+               // To test banners generated by the echoBanner method, do the 
following:
+               //  - In your browser, spoof the "X-CS" header to "ON"
+               //  - In mediawiki/includes/WebRequest.php, change the 
"headers" variable to "public"
+               //  - Uncomment the following line and replace "TEST" with your 
local Zero config
+               //$this->getRequest()->headers['X-CS'] = 'TEST';
+
                $out = $this->getOutput();
 
                // todo: vary-headers should be removed from the mobile frontend
@@ -462,9 +468,12 @@
                                        $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);';
                                }
-                               $banner = $cfg . $banner;
+                               $banner = '(function(window){' . $cfg . 
$bannerElem . '})(window);';
                        }
                } else {
                        //

-- 
To view, visit https://gerrit.wikimedia.org/r/249874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2574b5e77b855691d825a5f5f9fe8d56646075a4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroBanner
Gerrit-Branch: master
Gerrit-Owner: Jhobs <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to