Now again using a local etemplate2 instance on the client

This commit is contained in:
Andreas Stöckel 2012-03-12 12:05:14 +00:00
parent 36314a077e
commit dc017ed889
9 changed files with 33 additions and 44 deletions

View File

@ -25,7 +25,8 @@
*
* etemplate or uietemplate extends boetemplate, all vars and public functions are inherited
*/
class etemplate extends boetemplate
class etemplate extends etemplate_new {}
class etemplate_old extends boetemplate
{
/**
* integer debug-level or template-name or cell-type or '' = off

View File

@ -102,8 +102,18 @@ class etemplate_new extends etemplate_widget_template
function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$ignore_validation='',$changes='')
{
// Overwrite "nonavbar" is the output_mode is two
$GLOBALS['egw_info']['flags']['nonavbar'] = ($output_mode == 2);
// Include the etemplate2 javascript code
egw_framework::validate_file('.', 'etemplate2', 'etemplate');
// load translations
translation::add_app('etemplate');
foreach(translation::$loaded_apps as $app => $lang)
{
egw_framework::validate_file('/phpgwapi/lang.php', array(
'app' => $app,
'lang' => $lang,
));
}
if (!$this->rel_path) throw new egw_exception_assertion_failed('No (valid) template read!');
@ -157,7 +167,7 @@ class etemplate_new extends etemplate_widget_template
<div id="container"></div>
<script>
egw(window).ready(function() {
var et2 = new (egw().etemplate2)(document.getElementById("container"), "etemplate_new::ajax_process_content");
var et2 = new etemplate2(document.getElementById("container"), "etemplate_new::ajax_process_content");
et2.load("'.$GLOBALS['egw_info']['server']['webserver_url'].$this->rel_path.'",'.json_encode($data).');
}, null, true);
</script>

View File

@ -90,9 +90,13 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
this.header = new et2_nextmatch_header_bar(this, this.div);
this.innerDiv = $j(document.createElement("div"))
.appendTo(this.div);
// Create the dynheight component which dynamically scales the inner
// container.
this.dynheight = new et2_dynheight(null, this.div, 150);
this.dynheight = new et2_dynheight(this.egw().window,
this.innerDiv, 150);
// Create the action manager
this.actionManager = new egwActionManager();
@ -111,7 +115,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
}
// Create the outer grid container
this.dataviewContainer = new et2_dataview_gridContainer(this.div,
this.dataviewContainer = new et2_dataview_gridContainer(this.innerDiv,
this.dataProvider, this.egw());
this.activeFilters = {};
@ -631,7 +635,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
.append(select.getDOMNode())
.append(okButton.getDOMNode())
.append(cancelButton.getDOMNode())
.appendTo(this.div);
.appendTo(this.innerDiv);
// Add default checkbox for admins
var apps = this.egw().user('apps');

View File

@ -30,13 +30,12 @@ var et2_dynheight = Class.extend({
* @param _outerNode is the node which surrounds the _innerNode and to
* which extend the innerNode should be expanded without creating a
* scrollbar. Note: The outer node must be a parent of the inner node.
* If "null" is passed, the outer node is set to "window".
* @param _innerNode is the node which should be scaled. Call update to
* scale the node.
* @param _minHeight is the minimum height the inner node should have
*/
init: function(_outerNode, _innerNode, _minHeight) {
this.outerNode = _outerNode ? $j(_outerNode) : $j(window);
this.outerNode = $j(_outerNode);
this.innerNode = $j(_innerNode);
this.minHeight = _minHeight;
@ -58,6 +57,9 @@ var et2_dynheight = Class.extend({
// Initialize the height calculation
this._initialize();
console.log(this.outerNode);
console.log(this.innerNode);
// Get the outer container height
var oh = this.outerNode.height();
@ -158,13 +160,6 @@ var et2_dynheight = Class.extend({
var ih = this.innerNode.height();
this.innerMargin = ioh - ih;
// Calculate the outer margin
var node = this.outerNode;
if (node[0] == window)
{
node = $j("body");
}
this.initialized = true;
}
}

View File

@ -50,8 +50,6 @@
jsapi.egw_json;
*/
egw.extend('etemplate2', egw.MODULE_GLOBAL, function() {
/**
* The etemplate2 class manages a certain etemplate2 instance.
*
@ -161,6 +159,7 @@ etemplate2.prototype.load = function(_url, _data)
// Asynchronously load the XET file (code below is executed ahead of the
// code in the callback function)
et2_loadXMLFromURL(_url, function(_xmldoc) {
// Read the XML structure
this.widgetContainer.loadFromXML(_xmldoc);
@ -181,7 +180,7 @@ etemplate2.prototype.load = function(_url, _data)
this.widgetContainer = new et2_container(null);
this.widgetContainer.setApiInstance(egw(egw.elemWindow(this.DOMContainer)));
this.widgetContainer.setInstanceManager(this);
this.widgetContainer.setParentDOMNode(frag);
this.widgetContainer.setParentDOMNode(this.DOMContainer);
// store the id to submit it back to server
if(_data) {
@ -378,8 +377,3 @@ function etemplate2_handle_validation_error(_type, _response)
egw(window).registerJSONPlugin(etemplate2_handle_load, null, 'et2_load');
egw(window).registerJSONPlugin(etemplate2_handle_validation_error, null, 'et2_validation_error');
// Return the etemplate2 constructor
return {'etemplate2': etemplate2};
});

View File

@ -94,7 +94,7 @@ abstract class egw_framework
'/phpgwapi/js/./egw_json.js',
// always include javascript helper functions
'/phpgwapi/js/jsapi/jsapi.js',
// '/phpgwapi/js/jsapi/egw.js',
'/phpgwapi/js/jsapi/egw.js',
));
}

View File

@ -28,6 +28,6 @@
egw_css;
egw_calendar;
egw_ready;
egw_jquery;
// egw_jquery;
*/

View File

@ -13,6 +13,8 @@
"use strict";
/*egw:uses
jquery.jquery_ui;
egw_core;
egw_preferences;
egw_jquery;
@ -58,7 +60,7 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
}
// Get the preferences
_egw.$j(_input).datepicker(params);
$j(_input).datepicker(params);
/*
onClose: function(date_text, picker) {
// Only update if there's a change - "" if no date selected

View File

@ -89,23 +89,6 @@ class idots_framework extends egw_framework
if (self::$header_done) return '';
self::$header_done = true;
// load translations
self::validate_file('jsapi', 'egw', 'phpgwapi');
translation::add_app('etemplate');
foreach(translation::$loaded_apps as $app => $lang)
{
egw_framework::validate_file('/phpgwapi/lang.php', array(
'app' => $app,
'lang' => $lang,
));
}
if ($this->isTop(false))
{
self::validate_file('.', 'etemplate2', 'etemplate');
}
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
header('Content-type: text/html; charset='.translation::charset());