mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-25 06:36:32 +00:00
815f3386e3
When advanced mobile contributions mode is enabled and `$wgMinervaOverflowInPageActions` is set, show a secondary overflow menu on main namespace articles and user namespace pages. The menu content varies for each namespace. The new submenu is *disabled* by default, even when AMC is active. This feature should not be deployed until instrumentation is available. The secondary menu is rendered in PHP using the existing menu system with some changes to the template. The checkbox hack is needed for no- JavaScript keyboard navigation until :focus-within is supported. CSS additions are documented in the source. All client side toolbar execution occurs in Toolbar.js. Enhancements are documented in the source. Minor changes to the existing download button: - Move download and edit button initialization to Toolbar. - Update copy (not visible) from "Download" to "Download PDF". - When the overflow menu is present, use the "hasText" / label style. Wikimedia UI icons are copied from OOUI at d00a0ac and seem useful to expose as HTTP URIs (not data URIs). The overflow menu does not show for pages provided by the content proxy since its entries depend on $tpl->data['nav_urls'] being populated. Bug: T216418 Depends-On: I0781151a8232b6a7b52f79a34298afcecb8e4271 Change-Id: I4b50a0e519024a7ab91dae6ab40b23cf14a03861
105 lines
3.2 KiB
PHP
105 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
*
|
|
* @file
|
|
*/
|
|
namespace MediaWiki\Minerva;
|
|
|
|
/**
|
|
* A wrapper for all available Skin options.
|
|
*/
|
|
final class SkinOptions {
|
|
/** Set of keys for available skin options. See $skinOptions. */
|
|
const OPTION_MOBILE_OPTIONS = 'mobileOptionsLink';
|
|
const OPTION_AMC = 'amc';
|
|
const OPTION_CATEGORIES = 'categories';
|
|
const OPTION_BACK_TO_TOP = 'backToTop';
|
|
const OPTION_PAGE_ISSUES = 'pageIssues';
|
|
const OPTION_SHARE_BUTTON = 'shareButton';
|
|
const OPTION_TOGGLING = 'toggling';
|
|
const OPTIONS_MOBILE_BETA = 'beta';
|
|
const OPTIONS_TALK_AT_TOP = 'talkAtTop';
|
|
const OPTIONS_HISTORY_PAGE_ACTIONS = 'historyInPageActions';
|
|
const OPTION_OVERFLOW_SUBMENU = 'overflowSubmenu';
|
|
|
|
/** @var array skin specific options */
|
|
private $skinOptions = [
|
|
// Defaults to true for desktop mode.
|
|
self::OPTION_AMC => true,
|
|
self::OPTIONS_MOBILE_BETA => false,
|
|
/**
|
|
* Whether the main menu should include a link to
|
|
* Special:Preferences of Special:MobileOptions
|
|
*/
|
|
self::OPTION_MOBILE_OPTIONS => false,
|
|
/** Whether a categories button should appear at the bottom of the skin. */
|
|
self::OPTION_CATEGORIES => false,
|
|
/** Whether a back to top button appears at the bottom of the view page */
|
|
self::OPTION_BACK_TO_TOP => false,
|
|
/** Whether a share button should appear in icons section */
|
|
self::OPTION_SHARE_BUTTON => false,
|
|
/** Whether sections can be collapsed (requires MobileFrontend and MobileFormatter) */
|
|
self::OPTION_TOGGLING => false,
|
|
self::OPTION_PAGE_ISSUES => false,
|
|
self::OPTIONS_TALK_AT_TOP => false,
|
|
self::OPTIONS_HISTORY_PAGE_ACTIONS => false,
|
|
self::OPTION_OVERFLOW_SUBMENU => false,
|
|
];
|
|
|
|
/**
|
|
* override an existing option or options with new values
|
|
* @param array $options
|
|
*/
|
|
public function setMultiple( array $options ) {
|
|
$this->skinOptions = array_merge( $this->skinOptions, $options );
|
|
}
|
|
|
|
/**
|
|
* Return whether a skin option is truthy. Should be one of self:OPTION_* flags
|
|
* @param string $key
|
|
* @return bool
|
|
*/
|
|
public function get( $key ) {
|
|
if ( !array_key_exists( $key, $this->skinOptions ) ) {
|
|
throw new \OutOfBoundsException( "SkinOption $key doesn't exist" );
|
|
}
|
|
return $this->skinOptions[$key];
|
|
}
|
|
|
|
/**
|
|
* Get all skin options
|
|
* @return array
|
|
*/
|
|
public function getAll() {
|
|
return $this->skinOptions;
|
|
}
|
|
|
|
/**
|
|
* Return whether any of the skin options have been set
|
|
* @return bool
|
|
*/
|
|
public function hasSkinOptions() {
|
|
foreach ( $this->skinOptions as $key => $val ) {
|
|
if ( $val ) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|