Mwalker has uploaded a new change for review.

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


Change subject: Preventing Banner Load on Mobile Devices
......................................................................

Preventing Banner Load on Mobile Devices

Right now the backend in CentralNotice cannot support device
selection. So... we're just going to break out of the random
banner selector if a device is present.

Change-Id: Idbc96ed4c5eceefedddafc05b335f0aa5f9b4acc
---
M CentralNotice.php
M modules/ext.centralNotice.bannerController/bannerController.js
2 files changed, 15 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice 
refs/changes/81/52181/1

diff --git a/CentralNotice.php b/CentralNotice.php
index cf45fdf..7afd058 100644
--- a/CentralNotice.php
+++ b/CentralNotice.php
@@ -506,13 +506,7 @@
 function efCentralNoticeDisplay( &$notice ) {
        // Setup siteNotice div and initialize the banner controller.
        // Comment hack for IE8 to collapse empty div
-       $notice = <<<EOT
-<!-- CentralNotice --><script>
-       mw.loader.using( 'ext.centralNotice.bannerController', function() { 
mw.centralNotice.initialize(); } );
-</script>
-$notice
-EOT;
-
+       $notice = "<!-- CentralNotice -->$notice";
        return true;
 }
 
diff --git a/modules/ext.centralNotice.bannerController/bannerController.js 
b/modules/ext.centralNotice.bannerController/bannerController.js
index 64f03e3..1c1967f 100644
--- a/modules/ext.centralNotice.bannerController/bannerController.js
+++ b/modules/ext.centralNotice.bannerController/bannerController.js
@@ -11,9 +11,6 @@
                }
        }
 
-       $.ajaxSetup({
-               cache: true
-       });
        mw.centralNotice = {
         /** -- Central Notice Required Data -- **/
                data: {
@@ -48,7 +45,8 @@
                                userlang: mw.config.get( 'wgUserLanguage' ),
                                db: mw.config.get( 'wgDBname' ),
                                sitename: mw.config.get( 'wgSiteName' ),
-                               country: mw.centralNotice.data.country
+                               country: mw.centralNotice.data.country,
+                               device: mw.config.get( 'wgMobileDeviceName', 
'desktop' )
                        };
                        scriptUrl = mw.config.get( 'wgCentralPagePath' ) + '?' 
+ $.param( bannerPageQuery );
                        bannerScript = '<script src="' + mw.html.escape( 
scriptUrl ) + '"></script>';
@@ -57,6 +55,11 @@
                loadRandomBanner: function () {
                        var RAND_MAX = 30;
 
+                       // TODO: Get rid of this when mobile support in CN is 
totally there
+                       if ( mw.config.get( 'wgMobileDeviceName' ) ) {
+                               return;
+                       }
+
                        var bannerDispatchQuery = {
                                userlang: mw.config.get( 'wgUserLanguage' ),
                                sitename: mw.config.get( 'wgSiteName' ),
@@ -64,6 +67,7 @@
                                anonymous: mw.config.get( 'wgUserName' ) === 
null,
                                bucket: mw.centralNotice.data.bucket,
                                country: mw.centralNotice.data.country,
+                               device: mw.config.get( 'wgMobileDeviceName', 
'desktop' ),
                                slot: Math.floor( Math.random() * RAND_MAX ) + 1
                        };
                        var scriptUrl = mw.config.get( 
'wgCentralBannerDispatcher' )
@@ -180,10 +184,10 @@
 
             // Has the banner been hidden by cookie?
                        if ( $.cookie( 'stopMobileRedirect' ) === 'true' ) {
-                           impressionResultData = {
+                               impressionResultData = {
                                        result: 'hide',
                                        reason: 'mobile'
-                           }
+                               }
                        } else if ( $.cookie( 'centralnotice_' + 
encodeURIComponent( mw.centralNotice.data.bannerType ) ) === 'hide' ) {
                 // Yes
                 impressionResultData = {
@@ -269,4 +273,8 @@
                window.hideBanner();
        };
 
+       // Initialize CentralNotice
+               $( function() {
+               mw.centralNotice.initialize();
+       });
 } )( jQuery, mediaWiki );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbc96ed4c5eceefedddafc05b335f0aa5f9b4acc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

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

Reply via email to