diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c024e55 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +/.vscode/ +/node_modules/ +/qx_packages/ +/source/resource/ diff --git a/Manifest.json b/Manifest.json index 1a484e7..cb4306c 100644 --- a/Manifest.json +++ b/Manifest.json @@ -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" } } \ No newline at end of file diff --git a/compile.json b/compile.json index 20ecc37..cf8b10c 100644 --- a/compile.json +++ b/compile.json @@ -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": [ diff --git a/source/class/com/zenesis/qx/upload/AbstractHandler.js b/source/class/com/zenesis/qx/upload/AbstractHandler.js index 434d572..8c5bb2b 100644 --- a/source/class/com/zenesis/qx/upload/AbstractHandler.js +++ b/source/class/com/zenesis/qx/upload/AbstractHandler.js @@ -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 = []; @@ -52,8 +52,8 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", { check: "Integer", init: 5, nullable: false, - event: "changeMaxConnections" - } + event: "changeMaxConnections", + }, }, members: { @@ -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); @@ -95,23 +95,23 @@ 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); }, @@ -119,8 +119,11 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", { /** * 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); @@ -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); @@ -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) { @@ -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; @@ -212,25 +213,25 @@ 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 @@ -238,89 +239,88 @@ qx.Class.define("com.zenesis.qx.upload.AbstractHandler", { * @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 */ - } - - } + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/File.js b/source/class/com/zenesis/qx/upload/File.js index 314dc68..189b6e2 100644 --- a/source/class/com/zenesis/qx/upload/File.js +++ b/source/class/com/zenesis/qx/upload/File.js @@ -31,7 +31,7 @@ qx.Class.define("com.zenesis.qx.upload.File", { /** * Constructor - * + * * @param browserObject * {DOM} Anythign the AbstractHandler wants to store, typically an * input[type=file] or a File @@ -40,8 +40,8 @@ qx.Class.define("com.zenesis.qx.upload.File", { * @param id * {String} the unique id of the file */ - construct: function(browserObject, filename, id) { - this.base(arguments); + construct(browserObject, filename, id) { + super(); qx.core.Assert.assertNotNull(browserObject); qx.core.Assert.assertNotNull(filename); qx.core.Assert.assertNotNull(id); @@ -57,7 +57,7 @@ qx.Class.define("com.zenesis.qx.upload.File", { filename: { check: "String", nullable: false, - event: "changeFilename" + event: "changeFilename", }, /** @@ -66,7 +66,7 @@ qx.Class.define("com.zenesis.qx.upload.File", { id: { check: "String", nullable: false, - event: "changeId" + event: "changeId", }, /** @@ -76,7 +76,7 @@ qx.Class.define("com.zenesis.qx.upload.File", { check: "Integer", nullable: false, init: -1, - event: "changeSize" + event: "changeSize", }, /** @@ -86,18 +86,18 @@ qx.Class.define("com.zenesis.qx.upload.File", { check: "Integer", nullable: false, init: 0, - event: "changeProgress" + event: "changeProgress", }, /** * State of the file, re: uploading */ state: { - check: [ "not-started", "uploading", "cancelled", "uploaded" ], + check: ["not-started", "uploading", "cancelled", "uploaded"], nullable: false, init: "not-started", event: "changeState", - apply: "_applyState" + apply: "_applyState", }, /** @@ -107,7 +107,7 @@ qx.Class.define("com.zenesis.qx.upload.File", { init: null, nullable: true, check: "String", - event: "changeResponse" + event: "changeResponse", }, /** @@ -116,7 +116,7 @@ qx.Class.define("com.zenesis.qx.upload.File", { uploadWidget: { init: null, nullable: true, - event: "changeUploadWidget" + event: "changeUploadWidget", }, /** @@ -126,8 +126,8 @@ qx.Class.define("com.zenesis.qx.upload.File", { status: { init: null, nullable: true, - event: "changeStatus" - } + event: "changeStatus", + }, }, members: { @@ -136,58 +136,58 @@ qx.Class.define("com.zenesis.qx.upload.File", { /** * Sets a parameter value to be sent with the file - * + * * @param name * {String} name of the parameter * @param value * {String} the value of the parameter, or null to delete a * previous parameter */ - setParam: function(name, value) { - if (value !== null && typeof value != "string") - value = "" + value; - if (!this.__params) - this.__params = {}; + setParam(name, value) { + if (value !== null && typeof value != "string") value = "" + value; + if (!this.__params) this.__params = {}; this.__params[name] = value; }, /** * Returns a parameter value to be sent with the file - * + * * @param name {String} Name of the parameter * @returns {Boolean} */ - getParam: function(name) { + getParam(name) { return this.__params && this.__params[name]; }, /** * Returns a list of parameter names - * + * * @returns {Array} */ - getParamNames: function() { + getParamNames() { var result = []; - if (this.__params) - for ( var name in this.__params) - result.push(name); + if (this.__params) for (var name in this.__params) result.push(name); return result; }, /** * Returns the browser object - * + * * @returns {DOM} */ - getBrowserObject: function() { + getBrowserObject() { return this.__browserObject; }, // property apply - _applyState: function(value, oldValue) { - qx.core.Assert.assertTrue((!oldValue && value == "not-started") - || (oldValue == "not-started" && (value == "cancelled" || value == "uploading")) - || (oldValue == "uploading" && (value == "cancelled" || value == "uploaded"))); - } - } + _applyState(value, oldValue) { + qx.core.Assert.assertTrue( + (!oldValue && value == "not-started") || + (oldValue == "not-started" && + (value == "cancelled" || value == "uploading")) || + (oldValue == "uploading" && + (value == "cancelled" || value == "uploaded")) + ); + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/FormHandler.js b/source/class/com/zenesis/qx/upload/FormHandler.js index c7d30da..0a4aa06 100644 --- a/source/class/com/zenesis/qx/upload/FormHandler.js +++ b/source/class/com/zenesis/qx/upload/FormHandler.js @@ -37,38 +37,43 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { /* * @Override */ - addBlob: function (filename, blob, params) { - throw new Error("addBlob is not supported in the FormHandler."); + addBlob(filename, blob, params) { + throw new Error("addBlob is not supported in the FormHandler."); }, /* * @Override */ - _createFile: function(input) { - var id = "upload-" + this._getUniqueFileId(), filename = input.value.replace(/.*(\/|\\)/, ""), file = new com.zenesis.qx.upload.File( - input, filename, id); + _createFile(input) { + var id = "upload-" + this._getUniqueFileId(), + filename = input.value.replace(/.*(\/|\\)/, ""), + file = new com.zenesis.qx.upload.File(input, filename, id); return file; }, /* * @Override */ - _doUpload: function(file) { - var iframe = this._createIframe(file.getId()), form = this._createForm(iframe, file); + _doUpload(file) { + var iframe = this._createIframe(file.getId()), + form = this._createForm(iframe, file); form.appendChild(file.getBrowserObject()); var self = this; - qx.bom.Event.addNativeListener(iframe, "load", function(evt) { + qx.bom.Event.addNativeListener(iframe, "load", function (evt) { // when we remove iframe from dom the request stops, but in IE // load event fires - if (!iframe.parentNode) - return; + if (!iframe.parentNode) return; // fixing Opera 10.53 try { - if (iframe.contentDocument && iframe.contentDocument.body && iframe.contentDocument.body.innerHTML == "false") { + if ( + iframe.contentDocument && + iframe.contentDocument.body && + iframe.contentDocument.body.innerHTML == "false" + ) { // In Opera event is fired second time when body.innerHTML // changed from false // to server response approx. after 1 sec when we upload @@ -86,7 +91,7 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { self._onCompleted(file, response); // timeout added to fix busy state in FF3.6 - setTimeout(function() { + setTimeout(function () { iframe.parentNode.removeChild(iframe); form.parentNode.removeChild(form); }, 1); @@ -97,33 +102,34 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { /* * @Override */ - _doCancel: function(file) { + _doCancel(file) { var data = file.getUserData("com.zenesis.qx.upload.FormHandler"); - if (!data) - return; - var iframe = document.getElementById("upload-iframe-" + file.getId()), form = document.getElementById("upload-form-" - + file.getId()); + if (!data) return; + var iframe = document.getElementById("upload-iframe-" + file.getId()), + form = document.getElementById("upload-form-" + file.getId()); if (iframe != null) { // to cancel request set src to something else // we use src="javascript:false;" because it doesn't // trigger ie6 prompt on https - iframe.setAttribute('src', 'javascript:false;'); + iframe.setAttribute("src", "javascript:false;"); iframe.parentNode.removeChild(iframe); } - if (form != null) - form.parentNode.removeChild(form); + if (form != null) form.parentNode.removeChild(form); }, /** * Returns text received by iframe from server. - * + * * @return {String} */ - _getIframeContent: function(iframe) { + _getIframeContent(iframe) { try { // iframe.contentWindow.document - for IE<7 - var doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document, response = doc.body.innerHTML; + var doc = iframe.contentDocument + ? iframe.contentDocument + : iframe.contentWindow.document, + response = doc.body.innerHTML; // this.debug("response=" + response); return response; } catch (e) { @@ -135,10 +141,10 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { /** * Creates iframe with unique name - * + * * @return {DOMElement} the iframe */ - _createIframe: function(id) { + _createIframe(id) { // We can't use following code as the name attribute // won't be properly registered in IE6, and new window // on form submit will open @@ -147,14 +153,15 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { var iframe = qx.dom.Element.create("iframe", { src: "javascript:false;", // src="javascript:false;" removes ie6 - // prompt on https + // prompt on https name: id, - id: "upload-iframe-" + id + id: "upload-iframe-" + id, }); qx.bom.element.Style.setStyles(iframe, { - display: 'none' + display: "none", }); + document.body.appendChild(iframe); return iframe; @@ -162,10 +169,10 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { /** * Creates form, that will be submitted to iframe - * + * * @return {DOMElement} the form */ - _createForm: function(iframe, file) { + _createForm(iframe, file) { // We can't use the following code in IE6 // var form = document.createElement('form'); // form.setAttribute('method', 'post'); @@ -177,25 +184,26 @@ qx.Class.define("com.zenesis.qx.upload.FormHandler", { action: this._getUploader().getUploadUrl(), method: "POST", target: iframe.name, - id: "upload-form-" + file.getId() + id: "upload-form-" + file.getId(), }); qx.bom.element.Style.setStyles(form, { - display: 'none' + display: "none", }); + var params = this._getMergedParams(file); - for ( var name in params) { - var el = qx.dom.Element.create('input', { + for (var name in params) { + var el = qx.dom.Element.create("input", { type: "hidden", name: name, - value: params[name] + value: params[name], }); + form.appendChild(el); } document.body.appendChild(form); return form; - } - - } + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/InputElement.js b/source/class/com/zenesis/qx/upload/InputElement.js index f0e9e28..20e9729 100644 --- a/source/class/com/zenesis/qx/upload/InputElement.js +++ b/source/class/com/zenesis/qx/upload/InputElement.js @@ -1,7 +1,7 @@ qx.Class.define("com.zenesis.qx.upload.InputElement", { extend: qx.html.Element, - construct: function(widget, name) { + construct(widget, name) { // styling the input[type=file] // element is a bit tricky. Some browsers just ignore the normal // css style input. Firefox is especially tricky in this regard. @@ -19,82 +19,88 @@ qx.Class.define("com.zenesis.qx.upload.InputElement", { zIndex: widget.getZIndex() + 11, opacity: 0, // align to the top right hand corner - top: '0px', - right: '0px', + top: "0px", + right: "0px", // ff ignores the width setting pick a realy large font size to get // a huge button that covers the area of the upload button - fontFamily: 'Arial', + fontFamily: "Arial", // from valums.com/ajax-upload: 4 persons reported this, the max values // that worked for them were 243, 236, 236, 118 - fontSize: '118px' + fontSize: "118px", }; - if ((qx.core.Environment && qx.core.Environment.get('browser.name') == 'ie' && qx.core.Environment.get('browser.version') < 9) - || (!qx.core.Environment && qx.bom.client.Engine.MSHTML && qx.bom.client.Engine.VERSION < 9.0)) { - css.filter = 'alpha(opacity=0)'; - css.width = '200%'; - css.height = '100%'; + + if ( + (qx.core.Environment && + qx.core.Environment.get("browser.name") == "ie" && + qx.core.Environment.get("browser.version") < 9) || + (!qx.core.Environment && + qx.bom.client.Engine.MSHTML && + qx.bom.client.Engine.VERSION < 9.0) + ) { + css.filter = "alpha(opacity=0)"; + css.width = "200%"; + css.height = "100%"; } var attrs = { - type: 'file', - name: name, - title: ' ' - }; - this.base(arguments, 'input', css, attrs); - if (qx.Class.hasMixin(widget.constructor, com.zenesis.qx.upload.MUploadButton)) { - widget.bind("acceptUpload", this, "acceptUpload"); - widget.bind("multiple", this, "multiple"); - widget.bind("directory", this, "directory"); - } - this.__relatedWidget = widget; + type: "file", + name: name, + title: " ", + }; + + super("input", css, attrs); + if ( + qx.Class.hasMixin(widget.constructor, com.zenesis.qx.upload.MUploadButton) + ) { + widget.bind("acceptUpload", this, "acceptUpload"); + widget.bind("multiple", this, "multiple"); + widget.bind("directory", this, "directory"); + } + this.__relatedWidget = widget; }, properties: { - acceptUpload: { + acceptUpload: { init: null, nullable: true, check: "String", - apply: "_applyAcceptUpload" + apply: "_applyAcceptUpload", }, + multiple: { init: false, check: "Boolean", nullable: false, - apply: "_applyMultiple" + apply: "_applyMultiple", }, + directory: { init: false, check: "Boolean", nullable: false, - apply: "_applyDirectory" - } + apply: "_applyDirectory", + }, }, members: { __relatedWidget: null, - getWidget: function() { + getWidget() { return this.__relatedWidget; }, - _applyAcceptUpload: function(value) { - if (value) - this.setAttribute("accept", value, true); - else - this.removeAttribute("accept", true); + _applyAcceptUpload(value) { + if (value) this.setAttribute("accept", value, true); + else this.removeAttribute("accept", true); }, - _applyDirectory: function(value) { - if (value) - this.setAttribute("webkitdirectory", "webkitdirectory", true); - else - this.removeAttribute("webkitdirectory", true); + _applyDirectory(value) { + if (value) this.setAttribute("webkitdirectory", "webkitdirectory", true); + else this.removeAttribute("webkitdirectory", true); }, - - _applyMultiple: function(value) { - if (value) - this.setAttribute("multiple", "multiple", true); - else - this.removeAttribute("multiple", true); - } - } + + _applyMultiple(value) { + if (value) this.setAttribute("multiple", "multiple", true); + else this.removeAttribute("multiple", true); + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/MParameters.js b/source/class/com/zenesis/qx/upload/MParameters.js index 2c96102..cc780a5 100644 --- a/source/class/com/zenesis/qx/upload/MParameters.js +++ b/source/class/com/zenesis/qx/upload/MParameters.js @@ -31,42 +31,38 @@ qx.Mixin.define("com.zenesis.qx.upload.MParameters", { /** * Sets a parameter value to be sent with the file - * + * * @param name * {String} name of the parameter * @param value * {String} the value of the parameter, or null to delete a * previous parameter */ - setParam: function(name, value) { - if (value !== null && typeof value != "string") - value = "" + value; - if (!this.__params) - this.__params = {}; + setParam(name, value) { + if (value !== null && typeof value != "string") value = "" + value; + if (!this.__params) this.__params = {}; this.__params[name] = value; }, /** * Returns a parameter value to be sent with the file - * + * * @param name {String} Name of the parameter * @returns {Boolean} */ - getParam: function(name) { + getParam(name) { return this.__params && this.__params[name]; }, /** * Returns a list of parameter names - * + * * @returns {Array} */ - getParamNames: function() { + getParamNames() { var result = []; - if (this.__params) - for ( var name in this.__params) - result.push(name); + if (this.__params) for (var name in this.__params) result.push(name); return result; - } - } + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/MUploadButton.js b/source/class/com/zenesis/qx/upload/MUploadButton.js index 39b11c1..c540d3d 100644 --- a/source/class/com/zenesis/qx/upload/MUploadButton.js +++ b/source/class/com/zenesis/qx/upload/MUploadButton.js @@ -1,4 +1,3 @@ - /* *********************************************************************** UploadMgr - provides an API for uploading one or multiple files @@ -28,28 +27,29 @@ * qx.ui.core.Widget must not be fired. */ qx.Mixin.define("com.zenesis.qx.upload.MUploadButton", { - include: [ com.zenesis.qx.upload.MParameters ], - + include: [com.zenesis.qx.upload.MParameters], + properties: { - /** - * File types which are acceptable for upload; note that this is not guaranteed - * because not all (older) browsers support it, but where available it will - * restrict the file open dialog to only allow these file types. - * - * This value is passed directly through to the input tag's accept attribute, so - * the format can be seen here: {@link http://www.w3schools.com/tags/att_input_accept.asp}; - * in summary, it is a comma separated list of file extensions (with the dot) and/or - * MIME types; EG: - * - * .jpg,.png,.gif -- Images - * image/*,.mp4 -- Images and *.mp4 - */ + /** + * File types which are acceptable for upload; note that this is not guaranteed + * because not all (older) browsers support it, but where available it will + * restrict the file open dialog to only allow these file types. + * + * This value is passed directly through to the input tag's accept attribute, so + * the format can be seen here: {@link http://www.w3schools.com/tags/att_input_accept.asp}; + * in summary, it is a comma separated list of file extensions (with the dot) and/or + * MIME types; EG: + * + * .jpg,.png,.gif -- Images + * image/*,.mp4 -- Images and *.mp4 + */ acceptUpload: { - init: null, - nullable: true, - check: "String", - event: "changeAcceptUpload" - }, + init: null, + nullable: true, + check: "String", + event: "changeAcceptUpload", + }, + /** * Whether to support multiple files (default=true); this is not supported * on older browsers @@ -58,8 +58,9 @@ qx.Mixin.define("com.zenesis.qx.upload.MUploadButton", { check: "Boolean", init: false, nullable: false, - event: "changeMultiple" + event: "changeMultiple", }, + /** * Whether to support directories only (default=false); this is not supported * on older browsers @@ -68,19 +69,19 @@ qx.Mixin.define("com.zenesis.qx.upload.MUploadButton", { check: "Boolean", init: false, nullable: false, - event: "changeDirectory" - } + event: "changeDirectory", + }, }, members: { // overridden - capture: function() { + capture() { // Nothing }, // overridden - releaseCapture: function() { + releaseCapture() { // Nothing - } - } -}); \ No newline at end of file + }, + }, +}); diff --git a/source/class/com/zenesis/qx/upload/UploadButton.js b/source/class/com/zenesis/qx/upload/UploadButton.js index 4e14c9c..2cdbb0a 100644 --- a/source/class/com/zenesis/qx/upload/UploadButton.js +++ b/source/class/com/zenesis/qx/upload/UploadButton.js @@ -26,9 +26,7 @@ */ qx.Class.define("com.zenesis.qx.upload.UploadButton", { extend: qx.ui.form.Button, - include: [ com.zenesis.qx.upload.MUploadButton ], + include: [com.zenesis.qx.upload.MUploadButton], - members: { - - } -}); \ No newline at end of file + members: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/UploadMenuButton.js b/source/class/com/zenesis/qx/upload/UploadMenuButton.js index 0c4d7c7..e7d2968 100644 --- a/source/class/com/zenesis/qx/upload/UploadMenuButton.js +++ b/source/class/com/zenesis/qx/upload/UploadMenuButton.js @@ -26,8 +26,7 @@ */ qx.Class.define("com.zenesis.qx.upload.UploadMenuButton", { extend: qx.ui.menu.Button, - include: [ com.zenesis.qx.upload.MUploadButton ], + include: [com.zenesis.qx.upload.MUploadButton], - members: { - } -}); \ No newline at end of file + members: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/UploadMgr.js b/source/class/com/zenesis/qx/upload/UploadMgr.js index 8a1d501..d103f12 100644 --- a/source/class/com/zenesis/qx/upload/UploadMgr.js +++ b/source/class/com/zenesis/qx/upload/UploadMgr.js @@ -25,23 +25,21 @@ * Manages uploading of files to the server; this class can use any suitable * widget to attach the input[type=file] to, provided the widget includes * com.zenesis.qx.upload.MUploadButton. - * + * * Uploader will use XhrHandler to upload via XMLHttpRequest if supported or * will fall back to FormHandler. - * + * * @require(qx.event.handler.Input) */ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { extend: qx.core.Object, - include: [ com.zenesis.qx.upload.MParameters ], + include: [com.zenesis.qx.upload.MParameters], - construct: function(widget, uploadUrl) { - this.base(arguments); + construct(widget, uploadUrl) { + super(); this.__widgetsData = {}; - if (widget) - this.addWidget(widget); - if (uploadUrl) - this.setUploadUrl(uploadUrl); + if (widget) this.addWidget(widget); + if (uploadUrl) this.setUploadUrl(uploadUrl); }, events: { @@ -49,25 +47,25 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { * Fired when a file is added to the queue; data is the * com.zenesis.qx.upload.File */ - "addFile": "qx.event.type.Data", + addFile: "qx.event.type.Data", /** * Fired when a file starts to be uploaded; data is the * com.zenesis.qx.upload.File */ - "beginUpload": "qx.event.type.Data", + beginUpload: "qx.event.type.Data", /** * Fired when a file has been uploaded; data is the * com.zenesis.qx.upload.File */ - "completeUpload": "qx.event.type.Data", + completeUpload: "qx.event.type.Data", /** * Fired when a file upload has been cancelled; data is the * com.zenesis.qx.upload.File */ - "cancelUpload": "qx.event.type.Data" + cancelUpload: "qx.event.type.Data", }, properties: { @@ -78,7 +76,7 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { check: "String", nullable: false, init: "", - event: "changeUploadUrl" + event: "changeUploadUrl", }, /** @@ -90,7 +88,7 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { init: true, nullable: false, event: "changeAutoUpload", - apply: "_applyAutoUpload" + apply: "_applyAutoUpload", }, /** @@ -103,7 +101,7 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { nullable: false, event: "changeMultiple", apply: "_applyMultiple", - event: "changeMultiple" + event: "changeMultiple", }, directory: { @@ -111,7 +109,7 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { check: "Boolean", nullable: false, apply: "_applyDirectory", - event: "changeDirectory" + event: "changeDirectory", }, /** @@ -121,7 +119,7 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { check: "String", init: "uploadMgrInput", nullable: false, - event: "changeInputNamePrefix" + event: "changeInputNamePrefix", }, /** @@ -132,8 +130,8 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { init: true, nullable: false, event: "changeRequireMultipartFormData", - apply: "_applyRequireMultipartFormData" - } + apply: "_applyRequireMultipartFormData", + }, }, members: { @@ -147,161 +145,187 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { * typically be an instance of com.zenesis.qx.upload.UploadButton (see * com.zenesis.qx.upload.MUploadButton for implementing for other widgets) */ - addWidget: function(widget) { - var appearId = widget.addListenerOnce("appear", function(evt) { - var data = this.__widgetsData[widget.toHashCode()]; - if (data) { - data.appearId = null; - var container = widget.getContentElement(); - container.setStyle("overflow", "hidden"); - if (widget.getEnabled() && !data.inputElement) - container.addAt(this._createInputElement(widget), 0); - this.__fixupSize(widget); - } - }, this); + addWidget(widget) { + var appearId = widget.addListenerOnce( + "appear", + function (evt) { + var data = this.__widgetsData[widget.toHashCode()]; + if (data) { + data.appearId = null; + var container = widget.getContentElement(); + container.setStyle("overflow", "hidden"); + if (widget.getEnabled() && !data.inputElement) + container.addAt(this._createInputElement(widget), 0); + this.__fixupSize(widget); + } + }, + this + ); var keydownId = null; if (qx.core.Environment.get("engine.name") != "gecko") { - keydownId = widget.addListener("keydown", function(evt) { - var data = this.__widgetsData[widget.toHashCode()]; - if (data && data.inputElement) { - var dom = data.inputElement.getDomElement(); - if (dom && typeof dom.click == "function") { - // dom.focus(); - dom.click(); + keydownId = widget.addListener( + "keydown", + function (evt) { + var data = this.__widgetsData[widget.toHashCode()]; + if (data && data.inputElement) { + var dom = data.inputElement.getDomElement(); + if (dom && typeof dom.click == "function") { + // dom.focus(); + dom.click(); + } } - } - }, this); + }, + this + ); } this.__widgetsData[widget.toHashCode()] = { appearId: appearId, keydownId: keydownId, widget: widget, - inputElement: null + inputElement: null, }; - widget.addListener("resize", function(evt) { - this.__fixupSize(widget); - }, this); - widget.addListener("changeEnabled", function(evt) { - if (evt.getData()) { - var container = widget.getContentElement(); - container.addAt(this._createInputElement(widget), 0); - } else { - this._removeInputElement(widget); - } - }, this); - if (qx.Class.hasMixin(widget.constructor, com.zenesis.qx.upload.MUploadButton)) { - this.bind("multiple", widget, "multiple"); - this.bind("directory", widget, "directory"); - } - + + widget.addListener( + "resize", + function (evt) { + this.__fixupSize(widget); + }, + this + ); + widget.addListener( + "changeEnabled", + function (evt) { + if (evt.getData()) { + var container = widget.getContentElement(); + container.addAt(this._createInputElement(widget), 0); + } else { + this._removeInputElement(widget); + } + }, + this + ); + if ( + qx.Class.hasMixin( + widget.constructor, + com.zenesis.qx.upload.MUploadButton + ) + ) { + this.bind("multiple", widget, "multiple"); + this.bind("directory", widget, "directory"); + } }, /** * Removes a widget - * + * * @param widget {qx.ui.core.Widget} Widget to remvove */ - removeWidget: function(widget) { + removeWidget(widget) { var data = this.__widgetsData[widget.toHashCode()]; if (data) { - if (data.appearId) - widget.removeListener(data.appearId); - if (data.keydownId) - widget.removeListener(data.keydownId); + if (data.appearId) widget.removeListener(data.appearId); + if (data.keydownId) widget.removeListener(data.keydownId); delete this.__widgetsData[widget.toHashCode()]; } }, - + /** - * Adds a blob to the upload list - * + * Adds a blob to the upload list + * * @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) { this.getUploadHandler().addBlob(filename, blob, params); - if (this.getAutoUpload()) - this.getUploadHandler().beginUploads(); + if (this.getAutoUpload()) this.getUploadHandler().beginUploads(); }, - + /** * Helper method that corrects the size of the input element to match the * size of the widget - * + * * @param widget {qx.ui.core.Widget} Widget to fixup size */ - __fixupSize: function(widget) { + __fixupSize(widget) { var data = this.__widgetsData[widget.toHashCode()]; if (data && data.inputElement) { var bounds = widget.getBounds(); // It may be that if the widgets icon is styled // through a theme, neither label nor icon are set yet. // In this situation bounds calculation would fail. - if(bounds) { + if (bounds) { data.inputElement.setStyles({ width: bounds.width + "px", - height: bounds.height + "px" + height: bounds.height + "px", }); } } }, // property apply - _applyAutoUpload: function(value, oldValue) { + _applyAutoUpload(value, oldValue) { this.getUploadHandler().beginUploads(); }, // property apply - _applyMultiple: function(value, oldValue) { - for ( var hash in this.__widgetsData) { + _applyMultiple(value, oldValue) { + for (var hash in this.__widgetsData) { var data = this.__widgetsData[hash]; - if (data.inputElement) - data.inputElement.setMultiple(value); + if (data.inputElement) data.inputElement.setMultiple(value); } }, // property directory - _applyDirectory: function(value, oldValue) { - for ( var hash in this.__widgetsData) { + _applyDirectory(value, oldValue) { + for (var hash in this.__widgetsData) { var data = this.__widgetsData[hash]; - if (data.inputElement) - data.inputElement.setDirectory(value); + if (data.inputElement) data.inputElement.setDirectory(value); } }, // property apply - _applyRequireMultipartFormData: function(value, oldValue) { + _applyRequireMultipartFormData(value, oldValue) { if (this.__uploadHandler) - throw new Error("Changing the requireMultipartFormData property of " + this + " has no effect once uploads have started"); + throw new Error( + "Changing the requireMultipartFormData property of " + + this + + " has no effect once uploads have started" + ); }, /** * Cancels a file being uploaded - * + * * @param file {String} Upload to cancel */ - cancel: function(file) { + cancel(file) { this.getUploadHandler().cancel(file); }, /** * Cancels all files being uploaded */ - cancelAll: function() { + cancelAll() { this.getUploadHandler().cancelAll(); }, /** * Creates the input[type=file] element - * + * * @returns */ - _createInputElement: function(widget) { + _createInputElement(widget) { var data = this.__widgetsData[widget.toHashCode()]; - var name = this.getInputNamePrefix() + '-' + (++this.__inputSerial); + var name = this.getInputNamePrefix() + "-" + ++this.__inputSerial; qx.core.Assert.assertNull(data.inputElement); - var elem = data.inputElement = new com.zenesis.qx.upload.InputElement(widget, name); - elem.addListenerOnce("change", qx.lang.Function.bind(this._onInputChange, this, elem)); + var elem = (data.inputElement = new com.zenesis.qx.upload.InputElement( + widget, + name + )); + elem.addListenerOnce( + "change", + qx.lang.Function.bind(this._onInputChange, this, elem) + ); return elem; }, @@ -309,20 +333,19 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { * Removes the input element - ie discards the current one (which presumably * has already been queued for uploading) */ - _removeInputElement: function(widget) { + _removeInputElement(widget) { var data = this.__widgetsData[widget.toHashCode()]; var elem = data.inputElement; var container = widget.getContentElement(); data.inputElement = null; - if (elem) - container.remove(elem); + if (elem) container.remove(elem); }, /** * Resets the input element - ie discards the current one (which presumably * has already been queued for uploading) and creates a new one */ - _resetInputElement: function(widget) { + _resetInputElement(widget) { this._removeInputElement(widget); var container = widget.getContentElement(); container.addAt(this._createInputElement(widget), 0); @@ -331,40 +354,42 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { /** * Callback for changes to the input[ty=file]'s value, ie this is called * when the user has selected a file to upload - * + * * @param elem {Element} Element which is affected * @param evt {Event} Event data */ - _onInputChange: function(elem, evt) { + _onInputChange(elem, evt) { var widget = elem.getWidget(); this.getUploadHandler().addFile(elem.getDomElement(), widget); - if (this.getAutoUpload()) - this.getUploadHandler().beginUploads(); + if (this.getAutoUpload()) this.getUploadHandler().beginUploads(); this._resetInputElement(widget); }, /** * Returns the upload handler - * + * * @returns */ - getUploadHandler: function() { + getUploadHandler() { if (!this.__uploadHandler) { - if (com.zenesis.qx.upload.XhrHandler.isSupported(this.isRequireMultipartFormData())) + if ( + com.zenesis.qx.upload.XhrHandler.isSupported( + this.isRequireMultipartFormData() + ) + ) this.__uploadHandler = new com.zenesis.qx.upload.XhrHandler(this); - else - this.__uploadHandler = new com.zenesis.qx.upload.FormHandler(this); + else this.__uploadHandler = new com.zenesis.qx.upload.FormHandler(this); } return this.__uploadHandler; }, /** * Sets the upload handler - * + * * @param elem {AbstractHandler} The upload handler */ - setUploadHandler: function(handler) { + setUploadHandler(handler) { this.__uploadHandler = handler; }, @@ -372,9 +397,8 @@ qx.Class.define("com.zenesis.qx.upload.UploadMgr", { * Allocates a new upload ID; this is just a unique number that widgets or * application code can use to uniquely identify themselves to the server */ - allocateUploadId: function() { - return "uploadId:" + (++this.__uploadId); - } - - } + allocateUploadId() { + return "uploadId:" + ++this.__uploadId; + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/UploadToolbarButton.js b/source/class/com/zenesis/qx/upload/UploadToolbarButton.js index f424941..a51d026 100644 --- a/source/class/com/zenesis/qx/upload/UploadToolbarButton.js +++ b/source/class/com/zenesis/qx/upload/UploadToolbarButton.js @@ -26,9 +26,7 @@ */ qx.Class.define("com.zenesis.qx.upload.UploadToolbarButton", { extend: qx.ui.toolbar.Button, - include: [ com.zenesis.qx.upload.MUploadButton ], + include: [com.zenesis.qx.upload.MUploadButton], - members: { - - } -}); \ No newline at end of file + members: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/XhrHandler.js b/source/class/com/zenesis/qx/upload/XhrHandler.js index c303070..27da3c3 100644 --- a/source/class/com/zenesis/qx/upload/XhrHandler.js +++ b/source/class/com/zenesis/qx/upload/XhrHandler.js @@ -32,7 +32,7 @@ /** * Implementation of AbstractHandler that uses XMLHttpRequest; this is based on * work at http://valums.com/ajax-upload/. - * + * * Call com.zenesis.qx.upload.XhrHandler.isSupported() to check whether this * class can be used (otherwise use FormHandler) */ @@ -40,27 +40,25 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { extend: com.zenesis.qx.upload.AbstractHandler, members: { - /* * @Override */ - addBlob: function (filename, blob, params){ - var id = "upload-" + this._getUniqueFileId(); - var file = new com.zenesis.qx.upload.File(blob, filename, id); - if (params) { - for (var name in params) { - var value = params[name]; - if (value !== null) - file.setParam(name, value); + addBlob(filename, blob, params) { + var id = "upload-" + this._getUniqueFileId(); + var file = new com.zenesis.qx.upload.File(blob, filename, id); + if (params) { + for (var name in params) { + var value = params[name]; + if (value !== null) file.setParam(name, value); + } } - } - this._addFile(file); + this._addFile(file); }, - + /* * @Override */ - _createFile: function(input) { + _createFile(input) { var bomFiles = input.files; if (!bomFiles || !bomFiles.length) this.debug("No files found to upload via XhrHandler"); @@ -69,9 +67,11 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { for (var i = 0; i < bomFiles.length; i++) { var bomFile = bomFiles[i]; var id = "upload-" + this._getUniqueFileId(); - var filename = typeof bomFile.name != "undefined" ? bomFile.name : bomFile.fileName; + var filename = + typeof bomFile.name != "undefined" ? bomFile.name : bomFile.fileName; var file = new com.zenesis.qx.upload.File(bomFile, filename, id); - var fileSize = typeof bomFile.size != "undefined" ? bomFile.size : bomFile.fileSize; + var fileSize = + typeof bomFile.size != "undefined" ? bomFile.size : bomFile.fileSize; file.setSize(fileSize); files.push(file); } @@ -82,7 +82,7 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { /* * @Override */ - _doUpload: function(file) { + _doUpload(file) { function sendAsMime(binaryData) { body += binaryData + "\r\n"; body += "--" + boundary + "--"; @@ -90,15 +90,18 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { xhr.open("POST", action, true); setRequestHeader("X-Requested-With", "XMLHttpRequest"); setRequestHeader("X-File-Name", encodeURIComponent(file.getFilename())); - setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary); + setRequestHeader( + "Content-Type", + "multipart/form-data; boundary=" + boundary + ); xhr.send(body); } - + function setRequestHeader(name, value) { - xhr.setRequestHeader(name, value); - headerLength += name.length + 2 + value.length + 1; + xhr.setRequestHeader(name, value); + headerLength += name.length + 2 + value.length + 1; } - + /* * The upload progress includes the size of the headers, but we cannot ask XMLHttpRequest what the * headers were so we count the headers we set and also add these below. This is never going to be @@ -106,22 +109,24 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { */ var headerLength = 0; var DEFAULT_HEADERS = { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "en,en-US;q=0.8", - "Cache-Control": "no-cache", - "Connection": "keep-alive", - "Content-Length": "" + file.getSize(), - "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryTfptZDRmE8C3dZmW", - "Host": document.location.host, - "Pragma": "no-cache", - "Referer": document.location.href, - "User-Agent": navigator.userAgent + Accept: "*/*", + "Accept-Encoding": "gzip, deflate", + "Accept-Language": "en,en-US;q=0.8", + "Cache-Control": "no-cache", + Connection: "keep-alive", + "Content-Length": "" + file.getSize(), + "Content-Type": + "multipart/form-data; boundary=----WebKitFormBoundaryTfptZDRmE8C3dZmW", + Host: document.location.host, + Pragma: "no-cache", + Referer: document.location.href, + "User-Agent": navigator.userAgent, }; + if (document.location.origin) DEFAULT_HEADERS.Origin = document.location.origin; for (var key in DEFAULT_HEADERS) - headerLength += DEFAULT_HEADERS[key].length + 1; + headerLength += DEFAULT_HEADERS[key].length + 1; var xhr = new XMLHttpRequest(); if (com.zenesis.qx.upload.XhrHandler.isWithCredentials()) @@ -131,15 +136,24 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { file.setUserData("com.zenesis.qx.upload.XhrHandler", xhr); - xhr.upload.onprogress = function(e) { - self.debug("onprogress: lengthComputable=" + e.lengthComputable + ", total=" + e.total + ", loaded=" + e.loaded + ", headerLength=" + headerLength); + xhr.upload.onprogress = function (e) { + self.debug( + "onprogress: lengthComputable=" + + e.lengthComputable + + ", total=" + + e.total + + ", loaded=" + + e.loaded + + ", headerLength=" + + headerLength + ); if (e.lengthComputable) { file.setSize(e.total - headerLength); file.setProgress(e.loaded - headerLength); } }; - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (xhr.readyState == 4) { var response = xhr.responseText; // self.debug("xhr server status=" + xhr.status + ", responseText=" + @@ -164,25 +178,33 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { setRequestHeader("X-Requested-With", "XMLHttpRequest"); setRequestHeader("X-File-Name", encodeURIComponent(file.getFilename())); xhr.send(fd); - } else { var browserFile = file.getBrowserObject(); - var boundary = "--------FormData" + Math.random(), body = "", action = this._getUploader().getUploadUrl(), params = this - ._getMergedParams(file); - for ( var name in params) { + var boundary = "--------FormData" + Math.random(), + body = "", + action = this._getUploader().getUploadUrl(), + params = this._getMergedParams(file); + for (var name in params) { body += "--" + boundary + "\r\n"; - body += "Content-Disposition: form-data; name=\"" + name + "\";\r\n\r\n"; + body += + 'Content-Disposition: form-data; name="' + name + '";\r\n\r\n'; body += params[name] + "\r\n"; } body += "--" + boundary + "\r\n"; - body += "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getFilename() + "\"\r\n"; - body += "Content-Type: " + (browserFile.type || "application/octet-stream") + "\r\n\r\n"; + body += + 'Content-Disposition: form-data; name="file"; filename="' + + file.getFilename() + + '"\r\n'; + body += + "Content-Type: " + + (browserFile.type || "application/octet-stream") + + "\r\n\r\n"; if (typeof browserFile.getAsBinary == "function") { sendAsMime(browserFile.getAsBinary()); } else { var reader = new FileReader(); - reader.onload = function(evt) { + reader.onload = function (evt) { sendAsMime(evt.target.result); }; reader.readAsBinaryString(browserFile); @@ -193,13 +215,13 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { /* * @Override */ - _doCancel: function(file) { + _doCancel(file) { var xhr = file.getUserData("com.zenesis.qx.upload.XhrHandler"); if (xhr) { xhr.abort(); file.setUserData("com.zenesis.qx.upload.XhrHandler", null); } - } + }, }, statics: { @@ -207,14 +229,17 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { /** * Detects whether this handler is support on the current browser - * + * * @returns {Boolean} */ - isSupported: function(requireMultipartFormData) { - var input = document.createElement('input'); - input.type = 'file'; + isSupported(requireMultipartFormData) { + var input = document.createElement("input"); + input.type = "file"; - var isSupported = 'multiple' in input && typeof File != "undefined" && typeof (new XMLHttpRequest()).upload != "undefined"; + var isSupported = + "multiple" in input && + typeof File != "undefined" && + typeof new XMLHttpRequest().upload != "undefined"; return isSupported; }, @@ -223,7 +248,7 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { * Whether to set XMLHttpRequest.withCredentials (used for CORS uploads wth * cookies) */ - setWithCredentials: function(value) { + setWithCredentials(value) { this.__withCredentials = true; }, @@ -231,8 +256,8 @@ qx.Class.define("com.zenesis.qx.upload.XhrHandler", { * Whether to set XMLHttpRequest.withCredentials (used for CORS uploads wth * cookies) */ - isWithCredentials: function() { + isWithCredentials() { return this.__withCredentials; - } - } + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/ZipHandler.js b/source/class/com/zenesis/qx/upload/ZipHandler.js index c969b42..0744281 100644 --- a/source/class/com/zenesis/qx/upload/ZipHandler.js +++ b/source/class/com/zenesis/qx/upload/ZipHandler.js @@ -30,37 +30,35 @@ qx.Class.define("com.zenesis.qx.upload.ZipHandler", { extend: com.zenesis.qx.upload.AbstractHandler, - construct: function(uploader) { - this.base(arguments, uploader); + construct(uploader) { + super(uploader); this.__zip = new JSZip(); }, members: { - generateAsync: function(options, onUpdate) { - return this.__zip.generateAsync(options, onUpdate); - }, - + generateAsync(options, onUpdate) { + return this.__zip.generateAsync(options, onUpdate); + }, + /* * @Override */ - addBlob: function (filename, blob, params){ - var id = "upload-" + this._getUniqueFileId(); - var file = new com.zenesis.qx.upload.File(blob, filename, id); - if (params) { - for (var name in params) { - var value = params[name]; - if (value !== null) - file.setParam(name, value); + addBlob(filename, blob, params) { + var id = "upload-" + this._getUniqueFileId(); + var file = new com.zenesis.qx.upload.File(blob, filename, id); + if (params) { + for (var name in params) { + var value = params[name]; + if (value !== null) file.setParam(name, value); + } } - } - this._addFile(file); + this._addFile(file); }, - - + /* * @Override */ - _createFile: function(input) { + _createFile(input) { var bomFiles = input.files; if (!bomFiles || !bomFiles.length) this.debug("No files found to upload via ZipHandler"); @@ -69,9 +67,11 @@ qx.Class.define("com.zenesis.qx.upload.ZipHandler", { for (var i = 0; i < bomFiles.length; i++) { var bomFile = bomFiles[i]; var id = "upload-" + this._getUniqueFileId(); - var filename = typeof bomFile.name != "undefined" ? bomFile.name : bomFile.fileName; + var filename = + typeof bomFile.name != "undefined" ? bomFile.name : bomFile.fileName; var file = new com.zenesis.qx.upload.File(bomFile, filename, id); - var fileSize = typeof bomFile.size != "undefined" ? bomFile.size : bomFile.fileSize; + var fileSize = + typeof bomFile.size != "undefined" ? bomFile.size : bomFile.fileSize; file.setSize(fileSize); files.push(file); } @@ -81,18 +81,18 @@ qx.Class.define("com.zenesis.qx.upload.ZipHandler", { /* * @Override */ - _doUpload: function(file) { - this.__zip.file(file.getFilename(), file.getBrowserObject()); - this._onCompleted(file, "add to zip"); - + _doUpload(file) { + this.__zip.file(file.getFilename(), file.getBrowserObject()); + this._onCompleted(file, "add to zip"); }, /* * @Override */ - _doCancel: function(file) { -1 }, + _doCancel(file) { + 1; + }, - __zip: null - } + __zip: null, + }, }); diff --git a/source/class/com/zenesis/qx/upload/demo/Application.js b/source/class/com/zenesis/qx/upload/demo/Application.js index 2d2eba1..a098f6d 100644 --- a/source/class/com/zenesis/qx/upload/demo/Application.js +++ b/source/class/com/zenesis/qx/upload/demo/Application.js @@ -24,7 +24,7 @@ /** * This is the main application class of your custom application * "com.zenesis.qx.upload" - * + * * @asset(com/zenesis/qx/upload/*) * @asset(qx/icon/Oxygen/22/actions/*) * @@ -44,12 +44,12 @@ qx.Class.define("com.zenesis.qx.upload.demo.Application", { /** * This method contains the initial application code and gets called * during startup of the application - * + * * @lint ignoreDeprecated(alert) */ - main: function() { + main() { // Call super class - this.base(arguments); + super.main(); // Enable logging in debug variant if (qx.core.Environment.get("qx.debug")) { @@ -69,42 +69,57 @@ qx.Class.define("com.zenesis.qx.upload.demo.Application", { var doc = this.getRoot(); var root = new qx.ui.container.Composite(new qx.ui.layout.VBox()); doc.add(root, { left: 0, top: 0, right: 0, bottom: 0 }); - + // Header var header = new qx.ui.container.Composite(new qx.ui.layout.HBox()); root.add(header); - header.add(new qx.ui.basic.Image("com/zenesis/qx/upload/banner.png").set({ - padding: [ 0, 30 ] - })); - header.add(new qx.ui.basic.Label("UploadMgr
Contrib Demo").set({ - font: new qx.bom.Font(20, [ "Arial" ]), - padding: [ 22, 20 ], - textColor: "white", - allowGrowX: true, - rich: true, - textAlign: "center" - }), { - flex: 1 - }); + header.add( + new qx.ui.basic.Image("com/zenesis/qx/upload/banner.png").set({ + padding: [0, 30], + }) + ); + + header.add( + new qx.ui.basic.Label("UploadMgr
Contrib Demo").set({ + font: new qx.bom.Font(20, ["Arial"]), + padding: [22, 20], + textColor: "white", + allowGrowX: true, + rich: true, + textAlign: "center", + }), + { + flex: 1, + } + ); + header.add(new qx.ui.basic.Image("com/zenesis/qx/upload/logo.gif")); - header.setDecorator(new qx.ui.decoration.Decorator().set({ - backgroundImage: "com/zenesis/qx/upload/banner-bg.png", - backgroundPositionX: 0 - })); + header.setDecorator( + new qx.ui.decoration.Decorator().set({ + backgroundImage: "com/zenesis/qx/upload/banner-bg.png", + backgroundPositionX: 0, + }) + ); + + root.add( + new qx.ui.basic.Label( + "Written by John Spackman john.spackman@zenesis.com, (c) Zenesis Ltd http://www.zenesis.com" + ).set({ + rich: true, + font: new qx.bom.Font(13, ["Arial", "Lucida Grande"]), + textAlign: "center", + allowGrowX: true, + padding: [10, 0], + }) + ); - root.add(new qx.ui.basic.Label("Written by John Spackman john.spackman@zenesis.com, (c) Zenesis Ltd http://www.zenesis.com").set({ - rich: true, - font: new qx.bom.Font(13, [ "Arial", "Lucida Grande" ]), - textAlign: "center", - allowGrowX: true, - padding: [ 10, 0] - })); - - var body = new qx.ui.container.Composite(new qx.ui.layout.Canvas()); root.add(body); - var btn = new com.zenesis.qx.upload.UploadButton("btn 1 Add File(s)", "com/zenesis/qx/upload/test.png"); + var btn = new com.zenesis.qx.upload.UploadButton( + "btn 1 Add File(s)", + "com/zenesis/qx/upload/test.png" + ); var lst = new qx.ui.form.List(); var uploadCount = 0; @@ -115,8 +130,7 @@ qx.Class.define("com.zenesis.qx.upload.demo.Application", { var uploadUrl = "http://www.zenesis.com/UploadMgr/demoupload"; //var uploadUrl = "http://localhost:9090/demoupload"; var match = document.location.href.match(/uploadUrl=([^&]+)$/); - if (match) - uploadUrl = match[1]; + if (match) uploadUrl = match[1]; var uploader = new com.zenesis.qx.upload.UploadMgr(btn, uploadUrl); // Parameter tp be added to all uploads (can be overridden by @@ -127,81 +141,146 @@ qx.Class.define("com.zenesis.qx.upload.demo.Application", { // (default is 5) // uploader.getUploadHandler().setMaxConnections(1); - uploader.addListener("addFile", function(evt) { - var file = evt.getData(), item = new qx.ui.form.ListItem(file.getFilename() + " (queued for upload)", null, file); - lst.add(item); - - // Set a parameter - each uploaded file has their own set, which - // can override those set - // globally against the upload manager - ++uploadCount; - file.setParam("myParam_" + uploadCount, "test"); - if (uploadCount % 2 == 0) - file.setParam("myGlobalParam", "overridden-global-value"); - - // On modern browsers (ie not IE) we will get progress updates - var progressListenerId = file.addListener("changeProgress", function(evt) { - this.debug("Upload " + file.getFilename() + ": " + evt.getData() + " / " + file.getSize() + " - " - + Math.round(evt.getData() / file.getSize() * 100) + "%"); - item.setLabel(file.getFilename() + ": " + evt.getData() + " / " + file.getSize() + " - " - + Math.round(evt.getData() / file.getSize() * 100) + "%"); - }, this); - - // All browsers can at least get changes in state (ie - // "uploading", "cancelled", and "uploaded") - var stateListenerId = file.addListener("changeState", function(evt) { - var state = evt.getData(); - - this.debug(file.getFilename() + ": state=" + state + ", file size=" + file.getSize() + ", progress=" - + file.getProgress()); - - if (state == "uploading") - item.setLabel(file.getFilename() + " (Uploading...)"); - else if (state == "uploaded") - item.setLabel(file.getFilename() + " (Complete)"); - else if (state == "cancelled") - item.setLabel(file.getFilename() + " (Cancelled)"); - - if (state == "uploaded" || state == "cancelled") { - file.removeListenerById(stateListenerId); - } - - }, this); - - this.debug("Added file " + file.getFilename()); - }, this); + uploader.addListener( + "addFile", + function (evt) { + var file = evt.getData(), + item = new qx.ui.form.ListItem( + file.getFilename() + " (queued for upload)", + null, + file + ); + lst.add(item); + + // Set a parameter - each uploaded file has their own set, which + // can override those set + // globally against the upload manager + ++uploadCount; + file.setParam("myParam_" + uploadCount, "test"); + if (uploadCount % 2 == 0) + file.setParam("myGlobalParam", "overridden-global-value"); + + // On modern browsers (ie not IE) we will get progress updates + var progressListenerId = file.addListener( + "changeProgress", + function (evt) { + this.debug( + "Upload " + + file.getFilename() + + ": " + + evt.getData() + + " / " + + file.getSize() + + " - " + + Math.round((evt.getData() / file.getSize()) * 100) + + "%" + ); + item.setLabel( + file.getFilename() + + ": " + + evt.getData() + + " / " + + file.getSize() + + " - " + + Math.round((evt.getData() / file.getSize()) * 100) + + "%" + ); + }, + this + ); + + // All browsers can at least get changes in state (ie + // "uploading", "cancelled", and "uploaded") + var stateListenerId = file.addListener( + "changeState", + function (evt) { + var state = evt.getData(); + + this.debug( + file.getFilename() + + ": state=" + + state + + ", file size=" + + file.getSize() + + ", progress=" + + file.getProgress() + ); + + if (state == "uploading") + item.setLabel(file.getFilename() + " (Uploading...)"); + else if (state == "uploaded") + item.setLabel(file.getFilename() + " (Complete)"); + else if (state == "cancelled") + item.setLabel(file.getFilename() + " (Cancelled)"); + + if (state == "uploaded" || state == "cancelled") { + file.removeListenerById(stateListenerId); + } + }, + this + ); + + this.debug("Added file " + file.getFilename()); + }, + this + ); body.add(btn, { left: 50, - top: 0 + top: 0, }); + var cbx = new qx.ui.form.CheckBox("Multiple"); cbx.bind("value", btn, "multiple"); body.add(cbx, { left: 50, - top: 50 + top: 50, }); + cbx = new qx.ui.form.CheckBox("Directory"); cbx.bind("value", btn, "directory"); body.add(cbx, { left: 50, - top: 70 + top: 70, }); // Create a button to cancel the upload selected in the list - var btnCancel = new qx.ui.form.Button("Cancel upload", "qx/icon/Oxygen/22/actions/process-stop.png"); + var btnCancel = new qx.ui.form.Button( + "Cancel upload", + "qx/icon/Oxygen/22/actions/process-stop.png" + ); btnCancel.set({ - enabled: false + enabled: false, }); - lst.addListener("changeSelection", function(evt) { - var sel = evt.getData(), item = sel.length ? sel[0] : null, file = item ? item.getModel() : null; - btnCancel.setEnabled(file != null && (file.getState() == "uploading" || file.getState() == "not-started")); - }, this); - btnCancel.addListener("execute", function(evt) { - var sel = lst.getSelection(), item = sel[0], file = item.getModel(); - if (file.getState() == "uploading" || file.getState() == "not-started") - uploader.cancel(file); - }, this); + + lst.addListener( + "changeSelection", + function (evt) { + var sel = evt.getData(), + item = sel.length ? sel[0] : null, + file = item ? item.getModel() : null; + btnCancel.setEnabled( + file != null && + (file.getState() == "uploading" || + file.getState() == "not-started") + ); + }, + this + ); + btnCancel.addListener( + "execute", + function (evt) { + var sel = lst.getSelection(), + item = sel[0], + file = item.getModel(); + if ( + file.getState() == "uploading" || + file.getState() == "not-started" + ) + uploader.cancel(file); + }, + this + ); // Auto upload? (default=true) cbx = new qx.ui.form.CheckBox("Automatically Upload"); @@ -209,92 +288,117 @@ qx.Class.define("com.zenesis.qx.upload.demo.Application", { cbx.bind("value", uploader, "autoUpload"); body.add(cbx, { left: 200, - top: 0 + top: 0, }); - + lst.set({ - width: 500 + width: 500, }); + body.add(lst, { left: 200, - top: 20 + top: 20, }); + body.add(btnCancel, { left: 720, - top: 0 + top: 0, }); // Descriptions var descs = new qx.ui.container.Composite(new qx.ui.layout.VBox()); body.add(descs, { left: 100, top: 210 }); - - descs.add(new qx.ui.basic.Label( + + descs.add( + new qx.ui.basic.Label( "This is a demo for the Qooxdoo UploadMgr contrib which can be found at " + - "https://github.com/johnspackman/UploadMgr; " + - "UploadMgr supports background uploads with progress feedback for modern browsers with fallback for " + - "older browsers (eg IE6-IE8).") - .set({ - rich: true, - width: 700, - margin: [ 8, 0 ] - })); - descs.add(new qx.ui.basic.Label( - "Upload Destination: This application will upload to " + uploadUrl + " - you can change that by " + - "editing the Application.js or adding \"?uploadUrl=\" to the URL.") - .set({ - rich: true, - width: 700, - margin: [ 8, 0 ] - })); - - descs.add(new qx.ui.basic.Label( - "Update:: You can now have multiple upload buttons per UploadMgr instance - below are a few extra upload buttons for testing.") - .set({ - rich: true, - width: 700, - margin: [ 8, 0 ] - })); - - btn = new com.zenesis.qx.upload.UploadButton("btn 2 Add File(s)", "com/zenesis/qx/upload/test.png"); + "https://github.com/johnspackman/UploadMgr; " + + "UploadMgr supports background uploads with progress feedback for modern browsers with fallback for " + + "older browsers (eg IE6-IE8)." + ).set({ + rich: true, + width: 700, + margin: [8, 0], + }) + ); + + descs.add( + new qx.ui.basic.Label( + "Upload Destination: This application will upload to " + + uploadUrl + + " - you can change that by " + + 'editing the Application.js or adding "?uploadUrl=" to the URL.' + ).set({ + rich: true, + width: 700, + margin: [8, 0], + }) + ); + + descs.add( + new qx.ui.basic.Label( + "Update:: You can now have multiple upload buttons per UploadMgr instance - below are a few extra upload buttons for testing." + ).set({ + rich: true, + width: 700, + margin: [8, 0], + }) + ); + + btn = new com.zenesis.qx.upload.UploadButton( + "btn 2 Add File(s)", + "com/zenesis/qx/upload/test.png" + ); uploader.addWidget(btn); body.add(btn, { left: 100, - top: 345 + top: 345, }); - btn = new com.zenesis.qx.upload.UploadButton("Add Image or *.mp4 File(s)", "com/zenesis/qx/upload/test.png"); - btn.set({ acceptUpload: ".png,.mp4"}) + + btn = new com.zenesis.qx.upload.UploadButton( + "Add Image or *.mp4 File(s)", + "com/zenesis/qx/upload/test.png" + ); + btn.set({ acceptUpload: ".png,.mp4" }); uploader.addWidget(btn); body.add(btn, { left: 250, - top: 345 + top: 345, }); - var btnDisabled = new com.zenesis.qx.upload.UploadButton("Add File(s)", "com/zenesis/qx/upload/test.png").set({ - enabled: false + + var btnDisabled = new com.zenesis.qx.upload.UploadButton( + "Add File(s)", + "com/zenesis/qx/upload/test.png" + ).set({ + enabled: false, }); + uploader.addWidget(btnDisabled); body.add(btnDisabled, { left: 500, - top: 345 + top: 345, }); + var cbxDisabled = new qx.ui.form.CheckBox("Enable/Disable"); - cbxDisabled.addListener("changeValue", function(evt) { + cbxDisabled.addListener("changeValue", function (evt) { btnDisabled.setEnabled(evt.getData()); }); body.add(cbxDisabled, { left: 500, - top: 325 + top: 325, }); var tb = new qx.ui.toolbar.ToolBar(); body.add(tb, { left: 100, - top: 395 + top: 395, }); + var part = new qx.ui.toolbar.Part(); tb.add(part); btn = new qx.ui.toolbar.Button("Do Nothing 1"); - btn.addListener("execute", function(evt) { + btn.addListener("execute", function (evt) { alert("Do Nothing 1 pressed"); }); part.add(btn); @@ -302,97 +406,142 @@ qx.Class.define("com.zenesis.qx.upload.demo.Application", { // Menu button var menuTop = new qx.ui.toolbar.MenuButton("Menu"); var menu = new qx.ui.menu.Menu(); - var mni = new com.zenesis.qx.upload.UploadMenuButton("Add File(s)", "com/zenesis/qx/upload/test.png"); + var mni = new com.zenesis.qx.upload.UploadMenuButton( + "Add File(s)", + "com/zenesis/qx/upload/test.png" + ); menu.add(mni); menuTop.setMenu(menu); part.add(menuTop); uploader.addWidget(mni); - btn = new com.zenesis.qx.upload.UploadToolbarButton("Add File(s)", "com/zenesis/qx/upload/test.png"); + btn = new com.zenesis.qx.upload.UploadToolbarButton( + "Add File(s)", + "com/zenesis/qx/upload/test.png" + ); uploader.addWidget(btn); part.add(btn); btn = new qx.ui.toolbar.Button("Do Nothing 2"); - btn.addListener("execute", function(evt) { + btn.addListener("execute", function (evt) { alert("Do Nothing 2 pressed"); }); part.add(btn); // Create an atom - var atom = new qx.ui.basic.Atom("qx.ui.basic.Atom upload button").set({ - rich: true + var atom = new qx.ui.basic.Atom( + "qx.ui.basic.Atom upload button" + ).set({ + rich: true, }); + body.add(atom, { left: 100, - top: 460 + top: 460, }); + uploader.addWidget(atom); - - var myBlob = new Blob(["This is my blob content"], {type : "text/plain"}); - uploader.addBlob("test blob", myBlob); + var myBlob = new Blob(["This is my blob content"], { + type: "text/plain", + }); + uploader.addBlob("test blob", myBlob); - btn = new com.zenesis.qx.upload.UploadButton("btn Add File(s) to zip", "com/zenesis/qx/upload/test.png"); + btn = new com.zenesis.qx.upload.UploadButton( + "btn Add File(s) to zip", + "com/zenesis/qx/upload/test.png" + ); body.add(btn, { left: 50, - top: 500 + top: 500, }); + var cbx = new qx.ui.form.CheckBox("Multiple"); cbx.bind("value", btn, "multiple"); body.add(cbx, { left: 50, - top: 550 + top: 550, }); + cbx = new qx.ui.form.CheckBox("Directory"); cbx.bind("value", btn, "directory"); body.add(cbx, { left: 50, - top: 570 + top: 570, }); + var btnZip = new qx.ui.form.Button("download zip"); - btnZip.addListener("execute", async function(evt) { - var blob = await zipHandler.generateAsync({type:"blob"}); + btnZip.addListener( + "execute", + async function (evt) { + var blob = await zipHandler.generateAsync({ type: "blob" }); saveAs(blob, "test.zip"); - }, this); + }, + this + ); body.add(btnZip, { left: 50, - top: 590 + top: 590, }); + var zipUploader = new com.zenesis.qx.upload.UploadMgr(btn); - var zipHandler = new com.zenesis.qx.upload.ZipHandler(zipUploader); - zipUploader.setUploadHandler(zipHandler); - var myBlob = new Blob(["This is my blob content"], {type : "text/plain"}); + var zipHandler = new com.zenesis.qx.upload.ZipHandler(zipUploader); + zipUploader.setUploadHandler(zipHandler); + var myBlob = new Blob(["This is my blob content"], { + type: "text/plain", + }); var zipLst = new qx.ui.form.List(); - zipUploader.addListener("addFile", function(evt) { - var file = evt.getData(), item = new qx.ui.form.ListItem(file.getFilename() + " (queued for upload)", null, file); - zipLst.add(item); - var stateListenerId = file.addListener("changeState", function(evt) { - var state = evt.getData(); - this.debug(file.getFilename() + ": state=" + state + ", file size=" + file.getSize() + ", progress=" - + file.getProgress()); - if (state == "uploading") - item.setLabel(file.getFilename() + " (Uploading...)"); - else if (state == "uploaded") - item.setLabel(file.getFilename() + " (Complete)"); - else if (state == "cancelled") - item.setLabel(file.getFilename() + " (Cancelled)"); - if (state == "uploaded" || state == "cancelled") { - file.removeListenerById(stateListenerId); - } - }, this); - }, this); + zipUploader.addListener( + "addFile", + function (evt) { + var file = evt.getData(), + item = new qx.ui.form.ListItem( + file.getFilename() + " (queued for upload)", + null, + file + ); + zipLst.add(item); + var stateListenerId = file.addListener( + "changeState", + function (evt) { + var state = evt.getData(); + this.debug( + file.getFilename() + + ": state=" + + state + + ", file size=" + + file.getSize() + + ", progress=" + + file.getProgress() + ); + if (state == "uploading") + item.setLabel(file.getFilename() + " (Uploading...)"); + else if (state == "uploaded") + item.setLabel(file.getFilename() + " (Complete)"); + else if (state == "cancelled") + item.setLabel(file.getFilename() + " (Cancelled)"); + if (state == "uploaded" || state == "cancelled") { + file.removeListenerById(stateListenerId); + } + }, + this + ); + }, + this + ); // add them to the UI zipLst.set({ - width: 500 + width: 500, }); + body.add(zipLst, { left: 200, - top: 500 + top: 500, }); + zipUploader.setAutoUpload(true); zipUploader.addBlob("test blob", myBlob); - - } - } + }, + }, }); diff --git a/source/class/com/zenesis/qx/upload/demo/theme/Appearance.js b/source/class/com/zenesis/qx/upload/demo/theme/Appearance.js index 0cbc53e..96cc667 100644 --- a/source/class/com/zenesis/qx/upload/demo/theme/Appearance.js +++ b/source/class/com/zenesis/qx/upload/demo/theme/Appearance.js @@ -8,11 +8,8 @@ ************************************************************************ */ -qx.Theme.define("com.zenesis.qx.upload.demo.theme.Appearance", -{ - extend : qx.theme.modern.Appearance, +qx.Theme.define("com.zenesis.qx.upload.demo.theme.Appearance", { + extend: qx.theme.modern.Appearance, - appearances : - { - } -}); \ No newline at end of file + appearances: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/demo/theme/Color.js b/source/class/com/zenesis/qx/upload/demo/theme/Color.js index 376509f..deb1eba 100644 --- a/source/class/com/zenesis/qx/upload/demo/theme/Color.js +++ b/source/class/com/zenesis/qx/upload/demo/theme/Color.js @@ -8,11 +8,8 @@ ************************************************************************ */ -qx.Theme.define("com.zenesis.qx.upload.demo.theme.Color", -{ - extend : qx.theme.modern.Color, +qx.Theme.define("com.zenesis.qx.upload.demo.theme.Color", { + extend: qx.theme.modern.Color, - colors : - { - } -}); \ No newline at end of file + colors: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/demo/theme/Decoration.js b/source/class/com/zenesis/qx/upload/demo/theme/Decoration.js index c7b93ad..b1be8d8 100644 --- a/source/class/com/zenesis/qx/upload/demo/theme/Decoration.js +++ b/source/class/com/zenesis/qx/upload/demo/theme/Decoration.js @@ -8,11 +8,8 @@ ************************************************************************ */ -qx.Theme.define("com.zenesis.qx.upload.demo.theme.Decoration", -{ - extend : qx.theme.modern.Decoration, +qx.Theme.define("com.zenesis.qx.upload.demo.theme.Decoration", { + extend: qx.theme.modern.Decoration, - decorations : - { - } -}); \ No newline at end of file + decorations: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/demo/theme/Font.js b/source/class/com/zenesis/qx/upload/demo/theme/Font.js index 466552b..69013e5 100644 --- a/source/class/com/zenesis/qx/upload/demo/theme/Font.js +++ b/source/class/com/zenesis/qx/upload/demo/theme/Font.js @@ -8,11 +8,8 @@ ************************************************************************ */ -qx.Theme.define("com.zenesis.qx.upload.demo.theme.Font", -{ - extend : qx.theme.modern.Font, +qx.Theme.define("com.zenesis.qx.upload.demo.theme.Font", { + extend: qx.theme.modern.Font, - fonts : - { - } -}); \ No newline at end of file + fonts: {}, +}); diff --git a/source/class/com/zenesis/qx/upload/demo/theme/Theme.js b/source/class/com/zenesis/qx/upload/demo/theme/Theme.js index d731441..bc29c26 100644 --- a/source/class/com/zenesis/qx/upload/demo/theme/Theme.js +++ b/source/class/com/zenesis/qx/upload/demo/theme/Theme.js @@ -8,14 +8,12 @@ ************************************************************************ */ -qx.Theme.define("com.zenesis.qx.upload.demo.theme.Theme", -{ - meta : - { - color : com.zenesis.qx.upload.demo.theme.Color, - decoration : com.zenesis.qx.upload.demo.theme.Decoration, - font : com.zenesis.qx.upload.demo.theme.Font, - icon : qx.theme.icon.Tango, - appearance : com.zenesis.qx.upload.demo.theme.Appearance - } -}); \ No newline at end of file +qx.Theme.define("com.zenesis.qx.upload.demo.theme.Theme", { + meta: { + color: com.zenesis.qx.upload.demo.theme.Color, + decoration: com.zenesis.qx.upload.demo.theme.Decoration, + font: com.zenesis.qx.upload.demo.theme.Font, + icon: qx.theme.icon.Tango, + appearance: com.zenesis.qx.upload.demo.theme.Appearance, + }, +});