/**
* EGroupware eTemplate2 widget browser
* View & play with et2 widgets - javascript
*
* @link http://www.egroupware.org
* @author Nathan Gray
* @copyright 2013 Nathan Gray
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage tools
* @version $Id$
*/
/**
* widget_browser shows a list of widgets, and allows you to view them one at a time.
* You can view and edit defined properties to see the effect.
*/
function widget_browser(list_div, widget_div)
{
// Initialize etemplate2
this.et2 = new etemplate2(widget_div, "etemplate::ajax_process_content");
// Normally this would be passed from app
var _data = {};
// Create the basic widget container and attach it to the DOM
// Not really needed, but let's be consitent with et2
this.et2.widgetContainer = new et2_container(null);
this.et2.widgetContainer.setApiInstance(egw('etemplate', egw.elemWindow(this.et2.DOMContainer)));
this.et2.widgetContainer.setInstanceManager(this.et2);
this.et2.widgetContainer.setParentDOMNode(this.et2.DOMContainer);
this.et2.widgetContainer.setArrayMgrs(this.et2._createArrayManagers(_data));
// Set up UI
this.list_div = $j(list_div);
this.widget_div = $j(widget_div);
this.attribute_list = null;
// Create and popuplate the widget list
this._init_list();
}
/**
* Read the widget registry and create a list.
* The user can pick a widget, and we'll instanciate it.
*/
widget_browser.prototype._init_list = function()
{
var self = this;
// Create list
var list = $j(document.createElement('ul'))
.attr('id', 'widgets')
.click(function(e) {self.select_widget(e);})
.appendTo(this.list_div);
for(var type in et2_registry)
{
var class_name = et2_registry[type];
list.append('