summaryrefslogtreecommitdiff
path: root/lib/scripts/fileuploader.js
diff options
context:
space:
mode:
authorKate Arzamastseva <pshns@ukr.net>2011-08-07 13:54:36 +0300
committerKate Arzamastseva <pshns@ukr.net>2011-08-07 13:54:36 +0300
commit8d7448594cb00e995bed9b6e6db6e7f9280da24d (patch)
tree1abebd54f5f5b5c331cfdcdb26779f1f445479c6 /lib/scripts/fileuploader.js
parent50fc55fe69fc348d3679981cc088c57b35c47571 (diff)
downloadrpg-8d7448594cb00e995bed9b6e6db6e7f9280da24d.tar.gz
rpg-8d7448594cb00e995bed9b6e6db6e7f9280da24d.tar.bz2
issue #44 fileuploader specific changes made in inheriting class
Diffstat (limited to 'lib/scripts/fileuploader.js')
-rw-r--r--lib/scripts/fileuploader.js64
1 files changed, 3 insertions, 61 deletions
diff --git a/lib/scripts/fileuploader.js b/lib/scripts/fileuploader.js
index 437984848..5368d9739 100644
--- a/lib/scripts/fileuploader.js
+++ b/lib/scripts/fileuploader.js
@@ -267,7 +267,6 @@ qq.FileUploaderBasic = function(o){
onProgress: function(id, fileName, loaded, total){},
onComplete: function(id, fileName, responseJSON){},
onCancel: function(id, fileName){},
- onUpload: function(){},
// messages
messages: {
typeError: "{file} has invalid extension. Only {extensions} are allowed.",
@@ -336,9 +335,6 @@ qq.FileUploaderBasic.prototype = {
onCancel: function(id, fileName){
self._onCancel(id, fileName);
self._options.onCancel(id, fileName);
- },
- onUpload: function(){
- self._onUpload();
}
});
@@ -371,9 +367,6 @@ qq.FileUploaderBasic.prototype = {
_onCancel: function(id, fileName){
this._filesInProgress--;
},
- _onUpload: function(){
- this._handler.uploadAll(this._options.params);
- },
_onInputChange: function(input){
if (this._handler instanceof qq.UploadHandlerXhr){
this._uploadFileList(input.files);
@@ -401,6 +394,7 @@ qq.FileUploaderBasic.prototype = {
if (this._options.onSubmit(id, fileName) !== false){
this._onSubmit(id, fileName);
+ this._handler.upload(id, this._options.params);
}
},
_validateFile: function(file){
@@ -494,13 +488,11 @@ qq.FileUploader = function(o){
'<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
'<div class="qq-upload-button">Upload a file</div>' +
'<ul class="qq-upload-list"></ul>' +
- '<input class="button" type="submit" value="Upload" id="mediamanager__upload_button">' +
'</div>',
// template for one item in file list
fileTemplate: '<li>' +
'<span class="qq-upload-file"></span>' +
- '<label><span>Upload as (optional):</span><input class="qq-upload-name-input" type="text"></label>' +
'<span class="qq-upload-spinner"></span>' +
'<span class="qq-upload-size"></span>' +
'<a class="qq-upload-cancel" href="#">Cancel</a>' +
@@ -513,9 +505,8 @@ qq.FileUploader = function(o){
drop: 'qq-upload-drop-area',
dropActive: 'qq-upload-drop-area-active',
list: 'qq-upload-list',
- nameInput: 'qq-upload-name-input',
- file: 'qq-upload-file',
+ file: 'qq-upload-file',
spinner: 'qq-upload-spinner',
size: 'qq-upload-size',
cancel: 'qq-upload-cancel',
@@ -538,7 +529,6 @@ qq.FileUploader = function(o){
this._button = this._createUploadButton(this._find(this._element, 'button'));
this._bindCancelEvent();
- this._bindUploadEvent();
this._setupDragDrop();
};
@@ -639,10 +629,6 @@ qq.extend(qq.FileUploader.prototype, {
qq.setText(fileElement, this._formatFileName(fileName));
this._find(item, 'size').style.display = 'none';
- var nameElement = this._find(item, 'nameInput');
- nameElement.value = this._formatFileName(fileName);
- nameElement.id = id;
-
this._listElement.appendChild(item);
},
_getItemByFileId: function(id){
@@ -674,19 +660,6 @@ qq.extend(qq.FileUploader.prototype, {
qq.remove(item);
}
});
- },
-
- _bindUploadEvent: function(){
- var self = this,
- list = this._listElement;
-
- qq.attach(document.getElementById('mediamanager__upload_button'), 'click', function(e){
- e = e || window.event;
- var target = e.target || e.srcElement;
- qq.preventDefault(e);
- self._handler._options.onUpload();
-
- });
}
});
@@ -904,10 +877,6 @@ qq.UploadHandlerAbstract.prototype = {
* @returns id
**/
add: function(file){},
-
- uploadAll: function(params){
- this._uploadAll(params);
- },
/**
* Sends the file identified by id and additional query params to the server
*/
@@ -958,8 +927,6 @@ qq.UploadHandlerAbstract.prototype = {
* Actual upload method
*/
_upload: function(id){},
-
- _uploadAll: function(params){},
/**
* Actual cancel method
*/
@@ -1059,12 +1026,6 @@ qq.extend(qq.UploadHandlerForm.prototype, {
return id;
},
- _uploadAll: function(params){
- for (key in this._inputs) {
- this.upload(key, params);
- }
-
- },
_attachLoadEvent: function(iframe, callback){
qq.attach(iframe, 'load', function(){
// when we remove iframe from dom
@@ -1192,21 +1153,10 @@ qq.extend(qq.UploadHandlerXhr.prototype, {
getName: function(id){
var file = this._files[id];
// fix missing name in Safari 4
- var name = document.getElementById(id);
- if (name != null) {
- return name.value;
- } else {
- if (file != null) {
- // fix missing name in Safari 4
- return file.fileName != null ? file.fileName : file.name;
- } else {
- return null;
- }
- }
+ return file.fileName != null ? file.fileName : file.name;
},
getSize: function(id){
var file = this._files[id];
- if (file == null) return null;
return file.fileSize != null ? file.fileSize : file.size;
},
/**
@@ -1223,7 +1173,6 @@ qq.extend(qq.UploadHandlerXhr.prototype, {
var file = this._files[id],
name = this.getName(id),
size = this.getSize(id);
- if (name == null || size == null) return;
this._loaded[id] = 0;
@@ -1254,13 +1203,6 @@ qq.extend(qq.UploadHandlerXhr.prototype, {
xhr.setRequestHeader("Content-Type", "application/octet-stream");
xhr.send(file);
},
-
- _uploadAll: function(params){
- for (key in this._files) {
- this.upload(key, params);
- }
-
- },
_onComplete: function(id, xhr){
// the request was aborted/cancelled
if (!this._files[id]) return;