Remove browser compatibility checks

WikiEditor works in all browsers that MW supports,
and should do going forward.

Change-Id: I189516917d805dff3819e742a9fd8ad96a161159
This commit is contained in:
Ed Sanders 2017-12-29 14:09:21 +00:00 committed by Catrope
parent 6f35dcc39c
commit 84926bbd33
6 changed files with 8 additions and 87 deletions

View file

@ -154,12 +154,7 @@ class WikiEditorHooks {
public static function EditPageBeforeEditToolbar( &$toolbar ) { public static function EditPageBeforeEditToolbar( &$toolbar ) {
global $wgUser; global $wgUser;
if ( $wgUser->getOption( 'usebetatoolbar' ) ) { if ( $wgUser->getOption( 'usebetatoolbar' ) ) {
$toolbar = Html::rawElement( $toolbar = '';
'div', [
'class' => 'wikiEditor-oldToolbar'
],
$toolbar
);
// Return false to signify that the toolbar has been over-written, so // Return false to signify that the toolbar has been over-written, so
// the old toolbar code shouldn't be added to the page. // the old toolbar code shouldn't be added to the page.
return false; return false;

View file

@ -2,10 +2,6 @@
* JavaScript for WikiEditor Dialogs * JavaScript for WikiEditor Dialogs
*/ */
jQuery( function ( $ ) { jQuery( function ( $ ) {
if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) {
return;
}
// Replace icons // Replace icons
$.wikiEditor.modules.dialogs.config.replaceIcons( $( '#wpTextbox1' ) ); $.wikiEditor.modules.dialogs.config.replaceIcons( $( '#wpTextbox1' ) );

View file

@ -2,10 +2,6 @@
* JavaScript for WikiEditor Toolbar * JavaScript for WikiEditor Toolbar
*/ */
jQuery( function ( $ ) { jQuery( function ( $ ) {
if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.toolbar ) ) {
$( '.wikiEditor-oldToolbar' ).show();
return;
}
// The old toolbar is still in place and needs to be removed so there aren't two toolbars // The old toolbar is still in place and needs to be removed so there aren't two toolbars
$( '#toolbar' ).remove(); $( '#toolbar' ).remove();
// Add toolbar module // Add toolbar module

View file

@ -22,9 +22,7 @@ form#editform {
resize: vertical; resize: vertical;
} }
/* Hide the old toolbar until the wikiEditor toolbar is deemed not supported, /* Hide the WikiEditor toolbar until its css has loaded */
* hide the WikiEditor toolbar until it's css has loaded */
.wikiEditor-oldToolbar,
.wikiEditor-ui-toolbar { .wikiEditor-ui-toolbar {
display: none; display: none;
} }
@ -38,7 +36,7 @@ form#editform {
/* Set a margin on the textarea while we load, matching the height, /* Set a margin on the textarea while we load, matching the height,
* of the wikieditor toolbar to prevent reflow. After the wikieditor ui is loaded, * of the wikieditor toolbar to prevent reflow. After the wikieditor ui is loaded,
* the textarea is wrapped inside wikieditor-ui div and no longer matches */ * the textarea is wrapped inside wikieditor-ui div and no longer matches */
.client-js .wikiEditor-oldToolbar + #wpTextbox1 { .client-js .mw-editform > #wpTextbox1 {
/* Toolbar height + padding + bottom border = 26 + 2*3 + 1 */ /* Toolbar height + padding + bottom border = 26 + 2*3 + 1 */
margin-top: 33px; margin-top: 33px;
} }

View file

@ -75,7 +75,7 @@
// Defer building of modules, unless they require immediate creation // Defer building of modules, unless they require immediate creation
for ( mod in config ) { for ( mod in config ) {
module = config[ mod ]; module = config[ mod ];
// Only create the dialog if it's supported, isn't filtered and doesn't exist yet // Only create the dialog if it isn't filtered and doesn't exist yet
filtered = false; filtered = false;
if ( typeof module.filters !== 'undefined' ) { if ( typeof module.filters !== 'undefined' ) {
for ( i = 0; i < module.filters.length; i++ ) { for ( i = 0; i < module.filters.length; i++ ) {
@ -92,7 +92,7 @@
} }
// Re-select from the DOM, we might have removed the dialog just now // Re-select from the DOM, we might have removed the dialog just now
$existingDialog = $( '#' + module.id ); $existingDialog = $( '#' + module.id );
if ( !filtered && $.wikiEditor.isSupported( module ) && $existingDialog.length === 0 ) { if ( !filtered && $existingDialog.length === 0 ) {
$.wikiEditor.modules.dialogs.modules[ mod ] = module; $.wikiEditor.modules.dialogs.modules[ mod ] = module;
context.$textarea.trigger( 'wikiEditor-dialogs-setup-' + mod ); context.$textarea.trigger( 'wikiEditor-dialogs-setup-' + mod );
// If this dialog requires immediate creation, create it now // If this dialog requires immediate creation, create it now

View file

@ -54,68 +54,12 @@
*/ */
instances: [], instances: [],
/**
* For each browser name, an array of conditions that must be met are supplied in [operation, 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.
*/
browsers: {
// Left-to-right languages
ltr: {
msie: [ [ '>=', 9 ] ],
firefox: [ [ '>=', 4 ] ],
opera: [ [ '>=', '10.5' ] ],
safari: [ [ '>=', 5 ] ],
chrome: [ [ '>=', 5 ] ],
netscape: [ [ '>=', 9 ] ],
blackberry: false,
ipod: [ [ '>=', 6 ] ],
iphone: [ [ '>=', 6 ] ]
},
// Right-to-left languages
rtl: {
msie: [ [ '>=', 9 ] ],
firefox: [ [ '>=', 4 ] ],
opera: [ [ '>=', '10.5' ] ],
safari: [ [ '>=', 5 ] ],
chrome: [ [ '>=', 5 ] ],
netscape: [ [ '>=', 9 ] ],
blackberry: false,
ipod: [ [ '>=', 6 ] ],
iphone: [ [ '>=', 6 ] ]
}
},
/** /**
* Path to images - this is a bit messy, and it would need to change if this code (and images) gets moved into the * 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... * core - or anywhere for that matter...
*/ */
imgPath: mw.config.get( 'wgExtensionAssetsPath' ) + '/WikiEditor/modules/images/', imgPath: mw.config.get( 'wgExtensionAssetsPath' ) + '/WikiEditor/modules/images/',
/**
* Checks the current browser against the browsers object to determine if the browser has been black-listed or not.
* Because these rules are often very complex, the object contains configurable operators and can check against
* either the browser version number or string. This process also involves checking if the current browser is among
* those which we have configured as compatible or not. If the browser was not configured as compatible we just go on
* assuming things will work - the argument here is to prevent the need to update the code when a new browser comes
* to market. The assumption here is that any new browser will be built on an existing engine or be otherwise so
* similar to another existing browser that things actually do work as expected. The merits of this argument, which
* is essentially to blacklist rather than whitelist are debatable, but at this point we've decided it's the more
* "open-web" way to go.
*
* @return {boolean}
*/
isSupported: function () {
// Fallback to the wikiEditor browser map if no special map is provided in the module
// Check for and make use of cached value and early opportunities to bail
if ( typeof $.wikiEditor.supported === 'undefined' ) {
// Run a browser support test and then cache and return the result
$.wikiEditor.supported = $.client.test( $.wikiEditor.browsers );
}
return $.wikiEditor.supported;
},
/** /**
* Checks if a module has a specific requirement * Checks if a module has a specific requirement
* *
@ -250,11 +194,6 @@
var context, profile, hasFocus, cursorPos, var context, profile, hasFocus, cursorPos,
args, modules, module, e, call; args, modules, module, e, call;
// Skip any further work when running in browsers that are unsupported
if ( !$.wikiEditor.isSupported() ) {
return $( this );
}
// Save browser profile for detailed tests. // Save browser profile for detailed tests.
profile = $.client.profile(); profile = $.client.profile();
@ -307,10 +246,8 @@
modules = data; modules = data;
} }
for ( module in modules ) { for ( module in modules ) {
// Check for the existence of an available / supported module with a matching name and a create function // Check for the existence of an available module with a matching name and a create function
if ( typeof module === 'string' && typeof $.wikiEditor.modules[ module ] !== 'undefined' && if ( typeof module === 'string' && typeof $.wikiEditor.modules[ module ] !== 'undefined' ) {
$.wikiEditor.isSupported( $.wikiEditor.modules[ module ] )
) {
// Extend the context's core API with this module's own API calls // Extend the context's core API with this module's own API calls
if ( 'api' in $.wikiEditor.modules[ module ] ) { if ( 'api' in $.wikiEditor.modules[ module ] ) {
for ( call in $.wikiEditor.modules[ module ].api ) { for ( call in $.wikiEditor.modules[ module ].api ) {
@ -568,8 +505,7 @@
modules[ args[ 1 ] ] = ''; modules[ args[ 1 ] ] = '';
} }
for ( module in modules ) { for ( module in modules ) {
// Only allow modules which are supported (and thus actually being turned on) affect the decision to extend if ( module in $.wikiEditor.modules ) {
if ( module in $.wikiEditor.modules && $.wikiEditor.isSupported( $.wikiEditor.modules[ module ] ) ) {
// Activate all required core extensions on context // Activate all required core extensions on context
for ( e in $.wikiEditor.extensions ) { for ( e in $.wikiEditor.extensions ) {
if ( if (