Merge "DAT.init#setEditorPreference: Change section edit alongside tab labels"

This commit is contained in:
jenkins-bot 2016-07-14 16:26:02 +00:00 committed by Gerrit Code Review
commit c3ab6950bc
3 changed files with 42 additions and 25 deletions

View file

@ -428,14 +428,6 @@ class VisualEditorHooks {
) {
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
// Exit if we're using the single edit tab.
if (
$config->get( 'VisualEditorUseSingleEditTab' ) &&
$skin->getUser()->getOption( 'visualeditor-tabs' ) !== 'multi-tab'
) {
return true;
}
// Exit if we're in parserTests
if ( isset( $GLOBALS[ 'wgVisualEditorInParserTests' ] ) ) {
return true;
@ -460,11 +452,29 @@ class VisualEditorHooks {
return true;
}
$tabMessages = $config->get( 'VisualEditorTabMessages' );
$sourceEditSection = $tabMessages['editsectionsource'] !== null ?
$tabMessages['editsectionsource'] : 'editsection';
$editor = self::getUserEditor( $skin->getUser(), RequestContext::getMain()->getRequest() );
if (
!$config->get( 'VisualEditorUseSingleEditTab' ) ||
$skin->getUser()->getOption( 'visualeditor-tabs' ) === 'multi-tab' ||
(
$skin->getUser()->getOption( 'visualeditor-tabs' ) === 'remember-last' &&
$editor === 'wikitext'
)
) {
// Don't add ve-edit, but do update the edit tab (e.g. "Edit source").
$tabMessages = $config->get( 'VisualEditorTabMessages' );
$sourceEditSection = $tabMessages['editsectionsource'] !== null ?
$tabMessages['editsectionsource'] : 'editsection';
$result['editsection']['text'] = $skin->msg( $sourceEditSection )->inLanguage( $lang )->text();
}
$result['editsection']['text'] = $skin->msg( $sourceEditSection )->inLanguage( $lang )->text();
// Exit if we're using the single edit tab.
if (
$config->get( 'VisualEditorUseSingleEditTab' ) &&
$skin->getUser()->getOption( 'visualeditor-tabs' ) !== 'multi-tab'
) {
return true;
}
// add VE edit section in VE available namespaces
if ( ApiVisualEditor::isAllowedNamespace( $config, $title->getNamespace() ) ) {

View file

@ -300,6 +300,7 @@
"create",
"create-local",
"edit",
"editsection",
"edit-local",
"pipe-separator",
"postedit-confirmation-created",

View file

@ -172,22 +172,9 @@
}
function activatePageTarget( modified ) {
var key;
trackActivateStart( { type: 'page', mechanism: 'click' } );
if ( !active ) {
if (
mw.config.get( 'wgVisualEditorConfig' ).singleEditTab &&
tabPreference === 'remember-last'
) {
key = pageExists ? 'edit' : 'create';
if ( $( '#ca-view-foreign' ).length ) {
key += '-local';
}
$( '#ca-edit a' ).text( mw.msg( key ) );
}
if ( uri.query.action !== 'edit' && uri.query.veaction !== 'edit' ) {
if ( history.pushState ) {
// Replace the current state with one that is tagged as ours, to prevent the
@ -270,10 +257,29 @@
}
function setEditorPreference( editor ) {
var key = pageExists ? 'edit' : 'create',
sectionKey = 'editsection';
if ( editor !== 'visualeditor' && editor !== 'wikitext' ) {
throw new Error( 'setEditorPreference called with invalid option: ', editor );
}
if (
mw.config.get( 'wgVisualEditorConfig' ).singleEditTab &&
tabPreference === 'remember-last'
) {
if ( $( '#ca-view-foreign' ).length ) {
key += 'localdescription';
}
if ( editor === 'wikitext' ) {
key += 'source';
sectionKey += 'source';
}
$( '#ca-edit a' ).text( mw.msg( tabMessages[ key ] || 'edit' ) );
$( '.mw-editsection a' ).text( mw.msg( tabMessages[ sectionKey ] || 'editsection' ) );
}
$.cookie( 'VEE', editor, { path: '/', expires: 30 } );
if ( mw.user.isAnon() ) {
return $.Deferred().resolve();