Jhobs has uploaded a new change for review.

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

Change subject: Update interstitial to use OOjs-UI
......................................................................

Update interstitial to use OOjs-UI

Move "leaving zero-rated access" warning screen to an OO-UI
ProcessDialog with close and accept actions
Also fix a bug with turning off "Don't Ask Again" feature

Change-Id: Iec2488a67a0615591466309d85e5163d9c23f8f3
---
M ZeroBanner.php
M i18n/en.json
M i18n/qqq.json
M modules/ZeroInfo.js
M modules/ZeroOverlay.js
M modules/interstitial.js
M templates/interstitial.hogan
M templates/zeroinfo.hogan
8 files changed, 85 insertions(+), 41 deletions(-)


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

diff --git a/ZeroBanner.php b/ZeroBanner.php
index b07ef74..75679f5 100644
--- a/ZeroBanner.php
+++ b/ZeroBanner.php
@@ -95,6 +95,7 @@
                'zero-accept',
                'zero-go-back',
                'zero-dont-ask',
+               'zero-interstitial-title',
                'zero-info-title',
                'zero-info-intro',
                'zero-info-buttonText',
diff --git a/i18n/en.json b/i18n/en.json
index 376b727..d6ec523 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -9,6 +9,7 @@
        },
        "zerobanner": "Zero Rated Mobile Access",
        "zero-landing-welcome": "<blockquote>Real knowledge never promoted 
either turbulence or unbelief; but its progress is the forerunner of liberality 
and enlightened toleration.<div style='padding-left: 4em'>— ''Henry 
Brougham''</div></blockquote>",
+       "zero-interstitial-title": "Warning",
        "zero-info-title": "Wikipedia Zero Details",
        "zero-info-intro": "$1 is providing access to {{SITENAME}} free of 
charge.",
        "zero-info-buttonText": "More Information",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b859d97..cda3e9c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -25,6 +25,7 @@
        },
        "zerobanner": "{{doc-special|ZeroBanner}}\nWikipedia Zero is an 
initiative of the Wikimedia Foundation to enable free mobile access to 
Wikipedia in developing countries. The objective of the program is to reduce 
barriers to accessing free knowledge -- two of the largest barriers being cost 
of data usage and network speed. See [[mw:Wikipedia Zero]].",
        "zero-landing-welcome": "<span 
style=\"color:red\">'''ATTENTION'''</span>. Please read 
[[meta:Special:MyLanguage/Wikipedia Zero Starting Page|about this message]] 
before translating. This welcome message is shown at the top of the starting 
page to the entire community, and should be different, depending on the 
language-specific culture and customs. It is OK to set this message to some 
generic text like \"''Welcome to Wikipedia, the free encyclopedia anyone can 
edit. Please choose your language.''\" until the community decides what text to 
use here.",
+       "zero-interstitial-title": "Title of the warning dialog when user is 
about to leave zero-rated access",
        "zero-info-title": "Title of the dialog describing details about 
Wikipedia Zero",
        "zero-info-intro": "Short explanation that the user is browsing 
Wikipedia without being charged for bandwidth.\n\nParameters:\n* $1 - localized 
partner name",
        "zero-info-buttonText": "Text to describe button with link to more 
information\n{{Identical|More information}}",
diff --git a/modules/ZeroInfo.js b/modules/ZeroInfo.js
index a7b0aac..bd9ea22 100644
--- a/modules/ZeroInfo.js
+++ b/modules/ZeroInfo.js
@@ -28,11 +28,11 @@
                        var content = M.template.get( 'zeroinfo.hogan' 
).render( tplData );
 
                        this.$body.append( content );
-                       if ( conf.bannerWarning ) {
+                       if ( conf.bannerWarning && M.settings.getUserSetting( 
'zerodontask', true ) !== 'true' ) {
                                $( '#banner-link' ).click( function ( ev ) {
                                        ev.preventDefault();
                                        M.require( 'ZeroOverlay' );
-                                       window.location.hash = '#zerosite/' + 
this.href;
+                                       window.location.hash = '#/zerosite/' + 
this.href;
                                } );
                        }
                };
diff --git a/modules/ZeroOverlay.js b/modules/ZeroOverlay.js
index 2862c7b..a637f70 100644
--- a/modules/ZeroOverlay.js
+++ b/modules/ZeroOverlay.js
@@ -1,35 +1,75 @@
-/* global mw */
-( function( M ) {
+/* global mw, OO, jQuery */
+( function( M, $ ) {
        'use strict';
-       var Overlay = M.require( 'Overlay' ),
-       ZeroOverlay = Overlay.extend( {
-               template: M.template.get( 'interstitial.hogan' ),
-               closeOnBack: true,
-               defaults: {
-                       yes: mw.msg( 'zero-accept' ),
-                       no: mw.msg( 'zero-go-back' ),
-                       dontask: mw.msg( 'zero-dont-ask' )
-               },
-               initialize: function( options ) {
-                       this.defaults.warning = mw.msg( options.image ? 
'zero-file-auth' : 'zero-charge-auth' );
-                       Overlay.prototype.initialize.call( this, options );
-               },
-               postRender: function( options ) {
-                       Overlay.prototype.postRender.call( this, options );
-                       this.$( '#zerodontask' ).on( 'click', function() {
-                               M.settings.saveUserSetting( 'zerodontask', 
true, true );
-                               window.location.href = options.url;
-                       } );
-               }
-       } );
+       var ZeroOverlay, windowManager;
 
-       M.router.route( /^zerosite\/(.*)/, function( url ) {
-               new ZeroOverlay( { url: url, image: false } ).show();
+       ZeroOverlay = function ( options ) {
+               this.windowManager = windowManager = new OO.ui.WindowManager();
+
+               function ProcessDialog( config ) {
+                       ProcessDialog.super.call( this, config );
+               }
+
+               OO.inheritClass( ProcessDialog, OO.ui.ProcessDialog );
+               ProcessDialog.static.title = mw.msg( 'zero-interstitial-title' 
);
+               ProcessDialog.static.actions = [
+                       { label: 'X', flags: 'safe' },
+                       { label: mw.msg( 'zero-accept' ), flags: 'primary', 
action: 'open' }
+               ];
+               ProcessDialog.prototype.initialize = function () {
+                       ProcessDialog.super.prototype.initialize.apply( this, 
arguments );
+
+                       var conf = ( window && window.zeroGlobalConfig ) || 
false,
+                               tplData = {
+                                       dontask: mw.msg( 'zero-dont-ask' ),
+                                       warning: mw.msg( options.image ? 
'zero-file-auth' : 'zero-charge-auth' )
+                               };
+
+                       $.extend(tplData, options);
+
+                       var content = M.template.get( 'interstitial.hogan' 
).render( tplData );
+
+                       this.$body.append( content );
+                       $('#zerodontask').on( 'click', function () {
+                               M.settings.saveUserSetting('zerodontask', 
this.checked, true);
+                       } );
+               };
+               ProcessDialog.prototype.getActionProcess = function ( action ) {
+                       if ( action === 'open' ) {
+                               window.location.href = options.url;
+                       }
+                       // Fallback to parent handler
+                       return 
ProcessDialog.super.prototype.getActionProcess.call( this, action );
+               }
+               ProcessDialog.prototype.getTeardownProcess = function ( data ) {
+                       // Parent method
+                       return 
ProcessDialog.super.prototype.getTeardownProcess.call( this, data )
+                               .first( function () {
+                                       if ( 
window.location.hash.indexOf('#/zerosite') > -1 ||
+                                               
window.location.hash.indexOf('#/zerofile') > -1 ) {
+                                               history.replaceState('', 
document.title, window.location.pathname + location.search);
+                                       }
+                               }, this );
+               };
+
+               $( 'body' ).append( this.windowManager.$element );
+               var dialog = new ProcessDialog();
+               this.windowManager.addWindows( [dialog] );
+               this.windowManager.openWindow( dialog );
+
+               // Listen to router and hide dialog on URL change
+               M.router.one( 'route', function () {
+                       windowManager.clearWindows();
+               } );
+       };
+
+       M.router.route( /^\/zerosite\/(.*)/, function( url ) {
+               return new ZeroOverlay( { url: url, image: false } );
        } );
-       M.router.route( /^zerofile\/(.*)/, function( url ) {
-               new ZeroOverlay( { url: url, image: true } ).show();
+       M.router.route( /^\/zerofile\/(.*)/, function( url ) {
+               return new ZeroOverlay( { url: url, image: true } );
        } );
 
        M.define( 'ZeroOverlay', ZeroOverlay );
 
-}( mw.mobileFrontend ) );
+}( mw.mobileFrontend, jQuery ) );
diff --git a/modules/interstitial.js b/modules/interstitial.js
index 93166e8..084ed7e 100644
--- a/modules/interstitial.js
+++ b/modules/interstitial.js
@@ -32,7 +32,7 @@
                And if the user doesn't have cookies but does have JS, we'll 
check
                the config API as a last resort.
                */
-               if ( supportsTls || M.settings.getUserSetting( 'zerodontask', 
true ) ) {
+               if ( supportsTls || M.settings.getUserSetting( 'zerodontask', 
true ) === 'true' ) {
                        $( '.icon-watchlist,.icon-loginout,#page-actions' 
).show();
                        $( '.hlist > li:not(.new)' ).css( 'display', 
'inline-block' );
                        if ( !isMdot ) {
@@ -113,7 +113,7 @@
                        if ( config && !config.enabled ) {
                                // Config is provided but disabled, we don't 
exist
                                showWarning = false;
-                       } else if ( M.settings.getUserSetting( 'zerodontask', 
true ) ) {
+                       } else if ( M.settings.getUserSetting( 'zerodontask', 
true ) === 'true' ) {
                                // User chooses not to be notified, no need for 
any kinds of warnings
                                showWarning = false;
                        } else if ( isSpecialCase ) {
@@ -160,7 +160,7 @@
                        function navigate( warn ) {
                                if ( warn ) {
                                        M.require( 'ZeroOverlay' );
-                                       window.location.hash = ( isImage ? 
'#zerofile/' : '#zerosite/' ) + toUrl;
+                                       window.location.hash = ( isImage ? 
'#/zerofile/' : '#/zerosite/' ) + toUrl;
                                } else {
                                        // Navigate directly to the target 
bypassing a server hit
                                        window.location.href = toUrl;
diff --git a/templates/interstitial.hogan b/templates/interstitial.hogan
index 2a26b11..bc80776 100644
--- a/templates/interstitial.hogan
+++ b/templates/interstitial.hogan
@@ -1,8 +1,9 @@
-<div class="header mw-mf-banner mw-mf-banner-undismissable">
-{{warning}}
-</div>
-<div class="button-bar button-bar-centered buttonBar zerobar">
-    <button class="cancel inline zerobutton">{{no}}</button>
-    <a href="{{url}}" class="button zerobutton">{{yes}}</a>
-    <a id="zerodontask" class="button zerobutton">{{dontask}}</a>
+<div class="content">
+       <p>{{warning}}</p>
+       <p>
+               <form>
+                       <input type="checkbox" id="zerodontask">
+                       <label for="zerodontask">{{dontask}}</label>
+               </form>
+       </p>
 </div>
\ No newline at end of file
diff --git a/templates/zeroinfo.hogan b/templates/zeroinfo.hogan
index cc23f63..b29ef73 100644
--- a/templates/zeroinfo.hogan
+++ b/templates/zeroinfo.hogan
@@ -2,7 +2,7 @@
        <p>{{intro}}</p>
        <p>
        {{#url}}
-               <a id="banner-link" href="{{url}}"><button 
class="mw-ui-button">{{moreInfo}}</button></a>
+               <a id="banner-link" class="mw-ui-button" 
href="{{url}}">{{moreInfo}}</a>
        {{/url}}
        </p>
 </div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec2488a67a0615591466309d85e5163d9c23f8f3
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