// Copyright (c) 2003, 2004 Four J's Development Tools.
// All Rights Reserved.
// Note that the modification of this file is not supported.
// For customizing with your own javascript and cascading style sheets
// please read the product documentation.
//
// $Id: application.js,v 1.231.2.2 2007/10/29 16:49:19 ff Exp $
var g_InitTime = (new Date()).getTime();
var g_styleSheet = gAppendStyleSheet(window);
var gFULL_MODE = 1;
var gINCREMENTAL_MODE = 2;
var gFIELD_MODE = 1;
var gSMART_FIELD_MODE = 2;
var gConfiguration = {
refreshPageMethodAfterNewApplication: gFULL_MODE
}
function gConnectionSyncQueue() {
var xmlhttp = gNewXMLHttpRequest();
var requestQueue = [];
this.sending = false;
this.Send = function( req ) {
requestQueue.push( req );
if ( !this.sending ) {
this.sending = true;
while ( requestQueue.length > 0 ) {
var request = requestQueue.shift();
var tok = 0, body = '';
for ( var key in request.data )
body += (tok++?'&':'') + encodeURIComponent(key) + '=' + encodeURIComponent(request.data[key]);
xmlhttp.open('POST', request.url, false);
xmlhttp.setRequestHeader('Accept-Charset', 'UTF-8');
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
try {
xmlhttp.send( body );
} catch (ex) {
request.receivedCallback( request, true, ex.number+': '+ex.message );
return;
}
request.receivedCallback( request, xmlhttp.status >= 400, xmlhttp.responseText );
}
this.sending = false;
}
}
}
function gConnectionForm() {
_form = document.body.appendChild( gCreateElement( 'FORM', { method:'POST' } ) );
this.Send = function( request ) {
_form.action = request.url;
for ( var key in request.data )
_form.appendChild( gCreateElement( 'INPUT', { type:'hidden', name:key, value:request.data[key] } ) );
_form.submit();
}
}
function gKeyManager( elt ) {
var _keyList = {};
this.kl = _keyList;
this.Set = function( set, fn ) {
for ( var i = arguments.length-1; i > 1; --i ) {
var k = arguments[i], list = (_keyList[k] || (_keyList[k]=[]));
if ( set )
list.push( { t:this, f:fn } );
else
for ( var j = list.length-1; j>=0; --j )
list[j].f == fn && list.splice(j,1);
}
}
function handleKey( ev ) {
var key = ev.keyCode || ev.charCode, list = _keyList[key];
if ( list ) {
list.length && gEventHandled( ev );
for ( var j in list )
list[j] && list[j].f.call( list[j].t, key, ev.shiftKey, ev.ctrlKey, ev.altKey );
}
}
this.Finalize = function() {
gRemoveEvent( elt, g_KeyEvent, handleKey );
elt = undefined;
}
gAddEvent( elt, g_KeyEvent, handleKey );
}
gEventManager.Select = function( name, value ) {
var data = {};
data[name] = value;
this.Commit( data );
return true;
}
gEventManager.Key = function( key ) {
var data = {};
data.Key = key;
this.Commit( data );
return true;
}
gEventManager.Next = function( backward ) {
var data = {};
data.Key = backward ? 'Shift-Tab' : 'Tab';
this.Commit( data );
return true;
}
gEventManager.Focus = function( w ) {
var data = {};
data.Focus = w.id;
this.Commit( data );
return true;
}
gEventManager.Changed = function( w ) {
var data = {};
data[w.id] = w.GetValue();
this.Commit( data );
return true;
}
gEventManager.Action = function( name ) {
var data = {};
data.Action = name;
this.Commit( data );
return true;
}
gEventManager.Offset = function( value ) {
var data = {};
data.Offset = value;
this.Commit( data );
return true;
}
gEventManager.PageSize = function( value ) {
var data = {};
data.PageSize = value;
this.Commit( data );
return true;
}
gEventManager.RequestedFolderPage = function( pageId ) {
var data = {};
data.RequestedFolderPage = pageId;
this.Commit( data );
return true;
}
gEventManager.Misc = function() {
var data = {};
for ( var i = 0; i < arguments.length; i+=2 )
data[arguments[i]] = arguments[i+1];
this.Commit( data );
return true;
}
function gEventManager( connection, incremental, api, url ) {
var requestIndex = 0;
_preCommit = {};
_postCommit = {};
this.PreCommit = function() { return _preCommit };
this.PostCommit = function() { return _postCommit };
if ( api ) {
api.updateFormsAction = function( action ) {
url = action;
}
}
function OnIncrementalUpdateDone( request, error, text ) {
if ( !error )
try {
request.api.Eval( text, request );
} catch(ex) {
if ( ex ) throw ex;
return true;
}
else
document.body.innerHTML = text;
g_state.Fire('stateReady');
for ( var i in _postCommit )
_postCommit[i]() || delete _postCommit[i];
g_state.Fire('incrementalUpdateDone');
}
this.Commit = function( data ) {
var req = { data:data, url:url, api:api, receivedCallback:OnIncrementalUpdateDone };
for ( var i in _preCommit )
_preCommit[i](req) || delete _preCommit[i];
incremental && ( req.data.Incremental = 'TRUE' );
if ( !requestIndex++ && incremental )
req.data.IncrementalTemplate = api.incrementalTemplate;
connection.Send( req );
}
function KeepAliveDone( request, error, text ) {
if ( !error )
try {
request.api.Eval( text, request );
} catch(ex) {
if ( ex ) throw ex;
}
else
document.body.innerHTML = text;
}
this.KeepAlive = function() {
var req = { data:{ Key:'_keepAlive' }, url:url, api:api, receivedCallback:KeepAliveDone };
incremental && ( req.data.Incremental = 'TRUE' );
if ( !requestIndex++ && incremental )
req.data.IncrementalTemplate = api.incrementalTemplate;
connection.Send( req );
}
this.Ping = function() {
var req = { data:{ t:'' }, url:url, api:api, receivedCallback:KeepAliveDone };
incremental && ( req.data.Incremental = 'TRUE' );
if ( !requestIndex++ && incremental )
req.data.IncrementalTemplate = api.incrementalTemplate;
connection.Send( req );
}
this.CurrentPage = function() {
return url;
}
this.EventSink = function() {
return gMergeObjects( { Commit:this.Commit }, gEventManager );
}
this.Finalize = function() {
_preCommit = {};
_postCommit = {};
}
}
function gGWCEvent() {
var requestData = {};
return new function() {
this.Append = function() {
for ( var i=0; i<arguments.length; i++ )
requestData[arguments[i].key] = arguments[i].value;
return this;
}
this.Send = function() {
g_eventManager.Commit( requestData );
requestData = {};
return this;
}
}
}
function gScrollGrid( scrollGridId ) {
return new function() {
this.Offset = function( offset ) {
return { key:'Offset', value:offset };
}
}
}
function gMatrix( matrixId ) {
return new function() {
this.Select = function( localIndex ) {
return { key:matrixId, value:localIndex };
}
}
}
function gTable( tableId ) {
return new function() {
this.Select = function( localIndex ) {
return { key:tableId, value:localIndex };
}
this.Offset = function( offset ) {
return { key:'Offset', value:offset };
}
this.PageSize = function( pageSize ) {
return { key:'PageSize', value:pageSize };
}
this.Sort = function( columnName ) {
return { key:columnName, value:'' };
}
}
}
function gField( name ) {
return new function() {
this.Focus = function() {
return { key:'Focus', value:name };
}
this.Value = function( value ) {
return { key:name, value:value };
}
}
}
function gAction( actionName ) {
return { key:'Action', value:actionName };
}
function gKey( keyName, shift, ctrl, alt ) {
return { key:'Key', value:(ctrl?'CONTROL-':'') + (shift?'SHIFT-':'') + (alt?'ALT-':'') + keyName };
}
gListener.prototype.Has = function( fct ) {
for ( var i in this._list )
if ( this._list[i] == fct )
return true;
}
gListener.prototype.Add = function( fct ) {
this._list.push(fct);
}
gListener.prototype.AddOnce = function( fct ) {
for ( var i in this._list )
if ( this._list[i] == fct )
return true;
this._list.push(fct);
}
gListener.prototype.Remove = function( fct ) {
if ( fct )
for ( var i in this._list )
this._list[i] == fct && delete this._list[i];
else
delete this._list[this._s.it];
}
gListener.prototype.Cancel = function() {
this._s.cancel = true;
}
gListener.prototype.ReturnValue = function( value ) {
this._s.value = value;
}
gListener.prototype.Fire = function() {
var s = this._s, l = this._list;
for ( s.it in l ) {
l[s.it].apply( this, arguments );
if ( s.cancel ) break;
}
this._s = {};
return s;
}
function gListener() {
this._s = {};
this._list = [];
}
gList.prototype.Item = function( name ) {
return this[name] || ( this[name] = new this._class() );
}
gList.prototype.Has = function( name ) {
return name in this;
}
function gList( itemClass ) {
this._class = itemClass;
}
function gWrapperManager( wrapperClassList, groupManager ) {
var _wl = {};
var _listenUpdate = this.listenUpdate = new gList(gListener);
var _listenCreate = this.listenCreate = new gList(gListener);
this.Finalize = function() {
for ( var id in _wl ) {
_wl[id].Finalize();
for ( var p in _wl[id] ) {
_wl[id][p] = undefined;
}
}
}
this.Item = function(id) {
return _wl[id];
}
function Apply( call, data, init ) {
_listenUpdate[call] && _listenUpdate[call].Fire( this, data );
this[call] && this[call](data, init);
this.state[call] = data;
}
function Update( call, data, init ) {
this.Apply( call, data, init );
}
this.UpdateWrapper = function( id, call, data, init ) {
_wl[id].Update( call, data, init );
}
this.RemoveWrapper = function( id ) {
var w = _wl[id];
w.Finalize();
w.Remove && w.Remove();
delete _wl[id];
w.group && groupManager.RemoveWrapper( w, w.group );
}
function GetWrapperClass( elt ) {
var eltId = elt.id;
if ( eltId ) {
var wc = wrapperClassList[eltId];
if ( wc && wc.method == gBY_ELEMENT_ID )
return wc;
}
var eltName = elt.name;
if ( eltName ) {
var wc = wrapperClassList[eltName];
if ( wc && wc.method == gBY_ELEMENT_NAME )
return wc;
}
var eltClass = elt.className;
if ( eltClass ) {
var wcnl = eltClass.split(' '), wc;
for ( var n = wcnl.length-1; n >= 0; --n )
if ( wc = wrapperClassList[wcnl[n]] )
return wc;
}
}
this.CreateWrapper = function( wrapperName, id, state, group ) {
var w = { state:state||{}, info:{}, id:id, group:group, eventSink:g_eventManager.EventSink(), Update:Update, Apply:Apply, Finalize:gNoop };
wrapperClassList[wrapperName].cl( w );
_wl[id] = w;
group && groupManager.AppendWrapper( w, group );
w.Create && w.Create(id);
for ( var p in w.state )
w.Update( p, w.state[p], true );
return w;
}
this.Wrap = function( from ) {
var deferUpdate = {};
function _wrapElt( elt ) {
var wc = GetWrapperClass( elt );
if ( wc ) {
var id = wc.idFn(elt);
if ( !id ) return;
var w = _wl[id];
if ( !w ) {
w = { info:{}, id:id, group:wc.group, eventSink:g_eventManager.EventSink(), Update:Update, Apply:Apply, Finalize:gNoop };
wc.cl && wc.cl( w );
var state = {};
wc.init && wc.init( w, elt, state );
w.state = state;
w.AppendElement && w.AppendElement( elt );
_wl[id] = w;
wc.group && groupManager.AppendWrapper( w, wc.group );
_listenCreate[id] && _listenCreate[id].Fire( w );
} else {
wc.init && wc.init( w, elt, w.state );
w.AppendElement && w.AppendElement( elt );
}
deferUpdate[id] = w;
}
}
var eltList = gAllElementsFrom( from );
var len = eltList.length;
var tmp = {};
for ( var i = 0; i < len; ++i )
tmp[i] = eltList[i];
eltList = tmp;
_wrapElt( from );
for ( var i = 0; i < len; ++i )
_wrapElt( eltList[i] );
eltList = undefined;
g_state.Fire('afterWrap');
for ( var id in deferUpdate ) {
var w = deferUpdate[id];
for ( var p in w.state )
w.Update( p, w.state[p], true );
}
}
this.UnWrap = function( from ) {
function _unWrapElt( elt ) {
var wc = GetWrapperClass( elt );
if ( wc ) {
var id = wc.idFn(elt);
if ( !id ) return;
var w = _wl[id];
w.RemoveElement && w.RemoveElement( elt ) && ( delete _wl[id] );
}
}
var eltList = gAllElementsFrom( from );
var len = eltList.length;
var tmp = {};
for ( var i = 0; i < len; ++i )
tmp[i] = eltList[i];
eltList = tmp;
_unWrapElt( from );
for ( var i = 0; i < len; ++i )
_unWrapElt( eltList[i] );
eltList = undefined;
}
}
function gState() {
var _stateListeners = new gList(gListener);
this.Add = function( name, fct ) {
_stateListeners.Item(name).Add(fct);
}
this.Remove = function( name, fct ) {
_stateListeners.Item(name).Remove(fct);
}
this.Fire = function( name ) {
return _stateListeners[name] && _stateListeners[name].Fire();
}
}
var gDYN_CREATE = 0;
var gBY_ELEMENT_CLASS = 1;
var gBY_ELEMENT_ID = 2;
var gBY_ELEMENT_NAME = 3;
var g_registeredWrapperList = {};
function gRegisterWrapper( wrapperClass, method, name, idFn, initFn, group ) {
g_registeredWrapperList[name] = { cl:wrapperClass, method:method, idFn:idFn, init:initFn, group:group };
}
function gGroupManager( registredGroupList ) {
var _gl = {};
this.Item = function( groupName ) {
return (_gl[groupName] || ( registredGroupList[groupName] && (_gl[groupName] = new registredGroupList[groupName](this))));
}
this.AppendWrapper = function( w, groupName ) {
var gm = this.Item(groupName);
gm && gm.AppendWrapper( w );
}
this.RemoveWrapper = function( w, groupName ) {
var gm = this.Item(groupName);
gm && gm.RemoveWrapper( w );
}
}
var g_registredGroupList = [];
function gRegisterGroup( groupClass, groupName ) {
g_registredGroupList[groupName] = groupClass;
}
var g_dialog;
function gIncrementalAPI( wrapperManager, groupManager ) {
//var _focusHasChanged;
var _hasNewApplication;
wrapperManager.listenUpdate.Item('currentField').Add( function( w, set ) { if (set) _focusHasChanged = true; } );
this.Eval = function( code, request ) {
_hasNewApplication = false;
eval( code );
//if ( gCurrentField.w && 'Focus' in request.data && !_focusHasChanged ) {
if ( gCurrentField.w && !_hasNewApplication ) {
gCurrentField.w.Focus();
}
}
this.incrementalTemplate = 'with(this){$(gui.incrementalInstructions)}';
this.setProperty = function( wid, prop, value ) { wrapperManager.UpdateWrapper( wid, prop, value || true ); }
this.unsetProperty = function( wid, prop ) { wrapperManager.UpdateWrapper( wid, prop, undefined ); }
this.setStyle = function( wid, data ) { wrapperManager.UpdateWrapper(wid, 'setStyle', data); }
this.unsetStyle = function( wid, data ) { wrapperManager.UpdateWrapper(wid, 'unsetStyle', data); }
this.setValue = function( wid, data ) { wrapperManager.UpdateWrapper(wid, 'value', data); }
this.setCurrentField = function( name ) { gCurrentField.Set(wrapperManager.Item(name)); }
this.unsetCurrentField = function() { gCurrentField.Unset(); }
this.enableField = function( name ) { wrapperManager.UpdateWrapper(name, 'enable', true ); }
this.disableField = function( name ) { wrapperManager.UpdateWrapper(name, 'enable', false ); }
this.enableAction = function( name ) { wrapperManager.UpdateWrapper( 'action_' + name, 'enable', true ); }
this.disableAction = function( name ) { wrapperManager.UpdateWrapper( 'action_' + name, 'enable', false ); }
this.setCurrentAction = function( name ) { groupManager.Item('action').SetCurrentAction(wrapperManager.Item('action_' + name)); }
this.unsetCurrentAction = function() { groupManager.Item('action').UnsetCurrentAction(); }
this.enableScroll = function( id ) { wrapperManager.UpdateWrapper(id, 'enabledScroll', true ); }
this.disableScroll = function( id ) { wrapperManager.UpdateWrapper(id, 'enabledScroll', false ); }
this.setOffset = function( id, data ) { wrapperManager.UpdateWrapper(id, 'offset', data ); }
this.setSize = function( id, data ) { wrapperManager.UpdateWrapper(id, 'size', data ); }
this.setPageSize = function( id, data ) { wrapperManager.UpdateWrapper(id, 'pageSize', data ); }
this.enableRowSelection = function( id ) { wrapperManager.UpdateWrapper(id, 'enabledSelection', true ); }
this.disableRowSelection = function( id ) { wrapperManager.UpdateWrapper(id, 'enabledSelection', false ); }
this.setCurrentRow = function( id, row ) { wrapperManager.UpdateWrapper(id, 'currentRow', row ); }
this.unsetCurrentRow = function( id ) { wrapperManager.UpdateWrapper(id, 'currentRow', undefined ); }
this.sortedColumn = function( name, data ) { wrapperManager.UpdateWrapper(name, 'sorted', data ); }
this.unsortedColumn = function( name ) { wrapperManager.UpdateWrapper(name, 'sorted', undefined ); }
this.enableSort = function( name ) { wrapperManager.UpdateWrapper(name, 'enable', true ); }
this.disableSort = function( name ) { wrapperManager.UpdateWrapper(name, 'enable', false ); }
this.setActiveCellCount = function( name, activeCellCount ) { wrapperManager.UpdateWrapper(name, 'activeCellCount', activeCellCount ); }
this.setCurrentCell = function( name, cell ) { wrapperManager.UpdateWrapper(name, 'currentCell', cell ); }
this.unsetCurrentCell = function( name ) { wrapperManager.UpdateWrapper(name, 'currentCell', undefined ); }
this.addIdle = function( delay ) {
wrapperManager.CreateWrapper( 'gIdleAction', 'Idle', { delay:delay } );
}
this.setIdle = function( delay ) {
wrapperManager.UpdateWrapper( 'Idle', 'delay', delay );
}
this.removeIdle = function() {
wrapperManager.RemoveWrapper( 'Idle' );
}
this.newWindow = function( url ) {
var win = gModalWindow( window, url );
gOnClose( win, function() { g_eventManager.Commit( { CloseWindow:'true' } ); } );
}
this.closeWindow = function() {
window.close();
}
function beforeReloadPage_pannel() {
g_dialog.onExit = undefined;
wrapperManager.UnWrap( g_dialog.document.body.firstChild );
g_dialog.close();
this.Remove();
}
this.addActionPanel = function( html, style ) {
if ( style == 'Dialog' ) {
var win = gModalWindow( window, '', 400, 100 );
g_state.Add( 'beforeReloadPage', beforeReloadPage_pannel );
win.onExit = function() {
g_eventManager.Commit( { Action:'close' } );
}
var ss = window.document.styleSheets;
for ( var i=0; i<ss.length; i++ ) {
var href = ss.item(i).href;
if ( href.substr( href.length-4 ) == '.css' )
gAddCssFile( win, href  );
}
var elt = win.document.body.appendChild( gHtmlToElement( html, win ) );
wrapperManager.Wrap( elt );
g_dialog = win;
} else {
wrapperManager.Wrap( (gIdToElement('gPanel')||gIdToElement('gDialogForm')).appendChild( gHtmlToElement( html ) ) );
}
}
this.removeActionPanel = function( style ) {
if ( style == 'Dialog' ) {
g_state.Remove( 'beforeReloadPage', beforeReloadPage_pannel );
g_dialog.onExit = undefined;
wrapperManager.UnWrap( g_dialog.document.body.firstChild );
g_dialog.close();
} else {
wrapperManager.UnWrap( gFirstChild(gIdToElement('gPanel')) );
gRemoveElement( gFirstChild(gIdToElement('gPanel')) );
}
}
this.addMessage = function( type, text ) {
wrapperManager.CreateWrapper( type, type, { text:text } );
}
this.setMessage = function( type, text ) {
wrapperManager.UpdateWrapper( type, 'text', text );
}
this.removeMessage = function( type ) {
wrapperManager.RemoveWrapper( type );
}
this.setCurrentFolderPage = function( id, pageId ) { wrapperManager.UpdateWrapper(id, 'currentPage', pageId ); }
this.setFolderPageContent = function( id, pageId, html, layoutData ) {
var tmp = gCreateElement( 'DIV', { style:{ visibility:'hidden', position:'absolute' } } );
document.body.appendChild( tmp );
wrapperManager.Wrap( tmp.appendChild( gHtmlToElement( html ) ) )
Layout( layoutData );
gIdToElement(pageId).appendChild( gFirstChild(tmp) );
gLazyRemove( tmp );
}
this.updateFormsAction = gNoop;
this.reloadPage = function() {
g_state.Fire('beforeReloadPage');
document.location.replace( g_eventManager.CurrentPage() );
throw(undefined);
}
this.processing = function() {
if ( gConfiguration.refreshPageMethodAfterNewApplication == gFULL_MODE ) {
new gConnectionForm().Send( { data:{t:''}, url:g_eventManager.CurrentPage() } );
} else
g_eventManager.Commit( { t:'' } );
}
this.newApplication = function( url ) {
_hasNewApplication = true;
var w = wrapperManager.Item( 'newApplication' ) || wrapperManager.CreateWrapper( 'newApplication', 'newApplication' );
w.Update( 'url', url );
}
}
function Space( col, s, e ) {
for ( var size = 0; s < e; s++ )
size += col[s] || (col[s] = 5);
return size;
}
function LayoutGrid( elt, g ) {
gSetClass( elt, 'gFill', false );
var col = {};
for ( var i in g ) {
var gi = g[i];
var e = gIdToElement(gi[0]);
gi.es = e.style;
var p = e.offsetWidth;
var gi4 = gi[4];
if ( gi4 ) {
var sp = 0;
for ( var h in gi4 )
sp += gi4[h]?0:1;
gi.sp = sp;
p += (gi4.length - sp - 1 ) * 5;
gi.ow = p;
}
var s = Space( col, gi[2], gi[3] );
if ( p > s )
col[gi[3]-1] += p-s;
}
for ( var i in g ) {
var gi = g[i];
var es = gi.es;
var ml = Space( col, gi[1], gi[2] );
ml && ( es.marginLeft = ml );
var width = Space( col, gi[2], gi[3] );
es.width = width;
var gi4 = gi[4];
if ( gi4 ) {
var spw = Math.floor( (width - gi.ow) / gi.sp );
var remainder = (width - gi.ow) % gi.sp;
for ( var h = gi4.length; h > 0; --h )
if ( gi4[h] )
gIdToElement( gi4[h] ).style.marginLeft = gi4[h-1]? 5 : spw + (h>1?5:0) + (remainder-->0?1:0);
}
}
gSetClass( elt, 'gFill', true );
}
function Layout( layoutData ) {
for ( var g in layoutData )
LayoutGrid( gIdToElement(g), layoutData[g] );
}
function gInitFieldMode( form, outgoing, incoming, keepAliveInterval ) {
gAddEvent( form, 'submit', gEventHandled );
form.setAttribute( 'autocomplete', 'off' );
g_state = new gState();
g_keyManager = new gKeyManager( document );
g_groupManager = new gGroupManager( g_registredGroupList );
g_wrapperManager = new gWrapperManager( g_registeredWrapperList, g_groupManager );
g_IsIe && g_keyManager.Set( true, gNoop, 27 );
if ( g_IsIe ) {
function Finalize() {
if ( typeof(_calendar) != 'undefined' )
_calendar.Finalize();
gRemoveEvents( form );
g_keyManager.Finalize();
g_wrapperManager.Finalize();
g_eventManager.Finalize();
gRemoveEvent( window, 'unload', Finalize );
}
gAddEvent( window, 'unload', Finalize );
}
connection = incoming == gINCREMENTAL_MODE ? new gConnectionSyncQueue() : new gConnectionForm();
var incrementalApi;
if ( incoming == gINCREMENTAL_MODE )
incrementalApi = new gIncrementalAPI( g_wrapperManager, g_groupManager );
g_eventManager = new gEventManager( connection, incoming == gINCREMENTAL_MODE, incrementalApi, form.getAttribute('action') );
if ( outgoing == gSMART_FIELD_MODE ) {
gRegisterGroup( gSmartFieldManager, 'field' );
gRegisterGroup( gSmartTableManager, 'table' );
} else {
gRegisterGroup( gFieldManager, 'field' );
gRegisterGroup( gTableManager, 'table' );
}
g_wrapperManager.Wrap( form );
if ( keepAliveInterval ) {
var keepAliveTimeout;
function KeepAlive() {
var timeCorrection = 0;
if ( g_InitTime ) {
timeCorrection = (new Date()).getTime() - g_InitTime;
g_InitTime = 0;
}
keepAliveTimeout && gClearTimeout(keepAliveTimeout);
keepAliveTimeout = gSetTimeout( function() { g_eventManager.KeepAlive(); KeepAlive() }, keepAliveInterval * 1000 - timeCorrection );
return true;
}
KeepAlive();
g_eventManager.PreCommit().avoidKeepAlive = function() {
if ( keepAliveTimeout ) {
gClearTimeout( keepAliveTimeout );
keepAliveTimeout = undefined;
}
return true;
}
g_eventManager.PostCommit().startKeepAlive = KeepAlive;
}
if ( typeof(gLayoutData) == 'object' ) {
var ri1 = gAppendCssRule( g_styleSheet, '.gFolder .gPage', 'display:block' );
Layout( gLayoutData );
gRemoveCssRule( g_styleSheet, ri1 );
}
g_state.Fire('stateReady');
}
