2014-11-11 19:00:29 +01:00
|
|
|
/**
|
|
|
|
* eGroupware Framework base object
|
|
|
|
* @package framework
|
|
|
|
* @author Hadi Nategh <hn@stylite.de>
|
2014-11-14 17:20:11 +01:00
|
|
|
* @author Andreas Stoeckel <as@stylite.de>
|
2014-11-11 19:00:29 +01:00
|
|
|
* @copyright Stylite AG 2014
|
|
|
|
* @description Framework base module which creates fw_base object and includes basic framework functionallity
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*egw:uses
|
2016-06-06 17:38:20 +02:00
|
|
|
vendor.bower-asset.jquery.dist.jquery;
|
2014-11-11 19:00:29 +01:00
|
|
|
egw_inheritance.js;
|
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
import '../jsapi/egw_inheritance.js';
|
2014-11-11 19:00:29 +01:00
|
|
|
|
2021-06-05 20:39:39 +02:00
|
|
|
window.fw_base = (function(){ "use strict"; return Class.extend(
|
2016-02-29 16:50:24 +01:00
|
|
|
{
|
2014-11-11 19:00:29 +01:00
|
|
|
/**
|
|
|
|
* Framework base class constructor sets up basic initialization
|
2014-11-14 17:20:11 +01:00
|
|
|
* @param {type} _sidemenuId
|
|
|
|
* @param {type} _tabsId
|
|
|
|
* @param {type} _webserverUrl
|
|
|
|
* @param {type} _sideboxSizeCallback
|
|
|
|
* @returns {undefined}
|
2014-11-11 19:00:29 +01:00
|
|
|
*/
|
2014-11-14 17:20:11 +01:00
|
|
|
init: function (_sidemenuId, _tabsId, _webserverUrl, _sideboxSizeCallback){
|
|
|
|
/* Get the base div */
|
|
|
|
this.sidemenuDiv = document.getElementById(_sidemenuId);
|
|
|
|
this.tabsDiv = document.getElementById(_tabsId);
|
|
|
|
this.webserverUrl = _webserverUrl;
|
|
|
|
this.sideboxSizeCallback = _sideboxSizeCallback;
|
|
|
|
window.egw_webserverUrl = _webserverUrl;
|
|
|
|
|
|
|
|
this.serializedTabState = '';
|
2015-11-19 17:33:39 +01:00
|
|
|
this.notifyTabChangeEnabled = false;
|
2014-11-14 17:20:11 +01:00
|
|
|
|
|
|
|
this.sidemenuUi = null;
|
|
|
|
this.tabsUi = null;
|
|
|
|
|
|
|
|
this.applications = new Object();
|
|
|
|
this.activeApp = null;
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2021-04-19 10:17:40 +02:00
|
|
|
// keeps the firstload animation gauge in sync
|
|
|
|
this.firstload_animation_gauge = 0;
|
|
|
|
|
2020-11-02 12:50:21 +01:00
|
|
|
this.apps = null;
|
|
|
|
|
2021-03-01 17:30:33 +01:00
|
|
|
this.tabApps = JSON.parse(egw.getSessionItem('api', 'fw_tab_apps')||null) || {};
|
2020-11-02 12:50:21 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
//Register the resize handler
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(window).resize(function(){window.framework.resizeHandler();});
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
//Register the global alert handler
|
|
|
|
window.egw_alertHandler = this.alertHandler;
|
|
|
|
|
|
|
|
//Register the key press handler
|
2016-06-02 16:51:15 +02:00
|
|
|
//jQuery(document).keypress(this.keyPressHandler);
|
2014-11-14 17:20:11 +01:00
|
|
|
|
|
|
|
//Override the app_window function
|
|
|
|
window.egw_appWindow = this.egw_appWindow;
|
|
|
|
|
|
|
|
// Override the egw_appWindowOpen function
|
|
|
|
window.egw_appWindowOpen = this.egw_appWindowOpen;
|
|
|
|
|
|
|
|
// Override the egw_getAppName function
|
|
|
|
window.egw_getAppName = this.egw_getAppName;
|
2018-03-09 17:48:09 +01:00
|
|
|
|
|
|
|
// keep track of opened popups
|
|
|
|
this.popups = [];
|
2020-12-15 20:24:25 +01:00
|
|
|
|
2021-01-26 17:04:37 +01:00
|
|
|
|
2020-12-15 20:24:25 +01:00
|
|
|
// initiate dark mode
|
2021-01-26 17:04:37 +01:00
|
|
|
let darkmode = egw.getSessionItem('api', 'darkmode');
|
|
|
|
if (darkmode == '0' || darkmode == '1')
|
|
|
|
{
|
|
|
|
this._setDarkMode(darkmode);
|
|
|
|
}
|
|
|
|
else if (egw.preference('darkmode', 'common') !='2')
|
|
|
|
{
|
|
|
|
this._setDarkMode( egw.preference('darkmode', 'common'));
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Load applications
|
|
|
|
* @param {object} apps an object list of all applications
|
|
|
|
*/
|
|
|
|
loadApplications: function (apps)
|
|
|
|
{
|
|
|
|
//Close all open tabs, remove all applications from the application list
|
|
|
|
this.sidemenuUi.clean();
|
|
|
|
this.tabsUi.clean();
|
2021-03-01 17:30:33 +01:00
|
|
|
if (Object.keys(this.tabApps).length > 0)
|
|
|
|
{
|
|
|
|
apps = apps.concat(Object.values(this.tabApps));
|
|
|
|
}
|
|
|
|
this.apps = apps;
|
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
var defaultApp = null;
|
|
|
|
var restore = new Object;
|
|
|
|
var restore_count = 0;
|
|
|
|
|
2019-03-11 12:06:41 +01:00
|
|
|
var mkRestoreEntry = function(_app, _pos, _url, _active, _status) {
|
2014-11-14 17:20:11 +01:00
|
|
|
return {
|
|
|
|
'app': _app,
|
|
|
|
'position': _pos,
|
|
|
|
'url': _url,
|
2019-03-11 12:06:41 +01:00
|
|
|
'active': _active,
|
|
|
|
status: _status
|
2014-11-14 17:20:11 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
//Iterate through the application array returned
|
|
|
|
for (var i = 0; i < apps.length; i++)
|
|
|
|
{
|
|
|
|
var app = apps[i];
|
|
|
|
|
|
|
|
// Retrieve the application base url
|
|
|
|
var baseUrl = false;
|
|
|
|
if (typeof app.baseUrl == 'string')
|
|
|
|
{
|
|
|
|
baseUrl = app.baseUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute the instance internal name
|
|
|
|
var internalName = app.name;
|
|
|
|
if (typeof app.internalName == 'string')
|
|
|
|
{
|
|
|
|
internalName = app.internalName;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.appData = new egw_fw_class_application(this,
|
|
|
|
app.name, app.title, app.icon, app.url, app.sideboxwidth,
|
|
|
|
baseUrl, internalName);
|
2021-04-19 16:12:58 +02:00
|
|
|
if (app.isFrameworkTab)
|
|
|
|
{
|
|
|
|
jQuery.extend(this.appData, app);
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
//Create a sidebox menu entry for each application
|
2021-03-16 11:33:01 +01:00
|
|
|
if (!app.noNavbar && (app.status != 5 || app.isFrameworkTab))
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
this.appData.sidemenuEntry = this.sidemenuUi.addEntry(
|
|
|
|
this.appData.displayName, this.appData.icon,
|
|
|
|
this.applicationClickCallback, this.appData, app.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//If this entry is the default entry, show it using the click callback
|
2015-05-25 19:05:06 +02:00
|
|
|
if (app.isDefault && (app.isDefault === true) && (restore_count === 0))
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
defaultApp = this.appData;
|
|
|
|
}
|
|
|
|
|
|
|
|
//If the opened field is set, add the application to the restore array.
|
2019-03-11 12:06:41 +01:00
|
|
|
if ((typeof app.opened != 'undefined') && (app.opened !== false) || app.status == 5)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
defaultApp = null;
|
|
|
|
|
|
|
|
var url = null;
|
|
|
|
if (typeof app.openOnce != 'undefined' && app.openOnce)
|
|
|
|
url = app.openOnce;
|
|
|
|
|
|
|
|
restore[this.appData.appName] = mkRestoreEntry(this.appData, app.opened,
|
2019-03-11 12:06:41 +01:00
|
|
|
url, app.active ? 1 : 0, app.status);
|
2014-11-14 17:20:11 +01:00
|
|
|
restore_count += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.applications[this.appData.appName] = this.appData;
|
2018-03-09 17:48:09 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// else display the default application
|
2015-05-25 19:05:06 +02:00
|
|
|
if (defaultApp && restore_count === 0)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
restore[defaultApp.appName] = mkRestoreEntry(defaultApp, 0, null, 1);
|
|
|
|
}
|
|
|
|
return restore;
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Navigate to the tab of an application (opening the tab if not yet open)
|
|
|
|
*
|
|
|
|
* @param {egw_fw_class_application} _app
|
|
|
|
* @param {string} _url optional url, default index page of app
|
2020-09-24 16:19:56 +02:00
|
|
|
* @param {boolean} _hidden specifies, whether the application should be set active
|
2014-11-14 17:20:11 +01:00
|
|
|
* after opening the tab
|
|
|
|
* @param {int} _pos
|
2019-03-11 12:06:41 +01:00
|
|
|
* @param {status} _status
|
2015-03-10 21:12:30 +01:00
|
|
|
*
|
|
|
|
* @return {Deferred|null} Deferred Promise, will be resolved when the tab is loaded
|
2014-11-14 17:20:11 +01:00
|
|
|
*/
|
2019-03-11 12:06:41 +01:00
|
|
|
applicationTabNavigate: function(_app, _url, _hidden, _pos, _status)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
//Default the post parameter to -1
|
|
|
|
if (typeof _pos == 'undefined')
|
|
|
|
_pos = -1;
|
|
|
|
|
|
|
|
//Create the tab for that application
|
2019-03-11 12:06:41 +01:00
|
|
|
this.createApplicationTab(_app, _pos, _status);
|
2014-11-14 17:20:11 +01:00
|
|
|
|
2015-03-10 21:12:30 +01:00
|
|
|
// Response
|
|
|
|
var deferred = new jQuery.Deferred();
|
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
if (typeof _url == 'undefined' || _url == null)
|
|
|
|
{
|
|
|
|
_url = _app.indexUrl;
|
|
|
|
}
|
2016-12-01 19:20:25 +01:00
|
|
|
// If there are query parameters and URL is the same, don't just refresh
|
|
|
|
// because the app's state may have changed since last time
|
|
|
|
else if (_app.browser != null && _url == _app.browser.currentLocation
|
|
|
|
&& !_url.match(/menuaction=[^&]+&ajax=true/))
|
|
|
|
{
|
|
|
|
// Reset current so new url loads fully
|
|
|
|
_app.browser.currentLocation = _app.indexUrl;
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
else if (_app.browser != null &&
|
|
|
|
// check if app has its own linkHandler
|
|
|
|
!(this.applications[_app.appName].app_refresh) &&
|
2015-10-24 13:07:22 +02:00
|
|
|
_app.browser.iframe == null && _url == _app.browser.currentLocation
|
2015-09-14 19:34:43 +02:00
|
|
|
// links with load may needs to be reloaded e.g. admin applications global cats
|
2015-12-02 19:05:25 +01:00
|
|
|
&& !(_app.browser.currentLocation.match(/&load=[^&]+/g) && _app.appName === 'admin'))
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
// Just do an egw_refresh to avoid a full reload
|
|
|
|
egw_refresh('',_app.appName);
|
|
|
|
//Show the application tab
|
|
|
|
if (_app.tab)
|
|
|
|
{
|
|
|
|
this.setActiveApp(_app);
|
|
|
|
}
|
2015-03-10 21:12:30 +01:00
|
|
|
deferred.resolve();
|
|
|
|
return deferred.promise();
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_app.browser == null)
|
|
|
|
{
|
|
|
|
//Create a new browser ui and set it as application tab callback
|
|
|
|
var callback = new egw_fw_class_callback(this, this.getIFrameHeight);
|
|
|
|
_app.browser = new fw_browser(_app, callback);
|
|
|
|
_app.tab.setContent(_app.browser.baseDiv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof _hidden == 'undefined' || !_hidden)
|
|
|
|
{
|
2015-03-10 21:12:30 +01:00
|
|
|
deferred = _app.browser.browse(_url);
|
2014-11-14 17:20:11 +01:00
|
|
|
this.setActiveApp(_app);
|
|
|
|
}
|
2021-04-06 17:09:31 +02:00
|
|
|
// load application with status 5 as it will run in the background, and ignore apps with index set none
|
|
|
|
else if (_status == 5 && !_url.match(/menuaction\=none/))
|
2019-03-11 12:06:41 +01:00
|
|
|
{
|
|
|
|
deferred = _app.browser.browse(_url);
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
else
|
|
|
|
{
|
2015-03-10 21:12:30 +01:00
|
|
|
this.notifyTabChange(deferred);
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
2015-03-10 21:12:30 +01:00
|
|
|
|
|
|
|
return deferred.promise();
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Callback to calculate height of browser iframe or div
|
|
|
|
*
|
|
|
|
* @param {object} _iframe dom node of iframe or null for div
|
|
|
|
* @returns number in pixel
|
|
|
|
*/
|
|
|
|
getIFrameHeight: function(_iframe)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
var $header = jQuery(this.tabsUi.appHeaderContainer);
|
|
|
|
var height = jQuery(this.sidemenuDiv).height()-this.tabsUi.appHeaderContainer.outerHeight();
|
2014-11-14 17:20:11 +01:00
|
|
|
return height;
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Sets the sidebox data of an application
|
|
|
|
* @param {object} _app the application whose sidebox content should be set.
|
|
|
|
* @param {object} _data an array/object containing the data of the sidebox content
|
|
|
|
* @param {string} _md5 an md5 hash of the sidebox menu content: Only if this hash differs between two setSidebox calles, the sidebox menu will be updated.
|
|
|
|
*/
|
|
|
|
setSidebox: function(_app, _data, _md5)
|
|
|
|
{
|
|
|
|
if (typeof _app == 'string') _app = this.getApplicationByName(_app);
|
|
|
|
|
|
|
|
if ((_app != null) && (_app.sidebox_md5 != _md5) && (_app.sidemenuEntry != null))
|
|
|
|
{
|
|
|
|
//Parse the sidebox data
|
|
|
|
if (_data != null)
|
|
|
|
{
|
|
|
|
var contDiv = document.createElement('div');
|
|
|
|
var contJS = ''; //new Array();
|
|
|
|
for (var i = 0; i < _data.length; i++)
|
|
|
|
{
|
|
|
|
var catContent = '';
|
|
|
|
for (var j = 0; j < _data[i].entries.length; j++)
|
|
|
|
{
|
|
|
|
/* As jquery executes all script tags which are found inside
|
|
|
|
the html and removes them afterwards, we have to seperate the
|
|
|
|
javaScript from the html in lang_item and add it manually. */
|
|
|
|
this.html = new Object();
|
|
|
|
this.html.html = _data[i].entries[j].lang_item;
|
|
|
|
this.html.js = '';
|
|
|
|
|
|
|
|
egw_seperateJavaScript(this.html);
|
|
|
|
contJS += this.html.js;//contJS.concat(html.js);
|
|
|
|
|
|
|
|
if (_data[i].entries[j].icon_or_star)
|
|
|
|
{
|
2018-11-27 15:22:50 +01:00
|
|
|
var disableIfNoEPL = _data[i].entries[j].disableIfNoEPL ? ' disableIfNoEPL" title="'+egw.lang("This feature is only available in EPL version.") : "";
|
2021-05-12 19:34:34 +02:00
|
|
|
catContent += '<li class="egw_fw_ui_sidemenu_listitem'+disableIfNoEPL+
|
2018-11-27 15:22:50 +01:00
|
|
|
'"><img class="egw_fw_ui_sidemenu_listitem_icon" src="' + _data[i].entries[j].icon_or_star + '" />';
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
if (_data[i].entries[j].item_link == '')
|
|
|
|
{
|
|
|
|
catContent += this.html.html;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var link = _data[i].entries[j].item_link;
|
|
|
|
if (link)
|
|
|
|
{
|
|
|
|
catContent += '<a href="' + link +
|
|
|
|
(_data[i].entries[j].target ? '" target="'+_data[i].entries[j].target : '') +
|
|
|
|
'">' + this.html.html + '</a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_data[i].entries[j].icon_or_star)
|
|
|
|
{
|
|
|
|
catContent += '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append the category content */
|
|
|
|
if (catContent != '')
|
|
|
|
{
|
|
|
|
var categoryUi = new egw_fw_ui_category(contDiv,_data[i].menu_name,
|
|
|
|
_data[i].title, catContent, this.categoryOpenCloseCallback,
|
|
|
|
this.categoryAnimationCallback, _app);
|
|
|
|
|
|
|
|
//Lookup whether this entry was opened before. If no data is
|
|
|
|
//stored about this, use the information we got from the server
|
2020-10-22 13:52:17 +02:00
|
|
|
var opened = egw.preference('jdots_sidebox_'+_data[i].menu_name, _app.internalName);
|
2014-11-14 17:20:11 +01:00
|
|
|
if (typeof opened == 'undefined')
|
|
|
|
{
|
|
|
|
opened = _data[i].opened;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opened)
|
|
|
|
{
|
|
|
|
categoryUi.open(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Stop ajax loader spinner icon in case there's no data and still is not stopped
|
|
|
|
if (_data.length <= 0) _app.sidemenuEntry.hideAjaxLoader();
|
|
|
|
//Rewrite all form actions if they contain some javascript
|
2016-06-02 16:51:15 +02:00
|
|
|
var forms = jQuery('form', contDiv).toArray();
|
2014-11-14 17:20:11 +01:00
|
|
|
for (var i = 0; i < forms.length; ++i)
|
|
|
|
{
|
|
|
|
var form = forms[i];
|
|
|
|
if (form.action.indexOf('javascript:') == 0)
|
|
|
|
{
|
|
|
|
var action = form.action.match(/\('([^']*)/)[0].substr(2);
|
|
|
|
form.action = action;
|
|
|
|
form.target = 'egw_app_iframe_' + this.parseAppFromUrl(action).appName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_app.sidemenuEntry.setContent(contDiv);
|
|
|
|
_app.sidebox_md5 = _md5;
|
|
|
|
|
|
|
|
//console.log(contJS);
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(contDiv).append(contJS);
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_app.hasSideboxMenuContent = true;
|
|
|
|
|
|
|
|
//Only view the sidemenu content if this is really the active application
|
|
|
|
if (_app == _app.parentFw.activeApp)
|
|
|
|
{
|
|
|
|
//Set the sidebox width if a application specific sidebox width is set
|
|
|
|
if (_app.sideboxWidth !== false)
|
|
|
|
{
|
|
|
|
this.sideboxSizeCallback(_app.sideboxWidth);
|
|
|
|
}
|
|
|
|
_app.sidemenuEntry.parent.open(_app.sidemenuEntry);
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
// reliable init sidebox, as app.js might initialise earlier
|
|
|
|
if (typeof app[_app.appName] == 'object')
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
var sidebox = jQuery('#favorite_sidebox_'+_app.appName, this.sidemenuDiv);
|
2014-11-14 17:20:11 +01:00
|
|
|
var self = this;
|
|
|
|
var currentAppName = _app.appName;
|
|
|
|
// make sidebox
|
|
|
|
sidebox.children().sortable({
|
|
|
|
|
|
|
|
items:'li:not([data-id$="add"])',
|
|
|
|
placeholder:'ui-fav-sortable-placeholder',
|
|
|
|
update: function (event, ui)
|
|
|
|
{
|
|
|
|
var favSortedList = jQuery(this).sortable('toArray', {attribute:'data-id'});
|
|
|
|
|
|
|
|
egw().set_preference(currentAppName,'fav_sort_pref',favSortedList);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (sidebox.length) app[_app.appName]._init_sidebox.call(app[_app.appName], sidebox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
2015-03-10 21:12:30 +01:00
|
|
|
* Notify a tab that it was changed, update preferences
|
2014-12-01 11:44:51 +01:00
|
|
|
*
|
2015-03-10 21:12:30 +01:00
|
|
|
* @param {Deferred} deferred Someone is listening, and wants to know when done.
|
2014-11-14 17:20:11 +01:00
|
|
|
*/
|
2015-03-10 21:12:30 +01:00
|
|
|
notifyTabChange: function(deferred)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
// Call the "resize" function of the currently active app
|
|
|
|
if (this.activeApp)
|
|
|
|
{
|
|
|
|
var browser = this.activeApp.browser;
|
|
|
|
if (browser)
|
|
|
|
{
|
|
|
|
window.setTimeout(function() {
|
|
|
|
browser.callResizeHandler();
|
|
|
|
|
|
|
|
// Focus the current window so that keyboard input is forwarderd
|
|
|
|
// to it. The timeout is needed, as this is function is often
|
|
|
|
// called by the click on a jdots-tab. And that click immediately
|
|
|
|
// focuses the outer window again.
|
|
|
|
if (browser.iframe && browser.iframe.contentWindow)
|
|
|
|
{
|
|
|
|
browser.iframe.contentWindow.focus();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window.focus();
|
|
|
|
}
|
2015-03-10 21:12:30 +01:00
|
|
|
if(deferred)
|
|
|
|
{
|
|
|
|
deferred.resolve();
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.notifyTabChangeEnabled)
|
|
|
|
{
|
2015-11-16 16:45:04 +01:00
|
|
|
this.storeTabsStatus();
|
|
|
|
}
|
|
|
|
},
|
2016-02-29 16:50:24 +01:00
|
|
|
|
2015-11-16 16:45:04 +01:00
|
|
|
/**
|
|
|
|
* Store last status of tabs
|
|
|
|
* tab status being used in order to open all previous opened
|
|
|
|
* tabs and to activate the last active tab
|
|
|
|
*/
|
|
|
|
storeTabsStatus: function ()
|
|
|
|
{
|
|
|
|
//Send the current tab list to the server
|
|
|
|
var data = this.assembleTabList();
|
2014-11-14 17:20:11 +01:00
|
|
|
|
2015-11-16 16:45:04 +01:00
|
|
|
//Serialize the tab list and check whether it really has changed since the last
|
|
|
|
//submit
|
|
|
|
var serialized = egw.jsonEncode(data);
|
|
|
|
if (serialized != this.serializedTabState)
|
|
|
|
{
|
|
|
|
this.serializedTabState = serialized;
|
2021-03-01 17:30:33 +01:00
|
|
|
if (this.tabApps) this._setTabAppsSession(this.tabApps);
|
2016-05-18 12:39:06 +02:00
|
|
|
egw.jsonq('EGroupware\\Api\\Framework\\Ajax::ajax_tab_changed_state', [data]);
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
},
|
2016-02-29 16:50:24 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* @param {function} _opened
|
|
|
|
* Sends sidemenu entry category open/close information to the server using an AJAX request
|
|
|
|
*/
|
|
|
|
categoryOpenCloseCallback: function(_opened)
|
|
|
|
{
|
2020-10-22 13:52:17 +02:00
|
|
|
if (!framework.isAnInternalApp(this.tag)) egw.set_preference(this.tag.internalName, 'jdots_sidebox_'+this.catName, _opened);
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
categoryAnimationCallback: function()
|
|
|
|
{
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an ordered list with all opened tabs and whether the tab is currently active
|
|
|
|
* @return {array} returns an array of tabs
|
|
|
|
*/
|
|
|
|
assembleTabList: function()
|
|
|
|
{
|
|
|
|
var result = [];
|
|
|
|
for (var i = 0; i < this.tabsUi.tabs.length; i++)
|
|
|
|
{
|
|
|
|
var tab = this.tabsUi.tabs[i];
|
|
|
|
result[i] = {
|
|
|
|
'appName': tab.tag.appName,
|
|
|
|
'active': tab == this.tabsUi.activeTab
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
2014-12-01 11:44:51 +01:00
|
|
|
*
|
2014-11-14 17:20:11 +01:00
|
|
|
* @param {app object} _app
|
|
|
|
* @param {int} _pos
|
|
|
|
* Checks whether the application already owns a tab and creates one if it doesn't exist
|
|
|
|
*/
|
2019-03-11 12:06:41 +01:00
|
|
|
createApplicationTab: function(_app, _pos, _status)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
//Default the pos parameter to -1
|
|
|
|
if (typeof _pos == 'undefined')
|
|
|
|
_pos = -1;
|
|
|
|
|
|
|
|
if (_app.tab == null)
|
|
|
|
{
|
|
|
|
//Create the tab
|
|
|
|
_app.tab = this.tabsUi.addTab(_app.icon, this.tabClickCallback, this.tabCloseClickCallback,
|
2019-08-20 14:01:09 +02:00
|
|
|
_app, _pos, _status);
|
2014-11-14 17:20:11 +01:00
|
|
|
_app.tab.setTitle(_app.displayName);
|
2020-09-25 11:53:00 +02:00
|
|
|
_app.tab.setHint(_app.hint ? _app.hint : '');
|
2014-11-14 17:20:11 +01:00
|
|
|
//Set the tab closeable if there's more than one tab
|
2019-08-20 14:01:09 +02:00
|
|
|
this.tabsUi.setCloseable(this.tabsUi._isNotTheLastTab());
|
2019-03-11 12:06:41 +01:00
|
|
|
// Do not show tab header if the app is with status 5, means run in background
|
2021-03-16 11:33:01 +01:00
|
|
|
if (_status == 5 && !_app.isFrameworkTab) _app.tab.hideTabHeader(true);
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
2021-04-19 10:17:40 +02:00
|
|
|
if (this.activeApp && this.activeApp.appName != _app.appName) this.firstload_animation(_app.appName);
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* applicationClickCallback is used internally by egw_fw in order to handle clicks on
|
|
|
|
* an application in the sidebox menu.
|
|
|
|
*
|
|
|
|
* @param {egw_fw_ui_tab} _sender specifies the tab ui object, the user has clicked
|
|
|
|
*/
|
|
|
|
applicationClickCallback: function(_sender)
|
|
|
|
{
|
|
|
|
this.tag.parentFw.applicationTabNavigate(this.tag, this.tag.indexUrl);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* tabClickCallback is used internally by egw_fw in order to handle clicks on
|
|
|
|
* a tab.
|
|
|
|
*
|
|
|
|
* @param {egw_fw_ui_tab} _sender specifies the tab ui object, the user has clicked
|
|
|
|
*/
|
|
|
|
tabClickCallback: function(_sender)
|
|
|
|
{
|
|
|
|
//Set the active application in the framework
|
|
|
|
this.tag.parentFw.setActiveApp(this.tag);
|
2014-11-11 19:00:29 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* tabCloseClickCallback is used internally by egw_fw in order to handle clicks
|
|
|
|
* on the close button of every tab.
|
|
|
|
*
|
|
|
|
* @param {egw_fw_ui_tab} _sender specifies the tab ui object, the user has clicked
|
|
|
|
*/
|
|
|
|
tabCloseClickCallback: function(_sender)
|
|
|
|
{
|
|
|
|
//Save references to the application and the tabsUi as "this" will be deleted
|
|
|
|
var app = this.tag;
|
|
|
|
var tabsUi = this.parent;
|
|
|
|
|
|
|
|
//At least one tab must stay open
|
|
|
|
if (tabsUi.tabs.length > 1)
|
|
|
|
{
|
|
|
|
//Tell the browser object to browse to an empty page, which will trigger the
|
|
|
|
//unload handler
|
|
|
|
app.browser.blank();
|
|
|
|
|
|
|
|
this.tag.parentFw.notifyTabChangeEnabled = false;
|
|
|
|
|
|
|
|
tabsUi.removeTab(this);
|
|
|
|
app.tab = null;
|
|
|
|
app.browser = null;
|
|
|
|
|
|
|
|
if (app.sidemenuEntry)
|
|
|
|
app.sidemenuEntry.hideAjaxLoader();
|
|
|
|
|
|
|
|
//Set the active application to the application of the currently active tab
|
|
|
|
app.parentFw.setActiveApp(tabsUi.activeTab.tag);
|
|
|
|
|
|
|
|
this.tag.parentFw.notifyTabChangeEnabled = true;
|
|
|
|
|
|
|
|
this.tag.parentFw.notifyTabChange();
|
|
|
|
}
|
|
|
|
|
2019-08-20 14:01:09 +02:00
|
|
|
tabsUi.setCloseable(tabsUi._isNotTheLastTab());
|
2014-11-14 17:20:11 +01:00
|
|
|
|
|
|
|
//As a new tab might remove a row from the tab header, we have to resize all tab content browsers
|
|
|
|
this.tag.parentFw.resizeHandler();
|
2020-09-30 16:03:04 +02:00
|
|
|
if (app.isFrameworkTab)
|
2020-09-28 15:43:42 +02:00
|
|
|
{
|
|
|
|
app.destroy();
|
|
|
|
}
|
2020-11-02 13:12:31 +01:00
|
|
|
|
2021-03-01 17:30:33 +01:00
|
|
|
delete(this.tag.parentFw.tabApps[this.tag.appName]);
|
2020-11-02 13:12:31 +01:00
|
|
|
this.tag.parentFw._setTabAppsSession(this.tag.parentFw.tabApps);
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* @param {string} _url
|
|
|
|
* Tries to obtain the application from a menuaction
|
|
|
|
*/
|
|
|
|
parseAppFromUrl: function(_url)
|
|
|
|
{
|
|
|
|
var _app = null;
|
|
|
|
|
2015-10-24 13:07:22 +02:00
|
|
|
// Check the menuaction parts from the url
|
|
|
|
var matches = _url.match(/menuaction=([a-z0-9_-]+)\./i) ||
|
|
|
|
// Check the url for a scheme of "/app/something.php"
|
|
|
|
_url.match(/\/([^\/]+)\/[^\/]+\.php/i);
|
|
|
|
if (matches)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
2015-10-24 13:07:22 +02:00
|
|
|
// check if this is a regular app-name
|
|
|
|
_app = this.getApplicationByName(matches[1]);
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
|
2015-10-24 13:07:22 +02:00
|
|
|
return _app;
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Goes through all applications and returns the application with the specified name.
|
|
|
|
* @param {string} _name the name of the application which should be returned.
|
|
|
|
* @return object or null if application is not found.
|
|
|
|
*/
|
|
|
|
getApplicationByName: function(_name)
|
|
|
|
{
|
|
|
|
if (typeof this.applications[_name] != 'undefined')
|
|
|
|
{
|
|
|
|
return this.applications[_name];
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Sets the website title of an application
|
|
|
|
* @param {object} _app the application whose title should be set.
|
|
|
|
* @param {string} _title title to set
|
|
|
|
* @param {object} _header
|
|
|
|
*/
|
|
|
|
setWebsiteTitle: function(_app, _title, _header)
|
|
|
|
{
|
|
|
|
if (typeof _app == 'string') _app = this.getApplicationByName(_app);
|
|
|
|
|
|
|
|
if (_app) {
|
|
|
|
_app.website_title = _title;
|
|
|
|
|
|
|
|
// only set app_header if different from app-name
|
|
|
|
if (_header && _header != egw.lang(_app.appName))
|
|
|
|
{
|
|
|
|
_app.app_header = _header;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_app.app_header = '';
|
|
|
|
}
|
|
|
|
if (_app == this.activeApp)
|
|
|
|
this.refreshAppTitle();
|
|
|
|
}
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Handles alert message
|
2014-12-01 11:44:51 +01:00
|
|
|
*
|
2014-11-14 17:20:11 +01:00
|
|
|
* @param {type} _message
|
|
|
|
* @param {type} _details
|
|
|
|
*/
|
2014-11-11 19:00:29 +01:00
|
|
|
alertHandler: function (_message, _details)
|
|
|
|
{
|
|
|
|
if (_details)
|
|
|
|
{
|
|
|
|
alert('Error:\n ' + _message + '\n\nDetails:\n ' + _details);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
alert(_message);
|
|
|
|
}
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-11 19:00:29 +01:00
|
|
|
/**
|
|
|
|
* Call online manual
|
|
|
|
*
|
|
|
|
* @param {string} referer optional referer, default use activeApp
|
|
|
|
*/
|
|
|
|
callManual: function(referer)
|
|
|
|
{
|
|
|
|
if (typeof referer == 'undefined' && this.activeApp && this.activeApp.appName != 'manual')
|
|
|
|
{
|
|
|
|
referer = this.activeApp.indexUrl;
|
|
|
|
if (this.activeApp.browser.iframe && this.activeApp.browser.iframe.contentWindow.location)
|
|
|
|
{
|
|
|
|
//this.activeApp.browser.iframe.contentWindow.callManual();
|
|
|
|
referer = this.activeApp.browser.iframe.contentWindow.location.href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (typeof referer != 'undefined')
|
|
|
|
{
|
|
|
|
this.linkHandler(egw.link('/index.php', {
|
|
|
|
menuaction: 'manual.uimanual.view',
|
|
|
|
referer: referer
|
|
|
|
}), 'manual', true);
|
|
|
|
}
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2020-11-02 13:12:31 +01:00
|
|
|
_setTabAppsSession: function(_tabApps)
|
|
|
|
{
|
|
|
|
if (_tabApps)
|
|
|
|
{
|
|
|
|
egw.setSessionItem('api', 'fw_tab_apps', JSON.stringify(_tabApps));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-24 16:19:56 +02:00
|
|
|
tabLinkHandler: function(_link, _extra)
|
|
|
|
{
|
2021-03-01 12:41:27 +01:00
|
|
|
var app = this.parseAppFromUrl(_link);
|
2020-09-24 16:19:56 +02:00
|
|
|
if (app)
|
|
|
|
{
|
2020-11-09 11:10:18 +01:00
|
|
|
var appname = app.appName+"-"+btoa(_extra.id ? _extra.id : _link).replace(/=/g,'i');
|
2020-10-20 17:28:14 +02:00
|
|
|
this.applications[appname] = this.getApplicationByName(appname);
|
|
|
|
if (this.applications[appname])
|
|
|
|
{
|
|
|
|
this.setActiveApp(this.applications[appname]);
|
2021-03-03 18:12:10 +01:00
|
|
|
return appname;
|
2020-10-20 17:28:14 +02:00
|
|
|
}
|
2020-09-30 13:19:36 +02:00
|
|
|
var self = this;
|
2020-09-28 15:43:42 +02:00
|
|
|
// add target flag
|
2020-09-30 13:19:36 +02:00
|
|
|
_link += '&fw_target='+appname;
|
2020-09-24 16:19:56 +02:00
|
|
|
// create an actual clone of existing app object
|
|
|
|
this.applications[appname] = jQuery.extend(true, {}, app);
|
2020-09-30 16:03:04 +02:00
|
|
|
this.applications[appname]['isFrameworkTab'] = true;
|
2020-09-24 16:19:56 +02:00
|
|
|
// merge extra framework app data into the new one
|
|
|
|
this.applications[appname] = jQuery.extend(true, this.applications[appname], _extra);
|
|
|
|
this.applications[appname]['appName'] = appname; // better to control it here
|
|
|
|
this.applications[appname]['indexUrl'] = _link;
|
|
|
|
this.applications[appname]['tab'] = null; // must be rest to create a new tab
|
|
|
|
this.applications[appname]['browser'] = null; // must be rest to create a new browser content
|
2020-09-28 15:43:42 +02:00
|
|
|
this.applications[appname]['sidemenuEntry'] = this.sidemenuUi.addEntry(
|
|
|
|
this.applications[appname].displayName, this.applications[appname].icon,
|
2020-09-30 13:19:36 +02:00
|
|
|
function(){
|
|
|
|
self.applicationTabNavigate(self.applications[appname], _link, false, -1, null);
|
|
|
|
}, this.applications[appname], appname);
|
2020-09-28 15:43:42 +02:00
|
|
|
|
2020-09-24 16:19:56 +02:00
|
|
|
|
|
|
|
this.applicationTabNavigate(this.applications[appname], _link, false, -1, null);
|
2021-03-01 17:30:33 +01:00
|
|
|
this.tabApps[appname] = (jQuery.extend(true, this.apps.filter(a=>{if (a.name == app.appName) return a})[0], {
|
2020-11-02 12:50:21 +01:00
|
|
|
title: _extra.displayName,
|
|
|
|
icon:_extra.icon,
|
|
|
|
name: appname,
|
2021-03-01 17:30:33 +01:00
|
|
|
opened: this.tabsUi.tabs.length+1,
|
2020-11-02 12:50:21 +01:00
|
|
|
url: _link,
|
2021-03-01 17:30:33 +01:00
|
|
|
internalName: app.appName,
|
2021-03-10 11:56:34 +01:00
|
|
|
active: true,
|
2021-04-19 16:12:58 +02:00
|
|
|
isFrameworkTab: true,
|
2021-04-20 14:45:21 +02:00
|
|
|
hint: _extra.hint,
|
2021-04-19 16:12:58 +02:00
|
|
|
refreshCallback: _extra.refreshCallback
|
2020-11-02 12:50:21 +01:00
|
|
|
}));
|
|
|
|
|
2020-11-02 13:12:31 +01:00
|
|
|
this._setTabAppsSession(this.tabApps);
|
2021-03-03 18:12:10 +01:00
|
|
|
|
|
|
|
return appname;
|
2020-09-24 16:19:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
egw_alertHandler("No appropriate target application has been found.",
|
|
|
|
"Target link: " + _link);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
2014-12-01 11:44:51 +01:00
|
|
|
*
|
2014-11-14 17:20:11 +01:00
|
|
|
* @param {type} _link
|
|
|
|
* @param {type} _app
|
|
|
|
* @param {type} _useIframe
|
|
|
|
* @param {type} _linkSource
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
linkHandler: function(_link, _app, _useIframe, _linkSource)
|
|
|
|
{
|
|
|
|
//Determine the app string from the application parameter
|
|
|
|
var app = null;
|
|
|
|
if (_app && typeof _app == 'string')
|
|
|
|
{
|
|
|
|
app = this.getApplicationByName(_app);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!app)
|
|
|
|
{
|
|
|
|
//The app parameter was false or not a string or the application specified did not exists.
|
|
|
|
//Determine the target application from the link that had been passed to this function
|
|
|
|
app = this.parseAppFromUrl(_link);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (app)
|
|
|
|
{
|
2020-09-23 16:55:35 +02:00
|
|
|
if (_app == '_tab')
|
|
|
|
{
|
|
|
|
// add target flag
|
|
|
|
_link += '&target=_tab';
|
|
|
|
var appname = app.appName+":"+btoa(_link);
|
2020-09-24 11:13:12 +02:00
|
|
|
this.applications[appname] = jQuery.extend(true, {},app);
|
2020-09-23 16:55:35 +02:00
|
|
|
this.applications[appname]['appName'] = appname;
|
|
|
|
this.applications[appname]['indexUrl'] = _link;
|
|
|
|
this.applications[appname]['tab'] = null;
|
|
|
|
this.applications[appname]['browser'] = null;
|
|
|
|
this.applications[appname]['title'] = 'view';
|
|
|
|
app = this.getApplicationByName(appname);
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
this.applicationTabNavigate(app, _link);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Display some error messages to have visible feedback
|
|
|
|
if (typeof _app == 'string')
|
|
|
|
{
|
|
|
|
egw_alertHandler('Application "' + _app + '" not found.',
|
|
|
|
'The application "' + _app + '" the link "' + _link + '" points to is not registered.');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
egw_alertHandler("No appropriate target application has been found.",
|
|
|
|
"Target link: " + _link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-11-11 19:00:29 +01:00
|
|
|
/**
|
|
|
|
* Redirect window to the URL
|
|
|
|
* @param {string} _url
|
|
|
|
*/
|
|
|
|
redirect: function(_url)
|
|
|
|
{
|
|
|
|
window.location = _url;
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-11 19:00:29 +01:00
|
|
|
/**
|
|
|
|
* Sets the active framework application to the application specified by _app
|
|
|
|
*
|
|
|
|
* @param {egw_fw_class_application} _app application object
|
|
|
|
*/
|
|
|
|
setActiveApp: function(_app)
|
|
|
|
{
|
|
|
|
//Only perform the following commands if a new application is activated
|
|
|
|
if (_app != this.activeApp)
|
|
|
|
{
|
|
|
|
// tab not yet loaded, load it now
|
2019-01-10 22:21:05 +01:00
|
|
|
if (!_app.browser || !_app.browser.currentLocation && !_app.browser.iframe)
|
2014-11-11 19:00:29 +01:00
|
|
|
{
|
2019-01-10 22:21:05 +01:00
|
|
|
return this.applicationTabNavigate(_app, _app.indexUrl);
|
2014-11-11 19:00:29 +01:00
|
|
|
}
|
|
|
|
this.activeApp = _app;
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-11 19:00:29 +01:00
|
|
|
//Open the sidemenuUi that belongs to the app, if no sidemenu is attached
|
|
|
|
//to the app, close the sidemenuUi
|
|
|
|
if (_app.sidemenuEntry)
|
|
|
|
{
|
|
|
|
if (_app.hasSideboxMenuContent)
|
|
|
|
{
|
|
|
|
this.sidemenuUi.open(_app.sidemenuEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.sidemenuUi.open(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Set the website title
|
|
|
|
this.refreshAppTitle();
|
|
|
|
|
|
|
|
//Show the application tab
|
|
|
|
if (_app.tab)
|
|
|
|
{
|
|
|
|
this.tabsUi.showTab(_app.tab);
|
2021-03-10 11:56:34 +01:00
|
|
|
if (this.tabApps)
|
2021-03-01 17:30:33 +01:00
|
|
|
{
|
|
|
|
for (let t in this.tabApps)
|
|
|
|
{
|
|
|
|
this.tabApps[t]['active'] = t == _app.appName;
|
|
|
|
}
|
|
|
|
}
|
2014-11-11 19:00:29 +01:00
|
|
|
//Going to a new tab changes the tab state
|
2015-03-10 21:12:30 +01:00
|
|
|
this.notifyTabChange();
|
2014-11-11 19:00:29 +01:00
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
2014-12-01 11:44:51 +01:00
|
|
|
* Open a (centered) popup window with given size and url
|
|
|
|
*
|
|
|
|
* @param {string} _url
|
|
|
|
* @param {number} _width
|
|
|
|
* @param {number} _height
|
|
|
|
* @param {string} _windowName or "_blank"
|
|
|
|
* @param {string|boolean} _app app-name for framework to set correct opener or false for current app
|
|
|
|
* @param {boolean} _returnID true: return window, false: return undefined
|
|
|
|
* @param {type} _status "yes" or "no" to display status bar of popup
|
2014-12-02 12:18:12 +01:00
|
|
|
* @param {DOMWindow} _parentWnd parent window
|
2014-12-01 11:44:51 +01:00
|
|
|
* @returns {DOMWindow|undefined}
|
2014-11-14 17:20:11 +01:00
|
|
|
*/
|
2014-12-02 12:18:12 +01:00
|
|
|
openPopup: function(_url, _width, _height, _windowName, _app, _returnID, _status, _parentWnd)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
|
|
|
//Determine the window the popup should be opened in - normally this is the iframe of the currently active application
|
2014-12-02 12:18:12 +01:00
|
|
|
var parentWindow = _parentWnd || window;
|
2014-11-14 17:20:11 +01:00
|
|
|
var navigate = false;
|
|
|
|
if (typeof _app != 'undefined' && _app !== false)
|
|
|
|
{
|
|
|
|
var appEntry = framework.getApplicationByName(_app);
|
|
|
|
if (appEntry && appEntry.browser == null)
|
|
|
|
{
|
|
|
|
navigate = true;
|
2021-05-21 12:39:56 +02:00
|
|
|
framework.applicationTabNavigate(appEntry, appEntry.indexUrl);
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var appEntry = framework.activeApp;
|
|
|
|
}
|
|
|
|
|
2014-12-02 12:18:12 +01:00
|
|
|
if (appEntry != null && appEntry.browser.iframe != null && (_app || !egw(parentWindow).is_popup()))
|
2014-11-14 17:20:11 +01:00
|
|
|
parentWindow = appEntry.browser.iframe.contentWindow;
|
|
|
|
|
2014-12-01 11:44:51 +01:00
|
|
|
var windowID = egw(parentWindow).openPopup(_url, _width, _height, _windowName, _app, true, _status, true);
|
2014-11-14 17:20:11 +01:00
|
|
|
|
2014-12-01 11:44:51 +01:00
|
|
|
windowID.framework = this;
|
2018-03-09 17:48:09 +01:00
|
|
|
this.popups.push(windowID);
|
2014-11-14 17:20:11 +01:00
|
|
|
|
|
|
|
if (navigate)
|
|
|
|
{
|
|
|
|
window.setTimeout("framework.applicationTabNavigate(framework.activeApp, framework.activeApp.indexUrl);", 500);
|
|
|
|
}
|
|
|
|
|
2014-12-01 11:44:51 +01:00
|
|
|
if (_returnID !== false) return windowID;
|
2014-11-14 17:20:11 +01:00
|
|
|
},
|
|
|
|
|
2018-03-09 17:48:09 +01:00
|
|
|
/**
|
|
|
|
* Check if given window is a "popup" alike, returning integer or undefined if not
|
|
|
|
*
|
|
|
|
* @param {DOMWindow} _wnd
|
|
|
|
* @returns {Number|undefined}
|
|
|
|
*/
|
|
|
|
popup_idx: function(_wnd)
|
|
|
|
{
|
|
|
|
if (typeof window.framework.popups != 'undefined')
|
|
|
|
{
|
|
|
|
for (var i=0; i < window.framework.popups.length; i++)
|
|
|
|
{
|
|
|
|
if (window.framework.popups[i] === _wnd)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {window} _wnd window object which suppose to be closed
|
|
|
|
*/
|
|
|
|
popup_close:function (_wnd)
|
|
|
|
{
|
|
|
|
var i = this.popup_idx(_wnd);
|
|
|
|
|
|
|
|
if (i !== undefined)
|
|
|
|
{
|
|
|
|
// Close the matched popup
|
|
|
|
this.popups.splice(i,1);
|
|
|
|
}
|
|
|
|
_wnd.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collect and close all already closed windowss
|
|
|
|
*/
|
|
|
|
popups_garbage_collector: function ()
|
|
|
|
{
|
|
|
|
for (var i=0; i < this.popups.length; i++)
|
|
|
|
{
|
|
|
|
if (this.popups[i].closed) this.popups.splice(i,1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get popups based on application name and regexp
|
|
|
|
* @param {string} _app app name
|
2019-02-25 13:37:22 +01:00
|
|
|
* @param {regexp|object} regex regular expression to check against location.href url or
|
|
|
|
* an object containing window property to be checked against
|
2018-03-09 17:48:09 +01:00
|
|
|
*
|
|
|
|
* @returns {Array} returns array of windows object
|
|
|
|
*/
|
2019-02-25 13:37:22 +01:00
|
|
|
popups_get: function(_app, param)
|
2018-03-09 17:48:09 +01:00
|
|
|
{
|
|
|
|
var popups = [];
|
|
|
|
for (var i=0; i < this.popups.length; i++)
|
|
|
|
{
|
|
|
|
if (!this.popups[i].closed && this.popups[i].egw_appName == _app) {
|
|
|
|
popups.push(this.popups[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2019-02-25 13:37:22 +01:00
|
|
|
if (param)
|
2018-03-09 17:48:09 +01:00
|
|
|
{
|
|
|
|
for (var j=0; j < popups.length; j++)
|
|
|
|
{
|
2020-06-03 11:38:10 +02:00
|
|
|
if (typeof param === 'object' && param.constructor.name != 'RegExp')
|
2018-03-09 17:48:09 +01:00
|
|
|
{
|
2019-02-25 13:37:22 +01:00
|
|
|
var key = Object.keys(param)[0];
|
2019-04-24 15:13:44 +02:00
|
|
|
if (!popups[j][key].match(new RegExp(param[key])))
|
2019-02-25 13:37:22 +01:00
|
|
|
{
|
|
|
|
delete(popups[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!popups[j].location.href.match(param))
|
|
|
|
{
|
|
|
|
delete(popups[j]);
|
|
|
|
}
|
2018-03-09 17:48:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-25 13:37:22 +01:00
|
|
|
return popups.flat();
|
2018-03-09 17:48:09 +01:00
|
|
|
},
|
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Get application window
|
|
|
|
* @param {type} _app
|
|
|
|
* @returns {window|iframe content}
|
|
|
|
*/
|
|
|
|
egw_appWindow: function(_app)
|
|
|
|
{
|
|
|
|
var app = framework.getApplicationByName(_app);
|
|
|
|
var result = window;
|
|
|
|
if (app != null && app.browser != null && app.browser.iframe != null)
|
|
|
|
{
|
|
|
|
result = app.browser.iframe.contentWindow;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens application with provided url
|
|
|
|
* @param {string|app object} _app app name or app object
|
|
|
|
* @param {string} _url url
|
|
|
|
*/
|
|
|
|
egw_appWindowOpen: function(_app, _url)
|
|
|
|
{
|
|
|
|
if (typeof _url == "undefined") {
|
|
|
|
_url = "about:blank";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do a global location change if the given application name is null (as this function
|
|
|
|
// is called by egw_json.js redirect handler, where the _app parameter defaults to null)
|
|
|
|
if (_app == null) {
|
|
|
|
window.location = _url;
|
|
|
|
}
|
|
|
|
|
|
|
|
var app = null;
|
|
|
|
if (typeof _app == "string") {
|
|
|
|
app = framework.getApplicationByName(_app);
|
|
|
|
} else {
|
|
|
|
app = _app;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (app != null) {
|
|
|
|
framework.applicationTabNavigate(app, _url);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets application name
|
2014-12-01 11:44:51 +01:00
|
|
|
*
|
2014-11-14 17:20:11 +01:00
|
|
|
* @returns {string} returns application name
|
|
|
|
*/
|
|
|
|
|
|
|
|
egw_getAppName: function()
|
|
|
|
{
|
|
|
|
return framework.activeApp.appName;
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
|
|
|
* Change timezone and refresh current app
|
|
|
|
* @param _tz
|
|
|
|
*/
|
|
|
|
tzSelection: function(_tz)
|
|
|
|
{
|
|
|
|
//Perform an AJAX request to tell server
|
2016-06-09 00:02:10 +02:00
|
|
|
var req = egw.json('EGroupware\\Api\\Framework\\Ajax::ajax_tz_selection',[_tz],null,null,false); // false = synchron
|
2014-11-14 17:20:11 +01:00
|
|
|
req.sendRequest();
|
|
|
|
|
2016-06-09 00:02:10 +02:00
|
|
|
// Reload apps so they can use the new setting
|
|
|
|
for (var app in this.applications)
|
2014-11-14 17:20:11 +01:00
|
|
|
{
|
2016-06-09 00:02:10 +02:00
|
|
|
if (this.applications[app].browser)
|
|
|
|
{
|
|
|
|
this.applications[app].browser.reload();
|
|
|
|
}
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-14 17:20:11 +01:00
|
|
|
/**
|
2014-12-01 11:44:51 +01:00
|
|
|
* Refresh application title
|
2014-11-14 17:20:11 +01:00
|
|
|
*/
|
|
|
|
refreshAppTitle: function()
|
|
|
|
{
|
|
|
|
if (this.activeApp)
|
|
|
|
{
|
|
|
|
if (this.messageTimer)
|
|
|
|
{
|
|
|
|
window.clearTimeout(this.messageTimer);
|
|
|
|
delete this.messageTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.tabsUi.setAppHeader(this.activeApp.app_header);
|
2018-03-12 12:16:50 +01:00
|
|
|
var default_title = (egw.config('site_title', 'phpgwapi') ? egw.config('site_title', 'phpgwapi') : "EGroupware")
|
|
|
|
+ ' ['+this.activeApp.displayName+']';;
|
2017-02-01 16:23:08 +01:00
|
|
|
document.title = this.activeApp.website_title || default_title;
|
2014-11-14 17:20:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.resizeHandler();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-12-01 11:44:51 +01:00
|
|
|
*
|
2014-11-14 17:20:11 +01:00
|
|
|
*/
|
|
|
|
resizeHandler: function()
|
|
|
|
{
|
|
|
|
//Resize the browser area of the applications
|
|
|
|
for (var app in this.applications)
|
|
|
|
{
|
|
|
|
if (this.applications[app].browser != null)
|
|
|
|
{
|
|
|
|
this.applications[app].browser.resize();
|
|
|
|
}
|
2014-11-11 19:00:29 +01:00
|
|
|
}
|
2014-11-19 14:58:01 +01:00
|
|
|
},
|
2014-12-01 11:44:51 +01:00
|
|
|
|
2014-11-19 14:58:01 +01:00
|
|
|
/**
|
|
|
|
* Refresh given application _targetapp display of entry _app _id, incl. outputting _msg
|
|
|
|
* @param {string} _msg message (already translated) to show, eg. 'Entry deleted'
|
|
|
|
* @param {string|undefined} _app application name
|
|
|
|
* @param {string|number|undefined} _id id of entry to refresh
|
|
|
|
* @param {string|undefined} _type either 'edit', 'delete', 'add' or undefined
|
|
|
|
* @param {string|undefined} _targetapp which app's window should be refreshed, default current
|
|
|
|
* @param {string|RegExp} _replace regular expression to replace in url
|
|
|
|
* @param {string} _with
|
|
|
|
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
|
|
|
|
* @return {DOMwindow|null} null if refresh was triggered, or DOMwindow of app
|
|
|
|
*/
|
|
|
|
refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
|
|
|
|
{
|
|
|
|
//alert("egw_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')");
|
2020-10-22 13:52:17 +02:00
|
|
|
let app_object = this.getApplicationByName(_app);
|
|
|
|
if (this.isAnInternalApp(app_object) && typeof app_object.refreshCallback == 'function')
|
|
|
|
{
|
|
|
|
app_object.refreshCallback();
|
|
|
|
return;
|
|
|
|
}
|
2014-11-19 14:58:01 +01:00
|
|
|
if (!_app) // force reload of entire framework, eg. when template-set changes
|
|
|
|
{
|
|
|
|
window.location.href = window.egw_webserverUrl+'/index.php?cd=yes'+(_msg ? '&msg='+encodeURIComponent(_msg) : '');
|
|
|
|
}
|
|
|
|
// Call appropriate default / fallback refresh
|
|
|
|
var win = window;
|
2016-06-13 12:30:21 +02:00
|
|
|
|
|
|
|
// Preferences app is running under admin app, we need to trigger admin refersh
|
|
|
|
// in order to refresh categories list
|
|
|
|
_app = _app === 'preferences'?'admin':_app;
|
|
|
|
|
2014-11-19 14:58:01 +01:00
|
|
|
var app = this.getApplicationByName(_app);
|
|
|
|
if (app)
|
|
|
|
{
|
|
|
|
// app with closed, or not yet loaded tab --> ignore update, happens automatic when tab loads
|
|
|
|
if (!app.browser)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (app.browser && app.browser.iframe)
|
|
|
|
{
|
|
|
|
win = app.browser.iframe.contentWindow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// app running top-level (no full refresh / window reload!)
|
2020-07-24 09:23:44 +02:00
|
|
|
if (win == window && _app !== 'msg-only-push-refresh')
|
2014-11-19 14:58:01 +01:00
|
|
|
{
|
|
|
|
var refresh_done = false;
|
|
|
|
// et2 nextmatch available, let it refresh
|
|
|
|
if(typeof etemplate2 == "function" && etemplate2.app_refresh)
|
|
|
|
{
|
|
|
|
refresh_done = etemplate2.app_refresh(_msg, _app, _id, _type);
|
|
|
|
}
|
|
|
|
// if not trigger a regular refresh
|
|
|
|
if (!refresh_done)
|
|
|
|
{
|
|
|
|
if (!app) app = this.activeApp;
|
|
|
|
if (app && app.browser) app.browser.reload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if different target-app given, refresh it too
|
|
|
|
if (_targetapp && _app != _targetapp)
|
|
|
|
{
|
|
|
|
this.refresh(_msg, _targetapp, null, null, null, _replace, _with, _msg_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
// app runs in iframe (refresh iframe content window)
|
|
|
|
if (win != window)
|
|
|
|
{
|
|
|
|
return win;
|
|
|
|
}
|
2014-11-26 09:40:42 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2019-03-15 23:01:25 +01:00
|
|
|
* Print function prints the active window, or the provided window
|
2014-11-26 09:40:42 +01:00
|
|
|
*/
|
2019-03-15 23:01:25 +01:00
|
|
|
print: function(_window)
|
2014-11-26 09:40:42 +01:00
|
|
|
{
|
2019-03-15 23:01:25 +01:00
|
|
|
if (_window || this.activeApp && this.activeApp.appName != 'manual')
|
2014-11-26 09:40:42 +01:00
|
|
|
{
|
2019-03-15 23:01:25 +01:00
|
|
|
var appWindow = _window || this.egw_appWindow(this.activeApp.appName);
|
|
|
|
var content = (_window && appWindow === _window) ?
|
|
|
|
_window.document : this.activeApp.tab.contentDiv;
|
2014-11-26 09:40:42 +01:00
|
|
|
if (appWindow)
|
|
|
|
{
|
|
|
|
appWindow.focus();
|
2015-01-27 17:26:59 +01:00
|
|
|
|
|
|
|
// et2 available, let its widgets prepare
|
2015-10-24 13:07:22 +02:00
|
|
|
var deferred = [];
|
2015-02-11 19:05:14 +01:00
|
|
|
var et2_list = [];
|
2019-03-15 23:01:25 +01:00
|
|
|
jQuery('.et2_container',content).each(function() {
|
|
|
|
var et2 = appWindow.etemplate2.getById(this.id);
|
2016-04-21 22:30:10 +02:00
|
|
|
if(et2 && jQuery(et2.DOMContainer).filter(':visible').length)
|
2015-02-11 19:05:14 +01:00
|
|
|
{
|
|
|
|
deferred = deferred.concat(et2.print());
|
|
|
|
et2_list.push(et2);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if(et2_list.length)
|
2015-01-27 17:26:59 +01:00
|
|
|
{
|
2015-02-11 19:05:14 +01:00
|
|
|
// Try to clean up after - not guaranteed
|
|
|
|
var afterPrint = function() {
|
2015-02-19 01:54:49 +01:00
|
|
|
var app = framework.activeApp;
|
|
|
|
framework.activeApp = '';
|
|
|
|
framework.setActiveApp(app);
|
2016-05-04 21:07:54 +02:00
|
|
|
|
2016-04-29 18:34:18 +02:00
|
|
|
egw.loading_prompt(app.appName,true,egw.lang('please wait...'),app.browser.baseDiv, egwIsMobile()?'horizental':'spinner');
|
2015-02-19 01:54:49 +01:00
|
|
|
|
|
|
|
// Give framework a chance to deal, then reset the etemplates
|
2019-03-15 23:01:25 +01:00
|
|
|
appWindow.setTimeout(function() {
|
2015-02-19 01:54:49 +01:00
|
|
|
for(var i = 0; i < et2_list.length; i++)
|
|
|
|
{
|
|
|
|
et2_list[i].widgetContainer.iterateOver(function(_widget) {
|
|
|
|
_widget.afterPrint();
|
2019-03-15 23:01:25 +01:00
|
|
|
},et2_list[i],appWindow.et2_IPrint);
|
2015-02-19 01:54:49 +01:00
|
|
|
}
|
2016-04-29 18:34:18 +02:00
|
|
|
egw.loading_prompt(app.appName,false);
|
2015-02-19 01:54:49 +01:00
|
|
|
},100);
|
|
|
|
appWindow.onafterprint = null;
|
2015-02-11 19:05:14 +01:00
|
|
|
};
|
|
|
|
if(appWindow.matchMedia) {
|
|
|
|
var mediaQueryList = appWindow.matchMedia('print');
|
|
|
|
var listener = function(mql) {
|
|
|
|
if (!mql.matches) {
|
|
|
|
mediaQueryList.removeListener(listener);
|
2015-02-19 01:27:21 +01:00
|
|
|
afterPrint();
|
2015-02-11 19:05:14 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
mediaQueryList.addListener(listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
appWindow.onafterprint = afterPrint;
|
|
|
|
|
|
|
|
// Wait for everything to be loaded, then send it off
|
|
|
|
jQuery.when.apply(jQuery, deferred).done(function() {
|
2015-02-19 01:27:21 +01:00
|
|
|
appWindow.setTimeout(appWindow.print, 0);
|
2015-02-11 19:05:14 +01:00
|
|
|
}).fail(function() {
|
|
|
|
afterPrint();
|
|
|
|
});
|
2015-01-27 17:26:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Print
|
|
|
|
appWindow.print();
|
|
|
|
}
|
2014-11-26 09:40:42 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-10 14:17:50 +01:00
|
|
|
},
|
2020-06-03 11:38:10 +02:00
|
|
|
|
2019-12-10 14:17:50 +01:00
|
|
|
/**
|
|
|
|
* Set a notification message for topmenu info item
|
|
|
|
*
|
|
|
|
* @param {string} _id id of topmenu info item with its prefix
|
|
|
|
* @param {string} _message message that should be displayed
|
|
|
|
* @param {string} _tooltip hint text as tooltip
|
|
|
|
*/
|
|
|
|
topmenu_info_notify: function(_id, _switch, _message, _tooltip) {
|
|
|
|
var $items = jQuery('#egw_fw_topmenu_info_items').children();
|
|
|
|
var prefix = "topmenu_info_";
|
|
|
|
|
|
|
|
$items.each(function(i,item){
|
|
|
|
if (item.id == prefix+_id || item.id == _id)
|
|
|
|
{
|
|
|
|
var $notify = jQuery(item).find('.egw_fw_topmenu_info_notify');
|
|
|
|
if (_switch)
|
|
|
|
{
|
|
|
|
if ($notify.length == 0)
|
|
|
|
{
|
|
|
|
$notify = jQuery(document.createElement('div'))
|
|
|
|
.addClass('egw_fw_topmenu_info_notify')
|
|
|
|
.prop('title', _tooltip)
|
|
|
|
.appendTo(item);
|
|
|
|
}
|
|
|
|
$notify.prop('title', _tooltip).text(_message);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$notify.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-10-22 13:52:17 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the app is an internal app object like multitab views
|
|
|
|
* @param _app app object
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
isAnInternalApp: function(_app)
|
|
|
|
{
|
2020-10-23 11:11:42 +02:00
|
|
|
return _app && _app.appName != _app.internalName;
|
2020-12-15 20:24:25 +01:00
|
|
|
},
|
|
|
|
|
2021-01-26 17:04:37 +01:00
|
|
|
/**
|
|
|
|
* set darkmode attribute into html tag
|
|
|
|
* @param string _state '0' means off and '1' means on
|
|
|
|
* @private
|
|
|
|
*/
|
2020-12-15 20:24:25 +01:00
|
|
|
_setDarkMode: function(_state)
|
|
|
|
{
|
2021-03-18 16:32:21 +01:00
|
|
|
let state = !_state || _state == '0' ?'0':'1';
|
2021-02-24 12:22:27 +01:00
|
|
|
jQuery('html').attr('data-darkmode', state);
|
|
|
|
jQuery('iframe').each((i, frame) =>{
|
|
|
|
try {
|
|
|
|
if (frame && frame.contentWindow && frame.contentWindow.jQuery)
|
|
|
|
{
|
2021-03-18 16:32:21 +01:00
|
|
|
frame.contentWindow.jQuery('html').attr('data-darkmode', state == 0?'':'1');
|
2021-02-24 12:22:27 +01:00
|
|
|
}
|
|
|
|
}catch(e)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
egw.setSessionItem('api', 'darkmode',state);
|
|
|
|
egw.json('EGroupware\\Api\\Framework\\Ajax::ajax_set_darkmode_flag',[state]).sendRequest();
|
2021-04-19 10:17:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* firstload animation
|
|
|
|
* @param string _app app name
|
|
|
|
* @param int _gauge 0 - 100
|
|
|
|
*/
|
|
|
|
firstload_animation: function(_app, _gauge)
|
|
|
|
{
|
|
|
|
if (_app)
|
|
|
|
{
|
|
|
|
jQuery('.fl_app.'+_app).css({
|
2021-04-20 14:45:21 +02:00
|
|
|
opacity: 1,
|
|
|
|
animation:"anim 1s"
|
2021-04-19 10:17:40 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
let progress = jQuery('.fl_progress');
|
|
|
|
let gauge = progress.children();
|
|
|
|
|
|
|
|
this.firstload_animation_gauge = _gauge ? _gauge : (this.firstload_animation_gauge == 0 ? 10 : (this.firstload_animation_gauge+5));
|
|
|
|
gauge.width(this.firstload_animation_gauge+"%");
|
2021-04-22 16:00:52 +02:00
|
|
|
if (_gauge == 100) window.setTimeout(function(){jQuery('#egw_fw_firstload').remove();},1000);
|
2014-11-26 09:40:42 +01:00
|
|
|
}
|
2016-02-29 16:50:24 +01:00
|
|
|
});}).call(this);
|