Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/251016
Change subject: Restructure education popup code to work without overriding
onSelect
......................................................................
Restructure education popup code to work without overriding onSelect
That code was breaking on mobile which uses a subclass of the normal
link inspector.
Bug: T117603
Change-Id: I75541230c21b1ee9eb73f6fb4b1fe5a5f9c14e75
---
M modules/ve-mw/ui/styles/tools/ve.ui.MWEducationPopupTool.css
M modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js
2 files changed, 42 insertions(+), 40 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/16/251016/1
diff --git a/modules/ve-mw/ui/styles/tools/ve.ui.MWEducationPopupTool.css
b/modules/ve-mw/ui/styles/tools/ve.ui.MWEducationPopupTool.css
index b18cf4d..2c275c2 100644
--- a/modules/ve-mw/ui/styles/tools/ve.ui.MWEducationPopupTool.css
+++ b/modules/ve-mw/ui/styles/tools/ve.ui.MWEducationPopupTool.css
@@ -24,6 +24,14 @@
position: absolute;
}
+.ve-ui-educationPopup-shield {
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+}
+
.oo-ui-widget-disabled .ve-ui-pulsatingDot,
.oo-ui-widget-disabled .ve-ui-stillDot {
display: none;
diff --git a/modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js
b/modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js
index 3b26889..08abd94 100644
--- a/modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js
+++ b/modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js
@@ -15,7 +15,7 @@
* @param {Object} [config] Configuration options
*/
ve.ui.MWEducationPopupTool = function VeUiMwEducationPopupTool( config ) {
- var popupCloseButton, $popupContent,
+ var popupCloseButton, $popupContent, $shield,
usePrefs = !mw.user.isAnon(),
prefSaysShow = usePrefs && !mw.user.options.get(
'visualeditor-hideusered' ),
tool = this;
@@ -55,11 +55,31 @@
width: 300
} );
+ this.shownEducationPopup = false;
this.$pulsatingDot = $( '<div>' ).addClass( 've-ui-pulsatingDot' );
this.$stillDot = $( '<div>' ).addClass( 've-ui-stillDot' );
+ $shield = $( '<div>' ).addClass( 've-ui-educationPopup-shield' ).click(
function ( e ) {
+ if ( !tool.shownEducationPopup ) {
+ if ( ve.init.target.openEducationPopupTool ) {
+
ve.init.target.openEducationPopupTool.popup.toggle( false );
+
ve.init.target.openEducationPopupTool.setActive( false );
+
ve.init.target.openEducationPopupTool.$pulsatingDot.show();
+
ve.init.target.openEducationPopupTool.$stillDot.show();
+ }
+ ve.init.target.openEducationPopupTool = tool;
+ tool.$pulsatingDot.hide();
+ tool.$stillDot.hide();
+ tool.popup.toggle( true );
+ tool.popup.$element.css( {
+ left: tool.$element.width() / 2,
+ top: tool.$element.height()
+ } );
+ $shield.remove();
+ }
+ } );
this.$element
.addClass( 've-ui-educationPopup' )
- .append( this.popup.$element, this.$stillDot,
this.$pulsatingDot );
+ .append( $shield, this.popup.$element, this.$stillDot,
this.$pulsatingDot );
setTimeout( function () {
var radius = tool.$pulsatingDot.width() / 2;
@@ -84,48 +104,22 @@
* Click handler for the popup close button
*/
ve.ui.MWEducationPopupTool.prototype.onPopupCloseButtonClick = function () {
- this.popup.toggle( false );
- this.setActive( false );
- ve.init.target.openEducationPopupTool = undefined;
-};
-
-/**
- * Overrides Tool's onSelect to bring up popup where necessary
- */
-ve.ui.MWEducationPopupTool.prototype.onSelect = function () {
var usePrefs = !mw.user.isAnon(),
prefSaysShow = usePrefs && !mw.user.options.get(
'visualeditor-hideusered' );
- // Beware: this method is called even if the constructor bailed after
checking
- // the user preference / cookie / localStorage. In that case,
this.$pulsatingDot,
- // this.popup and other properties will not be set.
- if ( this.$pulsatingDot && this.$pulsatingDot.is( ':visible' ) ) {
- if ( ve.init.target.openEducationPopupTool ) {
- ve.init.target.openEducationPopupTool.popup.toggle(
false );
- ve.init.target.openEducationPopupTool.setActive( false
);
-
ve.init.target.openEducationPopupTool.$pulsatingDot.show();
- ve.init.target.openEducationPopupTool.$stillDot.show();
- }
- ve.init.target.openEducationPopupTool = this;
- this.$pulsatingDot.hide();
- this.$stillDot.hide();
- this.popup.toggle( true );
- this.popup.$element.css( {
- left: this.$element.width() / 2,
- top: this.$element.height()
- } );
+ this.shownEducationPopup = true;
+ this.popup.toggle( false );
+ this.setActive( false );
+ ve.init.target.openEducationPopupTool = undefined;
- if ( prefSaysShow ) {
- new mw.Api().saveOption( 'visualeditor-hideusered', 1 );
- mw.user.options.set( 'visualeditor-hideusered', 1 );
- } else if ( !usePrefs ) {
- try {
- localStorage.setItem( 've-hideusered', 1 );
- } catch ( e ) {
- $.cookie( 've-hideusered', 1, { path: '/',
expires: 30 } );
- }
+ if ( prefSaysShow ) {
+ new mw.Api().saveOption( 'visualeditor-hideusered', 1 );
+ mw.user.options.set( 'visualeditor-hideusered', 1 );
+ } else if ( !usePrefs ) {
+ try {
+ localStorage.setItem( 've-hideusered', 1 );
+ } catch ( e ) {
+ $.cookie( 've-hideusered', 1, { path: '/', expires: 30
} );
}
- } else if ( !this.popup || !this.popup.isVisible() ) {
- return this.constructor.super.prototype.onSelect.apply( this,
arguments );
}
};
--
To view, visit https://gerrit.wikimedia.org/r/251016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I75541230c21b1ee9eb73f6fb4b1fe5a5f9c14e75
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits