TheDJ has uploaded a new change for review.
https://gerrit.wikimedia.org/r/118998
Change subject: Fix JSHint for CodeEditor
......................................................................
Fix JSHint for CodeEditor
Change-Id: Iaf5c1fde6e002ea31eeef88f1963090e14784a7a
---
R .jshintrc
M modules/ext.codeEditor.geshi.js
M modules/jquery.codeEditor.js
3 files changed, 36 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeEditor
refs/changes/98/118998/1
diff --git a/.jshint b/.jshintrc
similarity index 74%
rename from .jshint
rename to .jshintrc
index dae6c7d..ea82e8f 100644
--- a/.jshint
+++ b/.jshintrc
@@ -14,5 +14,12 @@
"quotmark": "single",
"trailing": true,
"undef": true,
-"unused": true
+"unused": true,
+
+"jquery": true,
+"browser": true,
+
+"predef": [
+ "mediaWiki"
+]
}
diff --git a/modules/ext.codeEditor.geshi.js b/modules/ext.codeEditor.geshi.js
index 876c989..72d81c8 100644
--- a/modules/ext.codeEditor.geshi.js
+++ b/modules/ext.codeEditor.geshi.js
@@ -3,6 +3,8 @@
* Has to be manually enabled.
* Needs some code de-dup with the full-page JS/CSS page editing.
*/
+/*global require, ace */
+(function ( $, mw ) {
$( function () {
var $sources, setupEditor, openEditor;
@@ -79,8 +81,8 @@
$label = $( '<label>' ).text( 'Source language:
' );
$langDropDown = $( '<select>' );
- $.each( map, function ( geshiLang, aceLang ) {
- var $opt = $( '<option>' )
+ $.each( map, function ( geshiLang ) {
+ $( '<option>' )
.text( geshiLang )
.val( geshiLang )
.appendTo( $langDropDown );
@@ -88,26 +90,26 @@
$langDropDown
.val( geshiLang )
.appendTo( $label )
- .change( function ( event ) {
+ .change( function ( ) {
setLanguage( $( this ).val() );
} );
$save = $( '<button>' )
.text( mediaWiki.msg( 'savearticle' ) )
- .click( function ( event ) {
+ .click( function ( ) {
// horrible hack ;)
var src, tag;
src =
codeEditor.getSession().getValue();
tag = '<source lang="' +
geshiLang + '">' + src + '</source>';
- $.ajax( wgScriptPath + '/api' +
wgScriptExtension, {
+ $.ajax( mw.config.get(
'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ), {
data: {
action: 'parse',
text: tag,
format: 'json'
},
type: 'POST',
- success: function (
data, xhr ) {
+ success: function (
data ) {
var $html = $(
data.parse.text['*'] );
$div.replaceWith( $html );
setupEditor(
$html );
@@ -141,7 +143,7 @@
setLanguage = function ( lang ) {
geshiLang = lang;
var aceLang = map[geshiLang],
- AceLangMode = require(
"ace/mode/" + aceLang ).Mode;
+ AceLangMode = require(
'ace/mode/' + aceLang ).Mode;
codeEditor.getSession().setMode( new
AceLangMode() );
};
setLanguage( geshiLang );
@@ -158,4 +160,6 @@
setupEditor( $div );
} );
}
-} );
+});
+})( jQuery, mediaWiki );
+
diff --git a/modules/jquery.codeEditor.js b/modules/jquery.codeEditor.js
index df64d43..f87acd7 100644
--- a/modules/jquery.codeEditor.js
+++ b/modules/jquery.codeEditor.js
@@ -1,6 +1,6 @@
/* Ace syntax-highlighting code editor extension for wikiEditor */
-
-(function ( $ ) {
+/*global require, ace */
+(function ( $, mw ) {
$.wikiEditor.modules.codeEditor = {
/**
* Core Requirements
@@ -47,19 +47,19 @@
* function is to both classify the scope of changes as
'division' or 'character' and to prevent further
* processing of events which did not actually change
the content of the iframe.
*/
- 'keydown': function ( event ) {
+ 'keydown': function ( ) {
},
- 'change': function ( event ) {
+ 'change': function ( ) {
},
- 'delayedChange': function ( event ) {
+ 'delayedChange': function ( ) {
},
- 'cut': function ( event ) {
+ 'cut': function ( ) {
},
- 'paste': function ( event ) {
+ 'paste': function ( ) {
},
- 'ready': function ( event ) {
+ 'ready': function ( ) {
},
- 'codeEditorSubmit': function ( event ) {
+ 'codeEditorSubmit': function ( ) {
context.$textarea.val(
context.$textarea.textSelection( 'getContents' ) );
}
} );
@@ -134,8 +134,8 @@
var box, lang, container, editdiv, session,
resize, summary, AceLangMode;
box = context.$textarea;
- lang = mw.config.get(
"wgCodeEditorCurrentLanguage" );
- ace.config.set( "basePath", mw.config.get(
"wgExtensionAssetsPath" ) + '/CodeEditor/modules/ace' );
+ lang = mw.config.get(
'wgCodeEditorCurrentLanguage' );
+ ace.config.set( 'basePath', mw.config.get(
'wgExtensionAssetsPath' ) + '/CodeEditor/modules/ace' );
if ( lang ) {
// Ace doesn't like replacing a
textarea directly.
@@ -184,7 +184,7 @@
// updated right away to actually use
the new style.
$( mw ).bind( 'LivePreviewPrepare',
context.evt.codeEditorSubmit );
- AceLangMode = require( "ace/mode/" +
lang ).Mode;
+ AceLangMode = require( 'ace/mode/' +
lang ).Mode;
session.setMode( new AceLangMode() );
// Force the box to resize horizontally
to match in future :D
@@ -374,7 +374,7 @@
* Gets the position (in resolution of bytes not
nessecarily characters) in a textarea
* DO NOT CALL THIS DIRECTLY, use $.textSelection(
'functionname', options ) instead
*/
- 'getCaretPosition': function ( options ) {
+ 'getCaretPosition': function ( ) {
mw.log( 'codeEditor stub function
getCaretPosition called' );
},
/**
@@ -423,7 +423,7 @@
* Scroll a textarea to the current cursor position.
You can set the cursor position with setSelection()
* DO NOT CALL THIS DIRECTLY, use $.textSelection(
'functionname', options ) instead
*/
- 'scrollToCaretPosition': function ( options ) {
+ 'scrollToCaretPosition': function ( ) {
mw.log( 'codeEditor stub function
scrollToCaretPosition called' );
return context.$textarea;
},
@@ -434,7 +434,7 @@
* @param $element jQuery object containing an element
in the iframe
* @param force If true, scroll the element even if
it's already visible
*/
- 'scrollToTop': function ( $element, force ) {
+ 'scrollToTop': function () {
mw.log( 'codeEditor stub function scrollToTop
called' );
}
} );
@@ -446,4 +446,4 @@
}
};
-})( jQuery );
+})( jQuery, mediaWiki );
--
To view, visit https://gerrit.wikimedia.org/r/118998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf5c1fde6e002ea31eeef88f1963090e14784a7a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeEditor
Gerrit-Branch: master
Gerrit-Owner: TheDJ <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits