ve.init.mw.ViewPageTarget.init: Pass default values

Though this is already handled by Ie50b63ba5064e85d26 for the
server-side, and that should automatically reflect to the
client-side. Since we're dealing with cache conditions in
wmf-production where the user.options manifest does not yet
contain an entry for these relatively new preferences, lets
transfer the default value here as well. This does not affect
logged-in users (since their user options are always up-to-date
and embedded in the page).

Also made ve.support.es5 be casted to boolean. Previously it
would be a reference to JSON.stringify (if supported), or the
bottom value of whichever feature the browser didn't support.
Doesn't change any behaviour but should make things slightly
more performant when this value is evaluated.

Change-Id: I9ca430051ae6f4e603c2d89982e540e455055255
This commit is contained in:
Timo Tijhof 2013-07-26 22:20:10 +02:00 committed by Krinkle
parent 7ca95e3d32
commit 5036099906
2 changed files with 21 additions and 5 deletions

View file

@ -140,7 +140,8 @@ class VisualEditorHooks {
* Adds extra variables to the global config * Adds extra variables to the global config
*/ */
public static function onResourceLoaderGetConfigVars( array &$vars ) { public static function onResourceLoaderGetConfigVars( array &$vars ) {
global $wgVisualEditorDisableForAnons, global $wgDefaultUserOptions,
$wgVisualEditorDisableForAnons,
$wgVisualEditorEnableEventLogging, $wgVisualEditorEnableEventLogging,
$wgVisualEditorEnableExperimentalCode, $wgVisualEditorEnableExperimentalCode,
$wgVisualEditorNamespaces, $wgVisualEditorNamespaces,
@ -153,6 +154,10 @@ class VisualEditorHooks {
'enableExperimentalCode' => $wgVisualEditorEnableExperimentalCode, 'enableExperimentalCode' => $wgVisualEditorEnableExperimentalCode,
'namespaces' => $wgVisualEditorNamespaces, 'namespaces' => $wgVisualEditorNamespaces,
'pluginModules' => $wgVisualEditorPluginModules, 'pluginModules' => $wgVisualEditorPluginModules,
'defaultUserOptions' => array(
'enable' => $wgDefaultUserOptions['visualeditor-enable'],
'betatempdisable' => $wgDefaultUserOptions['visualeditor-betatempdisable'],
),
'skins' => self::$supportedSkins, 'skins' => self::$supportedSkins,
'tabLayout' => $wgVisualEditorTabLayout, 'tabLayout' => $wgVisualEditorTabLayout,
); );

View file

@ -62,7 +62,7 @@
); );
support = { support = {
es5: ( es5: !!(
// It would be much easier to do a quick inline function that asserts "use strict" // It would be much easier to do a quick inline function that asserts "use strict"
// works, but since IE9 doesn't support strict mode (and we don't use strict mode) we // works, but since IE9 doesn't support strict mode (and we don't use strict mode) we
// have to instead list all the ES5 features we do use. // have to instead list all the ES5 features we do use.
@ -375,10 +375,21 @@
!mw.config.get( 'wgIsRedirect', !!uri.query.redirect ) && !mw.config.get( 'wgIsRedirect', !!uri.query.redirect ) &&
// User has 'visualeditor-enable' preference enabled (for alpha opt-in) // User has 'visualeditor-enable' preference enabled (for alpha opt-in)
mw.user.options.get( 'visualeditor-enable' ) &&
// User has 'visualeditor-betatempdisable' preference disabled // User has 'visualeditor-betatempdisable' preference disabled
!mw.user.options.get( 'visualeditor-betatempdisable' ) && // Because user.options is embedded in the HTML and cached per-page for anons on wikis
// with static caching (e.g. wgUseFileCache or reverse-proxy) ignore user.options for
// anons as it is likely outdated.
(
mw.user.isAnon() ?
( conf.defaultUserOptions.enable && !conf.defaultUserOptions.betatempdisable ) :
(
mw.user.options.get( 'visualeditor-enable', conf.defaultUserOptions.enable ) &&
!mw.user.options.get(
'visualeditor-betatempdisable',
conf.defaultUserOptions.betatempdisable
)
)
) &&
// Only in supported skins // Only in supported skins
$.inArray( mw.config.get( 'skin' ), conf.skins ) !== -1 && $.inArray( mw.config.get( 'skin' ), conf.skins ) !== -1 &&