Jdlrobson has uploaded a new change for review.

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


Change subject: Make CentralNotice device aware
......................................................................

Make CentralNotice device aware

For time being only make it aware of iphone, ipad and android devices
(Mobile team currently wants to run campaigns for existing apps)
We can extend this in future to other devices

Bug: 47586

Change-Id: Ifbbd97830f0184eb843d616a7d2e70487169155c
---
M CentralNotice.php
A modules/ext.centralNotice.bannerController/mobile/device.js
2 files changed, 21 insertions(+), 1 deletion(-)


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

diff --git a/CentralNotice.php b/CentralNotice.php
index be4a9ab..303a37b 100644
--- a/CentralNotice.php
+++ b/CentralNotice.php
@@ -90,7 +90,10 @@
 $wgResourceModules[ 'ext.centralNotice.bannerController.mobile' ] = 
$wgResourceModules[ 'ext.centralNotice.bannerController' ] + array(
        'targets' => 'mobile',
 );
-$wgResourceModules[ 'ext.centralNotice.bannerController.mobile' ][ 
'dependencies' ][] = 'mobile.xdevice.detect.scripts';
+$wgResourceModules[ 'ext.centralNotice.bannerController.mobile' ][ 'scripts' ] 
= array(
+       'ext.centralNotice.bannerController/mobile/device.js',
+       'ext.centralNotice.bannerController/bannerController.js',
+);
 
 function efEnableMobileModules( $out, $mode ) {
        $name = 'ext.centralNotice.bannerController.mobile';
diff --git a/modules/ext.centralNotice.bannerController/mobile/device.js 
b/modules/ext.centralNotice.bannerController/mobile/device.js
new file mode 100644
index 0000000..249e489
--- /dev/null
+++ b/modules/ext.centralNotice.bannerController/mobile/device.js
@@ -0,0 +1,17 @@
+/*
+Basic device detection module for mobile
+*/
+( function( mw ) {
+       var ua = navigator.userAgent, name;
+       
+       if ( ua.match( /iphone/i ) ) {
+               name = 'iphone';
+       } else if ( ua.match( /ipad/i ) ) {
+               name = 'ipad';
+       } else if ( ua.match( /android/i ) ) {
+               name = 'android';
+       }
+       if ( name ) {
+               mw.config.set( 'wgMobileDeviceName', name );
+       }
+}( mediaWiki ) );

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

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

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

Reply via email to