jenkins-bot has submitted this change and it was merged.

Change subject: Add npm entry point
......................................................................


Add npm entry point

Change-Id: Ie84791baeb165cf18649bc40836cf5a7929294e1
---
A .jshintignore
A .jshintrc
A Gruntfile.js
M modules/ext.Drafts.js
A package.json
5 files changed, 87 insertions(+), 17 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..bde3473
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,23 @@
+{
+       // Enforcing
+       "bitwise": true,
+       "eqeqeq": true,
+       "freeze": true,
+       "latedef": "nofunc",
+       "noarg": true,
+       "nonew": true,
+       "undef": false,
+       "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..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.Drafts.js b/modules/ext.Drafts.js
index d761ed5..ee86b3f 100644
--- a/modules/ext.Drafts.js
+++ b/modules/ext.Drafts.js
@@ -1,5 +1,9 @@
 /* JavaScript for Drafts extension */
 
+/*jshint -W066 */
+
+var wgDraft;
+
 function Draft() {
 
        /* Private Members */
@@ -29,23 +33,23 @@
                        switch ( state ) {
                                case 'unchanged':
                                        form.wpDraftSave.disabled = true;
-                                       form.wpDraftSave.value = mw.message( 
'drafts-save-save' ).text();
+                                       form.wpDraftSave.value = 
mediaWiki.message( 'drafts-save-save' ).text();
                                        break;
                                case 'changed':
                                        form.wpDraftSave.disabled = false;
-                                       form.wpDraftSave.value = mw.message( 
'drafts-save-save' ).text();
+                                       form.wpDraftSave.value = 
mediaWiki.message( 'drafts-save-save' ).text();
                                        break;
                                case 'saved':
                                        form.wpDraftSave.disabled = true;
-                                       form.wpDraftSave.value = mw.message( 
'drafts-save-saved' ).text();
+                                       form.wpDraftSave.value = 
mediaWiki.message( 'drafts-save-saved' ).text();
                                        break;
                                case 'saving':
                                        form.wpDraftSave.disabled = true;
-                                       form.wpDraftSave.value = mw.message( 
'drafts-save-saving' ).text();
+                                       form.wpDraftSave.value = 
mediaWiki.message( 'drafts-save-saving' ).text();
                                        break;
                                case 'error':
                                        form.wpDraftSave.disabled = true;
-                                       form.wpDraftSave.value = mw.message( 
'drafts-save-error' ).text();
+                                       form.wpDraftSave.value = 
mediaWiki.message( 'drafts-save-error' ).text();
                                        break;
                                default: break;
                        }
@@ -90,12 +94,12 @@
                }
 
                // Performs asynchronous save on server
-               var api = new mw.Api();
+               var api = new mediaWiki.Api();
                api.post(params).done( self.respond ).fail( self.respond );
 
                // Re-allow request if it is not done in 10 seconds
                self.timeoutID = window.setTimeout(
-                       "wgDraft.setState( 'changed' )", 10000
+                       "wgDraft.setState( 'changed' );", 10000
                );
                // Ensure timer is cleared in case we saved manually before it 
expired
                clearTimeout( timer );
@@ -116,7 +120,7 @@
                        if ( configuration.autoSaveWait && 
configuration.autoSaveWait > 0 ) {
                                // Sets timer to save automatically after a 
period of time
                                timer = setTimeout(
-                                       'wgDraft.save()', 
configuration.autoSaveWait * 1000
+                                       'wgDraft.save();', 
configuration.autoSaveWait * 1000
                                );
                        }
                        return;
@@ -130,7 +134,7 @@
                if ( configuration.autoSaveWait && configuration.autoSaveWait > 
0 ) {
                        // Sets timer to save automatically after a period of 
time
                        timer = setTimeout(
-                               'wgDraft.save()', configuration.autoSaveWait * 
1000
+                               'wgDraft.save();', configuration.autoSaveWait * 
1000
                        );
                }
        };
@@ -144,18 +148,18 @@
                // Check to see that the form and controls exist
                if ( form && form.wpDraftSave ) {
                        // Handle manual draft saving through clicking the save 
draft button
-                       $j( form.wpDraftSave ).on( 'click', self.save );
+                       jQuery( form.wpDraftSave ).on( 'click', self.save );
                        // Handle keeping track of state by watching for 
changes to fields
-                       $j( form.wpTextbox1 ).on( 'keypress keyup keydown paste 
cut', self.change );
-                       $j( form.wpSummary ).on( 'keypress keyup keydown paste 
cut', self.change );
+                       jQuery( form.wpTextbox1 ).on( 'keypress keyup keydown 
paste cut', self.change );
+                       jQuery( form.wpSummary ).on( 'keypress keyup keydown 
paste cut', self.change );
                        if ( form.wpMinoredit ) {
-                               $j( form.wpMinoredit ).on( 'change', 
self.change );
+                               jQuery( form.wpMinoredit ).on( 'change', 
self.change );
                        }
                        // Gets configured specific values
                        configuration = {
-                               autoSaveWait: mw.config.get( 
'wgDraftAutoSaveWait' ),
-                               autoSaveTimeout: mw.config.get( 
'wgDraftAutoSaveTimeout' ),
-                               autoSaveBasedOnInput: mw.config.get( 
'wgDraftAutoSaveInputBased' )
+                               autoSaveWait: mediaWiki.config.get( 
'wgDraftAutoSaveWait' ),
+                               autoSaveTimeout: mediaWiki.config.get( 
'wgDraftAutoSaveTimeout' ),
+                               autoSaveBasedOnInput: mediaWiki.config.get( 
'wgDraftAutoSaveInputBased' )
                        };
                }
        };
@@ -179,5 +183,5 @@
        };
 }
 
-var wgDraft = new Draft();
+wgDraft = new Draft();
 wgDraft.initialize();
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..ec97d7b
--- /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.4.0",
+    "grunt-contrib-jshint": "1.0.0",
+    "grunt-jsonlint": "1.0.7"
+  }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie84791baeb165cf18649bc40836cf5a7929294e1
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Drafts
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

Reply via email to