You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/03/11 21:43:40 UTC

svn commit: r385159 [2/2] - in /incubator/tobago/trunk: tobago-core/ tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/t...

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js?rev=385159&r1=385158&r2=385159&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js Sat Mar 11 12:43:36 2006
@@ -17,63 +17,74 @@
 
 var LOG = new Object();
 Object.extend(LOG, {
-    IdBase: "TbgLog",
-    messages: new Array(),
-    appenders: new Array(),
-    DEBUG: 1,
-    INFO:  2,
-    WARN:  3,
-    ERROR: 4,
-
-    show: function() {
-      for (var i = 0 ; i < this.appenders.length; i++) {
-        var appender = this.appenders[i];
-        if (appender.show) {
-          appender.show();
-        }
+  IdBase: "TbgLog",
+  messages: new Array(),
+  appenders: new Array(),
+  DEBUG: 1,
+  INFO:  2,
+  WARN:  3,
+  ERROR: 4,
+
+  show: function() {
+    for (var i = 0 ; i < this.appenders.length; i++) {
+      var appender = this.appenders[i];
+      if (appender.show) {
+        appender.show();
       }
-    },
+    }
+  },
 
-    addAppender: function(appender) {
-      this.appenders.push(appender);
-    },
-
-    addMessage: function(msg) {
-      this.messages.push(msg);
-      for (var i = 0 ; i < this.appenders.length; i++) {
-        var appender = this.appenders[i];
-        if (appender.append
-            && typeof(msg.type) == "number"
-            && appender.logFor(msg.type)) {
-          appender.append(msg);
-        }
+  addAppender: function(appender) {
+    this.appenders.push(appender);
+  },
+
+  addMessage: function(msg) {
+    this.messages.push(msg);
+    for (var i = 0 ; i < this.appenders.length; i++) {
+      var appender = this.appenders[i];
+      if (appender.append
+          && typeof(msg.type) == "number"
+          && appender.logFor(msg.type)) {
+        appender.append(msg);
       }
-    },
+    }
+  },
 
-    debug: function(text) {
-      this.addMessage(new LOG.LogMessage(LOG.DEBUG, text));
-    },
-
-    info  : function(text) {
-      this.addMessage(new LOG.LogMessage(LOG.INFO, text));
-    },
-
-    warn: function(text) {
-      this.addMessage(new LOG.LogMessage(LOG.WARN, text));
-    },
-
-    error: function(text) {
-      this.addMessage(new LOG.LogMessage(LOG.ERROR, text));
-    },
-
-    bindOnWindow: function() {
-      window.onerror = this.windowError.bind(this);
-    },
-
-    windowError: function(msg, url, line){
-		  var message = "Error in (" + (url || window.location) + ") on line "+ line +" with message (" + msg + ")";
-		  this.error(message);	
+  debug: function(text) {
+    this.addMessage(new LOG.LogMessage(LOG.DEBUG, text));
+  },
+
+  info  : function(text) {
+    this.addMessage(new LOG.LogMessage(LOG.INFO, text));
+  },
+
+  warn: function(text) {
+    this.addMessage(new LOG.LogMessage(LOG.WARN, text));
+  },
+
+  error: function(text) {
+    this.show();
+    this.addMessage(new LOG.LogMessage(LOG.ERROR, text));
+  },
+
+  bindOnWindow: function() {
+    window.onerror = this.windowError.bind(this);
+  },
+
+  windowError: function(msg, url, line){
+    var message = "Error in (" + (url || window.location) + ") on line "+ line +" with message (" + msg + ")";
+    this.error(message);
+  },
+
+  listScriptFiles: function() {
+    var children = document.getElementsByTagName('head')[0].childNodes;
+    for (var i = 0; i < children.length; i++) {
+      var child = children[i];
+      if (child.tagName.toUpperCase() == "SCRIPT"){
+        this.debug("script.src=" + child.src);
+      }
     }
+  }
 });
 LOG.bindOnWindow();
 
@@ -97,7 +108,7 @@
 
     this.options = options;
 
-    if ($(LOG.IdBase)) {
+    if (Tobago.element(LOG.IdBase)) {
       return;
     }
 
@@ -178,7 +189,7 @@
     this.logList.id = "Log";
     this.scrollElement.appendChild(this.logList);
 
-    this.handle       = options.handle ? $(options.handle) : this.element;
+    this.handle       = options.handle ? Tobago.element(options.handle) : this.element;
 
     Element.makePositioned(this.element); // fix IE
 

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js?rev=385159&r1=385158&r2=385159&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js Sat Mar 11 12:43:36 2006
@@ -19,8 +19,8 @@
   initialize: function(tabGroupId, activeIndex, page) {
     this.tabGroupId = tabGroupId,
     this.activeIndex = activeIndex;
-    this.element = $(tabGroupId + '.' + activeIndex);
-    this.page = $(page);
+    this.element = Tobago.element(tabGroupId + '.' + activeIndex);
+    this.page = Tobago.element(page);
 
     this.options = {
       method: 'post',
@@ -37,14 +37,14 @@
   setUp: function() {
 //    LOG.debug("setup tabgroup " + this.element.id);
     var i = 0;
-    var idPrefix = this.element.id + getSubComponentSeparator();
-    var anchor = $(idPrefix + i++);
+    var idPrefix = this.element.id + Tobago.SUB_COMPONENT_SEP;
+    var anchor = Tobago.element(idPrefix + i++);
     while (anchor) {
 //      LOG.debug("observe tab " + anchor.id);
 //      if (i != this.activeIndex) {
         Event.observe(anchor, "click", this.reload.bindAsEventListener(this));
 //      }
-      anchor = $(idPrefix + i++);
+      anchor = Tobago.element(idPrefix + i++);
     }
 
   },
@@ -52,15 +52,15 @@
   reload: function(event) {
     if (event) {
       var aId = Event.findElement(event, 'A').id;
-      this.activeIndex = aId.substring(aId.lastIndexOf(getSubComponentSeparator()) + getSubComponentSeparator().length);
+      this.activeIndex = aId.substring(aId.lastIndexOf(Tobago.SUB_COMPONENT_SEP) + Tobago.SUB_COMPONENT_SEP.length);
       LOG.debug("Request tab with index " + this.activeIndex);
 
-      var hidden = $(this.tabGroupId + getSubComponentSeparator() + "activeIndex");
+      var hidden = Tobago.element(this.tabGroupId + Tobago.SUB_COMPONENT_SEP + "activeIndex");
       if (hidden) {
         hidden.value = this.activeIndex;
       }
       else {
-        LOG.warn("No hidden field for tabindex Id='" + this.tabGroupId + getSubComponentSeparator() + "activeIndex" + "'");
+        LOG.warn("No hidden field for tabindex Id='" + this.tabGroupId + Tobago.SUB_COMPONENT_SEP + "activeIndex" + "'");
         LOG.warn("aId = " + aId);
       }
 

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js?rev=385159&r1=385158&r2=385159&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-menu.js Sat Mar 11 12:43:36 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2005 atanion GmbH.
+ *    Copyright 2002-2005 The Apache Software Foundation.
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=385159&r1=385158&r2=385159&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Sat Mar 11 12:43:36 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2005 atanion GmbH.
+ *    Copyright 2002-2005 The Apache Software Foundation.
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
 Tobago.SheetBase = {
   initialize: function(sheetId, page) {
     this.sheetId = sheetId,
-    this.element = $(sheetId + "_outer_div");
-    this.page = $(page);
+    this.element = Tobago.element(sheetId + "_outer_div");
+    this.page = Tobago.element(page);
 
     this.options = {
       method: 'post',
@@ -34,15 +34,14 @@
     LOG.debug("New Sheet with id " + this.sheetId);
   },
 
-  sortOnclickRegExp :
-      new RegExp("submitAction\\(('|\")(.*?)('|\") *, *('|\")(.*?)('|\")\\)"),
+  sortOnclickRegExp : new RegExp("Tobago.submitAction\\(('|\")(.*?)('|\")\\)"),
 
   setup: function() {
 
     // setup sorting headers
     var i = 0;
     var idPrefix = this.sheetId + "_header_box_";
-    var headerBox = $(idPrefix + i++);
+    var headerBox = Tobago.element(idPrefix + i++);
     while (headerBox) {
       if (headerBox.onclick) {
         var match = this.sortOnclickRegExp.exec(headerBox.onclick.valueOf());
@@ -51,19 +50,19 @@
 //        LOG.debug("*match[2] = " + match[2]);
 //        LOG.debug("match[3] = " + match[3]);
 //        LOG.debug("match[4] = " + match[4]);
-//        LOG.debug("*match[5] = " + match[5]);
+//        LOG.debug("match[5] = " + match[5]);
 //        LOG.debug("match[6] = " + match[6]);
 //        headerBox.formId = match[2];
-        headerBox.sorterId = match[5];
+        headerBox.sorterId = match[2];
         headerBox.onclick = null;
 //        LOG.debug("headerBox.id = " + headerBox.id);
         Event.observe(headerBox, "click", this.doSort.bindAsEventListener(this));
       }
-      headerBox = $(idPrefix + i++);
+      headerBox = Tobago.element(idPrefix + i++);
     }
 
     // setup paging links
-    var linkBox = $(this.sheetId + Tobago.subComponentSeparator + "pagingLinks");
+    var linkBox = Tobago.element(this.sheetId + Tobago.SUB_COMPONENT_SEP + "pagingLinks");
     if (linkBox) {
       for (i = 0 ; i < linkBox.childNodes.length ; i++) {
         var child = linkBox.childNodes[i];
@@ -75,7 +74,7 @@
     }
 
     // setup paging pages
-    linkBox = $(this.sheetId + Tobago.subComponentSeparator + "pagingPages");
+    linkBox = Tobago.element(this.sheetId + Tobago.SUB_COMPONENT_SEP + "pagingPages");
     if (linkBox) {
       for (i = 0 ; i < linkBox.childNodes.length ; i++) {
         var child = linkBox.childNodes[i];
@@ -98,7 +97,7 @@
 
 
     // setup row paging
-    var rowText = $(this.sheetId + Tobago.componentSeparator + "ToRow" + Tobago.subComponentSeparator + "text");
+    var rowText = Tobago.element(this.sheetId + Tobago.COMPONENT_SEP + "ToRow" + Tobago.SUB_COMPONENT_SEP + "text");
     if (rowText) {
       var parent = rowText.parentNode;
 //      LOG.debug("row : onclick =" + parent.onclick);
@@ -121,14 +120,14 @@
 
   doPagingDirect: function(event) {
     var element = Event.element(event);
-    var action = this.sheetId + Tobago.componentSeparator + "ToPage";
+    var action = this.sheetId + Tobago.COMPONENT_SEP + "ToPage";
 
     var page = element.id.lastIndexOf('_');
     page = element.id.substring(page + 1);
     var hidden = document.createElement('input');
     hidden.type = 'hidden';
     hidden.value = page;
-    hidden.name = action + Tobago.subComponentSeparator +  "value";
+    hidden.name = action + Tobago.SUB_COMPONENT_SEP +  "value";
     this.element.appendChild(hidden);
 
     this.reloadWithAction(action);
@@ -137,15 +136,15 @@
   doPaging: function(event) {
     var element = Event.element(event);
     var action = "unset";
-    // TODO: replace '::' in regexp by Tobago.subComponentSeparator
+    // TODO: replace '::' in regexp by Tobago.SUB_COMPONENT_SEP
     if (element.id.match(/::pagingPages::First$/)){
-      action = this.sheetId + Tobago.componentSeparator +"First";
+      action = this.sheetId + Tobago.COMPONENT_SEP +"First";
     } else if (element.id.match(/::pagingPages::Prev$/)){
-      action = this.sheetId + Tobago.componentSeparator +"Prev";
+      action = this.sheetId + Tobago.COMPONENT_SEP +"Prev";
     } else if (element.id.match(/::pagingPages::Next$/)){
-      action = this.sheetId + Tobago.componentSeparator +"Next";
+      action = this.sheetId + Tobago.COMPONENT_SEP +"Next";
     } else if (element.id.match(/::pagingPages::Last$/)){
-      action = this.sheetId + Tobago.componentSeparator +"Last";
+      action = this.sheetId + Tobago.COMPONENT_SEP +"Last";
     }
     this.reloadWithAction(action);
   },
@@ -157,22 +156,22 @@
   },
 
   insertPageTarget: function() {
-    this.insertTarget(this.sheetId + Tobago.componentSeparator + "ToPage");
+    this.insertTarget(this.sheetId + Tobago.COMPONENT_SEP + "ToPage");
   },
 
   insertRowTarget: function() {
-    this.insertTarget(this.sheetId + Tobago.componentSeparator + "ToRow");
+    this.insertTarget(this.sheetId + Tobago.COMPONENT_SEP + "ToRow");
   },
 
   insertTarget: function(actionId) {
 //    LOG.debug("insertTarget('" + actionId + "')")
-    var textId = actionId + Tobago.subComponentSeparator + "text";
-    var text = $(textId);
+    var textId = actionId + Tobago.SUB_COMPONENT_SEP + "text";
+    var text = Tobago.element(textId);
     if (text) {
       var span = text.parentNode;
-      var hiddenId = actionId + getSubComponentSeparator() +  "value";
+      var hiddenId = actionId + Tobago.SUB_COMPONENT_SEP +  "value";
       span.style.cursor = 'auto';
-      var input = $(hiddenId);
+      var input = Tobago.element(hiddenId);
       if (! input) {
         input = document.createElement('input');
         input.type='text';

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=385159&r1=385158&r2=385159&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Sat Mar 11 12:43:36 2006
@@ -17,37 +17,218 @@
 var Tobago = new Object();
 Object.extend(Tobago, {
 
+  // -------- Constants -------------------------------------------------------
+
+   /**
+    * Component separator constant
+    */
+  COMPONENT_SEP: ":",
+
+   /**
+    * Tobagos subComponent separator constant
+    */
+  SUB_COMPONENT_SEP: "::",
+
+  /**
+    *  regexp to find non valid javascript name characters in scriptIds
+    */
   scriptIdRegExp: new RegExp("[/.-]", 'g'),
 
-  componentSeparator: ":",
 
-  subComponentSeparator: "::",  
+  // -------- Variables -------------------------------------------------------
 
+   /**
+    * the html body object of current page.
+    * set via init fuction (onload attribute of body)
+    */
+  page: null,
+
+   /**
+    * The html form object of current page.
+    * set via init fuction (onload attribute of body)
+    */
+  form: null,
+
+   /**
+    * The hidden html input object for submitted actionId.
+    * set via init fuction (onload attribute of body)
+    */
+  action: null,
+
+   /**
+    * The id ot the element which should became the focus after loading.
+    * Set via renderer if requested.
+    */
+  focusId: null,
+
+  images: {},
+
+  imageSources: new Array(),
+
+   /**
+    * Object to store already loaded scriptfiles.
+    * to prevent multiple loading via ajax requests.
+    */
   registeredScripts: {},
 
+   /**
+    * Array to queue ScriptLoaders.
+    */
   scriptLoaders: new Array(),
 
+   /**
+    * Flag indicating that the page is complete loaded.
+    */
+  pageIsComplete: false,
+
+   /**
+    * Flag indicating that currently a scriptLoader is running.
+    */
+  scriptLoadingActive: false,
+
+
+  // TODO mv configuration items to Tobago.Config object
+
+   /**
+    * 2 * borderWidth of popup content div
+    * TODO check correctness for different themes
+    */
+  popupBorderWidth: 4,
+
+   /**
+    * scrollbar witdh, may be browser specific
+    */
+  scrollbarWidth: 15,
+
+  // -------- Functions -------------------------------------------------------
+
+
+  /**
+   * Tobagos central init function.
+   * Called via onload attribure of body tag
+   */
+  init: function(pageId) {
+//    new LOG.LogArea({hide: false});
+//    LOG.show();
+    this.page = this.element(pageId);
+    this.form = this.element(this.page.id + this.SUB_COMPONENT_SEP + "form");
+    this.action = this.element(this.form.id + '-action')
+    this.clientDimension
+        = this.createInput("hidden", this.form.id + '-clientDimension');
+    this.form.appendChild(this.clientDimension);
+
+    this.applicationOnload();
+
+    this.setFocus();
+
+    this.pageIsComplete = true;
+    this.registerCurrentScripts();
+    this.startScriptLoaders();
+  },
+
+   /**
+    * return true if page loading is complete.
+    */
+  isPageComplete: function(){
+    return this.pageIsComplete;
+  },
+
+
+   /**
+    * Submitting the page with specified actionId.
+    */
+  submitAction: function(actionId) {
+    this.setAction(actionId);
+    // todo: why this doesn't work?  document.body.onunload = onunloadScript;
+    window.onunload = onunloadScript;
+    if (this.form) {
+      this.form.submit();
+    }
+  },
+
+   /**
+    * Set the actionId and clientDimension
+    */
+  setAction: function(actionId) {
+    this.action.value = actionId;
+    this.clientDimension.value
+        = document.body.clientWidth + ";" + document.body.clientHeight;
+  },
+
+   /**
+    * Submit the page with specified actionId and position data for popup.
+    */
+  openPickerPopup: function(event, actionId, hiddenId) {
+    var hidden = this.element(hiddenId);
+    if (hidden) {
+      // calculate position of command and size of window
+      hidden.value = this.getBrowserInnerWidth() + "x" + this.getBrowserInnerHeight();
+      if (event) {
+        hidden.value = hidden.value + ":" + event.clientX + "x" + event.clientY;
+      }
+    }
+    this.submitAction(actionId);
+  },
+
+   /**
+    * remove the popup elements from dom tree.
+    */
+  closePickerPopup: function(popupId) {
+    var popup = this.element(popupId);
+    if (popup) {
+      popup.parentNode.removeChild(popup);
+    }
+    popup = this.element(popupId + Tobago.SUB_COMPONENT_SEP + "content");
+    if (popup) {
+      popup.parentNode.removeChild(popup);
+    }
+    popup = this.element(popupId + Tobago.SUB_COMPONENT_SEP + "iframe");
+    if (popup) {
+      popup.parentNode.removeChild(popup);
+    }
+  },
+
+   /**
+    * Reset the form element.
+    */
+  resetForm: function() {
+    this.form.reset();
+  },
+
+   /**
+    * Load a specified url into client
+    */
+  navigateToUrl: function(toUrl) {
+    document.location.href = toUrl;
+  },
+
+   /**
+    * Register a script file to prevent multiple loadings via ajax.
+    */
   registerScript: function(scriptId) {
     LOG.info("register :" + scriptId);
     this.registeredScripts[this.genScriptId(scriptId)] = true;
   },
 
+   /**
+    * Check i a script is already registered.
+    */
   hasScript: function(scriptId) {
     return this.registeredScripts[this.genScriptId(scriptId)];
   },
 
+   /**
+    * Generate a id usable as javascript name.
+    */
   genScriptId: function(script) {
     script = script.substring(script.indexOf("/html/"));
     return script.replace(this.scriptIdRegExp, '_');
   },
 
-  findAnchestorWithTagName: function(element, tagName) {
-    while (element.parentNode && (!element.tagName ||
-        (element.tagName.toUpperCase() != tagName.toUpperCase())))
-      element = element.parentNode;
-    return element;
-  },
-
+   /**
+    * Check if a style file is already loaded, to prevent multiple loadings
+    * from ajax requests.
+    */
   styleFileLoaded: function(name) {
     var children = document.getElementsByTagName('head')[0].childNodes;
     for (var i = 0; i < children.length; i++) {
@@ -63,6 +244,9 @@
     return false;
   },
 
+   /**
+    * Ensure that a style file is loaded.
+    */
   ensureStyleFile: function(name) {
     if (!this.styleFileLoaded(name)) {
       var style = document.createElement('link');
@@ -74,27 +258,31 @@
     }
   },
 
+   /**
+    * Ensure that a array of style files are loaded.
+    */
   ensureStyleFiles: function(names) {
     for (var i = 0; i < names.length; i++) {
       this.ensureStyleFile(names[i]);
     }
   },
 
-  pageIsComplete: false,
-
-  pageComplete: function() {
-    LOG.debug("PageComplete");
-    this.pageIsComplete = true;
-    this.registerCurrentScripts();
-    this.startScriptLoaders();
-  },
-
-  isPageComplete: function(){
-    return this.pageIsComplete;
+   /**
+    * Register all already loaded script files.
+    */
+  registerCurrentScripts: function() {
+    var children = document.getElementsByTagName('head')[0].childNodes;
+    for (var i = 0; i < children.length; i++) {
+      var child = children[i];
+      if (child.nodeType == 1 && child.tagName.toUpperCase() == "SCRIPT"){
+        Tobago.registerScript(child.src);
+      }
+    }
   },
 
-  scriptLoadingActive: false,
-
+   /**
+    * Add a scriptLoader to the queue or start it direct.
+    */
   addScriptLoader: function(scriptLoader) {
     if (! this.pageIsComplete || this.scriptLoadingActive) {
 //      LOG.debug("add one scriptLoader");
@@ -106,16 +294,9 @@
     }
   },
 
-  registerCurrentScripts: function() {
-    var children = document.getElementsByTagName('head')[0].childNodes;
-    for (var i = 0; i < children.length; i++) {
-      var child = children[i];
-      if (child.nodeType == 1 && child.tagName.toUpperCase() == "SCRIPT"){
-        Tobago.registerScript(child.src);
-      }
-    }
-  },
-
+   /**
+    * Start script loaders from queue
+    */
   startScriptLoaders: function() {
 //    LOG.debug("start 1 of " + this.scriptLoaders.length + " Loaders");
     if (this.scriptLoaders.length > 0) {
@@ -126,21 +307,327 @@
     }
   },
 
-  listScriptFiles: function() {
-    var children = document.getElementsByTagName('head')[0].childNodes;
-    for (var i = 0; i < children.length; i++) {
-      var child = children[i];
-      if (child.tagName.toUpperCase() == "SCRIPT"){
-        LOG.debug("script.src=" + child.src);
+
+   /**
+    * Register a imageSource.
+    */
+  addImageSources: function(id, normal, disabled, hover) {
+    var sources = new Array(4);
+    sources[0] = id;
+    sources[1] = normal;
+    sources[2] = disabled;
+    sources[3] = hover;
+    this.imageSources[this.imageSources.length] = sources;
+    //LOG.debug("here are " + tobagoImageSources.length + " images");
+  },
+
+   /**
+    * Return the imageSource for given id.
+    */
+  getImageSources: function(id) {
+    for (var i = 0; i < this.imageSources.length ; i++) {
+      if (this.imageSources[i][0] == id) {
+        return this.imageSources[i];
+      }
+    }
+  },
+
+   /**
+    * Mouseover function for images.
+    */
+  imageMouseover: function(id) {
+    var image = this.element(id);
+    var sourcen = this.getImageSources(id);
+    if (sourcen && sourcen[3] != 'null' && sourcen[3] != image.src) {
+      image.src = sourcen[3];
+    }
+  },
+
+   /**
+    * Mouseout function for images.
+    */
+  imageMouseout: function(id) {
+    var image = this.element(id);
+    var sourcen = this.getImageSources(id);
+    if (sourcen && sourcen[1] != 'null' && sourcen[1] != image.src) {
+      image.src = sourcen[1];
+    }
+  },
+
+   /**
+    * Mouseover function for toolbar buttons.
+    */
+  toolbarMousesover: function(element, className, imageId) {
+    this.addCssClass(element, className);
+    this.imageMouseover(imageId);
+  },
+
+   /**
+    * Mouseout function for toolbar buttons.
+    */
+  toolbarMousesout: function(element, className, imageId) {
+    this.removeCssClass(element, className);
+    this.imageMouseout(imageId);
+  },
+
+   /**
+    * Focus function for toolbar buttons.
+    *  IE only.
+    */
+  toolbarFocus: function(element, event) {
+    if (window.event && event.altKey) {
+      // ie only set focus on keyboard access, so do the click here.
+      //LOG.debug(" alt=" + event.altKey + "  keycode=" + event.keyCode)
+      element.click();
+    }
+  },
+
+
+// -------- SelectOne functions ----------------------------------------------------
+    // TODO move SelectOne function in Tobago.SelectOne object
+
+   /**
+    * Onchange function for SelectOneListbox.
+    */
+  selectOneListboxChange: function(element) {
+    if (element.oldValue == undefined) {
+      element.oldValue = -1;
+    }
+  },
+
+   /**
+    * Onclick function for SelectOneListbox.
+    */
+  selectOneListboxClick: function(element) {
+    if (element.oldValue == undefined || element.oldValue == element.selectedIndex) {
+      element.selectedIndex = -1;
+    }
+    element.oldValue = element.selectedIndex;
+  },
+
+   /**
+    * Init function for SelectOneradio.
+    */
+  selectOneRadioInit: function(name) {
+    var elements = document.getElementsByName(name);
+    for (var i = 0; i < elements.length; i++) {
+      elements[i].oldValue = elements[i].checked;
+    }
+  },
+
+   /**
+    * Onclick function for SelectOneradio.
+    */
+  selectOneRadioClick: function(element, name) {
+    var elements = document.getElementsByName(name);
+    for (var i = 0; i < elements.length; i++) {
+      if (elements[i] != element) {
+        elements[i].checked = false;
+        elements[i].oldValue = false;
+      }
+    }
+    if (element.oldValue == element.checked) {
+      element.checked = false;
+    }
+    element.oldValue = element.checked;
+  },
+
+// -------- Popup functions ---------------------------------------------------
+    // TODO move popup functions in Tobago.Popup object
+
+   /**
+    * Setup popup size
+    */
+  setupPopup: function(id, left, top) {
+//  alert("tobagoSetupPopup('" + id + "', '" + left + "', '"+ top + "')");
+    var contentId = id + Tobago.SUB_COMPONENT_SEP + "content";
+    var div = this.element(contentId);
+    if (div) {
+      var l = left.replace(/\D/g, "");
+      if (l.length > 0) {
+        div.style.left = l;
+        //      alert("1 set left to " + l);
+      } else {
+        l = this.getBrowserInnerWidth() - div.clientWidth - this.popupBorderWidth;
+        div.style.left = l/2;
+        //      alert("2 set left to " + l/2);
+      }
+
+      var t = top.replace(/\D/g, "");
+      if (t.length > 0) {
+        div.style.top = t;
+        //      alert("1 set top to " + t);
+      } else {
+        t = this.getBrowserInnerHeight() - div.clientHeight - this.popupBorderWidth;
+        div.style.top = t/2;
+        //      alert("2 set top to " + t/2);
+      }
+
+      var iframeId = id + Tobago.SUB_COMPONENT_SEP + "iframe";
+      var iframe = this.element(iframeId);
+      if (iframe) {
+        iframe.style.left = div.style.left;
+        iframe.style.top = div.style.top;
+      }
+
+      //  } else {
+      //    alert("popup div mit id '" + id + "' nicht gefunden!");
+    }
+
+  },
+
+   /**
+    * Make popup blink
+    * // TODO use css class
+    */
+  popupBlink: function(id) {
+    LOG.debug("popupId ist " + id);
+    var element = this.element(id);
+    element.style.background = 'red';
+    setTimeout("Tobago.popupBlinkOff('" + id + "')", 10);
+  },
+   /**
+    * helper for popupBlink
+    */
+  popupBlinkOff: function(id) {
+    var element = this.element(id);
+    element.style.background = 'none';
+  },
+
+// -------- Util functions ----------------------------------------------------
+    // TODO move util function in Tobago.Utils object
+
+   /**
+    * Sets the focus to the requested element or to the first possible if
+    * no element explecit requested.
+    */
+  setFocus: function() {
+    var focusElement = this.element(this.focusId);
+
+    if (focusElement) {
+      try { // focus() on not visible elements breaks IE
+        focusElement.focus();
+      } catch(ex) { }
+    } else {
+      foriLoop: for ( i = 0 ; i < document.forms.length ; i++) {
+        var form = document.forms[i];
+        if (form != null){
+          for (j = 0 ; j < form.elements.length ; j++) {
+            var element = form.elements[j];
+            if (element != null) {
+              if (!element.disabled && this.isFocusType(element.type)){
+                try { // focus() on not visible elements breaks IE
+                  element.focus();
+                  break foriLoop;
+                } catch(ex) { }
+              }
+            }
+          }
+        }
       }
     }
+
   },
 
-  getFormElement: function(page) {
-    page = $(page);
-    return $(page.id + Tobago.subComponentSeparator + "form");
+
+   /**
+    * check if a component type is valid to recieve the focus
+    */
+  isFocusType: function(type) {
+    if ( type == 'text'
+        || type == 'textarea'
+        || type == 'select-one'
+        || type == 'select-multiple'
+    //       ||  type == 'button'
+        || type == 'checkbox'
+    // || type == 'file'
+        || type == 'password'
+        || type == 'radio'
+        ||  type == 'reset'
+        ||  type == 'submit'
+        ) {
+      return true;
+    }
+    else {
+      return false;
+    }
+  },
+
+   /**
+    * Create a html input element with given type, name and value.
+    */
+  createInput: function(type, name, value) {
+    var input = document.createElement("INPUT");
+    if (type) {
+      input.type = type;
+    }
+    if (name) {
+      input.name = name;
+    }
+    if (value) {
+      input.value = value;
+    }
+    return input;
+  },
+
+   /**
+    * Add a cssClass name to the className property of a htmlElement
+    */
+  addCssClass: function(element, className) {
+    element.className = element.className + " " + className;
+  },
+
+   /**
+    * remove a cssClass name from the className property of a htmlElement
+    */
+  removeCssClass: function(element, className) {
+    var classes = " " + element.className + " ";
+    var re = new RegExp(" " + className + " ", 'g');
+    while (classes.match(re)) {
+      classes = classes.replace(re, " ");
+    }
+    classes = classes.replace(/  /g, " ");
+    element.className = classes;
+  },
+
+
+   /**
+    * Clear the selection.
+    */
+  clearSelection: function() {
+    if (document.selection) {  // IE
+      document.selection.empty();
+    } else if (window.getSelection) {  // GECKO
+      window.getSelection().removeAllRanges();
+    }
+  },
+
+   /**
+    * Returns the computedStyle of a html element
+    */
+  getRuntimeStyle: function(element) {
+    if (element.runtimeStyle) { // IE
+      return element.runtimeStyle;
+    } else {
+      return document.defaultView.getComputedStyle(element, null);
+    }
   },
 
+   /**
+    * Return anchestor with given type.
+    */
+    // TODO what if no anchestor found?
+  findAnchestorWithTagName: function(element, tagName) {
+    while (element.parentNode && (!element.tagName ||
+        (element.tagName.toUpperCase() != tagName.toUpperCase())))
+      element = element.parentNode;
+    return element;
+  },
+
+
+   /**
+    * Create a overlay with same dimension an wait cursor over a htmlElement.
+    */
   createOverlay: function(element) {
     var overlay = document.createElement('div');
     overlay.style.position = "absolute";
@@ -153,10 +640,196 @@
     overlay.style.zIndex = 10000;
     element.appendChild(overlay);
     return overlay;
-  }
+  },
+
+   /**
+    * Set the width of a htmlElement via style
+    */
+  setElementWidth: function(id, width) {
+    var element = this.element(id);
+    if (element) {
+      element.style.width = width;
+    }
+  },
+
+   /**
+    * Add a eventListener to a htmlElement
+    */
+  addEventListener: function(element, event, myFunction) {
+    if (element.addEventListener) { // this is DOM2
+      element.addEventListener(event, myFunction, false);
+    } else { // IE
+      element.attachEvent("on" + event, myFunction);
+    }
+  },
+
+   /**
+    * Remove a eventListener from a htmlElement
+    */
+  removeEventListener: function(element, event, myFunction) {
+    if (element.removeEventListener) { // this is DOM2
+      element.removeEventListener(event, myFunction, true);
+    }
+    else {  // IE
+      element.detachEvent("on" + event, myFunction);
+    }
+  },
 
+   /**
+    * Stop event bubbling
+    */
+  stopEventPropagation: function(event) {
+    if (! event) {
+      event = window.event;
+    }
+    event.cancelBubble = true;  // this is IE, no matter if not supported by actual browser
+    if (event.stopPropagation) {
+      event.stopPropagation(); // this is DOM2
+      event.preventDefault();
+    }
+  },
+
+   /**
+    * Return the absolute top value, related to the body element, for a htmlElement.
+    */
+  getAbsoluteTop: function(element) {
+    var top = 0;
+    var parent = false;
+    while (element.offsetParent) {
+      top += element.offsetTop;
+      top -= element.scrollTop;
+      if (parent && element.currentStyle) { // IE only
+        top += element.currentStyle.borderTopWidth.replace(/\D/g, "") - 0;
+      }
+      element = element.offsetParent;
+      parent = true;
+    }
+    return top;
+  },
+
+
+   /**
+    * Return the absolute left, related to the body element, value for a htmlElement.
+    */
+  getAbsoluteLeft: function(element) {
+    var left = 0;
+    var parent = false;
+    while (element.offsetParent) {
+      left += element.offsetLeft;
+      left -= element.scrollLeft;
+      if (parent && element.currentStyle) {  // IE only
+        left += element.currentStyle.borderLeftWidth.replace(/\D/g, "") - 0;
+      }
+      element = element.offsetParent;
+      parent = true;
+    }
+    return left;
+  },
+
+   /**
+    * Return the scroll-x value of the body element.
+    */
+  getBrowserInnerLeft: function() {
+    var innerLeft;
+    if (document.all) { // ie
+      innerLeft = document.body.scrollLeft;
+    } else {
+      innerLeft = window.scrollX;
+    }
+    return innerLeft;
+  },
+
+   /**
+    * Return the scroll-y value of the body element.
+    */
+  getBrowserInnerTop: function() {
+    var innerTop;
+    if (document.all) { // ie
+      innerTop = document.body.scrollTop;
+    } else {
+      innerTop = window.scrollY;
+    }
+    return innerTop;
+  },
+
+   /**
+    * Return the client inner width.
+    */
+  getBrowserInnerWidth: function() {
+    var innerWidth;
+    if (document.all) { // ie
+      innerWidth = document.body.clientWidth;
+    } else {
+      innerWidth = window.innerWidth;
+      if (document.body.scrollHeight > window.innerHeight) {
+        innerWidth -= this.scrollbarWidth;
+      }
+    }
+    return innerWidth;
+  },
+
+   /**
+    * Return the client inner height.
+    */
+  getBrowserInnerHeight: function() {
+    var innerHeight;
+    if (document.all) { // ie
+      innerHeight = document.body.clientHeight;
+    } else {
+      innerHeight = window.innerHeight;
+    }
+    return innerHeight;
+  },
+
+  // TODO check if this is still ok
+  doEditorCommand: function(element, id) {
+    LOG.debug("doEditorCommand()");
+    var ta = this.element(id);
+    var text = ta.value;
+    var marked = text.substring(ta.selectionStart, ta.selectionEnd);
+    LOG.debug("text = " + marked);
+    LOG.debug("von = " + ta.selectionStart + " bis =" + ta.selectionEnd);
+    ta.selectionStart--;
+    ta.focus();
+
+  },
+
+   /**
+    * Returns a html element.
+    * valid input types are:
+    * 'string'      : returns the result of document.getElementById()
+    * 'Event'       : returns the currentTarget/srcElement property
+    * 'HtmlElement' : returns the element itself
+    * For all other types return 'undefined'
+    */
+  element: function(arg) {
+//    LOG.debug("arg = " + arg);
+
+    try {
+      if (typeof arg == 'string') {
+//        LOG.debug("arg ist string ");
+        return document.getElementById(arg);
+      } else if (typeof arg.currentTarget == 'object') {
+//        LOG.debug("arg ist dom event ");
+        return arg.currentTarget;
+      } else if (typeof arg.srcElement == 'object') {
+//        LOG.debug("arg ist IE event ");
+          return arg.srcElement;  // IE don't support currentTarget, hope src target helps
+      } else if (typeof arg.tagName == 'string') {
+//        LOG.debug("arg ist html element ");
+        return arg;
+      }
+
+    } catch(ex) {
+      return undefined;
+    }
+    LOG.error("arg ist unbekannt : " + typeof arg + " : " + arg);
+    return undefined;
+  }
 });
 
+
+
 Tobago.ScriptLoader = Class.create();
 Tobago.ScriptLoader.prototype = {
   initialize: function(names, doAfter) {
@@ -213,7 +886,12 @@
 //          if (this.actualScript.indexOf('tabgroup') > -1) {
 //      LOG.debug("doAfter=" + this.doAfter);
 //              }
-      eval(this.doAfter);
+      try {
+        eval(this.doAfter);
+      } catch(ex) {
+        LOG.error(ex);
+        LOG.error("errorCode: " + this.doAfter.valueOf());
+      }
 
 //          } else {
 //              LOG.debug("doAfter = " + this.doAfter)
@@ -227,23 +905,10 @@
 Object.extend(Tobago.Updater, {
   update: function(container, page, actionId, ajaxComponentId, options) {
 
-    var form = Tobago.getFormElement(page);
-    if (!form) {
-      LOG.error("Can't find form Tag!");
-      return;
-    }
-
-    var hidden = $(form.id + "-action");
-    if (hidden) {
-      hidden.value = actionId;
-//      LOG.debug("set action to : \"" + hidden.value + "\"");
-    } else {
-      LOG.error("No hidden field for form action Id='" + form.id + "-action" + "'");
-      return;
-    }
+    Tobago.action.value = actionId;
 
-    var url = form.action + "?affectedAjaxComponent=" + ajaxComponentId
-        + '&' + Form.serialize(form);
+    var url = Tobago.form.action + "?affectedAjaxComponent=" + ajaxComponentId
+        + '&' + Form.serialize(Tobago.form);
 
     Tobago.createOverlay(container);
     //    LOG.debug("request url = " + url);
@@ -251,6 +916,18 @@
   }
 });
 
+
+
+function tobago_showHidden() {
+  for(var i = 0; i < document.forms.length; i++) {
+    var form = document.forms[i];
+    for(var j = 0; j < form.elements.length; j++) {
+      if (form.elements[j].type == "hidden") {
+        form.elements[j].type = "text";
+      }
+    }
+  }
+}
 
 if (typeof(LOG) == "undefined") {
   var LOG = {