Skip to content

Commit 3f5e4bf

Browse files
mbergenFO-nTTaX
andauthored
feat: Support alt-click for widget invokes (#19)
* feat: Support alt-click for widget invokes * add semicolon * Remove a bunch of unneeded code This stuff was for browsers so old they aren't supported anymore anyways --------- Co-authored-by: Alex Winkler <FO-nTTaX@users.noreply.github.com>
1 parent df4733c commit 3f5e4bf

1 file changed

Lines changed: 4 additions & 37 deletions

File tree

resources/scripts/codemirror.js

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
1-
if ( !String.prototype.startsWith ) {
2-
String.prototype.startsWith = function( searchString, position ) {
3-
position = position || 0;
4-
return this.slice( position, position + searchString.length ) === searchString;
5-
};
6-
}
7-
8-
if ( !String.prototype.endsWith ) {
9-
String.prototype.endsWith = function( searchString, position ) {
10-
const subjectString = this.toString();
11-
if ( typeof position !== 'number' || !isFinite( position ) || Math.floor( position ) !== position || position > subjectString.length ) {
12-
position = subjectString.length;
13-
}
14-
position -= searchString.length;
15-
const lastIndex = subjectString.indexOf( searchString, position );
16-
return lastIndex !== -1 && lastIndex === position;
17-
};
18-
}
19-
20-
if ( !String.prototype.includes ) {
21-
String.prototype.includes = function( search, start ) {
22-
'use strict';
23-
if ( typeof start !== 'number' ) {
24-
start = 0;
25-
}
26-
if ( start + search.length > this.length ) {
27-
return false;
28-
} else {
29-
return this.indexOf( search, start ) !== -1;
30-
}
31-
};
32-
}
33-
341
/*
352
* Adapted from https://www.mediawiki.org/wiki/Extension:CodeMirror
363
* License: GPL 2.0 or later
@@ -328,10 +295,6 @@ if ( !String.prototype.includes ) {
328295
lineWrapping: linewrapping,
329296
styleActiveLine: true
330297
} );
331-
// Our best friend, IE, needs some special css
332-
if ( window.navigator.userAgent.indexOf( 'Trident/' ) > -1 ) {
333-
$( '.CodeMirror' ).addClass( 'CodeMirrorIE' );
334-
}
335298
if ( linewrapping ) {
336299
$( '.CodeMirror' ).addClass( 'lineWrapping' );
337300
}
@@ -380,6 +343,10 @@ if ( !String.prototype.includes ) {
380343

381344
if ( pagename.startsWith( 'module=' ) ) {
382345
pagename = pagename.slice( 7 );
346+
} else if ( pagename.startsWith( 'widget=' ) ) {
347+
// Support invokes of style
348+
// {{#invoke:Lua|invoke|module=Widget/Factory|fn=fromTemplate|widget=pagename}}
349+
pagename = pagename.replace( 'widget=', 'Widget/' );
383350
} else if ( !parserfunction.hasClass( 'cm-mw-parserfunction-name' ) ||
384351
parserfunction.text() !== '#invoke' ) {
385352
return;

0 commit comments

Comments
 (0)