jenkins-bot has submitted this change and it was merged.
Change subject: Add npm entry point
......................................................................
Add npm entry point
Change-Id: I9f32d59ed127e11adecd996f731f138265cfb97b
---
A .jshintignore
A .jshintrc
A Gruntfile.js
M modules/AccountCreationUserBucket.js
A package.json
5 files changed, 93 insertions(+), 26 deletions(-)
Approvals:
Hashar: Looks good to me, approved
jenkins-bot: Verified
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..04c3a97
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,23 @@
+{
+ // Enforcing
+ "bitwise": true,
+ "eqeqeq": true,
+ "freeze": true,
+ "latedef": "nofunc",
+ "noarg": true,
+ "nonew": true,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+
+ // Relaxing
+ "es5": false,
+
+ // Environment
+ "browser": true,
+ "jquery": true,
+
+ "globals": {
+ "mediaWiki": false
+ }
+}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..2ea9e32
--- /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/AccountCreationUserBucket.js
b/modules/AccountCreationUserBucket.js
index 7a7c629..8b19cf6 100644
--- a/modules/AccountCreationUserBucket.js
+++ b/modules/AccountCreationUserBucket.js
@@ -1,8 +1,10 @@
+/*jshint -W069 */
+
//checks
-if(!mw.activeCampaigns){ mw.activeCampaigns ={}; }
+if(!mediaWiki.activeCampaigns){ mediaWiki.activeCampaigns ={}; }
//define new active campaign
-mw.activeCampaigns.AccountCreation =
+mediaWiki.activeCampaigns.AccountCreation =
{
//Treatment name
@@ -29,62 +31,62 @@
"ACP1": function(){
//change to NiceMsg1 campaign
- $j("#pt-anonlogin a").each(function(){
- $j(this).attr("href", $j(this).attr("href") +
"&campaign=ACP1" );
+ jQuery("#pt-anonlogin a").each(function(){
+ jQuery(this).attr("href", jQuery(this).attr("href") +
"&campaign=ACP1" );
});
- $j("#pt-login a").each(function(){
- $j(this).attr("href", $j(this).attr("href") +
"&campaign=ACP1" );
+ jQuery("#pt-login a").each(function(){
+ jQuery(this).attr("href", jQuery(this).attr("href") +
"&campaign=ACP1" );
});
},
"ACP2": function(){
//change to NiceMsg2 campaign
- $j("#pt-anonlogin a").each(function(){
- $j(this).attr("href", $j(this).attr("href") +
"&campaign=ACP2" );
+ jQuery("#pt-anonlogin a").each(function(){
+ jQuery(this).attr("href", jQuery(this).attr("href") +
"&campaign=ACP2" );
});
- $j("#pt-login a").each(function(){
- $j(this).attr("href", $j(this).attr("href") +
"&campaign=ACP2" );
+ jQuery("#pt-login a").each(function(){
+ jQuery(this).attr("href", jQuery(this).attr("href") +
"&campaign=ACP2" );
});
},
"ACP3": function(){
//change to NiceMsg2 campaign
- $j("#pt-anonlogin a").each(function(){
- $j(this).attr("href", $j(this).attr("href") +
"&campaign=ACP3" );
+ jQuery("#pt-anonlogin a").each(function(){
+ jQuery(this).attr("href", jQuery(this).attr("href") +
"&campaign=ACP3" );
});
- $j("#pt-login a").each(function(){
- $j(this).attr("href", $j(this).attr("href") +
"&campaign=ACP3" );
+ jQuery("#pt-login a").each(function(){
+ jQuery(this).attr("href", jQuery(this).attr("href") +
"&campaign=ACP3" );
});
},
// "allActive" is reserved.
// If this function exists, it will be apply to every user not in the "none"
bucket
"allActive": function(){
- if ( !mw.config.get( 'wgCustomUserSignupTrackAccountCreations' ) ) {
return; }
+ if ( !mediaWiki.config.get( 'wgCustomUserSignupTrackAccountCreations' )
) { return; }
//track account creation attempts
- $j("#wpCreateaccount").click(function(){
$j.trackAction('submit-signup-data'); });
+ jQuery("#wpCreateaccount").click(function(){
jQuery.trackAction('submit-signup-data'); });
//this is the "don't have an account? CREATE ONE" link
- $j("#userloginlink").click(function(){
$j.trackAction('visit-signup'); });
+ jQuery("#userloginlink").click(function(){
jQuery.trackAction('visit-signup'); });
- if($j.cookie('acctcreation') ){
+ if(jQuery.cookie('acctcreation') ){
//add click tracking to preview
- $j("#wpPreview").click(function(){ $j.trackAction('preview');
});
+ jQuery("#wpPreview").click(function(){
jQuery.trackAction('preview'); });
//add click tracking to save
- $j("#wpSave").click(function(){ $j.trackAction('save'); });
+ jQuery("#wpSave").click(function(){
jQuery.trackAction('save'); });
}
},
"all": function(){
//add up all rates
- var campaign = mw.activeCampaigns.AccountCreation;
- if( $j.cookie('userbuckets') &&
- $j.parseJSON( $j.cookie('userbuckets')
)["AccountCreation"]){
- var buckets = $j.parseJSON(
$j.cookie('userbuckets') );
+ var campaign =
mediaWiki.activeCampaigns.AccountCreation;
+ if( jQuery.cookie('userbuckets') &&
+ jQuery.parseJSON(
jQuery.cookie('userbuckets') )["AccountCreation"]){
+ var buckets = jQuery.parseJSON(
jQuery.cookie('userbuckets') );
- if(typeof(campaign[buckets[campaign.name][0]])
== "function"){
+ if(typeof(campaign[buckets[campaign.name][0]])
=== "function"){
campaign[buckets[campaign.name][0]]();
//function to execute
campaign.allActive();
return;
@@ -105,7 +107,7 @@
for( rate in campaign.rates ){
next_val += campaign.rates[rate];
if(prev_val <= currentUser &&
currentUser < next_val){
- if(rate != "none"){
+ if(rate !== "none"){
campaign[rate]();
}
break;
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..a0b255c
--- /dev/null
+++ b/package.json
@@ -0,0 +1,11 @@
+{
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "0.4.5",
+ "grunt-cli": "0.1.13",
+ "grunt-contrib-jshint": "1.0.0",
+ "grunt-jsonlint": "1.0.7"
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/275588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9f32d59ed127e11adecd996f731f138265cfb97b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/CustomUserSignup
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