Merge "Use subpage only for media search string"

This commit is contained in:
jenkins-bot 2014-06-04 22:10:29 +00:00 committed by Gerrit Code Review
commit 55952a32b3
2 changed files with 13 additions and 2 deletions

View file

@ -374,7 +374,7 @@ class VisualEditorHooks {
* Adds extra variables to the page config.
*/
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) {
global $wgStylePath, $wgSVGMaxSize;
global $wgStylePath, $wgSVGMaxSize, $wgNamespacesWithSubpages;
$pageLanguage = $out->getTitle()->getPageLanguage();
@ -387,6 +387,7 @@ class VisualEditorHooks {
'pageLanguageCode' => $pageLanguage->getHtmlCode(),
'pageLanguageDir' => $pageLanguage->getDir(),
'svgMaxSize' => $wgSVGMaxSize,
'namespacesWithSubpages' => $wgNamespacesWithSubpages
);
return true;

View file

@ -18,10 +18,20 @@
* @param {number} [size] Vertical size of thumbnails
*/
ve.ui.MWMediaSearchWidget = function VeUiMWMediaSearchWidget( config ) {
var pageTitle = mw.config.get( 'wgTitle' ),
namespace = mw.config.get( 'wgNamespaceNumber' ),
namespacesWithSubpages = mw.config.get( 'wgVisualEditor' ).namespacesWithSubpages;
if ( namespacesWithSubpages[ namespace ] ) {
// If we are in a namespace that allows for subpages, strip the entire
// title except for the part after the last /
pageTitle = pageTitle.substr( pageTitle.lastIndexOf( '/' ) + 1 );
}
// Configuration intialization
config = ve.extendObject( {
'placeholder': ve.msg( 'visualeditor-media-input-placeholder' ),
'value': mw.config.get( 'wgTitle' )
'value': pageTitle
}, config );
// Parent constructor