diff --git a/api/js/etemplate/et2_core_DOMWidget.js b/api/js/etemplate/et2_core_DOMWidget.js index 8ecf911aa3..d3770dd159 100644 --- a/api/js/etemplate/et2_core_DOMWidget.js +++ b/api/js/etemplate/et2_core_DOMWidget.js @@ -698,6 +698,9 @@ var et2_surroundingsMgr = /** @class */ (function (_super) { // Return the widget container return this._widgetContainer; }; + et2_surroundingsMgr.prototype.getWidgetSurroundings = function () { + return this._widgetSurroundings; + }; return et2_surroundingsMgr; }(et2_core_inheritance_1.ClassWithAttributes)); /** diff --git a/api/js/etemplate/et2_core_DOMWidget.ts b/api/js/etemplate/et2_core_DOMWidget.ts index 5439f82dfb..25870e8492 100644 --- a/api/js/etemplate/et2_core_DOMWidget.ts +++ b/api/js/etemplate/et2_core_DOMWidget.ts @@ -875,6 +875,11 @@ class et2_surroundingsMgr extends ClassWithAttributes // Return the widget container return this._widgetContainer; } + + getWidgetSurroundings() : HTMLElement [] + { + return this._widgetSurroundings; + } } /** diff --git a/api/js/etemplate/et2_types.d.ts b/api/js/etemplate/et2_types.d.ts index f2b4f913b9..c03bed2275 100644 --- a/api/js/etemplate/et2_types.d.ts +++ b/api/js/etemplate/et2_types.d.ts @@ -191,4 +191,7 @@ declare function nm_open_popup(_action, _selected) : void; declare function nm_submit_popup(button) : void; declare function nm_hide_popup(element, div_id) : false; declare function nm_activate_link(_action, _senders) : void; -declare function egw_seperateJavaScript(_html) : void; \ No newline at end of file +declare function egw_seperateJavaScript(_html) : void; +declare class Resumable { + constructor(asyncOptions: any); +} \ No newline at end of file diff --git a/api/js/etemplate/et2_widget_description.js b/api/js/etemplate/et2_widget_description.js index 7612701a35..a940abaf2f 100644 --- a/api/js/etemplate/et2_widget_description.js +++ b/api/js/etemplate/et2_widget_description.js @@ -352,5 +352,6 @@ var et2_description = /** @class */ (function (_super) { }; return et2_description; }(et2_core_baseWidget_1.et2_baseWidget)); +exports.et2_description = et2_description; et2_core_widget_1.et2_register_widget(et2_description, ["description", "label"]); //# sourceMappingURL=et2_widget_description.js.map \ No newline at end of file diff --git a/api/js/etemplate/et2_widget_description.ts b/api/js/etemplate/et2_widget_description.ts index 2934ae52ce..5593921669 100644 --- a/api/js/etemplate/et2_widget_description.ts +++ b/api/js/etemplate/et2_widget_description.ts @@ -24,7 +24,7 @@ import './et2_types'; /** * Class which implements the "description" XET-Tag */ -class et2_description extends et2_baseWidget implements et2_IDetachedDOM +export class et2_description extends et2_baseWidget implements et2_IDetachedDOM { static readonly _attributes : any = { "label": { diff --git a/api/js/etemplate/et2_widget_dialog.js b/api/js/etemplate/et2_widget_dialog.js index e56e0a48c4..7a0d541bed 100644 --- a/api/js/etemplate/et2_widget_dialog.js +++ b/api/js/etemplate/et2_widget_dialog.js @@ -799,5 +799,6 @@ var et2_dialog = /** @class */ (function (_super) { et2_dialog.NO_BUTTON = 3; return et2_dialog; }(et2_core_widget_2.et2_widget)); +exports.et2_dialog = et2_dialog; et2_core_widget_1.et2_register_widget(et2_dialog, ["dialog"]); //# sourceMappingURL=et2_widget_dialog.js.map \ No newline at end of file diff --git a/api/js/etemplate/et2_widget_dialog.ts b/api/js/etemplate/et2_widget_dialog.ts index cee19a5e0d..bf263375e0 100644 --- a/api/js/etemplate/et2_widget_dialog.ts +++ b/api/js/etemplate/et2_widget_dialog.ts @@ -93,7 +93,7 @@ import {et2_DOMWidget} from "./et2_core_DOMWidget"; * @augments et2_widget * @see http://api.jqueryui.com/dialog/ */ -class et2_dialog extends et2_widget { +export class et2_dialog extends et2_widget { static readonly _attributes: any = { callback: { name: "Callback", diff --git a/api/js/etemplate/et2_widget_file.js b/api/js/etemplate/et2_widget_file.js index b274069d28..78b5254108 100644 --- a/api/js/etemplate/et2_widget_file.js +++ b/api/js/etemplate/et2_widget_file.js @@ -1,3 +1,4 @@ +"use strict"; /** * EGroupware eTemplate2 - JS Number object * @@ -9,710 +10,611 @@ * @copyright Nathan Gray 2011 * @version $Id$ */ - +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); /*egw:uses - et2_core_inputWidget; - phpgwapi.Resumable.resumable; + et2_core_inputWidget; + phpgwapi.Resumable.resumable; */ - +var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); +var et2_core_widget_1 = require("./et2_core_widget"); +var et2_core_inheritance_1 = require("./et2_core_inheritance"); /** * Class which implements file upload * * @augments et2_inputWidget */ -var et2_file = (function(){ "use strict"; return et2_inputWidget.extend( -{ - attributes: { - "multiple": { - "name": "Multiple files", - "type": "boolean", - "default": false, - "description": "Allow the user to select more than one file to upload at a time. Subject to browser support." - }, - "max_file_size": { - "name": "Maximum file size", - "type": "integer", - "default":0, - "description": "Largest file accepted, in bytes. Subject to server limitations. 8MB = 8388608" - }, - "mime": { - "name": "Allowed file types", - "type": "string", - "default": et2_no_init, - "description": "Mime type (eg: image/png) or regex (eg: /^text\//i) for allowed file types" - }, - "blur": { - "name": "Placeholder", - "type": "string", - "default": "", - "description": "This text get displayed if an input-field is empty and does not have the input-focus (blur). It can be used to show a default value or a kind of help-text." - }, - "progress": { - "name": "Progress node", - "type": "string", - "default": et2_no_init, - "description": "The ID of an alternate node (div) to display progress and results. The Node is fetched with et2 getWidgetById so you MUST use the id assigned in XET-File (it may not be available at creation time, so we (re)check on createStatus time)" - }, - "onStart": { - "name": "Start event handler", - "type": "any", - "default": et2_no_init, - "description": "A (js) function called when an upload starts. Return true to continue with upload, false to cancel." - }, - "onFinish": { - "name": "Finish event handler", - "type": "any", - "default": et2_no_init, - "description": "A (js) function called when all files to be uploaded are finished." - }, - drop_target: { - "name": "Optional, additional drop target for HTML5 uploads", - "type": "string", - "default": et2_no_init, - "description": "The ID of an additional drop target for HTML5 drag-n-drop file uploads" - }, - label: { - "name": "Label of file upload", - "type": "string", - "default": "Choose file...", - "description": "String caption to be displayed on file upload span" - }, - progress_dropdownlist: { - "name": "List on files in progress like dropdown", - "type": "boolean", - "default": false, - "description": "Style list of files in uploading progress like dropdown list with a total upload progress indicator" - }, - onFinishOne: { - "name": "Finish event handler for each one", - "type": "any", - "default": et2_no_init, - "description": "A (js) function called when a file to be uploaded is finished." - }, - accept: { - "name": "Acceptable extensions", - "type": "string", - "default": '', - "description": "Define types of files that the server accepts. Multiple types can be seperated by comma and the default is to accept everything." - }, - chunk_size: { - "name": "Chunk size", - "type": "integer", - "default": 1024*1024, - "description": "Max chunk size, gets set from server-side PHP (max_upload_size-1M)/2" // last chunk can be up to 2*chunk_size! - } - }, - - asyncOptions: {}, - - /** - * Constructor - * - * @memberOf et2_file - */ - init: function(_parent, attrs) { - this._super.apply(this, arguments); - - this.node = null; - this.input = null; - this.progress = null; - this.span = null; - // Contains all submit buttons need to be disabled during upload process - this.disabled_buttons = jQuery("input[type='submit'], button"); - if(!this.options.value) this.options.value = {}; - - if(!this.options.id) { - console.warn("File widget needs an ID. Used 'file_widget'."); - this.options.id = "file_widget"; - } - - // Legacy - id ending in [] means multiple - if(this.options.id.substr(-2) == "[]") - { - this.options.multiple = true; - } - // If ID ends in /, it's a directory - allow multiple - else if (this.options.id.substr(-1) === "/") - { - this.options.multiple = true; - attrs.multiple = true; - } - - // Set up the URL to have the request ID & the widget ID - var instance = this.getInstanceManager(); - - var self = this; - - this.asyncOptions = jQuery.extend({ - // Callbacks - onStart: function(event, file_count) { - return self.onStart(event, file_count); - }, - onFinish: function(event, file_count) { - self.onFinish.apply(self, [event, file_count]) - }, - onStartOne: function(event, file_name, index, file_count) { - - }, - onFinishOne: function(event, response, name, number, total) { return self.finishUpload(event,response,name,number,total);}, - onProgress: function(event, progress, name, number, total) { return self.onProgress(event,progress,name,number,total);}, - onError: function(event, name, error) { return self.onError(event,name,error);}, - beforeSend: function(form) { return self.beforeSend(form);}, - - chunkSize: this.options.chunk_size || 1024*1024, - - target: egw.ajaxUrl("EGroupware\\Api\\Etemplate\\Widget\\File::ajax_upload"), - query: function(file) {return self.beforeSend(file);}, - // Disable checking for already uploaded chunks - testChunks: false - },this.asyncOptions); - this.asyncOptions.fieldName = this.options.id; - this.createInputWidget(); - this.set_readonly(this.options.readonly); - }, - - destroy: function() { - this._super.apply(this, arguments); - this.set_drop_target(null); - this.node = null; - this.input = null; - this.span = null; - this.progress = null; - }, - - createInputWidget: function() { - this.node = jQuery(document.createElement("div")).addClass("et2_file"); - this.span = jQuery(document.createElement("span")) - .addClass('et2_file_span et2_button') - .appendTo (this.node); - if (this.options.label != '') this.span.addClass('et2_button_text'); - var span = this.span; - this.input = jQuery(document.createElement("input")) - .attr("type", "file").attr("placeholder", this.options.blur) - .addClass ("et2_file_upload") - .appendTo(this.node) - .hover(function(e){ - jQuery(span) - .toggleClass('et2_file_spanHover'); - }) - .on({ - mousedown:function (e){ - jQuery(span).addClass('et2_file_spanActive'); - }, - mouseup:function (e){ - jQuery(span).removeClass('et2_file_spanActive'); - } - }); - if (this.options.accept) this.input.attr('accept', this.options.accept); - var self = this; - // trigger native input upload file - if (!this.options.readonly) this.span.click(function(){self.input.click()}); - // Check for File interface, should fall back to normal form submit if missing - if(typeof File != "undefined" && typeof (new XMLHttpRequest()).upload != "undefined") - { - this.resumable = new Resumable(this.asyncOptions); - this.resumable.assignBrowse(this.input); - this.resumable.on('fileAdded', jQuery.proxy(this._fileAdded, this)); - this.resumable.on('fileProgress', jQuery.proxy(this._fileProgress, this)); - this.resumable.on('fileSuccess', jQuery.proxy(this.finishUpload, this)); - this.resumable.on('complete', jQuery.proxy(this.onFinish, this)); - } - else - { - // This may be a problem submitting via ajax - } - if(this.options.progress) - { - var widget = this.getRoot().getWidgetById(this.options.progress); - if(widget) - { - //may be not available at createInputWidget time - this.progress = jQuery(widget.getDOMNode()); - } - } - if(!this.progress) - { - this.progress = jQuery(document.createElement("div")).appendTo(this.node); - } - this.progress.addClass("progress"); - - if(this.options.multiple) - { - this.input.attr("multiple","multiple"); - } - - this.setDOMNode(this.node[0]); - }, - - /** - * Set a widget or DOM node as a HTML5 file drop target - * - * @param String new_target widget ID or DOM node ID to be used as a new target - */ - set_drop_target: function(new_target) - { - // Cancel old drop target - if(this.options.drop_target) - { - var widget = this.getRoot().getWidgetById(this.options.drop_target); - var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target); - if(drop_target) - { - this.resumable.unAssignDrop(drop_target); - } - } - - this.options.drop_target = new_target; - - if(!this.options.drop_target) return; - - // Set up new drop target - var widget = this.getRoot().getWidgetById(this.options.drop_target); - var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target); - if(drop_target) - { - this.resumable.assignDrop([drop_target]); - } - else - { - this.egw().debug("warn", "Did not find file drop target %s", this.options.drop_target); - } - - }, - attachToDOM: function() { - this._super.apply(this, arguments); - // Override parent's change, file widget will fire change when finished uploading - this.input.unbind("change.et2_inputWidget"); - }, - getValue: function() { - var value = this.options.value ? this.options.value : this.input.val(); - return value; - }, - - /** - * Set the value of the file widget. - * - * If you pass a FileList or list of files, it will trigger the async upload - * - * @param {FileList|File[]|false} value List of files to be uploaded, or false to reset. - * @param {Event} event Most browsers require the user to initiate file transfers in some way. - * Pass the event in, if you have it. - */ - set_value: function(value, event) { - if(!value || typeof value == "undefined") - { - value = {}; - } - if(jQuery.isEmptyObject(value)) - { - this.options.value = {}; - if (this.resumable.progress() == 1) this.progress.empty(); - - // Reset the HTML element - this.input.wrap('