making video position available and a couple of documentation updates

This commit is contained in:
Ralf Becker
2020-05-10 14:52:47 +02:00
parent cf8f421c4d
commit 4dc120a6d2
9 changed files with 88 additions and 22 deletions

View File

@ -30,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
et2_core_arrayMgr; et2_core_arrayMgr;
*/ */
var et2_core_inheritance_1 = require("./et2_core_inheritance"); var et2_core_inheritance_1 = require("./et2_core_inheritance");
var et2_core_arrayMgr_1 = require("./et2_core_arrayMgr");
/** /**
* The registry contains all XML tag names and the corresponding widget * The registry contains all XML tag names and the corresponding widget
* constructor. * constructor.
@ -316,7 +317,7 @@ var et2_widget = /** @class */ (function (_super) {
} }
} }
if (this.id && _id.indexOf('[') > -1 && this._children.length) { if (this.id && _id.indexOf('[') > -1 && this._children.length) {
var ids = (new et2_arrayMgr()).explodeKey(_id); var ids = (new et2_core_arrayMgr_1.et2_arrayMgr()).explodeKey(_id);
var widget = this; var widget = this;
for (var i = 0; i < ids.length && widget !== null; i++) { for (var i = 0; i < ids.length && widget !== null; i++) {
widget = widget.getWidgetById(ids[i]); widget = widget.getWidgetById(ids[i]);
@ -526,7 +527,7 @@ var et2_widget = /** @class */ (function (_super) {
} }
else { else {
// Try the root, in case a namespace got missed // Try the root, in case a namespace got missed
var entry = modifications.getRoot().getEntry(_node.getAttribute("id")); entry = modifications.getRoot().getEntry(_node.getAttribute("id"));
} }
} }
if (entry && entry.type && typeof entry.type === 'string') { if (entry && entry.type && typeof entry.type === 'string') {

View File

@ -17,6 +17,7 @@
*/ */
import {ClassWithAttributes} from './et2_core_inheritance'; import {ClassWithAttributes} from './et2_core_inheritance';
import {et2_arrayMgr, et2_readonlysArrayMgr} from "./et2_core_arrayMgr";
/** /**
* The registry contains all XML tag names and the corresponding widget * The registry contains all XML tag names and the corresponding widget
@ -527,7 +528,7 @@ export class et2_widget extends ClassWithAttributes
// Check for modifications on legacy options here. Normal modifications // Check for modifications on legacy options here. Normal modifications
// are handled in widget constructor, but it's too late for legacy options then // are handled in widget constructor, but it's too late for legacy options then
if (_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) { if (_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) {
var mod = this.getArrayMgr("modifications").getEntry(_target.id); var mod : any = this.getArrayMgr("modifications").getEntry(_target.id);
if (typeof mod.options != "undefined") attrValue = _attrsObj[i].value = mod.options; if (typeof mod.options != "undefined") attrValue = _attrsObj[i].value = mod.options;
} }
// expand legacyOptions with content // expand legacyOptions with content
@ -652,14 +653,14 @@ export class et2_widget extends ClassWithAttributes
var _nodeName = attributes["type"] = _node.getAttribute("type") ? var _nodeName = attributes["type"] = _node.getAttribute("type") ?
_node.getAttribute("type") : _node.nodeName.toLowerCase(); _node.getAttribute("type") : _node.nodeName.toLowerCase();
var readonly = attributes["readonly"] = this.getArrayMgr("readonlys") ? var readonly = attributes["readonly"] = this.getArrayMgr("readonlys") ?
this.getArrayMgr("readonlys").isReadOnly( (<any>this.getArrayMgr("readonlys")).isReadOnly(
_node.getAttribute("id"), _node.getAttribute("readonly"), _node.getAttribute("id"), _node.getAttribute("readonly"),
typeof this.readonly !== 'undefined' ? this.readonly : this.options.readonly) : false; typeof this.readonly !== 'undefined' ? this.readonly : this.options.readonly) : false;
// Check to see if modifications change type // Check to see if modifications change type
var modifications = this.getArrayMgr("modifications"); var modifications = this.getArrayMgr("modifications");
if (modifications && _node.getAttribute("id")) { if (modifications && _node.getAttribute("id")) {
var entry = modifications.getEntry(_node.getAttribute("id")); var entry : any = modifications.getEntry(_node.getAttribute("id"));
if (entry == null) { if (entry == null) {
// Try again, but skip the fancy stuff // Try again, but skip the fancy stuff
// TODO: Figure out why the getEntry() call doesn't always work // TODO: Figure out why the getEntry() call doesn't always work
@ -668,7 +669,7 @@ export class et2_widget extends ClassWithAttributes
this.egw().debug("warn", "getEntry(" + _node.getAttribute("id") + ") failed, but the data is there.", modifications, entry); this.egw().debug("warn", "getEntry(" + _node.getAttribute("id") + ") failed, but the data is there.", modifications, entry);
} else { } else {
// Try the root, in case a namespace got missed // Try the root, in case a namespace got missed
var entry = modifications.getRoot().getEntry(_node.getAttribute("id")); entry = modifications.getRoot().getEntry(_node.getAttribute("id"));
} }
} }
if (entry && entry.type && typeof entry.type === 'string') { if (entry && entry.type && typeof entry.type === 'string') {
@ -933,7 +934,7 @@ export class et2_widget extends ClassWithAttributes
* @param {string} _part which array mgr to set * @param {string} _part which array mgr to set
* @param {object} _mgr * @param {object} _mgr
*/ */
setArrayMgr(_part : string, _mgr) setArrayMgr(_part : string, _mgr : et2_arrayMgr)
{ {
this._mgrs[_part] = _mgr; this._mgrs[_part] = _mgr;
} }
@ -943,7 +944,7 @@ export class et2_widget extends ClassWithAttributes
* *
* @param {string} managed_array_type name of array mgr to return * @param {string} managed_array_type name of array mgr to return
*/ */
getArrayMgr(managed_array_type : string) getArrayMgr(managed_array_type : string) : et2_arrayMgr | null
{ {
if (this._mgrs && typeof this._mgrs[managed_array_type] != "undefined") { if (this._mgrs && typeof this._mgrs[managed_array_type] != "undefined") {
return this._mgrs[managed_array_type]; return this._mgrs[managed_array_type];

View File

@ -229,5 +229,6 @@ var et2_template = /** @class */ (function (_super) {
}; };
return et2_template; return et2_template;
}(et2_core_DOMWidget_1.et2_DOMWidget)); }(et2_core_DOMWidget_1.et2_DOMWidget));
exports.et2_template = et2_template;
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 //# sourceMappingURL=et2_widget_template.js.map

View File

@ -26,7 +26,7 @@ import './et2_types';
* exists. If yes, this template is removed from the DOM tree, copied and * exists. If yes, this template is removed from the DOM tree, copied and
* inserted in place of this template. * inserted in place of this template.
*/ */
class et2_template extends et2_DOMWidget export class et2_template extends et2_DOMWidget
{ {
static readonly _attributes : any = { static readonly _attributes : any = {
"template": { "template": {

View File

@ -134,6 +134,32 @@ var et2_video = /** @class */ (function (_super) {
this.video.attr("poster", _url); this.video.attr("poster", _url);
} }
}; };
/**
* Seek to a time / position
*
* @param _vtime in seconds
*/
et2_video.prototype.seek_video = function (_vtime) {
this.video[0].currentTime = _vtime;
};
/**
* Play video
*/
et2_video.prototype.play_video = function () {
return this.video[0].play();
};
/**
* Pause video
*/
et2_video.prototype.pause_video = function () {
this.video[0].pause();
};
/**
* Get current video time / position in seconds
*/
et2_video.prototype.currentTime = function () {
return this.video[0].currentTime;
};
et2_video._attributes = { et2_video._attributes = {
"video_src": { "video_src": {
"name": "Video", "name": "Video",

View File

@ -94,7 +94,7 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
} }
}; };
video: JQuery = null; video: JQuery<HTMLVideoElement> = null;
constructor(_parent, _attrs? : WidgetConfig, _child? : object) constructor(_parent, _attrs? : WidgetConfig, _child? : object)
{ {
@ -189,5 +189,39 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
this.video.attr("poster", _url); this.video.attr("poster", _url);
} }
} }
/**
* Seek to a time / position
*
* @param _vtime in seconds
*/
public seek_video(_vtime : number)
{
this.video[0].currentTime = _vtime;
}
/**
* Play video
*/
public play_video() : Promise<void>
{
return this.video[0].play();
}
/**
* Pause video
*/
public pause_video()
{
this.video[0].pause();
}
/**
* Get current video time / position in seconds
*/
public currentTime() : number
{
return this.video[0].currentTime;
}
} }
et2_register_widget(et2_video, ["video"]); et2_register_widget(et2_video, ["video"]);

View File

@ -15,6 +15,7 @@ require("jquery");
require("jqueryui"); require("jqueryui");
require("../jsapi/egw_global"); require("../jsapi/egw_global");
require("../etemplate/et2_types"); require("../etemplate/et2_types");
var etemplate2_1 = require("../etemplate/etemplate2");
/** /**
* Common base class for application javascript * Common base class for application javascript
* Each app should extend as needed. * Each app should extend as needed.
@ -287,7 +288,7 @@ var EgwApp = /** @class */ (function () {
} }
// Try and find a nextmatch widget, and set its filters // Try and find a nextmatch widget, and set its filters
var nextmatched = false; var nextmatched = false;
var et2 = template ? etemplate2.getByTemplate(template) : etemplate2.getByApplication(this.appname); var et2 = template ? etemplate2_1.etemplate2.getByTemplate(template) : etemplate2_1.etemplate2.getByApplication(this.appname);
for (var i = 0; i < et2.length; i++) { for (var i = 0; i < et2.length; i++) {
et2[i].widgetContainer.iterateOver(function (_widget) { et2[i].widgetContainer.iterateOver(function (_widget) {
// Firefox has trouble with spaces in search // Firefox has trouble with spaces in search
@ -336,7 +337,7 @@ var EgwApp = /** @class */ (function () {
EgwApp.prototype.getState = function () { EgwApp.prototype.getState = function () {
var state = {}; var state = {};
// Try and find a nextmatch widget, and set its filters // Try and find a nextmatch widget, and set its filters
var et2 = etemplate2.getByApplication(this.appname); var et2 = etemplate2_1.etemplate2.getByApplication(this.appname);
for (var i = 0; i < et2.length; i++) { for (var i = 0; i < et2.length; i++) {
et2[i].widgetContainer.iterateOver(function (_widget) { et2[i].widgetContainer.iterateOver(function (_widget) {
state = _widget.getValue(); state = _widget.getValue();
@ -437,7 +438,7 @@ var EgwApp = /** @class */ (function () {
'validation_errors': this.et2.getArrayMgr('validation_errors').data 'validation_errors': this.et2.getArrayMgr('validation_errors').data
}; };
// etemplate2 object for view // etemplate2 object for view
this.et2_view = new etemplate2(this.viewTemplate[0], false); this.et2_view = new etemplate2_1.etemplate2(this.viewTemplate[0], '');
framework.pushState('view'); framework.pushState('view');
if (templateName) { if (templateName) {
this.et2_view.load(this.appname + '.' + templateName, templateURL, data, typeof et2_callback == 'function' ? et2_callback : function () { }, app); this.et2_view.load(this.appname + '.' + templateName, templateURL, data, typeof et2_callback == 'function' ? et2_callback : function () { }, app);
@ -597,8 +598,8 @@ var EgwApp = /** @class */ (function () {
*/ */
EgwApp.prototype._refresh_fav_nm = function () { EgwApp.prototype._refresh_fav_nm = function () {
var self = this; var self = this;
if (etemplate2 && etemplate2.getByApplication) { if (etemplate2_1.etemplate2 && etemplate2_1.etemplate2.getByApplication) {
var et2 = etemplate2.getByApplication(self.appname); var et2 = etemplate2_1.etemplate2.getByApplication(self.appname);
for (var i = 0; i < et2.length; i++) { for (var i = 0; i < et2.length; i++) {
et2[i].widgetContainer.iterateOver(function (_widget) { et2[i].widgetContainer.iterateOver(function (_widget) {
_widget.stored_filters = _widget.load_favorites(self.appname); _widget.stored_filters = _widget.load_favorites(self.appname);
@ -1020,7 +1021,7 @@ var EgwApp = /** @class */ (function () {
*/ */
EgwApp.prototype.egwTutorial_init = function (div) { EgwApp.prototype.egwTutorial_init = function (div) {
// et2 object // et2 object
var etemplate = new etemplate2(div, false); var etemplate = new etemplate2_1.etemplate2(div, '');
var template = egw.webserverUrl + '/api/templates/default/egw_tutorial.xet?1'; var template = egw.webserverUrl + '/api/templates/default/egw_tutorial.xet?1';
this.egwTutorialGetData().then(function (_data) { this.egwTutorialGetData().then(function (_data) {
var lang = egw.preference('lang'); var lang = egw.preference('lang');
@ -1062,7 +1063,7 @@ var EgwApp = /** @class */ (function () {
* @param {string} _url * @param {string} _url
*/ */
EgwApp.prototype.tutorial_videoOnClick = function (_url) { EgwApp.prototype.tutorial_videoOnClick = function (_url) {
var frame = etemplate2.getByApplication('api')[0].widgetContainer.getWidgetById('src'); var frame = etemplate2_1.etemplate2.getByApplication('api')[0].widgetContainer.getWidgetById('src');
if (frame) { if (frame) {
frame.set_value(_url); frame.set_value(_url);
} }

View File

@ -14,6 +14,8 @@ import 'jquery';
import 'jqueryui'; import 'jqueryui';
import '../jsapi/egw_global'; import '../jsapi/egw_global';
import '../etemplate/et2_types'; import '../etemplate/et2_types';
import {etemplate2} from "../etemplate/etemplate2";
import {et2_container} from "../etemplate/et2_core_baseWidget";
/** /**
* Type for push-message * Type for push-message
@ -98,7 +100,7 @@ export abstract class EgwApp
* *
* @var {et2_container} * @var {et2_container}
*/ */
et2: any; et2: et2_container;
/** /**
* Internal reference to egw client-side api object for current app and window * Internal reference to egw client-side api object for current app and window
@ -191,7 +193,7 @@ export abstract class EgwApp
* @param {etemplate2} et2 * @param {etemplate2} et2
* @param {string} name template name * @param {string} name template name
*/ */
et2_ready(et2, name : string) et2_ready(et2 : etemplate2, name : string)
{ {
if(this.et2 !== null) if(this.et2 !== null)
{ {
@ -581,7 +583,7 @@ export abstract class EgwApp
}; };
// etemplate2 object for view // etemplate2 object for view
this.et2_view = new etemplate2 (this.viewTemplate[0], false); this.et2_view = new etemplate2 (this.viewTemplate[0], '');
framework.pushState('view'); framework.pushState('view');
if(templateName) if(templateName)
{ {
@ -1284,7 +1286,7 @@ export abstract class EgwApp
egwTutorial_init(div) egwTutorial_init(div)
{ {
// et2 object // et2 object
var etemplate = new etemplate2 (div, false); var etemplate = new etemplate2 (div, '');
var template = egw.webserverUrl+'/api/templates/default/egw_tutorial.xet?1'; var template = egw.webserverUrl+'/api/templates/default/egw_tutorial.xet?1';
this.egwTutorialGetData().then(function(_data){ this.egwTutorialGetData().then(function(_data){

View File

@ -680,7 +680,7 @@ declare class JsonRequest
* *
* @return {jqXHR} jQuery jqXHR request object * @return {jqXHR} jQuery jqXHR request object
*/ */
sendRequest(async? : boolean|"keepalive", method? : "POST"|"GET", error? : Function) sendRequest(async? : boolean|"keepalive", method? : "POST"|"GET", error? : Function) : Promise<any>
/** /**
* Open websocket to push server (and keeps it open) * Open websocket to push server (and keeps it open)
* *