2011-08-23 16:29:56 +02:00
|
|
|
/**
|
|
|
|
* EGroupware clientside API object
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
2021-06-05 20:39:39 +02:00
|
|
|
* @link https://www.egroupware.org
|
2011-08-23 16:29:56 +02:00
|
|
|
* @author Andreas Stöckel (as AT stylite.de)
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
*/
|
|
|
|
|
2012-03-01 17:24:29 +01:00
|
|
|
/*egw:uses
|
|
|
|
egw_core;
|
2012-03-05 16:02:00 +01:00
|
|
|
egw_debug;
|
2012-03-01 17:24:29 +01:00
|
|
|
egw_preferences;
|
|
|
|
egw_lang;
|
|
|
|
egw_links;
|
2012-03-28 14:37:03 +02:00
|
|
|
egw_open;
|
2012-03-01 17:24:29 +01:00
|
|
|
egw_user;
|
|
|
|
egw_config;
|
|
|
|
egw_images;
|
|
|
|
egw_jsonq;
|
2012-03-05 14:07:38 +01:00
|
|
|
egw_files;
|
2012-03-05 16:02:00 +01:00
|
|
|
egw_json;
|
2013-10-05 11:28:12 +02:00
|
|
|
egw_store;
|
2012-03-06 14:22:01 +01:00
|
|
|
egw_tooltip;
|
2012-03-07 15:04:25 +01:00
|
|
|
egw_css;
|
2012-03-08 12:29:46 +01:00
|
|
|
egw_calendar;
|
2012-03-20 13:05:31 +01:00
|
|
|
egw_data;
|
2014-01-27 15:29:24 +01:00
|
|
|
egw_tail;
|
2013-04-09 10:45:59 +02:00
|
|
|
egw_inheritance;
|
2014-02-06 16:42:33 +01:00
|
|
|
egw_message;
|
2016-04-29 16:25:07 +02:00
|
|
|
egw_notification;
|
2012-03-01 17:24:29 +01:00
|
|
|
*/
|
2011-08-23 16:29:56 +02:00
|
|
|
|
2021-06-11 13:47:59 +02:00
|
|
|
/**
|
|
|
|
* Object to collect instantiated application objects
|
|
|
|
*
|
|
|
|
* Attributes classes collects loaded application classes,
|
|
|
|
* which can get instantiated:
|
|
|
|
*
|
|
|
|
* app[appname] = new app.classes[appname]();
|
|
|
|
*
|
|
|
|
* On destruction only app[appname] gets deleted, app.classes[appname] need to be used again!
|
|
|
|
*
|
|
|
|
* @type object
|
|
|
|
*/
|
|
|
|
window.app = {classes: {}};
|
|
|
|
|
2016-02-29 16:50:24 +01:00
|
|
|
(function()
|
|
|
|
{
|
|
|
|
"use strict";
|
|
|
|
|
2013-07-19 10:45:26 +02:00
|
|
|
var debug = false;
|
|
|
|
var egw_script = document.getElementById('egw_script_id');
|
2014-01-09 13:20:13 +01:00
|
|
|
var start_time = (new Date).getTime();
|
2015-03-27 11:46:56 +01:00
|
|
|
if(typeof console != "undefined" && console.time) console.time("egw");
|
2013-11-05 19:08:07 +01:00
|
|
|
|
2014-11-27 18:34:06 +01:00
|
|
|
// set opener as early as possible for framework popups (not real popups)
|
|
|
|
if (!window.opener && window.parent !== window)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
if (window.parent.framework && typeof window.parent.framework.popup_idx == 'function' &&
|
|
|
|
window.parent.framework.popup_idx.call(window.parent.framework, window) !== undefined)
|
|
|
|
{
|
|
|
|
window.opener = window.parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if opener is different security context / cross-origin
|
|
|
|
}
|
|
|
|
}
|
2013-10-07 12:09:08 +02:00
|
|
|
// Flag for if this is opened in a popup
|
2013-12-19 18:18:01 +01:00
|
|
|
var popup = (window.opener != null);
|
2013-11-05 19:08:07 +01:00
|
|
|
|
2013-07-19 10:45:26 +02:00
|
|
|
window.egw_webserverUrl = egw_script.getAttribute('data-url');
|
|
|
|
window.egw_appName = egw_script.getAttribute('data-app');
|
|
|
|
|
2021-06-10 11:38:54 +02:00
|
|
|
// split includes in legacy js and modules
|
|
|
|
const legacy_js_regexp = /\/dhtmlx|jquery/;
|
|
|
|
|
2013-07-19 10:45:26 +02:00
|
|
|
// check if egw object was injected by window open
|
|
|
|
if (typeof window.egw == 'undefined')
|
|
|
|
{
|
2014-01-08 16:14:10 +01:00
|
|
|
try {
|
|
|
|
// try finding it in top or opener's top
|
|
|
|
if (window.opener && typeof window.opener.top.egw != 'undefined')
|
|
|
|
{
|
|
|
|
window.egw = window.opener.top.egw;
|
|
|
|
if (typeof window.opener.top.framework != 'undefined') window.framework = window.opener.top.framework;
|
|
|
|
popup = true;
|
|
|
|
if (debug) console.log('found egw object in opener');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if opener is different security context / cross-origin
|
|
|
|
}
|
2017-03-08 14:14:16 +01:00
|
|
|
try {
|
|
|
|
// try finding it in top
|
|
|
|
if (typeof window.egw == 'undefined' && window.top && typeof window.top.egw != 'undefined')
|
|
|
|
{
|
|
|
|
window.egw = window.top.egw;
|
|
|
|
if (typeof window.top.framework != 'undefined') window.framework = window.top.framework;
|
|
|
|
if (debug) console.log('found egw object in top');
|
|
|
|
}
|
2013-07-19 10:45:26 +02:00
|
|
|
}
|
2017-03-08 14:14:16 +01:00
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if top is different security context / cross-origin
|
2013-07-19 10:45:26 +02:00
|
|
|
}
|
2017-03-08 14:14:16 +01:00
|
|
|
if (typeof window.egw == 'undefined')
|
2013-07-19 10:45:26 +02:00
|
|
|
{
|
|
|
|
window.egw = {
|
|
|
|
prefsOnly: true,
|
2021-06-10 11:38:54 +02:00
|
|
|
legacy_js_regexp: legacy_js_regexp,
|
2013-07-19 10:45:26 +02:00
|
|
|
webserverUrl: egw_webserverUrl
|
|
|
|
};
|
|
|
|
if (debug) console.log('creating new egw object');
|
|
|
|
}
|
|
|
|
}
|
2013-07-19 17:22:37 +02:00
|
|
|
else if (debug) console.log('found injected egw object');
|
2013-11-05 19:08:07 +01:00
|
|
|
|
2020-10-22 10:00:13 +02:00
|
|
|
var include = JSON.parse(egw_script.getAttribute('data-include')) || [];
|
|
|
|
|
2013-07-19 10:45:26 +02:00
|
|
|
// check for a framework object
|
|
|
|
if (typeof window.framework == 'undefined')
|
|
|
|
{
|
2014-01-08 16:19:04 +01:00
|
|
|
try {
|
|
|
|
// try finding it in top or opener's top
|
|
|
|
if (window.opener && typeof window.opener.top.framework != 'undefined')
|
|
|
|
{
|
|
|
|
window.framework = window.opener.top.framework;
|
|
|
|
if (debug) console.log('found framework object in opener top');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if opener is different security context / cross-origin
|
|
|
|
}
|
2017-03-08 14:21:29 +01:00
|
|
|
try {
|
|
|
|
if (typeof window.framework == 'undefined' && window.top && typeof window.top.framework != 'undefined')
|
|
|
|
{
|
|
|
|
window.framework = window.top.framework;
|
|
|
|
if (debug) console.log('found framework object in top');
|
|
|
|
}
|
2013-07-19 10:45:26 +02:00
|
|
|
}
|
2017-03-08 14:21:29 +01:00
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if top is different security context / cross-origin
|
2013-07-19 10:45:26 +02:00
|
|
|
}
|
|
|
|
// if framework not found, but requested to check for it, redirect to cd=yes to create it
|
2020-10-22 10:00:13 +02:00
|
|
|
var check_framework = egw_script.getAttribute('data-check-framework');
|
2020-10-14 17:31:17 +02:00
|
|
|
if (typeof window.framework == 'undefined' &&
|
2020-10-22 10:00:13 +02:00
|
|
|
!window.location.pathname.match(/\/(smallpart\/|login.php)/) && // not for login page
|
|
|
|
!window.location.search.match(/[&?]cd=/) &&
|
|
|
|
// for popups check if required files are not about to be loaded (saved additional redirect and fixes LTI launches)
|
|
|
|
(check_framework || include.filter(function(_uri){return _uri.match(/api\/(config|user)\.php/);}).length < 2))
|
2013-07-19 10:45:26 +02:00
|
|
|
{
|
2020-10-22 10:00:13 +02:00
|
|
|
window.location.search += (window.location.search ? "&" : "?")+(check_framework ? "cd=yes" : "cd=popup");
|
2013-07-19 10:45:26 +02:00
|
|
|
}
|
|
|
|
}
|
2015-10-26 22:13:34 +01:00
|
|
|
try {
|
2015-11-02 18:04:40 +01:00
|
|
|
if (typeof egw == 'function') egw(window).message;
|
2015-10-26 22:13:34 +01:00
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log('Security exception accessing window specific egw object --> creating new one', e);
|
|
|
|
window.egw = {
|
|
|
|
prefsOnly: true,
|
2021-06-10 11:38:54 +02:00
|
|
|
legacy_js_regexp: legacy_js_regexp,
|
2015-10-26 22:13:34 +01:00
|
|
|
webserverUrl: egw_webserverUrl
|
|
|
|
};
|
|
|
|
}
|
2020-05-18 20:55:57 +02:00
|
|
|
// set top window in egw object
|
|
|
|
if (typeof window.egw.top === "undefined")
|
|
|
|
{
|
|
|
|
window.egw.top = window;
|
|
|
|
}
|
2013-11-05 19:08:07 +01:00
|
|
|
|
2013-08-26 12:24:11 +02:00
|
|
|
// focus window / call window.focus(), if data-window-focus is specified
|
2013-08-20 15:25:36 +02:00
|
|
|
var window_focus = egw_script.getAttribute('data-window-focus');
|
|
|
|
if (window_focus && JSON.parse(window_focus))
|
|
|
|
{
|
|
|
|
window.focus();
|
|
|
|
}
|
2013-07-19 10:45:26 +02:00
|
|
|
|
2021-06-05 20:39:39 +02:00
|
|
|
/**
|
|
|
|
* Import JavaScript legacy code: global scope, non-strict and executed in order
|
|
|
|
*
|
|
|
|
* @param String|Array _src
|
|
|
|
* @param String|undefined _baseurl
|
|
|
|
* @return {Promise<Promise<unknown>[]>}
|
|
|
|
*/
|
|
|
|
async function legacy_js_import(_src, _baseurl)
|
|
|
|
{
|
|
|
|
if (!Array.isArray(_src)) _src = [].concat(_src);
|
|
|
|
return Promise.all(_src.map(src => {
|
|
|
|
return new Promise(function(_resolve, _reject)
|
|
|
|
{
|
|
|
|
const script = document.createElement('script');
|
|
|
|
script.src = (_baseurl ? _baseurl+'/' : '')+src;
|
|
|
|
script.async = _src.length === 1;
|
|
|
|
script.onload = _resolve;
|
|
|
|
script.onerror = _reject;
|
|
|
|
document.head.appendChild(script);
|
|
|
|
})
|
|
|
|
// catch and display, but not stop execution
|
2021-06-08 14:11:59 +02:00
|
|
|
.catch((err) => { console.log(src+":\n\n"+err.message)});
|
2021-06-05 20:39:39 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
// make our promise global, as legacy code calls egw_LAB.wait which we assign to egw_ready.then
|
2021-06-10 11:38:54 +02:00
|
|
|
window.egw_LAB = window.egw_ready =
|
|
|
|
legacy_js_import(include.filter((src) => src.match(legacy_js_regexp) !== null), window.egw_webserverUrl)
|
|
|
|
.then(() => Promise.all(include.filter((src) => src.match(legacy_js_regexp) === null)
|
2021-06-05 20:39:39 +02:00
|
|
|
.map(rel_src => import(window.egw_webserverUrl+'/'+rel_src)
|
2021-06-08 14:11:59 +02:00
|
|
|
.catch((err) => { console.log(rel_src+":\n\n"+err.message)})
|
2021-06-05 20:39:39 +02:00
|
|
|
))).then(() =>
|
2013-11-05 19:08:07 +01:00
|
|
|
{
|
2017-10-27 17:42:04 +02:00
|
|
|
// We need to override the globalEval to mitigate potential execution of
|
|
|
|
// script tag. This issue is relevant to jQuery 1.12.4, we need to check
|
|
|
|
// if we still need this after upgrading jQuery.
|
|
|
|
jQuery.extend({
|
|
|
|
globalEval:function(data){}
|
|
|
|
});
|
|
|
|
|
2014-11-26 19:37:36 +01:00
|
|
|
// call egw.link_handler, if attr specified
|
|
|
|
var egw_redirect = egw_script.getAttribute('data-egw-redirect');
|
|
|
|
if (egw_redirect)
|
|
|
|
{
|
|
|
|
// set sidebox for tabed templates, we need to set it now, as framework will not resent it!
|
|
|
|
var sidebox = egw_script.getAttribute('data-setSidebox');
|
|
|
|
if (window.framework && sidebox)
|
|
|
|
{
|
|
|
|
window.framework.setSidebox.apply(window.framework, JSON.parse(sidebox));
|
|
|
|
}
|
|
|
|
egw_redirect = JSON.parse(egw_redirect);
|
|
|
|
egw.link_handler.apply(egw, egw_redirect);
|
|
|
|
return; // do NOT execute any further code, as IE(11) will give errors because framework already redirects
|
|
|
|
}
|
|
|
|
|
|
|
|
// call egw_refresh on opener, if attr specified
|
|
|
|
var refresh_opener = egw_script.getAttribute('data-refresh-opener');
|
|
|
|
if (refresh_opener && window.opener)
|
|
|
|
{
|
|
|
|
refresh_opener = JSON.parse(refresh_opener) || {};
|
2014-12-10 14:33:42 +01:00
|
|
|
window.opener.egw(window.opener).refresh.apply(egw(window.opener), refresh_opener);
|
2014-11-26 19:37:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// close window / call window.close(), if data-window-close is specified
|
|
|
|
var window_close = egw_script.getAttribute('data-window-close');
|
|
|
|
if (window_close)
|
|
|
|
{
|
|
|
|
if (typeof window_close == 'string' && window_close !== '1')
|
|
|
|
{
|
|
|
|
alert(window_close);
|
|
|
|
}
|
|
|
|
// If there's a message & opener, set it
|
|
|
|
if(window.opener && egw_script.getAttribute('data-message'))
|
|
|
|
{
|
|
|
|
egw(window.opener).message(JSON.parse(egw_script.getAttribute('data-message')));
|
|
|
|
}
|
2014-11-27 18:01:47 +01:00
|
|
|
egw(window).close();
|
2014-11-26 19:37:36 +01:00
|
|
|
}
|
|
|
|
|
2014-06-18 15:57:15 +02:00
|
|
|
// call egw.open_link, if popup attr specified
|
|
|
|
var egw_popup = egw_script.getAttribute('data-popup');
|
|
|
|
if (egw_popup)
|
|
|
|
{
|
|
|
|
egw_popup = JSON.parse(egw_popup) || [];
|
|
|
|
egw.open_link.apply(egw, egw_popup);
|
|
|
|
}
|
|
|
|
|
2020-07-13 19:25:48 +02:00
|
|
|
// set grants if given for push
|
2020-09-17 15:36:02 +02:00
|
|
|
var egw_grants = egw_script.getAttribute('data-grants');
|
2020-07-13 19:25:48 +02:00
|
|
|
if (egw_grants)
|
|
|
|
{
|
|
|
|
egw.set_grants(JSON.parse(egw_grants));
|
|
|
|
}
|
|
|
|
|
2015-03-27 11:46:56 +01:00
|
|
|
if(typeof console != "undefined" && console.timeEnd) console.timeEnd("egw");
|
2014-01-09 13:20:13 +01:00
|
|
|
var end_time = (new Date).getTime();
|
2016-06-02 16:51:15 +02:00
|
|
|
var gen_time_div = jQuery('#divGenTime_'+window.egw_appName);
|
|
|
|
if (!gen_time_div.length) gen_time_div = jQuery('.pageGenTime');
|
2016-07-15 09:34:48 +02:00
|
|
|
var gen_time_async = jQuery('.asyncIncludeTime').length > 0 ? jQuery('.asyncIncludeTime'):
|
|
|
|
gen_time_div.append('<span class="asyncIncludeTime"></span>').find('.asyncIncludeTime');
|
|
|
|
gen_time_async.text(egw.lang('async includes took %1s', (end_time-start_time)/1000));
|
2014-01-09 13:20:13 +01:00
|
|
|
|
2013-10-10 11:37:21 +02:00
|
|
|
// Make sure opener knows when we close - start a heartbeat
|
2021-05-20 16:35:54 +02:00
|
|
|
try {
|
2021-05-20 16:35:54 +02:00
|
|
|
if ((window.opener && window.opener.framework || popup) && window.name != '') {
|
2021-05-20 16:35:54 +02:00
|
|
|
// Timeout is 5 seconds, but it iks only applied(egw_utils) when something asks for the window list
|
|
|
|
window.setInterval(function () {
|
|
|
|
if (window.opener && window.opener.framework && typeof window.opener.framework.popup_idx(window) == 'undefined' && !egwIsMobile()) {
|
|
|
|
window.opener.framework.popups.push(window);
|
|
|
|
}
|
|
|
|
egw().storeWindow(this.egw_appName, this);
|
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if opener is different security context / cross-origin
|
2013-10-07 12:09:08 +02:00
|
|
|
}
|
2021-06-05 20:39:39 +02:00
|
|
|
// instantiate app object
|
2013-11-05 19:08:07 +01:00
|
|
|
var appname = window.egw_appName;
|
2016-03-17 19:12:36 +01:00
|
|
|
if (app && typeof app[appname] != 'object' && typeof app.classes[appname] == 'function')
|
2013-11-05 19:08:07 +01:00
|
|
|
{
|
2016-03-17 19:12:36 +01:00
|
|
|
app[appname] = new app.classes[appname]();
|
2013-11-05 19:08:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-29 00:18:36 +01:00
|
|
|
// set sidebox for tabed templates
|
2014-02-21 18:06:11 +01:00
|
|
|
var sidebox = egw_script.getAttribute('data-setSidebox') || jQuery('#late-sidebox').attr('data-setSidebox');
|
2015-01-09 19:58:23 +01:00
|
|
|
if (window.framework && sidebox && sidebox !== 'null')
|
2013-11-29 00:18:36 +01:00
|
|
|
{
|
|
|
|
window.framework.setSidebox.apply(window.framework, JSON.parse(sidebox));
|
|
|
|
}
|
|
|
|
|
2014-11-28 15:00:40 +01:00
|
|
|
var resize_attempt = 0;
|
|
|
|
var resize_popup = function()
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
var $main_div = jQuery('#popupMainDiv');
|
|
|
|
var $et2 = jQuery('.et2_container');
|
2014-11-28 15:00:40 +01:00
|
|
|
var w = {
|
|
|
|
width: egw_getWindowInnerWidth(),
|
|
|
|
height: egw_getWindowInnerHeight()
|
|
|
|
};
|
|
|
|
// Use et2_container for width since #popupMainDiv is full width, but we still need
|
|
|
|
// to take padding/margin into account
|
|
|
|
var delta_width = w.width - ($et2.outerWidth(true) + ($main_div.outerWidth(true) - $main_div.width()));
|
|
|
|
var delta_height = w.height - ($et2.outerHeight(true) + ($main_div.outerHeight(true) - $main_div.height()));
|
2015-10-24 13:07:22 +02:00
|
|
|
|
2015-10-01 15:17:41 +02:00
|
|
|
// Don't let the window gets horizental scrollbar
|
|
|
|
var scrollWidth = document.body.scrollWidth - document.body.clientWidth;
|
|
|
|
if (scrollWidth > 0 && scrollWidth + egw_getWindowOuterWidth() < screen.availWidth) delta_width = -scrollWidth;
|
2015-10-24 13:07:22 +02:00
|
|
|
|
2014-11-28 15:00:40 +01:00
|
|
|
if (delta_height && egw_getWindowOuterHeight() >= egw.availHeight())
|
|
|
|
{
|
|
|
|
delta_height = 0;
|
|
|
|
}
|
2015-01-09 19:58:23 +01:00
|
|
|
if((delta_width != 0 || delta_height != 0) &&
|
2015-01-06 15:52:41 +01:00
|
|
|
(delta_width >2 || delta_height >2 || delta_width<-2 || delta_height < -2))
|
2014-11-28 15:00:40 +01:00
|
|
|
{
|
2015-01-09 19:58:23 +01:00
|
|
|
|
2014-12-01 18:38:52 +01:00
|
|
|
if (window.framework && typeof window.framework.resize_popup != 'undefined')
|
|
|
|
{
|
|
|
|
window.framework.resize_popup($et2.outerWidth(true), $et2.outerHeight(true), window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-06 15:52:41 +01:00
|
|
|
window.resizeTo(egw_getWindowOuterWidth() - delta_width+8, egw_getWindowOuterHeight() - delta_height);
|
2014-12-01 18:38:52 +01:00
|
|
|
}
|
2014-11-28 15:00:40 +01:00
|
|
|
}
|
|
|
|
// trigger a 2. resize, as one is not enough, if window is zoomed
|
|
|
|
if (delta_width && ++resize_attempt < 2)
|
|
|
|
{
|
|
|
|
window.setTimeout(resize_popup, 50);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resize_attempt = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-21 15:38:23 +02:00
|
|
|
// rest needs DOM to be ready
|
2021-06-09 10:13:51 +02:00
|
|
|
jQuery(function()
|
|
|
|
{
|
2014-07-21 15:38:23 +02:00
|
|
|
// load etemplate2 template(s)
|
2021-06-09 10:13:51 +02:00
|
|
|
jQuery('form.et2_container[data-etemplate]').each( function(index, node)
|
|
|
|
{
|
|
|
|
import('../etemplate/etemplate2.js').then((module) => {
|
|
|
|
const data = JSON.parse(node.getAttribute('data-etemplate')) || {};
|
|
|
|
if (popup || window.opener && !egwIsMobile()) {
|
|
|
|
// Resize popup when et2 load is done
|
|
|
|
jQuery(node).on('load', () => window.setTimeout(resize_popup, 50));
|
|
|
|
}
|
|
|
|
const et2 = new module.etemplate2(node, "EGroupware\\Api\\Etemplate::ajax_process_content");
|
|
|
|
et2.load(data.name, data.url, data.data);
|
|
|
|
if (typeof data.response !== 'undefined') {
|
|
|
|
const json_request = egw(window).json("");
|
|
|
|
json_request.handleResponse({response: data.response});
|
|
|
|
}
|
|
|
|
}).catch((e) => alert(e.message+"\n\n"+e.stack));
|
2014-07-21 15:38:23 +02:00
|
|
|
});
|
|
|
|
|
2018-10-01 15:54:42 +02:00
|
|
|
// Offline/Online checking part
|
|
|
|
if (typeof window.Offline != 'undefined')
|
|
|
|
{
|
|
|
|
Offline.options = {
|
2021-06-07 17:33:53 +02:00
|
|
|
// Should we check the connection status immediately on page load.
|
2018-10-01 15:54:42 +02:00
|
|
|
checkOnLoad: false,
|
|
|
|
|
|
|
|
// Should we monitor AJAX requests to help decide if we have a connection.
|
|
|
|
interceptRequests: true,
|
|
|
|
|
|
|
|
// Should we automatically retest periodically when the connection is down (set to false to disable).
|
|
|
|
reconnect: {
|
|
|
|
// How many seconds should we wait before rechecking.
|
|
|
|
initialDelay: 3,
|
|
|
|
|
|
|
|
// How long should we wait between retries.
|
|
|
|
//delay: (1.5 * last delay, capped at 1 hour)
|
|
|
|
},
|
|
|
|
|
|
|
|
// Should we store and attempt to remake requests which fail while the connection is down.
|
|
|
|
requests: true,
|
|
|
|
|
|
|
|
checks: {
|
|
|
|
xhr: {
|
2018-10-02 10:12:40 +02:00
|
|
|
url: egw.webserverUrl+'/api/templates/default/images/favicon.ico?'+Date.now()
|
2018-10-01 15:54:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.Offline.on('down', function(){
|
|
|
|
this.loading_prompt('connectionLost', true, '', null);
|
|
|
|
}, egw(window));
|
|
|
|
window.Offline.on('up', function(){
|
2020-10-21 11:54:35 +02:00
|
|
|
jQuery('.close', '#egw_message').click();
|
2018-10-01 15:54:42 +02:00
|
|
|
this.loading_prompt('connectionLost', false);
|
|
|
|
}, egw(window));
|
|
|
|
}
|
|
|
|
|
2014-01-10 10:13:56 +01:00
|
|
|
// set app-header
|
2014-02-06 16:42:33 +01:00
|
|
|
if (window.framework && egw_script.getAttribute('data-app-header'))
|
2013-07-20 15:42:23 +02:00
|
|
|
{
|
2014-02-07 10:11:30 +01:00
|
|
|
egw(window).app_header(egw_script.getAttribute('data-app-header'), appname);
|
2013-07-20 15:42:23 +02:00
|
|
|
}
|
2014-01-10 10:13:56 +01:00
|
|
|
// display a message
|
2014-02-06 16:42:33 +01:00
|
|
|
if (egw_script.getAttribute('data-message'))
|
2013-07-20 15:42:23 +02:00
|
|
|
{
|
2014-04-01 16:16:11 +02:00
|
|
|
var params = JSON.parse(egw_script.getAttribute('data-message')) || [''];
|
|
|
|
egw(window).message.apply(egw(window), params);
|
2013-07-19 10:45:26 +02:00
|
|
|
}
|
2014-03-03 18:35:48 +01:00
|
|
|
// hide location bar for mobile browsers
|
|
|
|
if (egw_script.getAttribute('data-mobile'))
|
|
|
|
{
|
|
|
|
window.scrollTo(0, 1);
|
|
|
|
}
|
2017-03-08 14:25:52 +01:00
|
|
|
try {
|
|
|
|
// Open tutorial popup with an introduction video about egroupware
|
|
|
|
if (window.framework === window.top.framework && typeof et2_dialog != 'undefined' &&
|
|
|
|
!egw.preference('egw_tutorial_noautoload', 'common') &&
|
2019-11-04 09:29:49 +01:00
|
|
|
!parseInt(egw_script.getAttribute('data-framework-reload')) &&
|
2017-03-08 14:25:52 +01:00
|
|
|
(!egw.config('egw_tutorial_disable', 'phpgwapi') || egw.config('egw_tutorial_disable', 'phpgwapi') == 'sidebox'))
|
2015-10-24 13:07:22 +02:00
|
|
|
{
|
2017-03-08 14:25:52 +01:00
|
|
|
// we need to wait until common translations are loaded
|
|
|
|
egw.langRequireApp(window, 'common', function()
|
2015-10-24 13:07:22 +02:00
|
|
|
{
|
2017-03-08 14:25:52 +01:00
|
|
|
var buttons = [
|
|
|
|
{text:egw.lang("Show now"), id:"show", image: "check", default:"true"},
|
|
|
|
{text:egw.lang("Show next login"), id:"later", image: "right"},
|
|
|
|
{text:egw.lang("No thanks"), id:"never", image: "cancel"}
|
|
|
|
];
|
|
|
|
et2_dialog.show_dialog(function (_button_id)
|
2015-10-24 13:07:22 +02:00
|
|
|
{
|
2017-03-08 14:25:52 +01:00
|
|
|
if (_button_id == "show" )
|
|
|
|
{
|
|
|
|
egw.open_link(egw.link('/index.php', 'menuaction=api.EGroupware\\Api\\Framework\\Tutorial.popup&tuid=introduction-'+egw.preference('lang')+'-0-a'),'_blank','960x580');
|
|
|
|
}
|
|
|
|
if(_button_id != "later")
|
|
|
|
{
|
|
|
|
egw.set_preference('common', 'egw_tutorial_noautoload',true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
egw.lang('We would like to introduce you to EGroupware by showing a short introduction video.'),
|
|
|
|
egw.lang('Introduction'),
|
|
|
|
{}, buttons, et2_dialog.QUESTION_MESSAGE, undefined, egw(window));
|
|
|
|
}, this);
|
|
|
|
}
|
2019-11-04 09:29:49 +01:00
|
|
|
|
|
|
|
// open websocket to push server for our top window
|
|
|
|
if (egw === window.top.egw && egw_script.getAttribute('data-websocket-url'))
|
|
|
|
{
|
|
|
|
egw.json('websocket', {}, undefined, this).openWebSocket(
|
|
|
|
egw_script.getAttribute('data-websocket-url'),
|
2020-04-20 13:07:58 +02:00
|
|
|
JSON.parse(egw_script.getAttribute('data-websocket-tokens')),
|
|
|
|
parseInt(egw_script.getAttribute('data-websocket-account_id'))
|
2019-11-04 09:29:49 +01:00
|
|
|
);
|
|
|
|
}
|
2017-03-08 14:25:52 +01:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
// ignore SecurityError exception if top is different security context / cross-origin
|
2015-10-24 13:07:22 +02:00
|
|
|
}
|
2021-06-09 10:13:51 +02:00
|
|
|
});
|
|
|
|
});
|
2021-06-05 20:39:39 +02:00
|
|
|
//
|
|
|
|
window.egw_LAB.wait = window.egw_ready.then;
|
2013-11-05 19:08:07 +01:00
|
|
|
|
2013-08-20 20:01:49 +02:00
|
|
|
/**
|
2013-11-05 19:08:07 +01:00
|
|
|
*
|
2013-08-20 20:01:49 +02:00
|
|
|
*/
|
|
|
|
window.callManual = function()
|
|
|
|
{
|
|
|
|
if (window.framework)
|
|
|
|
{
|
|
|
|
window.framework.callManual.call(window.framework, window.location.href);
|
|
|
|
}
|
|
|
|
};
|
2013-07-19 10:45:26 +02:00
|
|
|
})();
|
2014-06-23 10:10:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc")
|
|
|
|
*
|
2021-03-02 11:16:47 +01:00
|
|
|
* @param {string|Function} _func dot-separated function name
|
2021-03-01 10:50:22 +01:00
|
|
|
* @param {mixed} ...args variable number of arguments
|
|
|
|
* @returns {Mixed|Promise}
|
2021-03-02 11:16:47 +01:00
|
|
|
* @deprecated use egw.callFunc(_func, ...) or egw.applyFunc(_func, args)
|
2014-06-23 10:10:40 +02:00
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
window.et2_call = function(_func)
|
2014-06-23 10:10:40 +02:00
|
|
|
{
|
2021-03-08 20:20:11 +01:00
|
|
|
return egw.applyFunc(_func, [].slice.call(arguments, 1), window);
|
2014-06-23 10:10:40 +02:00
|
|
|
}
|