From dabc661f41ffd271815c3868cbb125c83a9e91f3 Mon Sep 17 00:00:00 2001 From: Geoffrey Mon Date: Sun, 2 Aug 2015 00:03:57 +0000 Subject: [PATCH] Preferences: Fix issues from 6d3c65b5b0 * Use .mw-preferences-messagebox instead of .successbox to avoid conflicts with other Special pages using '.successbox' as a class and so that the new class can be used to check for messages to replace with notifications * Add logic to check for messages to replace using the new aforementioned class * Use Html::rawElement and Html::element instead of Xml::tags to add the non-JS successbox * Re-added

tags around non-JS successbox message that were accidentally ommitted in the original patch Bug: T19496 Change-Id: I990667aa114d8201516bee6cb2ad22994de53c6c --- includes/specials/SpecialPreferences.php | 9 ++++-- .../mediawiki.special.preferences.css | 4 +-- .../mediawiki.special.preferences.js | 28 +++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index f2a315e2f6..4b75e5f65c 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -50,10 +50,13 @@ class SpecialPreferences extends SpecialPage { if ( $this->getRequest()->getCheck( 'success' ) ) { $out->wrapWikiMsg( - Xml::tags( + Html::rawElement( 'div', - array( 'class' => 'successbox', 'id' => 'mw-preferences-success' ), - '$1' + array( + 'class' => 'mw-preferences-messagebox successbox', + 'id' => 'mw-preferences-success' + ), + Html::element( 'p', array(), '$1' ) ), 'savedprefs' ); diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.css b/resources/src/mediawiki.special/mediawiki.special.preferences.css index 0e71d30b78..8fb9a4785b 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.css +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.css @@ -20,7 +20,7 @@ zoom: 1; } -/* When JS is enabled, .successbox is replaced with a mw.notification */ -.successbox { +/* When JS is enabled, .mw-preferences-messageboxes are replaced with mw.notifications */ +.mw-preferences-messagebox { display: none; } diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index 893db9827e..7f13f2907e 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -1,4 +1,3 @@ - /*! * JavaScript for Special:Preferences */ @@ -86,18 +85,23 @@ jQuery( function ( $ ) { } } - // If there is a #mw-preferences-success box and javascript is enabled, use a slick notification instead! - if ( $( '#mw-preferences-success' ).length ) { - notif = mediaWiki.notification.notify( mediaWiki.message( 'savedprefs' ), { autoHide: false } ); - $( '#preftoc, .prefsection' ).one( 'change keydown mousedown', function () { // 'change' event not reliable! - if ( notif ) { - notif.close(); - } - } ); + // Check for messageboxes (.successbox, .warningbox, .errorbox) to replace with notifications + if ( $( '.mw-preferences-messagebox' ).length ) { + // If there is a #mw-preferences-success box and javascript is enabled, use a slick notification instead! + if ( $( '#mw-preferences-success' ).length ) { + notif = mediaWiki.notification.notify( mediaWiki.message( 'savedprefs' ), { autoHide: false } ); + // 'change' event not reliable! + $( '#preftoc, .prefsection' ).one( 'change keydown mousedown', function () { + if ( notif ) { + notif.close(); + notif = null; + } + } ); - // Remove now-unnecessary success=1 querystring to prevent reappearance of notification on reload - if ( history.replaceState ) { - history.replaceState( {}, document.title, document.URL.replace( /&?success=1/, '' ) ); + // Remove now-unnecessary success=1 querystring to prevent reappearance of notification on reload + if ( history.replaceState ) { + history.replaceState( {}, document.title, location.href.replace( /&?success=1/, '' ) ); + } } } -- 2.20.1