Added veaction param which auto-initializes the editor

Made edit tabs rendered on non view pages work correctly by routing them to the view page with an extra param that auto-initializes the editor

Change-Id: I4fd9106c8b45c6fc79af9ccb44e18944e9b9d8b9
This commit is contained in:
Trevor Parscal 2012-06-18 14:13:26 -07:00
parent 11a3d883f2
commit 76bca4f520
3 changed files with 39 additions and 11 deletions

View file

@ -14,8 +14,12 @@ class VisualEditorHooks {
if (
// Vector skin supported for now.
$skin->getSkinName() === 'vector' &&
// Be sure current page is VisualEditor:Something
$wgTitle->getNamespace() === NS_VISUALEDITOR
(
// Article in the VisualEditor namespace
$wgTitle->getNamespace() === NS_VISUALEDITOR ||
// Special page action for an article in the VisualEditor namespace
$skin->getRelevantTitle()->getNamespace() === NS_VISUALEDITOR
)
) {
$output->addModules( array( 'ext.visualEditor.editPageInit' ) );
}

View file

@ -96,7 +96,8 @@ $wgResourceModules += array(
),
'dependencies' => array(
'ext.visualEditor.init',
'mediawiki.util'
'mediawiki.util',
'mediawiki.Uri'
),
'messages' => array(
'minoredit',

View file

@ -35,11 +35,20 @@ ve.init.ViewPageTarget = function() {
// Initialization
if ( mw.config.get( 'wgCanonicalNamespace' ) === 'VisualEditor' ) {
// Clicking the edit tab is the only way any other code gets run, and this sets that up
if ( mw.config.get( 'wgAction' ) === 'view' ) {
this.setupSkinTabs();
this.setupSectionEditLinks();
this.setupToolbarSaveButton();
this.setupSaveDialog();
var uri = new mw.Uri( window.location.toString() );
if ( uri.query.veaction === 'edit' ) {
this.activate();
}
} else {
this.setupSkinTabs();
}
} else if ( mw.config.get( 'wgRelevantPageName' ).substr( 0, 13 ) === 'VisualEditor:' ) {
this.setupSkinTabs();
}
};
@ -347,13 +356,27 @@ ve.init.ViewPageTarget.prototype.setupSkinTabs = function() {
// Sysop users will need a new edit source tab since we are highjacking the edit tab
mw.util.addPortletLink(
'p-cactions',
mw.util.wikiGetlink() + '?action=edit',
$( '#ca-edit a' ).attr( 'href' ),
'Edit Source', // TODO: i18n
'ca-editsource'
);
}
if (
mw.config.get( 'wgCanonicalNamespace' ) === 'VisualEditor' &&
mw.config.get( 'wgAction' ) === 'view'
) {
$( '#ca-edit a' ).click( ve.proxy( this.onEditTabClick, this ) );
$( '#ca-view a' ).click( ve.proxy( this.onViewTabClick, this ) );
} else {
var uri = new mw.Uri( $( '#ca-edit a' ).attr( 'href' ) );
delete uri.query.action;
uri.query.veaction = 'edit';
$( '#ca-edit a' ).attr( 'href', uri );
}
// Source editing shouldn't highlight the edit tab
if ( mw.config.get( 'wgAction' ) === 'edit' ) {
$( '#p-views' ).find( 'li.selected' ).removeClass( 'selected' );
}
};
/**