TheDJ has submitted this change and it was merged.

Change subject: Refactor Cite extension JavaScript and make it pass Jshint
......................................................................


Refactor Cite extension JavaScript and make it pass Jshint

Moved the scripts and the CSS into the modules folder directly
(like almost all other extensions do), added a .jshintrc to not have
jenkins shout at this change and minor stuff.

After this change Cite will no longer work with anything older than
PHP 5.3!

Change-Id: I1c87af794f2a9894fb0d82a5bd97bd2182f028e1
---
A .jshintignore
A .jshintrc
M Cite.php
M SpecialCite.php
R modules/ext.cite.popups.js
R modules/ext.rtlcite.css
R modules/ext.specialcite.css
7 files changed, 51 insertions(+), 16 deletions(-)

Approvals:
  TheDJ: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..df46ab9
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+modules/jquery.tooltip/jquery.tooltip.js
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..4b356f8
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,34 @@
+{
+       "camelcase": true,
+       "curly": true,
+       "eqeqeq": true,
+       "immed": true,
+       "latedef": true,
+       "newcap": true,
+       "supernew": true,
+       "shadow": true,
+       "noarg": true,
+       "noempty": true,
+       "nonew": true,
+       "quotmark": false, // sometimes double quotes make sense, e.g. "foo's" 
is better readable than 'foo\'s'
+       "trailing": true,
+       "undef": true,
+       "unused": "vars", // we want to allow unused function parameters
+       "laxbreak": true,
+       "laxcomma": false,
+       "onevar": false,
+       "bitwise": false,
+       "forin": false,
+       "regexp": false,
+       "strict": true,
+       "scripturl": true,
+
+       // Environment
+       "browser": true,
+
+       // Globals
+       "predef": [
+               "jQuery",
+               "mediaWiki"
+       ]
+}
diff --git a/Cite.php b/Cite.php
index 0f95765..99d5163 100644
--- a/Cite.php
+++ b/Cite.php
@@ -28,10 +28,10 @@
        'descriptionmsg' => 'cite-desc',
        'url' => 'https://www.mediawiki.org/wiki/Extension:Cite/Cite.php'
 );
-$wgParserTestFiles[] = dirname( __FILE__ ) . "/citeParserTests.txt";
-$wgParserTestFiles[] = dirname( __FILE__ ) . "/citeCatTreeParserTests.txt";
-$wgExtensionMessagesFiles['Cite'] = dirname( __FILE__ ) . "/Cite.i18n.php";
-$wgAutoloadClasses['Cite'] = dirname( __FILE__ ) . "/Cite_body.php";
+$wgParserTestFiles[] = __DIR__ . "/citeParserTests.txt";
+$wgParserTestFiles[] = __DIR__ . "/citeCatTreeParserTests.txt";
+$wgExtensionMessagesFiles['Cite'] = __DIR__ . "/Cite.i18n.php";
+$wgAutoloadClasses['Cite'] = __DIR__ . "/Cite_body.php";
 $wgSpecialPageGroups['Cite'] = 'pagetools';
 
 define( 'CITE_DEFAULT_GROUP', '' );
@@ -66,13 +66,12 @@
 
 // Resources
 $citeResourceTemplate = array(
-       'localBasePath' => dirname(__FILE__) . '/modules',
+       'localBasePath' => __DIR__ . '/modules',
        'remoteExtPath' => 'Cite/modules'
 );
 
-$wgResourceModules['ext.cite'] = $citeResourceTemplate + array(
-       'styles' => array(),
-       'scripts' => 'ext.cite/ext.cite.js',
+$wgResourceModules['ext.cite.popups'] = $citeResourceTemplate + array(
+       'scripts' => 'ext.cite.popups.js',
        'position' => 'bottom',
        'dependencies' => array(
                'jquery.tooltip',
@@ -87,7 +86,7 @@
 
 /* Add RTL fix for the cite <sup> elements */
 $wgResourceModules['ext.rtlcite'] = $citeResourceTemplate + array(
-       'styles' => 'ext.rtlcite/ext.rtlcite.css',
+       'styles' => 'ext.rtlcite.css',
        'position' => 'top',
 );
 
@@ -100,7 +99,7 @@
        global $wgCiteEnablePopups;
 
        if ( $wgCiteEnablePopups ) {
-               $out->addModules( 'ext.cite' );
+               $out->addModules( 'ext.cite.popups' );
        }
 
        /* RTL support quick-fix module */
diff --git a/SpecialCite.php b/SpecialCite.php
index 6d9b813..5990f54 100644
--- a/SpecialCite.php
+++ b/SpecialCite.php
@@ -22,7 +22,7 @@
        'url' => 
'https://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php'
 );
 
-$dir = dirname( __FILE__ ) . '/';
+$dir = __DIR__ . '/';
 # Internationalisation file
 $wgExtensionMessagesFiles['SpecialCite'] = $dir . 'SpecialCite.i18n.php';
 $wgExtensionMessagesFiles['SpecialCiteAliases'] = $dir . 
'SpecialCite.alias.php';
@@ -35,12 +35,12 @@
 
 // Resources
 $citeResourceTemplate = array(
-       'localBasePath' => dirname(__FILE__) . '/modules',
+       'localBasePath' => __DIR__ . '/modules',
        'remoteExtPath' => 'Cite/modules'
 );
 
 $wgResourceModules['ext.specialcite'] = $citeResourceTemplate + array(
-       'styles' => 'ext.specialcite/ext.specialcite.css',
+       'styles' => 'ext.specialcite.css',
        'scripts' => array(),
        'position' => 'bottom',
 );
diff --git a/modules/ext.cite/ext.cite.js b/modules/ext.cite.popups.js
similarity index 67%
rename from modules/ext.cite/ext.cite.js
rename to modules/ext.cite.popups.js
index dc7328b..03529fd 100644
--- a/modules/ext.cite/ext.cite.js
+++ b/modules/ext.cite.popups.js
@@ -1,6 +1,8 @@
-( function($) {
+( function( $ ) {
+       'use strict';
+
        $( function() {
-               $('.biblio-cite-link,sup.reference a').tooltip({
+               $( '.biblio-cite-link,sup.reference a' ).tooltip( {
                                bodyHandler: function() {
                                        return $( '#' + this.hash.substr(1) + ' 
> .reference-text' )
                                                .html();
@@ -8,5 +10,4 @@
                                showURL : false
                        } );
        } );
-       
 } )( jQuery );
diff --git a/modules/ext.rtlcite/ext.rtlcite.css b/modules/ext.rtlcite.css
similarity index 100%
rename from modules/ext.rtlcite/ext.rtlcite.css
rename to modules/ext.rtlcite.css
diff --git a/modules/ext.specialcite/ext.specialcite.css 
b/modules/ext.specialcite.css
similarity index 100%
rename from modules/ext.specialcite/ext.specialcite.css
rename to modules/ext.specialcite.css

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1c87af794f2a9894fb0d82a5bd97bd2182f028e1
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cite
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to