mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-22 13:58:40 +01:00
Getting etemplate2 sort of working
This commit is contained in:
parent
239f75c8b9
commit
5c5d1dd39d
@ -745,3 +745,4 @@ var et2_action_object_impl = /** @class */ (function () {
|
|||||||
};
|
};
|
||||||
return et2_action_object_impl;
|
return et2_action_object_impl;
|
||||||
}());
|
}());
|
||||||
|
//# sourceMappingURL=et2_core_DOMWidget.js.map
|
@ -14,14 +14,18 @@
|
|||||||
/api/js/egw_action/egw_action.js;
|
/api/js/egw_action/egw_action.js;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ClassWithAttributes } from './et2_core_inheritance';
|
import {ClassWithAttributes} from './et2_core_inheritance';
|
||||||
import './et2_core_interfaces';
|
import './et2_core_interfaces';
|
||||||
import './et2_core_common';
|
import './et2_core_common';
|
||||||
import {et2_widget, et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
import {et2_widget, WidgetConfig} from "./et2_core_widget";
|
||||||
import {
|
import {
|
||||||
egw_getObjectManager, egwActionObjectInterface,
|
EGW_AI_DRAG_OUT,
|
||||||
egw_getActionManager, egw_getAppObjectManager,
|
EGW_AI_DRAG_OVER,
|
||||||
egwActionObject, egwAction, EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT
|
egw_getActionManager,
|
||||||
|
egw_getAppObjectManager,
|
||||||
|
egw_getObjectManager,
|
||||||
|
egwActionObject,
|
||||||
|
egwActionObjectInterface
|
||||||
} from '../egw_action/egw_action.js';
|
} from '../egw_action/egw_action.js';
|
||||||
import './et2_types';
|
import './et2_types';
|
||||||
|
|
||||||
|
@ -1,356 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
/**
|
|
||||||
* EGroupware eTemplate2 - JS Widget base class
|
|
||||||
*
|
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
||||||
* @package etemplate
|
|
||||||
* @subpackage api
|
|
||||||
* @link http://www.egroupware.org
|
|
||||||
* @author Andreas Stöckel
|
|
||||||
*/
|
|
||||||
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
|
|
||||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
|
||||||
lib/tooltip;
|
|
||||||
et2_core_DOMWidget;
|
|
||||||
*/
|
|
||||||
require("./et2_core_interfaces");
|
|
||||||
require("./et2_core_common");
|
|
||||||
var et2_core_DOMWidget_1 = require("./et2_core_DOMWidget");
|
|
||||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
|
||||||
/**
|
|
||||||
* Class which manages the DOM node itself. The simpleWidget class is derrived
|
|
||||||
* from et2_DOMWidget and implements the getDOMNode function. A setDOMNode
|
|
||||||
* function is provided, which attatches the given node to the DOM if possible.
|
|
||||||
*
|
|
||||||
* @augments et2_DOMWidget
|
|
||||||
*/
|
|
||||||
var et2_baseWidget = /** @class */ (function (_super) {
|
|
||||||
__extends(et2_baseWidget, _super);
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
function et2_baseWidget(_parent, _attrs, _child) {
|
|
||||||
var _this =
|
|
||||||
// Call the inherited constructor
|
|
||||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_core_DOMWidget_1.et2_DOMWidget._attributes, _child || {})) || this;
|
|
||||||
_this.align = 'left';
|
|
||||||
_this.node = null;
|
|
||||||
_this.statustext = '';
|
|
||||||
_this._messageDiv = null;
|
|
||||||
_this._tooltipElem = null;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
et2_baseWidget.prototype.destroy = function () {
|
|
||||||
_super.prototype.destroy.call(this);
|
|
||||||
this.node = null;
|
|
||||||
this._messageDiv = null;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* The setMessage function can be used to attach a small message box to the
|
|
||||||
* widget. This is e.g. used to display validation errors or success messages
|
|
||||||
*
|
|
||||||
* @param _text is the text which should be displayed as a message
|
|
||||||
* @param _type is an css class which is attached to the message box.
|
|
||||||
* Currently available are "hint", "success" and "validation_error", defaults
|
|
||||||
* to "hint"
|
|
||||||
* @param _floating if true, the object will be in one row with the element,
|
|
||||||
* defaults to true
|
|
||||||
* @param _prepend if set, the message is displayed behind the widget node
|
|
||||||
* instead of before. Defaults to false.
|
|
||||||
*/
|
|
||||||
et2_baseWidget.prototype.showMessage = function (_text, _type, _floating, _prepend) {
|
|
||||||
// Preset the parameters
|
|
||||||
if (typeof _type == "undefined") {
|
|
||||||
_type = "hint";
|
|
||||||
}
|
|
||||||
if (typeof _floating == "undefined") {
|
|
||||||
_floating = true;
|
|
||||||
}
|
|
||||||
if (typeof _prepend == "undefined") {
|
|
||||||
_prepend = false;
|
|
||||||
}
|
|
||||||
var surr = this.getSurroundings();
|
|
||||||
// Remove the message div from the surroundings before creating a new
|
|
||||||
// one
|
|
||||||
this.hideMessage(false, true);
|
|
||||||
// Create the message div and add it to the "surroundings" manager
|
|
||||||
this._messageDiv = jQuery(document.createElement("div"))
|
|
||||||
.addClass("message")
|
|
||||||
.addClass(_type)
|
|
||||||
.addClass(_floating ? "floating" : "")
|
|
||||||
.text(_text.valueOf() + "");
|
|
||||||
// Decide whether to prepend or append the div
|
|
||||||
if (_prepend) {
|
|
||||||
surr.prependDOMNode(this._messageDiv[0]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
surr.appendDOMNode(this._messageDiv[0]);
|
|
||||||
}
|
|
||||||
surr.update();
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* The hideMessage function can be used to hide a previously shown message.
|
|
||||||
*
|
|
||||||
* @param _fade if true, the message div will fade out, otherwise the message
|
|
||||||
* div is removed immediately. Defaults to true.
|
|
||||||
* @param _noUpdate is used internally to prevent an update of the surroundings
|
|
||||||
* manager.
|
|
||||||
*/
|
|
||||||
et2_baseWidget.prototype.hideMessage = function (_fade, _noUpdate) {
|
|
||||||
if (typeof _fade == "undefined") {
|
|
||||||
_fade = true;
|
|
||||||
}
|
|
||||||
if (typeof _noUpdate == "undefined") {
|
|
||||||
_noUpdate = false;
|
|
||||||
}
|
|
||||||
// Remove the message from the surroundings manager and remove the
|
|
||||||
// reference to it
|
|
||||||
if (this._messageDiv != null) {
|
|
||||||
var surr = this.getSurroundings();
|
|
||||||
var self = this;
|
|
||||||
var messageDiv = this._messageDiv;
|
|
||||||
self._messageDiv = null;
|
|
||||||
var _done = function () {
|
|
||||||
surr.removeDOMNode(messageDiv[0]);
|
|
||||||
// Update the surroundings manager
|
|
||||||
if (!_noUpdate) {
|
|
||||||
surr.update();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Either fade out or directly call the function which removes the div
|
|
||||||
if (_fade) {
|
|
||||||
messageDiv.fadeOut("fast", _done);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.detachFromDOM = function () {
|
|
||||||
// Detach this node from the tooltip node
|
|
||||||
if (this._tooltipElem) {
|
|
||||||
this.egw().tooltipUnbind(this._tooltipElem);
|
|
||||||
this._tooltipElem = null;
|
|
||||||
}
|
|
||||||
// Remove the binding to the click handler
|
|
||||||
if (this.node) {
|
|
||||||
jQuery(this.node).unbind("click.et2_baseWidget");
|
|
||||||
}
|
|
||||||
return _super.prototype.detachFromDOM.call(this);
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.attachToDOM = function () {
|
|
||||||
var ret = _super.prototype.attachToDOM.call(this);
|
|
||||||
// Add the binding for the click handler
|
|
||||||
if (this.node) {
|
|
||||||
jQuery(this.node).bind("click.et2_baseWidget", this, function (e) {
|
|
||||||
return e.data.click.call(e.data, e, this);
|
|
||||||
});
|
|
||||||
if (typeof this.onclick == 'function')
|
|
||||||
jQuery(this.node).addClass('et2_clickable');
|
|
||||||
}
|
|
||||||
// Update the statustext
|
|
||||||
this.set_statustext(this.statustext);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.setDOMNode = function (_node) {
|
|
||||||
if (_node != this.node) {
|
|
||||||
// Deatch the old node from the DOM
|
|
||||||
this.detachFromDOM();
|
|
||||||
// Set the new DOM-Node
|
|
||||||
this.node = _node;
|
|
||||||
// Attatch the DOM-Node to the tree
|
|
||||||
return this.attachToDOM();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.getDOMNode = function (_sender) {
|
|
||||||
return this.node;
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.getTooltipElement = function () {
|
|
||||||
return this.getDOMNode(this);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Click handler calling custom handler set via onclick attribute to this.onclick
|
|
||||||
*
|
|
||||||
* @param _ev
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
et2_baseWidget.prototype.click = function (_ev) {
|
|
||||||
if (typeof this.onclick == 'function') {
|
|
||||||
// Make sure function gets a reference to the widget, splice it in as 2. argument if not
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
if (args.indexOf(this) == -1)
|
|
||||||
args.splice(1, 0, this);
|
|
||||||
return this.onclick.apply(this, args);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.set_statustext = function (_value) {
|
|
||||||
// Tooltip should not be shown in mobile view
|
|
||||||
if (egwIsMobile())
|
|
||||||
return;
|
|
||||||
// Don't execute the code below, if no tooltip will be attached/detached
|
|
||||||
if (_value == "" && !this._tooltipElem) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// allow statustext to contain multiple translated sub-strings eg: {Firstname}.{Lastname}
|
|
||||||
if (_value.indexOf('{') !== -1) {
|
|
||||||
var egw = this.egw();
|
|
||||||
_value = _value.replace(/{([^}]+)}/g, function (str, p1) {
|
|
||||||
return egw.lang(p1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.statustext = _value;
|
|
||||||
//Get the domnode the tooltip should be attached to
|
|
||||||
var elem = jQuery(this.getTooltipElement());
|
|
||||||
if (elem) {
|
|
||||||
//If a tooltip is already attached to the element, remove it first
|
|
||||||
if (this._tooltipElem) {
|
|
||||||
this.egw().tooltipUnbind(this._tooltipElem);
|
|
||||||
this._tooltipElem = null;
|
|
||||||
}
|
|
||||||
if (_value && _value != '') {
|
|
||||||
this.egw().tooltipBind(elem, _value, this.options.statustext_html);
|
|
||||||
this._tooltipElem = elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.set_align = function (_value) {
|
|
||||||
this.align = _value;
|
|
||||||
};
|
|
||||||
et2_baseWidget.prototype.get_align = function () {
|
|
||||||
return this.align;
|
|
||||||
};
|
|
||||||
et2_baseWidget._attributes = {
|
|
||||||
"statustext": {
|
|
||||||
"name": "Tooltip",
|
|
||||||
"type": "string",
|
|
||||||
"description": "Tooltip which is shown for this element",
|
|
||||||
"translate": true
|
|
||||||
},
|
|
||||||
"statustext_html": {
|
|
||||||
"name": "Tooltip is html",
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Flag to allow html content in tooltip",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"align": {
|
|
||||||
"name": "Align",
|
|
||||||
"type": "string",
|
|
||||||
"default": "left",
|
|
||||||
"description": "Position of this element in the parent hbox"
|
|
||||||
},
|
|
||||||
"onclick": {
|
|
||||||
"name": "onclick",
|
|
||||||
"type": "js",
|
|
||||||
"default": et2_no_init,
|
|
||||||
"description": "JS code which is executed when the element is clicked."
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return et2_baseWidget;
|
|
||||||
}(et2_core_DOMWidget_1.et2_DOMWidget));
|
|
||||||
exports.et2_baseWidget = et2_baseWidget;
|
|
||||||
/**
|
|
||||||
* Simple container object
|
|
||||||
*/
|
|
||||||
var et2_container = /** @class */ (function (_super) {
|
|
||||||
__extends(et2_container, _super);
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
function et2_container(_parent, _attrs, _child) {
|
|
||||||
// Call the inherited constructor
|
|
||||||
return _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_core_DOMWidget_1.et2_DOMWidget._attributes, _child || {})) || this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The destroy function destroys all children of the widget, removes itself
|
|
||||||
* from the parents children list.
|
|
||||||
* Overriden to not try to remove self from parent, as that's not possible.
|
|
||||||
*/
|
|
||||||
et2_container.prototype.destroy = function () {
|
|
||||||
// Call the destructor of all children
|
|
||||||
for (var i = this._children.length - 1; i >= 0; i--) {
|
|
||||||
this._children[i].destroy();
|
|
||||||
}
|
|
||||||
// Free the array managers if they belong to this widget
|
|
||||||
for (var key in this._mgrs) {
|
|
||||||
if (this._mgrs[key] && this._mgrs[key].owner == this) {
|
|
||||||
this._mgrs[key].destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return et2_container;
|
|
||||||
}(et2_baseWidget));
|
|
||||||
/**
|
|
||||||
* Container object for not-yet supported widgets
|
|
||||||
*
|
|
||||||
* @augments et2_baseWidget
|
|
||||||
*/
|
|
||||||
var et2_placeholder = /** @class */ (function (_super) {
|
|
||||||
__extends(et2_placeholder, _super);
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
function et2_placeholder(_parent, _attrs, _child) {
|
|
||||||
var _this =
|
|
||||||
// Call the inherited constructor
|
|
||||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_core_DOMWidget_1.et2_DOMWidget._attributes, _child || {})) || this;
|
|
||||||
_this.visible = false;
|
|
||||||
_this.attrNodes = {};
|
|
||||||
// Create the placeholder div
|
|
||||||
_this.placeDiv = jQuery(document.createElement("span"))
|
|
||||||
.addClass("et2_placeholder");
|
|
||||||
var headerNode = jQuery(document.createElement("span"))
|
|
||||||
.text(_this.getType() || "")
|
|
||||||
.addClass("et2_caption")
|
|
||||||
.appendTo(_this.placeDiv);
|
|
||||||
var attrsCntr = jQuery(document.createElement("span"))
|
|
||||||
.appendTo(_this.placeDiv)
|
|
||||||
.hide();
|
|
||||||
headerNode.click(_this, function (e) {
|
|
||||||
e.data.visible = !e.data.visible;
|
|
||||||
if (e.data.visible) {
|
|
||||||
attrsCntr.show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
attrsCntr.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (var key in _this.options) {
|
|
||||||
if (typeof _this.options[key] != "undefined") {
|
|
||||||
if (typeof _this.attrNodes[key] == "undefined") {
|
|
||||||
_this.attrNodes[key] = jQuery(document.createElement("span"))
|
|
||||||
.addClass("et2_attr");
|
|
||||||
attrsCntr.append(_this.attrNodes[key]);
|
|
||||||
}
|
|
||||||
_this.attrNodes[key].text(key + "=" + _this.options[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_this.setDOMNode(_this.placeDiv[0]);
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
et2_placeholder.prototype.getDetachedAttributes = function (_attrs) {
|
|
||||||
_attrs.push("value");
|
|
||||||
};
|
|
||||||
et2_placeholder.prototype.getDetachedNodes = function () {
|
|
||||||
return [this.placeDiv[0]];
|
|
||||||
};
|
|
||||||
et2_placeholder.prototype.setDetachedAttributes = function (_nodes, _values) {
|
|
||||||
this.placeDiv = jQuery(_nodes[0]);
|
|
||||||
};
|
|
||||||
return et2_placeholder;
|
|
||||||
}(et2_baseWidget));
|
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
import './et2_core_interfaces';
|
import './et2_core_interfaces';
|
||||||
import './et2_core_common';
|
import './et2_core_common';
|
||||||
import { et2_DOMWidget } from './et2_core_DOMWidget';
|
import {et2_DOMWidget} from './et2_core_DOMWidget';
|
||||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||||
import { et2_widget, et2_createWidget, et2_register_widget, WidgetConfig } from "./et2_core_widget";
|
import {et2_widget, WidgetConfig} from "./et2_core_widget";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which manages the DOM node itself. The simpleWidget class is derrived
|
* Class which manages the DOM node itself. The simpleWidget class is derrived
|
||||||
@ -54,7 +54,7 @@ export class et2_baseWidget extends et2_DOMWidget implements et2_IAligned
|
|||||||
"default": et2_no_init,
|
"default": et2_no_init,
|
||||||
"description": "JS code which is executed when the element is clicked."
|
"description": "JS code which is executed when the element is clicked."
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
align: string = 'left';
|
align: string = 'left';
|
||||||
node: HTMLElement = null;
|
node: HTMLElement = null;
|
||||||
|
@ -579,3 +579,4 @@ function et2_rangeSubstract(_ar1, _ar2) {
|
|||||||
function html_entity_decode(_str) {
|
function html_entity_decode(_str) {
|
||||||
return _str && _str.indexOf('&') != -1 ? jQuery('<span>' + _str + '</span>').text() : _str;
|
return _str && _str.indexOf('&') != -1 ? jQuery('<span>' + _str + '</span>').text() : _str;
|
||||||
}
|
}
|
||||||
|
//# sourceMappingURL=et2_core_common.js.map
|
@ -74,12 +74,12 @@ var ClassWithAttributes = /** @class */ (function () {
|
|||||||
*
|
*
|
||||||
* @param {object} _attrs is the associative array containing the attributes.
|
* @param {object} _attrs is the associative array containing the attributes.
|
||||||
*/
|
*/
|
||||||
ClassWithAttributes.prototype.generateAttributeSet = function (_attrs) {
|
ClassWithAttributes.generateAttributeSet = function (widget, _attrs) {
|
||||||
// Sanity check and validation
|
// Sanity check and validation
|
||||||
for (var key in _attrs) {
|
for (var key in _attrs) {
|
||||||
if (typeof this.attributes[key] != "undefined") {
|
if (typeof widget[key] != "undefined") {
|
||||||
if (!this.attributes[key].ignore) {
|
if (!widget[key].ignore) {
|
||||||
_attrs[key] = et2_checkType(_attrs[key], this.attributes[key].type, key, this);
|
_attrs[key] = et2_checkType(_attrs[key], widget[key].type, key, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -90,9 +90,9 @@ var ClassWithAttributes = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Include default values or already set values for this attribute
|
// Include default values or already set values for this attribute
|
||||||
for (var key in this.attributes) {
|
for (var key in widget) {
|
||||||
if (typeof _attrs[key] == "undefined") {
|
if (typeof _attrs[key] == "undefined") {
|
||||||
var _default = this.attributes[key]["default"];
|
var _default = widget[key]["default"];
|
||||||
if (_default == et2_no_init) {
|
if (_default == et2_no_init) {
|
||||||
_default = undefined;
|
_default = undefined;
|
||||||
}
|
}
|
||||||
@ -116,6 +116,20 @@ var ClassWithAttributes = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
ClassWithAttributes.buildAttributes = function (class_prototype) {
|
||||||
|
var class_tree = [];
|
||||||
|
var attributes = {};
|
||||||
|
var n = 0;
|
||||||
|
do {
|
||||||
|
n++;
|
||||||
|
class_tree.push(class_prototype);
|
||||||
|
class_prototype = Object.getPrototypeOf(class_prototype);
|
||||||
|
} while (class_prototype !== ClassWithAttributes && n < 50);
|
||||||
|
for (var i = class_tree.length - 1; i > 0; i--) {
|
||||||
|
class_tree[i - 1]._attributes = ClassWithAttributes.extendAttributes(class_tree[i - 1]._attributes, class_tree[i]._attributes);
|
||||||
|
}
|
||||||
|
return class_tree[0]._attributes;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Extend current _attributes with the one from the parent class
|
* Extend current _attributes with the one from the parent class
|
||||||
*
|
*
|
||||||
@ -189,3 +203,4 @@ var ClassWithAttributes = /** @class */ (function () {
|
|||||||
return ClassWithAttributes;
|
return ClassWithAttributes;
|
||||||
}());
|
}());
|
||||||
exports.ClassWithAttributes = ClassWithAttributes;
|
exports.ClassWithAttributes = ClassWithAttributes;
|
||||||
|
//# sourceMappingURL=et2_core_inheritance.js.map
|
@ -95,16 +95,16 @@ export class ClassWithAttributes
|
|||||||
*
|
*
|
||||||
* @param {object} _attrs is the associative array containing the attributes.
|
* @param {object} _attrs is the associative array containing the attributes.
|
||||||
*/
|
*/
|
||||||
generateAttributeSet(_attrs)
|
static generateAttributeSet(widget, _attrs)
|
||||||
{
|
{
|
||||||
// Sanity check and validation
|
// Sanity check and validation
|
||||||
for (var key in _attrs)
|
for (var key in _attrs)
|
||||||
{
|
{
|
||||||
if (typeof this.attributes[key] != "undefined")
|
if (typeof widget[key] != "undefined")
|
||||||
{
|
{
|
||||||
if (!this.attributes[key].ignore)
|
if (!widget[key].ignore)
|
||||||
{
|
{
|
||||||
_attrs[key] = et2_checkType(_attrs[key], this.attributes[key].type,
|
_attrs[key] = et2_checkType(_attrs[key], widget[key].type,
|
||||||
key, this);
|
key, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,11 +118,11 @@ export class ClassWithAttributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Include default values or already set values for this attribute
|
// Include default values or already set values for this attribute
|
||||||
for (var key in this.attributes)
|
for (var key in widget)
|
||||||
{
|
{
|
||||||
if (typeof _attrs[key] == "undefined")
|
if (typeof _attrs[key] == "undefined")
|
||||||
{
|
{
|
||||||
var _default = this.attributes[key]["default"];
|
var _default = widget[key]["default"];
|
||||||
if (_default == et2_no_init)
|
if (_default == et2_no_init)
|
||||||
{
|
{
|
||||||
_default = undefined;
|
_default = undefined;
|
||||||
@ -154,6 +154,24 @@ export class ClassWithAttributes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static buildAttributes(class_prototype: object)
|
||||||
|
{
|
||||||
|
let class_tree = [];
|
||||||
|
let attributes = {};
|
||||||
|
let n = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
class_tree.push(class_prototype);
|
||||||
|
class_prototype = Object.getPrototypeOf(class_prototype);
|
||||||
|
} while (class_prototype !== ClassWithAttributes && n < 50);
|
||||||
|
|
||||||
|
for(let i = class_tree.length - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
class_tree[i-1]._attributes = ClassWithAttributes.extendAttributes(class_tree[i-1]._attributes,class_tree[i]._attributes);
|
||||||
|
}
|
||||||
|
return class_tree[0]._attributes;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Extend current _attributes with the one from the parent class
|
* Extend current _attributes with the one from the parent class
|
||||||
*
|
*
|
||||||
|
@ -284,3 +284,4 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
|||||||
return et2_inputWidget;
|
return et2_inputWidget;
|
||||||
}(et2_core_valueWidget_1.et2_valueWidget));
|
}(et2_core_valueWidget_1.et2_valueWidget));
|
||||||
exports.et2_inputWidget = et2_inputWidget;
|
exports.et2_inputWidget = et2_inputWidget;
|
||||||
|
//# sourceMappingURL=et2_core_inputWidget.js.map
|
@ -49,3 +49,4 @@ var et2_IPrint = "et2_IPrint";
|
|||||||
function implements_et2_IPrint(obj) {
|
function implements_et2_IPrint(obj) {
|
||||||
return implements_methods(obj, ["beforePrint", "afterPrint"]);
|
return implements_methods(obj, ["beforePrint", "afterPrint"]);
|
||||||
}
|
}
|
||||||
|
//# sourceMappingURL=et2_core_interfaces.js.map
|
@ -127,3 +127,4 @@ var et2_valueWidget = /** @class */ (function (_super) {
|
|||||||
return et2_valueWidget;
|
return et2_valueWidget;
|
||||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||||
exports.et2_valueWidget = et2_valueWidget;
|
exports.et2_valueWidget = et2_valueWidget;
|
||||||
|
//# sourceMappingURL=et2_core_valueWidget.js.map
|
@ -35,6 +35,7 @@ var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
|||||||
* constructor.
|
* constructor.
|
||||||
*/
|
*/
|
||||||
var et2_registry = {};
|
var et2_registry = {};
|
||||||
|
var et2_attribute_registry = {};
|
||||||
/**
|
/**
|
||||||
* Registers the widget class defined by the given constructor and associates it
|
* Registers the widget class defined by the given constructor and associates it
|
||||||
* with the types in the _types array.
|
* with the types in the _types array.
|
||||||
@ -44,6 +45,7 @@ var et2_registry = {};
|
|||||||
*/
|
*/
|
||||||
function et2_register_widget(_constructor, _types) {
|
function et2_register_widget(_constructor, _types) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
et2_attribute_registry[_constructor.name] = et2_core_inheritance_1.ClassWithAttributes.buildAttributes(_constructor);
|
||||||
// Iterate over all given types and register those
|
// Iterate over all given types and register those
|
||||||
for (var i = 0; i < _types.length; i++) {
|
for (var i = 0; i < _types.length; i++) {
|
||||||
var type = _types[i].toLowerCase();
|
var type = _types[i].toLowerCase();
|
||||||
@ -447,8 +449,9 @@ var et2_widget = /** @class */ (function (_super) {
|
|||||||
// do NOT overwrite already evaluated readonly attribute
|
// do NOT overwrite already evaluated readonly attribute
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mgr != null && typeof _proto.attributes[attrName] != "undefined") {
|
var attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {};
|
||||||
var attr = _proto.attributes[attrName];
|
if (mgr != null && typeof attrs[attrName] != "undefined") {
|
||||||
|
var attr = attrs[attrName];
|
||||||
// If the attribute is marked as boolean, parse the
|
// If the attribute is marked as boolean, parse the
|
||||||
// expression as bool expression.
|
// expression as bool expression.
|
||||||
if (attr.type == "boolean") {
|
if (attr.type == "boolean") {
|
||||||
@ -555,7 +558,7 @@ var et2_widget = /** @class */ (function (_super) {
|
|||||||
// Parse the attributes from the given XML attributes object
|
// Parse the attributes from the given XML attributes object
|
||||||
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
|
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
|
||||||
// Do an sanity check for the attributes
|
// Do an sanity check for the attributes
|
||||||
constructor.prototype.generateAttributeSet(attributes);
|
et2_core_inheritance_1.ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], attributes);
|
||||||
// Creates the new widget, passes this widget as an instance and
|
// Creates the new widget, passes this widget as an instance and
|
||||||
// passes the widgetType. Then it goes on loading the XML for it.
|
// passes the widgetType. Then it goes on loading the XML for it.
|
||||||
var widget = new constructor(this, attributes);
|
var widget = new constructor(this, attributes);
|
||||||
@ -884,3 +887,4 @@ var et2_widget = /** @class */ (function (_super) {
|
|||||||
return et2_widget;
|
return et2_widget;
|
||||||
}(et2_core_inheritance_1.ClassWithAttributes));
|
}(et2_core_inheritance_1.ClassWithAttributes));
|
||||||
exports.et2_widget = et2_widget;
|
exports.et2_widget = et2_widget;
|
||||||
|
//# sourceMappingURL=et2_core_widget.js.map
|
@ -23,6 +23,8 @@ import { ClassWithAttributes } from './et2_core_inheritance';
|
|||||||
* constructor.
|
* constructor.
|
||||||
*/
|
*/
|
||||||
var et2_registry = {};
|
var et2_registry = {};
|
||||||
|
var et2_attribute_registry = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the widget class defined by the given constructor and associates it
|
* Registers the widget class defined by the given constructor and associates it
|
||||||
@ -35,6 +37,7 @@ export function et2_register_widget(_constructor, _types)
|
|||||||
{
|
{
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
et2_attribute_registry[_constructor.name] = ClassWithAttributes.buildAttributes(_constructor);
|
||||||
// Iterate over all given types and register those
|
// Iterate over all given types and register those
|
||||||
for (var i = 0; i < _types.length; i++)
|
for (var i = 0; i < _types.length; i++)
|
||||||
{
|
{
|
||||||
@ -577,8 +580,9 @@ export class et2_widget extends ClassWithAttributes
|
|||||||
} else if (attrName == "readonly" && typeof _target[attrName] != "undefined") {
|
} else if (attrName == "readonly" && typeof _target[attrName] != "undefined") {
|
||||||
// do NOT overwrite already evaluated readonly attribute
|
// do NOT overwrite already evaluated readonly attribute
|
||||||
} else {
|
} else {
|
||||||
if (mgr != null && typeof _proto.attributes[attrName] != "undefined") {
|
let attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {};
|
||||||
var attr = _proto.attributes[attrName];
|
if (mgr != null && typeof attrs[attrName] != "undefined") {
|
||||||
|
var attr = attrs[attrName];
|
||||||
|
|
||||||
// If the attribute is marked as boolean, parse the
|
// If the attribute is marked as boolean, parse the
|
||||||
// expression as bool expression.
|
// expression as bool expression.
|
||||||
@ -701,7 +705,7 @@ export class et2_widget extends ClassWithAttributes
|
|||||||
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
|
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
|
||||||
|
|
||||||
// Do an sanity check for the attributes
|
// Do an sanity check for the attributes
|
||||||
constructor.prototype.generateAttributeSet(attributes);
|
ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], attributes);
|
||||||
|
|
||||||
// Creates the new widget, passes this widget as an instance and
|
// Creates the new widget, passes this widget as an instance and
|
||||||
// passes the widgetType. Then it goes on loading the XML for it.
|
// passes the widgetType. Then it goes on loading the XML for it.
|
||||||
|
@ -222,3 +222,4 @@ var et2_details = /** @class */ (function (_super) {
|
|||||||
}(et2_box));
|
}(et2_box));
|
||||||
exports.et2_details = et2_details;
|
exports.et2_details = et2_details;
|
||||||
et2_core_widget_1.et2_register_widget(et2_details, ["details"]);
|
et2_core_widget_1.et2_register_widget(et2_details, ["details"]);
|
||||||
|
//# sourceMappingURL=et2_widget_box.js.map
|
@ -390,3 +390,4 @@ var et2_button = /** @class */ (function (_super) {
|
|||||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||||
exports.et2_button = et2_button;
|
exports.et2_button = et2_button;
|
||||||
et2_core_widget_1.et2_register_widget(et2_button, ["button", "buttononly"]);
|
et2_core_widget_1.et2_register_widget(et2_button, ["button", "buttononly"]);
|
||||||
|
//# sourceMappingURL=et2_widget_button.js.map
|
@ -1,3 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
/**
|
/**
|
||||||
* EGroupware eTemplate2 - JS Description object
|
* EGroupware eTemplate2 - JS Description object
|
||||||
*
|
*
|
||||||
@ -6,410 +7,351 @@
|
|||||||
* @subpackage api
|
* @subpackage api
|
||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @author Andreas Stöckel
|
* @author Andreas Stöckel
|
||||||
* @copyright Stylite 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
|
/*egw:uses
|
||||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||||
et2_core_baseWidget;
|
et2_core_baseWidget;
|
||||||
expose;
|
expose;
|
||||||
*/
|
*/
|
||||||
|
require("./et2_core_common");
|
||||||
|
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||||
|
var et2_core_widget_1 = require("./et2_core_widget");
|
||||||
|
var et2_core_DOMWidget_1 = require("./et2_core_DOMWidget");
|
||||||
|
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||||
|
require("./et2_types");
|
||||||
/**
|
/**
|
||||||
* Class which implements the "description" XET-Tag
|
* Class which implements the "description" XET-Tag
|
||||||
*
|
|
||||||
* @augments et2_baseWidget
|
|
||||||
*/
|
*/
|
||||||
var et2_description = (function(){ "use strict"; return expose(et2_baseWidget.extend([et2_IDetachedDOM],
|
var et2_description = /** @class */ (function (_super) {
|
||||||
{
|
__extends(et2_description, _super);
|
||||||
attributes: {
|
/**
|
||||||
"label": {
|
* Constructor
|
||||||
"name": "Label",
|
*/
|
||||||
"default": "",
|
function et2_description(_parent, _attrs, _child) {
|
||||||
"type": "string",
|
var _this =
|
||||||
"description": "The label is displayed by default in front (for radiobuttons behind) each widget (if not empty). If you want to specify a different position, use a '%s' in the label, which gets replaced by the widget itself. Eg. '%s Name' to have the label Name behind a checkbox. The label can contain variables, as descript for name. If the label starts with a '@' it is replaced by the value of the content-array at this index (with the '@'-removed and after expanding the variables).",
|
// Call the inherited constructor
|
||||||
"translate": true
|
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_core_DOMWidget_1.et2_DOMWidget._attributes, _child || {})) || this;
|
||||||
},
|
_this.legacyOptions = ["font_style", "href", "activate_links", "for",
|
||||||
"value": {
|
"extra_link_target", "extra_link_popup", "statustext"];
|
||||||
"name": "Value",
|
_this._labelContainer = null;
|
||||||
"type": "string",
|
// Create the span/label tag which contains the label text
|
||||||
"description": "Displayed text",
|
_this.span = jQuery(document.createElement(_this.options["for"] ? "label" : "span"))
|
||||||
"translate": "!no_lang",
|
.addClass("et2_label");
|
||||||
"default": ""
|
et2_insertLinkText(_this._parseText(_this.options.value), _this.span[0], _this.options.href ? _this.options.extra_link_target : '_blank');
|
||||||
},
|
_this.setDOMNode(_this.span[0]);
|
||||||
|
return _this;
|
||||||
/**
|
}
|
||||||
* Options converted from the "options"-attribute.
|
et2_description.prototype.transformAttributes = function (_attrs) {
|
||||||
*/
|
_super.prototype.transformAttributes.call(this, _attrs);
|
||||||
"font_style": {
|
if (this.id) {
|
||||||
"name": "Font Style",
|
var val = this.getArrayMgr("content").getEntry(this.id);
|
||||||
"type": "string",
|
if (val) {
|
||||||
"description": "Style may be a compositum of \"b\" and \"i\" which " +
|
_attrs["value"] = val;
|
||||||
" renders the text bold and/or italic."
|
}
|
||||||
},
|
}
|
||||||
"href": {
|
};
|
||||||
"name": "Link URL",
|
et2_description.prototype.doLoadingFinished = function () {
|
||||||
"type": "string",
|
_super.prototype.doLoadingFinished.call(this);
|
||||||
"description": "Link URL, empty if you don't wan't to display a link."
|
// Get the real id of the 'for' widget
|
||||||
},
|
var for_widget = null;
|
||||||
"activate_links": {
|
if (this.options["for"] && ((for_widget = this.getParent().getWidgetById(this.options.for)) ||
|
||||||
"name": "Replace URLs",
|
(for_widget = this.getRoot().getWidgetById(this.options.for))) && for_widget && for_widget.id) {
|
||||||
"type": "boolean",
|
if (for_widget.dom_id) {
|
||||||
"default": false,
|
this.span.attr("for", for_widget.dom_id);
|
||||||
"description": "If set, URLs in the text are automatically replaced " +
|
}
|
||||||
"by links"
|
else {
|
||||||
},
|
// Target widget is not done yet, need to wait
|
||||||
"for": {
|
var tab_deferred = jQuery.Deferred();
|
||||||
"name": "Label for widget",
|
window.setTimeout(function () {
|
||||||
"type": "string",
|
this.span.attr("for", for_widget.dom_id);
|
||||||
"description": "Marks the text as label for the given widget."
|
tab_deferred.resolve();
|
||||||
},
|
}.bind(this), 0);
|
||||||
"extra_link_target": {
|
return tab_deferred.promise();
|
||||||
"name": "Link target",
|
}
|
||||||
"type": "string",
|
}
|
||||||
"default": "_browser",
|
return true;
|
||||||
"description": "Link target for href attribute"
|
};
|
||||||
},
|
et2_description.prototype.set_label = function (_value) {
|
||||||
"extra_link_popup": {
|
// Abort if ther was no change in the label
|
||||||
"name": "Popup",
|
if (_value == this.label) {
|
||||||
"type": "string",
|
return;
|
||||||
"description": "widthxheight, if popup should be used, eg. 640x480"
|
}
|
||||||
},
|
if (_value) {
|
||||||
"expose_view":{
|
// Create the label container if it didn't exist yet
|
||||||
name: "Expose view",
|
if (this._labelContainer == null) {
|
||||||
type: "boolean",
|
this._labelContainer = jQuery(document.createElement("label"))
|
||||||
default: false,
|
.addClass("et2_label");
|
||||||
description: "Clicking on description with href value would popup an expose view, and will show content referenced by href."
|
this.getSurroundings().insertDOMNode(this._labelContainer[0]);
|
||||||
},
|
}
|
||||||
mime:{
|
// Clear the label container.
|
||||||
name: "Mime type",
|
this._labelContainer.empty();
|
||||||
type: "string",
|
// Create the placeholder element and set it
|
||||||
default: '',
|
var ph = document.createElement("span");
|
||||||
description: "Mime type of the registered link"
|
this.getSurroundings().setWidgetPlaceholder(ph);
|
||||||
},
|
// Split the label at the "%s"
|
||||||
mime_data:{
|
var parts = et2_csvSplit(_value, 2, "%s");
|
||||||
name: "Mime data",
|
// Update the content of the label container
|
||||||
type: "string",
|
for (var i = 0; i < parts.length; i++) {
|
||||||
default: '',
|
if (parts[i]) {
|
||||||
description: "hash for data stored on service-side with egw_link::(get|set)_data()"
|
this._labelContainer.append(document.createTextNode(parts[i]));
|
||||||
},
|
}
|
||||||
hover_action: {
|
if (i == 0) {
|
||||||
"name": "hover action",
|
this._labelContainer.append(ph);
|
||||||
"type": "js",
|
}
|
||||||
"default": et2_no_init,
|
}
|
||||||
"description": "JS code which is executed when clicking on action button. This action is explicitly for attached nodes, like in nm."
|
// add class if label is empty
|
||||||
},
|
this._labelContainer.toggleClass('et2_label_empty', !_value || !parts[0]);
|
||||||
hover_action_title: {
|
}
|
||||||
"name": "hover action title",
|
else {
|
||||||
"type": "string",
|
// Delete the labelContainer from the surroundings object
|
||||||
"default": "Edit",
|
if (this._labelContainer) {
|
||||||
"description": "Text to show as tooltip of defined action"
|
this.getSurroundings().removeDOMNode(this._labelContainer[0]);
|
||||||
}
|
}
|
||||||
|
this._labelContainer = null;
|
||||||
},
|
}
|
||||||
|
// Update the surroundings in order to reflect the change in the label
|
||||||
legacyOptions: ["font_style", "href", "activate_links", "for",
|
this.getSurroundings().update();
|
||||||
"extra_link_target", "extra_link_popup", "statustext"],
|
// Copy the given value
|
||||||
|
this.label = _value;
|
||||||
/**
|
};
|
||||||
* Constructor
|
/**
|
||||||
*
|
* Function to get media content to feed the expose
|
||||||
* @memberOf et2_description
|
* @param {type} _value
|
||||||
*/
|
* @returns {Array|Array.getMedia.mediaContent}
|
||||||
init: function() {
|
*/
|
||||||
this._super.apply(this, arguments);
|
et2_description.prototype.getMedia = function (_value) {
|
||||||
|
var base_url = egw.webserverUrl.match(/^\//, 'ig') ? egw(window).window.location.origin : '';
|
||||||
// Create the span/label tag which contains the label text
|
var mediaContent = [];
|
||||||
this.span = jQuery(document.createElement(this.options["for"] ? "label" : "span"))
|
if (_value) {
|
||||||
.addClass("et2_label");
|
mediaContent = [{
|
||||||
|
title: this.options.label,
|
||||||
|
href: base_url + _value,
|
||||||
|
type: this.options.type + "/*",
|
||||||
et2_insertLinkText(this._parseText(this.options.value), this.span[0],
|
thumbnail: base_url + _value
|
||||||
this.options.href ? this.options.extra_link_target : '_blank');
|
}];
|
||||||
|
if (_value.match(/\/webdav.php/, 'ig'))
|
||||||
this.setDOMNode(this.span[0]);
|
mediaContent[0]["download_href"] = base_url + _value + '?download';
|
||||||
},
|
}
|
||||||
|
return mediaContent;
|
||||||
transformAttributes: function(_attrs) {
|
};
|
||||||
this._super.apply(this, arguments);
|
et2_description.prototype.set_value = function (_value) {
|
||||||
|
if (!_value)
|
||||||
if (this.id)
|
_value = "";
|
||||||
{
|
if (!this.options.no_lang)
|
||||||
var val = this.getArrayMgr("content").getEntry(this.id);
|
_value = this.egw().lang(_value);
|
||||||
|
if (this.options.value && (this.options.value + "").indexOf('%s') != -1) {
|
||||||
if (val)
|
_value = this.options.value.replace(/%s/g, _value);
|
||||||
{
|
}
|
||||||
_attrs["value"] = val;
|
et2_insertLinkText(this._parseText(_value), this.span[0], this.options.href ? this.options.extra_link_target : '_blank');
|
||||||
}
|
// Add hover action button (Edit)
|
||||||
}
|
if (this.options.hover_action) {
|
||||||
},
|
this._build_hover_action();
|
||||||
|
}
|
||||||
doLoadingFinished: function() {
|
if (this.options.extra_link_popup || this.options.mime) {
|
||||||
|
var href = this.options.href;
|
||||||
this._super.apply(this, arguments);
|
var mime_data = this.options.mime_data;
|
||||||
|
var self = this;
|
||||||
// Get the real id of the 'for' widget
|
var $span = this.options.mime_data ? jQuery(this.span) : jQuery('a', this.span);
|
||||||
var for_widget = null;
|
$span.click(function (e) {
|
||||||
if (this.options["for"] && (
|
if (self.options.expose_view && typeof self.options.mime != 'undefined' && self.options.mime.match(self.mime_regexp, 'ig')) {
|
||||||
(for_widget = this.getParent().getWidgetById(this.options.for)) ||
|
// ToDoExpose: self._init_blueimp_gallery(e, href);
|
||||||
(for_widget = this.getRoot().getWidgetById(this.options.for))
|
}
|
||||||
) && for_widget && for_widget.id)
|
else {
|
||||||
{
|
egw(window).open_link(mime_data || href, self.options.extra_link_target, self.options.extra_link_popup, null, null, self.options.mime);
|
||||||
if(for_widget.dom_id)
|
}
|
||||||
{
|
e.preventDefault();
|
||||||
this.span.attr("for", for_widget.dom_id);
|
return false;
|
||||||
}
|
});
|
||||||
else
|
}
|
||||||
{
|
};
|
||||||
// Target widget is not done yet, need to wait
|
et2_description.prototype._parseText = function (_value) {
|
||||||
var tab_deferred = jQuery.Deferred();
|
if (this.options.href) {
|
||||||
window.setTimeout(function() {
|
var href = this.options.href;
|
||||||
this.span.attr("for", for_widget.dom_id);
|
if (href.indexOf('/') == -1 && href.split('.').length >= 3 &&
|
||||||
tab_deferred.resolve();
|
!(href.indexOf('mailto:') != -1 || href.indexOf('://') != -1 || href.indexOf('javascript:') != -1)) {
|
||||||
}.bind(this),0);
|
href = "/index.php?menuaction=" + href;
|
||||||
|
}
|
||||||
return tab_deferred.promise();
|
if (href.charAt(0) == '/') // link relative to eGW
|
||||||
}
|
{
|
||||||
}
|
href = egw.link(href);
|
||||||
return true;
|
}
|
||||||
},
|
return [{
|
||||||
|
"href": href,
|
||||||
set_label: function(_value) {
|
"text": _value
|
||||||
// Abort if ther was no change in the label
|
}];
|
||||||
if (_value == this.label)
|
}
|
||||||
{
|
else if (this.options.activate_links) {
|
||||||
return;
|
return et2_activateLinks(_value);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (_value)
|
return [_value];
|
||||||
{
|
}
|
||||||
// Create the label container if it didn't exist yet
|
};
|
||||||
if (this._labelContainer == null)
|
et2_description.prototype.set_font_style = function (_value) {
|
||||||
{
|
this.font_style = _value;
|
||||||
this._labelContainer = jQuery(document.createElement("label"))
|
this.span.toggleClass("et2_bold", _value.indexOf("b") >= 0);
|
||||||
.addClass("et2_label");
|
this.span.toggleClass("et2_italic", _value.indexOf("i") >= 0);
|
||||||
this.getSurroundings().insertDOMNode(this._labelContainer[0]);
|
};
|
||||||
}
|
/**
|
||||||
|
* Code for implementing et2_IDetachedDOM
|
||||||
// Clear the label container.
|
*
|
||||||
this._labelContainer.empty();
|
* @param {array} _attrs
|
||||||
|
*/
|
||||||
// Create the placeholder element and set it
|
et2_description.prototype.getDetachedAttributes = function (_attrs) {
|
||||||
var ph = document.createElement("span");
|
_attrs.push("value", "class", "href");
|
||||||
this.getSurroundings().setWidgetPlaceholder(ph);
|
};
|
||||||
|
et2_description.prototype.getDetachedNodes = function () {
|
||||||
// Split the label at the "%s"
|
return [this.span[0]];
|
||||||
var parts = et2_csvSplit(_value, 2, "%s");
|
};
|
||||||
|
et2_description.prototype.setDetachedAttributes = function (_nodes, _values, _data) {
|
||||||
// Update the content of the label container
|
// Update the properties
|
||||||
for (var i = 0; i < parts.length; i++)
|
var updateLink = false;
|
||||||
{
|
if (typeof _values["href"] != "undefined") {
|
||||||
if (parts[i])
|
updateLink = true;
|
||||||
{
|
this.options.href = _values["href"];
|
||||||
this._labelContainer.append(document.createTextNode(parts[i]));
|
}
|
||||||
}
|
if (typeof _values["value"] != "undefined" || (updateLink && (_values["value"] || this.options.value))) {
|
||||||
if (i == 0)
|
this.span = jQuery(_nodes[0]);
|
||||||
{
|
this.set_value(_values["value"]);
|
||||||
this._labelContainer.append(ph);
|
}
|
||||||
}
|
if (typeof _values["class"] != "undefined") {
|
||||||
}
|
_nodes[0].setAttribute("class", _values["class"]);
|
||||||
|
}
|
||||||
// add class if label is empty
|
// Add hover action button (Edit), _data is nm's row data
|
||||||
this._labelContainer.toggleClass('et2_label_empty', !_value || !parts[0]);
|
if (this.options.hover_action) {
|
||||||
}
|
this._build_hover_action(_data);
|
||||||
else
|
}
|
||||||
{
|
};
|
||||||
// Delete the labelContainer from the surroundings object
|
/**
|
||||||
if (this._labelContainer)
|
* Builds button for hover action
|
||||||
{
|
* @param {object} _data
|
||||||
this.getSurroundings().removeDOMNode(this._labelContainer[0]);
|
*/
|
||||||
}
|
et2_description.prototype._build_hover_action = function (_data) {
|
||||||
this._labelContainer = null;
|
var content = _data && _data.content ? _data.content : undefined;
|
||||||
}
|
var widget = this;
|
||||||
|
this.span.off().on('mouseenter', jQuery.proxy(function (event) {
|
||||||
// Update the surroundings in order to reflect the change in the label
|
event.stopImmediatePropagation();
|
||||||
this.getSurroundings().update();
|
var self = this;
|
||||||
|
this.span.tooltip({
|
||||||
// Copy the given value
|
items: 'span.et2_label',
|
||||||
this.label = _value;
|
position: { my: "right top", at: "left top", collision: "flipfit" },
|
||||||
},
|
tooltipClass: "et2_email_popup",
|
||||||
/**
|
content: function () {
|
||||||
* Function to get media content to feed the expose
|
return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="' + egw.lang(widget.options.hover_action_title) + '"><img src="'
|
||||||
* @param {type} _value
|
+ egw.image("edit") + '"/></a>')
|
||||||
* @returns {Array|Array.getMedia.mediaContent}
|
.on('click', function () {
|
||||||
*/
|
widget.options.hover_action.call(self, self.widget, content);
|
||||||
getMedia: function (_value)
|
});
|
||||||
{
|
},
|
||||||
var base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin :'';
|
close: function (event, ui) {
|
||||||
var mediaContent = [];
|
ui.tooltip.hover(function () {
|
||||||
if (_value)
|
jQuery(this).stop(true).fadeTo(400, 1);
|
||||||
{
|
}, function () {
|
||||||
mediaContent = [{
|
jQuery(this).fadeOut("400", function () { jQuery(this).remove(); });
|
||||||
title: this.options.label,
|
});
|
||||||
href: base_url + _value,
|
}
|
||||||
type: this.options.type + "/*",
|
})
|
||||||
thumbnail: base_url + _value
|
.tooltip("open");
|
||||||
}];
|
}, { widget: this, span: this.span }));
|
||||||
if (_value.match(/\/webdav.php/,'ig')) mediaContent[0]["download_href"] = base_url + _value + '?download';
|
};
|
||||||
}
|
et2_description._attributes = {
|
||||||
return mediaContent;
|
"label": {
|
||||||
},
|
"name": "Label",
|
||||||
set_value: function(_value) {
|
"default": "",
|
||||||
if (!_value) _value = "";
|
"type": "string",
|
||||||
if (!this.options.no_lang) _value = this.egw().lang(_value);
|
"description": "The label is displayed by default in front (for radiobuttons behind) each widget (if not empty). If you want to specify a different position, use a '%s' in the label, which gets replaced by the widget itself. Eg. '%s Name' to have the label Name behind a checkbox. The label can contain variables, as descript for name. If the label starts with a '@' it is replaced by the value of the content-array at this index (with the '@'-removed and after expanding the variables).",
|
||||||
if (this.options.value && (this.options.value+"").indexOf('%s') != -1)
|
"translate": true
|
||||||
{
|
},
|
||||||
_value = this.options.value.replace(/%s/g, _value);
|
"value": {
|
||||||
}
|
"name": "Value",
|
||||||
et2_insertLinkText(this._parseText(_value),
|
"type": "string",
|
||||||
this.span[0],
|
"description": "Displayed text",
|
||||||
this.options.href ? this.options.extra_link_target : '_blank'
|
"translate": "!no_lang",
|
||||||
);
|
"default": ""
|
||||||
// Add hover action button (Edit)
|
},
|
||||||
if (this.options.hover_action)
|
/**
|
||||||
{
|
* Options converted from the "options"-attribute.
|
||||||
this._build_hover_action();
|
*/
|
||||||
}
|
"font_style": {
|
||||||
if(this.options.extra_link_popup || this.options.mime)
|
"name": "Font Style",
|
||||||
{
|
"type": "string",
|
||||||
var href = this.options.href;
|
"description": "Style may be a compositum of \"b\" and \"i\" which " +
|
||||||
var mime_data = this.options.mime_data;
|
" renders the text bold and/or italic."
|
||||||
var self= this;
|
},
|
||||||
var $span = this.options.mime_data? jQuery(this.span): jQuery('a',this.span);
|
"href": {
|
||||||
$span.click(function(e) {
|
"name": "Link URL",
|
||||||
if (self.options.expose_view && typeof self.options.mime !='undefined' && self.options.mime.match(self.mime_regexp,'ig'))
|
"type": "string",
|
||||||
{
|
"description": "Link URL, empty if you don't wan't to display a link."
|
||||||
self._init_blueimp_gallery(e, href);
|
},
|
||||||
}
|
"activate_links": {
|
||||||
else
|
"name": "Replace URLs",
|
||||||
{
|
"type": "boolean",
|
||||||
egw(window).open_link(mime_data || href, self.options.extra_link_target, self.options.extra_link_popup, null, null, self.options.mime);
|
"default": false,
|
||||||
}
|
"description": "If set, URLs in the text are automatically replaced " +
|
||||||
e.preventDefault();
|
"by links"
|
||||||
return false;
|
},
|
||||||
});
|
"for": {
|
||||||
}
|
"name": "Label for widget",
|
||||||
},
|
"type": "string",
|
||||||
|
"description": "Marks the text as label for the given widget."
|
||||||
_parseText: function(_value) {
|
},
|
||||||
if (this.options.href)
|
"extra_link_target": {
|
||||||
{
|
"name": "Link target",
|
||||||
var href = this.options.href;
|
"type": "string",
|
||||||
if (href.indexOf('/')==-1 && href.split('.').length >= 3 &&
|
"default": "_browser",
|
||||||
!(href.indexOf('mailto:')!=-1 || href.indexOf('://') != -1 || href.indexOf('javascript:') != -1)
|
"description": "Link target for href attribute"
|
||||||
)
|
},
|
||||||
{
|
"extra_link_popup": {
|
||||||
href = "/index.php?menuaction="+href;
|
"name": "Popup",
|
||||||
}
|
"type": "string",
|
||||||
if (href.charAt(0) == '/') // link relative to eGW
|
"description": "widthxheight, if popup should be used, eg. 640x480"
|
||||||
{
|
},
|
||||||
href = egw.link(href);
|
"expose_view": {
|
||||||
}
|
name: "Expose view",
|
||||||
return [{
|
type: "boolean",
|
||||||
"href": href,
|
default: false,
|
||||||
"text": _value
|
description: "Clicking on description with href value would popup an expose view, and will show content referenced by href."
|
||||||
}];
|
},
|
||||||
}
|
mime: {
|
||||||
else if (this.options.activate_links)
|
name: "Mime type",
|
||||||
{
|
type: "string",
|
||||||
return et2_activateLinks(_value);
|
default: '',
|
||||||
}
|
description: "Mime type of the registered link"
|
||||||
else
|
},
|
||||||
{
|
mime_data: {
|
||||||
return [_value];
|
name: "Mime data",
|
||||||
}
|
type: "string",
|
||||||
},
|
default: '',
|
||||||
|
description: "hash for data stored on service-side with egw_link::(get|set)_data()"
|
||||||
set_font_style: function(_value) {
|
},
|
||||||
this.font_style = _value;
|
hover_action: {
|
||||||
|
"name": "hover action",
|
||||||
this.span.toggleClass("et2_bold", _value.indexOf("b") >= 0);
|
"type": "js",
|
||||||
this.span.toggleClass("et2_italic", _value.indexOf("i") >= 0);
|
"default": et2_no_init,
|
||||||
},
|
"description": "JS code which is executed when clicking on action button. This action is explicitly for attached nodes, like in nm."
|
||||||
|
},
|
||||||
/**
|
hover_action_title: {
|
||||||
* Code for implementing et2_IDetachedDOM
|
"name": "hover action title",
|
||||||
*
|
"type": "string",
|
||||||
* @param {array} _attrs
|
"default": "Edit",
|
||||||
*/
|
"description": "Text to show as tooltip of defined action"
|
||||||
getDetachedAttributes: function(_attrs)
|
}
|
||||||
{
|
};
|
||||||
_attrs.push("value", "class", "href");
|
return et2_description;
|
||||||
},
|
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||||
|
et2_core_widget_1.et2_register_widget(et2_description, ["description", "label"]);
|
||||||
getDetachedNodes: function()
|
//# sourceMappingURL=et2_widget_description.js.map
|
||||||
{
|
|
||||||
return [this.span[0]];
|
|
||||||
},
|
|
||||||
|
|
||||||
setDetachedAttributes: function(_nodes, _values, _data)
|
|
||||||
{
|
|
||||||
// Update the properties
|
|
||||||
var updateLink = false;
|
|
||||||
if (typeof _values["href"] != "undefined")
|
|
||||||
{
|
|
||||||
updateLink = true;
|
|
||||||
this.options.href = _values["href"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof _values["value"] != "undefined" || (updateLink && (_values["value"] || this.options.value)))
|
|
||||||
{
|
|
||||||
this.span = jQuery(_nodes[0]);
|
|
||||||
this.set_value(_values["value"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof _values["class"] != "undefined")
|
|
||||||
{
|
|
||||||
_nodes[0].setAttribute("class", _values["class"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add hover action button (Edit), _data is nm's row data
|
|
||||||
if (this.options.hover_action)
|
|
||||||
{
|
|
||||||
this._build_hover_action(_data);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds button for hover action
|
|
||||||
* @param {object} _data
|
|
||||||
*/
|
|
||||||
_build_hover_action: function(_data)
|
|
||||||
{
|
|
||||||
var content = _data && _data.content ? _data.content: undefined;
|
|
||||||
var widget = this;
|
|
||||||
this.span.off().on('mouseenter', jQuery.proxy(function(event) {
|
|
||||||
event.stopImmediatePropagation();
|
|
||||||
var self = this;
|
|
||||||
this.span.tooltip({
|
|
||||||
items: 'span.et2_label',
|
|
||||||
position: {my:"right top", at:"left top", collision:"flipfit"},
|
|
||||||
tooltipClass: "et2_email_popup",
|
|
||||||
content: function()
|
|
||||||
{
|
|
||||||
return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="'+egw.lang(widget.options.hover_action_title)+'"><img src="'
|
|
||||||
+egw.image("edit") +'"/></a>')
|
|
||||||
.on('click', function() {
|
|
||||||
widget.options.hover_action.call(self, self.widget, content);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
close: function( event, ui )
|
|
||||||
{
|
|
||||||
ui.tooltip.hover(
|
|
||||||
function () {
|
|
||||||
jQuery(this).stop(true).fadeTo(400, 1);
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
jQuery(this).fadeOut("400", function(){ jQuery(this).remove();});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.tooltip("open");
|
|
||||||
}, {widget: this, span: this.span}));
|
|
||||||
}
|
|
||||||
}));}).call(this);
|
|
||||||
et2_register_widget(et2_description, ["description", "label"]);
|
|
||||||
|
|
@ -228,3 +228,4 @@ var et2_template = /** @class */ (function (_super) {
|
|||||||
return et2_template;
|
return et2_template;
|
||||||
}(et2_core_DOMWidget_1.et2_DOMWidget));
|
}(et2_core_DOMWidget_1.et2_DOMWidget));
|
||||||
et2_core_widget_1.et2_register_widget(et2_template, ["template"]);
|
et2_core_widget_1.et2_register_widget(et2_template, ["template"]);
|
||||||
|
//# sourceMappingURL=et2_widget_template.js.map
|
@ -575,3 +575,4 @@ var et2_searchbox = /** @class */ (function (_super) {
|
|||||||
return et2_searchbox;
|
return et2_searchbox;
|
||||||
}(et2_textbox));
|
}(et2_textbox));
|
||||||
et2_core_widget_1.et2_register_widget(et2_searchbox, ["searchbox"]);
|
et2_core_widget_1.et2_register_widget(et2_searchbox, ["searchbox"]);
|
||||||
|
//# sourceMappingURL=et2_widget_textbox.js.map
|
@ -175,3 +175,4 @@ var et2_video = /** @class */ (function (_super) {
|
|||||||
};
|
};
|
||||||
return et2_video;
|
return et2_video;
|
||||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||||
|
//# sourceMappingURL=et2_widget_video.js.map
|
Loading…
Reference in New Issue
Block a user