-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto upload feature #19
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -612,10 +612,13 @@ Sys.Extended.UI.AjaxFileUpload.ProcessorHtml5 = function(control, elements) { | |
|
||
// #endregion | ||
|
||
this.addFilesToQueue = function(files) { | ||
// Validate and generate file item from HTML5 files. | ||
this.addFilesToQueue = function (files) { | ||
|
||
for(var i = 0; i < files.length; i++) { | ||
var startUpload = true; | ||
var fileCount = files.length; // store original value for later purposes (under WebKit/Blink the collection lenght is modified ) | ||
|
||
// Validate and generate file item from HTML5 files. | ||
for (var i = 0; i < files.length; i++) { | ||
|
||
var blob = files[i], | ||
slices = 0; | ||
|
@@ -636,15 +639,22 @@ Sys.Extended.UI.AjaxFileUpload.ProcessorHtml5 = function(control, elements) { | |
|
||
// validate it, add it if it's OK | ||
if(control.fileTypeIsValid(fileItem.type)) { | ||
if(!control.addFileToQueue(fileItem)) | ||
if (!control.addFileToQueue(fileItem)) { | ||
startUpload = false; | ||
break; | ||
} | ||
} else { | ||
startUpload = false; | ||
control.confirmFileIsInvalid(fileItem); | ||
} | ||
} | ||
|
||
// reset input file value so 'change' event can be fired again with same file name. | ||
elements.inputFile.value = null; | ||
|
||
if (fileCount > 0 && startUpload && control.get_autoStartUpload()) { | ||
control.startUpload(); | ||
} | ||
}; | ||
|
||
this.cancelUpload = function() { | ||
|
@@ -917,6 +927,14 @@ Sys.Extended.UI.AjaxFileUpload.Control = function(element) { | |
/// <member name="cP:AjaxControlToolkit.AjaxFileUpload.mode" /> | ||
this._mode = 0; | ||
|
||
/// <summary> | ||
/// Whether or not automatically start upload files after drag/drop or select in file dialog. The default is false | ||
/// </summary> | ||
/// <getter>get_autoStartUpload</getter> | ||
/// <setter>set_autoStartUpload</setter> | ||
/// <member name="cP:AjaxControlToolkit.AjaxFileUpload.autoStartUpload" /> | ||
this._autoStartUpload = false; | ||
|
||
/// <summary> | ||
/// Whether or not AjaxFileUpload supports server polling. | ||
/// </summary> | ||
|
@@ -1135,6 +1153,18 @@ Sys.Extended.UI.AjaxFileUpload.Control.prototype = { | |
} | ||
}, | ||
|
||
/// <summary> | ||
/// Manually starts upload process | ||
/// </summary> | ||
startUpload: function () { | ||
if (this._isUploading || !this._filesInQueue.length) { | ||
return; | ||
} | ||
|
||
this._onUploadOrCancelButtonClickedHandler(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling this.onFileSelectedHandler = function(e) {
this.addFilesToQueue(e.target.files);
this.createInputFileElement();
}; Change |
||
}, | ||
|
||
|
||
/// <summary> | ||
/// If set to true, it will set the control state to enabled (ready to upload), | ||
/// otherwise the control will be disabled and the button state turns to the Cancel button. | ||
|
@@ -1450,6 +1480,13 @@ Sys.Extended.UI.AjaxFileUpload.Control.prototype = { | |
this._mode = value; | ||
}, | ||
|
||
get_autoStartUpload: function () { | ||
return this._autoStartUpload; | ||
}, | ||
set_autoStartUpload: function (value) { | ||
this._autoStartUpload = value; | ||
}, | ||
|
||
get_serverPollingSupport: function() { | ||
return this._serverPollingSupport; | ||
}, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this check and
control.startUpload()
outside the method (see comment below).