Skip to content

Commit

Permalink
Merge pull request #23 from hkollmann/move_to_v7
Browse files Browse the repository at this point in the history
move to v7
  • Loading branch information
johnspackman authored Mar 9, 2022
2 parents 5661d4b + 222d84d commit 64a417a
Show file tree
Hide file tree
Showing 21 changed files with 849 additions and 655 deletions.
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.vscode/
/node_modules/
/qx_packages/
/source/resource/
4 changes: 2 additions & 2 deletions Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"FileSaver.js"
]
},
"$schema": "https://raw.githubusercontent.com/qooxdoo/qooxdoo-compiler/master/source/resource/qx/tool/schema/Manifest-1-0-0.json",
"$schema": "https://raw.githubusercontent.com/qooxdoo/qooxdoo-compiler/master/source/resource/qx/tool/schema/Manifest-2-0-0.json",
"requires": {
"@qooxdoo/framework": "^7.0.0-beta"
"@qooxdoo/framework": "^7.0.0"
}
}
2 changes: 1 addition & 1 deletion compile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://qooxdoo.org/schema/compile-1-0-0.json",
"$schema": "https://qooxdoo.org/schema/compile-1-0-0.json",
"environment": {
"qx.icontheme": "Tango",
"excludeFromAPIViewer": [
Expand Down
122 changes: 61 additions & 61 deletions source/class/com/zenesis/qx/upload/AbstractHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
* current uploads, and restricts the number of simultaneous uploads.
*/
qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {
type : "abstract",
type: "abstract",
extend: qx.core.Object,

/**
* Constructor
*
*
* @param uploader
* {com.zenesis.qx.upload.UploadMgr} controller for uploading
*/
construct: function(uploader) {
this.base(arguments);
construct(uploader) {
super();
qx.core.Assert.assertNotNull(uploader);
this.__queue = [];
this.__current = [];
Expand All @@ -52,8 +52,8 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {
check: "Integer",
init: 5,
nullable: false,
event: "changeMaxConnections"
}
event: "changeMaxConnections",
},
},

members: {
Expand All @@ -75,14 +75,14 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {
/**
* Adds a file to the upload queue; this does not start uploading until
* beginUploads is called.
*
*
* @param input
* {DOM} either one input[type=file] or an array of
* input[type=file]
* @param widget
* {Widget} the widget that trigger the upload
*/
addFile: function(input, widget) {
addFile(input, widget) {
var files = this._createFile(input);
if (!qx.lang.Type.isArray(files)) {
files.setUploadWidget(widget);
Expand All @@ -95,32 +95,35 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {
},

/**
* Adds a blob to the upload list
*
* Adds a blob to the upload list
*
* @param filename {String} name of object
* @param blob {Blob} the blob to upload
* @param params {Object} List of params added to the upload params
*/
addBlob: function (filename, blob, params){
addBlob(filename, blob, params) {
/* abstract */
},

/**
* Adds a file to the outbound queue
*
*
* @param file
* {com.zenesis.qx.upload.File} the file to add
*/
_addFile: function(file) {
_addFile(file) {
if (this.__uploader.fireDataEvent("addFile", file, null, true))
this.__queue.push(file);
},

/**
* Begins spooling uploads to the server, up to the maxConnections
*/
beginUploads: function() {
while (this.__queue.length > 0 && this.__current.length < this.getMaxConnections()) {
beginUploads() {
while (
this.__queue.length > 0 &&
this.__current.length < this.getMaxConnections()
) {
var file = this.__queue.shift();
this.__current.push(file);
this.__uploader.fireDataEvent("beginUpload", file);
Expand All @@ -131,23 +134,22 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {

/**
* Cancels a file
*
*
* @param file
* {com.zenesis.qx.upload.File} the file to cancel
*/
cancel: function(file) {
cancel(file) {
var wasUploading = this.__current.length > 0;
// this.debug("cancelled: id=" + file.getId() + ", fileName=" +
// file.getFilename());
this._cancel(file);
if (wasUploading && this.__uploader.getAutoUpload())
this.beginUploads();
if (wasUploading && this.__uploader.getAutoUpload()) this.beginUploads();
},

/**
* Cancels all uploads
*/
cancelAll: function() {
cancelAll() {
for (var current = this.__current, i = 0; i < current.length; i++)
this._cancel(current[i]);
this.__current.splice(0, this.__current.length);
Expand All @@ -156,11 +158,11 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {

/**
* Cancels a file
*
*
* @param file
* {com.zenesis.qx.upload.File} the file to cancel
*/
_cancel: function(file) {
_cancel(file) {
var inCurrent = false;
for (var current = this.__current, i = 0; i < current.length; i++)
if (current[i] == file) {
Expand All @@ -174,21 +176,20 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {
break;
}
file.setState("cancelled");
if (inCurrent)
this._doCancel(file);
if (inCurrent) this._doCancel(file);
this.__uploader.fireDataEvent("cancelUpload", file);
},

/**
* Called by derived classes when a file has completed
*
*
* @param file
* {com.zenesis.qx.upload.File} the file which has finsihed
* uploading
* @param response
* {String} text received
*/
_onCompleted: function(file, response) {
_onCompleted(file, response) {
// this.debug("completed: id=" + file.getId() + ", fileName=" +
// file.getFilename() + ", response=" + response);
var current = this.__current;
Expand All @@ -212,115 +213,114 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", {

/**
* Returns the uploader
*
*
* @returns {com.zenesis.qx.upload.UploadMgr}
*/
_getUploader: function() {
_getUploader() {
return this.__uploader;
},

/**
* Allocates a unique ID
*
*
* @returns {Number}
*/
_getUniqueFileId: function() {
_getUniqueFileId() {
return ++this.__lastId;
},

/**
* Adds a parameter to send to the client
*
*
* @param key
* {String} the name of the parameter
* @param value
* {String} the value of the parameter
* @deprecated {1.0} see com.zenesis.qx.upload.UploadMgr.setParam or
* com.zenesis.qx.upload.File.setParam
*/
addParam: function(key, value) {
qx.log.Logger.deprecatedMethodWarning(arguments.callee,
"see com.zenesis.qx.upload.UploadMgr.setParam or com.zenesis.qx.upload.File.setParam");
addParam(key, value) {
qx.log.Logger.deprecatedMethodWarning(
arguments.callee,
"see com.zenesis.qx.upload.UploadMgr.setParam or com.zenesis.qx.upload.File.setParam"
);
this.__params[key] = value;
},

/**
* Returns the paramaters map
*
*
* @returns {Map}
* @deprecated {1.0} see com.zenesis.qx.upload.File.getParam
*/
getParams: function() {
qx.log.Logger.deprecatedMethodWarning(arguments.callee,
"see com.zenesis.qx.upload.UploadMgr.getParam or com.zenesis.qx.upload.File.getParam");
getParams() {
qx.log.Logger.deprecatedMethodWarning(
arguments.callee,
"see com.zenesis.qx.upload.UploadMgr.getParam or com.zenesis.qx.upload.File.getParam"
);
return this.__params;
},

/**
* Helper method that produces a final list of parameter values, by merging
* those set in this with those in the file.
*
*
* @param file
* {File} the file object
* @returns {Map} map of parameters to sent to the server
*/
_getMergedParams: function(file) {
_getMergedParams(file) {
var result = {};
for ( var name in this.__params) {
for (var name in this.__params) {
var value = this.__params[name];
if (value !== null)
result[name] = value;
if (value !== null) result[name] = value;
}
function merge(obj) {
var names = obj.getParamNames();
for (var i = 0; i < names.length; i++) {
var name = names[i], value = obj.getParam(name);
if (value !== null)
result[name] = value;
else
delete result[name];
var name = names[i],
value = obj.getParam(name);
if (value !== null) result[name] = value;
else delete result[name];
}
}
merge(this.__uploader);
var widget = file.getUploadWidget();
if (widget && (typeof widget.getParamNames == "function"))
merge(widget);
if (typeof file.getParamNames == "function")
merge(file);
if (widget && typeof widget.getParamNames == "function") merge(widget);
if (typeof file.getParamNames == "function") merge(file);
return result;
},

/**
* Implementation must create a com.zenesis.qx.upload.File or array of
* com.zenesis.qx.upload.File
*
*
* @param input
* {DOM} the DOM input[type=file]
* @return {com.zenesis.qx.upload.File|com.zenesis.qx.upload.File[]}
*/
_createFile: function(input) {
_createFile(input) {
/* abstract */
},

/**
* Called to do the real work of uploading the file
*
*
* @param file
* {com.zenesis.qx.upload.File}
*/
_doUpload: function(file) {
_doUpload(file) {
/* abstract */
},

/**
* Called to cancel the upload
*
*
* @param file
* {com.zenesis.qx.upload.File} file to cancel uploading
*/
_doCancel: function(file) {
_doCancel(file) {
/* abstract */
}

}
},
},
});
Loading

0 comments on commit 64a417a

Please sign in to comment.