jenkins-bot has submitted this change and it was merged. Change subject: Add npm entry point ......................................................................
Add npm entry point
Also cross out an image in the css file that does not exist.
Change-Id: I840f76c2dcfc6354a6a7499c527bfe44770b1f34
---
M .gitignore
A .jshintignore
A .jshintrc
A Gruntfile.js
M modules/ext.LightweightRDFa.button.css
M modules/ext.LightweightRDFa.button.js
A package.json
7 files changed, 124 insertions(+), 48 deletions(-)
Approvals:
Hashar: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.gitignore b/.gitignore
index 98b092a..1689d7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-.svn
*~
*.kate-swp
.*.swp
+node_modules/**
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..5237a16
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,25 @@
+{
+ // Enforcing
+ "bitwise": true,
+ "eqeqeq": true,
+ "freeze": true,
+ "latedef": "nofunc",
+ "noarg": true,
+ "nonew": true,
+ "undef": false,
+ "unused": false,
+ "strict": false,
+
+ // Relaxing
+ "es5": false,
+
+ // Environment
+ "browser": true,
+ "jquery": true,
+
+ "globals": {
+ "mediaWiki": false,
+ "alert": true,
+ "console": true
+ }
+}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..36b6671
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,30 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-jsonlint' );
+ grunt.loadNpmTasks( 'grunt-banana-checker' );
+
+ grunt.initConfig( {
+ jshint: {
+ options: {
+ jshintrc: true
+ },
+ all: [
+ '**/*.js',
+ '!node_modules/**'
+ ]
+ },
+ banana: {
+ all: 'i18n/'
+ },
+ jsonlint: {
+ all: [
+ '**/*.json',
+ '!node_modules/**'
+ ]
+ }
+ } );
+
+ grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
+ grunt.registerTask( 'default', 'test' );
+};
diff --git a/modules/ext.LightweightRDFa.button.css
b/modules/ext.LightweightRDFa.button.css
index 7e951a8..f5e385b 100644
--- a/modules/ext.LightweightRDFa.button.css
+++ b/modules/ext.LightweightRDFa.button.css
@@ -24,7 +24,7 @@
}
#wikieditor-toolbar-rdfa-int-target-status-exists {
/* @embed */
- background-image: url(images/insert-rdfa-exists.png);
+ /* background-image: url(images/insert-rdfa-exists.png); */
background-position: left;
}
#wikieditor-toolbar-rdfa-int-target-status-notexists {
diff --git a/modules/ext.LightweightRDFa.button.js
b/modules/ext.LightweightRDFa.button.js
index 1a605ca..dd47d78 100644
--- a/modules/ext.LightweightRDFa.button.js
+++ b/modules/ext.LightweightRDFa.button.js
@@ -1,3 +1,6 @@
+/*jshint -W043 */
+/*jshint -W059 */
+/*jshint -W117 */
/* RDFa link construct configuration */
// TODO Create string hardcoded in regex
@@ -6,13 +9,7 @@
var configRDFaCreateRegex = '::';
var configRDFaEscapeRegex = '\^\^';
-/* Check if we are in edit mode and the required modules are available and
then customize the toolbar */
-if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
- mw.loader.using( 'ext.wikiEditor.toolbar', function () {
- $(document).ready( addRDFaButton );
- });
-}
-
+( function ( $, mw ) {
/* Code copied from WikiEditor Extension and edited */
var addRDFaButton = function() {
@@ -36,7 +33,7 @@
}
})
.wikiEditor( 'addModule', getRDFaWikiEditorDialogConfig() );
-}
+};
getRDFaWikiEditorDialogConfig = function () {
return { 'dialogs': {
@@ -76,7 +73,7 @@
// * Starts with www.
// All of these are potentially valid
titles, and the latter two categories match about 6300
// titles in enwiki's ns0. Out of 6.9M
titles, that's 0.09%
- if ( typeof arguments.callee.regex ==
'undefined' ) {
+ if ( typeof arguments.callee.regex ===
'undefined' ) {
// Cache the regex
arguments.callee.regex =
new RegExp( "^(" +
mw.config.get( 'wgUrlProtocols' ) + "|www\\.)", 'i');
@@ -95,7 +92,7 @@
$(
'#wikieditor-toolbar-rdfa-int-target-status-' + status ).show();
$(
'#wikieditor-toolbar-rdfa-int-target' ).parent().addClass( 'status-' + status );
}
- if ( status == 'invalid' ) {
+ if ( status === 'invalid' ) {
$( '.ui-dialog:visible
.ui-dialog-buttonpane button:first' )
.attr( 'disabled', true
)
.addClass( 'disabled' );
@@ -109,7 +106,7 @@
// accepts parameter internal for bypassing
external link detection
function updateExistence( internal ) {
// ensure the internal parameter is a
boolean
- if ( internal != true ) internal =
false;
+ if ( internal !== true ) internal =
false;
// Abort previous request
var request = $(
'#wikieditor-toolbar-rdfa-int-target-status' ).data( 'request' );
if ( request ) {
@@ -121,7 +118,7 @@
updateWidget( cache[target] );
return;
}
- if ( target.replace( /^\s+$/,'' ) == ''
) {
+ if ( target.replace( /^\s+$/,'' ) ===
'' ) {
// Hide the widget when the
textbox is empty
updateWidget( false );
return;
@@ -131,7 +128,7 @@
updateWidget( 'external' );
return;
}
- if ( target.indexOf( '|' ) != -1 ) {
+ if ( target.indexOf( '|' ) !== -1 ) {
// Title contains | , which
means it's invalid
// but confuses the API. Show
invalid and bypass API
updateWidget( 'invalid' );
@@ -155,20 +152,23 @@
},
success: function( data
) {
var status;
- if ( !data ||
typeof data.query == 'undefined' ) {
+ if ( !data ||
typeof data.query === 'undefined' ) {
// This
happens in some weird cases
status
= false;
} else {
var
page = data.query.pages[data.query.pageids[0]];
status
= 'exists';
- if (
typeof page.missing != 'undefined' )
+ if (
typeof page.missing !== 'undefined' ) {
status = 'notexists';
- else if
( typeof page.invalid != 'undefined' )
+ } else
if ( typeof page.invalid !== 'undefined' ) {
status = 'invalid';
+ }
}
// Cache the
status of the link target if the force internal parameter was not
// passed
- if ( !internal
) cache[target] = status;
+ if ( !internal
) {
+
cache[target] = status;
+ }
updateWidget(
status );
}
} )
@@ -203,14 +203,14 @@
$( '#wikieditor-toolbar-rdfa-int-target,
#wikieditor-toolbar-rdfa-int-text, #wikieditor-toolbar-rdfa-int-annotation' )
.each( function() {
var tooltip = mediaWiki.msg( $(
this ).attr( 'id' ) + '-tooltip' );
- if ( $( this ).val() == '' )
+ if ( $( this ).val() === '' )
$( this )
.addClass(
'wikieditor-toolbar-dialog-hint' )
.val( $( this
).data( 'tooltip' ) )
.data(
'tooltip-mode', true );
} )
.focus( function() {
- if( $( this ).val() == $( this
).data( 'tooltip' ) ) {
+ if( $( this ).val() === $( this
).data( 'tooltip' ) ) {
$( this )
.val( '' )
.removeClass(
'wikieditor-toolbar-dialog-hint' )
@@ -218,14 +218,14 @@
}
})
.bind( 'change', function() {
- if ( $( this ).val() != $( this
).data( 'tooltip' ) ) {
+ if ( $( this ).val() !== $(
this ).data( 'tooltip' ) ) {
$( this )
.removeClass(
'wikieditor-toolbar-dialog-hint' )
.data(
'tooltip-mode', false );
}
})
.bind( 'blur', function() {
- if ( $( this ).val() == '' ) {
+ if ( $( this ).val() === '' ) {
$( this )
.addClass(
'wikieditor-toolbar-dialog-hint' )
.val( $( this
).data( 'tooltip' ) )
@@ -248,7 +248,7 @@
updateExistence();
}
if ( $(
'#wikieditor-toolbar-rdfa-int-text' ).data( 'untouched' ) )
- if ( $(
'#wikieditor-toolbar-rdfa-int-target' ).val() ==
+ if ( $(
'#wikieditor-toolbar-rdfa-int-target' ).val() ===
$(
'#wikieditor-toolbar-rdfa-int-target' ).data( 'tooltip' ) ) {
$(
'#wikieditor-toolbar-rdfa-int-text' )
.addClass( 'wikieditor-toolbar-dialog-hint' )
@@ -265,7 +265,7 @@
var oldVal = $(this).val();
var that = this;
setTimeout( function() {
- if ( $(that).val() != oldVal )
+ if ( $(that).val() !== oldVal )
$(that).data(
'untouched', false );
}, 0 );
});
@@ -307,7 +307,7 @@
$( '#wikieditor-toolbar-rdfa-int-target' )
.bind( 'keyup paste cut', function() {
// Cancel the running timer if
applicable
- if ( typeof $(this).data(
'timerID' ) != 'undefined' ) {
+ if ( typeof $(this).data(
'timerID' ) !== 'undefined' ) {
clearTimeout(
$(this).data( 'timerID' ) );
}
// Delay fetch for a while
@@ -317,7 +317,7 @@
} )
.change( function() {
// Cancel the running timer if
applicable
- if ( typeof $(this).data(
'timerID' ) != 'undefined' ) {
+ if ( typeof $(this).data(
'timerID' ) !== 'undefined' ) {
clearTimeout(
$(this).data( 'timerID' ) );
}
// Fetch right now
@@ -330,13 +330,13 @@
var that = this;
var title = $(this).val();
- if ( isExternalLink( title ) ||
title.indexOf( '|' ) != -1 || title == '') {
+ if ( isExternalLink( title ) ||
title.indexOf( '|' ) !== -1 || title === '') {
$(this).suggestions(
'suggestions', [] );
return;
}
var cache = $(this).data(
'suggcache' );
- if ( typeof cache[title] !=
'undefined' ) {
+ if ( typeof cache[title] !==
'undefined' ) {
$(this).suggestions(
'suggestions', cache[title] );
return;
}
@@ -384,14 +384,14 @@
return s.replace(
/(]+)/g, '<nowiki>$1</nowiki>' );
}
function
writeAnnotatedTarget(nnt, trg) {
- if ($.trim( nnt ) ==
'') {
- if
(trg.indexOf(configRDFaCreate) == -1)
+ if ($.trim( nnt ) ===
'') {
+ if
(trg.indexOf(configRDFaCreate) === -1)
return
trg;
else
return
configRDFaEscape + trg;
} else {
// TODO This
should never occur. Remove or check anyway
- // if
(trg.indexOf(configRDFaCreate) == -1)
+ // if
(trg.indexOf(configRDFaCreate) === -1)
//
return trg;
return nnt +
configRDFaCreate + trg;
}
@@ -408,11 +408,11 @@
text = "";
if ( $(
'#wikieditor-toolbar-rdfa-int-annotation' ).data( 'tooltip-mode' ) )
annotation = "";
- if ( target == '' ) {
+ if ( target === '' ) {
alert( mediaWiki.msg(
'wikieditor-toolbar-tool-rdfa-empty' ) );
return;
}
- if ( $.trim( text ) == '' ) {
+ if ( $.trim( text ) === '' ) {
// [[Foo| ]] creates an
invisible link
// Instead, generate
[[Foo|]]
text = '';
@@ -427,7 +427,7 @@
return;
}
- if ( target == text ||
!text.length )
+ if ( target === text ||
!text.length )
insertText =
'[[' + annotatedTarget + ']]';
else
insertText =
'[[' + annotatedTarget + '|' + escapeInternalText( text ) + ']]';
@@ -464,9 +464,9 @@
var escText =
escapeExternalText( text );
var escAnnotatedTarget
= writeAnnotatedTarget( annotation , escTarget );
- if ( escTarget ==
escText )
+ if ( escTarget ===
escText )
insertText =
escAnnotatedTarget;
- else if ( text == '' )
+ else if ( text === '' )
insertText =
'[' + escAnnotatedTarget + ']';
else
insertText =
'[' + escAnnotatedTarget + ' ' + escText + ']';
@@ -511,7 +511,7 @@
// Trigger the change event, so the
link status indicator is up to date
$(
'#wikieditor-toolbar-rdfa-int-target' ).change();
$( '#wikieditor-toolbar-rdfa-dialog'
).data( 'whitespace', [ '', '' ] );
- if ( selection != '' ) {
+ if ( selection !== '' ) {
var target, text, annotation,
type;
var matches;
if ( ( matches =
selection.match( /^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/ ) ) ) {
@@ -549,44 +549,44 @@
console.log(examine,
examine[0], examine[1], examine[2]);
var newTarget = '';
if ( examine[1] ) {
- if (
target.indexOf( configRDFaEscape ) == 0 ) {
+ if (
target.indexOf( configRDFaEscape ) === 0 ) {
newTarget = target.substring( configRDFaEscape.length );
} else {
annotation = examine[1];
newTarget = examine[2];
}
// Update text
is sameAs target
- if ( ( text !==
undefined ) && ( target == text ) )
+ if ( ( text !==
undefined ) && ( target === text ) )
text =
newTarget;
target =
newTarget;
}
}
// Change the value by calling
val() doesn't trigger the change event, so let's do that
// ourselves
- if ( typeof text != 'undefined'
)
+ if ( typeof text !==
'undefined' )
$(
'#wikieditor-toolbar-rdfa-int-text' ).val( text ).change();
- if ( typeof target !=
'undefined' )
+ if ( typeof target !==
'undefined' )
$(
'#wikieditor-toolbar-rdfa-int-target' ).val( target ).change();
- if ( typeof annotation !=
'undefined' )
+ if ( typeof annotation !==
'undefined' )
$(
'#wikieditor-toolbar-rdfa-int-annotation' ).val( annotation ).change();
- if ( typeof type != 'undefined'
)
+ if ( typeof type !==
'undefined' )
$(
'#wikieditor-toolbar-rdfa-' + type ).attr( 'checked', 'checked' );
}
$( '#wikieditor-toolbar-rdfa-int-text'
).data( 'untouched',
- $(
'#wikieditor-toolbar-rdfa-int-text' ).val() ==
+ $(
'#wikieditor-toolbar-rdfa-int-text' ).val() ===
$(
'#wikieditor-toolbar-rdfa-int-target' ).val() ||
$(
'#wikieditor-toolbar-rdfa-int-text' ).hasClass(
'wikieditor-toolbar-dialog-hint' )
);
$(
'#wikieditor-toolbar-rdfa-int-target' ).suggestions();
//don't overwrite user's text
- if( selection != '' ) {
+ if( selection !== '' ) {
$(
'#wikieditor-toolbar-rdfa-int-text' ).data( 'untouched', false );
}
$( '#wikieditor-toolbar-rdfa-int-text,
#wikiedit-toolbar-rdfa-int-target' )
.each( function() {
- if ( $(this).val() ==
'' )
+ if ( $(this).val() ===
'' )
$(this).parent().find( 'label' ).show();
});
@@ -595,7 +595,7 @@
// Execute the action
associated with the first button
// when the user presses Enter
$(this).closest( '.ui-dialog'
).keypress( function( e ) {
- if ( ( e.keyCode ||
e.which ) == 13 ) {
+ if ( ( e.keyCode ||
e.which ) === 13 ) {
var button =
$(this).data( 'dialogaction' ) || $(this).find( 'button:first' );
button.click();
e.preventDefault();
@@ -612,5 +612,13 @@
}
},
} };
+};
+
+/* Check if we are in edit mode and the required modules are available and
then customize the toolbar */
+if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
+ mw.loader.using( 'ext.wikiEditor.toolbar', function () {
+ $(document).ready( addRDFaButton );
+ });
}
+}( jQuery, mediaWiki ) );
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..0ee955e
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "0.4.5",
+ "grunt-cli": "0.1.13",
+ "grunt-banana-checker": "0.5.0",
+ "grunt-contrib-jshint": "1.0.0",
+ "grunt-jsonlint": "1.0.7"
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/281579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I840f76c2dcfc6354a6a7499c527bfe44770b1f34
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/LightweightRDFa
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
