mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-27 17:50:44 +00:00
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:
parent
6f35dcc39c
commit
84926bbd33
|
@ -154,12 +154,7 @@ class WikiEditorHooks {
|
|||
public static function EditPageBeforeEditToolbar( &$toolbar ) {
|
||||
global $wgUser;
|
||||
if ( $wgUser->getOption( 'usebetatoolbar' ) ) {
|
||||
$toolbar = Html::rawElement(
|
||||
'div', [
|
||||
'class' => 'wikiEditor-oldToolbar'
|
||||
],
|
||||
$toolbar
|
||||
);
|
||||
$toolbar = '';
|
||||
// Return false to signify that the toolbar has been over-written, so
|
||||
// the old toolbar code shouldn't be added to the page.
|
||||
return false;
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
* JavaScript for WikiEditor Dialogs
|
||||
*/
|
||||
jQuery( function ( $ ) {
|
||||
if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace icons
|
||||
$.wikiEditor.modules.dialogs.config.replaceIcons( $( '#wpTextbox1' ) );
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
* JavaScript for WikiEditor Toolbar
|
||||
*/
|
||||
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
|
||||
$( '#toolbar' ).remove();
|
||||
// Add toolbar module
|
||||
|
|
|
@ -22,9 +22,7 @@ form#editform {
|
|||
resize: vertical;
|
||||
}
|
||||
|
||||
/* Hide the old toolbar until the wikiEditor toolbar is deemed not supported,
|
||||
* hide the WikiEditor toolbar until it's css has loaded */
|
||||
.wikiEditor-oldToolbar,
|
||||
/* Hide the WikiEditor toolbar until its css has loaded */
|
||||
.wikiEditor-ui-toolbar {
|
||||
display: none;
|
||||
}
|
||||
|
@ -38,7 +36,7 @@ form#editform {
|
|||
/* 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,
|
||||
* 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 */
|
||||
margin-top: 33px;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
// Defer building of modules, unless they require immediate creation
|
||||
for ( mod in config ) {
|
||||
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;
|
||||
if ( typeof module.filters !== 'undefined' ) {
|
||||
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
|
||||
$existingDialog = $( '#' + module.id );
|
||||
if ( !filtered && $.wikiEditor.isSupported( module ) && $existingDialog.length === 0 ) {
|
||||
if ( !filtered && $existingDialog.length === 0 ) {
|
||||
$.wikiEditor.modules.dialogs.modules[ mod ] = module;
|
||||
context.$textarea.trigger( 'wikiEditor-dialogs-setup-' + mod );
|
||||
// If this dialog requires immediate creation, create it now
|
||||
|
|
|
@ -54,68 +54,12 @@
|
|||
*/
|
||||
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
|
||||
* core - or anywhere for that matter...
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
@ -250,11 +194,6 @@
|
|||
var context, profile, hasFocus, cursorPos,
|
||||
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.
|
||||
profile = $.client.profile();
|
||||
|
||||
|
@ -307,10 +246,8 @@
|
|||
modules = data;
|
||||
}
|
||||
for ( module in modules ) {
|
||||
// Check for the existence of an available / supported module with a matching name and a create function
|
||||
if ( typeof module === 'string' && typeof $.wikiEditor.modules[ module ] !== 'undefined' &&
|
||||
$.wikiEditor.isSupported( $.wikiEditor.modules[ module ] )
|
||||
) {
|
||||
// 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' ) {
|
||||
// Extend the context's core API with this module's own API calls
|
||||
if ( 'api' in $.wikiEditor.modules[ module ] ) {
|
||||
for ( call in $.wikiEditor.modules[ module ].api ) {
|
||||
|
@ -568,8 +505,7 @@
|
|||
modules[ args[ 1 ] ] = '';
|
||||
}
|
||||
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 && $.wikiEditor.isSupported( $.wikiEditor.modules[ module ] ) ) {
|
||||
if ( module in $.wikiEditor.modules ) {
|
||||
// Activate all required core extensions on context
|
||||
for ( e in $.wikiEditor.extensions ) {
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue