Skip to content

Commit

Permalink
Move 'edit source' button to dropdown menu - zlzleking
Browse files Browse the repository at this point in the history
  • Loading branch information
zlzleking committed Feb 25, 2023
1 parent e6b86c7 commit b65ef1c
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions LibertyTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,23 +488,24 @@ protected function contentsToolbox() {
if ( $action != 'edit' ) {
$editIcon = $editable ? '<i class="fa fa-edit"></i> ' : '<i class="fa fa-lock"></i> ';
$editLabel = 'edit';
$editLink = 'edit';
// If VE is enabled, the regular button becomes the "edit source" button
// @todo FIXME: for a bunch of other skins, this happens automatically.
// For Liberty I had to manually do this and add the VE edit button (below).
// But why?
if ( $hasVisualEditor ) {
$editLabel = 'visualeditor-ca-editsource';
$editLink = 've-edit';
}
echo $linkRenderer->makeKnownLink(
$title,
new HtmlArmor( $editIcon . $skin->msg( $editLabel )->plain() ),
[
'class' => 'btn btn-secondary tools-btn',
'id' => 'ca-edit',
'title' => Linker::titleAttrib( 'ca-edit', 'withaccess' ),
'accesskey' => Linker::accesskey( 'ca-edit' )
'id' => 'ca-' . $editLink,
'title' => Linker::titleAttrib( 'ca-' . $editLink, 'withaccess' ),
'accesskey' => Linker::accesskey( 'ca-' . $editLink )
],
$revid ? [ 'action' => 'edit', 'oldid' => $revid ] : [ 'action' => 'edit' ]
$revid ? [ 'action' => $editLink, 'oldid' => $revid ] : [ 'action' => $editLink ]
);
}
if ( $action == 'edit' || $action == 'history' ) {
Expand All @@ -517,27 +518,6 @@ protected function contentsToolbox() {
'accesskey' => Linker::accesskey( 'ca-nstab-main' )
]
);
}
// If VisualEditor is installed, it needs an "edit" button in order
// to correctly set up its JS
// The JS will transform the edit button *above* into the VE-ful one,
// whereas _this_ one will become the "edit source" button
if ( $hasVisualEditor ) {
if ( $action !== 'edit' ) {
$editIcon = $editable ? '<i class="fa fa-edit"></i> ' : '<i class="fa fa-lock"></i> ';
$editMsg = $editable ? 'edit' : 'viewsource';
echo $linkRenderer->makeKnownLink(
$title,
new HtmlArmor( $editIcon . $skin->msg( $editMsg )->plain() ),
[
'class' => 'btn btn-secondary tools-btn',
'id' => 'ca-ve-edit',
'title' => Linker::titleAttrib( 'ca-ve-edit', 'withaccess' ),
'accesskey' => Linker::accesskey( 'ca-ve-edit' )
],
$revid ? [ 'action' => 'veedit', 'oldid' => $revid ] : [ 'action' => 'veedit' ]
);
}
}
if ( $companionTitle && $action != 'edit' ) {
if ( $title->isTalkPage() && $action != 'history' ) {
Expand Down Expand Up @@ -590,6 +570,26 @@ protected function contentsToolbox() {
?>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<?php
// If VisualEditor is installed, it needs an "edit" button in order
// to correctly set up its JS
// The JS will transform the edit button *above* into the VE-ful one,
// whereas _this_ one will become the "edit source" button
if ( $hasVisualEditor ) {
if ( $action !== 'edit' && $editable == true) {
$editLabel = 'visualeditor-ca-editsource';
echo $linkRenderer->makeKnownLink(
$title,
new HtmlArmor( $skin->msg( $editLabel )->plain() ),
[
'class' => 'dropdown-item',
'id' => 'ca-edit',
'title' => Linker::titleAttrib( 'ca-edit', 'withaccess' ),
'accesskey' => Linker::accesskey( 'ca-edit' )
],
$revid ? [ 'action' => 'edit', 'oldid' => $revid ] : [ 'action' => 'edit' ]
);
}
}
if ( $title->inNamespaces( NS_USER, NS_USER_TALK ) ) {
// "User contributions" link on user and user talk pages
echo $linkRenderer->makeKnownLink(
Expand Down

0 comments on commit b65ef1c

Please sign in to comment.