- Fixed etemplate input dirty handling

- Now generating an widget object tree in widget.js
- Added generic response to egw_json
- Moved "getFramework" function to jsapi and renamed it to "egw_getFramework"
- Added plugin system to egw_json
- Transformed the jQuery "replaceWith" call form class.etemplate_form.inc.php into an own json plugin
- Fixed label creation for et_html
This commit is contained in:
Andreas Stöckel 2010-07-08 12:03:13 +00:00
parent b78a9865cc
commit b5e33eab09
3 changed files with 76 additions and 0 deletions

View File

@ -306,6 +306,18 @@ class egw_json_response
} }
} }
public function generic($type, array $parameters = array())
{
if (is_string($type))
{
$this->addGeneric($type, $parameters);
}
else
{
throw new Exception("Invalid parameters supplied.");
}
}
/** /**
* Adds an html assign to the response, which is excecuted upon the request is received. * Adds an html assign to the response, which is excecuted upon the request is received.
* *

View File

@ -121,6 +121,50 @@ function egw_json_encode(input)
*/ */
var egw_json_files = {}; var egw_json_files = {};
/**
* Variable which stores all currently registered plugins
*/
var _egw_json_plugins = [];
/**
* Register a plugin for the egw_json handler
*/
function egw_json_register_plugin(_callback, _context)
{
//Default the context parameter to "window"
if (typeof _context == 'undefined') {
_context = window;
}
//Add a plugin object to the plugins array
_egw_json_plugins[_egw_json_plugins.length] = {
'callback': _callback,
'context': _context
};
}
/**
* Function used internally to pass a response to all registered plugins
*/
function _egw_json_plugin_handle(_type, _response) {
for (var i = 0; i < _egw_json_plugins.length; i++)
{
try {
var plugin = _egw_json_plugins[i];
if (plugin.callback.call(plugin.context, _type, _response)) {
return true;
}
} catch (e) {
if (typeof console != 'undefined')
{
console.log(e);
}
}
}
return false;
}
/** The constructor of the egw_json_request class. /** The constructor of the egw_json_request class.
* @param string _menuaction the menuaction function which should be called and which handles the actual request * @param string _menuaction the menuaction function which should be called and which handles the actual request
* @param array _parameters which should be passed to the menuaction function. * @param array _parameters which should be passed to the menuaction function.
@ -376,6 +420,9 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
throw 'Invalid parameters'; throw 'Invalid parameters';
break; break;
} }
//Try to handle the json response with all registered plugins
hasResponse |= _egw_json_plugin_handle(data.response[i].type, res);
} catch(e) { } catch(e) {
this.jsonError('Internal JSON handler error', e); this.jsonError('Internal JSON handler error', e);
} }

View File

@ -114,6 +114,23 @@ function egw_appWindow(_app)
return window; return window;
} }
window.egw_getFramework = function()
{
if (typeof window.framework != 'undefined')
{
return framework;
}
else if (typeof window.parent.egw_getFramework != "undefined")
{
return window.parent.egw_getFramework();
}
else
{
return null;
}
}
function egw_set_checkbox_multiselect_enabled(_id, _enabled) function egw_set_checkbox_multiselect_enabled(_id, _enabled)
{ {
//Retrieve the checkbox_multiselect base div //Retrieve the checkbox_multiselect base div