[MediaWiki-commits] [Gerrit] Stop uploading if maxLimit reached - change (mediawiki...UploadWizard)

2013-06-20 Thread MarkTraceur (Code Review)
MarkTraceur has submitted this change and it was merged.

Change subject: Stop uploading if maxLimit reached
..


Stop uploading if maxLimit reached

Bug: 40158
Change-Id: If0a0362f988d1b9a235c36120d4e07b05755ca77
---
M UploadWizard.i18n.php
M resources/mw.UploadWizardUpload.js
M resources/mw.UploadWizardUploadInterface.js
3 files changed, 18 insertions(+), 20 deletions(-)

Approvals:
  MarkTraceur: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/UploadWizard.i18n.php b/UploadWizard.i18n.php
index 7744a18..5ad001f 100644
--- a/UploadWizard.i18n.php
+++ b/UploadWizard.i18n.php
@@ -241,7 +241,7 @@
'mwe-upwiz-error-license-wikitext-invalid' = 'This does not seem to be 
valid wikitext, or does not contain a license.',
'mwe-upwiz-details-error-count' = 'There {{PLURAL:$1|is one error|are 
$1 errors}} with the {{PLURAL:$2|form|forms}} above. Correct the 
{{PLURAL:$1|error|errors}}, and try submitting again.',
'mwe-upwiz-too-many-files-ok' = 'OK',
-   'mwe-upwiz-too-many-files-text' = 'You can only upload $1 
{{PLURAL:$1|file|files}} at once. You tried to upload $2 
{{PLURAL:$2|file|files}} in total, so $3 {{PLURAL:$3|file has|files have}} been 
removed.',
+   'mwe-upwiz-too-many-files-text' = 'You can only upload $1 
{{PLURAL:$1|file|files}} at once but you tried to upload $2 
{{PLURAL:$2|file|files}} in total. Please try again with fewer files!',
'mwe-upwiz-too-many-files' = 'Too many files.',
'mwe-upwiz-file-too-large-ok' = 'OK',
'mwe-upwiz-file-too-large-text' = 'You can only upload files with a 
size of up to $1. You tried to upload a file that is $2.',
diff --git a/resources/mw.UploadWizardUpload.js 
b/resources/mw.UploadWizardUpload.js
index b0a92d2..40fd599 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -341,9 +341,9 @@
 * @param {Array} of Files.  usually one, can be more for multi-file 
select.
 * @param {Function()} callback when ok, and upload object is ready
 * @param {Function(String, Mixed)} callback when filename or contents 
in error. Signature of string code, mixed info
+* @param {Function()} callback when resetting FileInput
 */
-   checkFile: function( filename, files, fileNameOk, fileNameErr ) {
-
+   checkFile: function( filename, files, fileNameOk, fileNameErr, 
resetFileInput ) {
var _this = this;
var fileErrors = {};
 
@@ -358,6 +358,13 @@
// Check if filename is acceptable
// TODO sanitize filename
var basename = mw.UploadWizardUtil.getBasename( filename );
+
+   var tooManyFiles = files.length + _this.wizard.uploads.length  
mw.UploadWizard.config.maxUploads;
+   if ( tooManyFiles ) {
+   _this.showTooManyFilesWarning( files.length );
+   resetFileInput();
+   return;
+   }
 
if ( files.length  1 ) {
 
@@ -504,16 +511,7 @@
 
// Now that first file has been 
prepared, process remaining files
// in case of a multi-file upload.
-   var tooManyFiles = files.length + 
_this.wizard.uploads.length  mw.UploadWizard.config.maxUploads;
-
-   if ( tooManyFiles ) {
-   var remainingFiles = 
mw.UploadWizard.config.maxUploads - _this.wizard.uploads.length;
-   _this.showTooManyFilesWarning( 
files.length - remainingFiles );
-   files = remainingFiles  1 ? 
files.slice( 1, remainingFiles ) : [];
-   } else {
-   files = files.slice( 1 );
-   }
-
+   files = files.slice( 1 );
if ( files.length  0 ) {
$j.each( files, function( i, 
file ) {
 
@@ -566,14 +564,14 @@
/**
 * Shows an error dialog informing the user that some uploads have been 
omitted
 * since they went over the max files limit.
-* @param filesIgnored integer - the number of files that have been 
omitted
+* @param filesUploaded integer - the number of files that have been 
attempted to upload
 */
-   showTooManyFilesWarning: function( filesIgnored ) {
+   showTooManyFilesWarning: function( filesUploaded ) {
var buttons = [
{
text: mw.msg( 'mwe-upwiz-too-many-files-ok' ),
click: function() {
-   $( this 

[MediaWiki-commits] [Gerrit] Stop uploading if maxLimit reached - change (mediawiki...UploadWizard)

2013-05-25 Thread Nischayn22 (Code Review)
Nischayn22 has uploaded a new change for review.

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


Change subject: Stop uploading if maxLimit reached
..

Stop uploading if maxLimit reached

Bug: 40158
Change-Id: If0a0362f988d1b9a235c36120d4e07b05755ca77
---
M UploadWizard.i18n.php
M resources/mw.UploadWizardUpload.js
M resources/mw.UploadWizardUploadInterface.js
3 files changed, 17 insertions(+), 19 deletions(-)


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

diff --git a/UploadWizard.i18n.php b/UploadWizard.i18n.php
index f420c46..ffc6d8f 100644
--- a/UploadWizard.i18n.php
+++ b/UploadWizard.i18n.php
@@ -241,7 +241,7 @@
'mwe-upwiz-error-license-wikitext-invalid' = 'This does not seem to be 
valid wikitext, or does not contain a license.',
'mwe-upwiz-details-error-count' = 'There {{PLURAL:$1|is one error|are 
$1 errors}} with the {{PLURAL:$2|form|forms}} above. Correct the 
{{PLURAL:$1|error|errors}}, and try submitting again.',
'mwe-upwiz-too-many-files-ok' = 'OK',
-   'mwe-upwiz-too-many-files-text' = 'You can only upload $1 
{{PLURAL:$1|file|files}} at once. You tried to upload $2 
{{PLURAL:$2|file|files}} in total, so $3 {{PLURAL:$3|file has|files have}} been 
removed.',
+   'mwe-upwiz-too-many-files-text' = 'You can only upload $1 
{{PLURAL:$1|file|files}} at once but you tried to upload $2 
{{PLURAL:$2|file|files}} in total. Please try again with lesser number of 
files!',
'mwe-upwiz-too-many-files' = 'Too many files.',
'mwe-upwiz-file-too-large-ok' = 'OK',
'mwe-upwiz-file-too-large-text' = 'You can only upload files with a 
size of up to $1. You tried to upload a file that is $2.',
diff --git a/resources/mw.UploadWizardUpload.js 
b/resources/mw.UploadWizardUpload.js
index c37d105..d475876 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -351,9 +351,9 @@
 * @param {Array} of Files.  usually one, can be more for multi-file 
select.
 * @param {Function()} callback when ok, and upload object is ready
 * @param {Function(String, Mixed)} callback when filename or contents 
in error. Signature of string code, mixed info
+* @param {Function()} callback when resetting FileInput
 */
-   checkFile: function( filename, files, fileNameOk, fileNameErr ) {
-
+   checkFile: function( filename, files, fileNameOk, fileNameErr, 
resetFileInput ) {
var _this = this;
var fileErrors = {};
 
@@ -368,6 +368,13 @@
// Check if filename is acceptable
// TODO sanitize filename
var basename = mw.UploadWizardUtil.getBasename( filename );
+
+   var tooManyFiles = files.length + _this.wizard.uploads.length  
mw.UploadWizard.config.maxUploads;
+   if ( tooManyFiles ) {
+   _this.showTooManyFilesWarning( files.length );
+   resetFileInput();
+   return;
+   }
 
if ( files.length  1 ) {
 
@@ -514,16 +521,7 @@
 
// Now that first file has been 
prepared, process remaining files
// in case of a multi-file upload.
-   var tooManyFiles = files.length + 
_this.wizard.uploads.length  mw.UploadWizard.config.maxUploads;
-
-   if ( tooManyFiles ) {
-   var remainingFiles = 
mw.UploadWizard.config.maxUploads - _this.wizard.uploads.length;
-   _this.showTooManyFilesWarning( 
files.length - remainingFiles );
-   files = remainingFiles  1 ? 
files.slice( 1, remainingFiles ) : [];
-   } else {
-   files = files.slice( 1 );
-   }
-
+   files = files.slice( 1 );
if ( files.length  0 ) {
$j.each( files, function( i, 
file ) {
 
@@ -579,14 +577,14 @@
/**
 * Shows an error dialog informing the user that some uploads have been 
omitted
 * since they went over the max files limit.
-* @param filesIgnored integer - the number of files that have been 
omitted
+* @param filesUploaded integer - the number of files that have been 
attempted to upload
 */
-   showTooManyFilesWarning: function( filesIgnored ) {
+   showTooManyFilesWarning: function( filesUploaded ) {
var buttons = [
{
text: mw.msg( 'mwe-upwiz-too-many-files-ok' ),
click: