Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/249580
Change subject: Make dismissable SiteNotices hidden by default so they don't
flash
......................................................................
Make dismissable SiteNotices hidden by default so they don't flash
Note this does not affect the accessibility of the SiteNotices since
dismissable SiteNotices can only be loaded via JavaScript already.
Besides T108513, this also fixes the dismiss button jumping from the
top of the notice to the side during page load.
Bug: T108513
Change-Id: I7e5a4bedc30e3bfa32995ad38eaef729cca9c362
---
M DismissableSiteNotice.hooks.php
M extension.json
M modules/ext.dismissableSiteNotice.css
M modules/ext.dismissableSiteNotice.js
4 files changed, 32 insertions(+), 7 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DismissableSiteNotice
refs/changes/80/249580/1
diff --git a/DismissableSiteNotice.hooks.php b/DismissableSiteNotice.hooks.php
index 86a739b..28d958a 100644
--- a/DismissableSiteNotice.hooks.php
+++ b/DismissableSiteNotice.hooks.php
@@ -3,6 +3,21 @@
class DismissableSiteNoticeHooks {
/**
+ * Adds the CSS module
+ * @param OutputPage $out
+ * @param Skin $skin
+ * @return bool true
+ */
+ public static function onBeforePageDisplay( $out, $skin ) {
+ global $wgDismissableSiteNoticeForAnons;
+ // If the notice is dismissable, load the extra CSS
+ if ( $wgDismissableSiteNoticeForAnons ||
$skin->getUser()->isLoggedIn() ) {
+ $out->addModuleStyles(
'ext.dismissableSiteNoticeStyles' );
+ }
+ return true;
+ }
+
+ /**
* @param string $notice
* @param Skin $skin
* @return bool true
@@ -37,7 +52,7 @@
}
if ( $skin->getUser()->isAnon() ) {
- // Hide the sitenotice from search engines (see bug
9209 comment 4)
+ // Hide the sitenotice from search engines (see bug
T11209 comment 4)
// XXX: Does this actually work?
$notice = Html::inlineScript( Xml::encodeJsCall(
'document.write', array( $notice ) ) );
}
diff --git a/extension.json b/extension.json
index 223a23b..c0692db 100644
--- a/extension.json
+++ b/extension.json
@@ -15,6 +15,9 @@
"DismissableSiteNoticeForAnons": false
},
"Hooks": {
+ "BeforePageDisplay": [
+ "DismissableSiteNoticeHooks::onBeforePageDisplay"
+ ],
"SiteNoticeAfter": [
"DismissableSiteNoticeHooks::onSiteNoticeAfter"
]
@@ -27,7 +30,6 @@
"ResourceModules": {
"ext.dismissableSiteNotice": {
"scripts": "ext.dismissableSiteNotice.js",
- "styles": "ext.dismissableSiteNotice.css",
"dependencies": [
"jquery.cookie",
"mediawiki.util"
@@ -35,6 +37,13 @@
"targets": [
"desktop",
"mobile"
+ ]
+ },
+ "ext.dismissableSiteNoticeStyles": {
+ "styles": "ext.dismissableSiteNotice.css",
+ "targets": [
+ "desktop",
+ "mobile"
],
"position": "top"
}
diff --git a/modules/ext.dismissableSiteNotice.css
b/modules/ext.dismissableSiteNotice.css
index bce13f6..b30677e 100644
--- a/modules/ext.dismissableSiteNotice.css
+++ b/modules/ext.dismissableSiteNotice.css
@@ -1,5 +1,5 @@
-.mw-dismissable-notice-close {
- visibility: hidden;
+.mw-dismissable-notice {
+ display: none;
}
/* @noflip */ .sitedir-ltr .mw-dismissable-notice-close {
diff --git a/modules/ext.dismissableSiteNotice.js
b/modules/ext.dismissableSiteNotice.js
index ba7e1de..a7bc38c 100644
--- a/modules/ext.dismissableSiteNotice.js
+++ b/modules/ext.dismissableSiteNotice.js
@@ -7,14 +7,15 @@
return;
}
- if ( $.cookie( cookieName ) === siteNoticeId ) {
- mw.util.addCSS( '.mw-dismissable-notice { display: none; }' );
+ // If the user doesn't have the cookie set, show the site notice
+ if ( $.cookie( cookieName ) !== siteNoticeId ) {
+ mw.util.addCSS( '.mw-dismissable-notice { display: block; }' );
+ } else {
return;
}
$( function () {
$( '.mw-dismissable-notice-close' )
- .css( 'visibility', 'visible' )
.find( 'a' )
.click( function ( e ) {
e.preventDefault();
--
To view, visit https://gerrit.wikimedia.org/r/249580
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7e5a4bedc30e3bfa32995ad38eaef729cca9c362
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DismissableSiteNotice
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits