Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/214362
Change subject: Message box standardisation (step 1) ...................................................................... Message box standardisation (step 1) Drop our alert class in favour of the classes used in core (warningbox, errorbox, successbox). Drop mw-dismissable-notice which does not exist anywhere in the core code or MobileFrontend code so purpose is unknown and probably dead code. On history and contributions page show a warningbox rather than an errorbox since they are not errors just information. Refactor message boxes to give a consistent experience on: * viewing diffs with warnings * viewing old revisions * MobileEditor with js disabled * history/contributions page when no items found * special uploads page when bad username given * saving preferences * warning box on special pages that are not available in stable (currently none) * user profile when bad username given Change-Id: I0fed10d45285a48fbc6af50dd3a3be9940ffc186 --- M i18n/en.json M includes/MobileUI.php M includes/skins/SkinMinerva.php M includes/skins/SkinMinervaBeta.php M includes/specials/MobileSpecialPage.php M includes/specials/SpecialMobileContributions.php M includes/specials/SpecialMobileDiff.php M includes/specials/SpecialMobileEditor.php M includes/specials/SpecialMobileHistory.php M includes/specials/SpecialMobileLanguages.php M includes/specials/SpecialMobilePreferences.php M includes/specials/SpecialNearby.php M includes/specials/SpecialUploads.php M includes/specials/SpecialUserProfile.php M resources/mobile.editor.common/EditorOverlayAnonWarning.hogan M resources/mobile.special.uploads.scripts/uploads.js M resources/skins.minerva.base.styles/ui.less M resources/skins.minerva.special.styles/common.less 18 files changed, 114 insertions(+), 91 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/62/214362/1 diff --git a/i18n/en.json b/i18n/en.json index eef6594..d87fce5 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -132,7 +132,6 @@ "mobile-frontend-editor-tutorial-confirm": "Start editing", "mobile-frontend-editor-tutorial-summary": "Try improving the $1 page.<br />Don't be scared of markup.", "mobile-frontend-editor-unavailable": "Mobile editing is not currently available on your browser. Please try a different browser.", - "mobile-frontend-editor-unavailable-header": "Editor unavailable", "mobile-frontend-editor-undo-unsupported": "Undo is not currently supported on mobile devices.", "mobile-frontend-editor-uploadenable": "Please upload a photo first to enable editing.", "mobile-frontend-editor-viewing-source-page": "<strong>Viewing source of</strong><span> $1</span>", diff --git a/includes/MobileUI.php b/includes/MobileUI.php index 81e7f1d..7461c8f 100644 --- a/includes/MobileUI.php +++ b/includes/MobileUI.php @@ -59,4 +59,54 @@ public static function anchorClass( $modifier = '', $additionalClassNames = '' ) { return self::semanticClass( 'mw-ui-anchor', $modifier, $additionalClassNames ); } + + /** + * Return a warning box. + * @param string $html of contents of box + * @param string className corresponding to box + * @return string of html representing a box. + */ + public static function messageBox( $html, $className ) { + return Html::openElement( 'div', array( 'class' => $className ) ) . + $html . Html::closeElement( 'div' ); + } + + /** + * Return a warning box. + * @param string $html of contents of box + * @return string of html representing a warning box. + */ + public static function warningBox( $html ) { + return self::messageBox( $html, 'warningbox' ); + } + + /** + * Return an error box. + * @param string $html of contents of error box + * @return string of html representing an error box. + */ + public static function errorBox( $html ) { + return self::messageBox( $html, 'errorbox' ); + } + + /** + * Return a success box. + * @param string $html of contents of box + * @return string of html representing a success box. + */ + public static function successBox( $html ) { + return self::messageBox( $html, 'successbox' ); + } + + /** + * Mark some html as being content + * @param string $html + * @param string $className additional class names + * @return string of html + */ + public static function contentElement( $html, $className = '' ) { + $className .= ' content '; + return Html::openElement( 'div', array( 'class' => $className ) ) . $html . + Html::closeElement( 'div' ); + } } diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index ffade0f..7abb2ad 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -790,17 +790,21 @@ } /** + * @return html for a message to display at top of old revisions + */ + protected function getOldRevisionHtml() { + return $this->getOutput()->getSubtitle(); + } + + /** * Prepare warnings for mobile output * @param BaseTemplate $tpl */ protected function prepareWarnings( BaseTemplate $tpl ) { $out = $this->getOutput(); if ( $out->getRequest()->getText( 'oldid' ) ) { - $subtitle = $out->getSubtitle(); - $tpl->set( - '_old_revision_warning', - Html::openElement( 'div', array( 'class' => 'alert warning' ) ) . - $subtitle . Html::closeElement( 'div' ) ); + $tpl->set( '_old_revision_warning', + MobileUI::warningBox( $this->getOldRevisionHtml() ) ); } } diff --git a/includes/skins/SkinMinervaBeta.php b/includes/skins/SkinMinervaBeta.php index 8c8dadb..8d271be 100644 --- a/includes/skins/SkinMinervaBeta.php +++ b/includes/skins/SkinMinervaBeta.php @@ -173,25 +173,17 @@ } /** - * Prepare warnings for mobile devices - * @param BaseTemplate $tpl + * @return html for a message to display at top of old revisions */ - protected function prepareWarnings( BaseTemplate $tpl ) { - parent::prepareWarnings( $tpl ); - $out = $this->getOutput(); - if ( $out->getRequest()->getText( 'oldid' ) ) { - $subtitle = $out->getSubtitle(); - $tpl->set( '_old_revision_warning', - Html::openElement( 'div', array( 'class' => 'alert warning' ) ) . - Html::openElement( 'p', array() ). - Html::element( 'a', array( 'href' => '#editor/0' ), + protected function getOldRevisionHtml() { + $viewSourceLink = Html::openElement( 'p', array() ) . + Html::element( 'a', array( 'href' => '#editor/0' ), $this->msg( 'mobile-frontend-view-source' )->text() ) . - Html::closeElement( 'p' ) . - $subtitle . - Html::closeElement( 'div' ) ); - } + Html::closeElement( 'p' ); + return $viewSourceLink . parent::getOldRevisionHtml(); } + /** @inheritdoc */ protected function preparePageContent( QuickTemplate $tpl ) { parent::preparePageContent( $tpl ); diff --git a/includes/specials/MobileSpecialPage.php b/includes/specials/MobileSpecialPage.php index 8eaf962..a3a10d0 100644 --- a/includes/specials/MobileSpecialPage.php +++ b/includes/specials/MobileSpecialPage.php @@ -79,10 +79,7 @@ $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'mobile-frontend-requires-title' ) ); $out->setProperty( 'unstyledContent', true ); - $out->addHTML( Html::openElement( 'div', array( 'class' => 'alert warning' ) ) . - $msg . - Html::closeElement( 'div' ) - ); + $out->addHTML( MobileUI::warningBox( $msg ) ); } /** diff --git a/includes/specials/SpecialMobileContributions.php b/includes/specials/SpecialMobileContributions.php index 19f8f46..03be001 100644 --- a/includes/specials/SpecialMobileContributions.php +++ b/includes/specials/SpecialMobileContributions.php @@ -103,8 +103,9 @@ $out->addHtml( $this->getMoreButton( $rev->getTimestamp() ) ); } } else { - $out->addHtml( Html::element( 'div', array( 'class' => 'error alert' ), - $this->msg( 'mobile-frontend-history-no-results' ) ) ); + // For users who exist but have not made any edits + $out->addHtml( + MobileUI::warningBox( $this->msg( 'mobile-frontend-history-no-results' ) ) ); } } diff --git a/includes/specials/SpecialMobileDiff.php b/includes/specials/SpecialMobileDiff.php index 11b2be3..42303f7 100644 --- a/includes/specials/SpecialMobileDiff.php +++ b/includes/specials/SpecialMobileDiff.php @@ -221,12 +221,7 @@ $warnings = $de->getWarningMessageText(); if ( $warnings ) { - $warnings = Html::openElement( 'div', - array( - 'class' => 'warning alert', - ) ) . - $warnings . - Html::closeElement( 'div' ); + $warnings = MobileUI::warningBox( $warnings ); } $this->getOutput()->addHtml( $warnings . diff --git a/includes/specials/SpecialMobileEditor.php b/includes/specials/SpecialMobileEditor.php index c3a8a79..266d0a1 100644 --- a/includes/specials/SpecialMobileEditor.php +++ b/includes/specials/SpecialMobileEditor.php @@ -48,21 +48,11 @@ ) ) . Html::openElement( 'noscript' ) . - Html::openElement( 'div', - array( - 'class' => 'error alert', - ) - ) . - Html::element( 'h2', array(), - $this->msg( 'mobile-frontend-editor-unavailable-header' )->text() ) . - Html::element( 'p', array(), - $this->msg( 'mobile-frontend-editor-unavailable' )->text() ) . + MobileUI::errorBox( $this->msg( 'mobile-frontend-editor-unavailable' )->text() ) . Html::openElement( 'p' ) . Html::element( 'a', array( 'href' => $title->getLocalUrl() ), $this->msg( 'returnto', $title->getText() )->text() ) . - Html::closeElement( 'p' ) . - Html::closeElement( 'div' ) . // .error .alert Html::closeElement( 'noscript' ) . Html::closeElement( 'div' ); // #mw-mf-editorunavailable diff --git a/includes/specials/SpecialMobileHistory.php b/includes/specials/SpecialMobileHistory.php index e7d5f35..98ec2e7 100644 --- a/includes/specials/SpecialMobileHistory.php +++ b/includes/specials/SpecialMobileHistory.php @@ -242,8 +242,10 @@ $out->addHtml( $this->getMoreButton( $rev1->getTimestamp() ) ); } } else { - $out->addHtml( Html::element( 'div', array( 'class' => 'error alert' ), - $this->msg( 'mobile-frontend-history-no-results' ) ) ); + // Edge case. + // I suspect this is here because revisions may exist but may have been hidden. + $out->addHtml( + MobileUI::warningBox( $this->msg( 'mobile-frontend-history-no-results' ) ) ); } } diff --git a/includes/specials/SpecialMobileLanguages.php b/includes/specials/SpecialMobileLanguages.php index a6ca866..f6d25fb 100644 --- a/includes/specials/SpecialMobileLanguages.php +++ b/includes/specials/SpecialMobileLanguages.php @@ -140,8 +140,7 @@ $output = $this->getOutput(); - $html = Html::openElement( 'div', array( 'class' => 'content' ) ); - + $html = ''; if ( $this->title && $this->title->exists() ) { $titlename = $this->title->getPrefixedText(); $pageTitle = $this->msg( 'mobile-frontend-languages-header-page', @@ -199,8 +198,7 @@ $this->msg( 'mobile-frontend-languages-nonexistent-title' )->params( $pagename )->text() ); } - $html .= Html::closeElement( 'div' ); - + $html = MobileUI::contentElement( $html ); $output->setPageTitle( $pageTitle ); $output->addHTML( $html ); } diff --git a/includes/specials/SpecialMobilePreferences.php b/includes/specials/SpecialMobilePreferences.php index 4b838a1..bfa0ea0 100644 --- a/includes/specials/SpecialMobilePreferences.php +++ b/includes/specials/SpecialMobilePreferences.php @@ -62,10 +62,7 @@ $this->checkReadOnly(); if ( $this->getRequest()->getCheck( 'success' ) ) { - $out->wrapWikiMsg( - "<div class=\"alert successbox\">$1</div>", - 'savedprefs' - ); + $out->addHtml( MobileUI::successBox( wfMessage( 'savedprefs' ) ) ); } if ( $par && in_array( $par, $this->validTabs ) ) { diff --git a/includes/specials/SpecialNearby.php b/includes/specials/SpecialNearby.php index b4ccddf..00a20a8 100644 --- a/includes/specials/SpecialNearby.php +++ b/includes/specials/SpecialNearby.php @@ -42,22 +42,15 @@ 'id' => 'mw-mf-nearby', ) ) . - Html::openElement( 'div', - array( - 'class' => 'noscript errorbox', - ) + MobileUI::contentElement( + MobileUI::errorBox( + Html::element( 'h2', array(), + wfMessage( 'mobile-frontend-nearby-requirements' ) ) . + Html::element( 'p', array(), + wfMessage( 'mobile-frontend-nearby-requirements-guidance' ) ) + ), + 'noscript' ) . - Html::openElement( 'div', - array( - 'class' => 'content', - ) - ) . - Html::element( 'h2', array(), - wfMessage( 'mobile-frontend-nearby-requirements' ) ) . - Html::element( 'p', array(), - wfMessage( 'mobile-frontend-nearby-requirements-guidance' ) ) . - Html::closeElement( 'div' ) . // .content - Html::closeElement( 'div' ) . // .noscript Html::closeElement( 'div' ); // #mw-mf-nearby $output->addHTML( $html ); diff --git a/includes/specials/SpecialUploads.php b/includes/specials/SpecialUploads.php index e2a4f3b..8209e25 100644 --- a/includes/specials/SpecialUploads.php +++ b/includes/specials/SpecialUploads.php @@ -35,11 +35,11 @@ if ( $par !== '' && $par !== null ) { $user = User::newFromName( $par ); if ( !$user || $user->isAnon() ) { - // User provided, but is invalid or not registered - // FIXME: Use Html class? - $html = '<div class="alert error">' - . $this->msg( 'mobile-frontend-photo-upload-invalid-user', $par )->parse() - . '</div>'; + $output->setStatusCode( 404 ); + $html = MobileUI::contentElement( + MobileUI::errorBox( + $this->msg( 'mobile-frontend-photo-upload-invalid-user', $par )->parse() ) . + ); } else { $html = $this->getUserUploadsPageHtml( $user ); } diff --git a/includes/specials/SpecialUserProfile.php b/includes/specials/SpecialUserProfile.php index 5089bbb..de21587 100644 --- a/includes/specials/SpecialUserProfile.php +++ b/includes/specials/SpecialUserProfile.php @@ -66,10 +66,12 @@ $out = $this->getOutput(); // generate a user friendly error with a meaningful message - $html = Html::openElement( 'div', array( 'class' => 'alert error' ) ); - $html .= Html::element( 'h2', array(), $this->msg( 'mobile-frontend-profile-error' ) ); - $html .= Html::element( 'p', array(), $this->msg( $msgKey ) ); - $html .= Html::closeElement( 'div' ); + $html = MobileUI::contentElement( + MobileUI::errorBox( + Html::element( 'h2', array(), $this->msg( 'mobile-frontend-profile-error' ) ) . + Html::element( 'p', array(), $this->msg( $msgKey ) ) + ) + ); // return page with status code 404, instead of 200 and output the error page $out->setStatusCode( 404 ); diff --git a/resources/mobile.editor.common/EditorOverlayAnonWarning.hogan b/resources/mobile.editor.common/EditorOverlayAnonWarning.hogan index fd1b162..66d20f1 100644 --- a/resources/mobile.editor.common/EditorOverlayAnonWarning.hogan +++ b/resources/mobile.editor.common/EditorOverlayAnonWarning.hogan @@ -1,5 +1,5 @@ -<div class="alert"> - <p class="anonMsg alert warning">{{{anonMsg}}}</p> +<div> + <p class="anonMsg warningbox">{{{anonMsg}}}</p> <div class="actions"> {{#anonButton}}{{>button}}{{/anonButton}} {{#loginButton}}{{>button}}{{/loginButton}} diff --git a/resources/mobile.special.uploads.scripts/uploads.js b/resources/mobile.special.uploads.scripts/uploads.js index 33ee225..d3586e6 100644 --- a/resources/mobile.special.uploads.scripts/uploads.js +++ b/resources/mobile.special.uploads.scripts/uploads.js @@ -11,12 +11,17 @@ * @ignore */ function init() { - new PhotoList( { - username: userName - } ).appendTo( '.content' ); + // check there are no errors on the page before attempting + // we might have an invalid username + if ( $( '.errorbox' ).length === 0 ) { + new PhotoList( { + username: userName + } ).appendTo( '.content' ); + } } - if ( userName && mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Uploads' ) { + // Assume we are on the special page. + if ( userName ) { $( init ); } diff --git a/resources/skins.minerva.base.styles/ui.less b/resources/skins.minerva.base.styles/ui.less index cfda712..bd02e58 100644 --- a/resources/skins.minerva.base.styles/ui.less +++ b/resources/skins.minerva.base.styles/ui.less @@ -80,11 +80,6 @@ } } -// Add border between notices and header -.mw-dismissable-notice { - border-bottom: 1px solid @grayLight; -} - // Used for messages on page lists and uploads and when showing old revisions .alert.warning { color: @colorWarningText; @@ -103,7 +98,9 @@ background: @colorSuccessBackground; } -.alert { +.successbox, +.errorbox, +.warningbox { padding: 1em @contentMargin; margin: 0 0 1em; diff --git a/resources/skins.minerva.special.styles/common.less b/resources/skins.minerva.special.styles/common.less index 292824a..079dec4 100644 --- a/resources/skins.minerva.special.styles/common.less +++ b/resources/skins.minerva.special.styles/common.less @@ -36,7 +36,8 @@ .mw-mf-special { .content { - h2 { + // don't apply these styles to headings in message boxes + > h2 { text-align: center; margin: .7em 0; font-size: 1.1em; -- To view, visit https://gerrit.wikimedia.org/r/214362 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0fed10d45285a48fbc6af50dd3a3be9940ffc186 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits