2012-03-01 17:24:29 +01:00
|
|
|
/**
|
|
|
|
* EGroupware clientside API object
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Andreas Stöckel (as AT stylite.de)
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*egw:uses
|
|
|
|
egw_core;
|
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
import './egw_core.js';
|
2012-03-01 17:24:29 +01:00
|
|
|
|
2016-02-29 16:50:24 +01:00
|
|
|
egw.extend('config', egw.MODULE_GLOBAL, function()
|
|
|
|
{
|
|
|
|
"use strict";
|
2012-03-01 17:24:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clientside config
|
2014-01-09 16:32:07 +01:00
|
|
|
*
|
2012-03-01 17:24:29 +01:00
|
|
|
* @access: private, use egw.config(_name, _app="phpgwapi")
|
|
|
|
*/
|
|
|
|
var configs = {};
|
|
|
|
|
2022-07-26 10:05:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* register our mail as mailto protocol handler (only for main-page, FF seems to pop it up constantly, if we do so in an iframe)
|
|
|
|
*/
|
|
|
|
function install_mailto_handler()
|
|
|
|
{
|
2022-07-28 14:23:36 +02:00
|
|
|
if (document.location.href.match(/(\?|&)cd=yes(&|$)/) &&
|
|
|
|
typeof navigator.registerProtocolHandler === 'function') // eg. Safari 15.5 does NOT implement it
|
2022-07-26 10:05:43 +02:00
|
|
|
{
|
|
|
|
let url = egw_webserverUrl;
|
|
|
|
if (url[0] === '/') url = document.location.protocol+'://'+document.location.hostname+(url !== '/' ? url : '');
|
|
|
|
navigator.registerProtocolHandler('mailto', url+'/index.php?menuaction=mail.mail_compose.compose&preset[mailto]=%s', 'Mail');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-01 17:24:29 +01:00
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Query clientside config
|
2014-01-09 16:32:07 +01:00
|
|
|
*
|
2015-02-02 20:49:18 +01:00
|
|
|
* @param {string} _name name of config variable
|
|
|
|
* @param {string} _app default "phpgwapi"
|
2012-03-01 17:24:29 +01:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
config: function (_name, _app)
|
|
|
|
{
|
|
|
|
if (typeof _app == 'undefined') _app = 'phpgwapi';
|
|
|
|
|
2014-01-10 09:12:59 +01:00
|
|
|
if (typeof configs[_app] == 'undefined') return null;
|
2014-01-09 16:32:07 +01:00
|
|
|
|
2014-01-10 09:12:59 +01:00
|
|
|
return configs[_app][_name];
|
2012-03-01 17:24:29 +01:00
|
|
|
},
|
2014-01-09 16:32:07 +01:00
|
|
|
|
2012-03-01 17:24:29 +01:00
|
|
|
/**
|
|
|
|
* Set clientside configuration for all apps
|
2014-01-09 16:32:07 +01:00
|
|
|
*
|
2015-02-02 20:49:18 +01:00
|
|
|
* @param {object} _configs
|
|
|
|
* @param {boolean} _need_clone _configs need to be cloned, as it is from different window context
|
|
|
|
* and therefore will be inaccessible in IE, after that window is closed
|
2012-03-01 17:24:29 +01:00
|
|
|
*/
|
2015-02-02 20:49:18 +01:00
|
|
|
set_configs: function(_configs, _need_clone)
|
2012-03-01 17:24:29 +01:00
|
|
|
{
|
2015-02-02 20:49:18 +01:00
|
|
|
configs = _need_clone ? jQuery.extend(true, {}, _configs) : _configs;
|
2022-07-26 10:05:43 +02:00
|
|
|
|
|
|
|
if (this.config('install_mailto_handler') !== 'disabled')
|
|
|
|
{
|
|
|
|
install_mailto_handler();
|
|
|
|
}
|
2012-03-01 17:24:29 +01:00
|
|
|
}
|
|
|
|
};
|
2022-07-26 10:05:43 +02:00
|
|
|
});
|