jenkins-bot has submitted this change and it was merged.
Change subject: alert: Make selectors less overly specific and clean up js
......................................................................
alert: Make selectors less overly specific and clean up js
Follows-up 383a818.
* There is no need for the additional element ("a") or
descendant ("#pt-mytalk") selector.
It isn't overrriding anything, only hardcodes details that make
it harder to maintain or extend this stylesheet. For example,
there is a gadget that makes user messages green instead of
orange, it now was required to hardcode the "#pt-mytalk a" part
of the selector eventhough those are subject to change.
Separation of concerns.
* Cache/reuse the jQuery object instead of executing the same
query to the document, again. It also avoids a potential bug
where the second query matches different elements (e.g. after
appending alertMessage, there could potentially be an additional
nested anchor link; there isn't now though, as the message is
plain text).
* Add comment about weird echoNewMsgAlertDisplayed variable.
Change-Id: I682182fe15a868969f25fa5bfe2412e2a6f3dddf
---
M modules/alert/ext.echo.alert.css
M modules/alert/ext.echo.alert.js
M modules/alert/ext.echo.alert.modern.css
3 files changed, 10 insertions(+), 4 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/alert/ext.echo.alert.css b/modules/alert/ext.echo.alert.css
index 1c2f105..a1fb628 100644
--- a/modules/alert/ext.echo.alert.css
+++ b/modules/alert/ext.echo.alert.css
@@ -1,7 +1,8 @@
#pt-mytalk {
white-space: nowrap;
}
-#pt-mytalk a.mw-echo-alert {
+
+.mw-echo-alert {
border-radius: 2px;
background-color: #F9C557;
padding: 0.25em 0.8em 0.2em 0.8em;
diff --git a/modules/alert/ext.echo.alert.js b/modules/alert/ext.echo.alert.js
index 8fffe54..eb4a1c7 100644
--- a/modules/alert/ext.echo.alert.js
+++ b/modules/alert/ext.echo.alert.js
@@ -1,9 +1,14 @@
( function ( $, mw ) {
'use strict';
+ // TODO: What is this extra echoNewMsgAlertDisplayed check for? This
should only run once
+ // and that variable isn't used anywhere else in the repository.
if ( mw.config.get( 'wgUserNewMsgRevisionId' ) && !mw.config.get(
'echoNewMsgAlertDisplayed' ) ) {
var alertMessage = mw.html.escape( mw.msg( 'colon-separator' )
+ mw.msg( 'echo-new-messages' ) );
- $( '#pt-mytalk a' ).append( alertMessage );
- $( '#pt-mytalk a' ).addClass( 'mw-echo-alert' );
+
+ $( '#pt-mytalk a' )
+ .append( alertMessage )
+ .addClass( 'mw-echo-alert' );
+
mw.config.set( 'echoNewMsgAlertDisplayed', true );
}
} )( jQuery, mediaWiki );
diff --git a/modules/alert/ext.echo.alert.modern.css
b/modules/alert/ext.echo.alert.modern.css
index 0acf6c5..1a3786e 100644
--- a/modules/alert/ext.echo.alert.modern.css
+++ b/modules/alert/ext.echo.alert.modern.css
@@ -1,4 +1,4 @@
/* No rounded corners for modern skin */
-#pt-mytalk a.mw-echo-alert {
+.mw-echo-alert {
border-radius: 0;
}
--
To view, visit https://gerrit.wikimedia.org/r/85798
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I682182fe15a868969f25fa5bfe2412e2a6f3dddf
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits