forked from extern/egroupware
moving egw_preferences (handler to call preferenes, acl or categories) from jsapi.js to egw_preferences.js show_preferences() method
This commit is contained in:
parent
899c04abb5
commit
ca334ad13b
@ -1363,7 +1363,7 @@ abstract class egw_framework
|
||||
'id' => $type,
|
||||
'name' => 'preferences',
|
||||
'title' => lang($types[$type]['title']),
|
||||
'url' => "javascript:egw_preferences('$type',".json_encode($apps).')',
|
||||
'url' => "javascript:egw.show_preferences(\"$type\",".json_encode($apps).')',
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd) {
|
||||
|
||||
return popup_window;
|
||||
}
|
||||
else if (typeof _wnd.egw_link_handler == 'function' && (typeof _target == 'undefined' || _target =='_self' || typeof this.link_app_list()[_target] != "undefined"))
|
||||
else if ((typeof _target == 'undefined' || _target == '_self' || typeof this.link_app_list()[_target] != "undefined"))
|
||||
{
|
||||
if(_target == '_self')
|
||||
{
|
||||
@ -288,16 +288,30 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd) {
|
||||
_target = undefined;
|
||||
}
|
||||
// Use framework's link handler, if present
|
||||
return _wnd.egw_link_handler(url,_target);
|
||||
}
|
||||
else if (_target == '_self')
|
||||
{
|
||||
_wnd.location.href = url;
|
||||
return this.link_handler(url,_target);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _wnd.open(url, _target);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Use frameworks (framed template) link handler to open a url
|
||||
*
|
||||
* @param {string} _url
|
||||
* @param {string} _target
|
||||
*/
|
||||
link_handler: function(_url, _target)
|
||||
{
|
||||
if (_wnd.framework)
|
||||
{
|
||||
_wnd.framework.linkHandler(_url, _target);
|
||||
}
|
||||
else
|
||||
{
|
||||
_wnd.location.href = _url;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -31,8 +31,8 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() {
|
||||
/**
|
||||
* Setting prefs for an app or 'common'
|
||||
*
|
||||
* @param object _data object with name: value pairs to set
|
||||
* @param string _app application name, 'common' or undefined to prefes of all apps at once
|
||||
* @param {object} _data object with name: value pairs to set
|
||||
* @param {string} _app application name, 'common' or undefined to prefes of all apps at once
|
||||
*/
|
||||
set_preferences: function(_data, _app)
|
||||
{
|
||||
@ -51,8 +51,8 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() {
|
||||
*
|
||||
* If a prefernce is not already loaded (only done for "common" by default), it is synchroniosly queryed from the server!
|
||||
*
|
||||
* @param string _name name of the preference, eg. 'dateformat', or '*' to get all the application's preferences
|
||||
* @param string _app='common'
|
||||
* @param {string} _name name of the preference, eg. 'dateformat', or '*' to get all the application's preferences
|
||||
* @param {string} _app default 'common'
|
||||
* @return string preference value
|
||||
* @todo add a callback to query it asynchron
|
||||
*/
|
||||
@ -76,9 +76,9 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() {
|
||||
*
|
||||
* Server will silently ignore setting preferences, if user has no right to do so!
|
||||
*
|
||||
* @param string _app application name or "common"
|
||||
* @param string _name name of the pref
|
||||
* @param string _val value of the pref
|
||||
* @param {string} _app application name or "common"
|
||||
* @param {string} _name name of the pref
|
||||
* @param {string} _val value of the pref
|
||||
*/
|
||||
set_preference: function(_app, _name, _val)
|
||||
{
|
||||
@ -86,8 +86,60 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() {
|
||||
|
||||
// update own preference cache, if _app prefs are loaded (dont update otherwise, as it would block loading of other _app prefs!)
|
||||
if (typeof prefs[_app] != 'undefined') prefs[_app][_name] = _val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Call context / open app specific preferences function
|
||||
*
|
||||
* @param {string} name type 'acl', 'prefs', or 'cats'
|
||||
* @param {(array|object)} apps array with apps allowing to call that type, or object/hash with app and boolean or hash with url-params
|
||||
*/
|
||||
show_preferences: function (name, apps)
|
||||
{
|
||||
var current_app = this.app_name();
|
||||
var query = {};
|
||||
// give warning, if app does not support given type, but all apps link to common prefs, if they dont support prefs themselfs
|
||||
if ($j.isArray(apps) && $j.inArray(current_app, apps) == -1 && name != 'prefs' ||
|
||||
!$j.isArray(apps) && (typeof apps[current_app] == 'undefined' || !apps[current_app]))
|
||||
{
|
||||
egw_message(egw.lang('Not supported by current application!'), 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
var url = '/index.php';
|
||||
switch(name)
|
||||
{
|
||||
case 'prefs':
|
||||
query.menuaction ='preferences.preferences_settings.index';
|
||||
if ($j.inArray(current_app, apps) != -1) query.appname=current_app;
|
||||
break;
|
||||
|
||||
case 'acl':
|
||||
query.menuaction='preferences.preferences_acl.index';
|
||||
query.acl_app=current_app;
|
||||
query.ajax=true;
|
||||
break;
|
||||
|
||||
case 'cats':
|
||||
if (typeof apps[current_app] == 'object')
|
||||
{
|
||||
for(var key in apps[current_app])
|
||||
{
|
||||
query[key] = encodeURIComponent(apps[current_app][key]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
query.menuaction='preferences.preferences_categories_ui.index';
|
||||
query.cats_app=current_app;
|
||||
query.ajax=true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
query.current_app = current_app;
|
||||
egw.link_handler(egw.link(url, query), current_app);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
@ -193,6 +193,8 @@ function egw_getApp(_name)
|
||||
|
||||
/**
|
||||
* Returns the name of the currently active application
|
||||
*
|
||||
* @deprecated use egw(window).app_name()
|
||||
*/
|
||||
function egw_getAppName()
|
||||
{
|
||||
@ -779,74 +781,15 @@ function dropdown_menu_hack(el)
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy link handler, which can be overwritten by templates
|
||||
* Use frameworks (framed template) link handler to open a url
|
||||
*
|
||||
* @param _link
|
||||
* @param _app
|
||||
* @deprecated use egw(window).link_handler(_link, _app) instead
|
||||
*/
|
||||
function egw_link_handler(_link, _app)
|
||||
{
|
||||
if (window.framework)
|
||||
{
|
||||
window.framework.linkHandler(_link, _app);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = _link;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call context / open app specific preferences function
|
||||
*
|
||||
* @param string name type 'acl', 'prefs', or 'cats'
|
||||
* @param array|object apps array with apps allowing to call that type, or object/hash with app and boolean or hash with url-params
|
||||
*/
|
||||
function egw_preferences(name, apps)
|
||||
{
|
||||
var current_app = egw_getAppName();
|
||||
var query = {};
|
||||
// give warning, if app does not support given type, but all apps link to common prefs, if they dont support prefs themselfs
|
||||
if ($j.isArray(apps) && $j.inArray(current_app, apps) == -1 && name != 'prefs' ||
|
||||
!$j.isArray(apps) && (typeof apps[current_app] == 'undefined' || !apps[current_app]))
|
||||
{
|
||||
egw_message(egw.lang('Not supported by current application!'), 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
var url = '/index.php';
|
||||
switch(name)
|
||||
{
|
||||
case 'prefs':
|
||||
query.menuaction ='preferences.preferences_settings.index';
|
||||
if ($j.inArray(current_app, apps) != -1) query.appname=current_app;
|
||||
break;
|
||||
|
||||
case 'acl':
|
||||
query.menuaction='preferences.preferences_acl.index';
|
||||
query.acl_app=current_app;
|
||||
query.ajax=true;
|
||||
break;
|
||||
|
||||
case 'cats':
|
||||
if (typeof apps[current_app] == 'object')
|
||||
{
|
||||
for(var key in apps[current_app])
|
||||
{
|
||||
query[key] = encodeURIComponent(apps[current_app][key]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
query.menuaction='preferences.preferences_categories_ui.index';
|
||||
query.cats_app=current_app;
|
||||
query.ajax=true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
query.current_app = current_app;
|
||||
egw_link_handler(egw.link(url, query), current_app);
|
||||
}
|
||||
egw(window).link_handler(_link, _app);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,21 +65,13 @@ egw_LAB.wait(function() {
|
||||
var href_regexp = /^javascript:([^\(]+)\((.*)?\);?$/;
|
||||
jQuery('#topmenu_items,#thesideboxcolumn').on('click','a[href^="javascript:"]',function(){
|
||||
var matches = this.href.match(href_regexp);
|
||||
if (matches && typeof window[matches[1]] == 'function') {
|
||||
var args = [];
|
||||
if (matches.length > 1 && matches[2] !== undefined) args = JSON.parse('['+matches[2].replace(/'/g,'"')+']');
|
||||
window[matches[1]].apply(window.framework, args);
|
||||
}
|
||||
else if (matches && matches[1].indexOf('app.') == 0)
|
||||
var args = [];
|
||||
if (matches.length > 1 && matches[2] !== undefined)
|
||||
{
|
||||
return et2_call(matches[1],matches[2]);
|
||||
args = JSON.parse('['+matches[2].replace(/'/g,'"')+']');
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Do NOT know how to execute '+this.href);
|
||||
}
|
||||
// return false to not execute link itself, which would violate CSP
|
||||
return false;
|
||||
args.unshift(matches[1]);
|
||||
return et2_call.apply(this, args);
|
||||
});
|
||||
|
||||
// make sidebox resizable with jQueryUI resizable
|
||||
|
Loading…
Reference in New Issue
Block a user