TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/158774

Change subject: Pass jshint
......................................................................

Pass jshint

Change-Id: I0278575038308f8cee03096a14253b9987bba727
---
A .jshintrc
M resources/ext.wikiLove.core.js
M resources/ext.wikiLove.defaultOptions.js
M resources/ext.wikiLove.init.js
4 files changed, 47 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiLove 
refs/changes/74/158774/1

diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..eb031c3
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,26 @@
+{
+/* Common */
+
+// Enforcing
+"camelcase": true,
+"curly": true,
+"eqeqeq": true,
+"immed": true,
+"latedef": true,
+"newcap": true,
+"noarg": true,
+"noempty": true,
+"nonew": true,
+"quotmark": "single",
+"trailing": true,
+"undef": true,
+"unused": true,
+"multistr": true,
+
+"jquery": true,
+"browser": true,
+
+"predef": [
+       "mediaWiki"
+]
+}
diff --git a/resources/ext.wikiLove.core.js b/resources/ext.wikiLove.core.js
index 9b45737..e00d972 100644
--- a/resources/ext.wikiLove.core.js
+++ b/resources/ext.wikiLove.core.js
@@ -1,5 +1,5 @@
-/*global window:false */
-( function( $ ) {
+/*global window:false, alert:false */
+( function( $, mw ) {
 
 var    options = {}, // options modifiable by the user
        $dialog = null, // dialog jQuery object
@@ -48,8 +48,8 @@
                                var     $button = $( '<a href="#" 
class=""></a>' );
 
                                if ( typeof type.icon === 'string' ) {
-                                       $button.append( '<img src="'
-                                               + mw.html.escape( type.icon ) + 
'"/>' );
+                                       $button.append( '<img src="' +
+                                               mw.html.escape( type.icon ) + 
'"/>' );
                                } else {
                                        $button.addClass( 'mw-wikilove-no-icon' 
);
                                }
@@ -392,8 +392,8 @@
                // set the new text for the image textbox
                $( '#mw-wikilove-image' ).val( currentRememberData.image || 
currentTypeOrSubtype.image || '' );
 
-               if( typeof currentTypeOrSubtype.gallery === 'object'
-                       && $.isArray( currentTypeOrSubtype.gallery.imageList )
+               if( typeof currentTypeOrSubtype.gallery === 'object' &&
+                       $.isArray( currentTypeOrSubtype.gallery.imageList )
                ) {
                        $( '#mw-wikilove-gallery, #mw-wikilove-gallery-label' 
).show();
                        $.wikiLove.showGallery(); // build gallery from array 
of images
@@ -500,7 +500,7 @@
         */
        submitPreview: function() {
                var text = $.wikiLove.prepareMsg( currentTypeOrSubtype.text || 
options.types[currentTypeId].text || options.defaultText );
-               $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() + 
"==\n" + text );
+               $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() + 
'==\n' + text );
        },
 
        showAddDetailsError: function( errmsg ) {
@@ -547,7 +547,7 @@
         */
        normalizeFilename: function( filename ) {
                // If a URL is given, extract and decode the filename
-               var index = filename.lastIndexOf( "/" ) + 1;
+               var index = filename.lastIndexOf( '/' ) + 1;
                filename = filename.substr( index );
                if ( index > 0 ) {
                        filename = decodeURI( filename );
@@ -639,8 +639,7 @@
                        'header': $( '#mw-wikilove-header' ).val(),
                        'text': $.wikiLove.prepareMsg( 
currentTypeOrSubtype.text || options.types[currentTypeId].text || 
options.defaultText ),
                        'message': $( '#mw-wikilove-message' ).val(),
-                       'type': currentTypeId
-                               + (currentSubtypeId !== null ? '-' + 
currentSubtypeId : '')
+                       'type': currentTypeId + (currentSubtypeId !== null ? 
'-' + currentSubtypeId : '')
                };
                if ( $( '#mw-wikilove-notify-checkbox:checked' ).val() && 
emailable ) {
                        submitData.email = $.wikiLove.prepareMsg( 
currentTypeOrSubtype.email );
@@ -691,7 +690,7 @@
                                                if ( redirect ) {
                                                        var     targetBaseUrl = 
mw.util.getUrl( data.redirect.pageName ),
                                                                // 
currentBaseUrl is the current URL minus the hash fragment
-                                                               currentBaseUrl 
= window.location.href.split("#")[0];
+                                                               currentBaseUrl 
= window.location.href.split('#')[0];
 
                                                        // Set window location 
to user talk page URL + WikiLove anchor hash.
                                                        // Unfortunately, in 
the most common scenario (starting from the user talk
@@ -707,9 +706,9 @@
                                                        // new WikiLove message 
is displayed.
                                                        // @todo: an 
expandUrl() would be very nice indeed!
                                                        if (
-                                                               mw.config.get( 
'wgServer' ) + targetBaseUrl === currentBaseUrl
+                                                               mw.config.get( 
'wgServer' ) + targetBaseUrl === currentBaseUrl ||
                                                                // 
Compatibility with protocol-relative URLs in MediaWiki 1.18+
-                                                               || 
window.location.protocol + mw.config.get( 'wgServer' ) + targetBaseUrl === 
currentBaseUrl
+                                                                       
window.location.protocol + mw.config.get( 'wgServer' ) + targetBaseUrl === 
currentBaseUrl
                                                        ) {
                                                                
window.location.reload();
                                                        }
@@ -761,8 +760,8 @@
                $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 );
                $( '#mw-wikilove-gallery-error' ).hide();
 
-               if ( currentTypeOrSubtype.gallery.number === undefined
-                   || currentTypeOrSubtype.gallery.number <= 0
+               if ( currentTypeOrSubtype.gallery.number === undefined ||
+                       currentTypeOrSubtype.gallery.number <= 0
                ) {
                        currentTypeOrSubtype.gallery.number = 
currentTypeOrSubtype.gallery.imageList.length;
                }
@@ -954,4 +953,4 @@
 
 
 $( document ).ready( $.wikiLove.init );
-} ) ( jQuery );
+} ) ( jQuery, mediaWiki );
diff --git a/resources/ext.wikiLove.defaultOptions.js 
b/resources/ext.wikiLove.defaultOptions.js
index c27057b..ff166eb 100644
--- a/resources/ext.wikiLove.defaultOptions.js
+++ b/resources/ext.wikiLove.defaultOptions.js
@@ -1,6 +1,6 @@
 //See http://www.mediawiki.org/wiki/Extension:WikiLove for basic documentation 
on configuration.
 //<nowiki>
-( function( $ ) {
+( function( $, mw ) {
 $.wikiLoveOptions = {
        defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\
 |rowspan="2" style="vertical-align: middle; padding: 5px;" | [[$3|$4]]\n\
@@ -372,5 +372,5 @@
        }
 };
 
-} )( jQuery );
+} )( jQuery, mediaWiki );
 //</nowiki>
diff --git a/resources/ext.wikiLove.init.js b/resources/ext.wikiLove.init.js
index 6519a32..709d695 100644
--- a/resources/ext.wikiLove.init.js
+++ b/resources/ext.wikiLove.init.js
@@ -1,5 +1,5 @@
-mw.loader.using( 'ext.wikiLove.local', function() {
-       jQuery( document ).ready( function() {
+( function( $, mw ) {
+       $( mw.loader.using( 'ext.wikiLove.local', function() {
                jQuery.wikiLove.init();
-       } );
-} );
+       } ) );
+} )( jQuery, mediaWiki );

-- 
To view, visit https://gerrit.wikimedia.org/r/158774
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0278575038308f8cee03096a14253b9987bba727
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiLove
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to