jenkins-bot has submitted this change and it was merged.
Change subject: Hide page actions for non-JS browsers when no actions are
visible
......................................................................
Hide page actions for non-JS browsers when no actions are visible
Mark each page action whether it can be used without JS. If all page
actions are JS-only, then the page actions wrapper has the class `jsonly`
which will hide it from non-JS browsers.
Bug: T131287
Change-Id: I56ec072856f1e66d8da0ff2091da30a4b120656d
---
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMinerva.php
M includes/skins/SkinMinervaBeta.php
3 files changed, 17 insertions(+), 4 deletions(-)
Approvals:
Phuedx: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 44681ff..5b8c5c0 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -126,12 +126,16 @@
protected function getPageActionsHtml( $data ) {
$actions = $this->getPageActions();
$html = '';
+ $isJSOnly = true;
if ( $actions ) {
- $html = '<ul id="page-actions" class="hlist">';
foreach ( $actions as $key => $val ) {
+ if ( isset( $val['is_js_only'] ) &&
!$val['is_js_only'] ) {
+ $isJSOnly = false;
+ }
$html .= $this->makeListItem( $key, $val );
}
- $html .= '</ul>';
+ $additionalClasses = $isJSOnly ? 'jsonly' : '';
+ $html = '<ul id="page-actions" class="hlist ' .
$additionalClasses . '">' . $html . '</ul>';
}
return $html;
}
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 049468a..fc638ab 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -817,6 +817,12 @@
/**
* Prepare configured and available page actions
+ *
+ * When adding new page actions make sure each menu item has
+ * <code>is_js_only</code> key set to <code>true</code> or
<code>false</code>.
+ * The key will be used to decide whether to display the page actions
+ * wrapper on the front end. The key will be considered false if not
set.
+ *
* @param BaseTemplate $tpl
*/
protected function preparePageActions( BaseTemplate $tpl ) {
@@ -844,7 +850,8 @@
'edit' => array(
'href' =>
$this->getTitle()->getLocalUrl( array( 'action' => 'edit', 'section' => 0 ) )
)
- )
+ ),
+ 'is_js_only' => !$noJsEdit
);
}
@@ -854,6 +861,7 @@
// Use blank icon to reserve space for
watchstar icon once JS loads
'class' => MobileUI::iconClass( '', 'element',
'icon-32px watch-this-article' ),
+ 'is_js_only' => true
);
// standardise watch article into one menu item
if ( isset( $actions['watch'] ) ) {
diff --git a/includes/skins/SkinMinervaBeta.php
b/includes/skins/SkinMinervaBeta.php
index 2808939..75026e1 100644
--- a/includes/skins/SkinMinervaBeta.php
+++ b/includes/skins/SkinMinervaBeta.php
@@ -62,7 +62,8 @@
$menu['language-switcher'] = array( 'id' =>
'language-switcher', 'text' => '',
'itemtitle' => $this->msg(
'mobile-frontend-language-article-heading' ),
'class' => MobileUI::iconClass(
'language-switcher', 'element', $languageSwitcherClasses ),
- 'links' => $languageSwitcherLinks
+ 'links' => $languageSwitcherLinks,
+ 'is_js_only' => false
);
$tpl->set( 'page_actions', $menu );
}
--
To view, visit https://gerrit.wikimedia.org/r/281551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I56ec072856f1e66d8da0ff2091da30a4b120656d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits