Fix expose class and its derived widgets

This commit is contained in:
Hadi Nategh 2020-02-20 17:46:53 +01:00
parent 9a4f2d1e69
commit b7403af93f
8 changed files with 109 additions and 71 deletions

View File

@ -36,7 +36,13 @@ require("./et2_types");
/**
* Class which implements the "description" XET-Tag
*/
exports.et2_description = expose((_a = /** @class */ (function (_super) {
var et2_description = /** @class */ (function (_super) {
__extends(et2_description, _super);
function et2_description() {
return _super !== null && _super.apply(this, arguments) || this;
}
return et2_description;
}(expose((_a = /** @class */ (function (_super) {
__extends(et2_description, _super);
/**
* Constructor
@ -353,6 +359,8 @@ exports.et2_description = expose((_a = /** @class */ (function (_super) {
"description": "Text to show as tooltip of defined action"
}
},
_a));
et2_core_widget_1.et2_register_widget(exports.et2_description, ["description", "label"]);
_a))));
exports.et2_description = et2_description;
;
et2_core_widget_1.et2_register_widget(et2_description, ["description", "label"]);
//# sourceMappingURL=et2_widget_description.js.map

View File

@ -23,7 +23,7 @@ import './et2_types';
/**
* Class which implements the "description" XET-Tag
*/
export const et2_description = expose(class et2_description extends et2_baseWidget implements et2_IDetachedDOM, et2_IExposable
export class et2_description extends expose(class et2_description extends et2_baseWidget implements et2_IDetachedDOM, et2_IExposable
{
static readonly _attributes : any = {
"label": {
@ -251,8 +251,8 @@ export const et2_description = expose(class et2_description extends et2_baseWidg
*/
getMedia(_value)
{
var base_url = egw.webserverUrl.match(new RegExp(/^\//,'ig'))?egw(window).window.location.origin :'';
var mediaContent = [];
let base_url = egw.webserverUrl.match(new RegExp(/^\//,'ig'))?egw(window).window.location.origin :'';
let mediaContent = [];
if (_value)
{
mediaContent = [{
@ -423,5 +423,5 @@ export const et2_description = expose(class et2_description extends et2_baseWidg
.tooltip("open");
}, {widget: this, span: this.span}));
}
});
}){};
et2_register_widget(et2_description, ["description", "label"]);

View File

@ -1230,7 +1230,13 @@ et2_core_widget_1.et2_register_widget(et2_link, ["link", "link-entry_ro"]);
*
* TODO: This one used to have expose
*/
exports.et2_link_string = expose((_a = /** @class */ (function (_super) {
var et2_link_string = /** @class */ (function (_super) {
__extends(et2_link_string, _super);
function et2_link_string() {
return _super !== null && _super.apply(this, arguments) || this;
}
return et2_link_string;
}(expose((_a = /** @class */ (function (_super) {
__extends(et2_link_string, _super);
/**
* Constructor
@ -1443,8 +1449,10 @@ exports.et2_link_string = expose((_a = /** @class */ (function (_super) {
description: "Clicking on description with href value would popup an expose view, and will show content referenced by href."
}
},
_a));
et2_core_widget_1.et2_register_widget(exports.et2_link_string, ["link-string"]);
_a))));
exports.et2_link_string = et2_link_string;
;
et2_core_widget_1.et2_register_widget(et2_link_string, ["link-string"]);
/**
* UI widget for one or more links in a list (table)
*/
@ -1883,7 +1891,7 @@ var et2_link_list = /** @class */ (function (_super) {
}
};
return et2_link_list;
}(exports.et2_link_string));
}(et2_link_string));
exports.et2_link_list = et2_link_list;
et2_core_widget_1.et2_register_widget(et2_link_list, ["link-list"]);
/**

View File

@ -1496,7 +1496,7 @@ et2_register_widget(et2_link, ["link", "link-entry_ro"]);
*
* TODO: This one used to have expose
*/
export const et2_link_string = expose(class et2_link_string extends et2_valueWidget implements et2_IDetachedDOM, et2_IExposable
export class et2_link_string extends expose(class et2_link_string extends et2_valueWidget implements et2_IDetachedDOM, et2_IExposable
{
static readonly _attributes : any = {
"application": {
@ -1623,8 +1623,8 @@ export const et2_link_string = expose(class et2_link_string extends et2_valueWid
*/
getMedia(_value)
{
var base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin + egw.webserverUrl : egw.webserverUrl;
var mediaContent = [];
let base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin + egw.webserverUrl : egw.webserverUrl;
let mediaContent = [];
if (_value && typeof _value.type !='undefined' && _value.type.match(/video\//,'ig'))
{
mediaContent = [{
@ -1751,7 +1751,7 @@ export const et2_link_string = expose(class et2_link_string extends et2_valueWid
this._labelContainer.contents().not(this.list).remove();
}
}
});
}){};
et2_register_widget(et2_link_string, ["link-string"]);
/**

View File

@ -432,7 +432,13 @@ et2_core_widget_1.et2_register_widget(et2_vfsName_ro, ["vfs-name_ro"]);
* span.overlayContainer is optional and only generated for symlinks
* @augments et2_valueWidget
*/
exports.et2_vfsMime = expose((_a = /** @class */ (function (_super) {
var et2_vfsMime = /** @class */ (function (_super) {
__extends(et2_vfsMime, _super);
function et2_vfsMime() {
return _super !== null && _super.apply(this, arguments) || this;
}
return et2_vfsMime;
}(expose((_a = /** @class */ (function (_super) {
__extends(et2_vfsMime, _super);
/**
* Constructor
@ -611,8 +617,9 @@ exports.et2_vfsMime = expose((_a = /** @class */ (function (_super) {
description: " Size of thumbnail in pixel for specified mime type with syntax of: mime_type(s),size (eg. image,video,128)"
}
},
_a));
et2_core_widget_1.et2_register_widget(exports.et2_vfsMime, ["vfs-mime"]);
_a))));
;
et2_core_widget_1.et2_register_widget(et2_vfsMime, ["vfs-mime"]);
/**
* vfs-size
* Human readable file sizes
@ -1314,5 +1321,6 @@ var et2_vfsSelect = /** @class */ (function (_super) {
};
return et2_vfsSelect;
}(et2_core_inputWidget_1.et2_inputWidget));
;
et2_core_widget_1.et2_register_widget(et2_vfsSelect, ["vfs-select"]);
//# sourceMappingURL=et2_widget_vfs.js.map

View File

@ -485,7 +485,7 @@ et2_register_widget(et2_vfsName_ro, ["vfs-name_ro"]);
* span.overlayContainer is optional and only generated for symlinks
* @augments et2_valueWidget
*/
export const et2_vfsMime = expose(class et2_vfsMime extends et2_valueWidget implements et2_IDetachedDOM, et2_IExposable
class et2_vfsMime extends expose(class et2_vfsMime extends et2_valueWidget implements et2_IDetachedDOM, et2_IExposable
{
static readonly _attributes : any = {
"value": {
@ -693,7 +693,7 @@ export const et2_vfsMime = expose(class et2_vfsMime extends et2_valueWidget impl
this.set_value(_values['value']);
}
}
});
}){};
et2_register_widget(et2_vfsMime, ["vfs-mime"]);
/**
@ -1528,6 +1528,6 @@ class et2_vfsSelect extends et2_inputWidget
{
return this.value;
}
}
};
et2_register_widget(et2_vfsSelect, ["vfs-select"]);

View File

@ -1,4 +1,3 @@
"use strict";
/**
* EGroupware eTemplate2 - JS object implementing expose view of media and a gallery view
*
@ -7,9 +6,12 @@
* @subpackage api
* @link http://www.egroupware.org
* @author Hadi Nategh <hn[at]stylite.de>
* @copyright Stylite AG
* @version $Id$
*/
/*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js;
/api/js/jquery/blueimp/js/blueimp-gallery.min.js;
*/
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@ -23,7 +25,6 @@ var __extends = (this && this.__extends) || (function () {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This function extends the given widget with blueimp gallery plugin
*
@ -349,10 +350,12 @@ function expose(Base) {
exposable.prototype.set_value = function (_value) {
//todo: not sure if we need that with the new construction
//if (typeof this._super == 'undefined') return;
// @ts-ignore
_super.prototype.set_value.call(this, _value);
// Do not run set value of expose if expose_view is not set
// it causes a wired error on nested image widgets which
// seems the expose is not its child widget
// @ts-ignore
if (!this.options.expose_view) {
return;
}
@ -363,7 +366,9 @@ function expose(Base) {
&& (!fe || fe.mime && !fe.mime[_value.mime])) || typeof _value.download_url == 'undefined') {
return;
}
// @ts-ignore
if (typeof this.options.expose_view != 'undefined' && this.options.expose_view) {
// @ts-ignore
jQuery(this.node).on('click', function (event) {
// Do not trigger expose view if one of the operator keys are held
if (!event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) {
@ -406,11 +411,13 @@ function expose(Base) {
}, 1);
}
else {
// @ts-ignore
mediaContent = this.getMedia(_value);
// Do not show thumbnail indicator on single expose view
this.expose_options.thumbnailIndicators = false;
}
this.expose_options.index = current_index;
// @ts-ignore
gallery = blueimp.Gallery(mediaContent, this.expose_options);
};
/**
@ -425,6 +432,7 @@ function expose(Base) {
var res = false;
if (nm) {
if (!target) {
// @ts-ignore
var target_1 = this.getDOMNode();
}
var entry = nm.controller.getRowByNode(target);
@ -435,7 +443,7 @@ function expose(Base) {
return res;
};
exposable.prototype.expose_onopen = function (event) { };
exposable.prototype.expose_onopened = function (event) {
exposable.prototype.expose_onopened = function () {
// Check to see if we're in a nextmatch, do magic
var nm = find_nextmatch(this);
var self = this;
@ -447,9 +455,11 @@ function expose(Base) {
$indicator.off()
.addClass('paginating')
.swipe(function (event, direction, distance) {
// @ts-ignore
if (direction == jQuery.fn.swipe.directions.LEFT) {
distance *= -1;
}
// @ts-ignore
else if (direction == jQuery.fn.swipe.directions.RIGHT) {
// OK.
}
@ -479,15 +489,12 @@ function expose(Base) {
};
/**
* Trigger on slide left/right
* @param {Gallery} gallery
* @param {integer} index
* @param {DOMNode} slide
*/
exposable.prototype.expose_onslide = function (gallery, index, slide) {
//todo
//if (typeof this._super == 'undefined') return;
// First let parent try
_this = _super.call(this, gallery, index, slide) || this;
_super.prototype.expose_onslide.call(this, gallery, index, slide);
var nm = find_nextmatch(this);
if (nm) {
// See if we need to move the indicator
@ -498,7 +505,7 @@ function expose(Base) {
}
}
};
exposable.prototype.expose_onslideend = function (gallery, index, slide) {
exposable.prototype.expose_onslideend = function (gallery, index) {
// Check to see if we're in a nextmatch, do magic
var nm = find_nextmatch(this);
if (nm) {
@ -534,9 +541,8 @@ function expose(Base) {
}
}
};
exposable.prototype.expose_onslidecomplete = function (gallery, index, slide) {
};
exposable.prototype.expose_onclose = function (event) {
exposable.prototype.expose_onslidecomplete = function () { };
exposable.prototype.expose_onclose = function () {
// Check to see if we're in a nextmatch, remove magic
var nm = find_nextmatch(this);
if (nm && !this._is_target_indepth(nm)) {
@ -549,8 +555,7 @@ function expose(Base) {
nm.applyFilters({ col_filter: { mime: '' } });
}
};
exposable.prototype.expose_onclosed = function (event) {
};
exposable.prototype.expose_onclosed = function () { };
return exposable;
}(Base));
}

View File

@ -6,8 +6,6 @@
* @subpackage api
* @link http://www.egroupware.org
* @author Hadi Nategh <hn[at]stylite.de>
* @copyright Stylite AG
* @version $Id$
*/
/*egw:uses
@ -15,9 +13,8 @@
/api/js/jquery/blueimp/js/blueimp-gallery.min.js;
*/
"use strict";
import {WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance";
type Constructor<T = {}> = new (...args: any[]) => T;
@ -60,8 +57,8 @@ function expose<TBase extends Constructor>(Base: TBase) {
* @returns {et2_nextmatch | null}
*/
var find_nextmatch = function (widget) {
var current = widget;
var nextmatch = null;
let current = widget;
let nextmatch = null;
while (nextmatch == null && current) {
current = current.getParent();
if (typeof current != 'undefined' && current.instanceOf(et2_nextmatch)) {
@ -87,10 +84,10 @@ function expose<TBase extends Constructor>(Base: TBase) {
*/
var read_from_nextmatch = function (nm, images, start_at) {
if (!start_at) start_at = 0;
var image_index = start_at;
var stop = Math.max.apply(null, Object.keys(nm.controller._indexMap));
let image_index = start_at;
let stop = Math.max.apply(null, Object.keys(nm.controller._indexMap));
for (var i = start_at; i <= stop; i++) {
for (let i = start_at; i <= stop; i++) {
if (!nm.controller._indexMap[i] || !nm.controller._indexMap[i].uid) {
// Returning instead of using IMAGE_DEFAULT means we stop as
// soon as a hole is found, instead of getting everything that is
@ -98,11 +95,11 @@ function expose<TBase extends Constructor>(Base: TBase) {
images[image_index++] = IMAGE_DEFAULT;
continue;
}
var uid = nm.controller._indexMap[i].uid;
let uid = nm.controller._indexMap[i].uid;
if (!uid) continue;
var data = egw.dataGetUIDdata(uid);
let data = egw.dataGetUIDdata(uid);
if (data && data.data && data.data.mime && MIME_REGEX.test(data.data.mime)) {
var media = this.getMedia(data.data);
let media = this.getMedia(data.data);
images[image_index++] = jQuery.extend({}, data.data, media[0]);
}
}
@ -117,7 +114,7 @@ function expose<TBase extends Constructor>(Base: TBase) {
* @returns {undefined}
*/
var set_slide = function (index, image) {
var active = (index == gallery.index);
let active = (index == gallery.index);
// Pad with blanks until length is right
while (index > gallery.getNumber()) {
@ -139,7 +136,7 @@ function expose<TBase extends Constructor>(Base: TBase) {
}
// Just use add to let gallery create everything it needs
var new_index = gallery.num;
let new_index = gallery.num;
gallery.add([image]);
// Move it to where we want it.
@ -151,15 +148,15 @@ function expose<TBase extends Constructor>(Base: TBase) {
gallery.list.splice(new_index, 1);
// indicators & slides
var dom_nodes = ['indicators', 'slides'];
for (var i in dom_nodes) {
var var_name = dom_nodes[i];
let dom_nodes = ['indicators', 'slides'];
for (let i in dom_nodes) {
let var_name = dom_nodes[i];
// Remove old one from DOM
jQuery(gallery[var_name][index]).remove();
// Move new one into it's place in gallery
gallery[var_name][index] = gallery[var_name][new_index];
// Move into place in DOM
var node = jQuery(gallery[var_name][index]);
let node = jQuery(gallery[var_name][index]);
node.attr('data-index', index)
.insertAfter(jQuery("[data-index='" + (index - 1) + "']", node.parent()));
if (active) node.addClass(gallery.options.activeIndicatorClass);
@ -366,22 +363,26 @@ function expose<TBase extends Constructor>(Base: TBase) {
//todo: not sure if we need that with the new construction
//if (typeof this._super == 'undefined') return;
// @ts-ignore
super.set_value(_value);
// Do not run set value of expose if expose_view is not set
// it causes a wired error on nested image widgets which
// seems the expose is not its child widget
// @ts-ignore
if (!this.options.expose_view) {
return;
}
var fe = egw_get_file_editor_prefered_mimes();
var self = this;
let fe = egw_get_file_editor_prefered_mimes();
let self = this;
// If the media type is not supported do not bind the click handler
if (!_value || typeof _value.mime != 'string' || (!_value.mime.match(MIME_REGEX, 'ig')
&& (!fe || fe.mime && !fe.mime[_value.mime])) || typeof _value.download_url == 'undefined') {
return;
}
// @ts-ignore
if (typeof this.options.expose_view != 'undefined' && this.options.expose_view) {
// @ts-ignore
jQuery(this.node).on('click', function (event) {
// Do not trigger expose view if one of the operator keys are held
if (!event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) {
@ -425,11 +426,13 @@ function expose<TBase extends Constructor>(Base: TBase) {
nm.applyFilters({col_filter: {mime: '/' + MIME_REGEX.source + '/'}});
}, 1);
} else {
// @ts-ignore
mediaContent = this.getMedia(_value);
// Do not show thumbnail indicator on single expose view
this.expose_options.thumbnailIndicators = false;
}
this.expose_options.index = current_index;
// @ts-ignore
gallery = blueimp.Gallery(mediaContent, this.expose_options);
}
@ -446,6 +449,7 @@ function expose<TBase extends Constructor>(Base: TBase) {
let res = false;
if (nm) {
if (!target) {
// @ts-ignore
let target = this.getDOMNode();
}
let entry = nm.controller.getRowByNode(target);
@ -458,7 +462,7 @@ function expose<TBase extends Constructor>(Base: TBase) {
expose_onopen(event) {}
expose_onopened(event)
expose_onopened()
{
// Check to see if we're in a nextmatch, do magic
let nm = find_nextmatch(this);
@ -471,11 +475,18 @@ function expose<TBase extends Constructor>(Base: TBase) {
$indicator.off()
.addClass('paginating')
.swipe(function (event, direction, distance) {
if (direction == jQuery.fn.swipe.directions.LEFT) {
// @ts-ignore
if (direction == jQuery.fn.swipe.directions.LEFT)
{
distance *= -1;
} else if (direction == jQuery.fn.swipe.directions.RIGHT) {
}
// @ts-ignore
else if (direction == jQuery.fn.swipe.directions.RIGHT)
{
// OK.
} else {
}
else
{
return;
}
jQuery(this).css('left', min(0, parseInt(jQuery(this).css('left')) - (distance * 30)) + 'px');
@ -502,16 +513,13 @@ function expose<TBase extends Constructor>(Base: TBase) {
/**
* Trigger on slide left/right
* @param {Gallery} gallery
* @param {integer} index
* @param {DOMNode} slide
*/
expose_onslide(gallery, index, slide)
{
//todo
//if (typeof this._super == 'undefined') return;
// First let parent try
super(gallery, index, slide);
super.expose_onslide(gallery, index, slide);
let nm = find_nextmatch(this);
if (nm) {
// See if we need to move the indicator
@ -524,7 +532,8 @@ function expose<TBase extends Constructor>(Base: TBase) {
}
}
expose_onslideend(gallery, index, slide?) {
expose_onslideend(gallery, index)
{
// Check to see if we're in a nextmatch, do magic
let nm = find_nextmatch(this);
if (nm) {
@ -564,13 +573,14 @@ function expose<TBase extends Constructor>(Base: TBase) {
}
}
expose_onslidecomplete(gallery, index, slide) {
}
expose_onslidecomplete() {}
expose_onclose(event) {
expose_onclose()
{
// Check to see if we're in a nextmatch, remove magic
let nm = find_nextmatch(this);
if (nm && !this._is_target_indepth(nm)) {
if (nm && !this._is_target_indepth(nm))
{
// Remove scrolling from thumbnails
gallery.container.find('.indicator')
.removeClass('paginating')
@ -582,8 +592,7 @@ function expose<TBase extends Constructor>(Base: TBase) {
}
}
expose_onclosed(event) {
}
expose_onclosed() {}
}
}