Index: WikiEditor.php =================================================================== --- WikiEditor.php (revision 113202) +++ WikiEditor.php (working copy) @@ -66,7 +66,6 @@ $wgHooks['GetPreferences'][] = 'WikiEditorHooks::getPreferences'; $wgHooks['ResourceLoaderGetConfigVars'][] = 'WikiEditorHooks::resourceLoaderGetConfigVars'; $wgHooks['MakeGlobalVariablesScript'][] = 'WikiEditorHooks::makeGlobalVariablesScript'; -$wgHooks['EditPageBeforeEditToolbar'][] = 'WikiEditorHooks::EditPageBeforeEditToolbar'; $wikiEditorTpl = array( 'localBasePath' => dirname( __FILE__ ) . '/modules', @@ -400,10 +399,21 @@ /* WikiEditor Resources */ + 'ext.wikiEditor.init' => $wikiEditorTpl + array( + 'scripts' => 'ext.wikiEditor.init.js', + 'styles' => 'ext.wikiEditor.init.css', + 'dependencies' => array( + 'jquery.client', + ), + 'position' => 'top', + ), 'ext.wikiEditor' => $wikiEditorTpl + array( 'scripts' => 'ext.wikiEditor.js', 'styles' => 'ext.wikiEditor.css', - 'dependencies' => 'jquery.wikiEditor', + 'dependencies' => array( + 'ext.wikiEditor.init', + 'jquery.wikiEditor', + ) ), 'ext.wikiEditor.dialogs' => $wikiEditorTpl + array( 'scripts' => 'ext.wikiEditor.dialogs.js', Index: WikiEditor.hooks.php =================================================================== --- WikiEditor.hooks.php (revision 113202) +++ WikiEditor.hooks.php (working copy) @@ -217,21 +217,6 @@ } /** - * EditPageBeforeEditToolbar hook - * - * Disable the old toolbar if the new one is enabled - * - * @param $toolbar html - * @return bool - */ - public static function EditPageBeforeEditToolbar( &$toolbar ) { - if ( self::isEnabled( 'toolbar' ) ) { - $toolbar = ''; - } - return true; - } - - /** * GetPreferences hook * * Adds WikiEditor-releated items to the preferences Index: modules/ext.wikiEditor.init.js =================================================================== --- modules/ext.wikiEditor.init.js (revision 0) +++ modules/ext.wikiEditor.init.js (revision 0) @@ -0,0 +1,36 @@ +if ( $.client.test( { + // Left-to-right languages + 'ltr': { + // The toolbar layout is broken in IE6 + 'msie': [['>=', 7]], + // Layout issues in FF < 2 + 'firefox': [['>=', 2]], + // Text selection bugs galore - this may be a different situation with the new iframe-based solution + 'opera': [['>=', 9.6]], + // jQuery minimums + 'safari': [['>=', 3]], + 'chrome': [['>=', 3]], + 'netscape': [['>=', 9]], + 'blackberry': false, + 'ipod': false, + 'iphone': false + }, + // Right-to-left languages + 'rtl': { + // The toolbar layout is broken in IE 7 in RTL mode, and IE6 in any mode + 'msie': [['>=', 8]], + // Layout issues in FF < 2 + 'firefox': [['>=', 2]], + // Text selection bugs galore - this may be a different situation with the new iframe-based solution + 'opera': [['>=', 9.6]], + // jQuery minimums + 'safari': [['>=', 3]], + 'chrome': [['>=', 3]], + 'netscape': [['>=', 9]], + 'blackberry': false, + 'ipod': false, + 'iphone': false + } +} ) ) { + $( 'body' ).addClass( 'wikiEditor-enabled' ); +} Index: modules/ext.wikiEditor.init.css =================================================================== --- modules/ext.wikiEditor.init.css (revision 0) +++ modules/ext.wikiEditor.init.css (revision 0) @@ -0,0 +1,3 @@ +body.wikiEditor-enabled #toolbar { + display: none; +} Index: modules/jquery.wikiEditor.js =================================================================== --- modules/jquery.wikiEditor.js (revision 113202) +++ modules/jquery.wikiEditor.js (working copy) @@ -32,45 +32,9 @@ */ 'instances': [], /** - * For each browser name, an array of conditions that must be met are supplied in [operaton, value]-form where - * operation is a string containing a JavaScript compatible binary operator and value is either a number to be - * compared with $.browser.versionNumber or a string to be compared with $.browser.version. If a browser is not - * specifically mentioned, we just assume things will work. + * Cached result from wikiEditor.init's compatibility check. */ - 'browsers': { - // Left-to-right languages - 'ltr': { - // The toolbar layout is broken in IE6 - 'msie': [['>=', 7]], - // Layout issues in FF < 2 - 'firefox': [['>=', 2]], - // Text selection bugs galore - this may be a different situation with the new iframe-based solution - 'opera': [['>=', 9.6]], - // jQuery minimums - 'safari': [['>=', 3]], - 'chrome': [['>=', 3]], - 'netscape': [['>=', 9]], - 'blackberry': false, - 'ipod': false, - 'iphone': false - }, - // Right-to-left languages - 'rtl': { - // The toolbar layout is broken in IE 7 in RTL mode, and IE6 in any mode - 'msie': [['>=', 8]], - // Layout issues in FF < 2 - 'firefox': [['>=', 2]], - // Text selection bugs galore - this may be a different situation with the new iframe-based solution - 'opera': [['>=', 9.6]], - // jQuery minimums - 'safari': [['>=', 3]], - 'chrome': [['>=', 3]], - 'netscape': [['>=', 9]], - 'blackberry': false, - 'ipod': false, - 'iphone': false - } - }, + 'supported': $( 'body' ).hasClass( 'wikiEditor-enabled' ), /** * Path to images - this is a bit messy, and it would need to change if this code (and images) gets moved into the * core - or anywhere for that matter... @@ -89,15 +53,19 @@ * @param module Module object, defaults to $.wikiEditor */ 'isSupported': function( module ) { - // Fallback to the wikiEditor browser map if no special map is provided in the module - var mod = module && 'browsers' in module ? module : $.wikiEditor; - // Check for and make use of cached value and early opportunities to bail - if ( typeof mod.supported !== 'undefined' ) { - // Cache hit - return mod.supported; + if ( $.wikiEditor.supported ) { + if ( module !== undefined ) { + // Check for and make use of cached value and early opportunities to bail + if ( module.supported !== undefined ) { + // Cache hit + return module.supported; + } + // Run a browser support test and then cache and return the result + return module.supported = module.browsers ? $.client.test( module.browsers ) : true; + } + return true; } - // Run a browser support test and then cache and return the result - return mod.supported = $.client.test( mod.browsers ); + return false; }, /** * Checks if a module has a specific requirement @@ -105,9 +73,9 @@ * @param requirement String identifying requirement */ 'isRequired': function( module, requirement ) { - if ( typeof module['req'] !== 'undefined' ) { - for ( var req in module['req'] ) { - if ( module['req'][req] == requirement ) { + if ( typeof module.req !== 'undefined' ) { + for ( var req in module.req ) { + if ( module.req[req] == requirement ) { return true; } }