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/04/21 16:25:41 UTC

svn commit: r395898 - in /myfaces/tobago/trunk/theme: scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/ stan...

Author: weber
Date: Fri Apr 21 07:25:38 2006
New Revision: 395898

URL: http://svn.apache.org/viewcvs?rev=395898&view=rev
Log:
changes on javascript to minimize client-site delaying

Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java?rev=395898&r1=395897&r2=395898&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Fri Apr 21 07:25:38 2006
@@ -23,7 +23,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_NAVIGATE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_SCRIPT;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP;
@@ -35,15 +36,13 @@
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_CHECKBOX;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_RADIO;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_NAVIGATE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_SCRIPT;
 import org.apache.myfaces.tobago.component.ComponentUtil;
-import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.component.UIMenu;
 import org.apache.myfaces.tobago.component.UIMenuCommand;
 import org.apache.myfaces.tobago.component.UIMenuSeparator;
-import org.apache.myfaces.tobago.component.UISelectOneCommand;
+import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.component.UISelectBooleanCommand;
-import org.apache.myfaces.tobago.component.UIMenu;
+import org.apache.myfaces.tobago.component.UISelectOneCommand;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
@@ -66,8 +65,8 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.StringTokenizer;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 public class MenuBarRenderer extends RendererBase {
 
@@ -153,6 +152,7 @@
     sb.append("function ");
     sb.append(setupFunction);
     sb.append("(id, pageId) {\n");
+    sb.append("  var menuStart = new Date();\n");
     sb.append("  var searchId = id + '" + SEARCH_ID_POSTFIX + "';\n");
     sb.append("  var menubar = document.getElementById(searchId);\n");
     sb.append("  if (! menubar) {\n");
@@ -183,6 +183,7 @@
     sb.append(
         "    LOG.debug('kein Element mit id: ' + searchId + ' gefunden!');\n");
     sb.append("  }\n");
+    sb.append("  LOG.debug('Menu Total Time : ' + (new Date().getTime() - menuStart.getTime()));\n");
     sb.append("}\n");
     return setupFunction;
   }
@@ -258,7 +259,7 @@
     facesContext.setResponseWriter(savedWriter);
 
 
-    return "new MenuItem('" + removeLFs(stringWriter.toString()) + "', null)";
+    return "new Tobago.Menu.Item('" + removeLFs(stringWriter.toString()) + "', null)";
   }
 
   private void addAcceleratorKey(
@@ -484,7 +485,7 @@
 
     sb.append("    ");
     sb.append(var);
-    sb.append(".addMenuItem(new MenuItem('");
+    sb.append(".addMenuItem(new Tobago.Menu.Item('");
     sb.append(removeLFs(html));
     sb.append("', ");
     if (!disabled) {
@@ -505,7 +506,7 @@
 
     sb.append("    ");
     sb.append(var);
-    sb.append(".addMenuItem(new MenuItem('");
+    sb.append(".addMenuItem(new Tobago.Menu.Item('");
     sb.append(removeLFs(html));
     sb.append("', ");
     sb.append("null");

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=395898&r1=395897&r2=395898&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Fri Apr 21 07:25:38 2006
@@ -162,6 +162,8 @@
     writer.startElement("html", null);
     writer.startElement("head", null);
 
+    HtmlRendererUtil.writeJavascript(writer, "var TbgHeadStart = new Date();");
+
     // meta
     // TODO duplicate; see PageTag.doStartTag()
 //    writer.startElement("meta", null);
@@ -346,6 +348,7 @@
           logMessages.toArray(new String[logMessages.size()]));
     }
 
+    HtmlRendererUtil.writeJavascript(writer, "TbgTimer.endBody = new Date();");
     writer.endElement("body");
     writer.endElement("html");
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewcvs/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js?rev=395898&r1=395897&r2=395898&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js Fri Apr 21 07:25:38 2006
@@ -76,20 +76,22 @@
 }
 
 function createMenuRoot(id) {
-  var menu = new MenuItem();
+  var menu = new Tobago.Menu.Item();
   menu.id = id + Tobago.SUB_COMPONENT_SEP + Tobago.Menu.MENU_ROOT_ID;
   menu.level = 0;
   Tobago.addJsObject(menu);
   return menu;
 }
 
-function MenuItem(label, action, disabled) {
+Tobago.Menu.Item = function(label, action, disabled) {
   this.label = label;
   this.action = action;
   this.disabled = disabled;
   this.subItems = new Array();
 
-  this.addMenuItem = function(menuItem) {
+};
+
+Tobago.Menu.Item.prototype.addMenuItem = function(menuItem) {
     var index = this.subItems.length;
     this.subItems[index] = menuItem;
     menuItem.parent = this;
@@ -98,7 +100,7 @@
     menuItem.level = this.level + 1;
   };
 
-  this.toHtml = function(createSubItems) {
+Tobago.Menu.Item.prototype.toHtml = function(createSubItems) {
     var html = "";
 //    LOG.debug("toHtml() for"  + this.id + " l=" + this.level);
     if (this.level > 1 || (this.level == 1 && ! createSubItems)) {
@@ -149,7 +151,7 @@
     return html;
   };
 
-  this.openSubMenus = function() {
+Tobago.Menu.Item.prototype.openSubMenus = function() {
     if (! this.subItemContainer) {     
       return;
     }
@@ -221,10 +223,12 @@
 //    calling via 'setTimeout()' is not nice, but resolves the problem
     setTimeout('tobagoSetSubMenuContainerVisible("' + this.id +  '")', 0);
   };
-  this.hideSubMenus = function() {
+
+Tobago.Menu.Item.prototype.hideSubMenus = function() {
     this.setSubMenuContainerVisibility("hidden");
   };
-  this.setSubMenuContainerVisibility = function(style) {
+
+Tobago.Menu.Item.prototype.setSubMenuContainerVisibility = function(style) {
     if (this.subItemContainer) {
       this.subItemContainer.style.visibility = style;
       if (this.subItemIframe) {
@@ -234,11 +238,11 @@
   };
 
 
-  this.openMenu = function() {
+Tobago.Menu.Item.prototype.openMenu = function() {
     this.focusLabelTag();
   };
 
-  this.onMouseOver = function() {
+Tobago.Menu.Item.prototype.onMouseOver = function() {
     this.mouseOver = true;
     //LOG.debug("onMouseOver " + this.id + " level :" + this.level);
     clearTimeout(this.onBlurTimer);
@@ -259,7 +263,7 @@
     }
   };
 
-  this.onMouseOut = function(clicked) {
+Tobago.Menu.Item.prototype.onMouseOut = function(clicked) {
     this.mouseOver = false;
     //LOG.debug("onMouseOut " + this.id + " clicked = " + clicked);
     clearTimeout(this.hoverTimer);
@@ -273,7 +277,7 @@
     }
   };
 
-  this.onFocus = function() {
+Tobago.Menu.Item.prototype.onFocus = function() {
     this.focus = true;
     Tobago.addCssClass(this.htmlElement, "tobago-menu-item-focus");
     if (this.menuButton) {
@@ -286,14 +290,15 @@
       this.htmlElement.click();
     }
   };
-  this.onBlur = function() {
+
+Tobago.Menu.Item.prototype.onBlur = function() {
     //LOG.debug("onBlur " + this.id);
     this.focus = false;
     this.onBlurTimer = setTimeout("tobagoFocusLost('" + this.id + "')",
         getFocusLostTimeout());
   };
 
-  this.focusLost = function() {
+Tobago.Menu.Item.prototype.focusLost = function() {
     //LOG.debug("focusLost " + this.id);
     if (this.level > 0
         && (!this.mouseOver)
@@ -308,12 +313,12 @@
     }
   };
 
-  this.isExpanded = function() {
+Tobago.Menu.Item.prototype.isExpanded = function() {
     return this.subItemContainer
         && this.subItemContainer.style.visibility.match(/visible/);
   };
 
-  this.focusLabelTag = function() {
+Tobago.Menu.Item.prototype.focusLabelTag = function() {
     //LOG.debug("setze Focus " + this.id);
     var element = this.getLabelTag();
     if (element) {
@@ -324,7 +329,8 @@
       }
     }
   };
-  this.blurLabelTag = function() {
+
+Tobago.Menu.Item.prototype.blurLabelTag = function() {
     //LOG.debug("entferne Focus " + this.id);
     var element = this.getLabelTag();
     if (element) {
@@ -332,7 +338,7 @@
     }
   };
 
-  this.childHasFocus = function() {
+Tobago.Menu.Item.prototype.childHasFocus = function() {
     for (var i = 0; i < this.subItems.length; i++) {
        if (this.subItems[i].focus) {
          return true;
@@ -345,7 +351,7 @@
   };
 
 
-  this.isNeighbourOpen = function() {
+Tobago.Menu.Item.prototype.isNeighbourOpen = function() {
     for (var i = 0; i < this.parent.subItems.length; i++) {
       if (this.parent.subItems[i].isExpanded()) {
         return true;
@@ -358,7 +364,7 @@
 
   // #########################################################  key access
 
-  this.keyDown = function() {
+Tobago.Menu.Item.prototype.keyDown = function() {
     if (this.level == 1) {
       this.openSubMenus();
       this.nextItem(-1, 1);
@@ -370,7 +376,7 @@
     }
   };
 
-  this.keyUp = function() {
+Tobago.Menu.Item.prototype.keyUp = function() {
     if (this.level == 1) {
       this.openSubMenus();
       this.nextItem(this.subItems.length, -1);
@@ -382,7 +388,7 @@
     }
   };
 
-  this.keyLeft = function() {
+Tobago.Menu.Item.prototype.keyLeft = function() {
     if (this.level == 1) {
       var next = this.parent.nextItem(this.index, -1);
       if (next && next.htmlElement.id != this.htmlElement.id) { // menu has changed
@@ -410,7 +416,7 @@
     }
   };
 
-  this.keyRight = function() {
+Tobago.Menu.Item.prototype.keyRight = function() {
     if (this.level == 1) {
       var next = this.parent.nextItem(this.index, 1);
       if (next && next.htmlElement.id != this.htmlElement.id) { // menu has changed
@@ -437,7 +443,7 @@
     }
   };
 
-  this.nextItem = function(start, offset) {
+Tobago.Menu.Item.prototype.nextItem = function(start, offset) {
     var i = start + offset;
 
     while (!(this.subItems[i] && ! this.subItems[i].disabled) && i != start) {
@@ -464,7 +470,7 @@
     return false;
   };
 
-  this.collapse = function() {
+Tobago.Menu.Item.prototype.collapse = function() {
     //LOG.debug("collapse " + this.id);
     if (this.level < 2) {
       var aTag = this.getLabelTag();
@@ -496,7 +502,7 @@
     }
   };
   
-  this.getLabelTag = function() {
+Tobago.Menu.Item.prototype.getLabelTag = function() {
     var children = this.htmlElement.childNodes;
     for (var k = 0; k < children.length; k++) {
       if (children[k].className.match(/tobago-menuBar-item-span/)) {
@@ -505,11 +511,11 @@
     }
   };
   
-  this.setSubitemArrowImage = function(image) {
+Tobago.Menu.Item.prototype.setSubitemArrowImage = function(image) {
     this.subitemArrowImage = image;
   };
 
-  this.getSubitemArrowImage = function() {
+Tobago.Menu.Item.prototype.getSubitemArrowImage = function() {
     if (! this.subitemArrowImage) {
       if (this.parent) {
         this.subitemArrowImage = this.parent.getSubitemArrowImage();
@@ -518,7 +524,7 @@
     return this.subitemArrowImage;
   };
   
-  this.addSubitemArrowImage = function() {
+Tobago.Menu.Item.prototype.addSubitemArrowImage = function() {
     if (this.level > 1 && this.subItems && this.subItems.length > 0) {
       var html = this.htmlElement.innerHTML;
       html += '<img class="tobago-menu-subitem-arrow" src="';
@@ -527,7 +533,7 @@
     }
   };
   
-  this.setupIframe = function() {
+Tobago.Menu.Item.prototype.setupIframe = function() {
     if (this.subItemIframe) {
       this.subItemIframe.style.width = this.subItemContainer.style.width;
       this.subItemIframe.style.height = this.subItemContainer.style.height;
@@ -536,10 +542,9 @@
     }
   };
 
-  this.setMenuButton = function(button) {
+Tobago.Menu.Item.prototype.setMenuButton = function(button) {
     this.menuButton = button;
   };
-}
 
 
 

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewcvs/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=395898&r1=395897&r2=395898&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Fri Apr 21 07:25:38 2006
@@ -40,14 +40,18 @@
 };
 
 Tobago.Sheet = function(sheetId, enableAjax, checkedImage, uncheckedImage) {
+  this.startTime = new Date();
   this.id = sheetId;
   this.ajaxEnabled = enableAjax;
   this.checkedImage = checkedImage;
   this.uncheckedImage = uncheckedImage;
 
   this.resizerId = undefined;
-  this.oldX = 0;
-  this.newWidth = 0;
+  this.oldX      = 0;
+  this.newWidth  = 0;
+
+  this.firstRowId = undefined;
+  this.firstRowIndex = -1;
 
   this.outerDivId    = this.id + "_outer_div";
   this.headerDivId   = this.id + "_header_div";
@@ -55,8 +59,16 @@
   this.selectedId    = this.id + Tobago.SUB_COMPONENT_SEP +"selected";
   this.headerWidthsId = this.id + Tobago.SUB_COMPONENT_SEP + "widths"
 
-  this.sortOnclickRegExp
-      = new RegExp("Tobago.submitAction\\(('|\")(.*?)('|\")\\)");
+  if (this.ajaxEnabled) {
+    // option are onyl used for ajax request
+    this.options = {
+      method: 'post',
+      asynchronous: true,
+      onComplete: Tobago.bind(this, "onComplete"),
+      parameters: '',
+      evalScripts: true
+    };
+  }
 
   this.ppPrefix
       = Tobago.SUB_COMPONENT_SEP + "pagingPages" + Tobago.SUB_COMPONENT_SEP;
@@ -71,16 +83,27 @@
 
   this.firstRowRegExp = new RegExp("^" + this.id + "_data_tr_\\d+$");
 
-  this.setupElements = function() {
+  this.setup();
+
+  LOG.debug("New Sheet with id " + this.id);
+  this.endTime = new Date();
+  LOG.debug("Sheet-setup time = " + (this.setupEnd.getTime() - this.setupStart.getTime()));
+  LOG.debug("Sheet-total time = " + (this.endTime.getTime() - this.startTime.getTime()));
+};
+
+Tobago.Sheet.prototype.sortOnclickRegExp
+      = new RegExp("Tobago.submitAction\\(('|\")(.*?)('|\")\\)");
+
+
+Tobago.Sheet.prototype.setupElements = function() {
 
     this.firstRowId = this.getFirstRowId();
     this.firstRowIndex = (this.firstRowId != undefined)
         ? this.firstRowId.substring(this.firstRowId.lastIndexOf("_data_tr_") + 9)
         : -1;
-
   };
 
-  this.setupSortHeaders = function() {
+Tobago.Sheet.prototype.setupSortHeaders = function() {
     var i = 0;
     var idPrefix = this.id + "_header_box_";
     var headerBox = Tobago.element(idPrefix + i++);
@@ -105,7 +128,7 @@
     }
   };
 
-  this.setupPagingLinks = function() {
+Tobago.Sheet.prototype.setupPagingLinks = function() {
     idPrefix = this.id + Tobago.SUB_COMPONENT_SEP;
     var linkBox = Tobago.element(idPrefix + "pagingLinks");
     if (linkBox) {
@@ -119,7 +142,7 @@
     }
   };
 
-  this.setupPagePaging = function() {
+Tobago.Sheet.prototype.setupPagePaging = function() {
     linkBox = Tobago.element(idPrefix + "pagingPages");
     if (linkBox) {
       for (i = 0 ; i < linkBox.childNodes.length ; i++) {
@@ -146,7 +169,7 @@
     }
   };
 
-  this.setupRowPaging = function() {
+Tobago.Sheet.prototype.setupRowPaging = function() {
     var toRowId = this.id + Tobago.COMPONENT_SEP + "ToRow";
     var rowText = Tobago.element(toRowId + Tobago.SUB_COMPONENT_SEP + "text");
     if (rowText) {
@@ -161,7 +184,7 @@
     }
   };
 
-  this.doSort = function(event) {
+Tobago.Sheet.prototype.doSort = function(event) {
     var element = Event.element(event);
     while (element && !element.sorterId) {
       element = element.parentNode;
@@ -171,7 +194,7 @@
     this.reloadWithAction(element.sorterId);
   };
 
-  this.doPagingDirect = function(event) {
+Tobago.Sheet.prototype.doPagingDirect = function(event) {
     var element = Event.element(event);
     var action = this.id + Tobago.COMPONENT_SEP + "ToPage";
 
@@ -186,7 +209,7 @@
     this.reloadWithAction(action);
   };
 
-  this.doPaging = function(event) {
+Tobago.Sheet.prototype.doPaging = function(event) {
     var element = Event.element(event);
     var action = "unset";
     if (element.id.match(this.firstRegExp)){
@@ -201,14 +224,14 @@
     this.reloadWithAction(action);
   };
 
-  this.reloadWithAction = function(action) {
+Tobago.Sheet.prototype.reloadWithAction = function(action) {
     LOG.debug("reload sheet with action \"" + action + "\"");
     var divElement = Tobago.element(this.outerDivId);
     Tobago.Updater.update(divElement, null, action, this.id, this.options);
 
   };
 
-  this.insertTarget = function(event, actionId) {
+Tobago.Sheet.prototype.insertTarget = function(event, actionId) {
 //    LOG.debug("insertTarget('" + actionId + "')")
     var textId = actionId + Tobago.SUB_COMPONENT_SEP + "text";
     var text = Tobago.element(textId);
@@ -240,7 +263,7 @@
     }
   };
 
-  this.delayedHideInput = function(event) {
+Tobago.Sheet.prototype.delayedHideInput = function(event) {
     var element = Event.element(event);
     if (element) {
       this.textInput = element;
@@ -248,7 +271,7 @@
     }
   };
 
-  this.hideInput = function() {
+Tobago.Sheet.prototype.hideInput = function() {
     if (this.textInput) {
       this.textInput.parentNode.style.cursor = 'pointer';
       this.textInput.style.display = 'none';
@@ -256,12 +279,12 @@
     }
   };
 
-  this.doKeyEvent = function(event) {
+Tobago.Sheet.prototype.doKeyEvent = function(event) {
     var input = Event.element(event);
     if (input) {
 
       var keyCode;
-      if (event.which) {                  
+      if (event.which) {
         keyCode = event.which;
       } else {
         keyCode = event.keyCode;
@@ -278,20 +301,12 @@
     }
   };
 
-  this.onComplete = function() {
+Tobago.Sheet.prototype.onComplete = function() {
     LOG.debug("sheet reloaded");
     this.setup();
   };
 
-  this.options = {
-    method: 'post',
-    asynchronous: true,
-    onComplete: Tobago.bind(this, "onComplete"),
-    parameters: '',
-    evalScripts: true
-  };
-
-  this.setupResizer = function() {
+Tobago.Sheet.prototype.setupResizer = function() {
     var i = 0;
     var headerDiv = Tobago.element(this.headerDivId);
     var contentDiv = Tobago.element(this.contentDivId)
@@ -308,8 +323,9 @@
     }
   };
 
-  this.setup = function() {
-    LOG.debug("setup(" + this.id +")");
+Tobago.Sheet.prototype.setup = function() {
+    this.setupStart = new Date();
+    LOG.debug("Tobago.Sheet.setup(" + this.id +")");
 
     // ToDo: find a better way to fix this problem
     // IE needs this in case of ajax loading of style classes
@@ -339,9 +355,10 @@
       this.setupPagePaging();
       this.setupRowPaging();
     }
+    this.setupEnd = new Date();
   };
 
-  this.adjustScrollBars = function() {
+Tobago.Sheet.prototype.adjustScrollBars = function() {
     var dataFiller = Tobago.element(this.id + "_data_row_0_column_filler");
     if (dataFiller) {
       var contentDiv = Tobago.element(this.contentDivId);
@@ -366,7 +383,7 @@
     }
   };
 
-  this.addSelectionListener = function() {
+Tobago.Sheet.prototype.addSelectionListener = function() {
     var row = Tobago.element(this.firstRowId);
     if (row) {
       var i = this.firstRowIndex;
@@ -380,7 +397,7 @@
     }
   };
 
-  this.doSelection = function(event) {
+Tobago.Sheet.prototype.doSelection = function(event) {
     if (! event) {
       event = window.event;
     }
@@ -401,7 +418,7 @@
     if (! Tobago.isInputElement(srcElement.tagName)) {
 
       Tobago.clearSelection();
-      
+
       var dataRow = Tobago.element(event);
       while (dataRow.id.search(new RegExp("_data_tr_\\d+$")) == -1) {
         dataRow = dataRow.parentNode;
@@ -428,7 +445,7 @@
     }
   };
 
-  this.updateSelectionView = function(sheetId) {
+Tobago.Sheet.prototype.updateSelectionView = function(sheetId) {
     var selected = Tobago.element(this.selectedId).value;
     var row = Tobago.element(this.firstRowId);
     var i = this.firstRowIndex;
@@ -457,12 +474,12 @@
     }
   };
 
-  this.toggleSelectionForRow = function(dataRow) {
+Tobago.Sheet.prototype.toggleSelectionForRow = function(dataRow) {
     var rowIndex = dataRow.id.substring(dataRow.id.lastIndexOf("_data_tr_") + 9);
     this.toggleSelection(rowIndex);
   };
 
-  this.toggleSelection = function(rowIndex) {
+Tobago.Sheet.prototype.toggleSelection = function(rowIndex) {
     this.tobagoLastClickedRowId
         = Tobago.element(this.id + "_data_tr_" + rowIndex).id;
     var selector = Tobago.element(this.id + "_data_row_selector_" + rowIndex);
@@ -478,7 +495,7 @@
     }
   };
 
-  this.selectRange = function(dataRow) {
+Tobago.Sheet.prototype.selectRange = function(dataRow) {
     var lastRow = Tobago.element(this.tobagoLastClickedRowId);
     var firstIndex = lastRow.id.substring(lastRow.id.lastIndexOf("_data_tr_") + 9) - 0;
     var lastIndex  = dataRow.id.substring(dataRow.id.lastIndexOf("_data_tr_") + 9) - 0;
@@ -504,7 +521,7 @@
     }
   };
 
-  this.getFirstRowId = function() {
+Tobago.Sheet.prototype.getFirstRowId = function() {
     var element = Tobago.element(this.id + "_data_row_0_column0");// data div
     while (element && element.id.search(this.firstRowRegExp) == -1) {
 //      LOG.debug("element id = " + element.id);
@@ -514,7 +531,7 @@
     return element ? element.id : undefined;
   };
 
-  this.setupHeader = function() {
+Tobago.Sheet.prototype.setupHeader = function() {
     var headerBox = Tobago.element(this.id + "_header_box_0");
     if (headerBox) {
 
@@ -529,7 +546,7 @@
     }
   };
 
-  this.adjustResizer = function() {
+Tobago.Sheet.prototype.adjustResizer = function() {
     // opera needs this
     if (window.opera) {
       var position = 5;
@@ -545,7 +562,7 @@
     }
   };
 
-  this.adjustHeaderDiv = function () {
+Tobago.Sheet.prototype.adjustHeaderDiv = function () {
     var headerDiv = Tobago.element(this.headerDivId);
     var contentDiv = Tobago.element(this.contentDivId);
     var contentTable = contentDiv.getElementsByTagName("table")[0];
@@ -585,7 +602,7 @@
     //  LOG.debug("##########################################");
   };
 
-  this.beginResize = function(event) {
+Tobago.Sheet.prototype.beginResize = function(event) {
     if (! event) {
       event = window.event;
     }
@@ -597,16 +614,15 @@
     }
   };
 
-  this.getHeaderBox = function() {
+Tobago.Sheet.prototype.getHeaderBox = function() {
     var boxId = this.resizerId.replace(/_header_resizer_/, "_header_box_");
     return Tobago.element(boxId);
   };
 
-  this.doResize = function(event) {
+Tobago.Sheet.prototype.doResize = function(event) {
     if (! event) {
       event = window.event;
     }
-
     if (this.resizerId) {
       var box = this.getHeaderBox();
       var elementWidth = box.style.width;
@@ -622,7 +638,7 @@
     }
   };
 
-  this.endResize = function(event) {
+Tobago.Sheet.prototype.endResize = function(event) {
     if (! event) {
       event = window.event;
     }
@@ -647,7 +663,7 @@
     }
   };
 
-  this.storeSizes = function() {
+Tobago.Sheet.prototype.storeSizes = function() {
     var index = 0;
     var idPrefix = this.id + "_header_box_";
     var header = Tobago.element(idPrefix + index++);
@@ -660,7 +676,7 @@
     Tobago.element(this.headerWidthsId).value = widths;
   };
 
-  this.doScroll = function(event) {
+Tobago.Sheet.prototype.doScroll = function(event) {
     //LOG.debug("header / data  " + this.headerDiv.scrollLeft + "/" + this.contentDiv.scrollLeft);
     Tobago.element(this.headerDivId).scrollLeft
         = Tobago.element(this.contentDivId).scrollLeft;
@@ -670,7 +686,7 @@
 
 
 
-  this.selectAll = function() {
+Tobago.Sheet.prototype.selectAll = function() {
     var row = Tobago.element(this.firstRowId);
     var i = this.firstRowIndex;
     var selected = Tobago.element(this.selectedId);
@@ -687,7 +703,7 @@
     this.updateSelectionView();
   };
 
-  this.unSelectAll = function() {
+Tobago.Sheet.prototype.unSelectAll = function() {
     var selected = Tobago.element(this.selectedId);
     var row = Tobago.element(this.firstRowId);
     var selector = Tobago.element(this.id + "_data_row_selector_" + i);
@@ -707,7 +723,7 @@
     this.updateSelectionView();
   };
 
-  this.toggleAllSelections = function(sheetId) {
+Tobago.Sheet.prototype.toggleAllSelections = function(sheetId) {
     var row = Tobago.element(this.firstRowId);
     var i = this.firstRowIndex;
     while (row) {
@@ -717,7 +733,3 @@
     this.updateSelectionView();
   };
 
-  this.setup();
-
-  LOG.debug("New Sheet with id " + this.id);
-}

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewcvs/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=395898&r1=395897&r2=395898&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Fri Apr 21 07:25:38 2006
@@ -14,6 +14,38 @@
  *    limitations under the License.
  */
 
+var TbgTimer = {
+    startTbgJs: new Date(),
+
+    log: function() {
+      var tbgjs = this.endTbgJs.getTime() - this.startTbgJs.getTime();
+//      var htmljs = this.endBody.getTime() - this.startHtml.getTime();
+      var bodyjs = this.endBody.getTime() - this.startBody.getTime();
+      var onloadjs = this.endOnload.getTime() - this.startOnload.getTime();
+      var bodyToOnload = this.startOnload.getTime() - this.endBody.getTime();
+      var totaljs = this.endTotal.getTime() - this.startTbgJs.getTime();
+      var appOnload = this.endAppOnload.getTime() - this.startAppOnload.getTime();
+      LOG.show();
+      if (TbgHeadStart) {
+        LOG.debug("startTbgJs-TbgHeadStart: " + (this.startTbgJs.getTime() - TbgHeadStart.getTime()));
+      }
+      LOG.debug("startBody-startTbgJs: " + (this.startBody.getTime() - this.startTbgJs.getTime()));
+      LOG.debug("startTbgJs:" + this.startTbgJs.getTime());
+      LOG.debug("startBody :" + this.startBody.getTime());
+      LOG.debug("parse tobago.js " + tbgjs);
+//      LOG.debug("parse htmltotal " + htmljs);
+      LOG.debug("parse body " + bodyjs);
+      LOG.debug("between body and onload " + bodyToOnload);
+      LOG.debug("execute onload " + onloadjs);
+      LOG.debug("execute appOnload " + appOnload);
+      LOG.debug("bis appOnload " + (this.startAppOnload.getTime() - this.startOnload.getTime()));
+      LOG.debug("bis scriptLoaders " + (this.startScriptLoaders.getTime() - this.startOnload.getTime()));
+      LOG.debug("time scriptLoaders " + (this.endScriptLoaders.getTime() - this.startScriptLoaders.getTime()));
+      LOG.debug("bis nach onload " + (this.endOnload.getTime() - this.startTbgJs.getTime()));
+      LOG.debug("total " + totaljs);
+    }
+};
+
 var Tobago = {
 
   // -------- Constants -------------------------------------------------------
@@ -172,6 +204,7 @@
   init: function(pageId) {
 //    new LOG.LogArea({hide: false});
 //    LOG.show();
+    TbgTimer.startOnload = new Date();
     this.page = this.element(pageId);
     this.form = this.element(this.page.id + this.SUB_COMPONENT_SEP + "form");
     this.addBindEventListener(this.form, "submit", this, "onSubmit");
@@ -179,17 +212,28 @@
 
     this.addBindEventListener(window, "unload", this, "onUnload");
 
+    TbgTimer.startAppOnload = new Date();
     if (this.applicationOnload) {
       this.applicationOnload();
     }
+    TbgTimer.endAppOnload = new Date();
 
     this.setFocus();
 
     this.addBindEventListener(document, "keypress", this.acceleratorKeys, "observe");
 
-    this.pageIsComplete = true;
-    this.registerCurrentScripts();
-    this.startScriptLoaders();
+    window.setTimeout(Tobago.finishPageLoading, 10);
+    TbgTimer.endOnload = new Date();
+  },
+
+  finishPageLoading: function() {
+    Tobago.registerCurrentScripts();
+    TbgTimer.startScriptLoaders = new Date();
+    Tobago.startScriptLoaders();
+    TbgTimer.endScriptLoaders = new Date();
+    Tobago.pageIsComplete = true;
+    TbgTimer.endTotal = new Date();
+    TbgTimer.log();
   },
 
   onSubmit: function() {
@@ -428,12 +472,26 @@
     * Start script loaders from queue
     */
   startScriptLoaders: function() {
-//    LOG.debug("start 1 of " + this.scriptLoaders.length + " Loaders");
-    if (this.scriptLoaders.length > 0) {
-      this.scriptLoadingActive = true;
-      this.scriptLoaders.shift().ensureScripts();
+    if (! this.pageIsComplete) {
+      while (this.scriptLoaders.length > 0) {
+        var scriptLoader = this.scriptLoaders.shift();
+        scriptLoader.executeCommands();
+      }
     } else {
-      this.scriptLoadingActive = false;
+      var start = new Date().getTime();
+      LOG.debug("start 1 of " + this.scriptLoaders.length + " Loaders");
+      if (this.tbgScLoSt) {
+        LOG.debug("time scriptLoader " + (start - this.tbgScLoSt));
+      }
+      this.tbgScLoSt = start;
+      if (this.scriptLoaders.length > 0) {
+        this.scriptLoadingActive = true;
+        this.scriptLoaders.shift().ensureScripts();
+      } else {
+        this.scriptLoadingActive = false;
+        LOG.debug("last time scriptLoader " + (new Date().getTime() - this.tbgScLoSt));
+        delete this.tbgScLoSt;
+      }
     }
   },
 
@@ -1105,19 +1163,21 @@
   this.ensureScript = function(src) {
     this.actualScript = src;
     if (!Tobago.hasScript(this.actualScript)) {
+      LOG.debug("Lade script " + src);
       this.scriptElement = document.createElement('script');
       this.scriptElement.type = "text/javascript";
       this.scriptElement.src = src;
       if (typeof(this.scriptElement.onreadystatechange) != "undefined") {
 //        LOG.debug("Set script.onreadystatechange ");
-        this.scriptElement.onreadystatechange = this.stateReady.bind(this);
+        this.scriptElement.onreadystatechange = Tobago.bind(this, "stateReady");
       } else {
 //        LOG.debug("Set script.onload");
-        this.scriptElement.onload = this.stateOnLoad.bind(this);
+        this.scriptElement.onload = Tobago.bind(this, "stateOnLoad");
       }
       var head = document.getElementsByTagName('head')[0];
       head.appendChild(this.scriptElement);
     } else {
+      LOG.debug("found script " + src);
       this.ensureScripts();
     }
 
@@ -1149,18 +1209,27 @@
 //          if (this.actualScript.indexOf('tabgroup') > -1) {
 //      LOG.debug("doAfter=" + this.doAfter);
 //              }
+      this.executeCommands();
+//          } else {
+//              LOG.debug("doAfter = " + this.doAfter)
+//          }
+      delete this.scriptElement.onreadystatechange;
+      delete this.scriptElement.onload;
+      delete this.scriptElement;
+      delete this.actualScript;
+      delete this.names;
+      delete this.doAfter;
+      Tobago.startScriptLoaders();
+    }
+  };
+
+  this.executeCommands = function() {
       try {
         eval(this.doAfter);
       } catch(ex) {
         LOG.error(ex);
         LOG.error("errorCode: " + this.doAfter.valueOf());
       }
-
-//          } else {
-//              LOG.debug("doAfter = " + this.doAfter)
-//          }
-      Tobago.startScriptLoaders();
-    }
   };
 
   Tobago.addScriptLoader(this);
@@ -1227,3 +1296,4 @@
   };
 }
 
+TbgTimer.endTbgJs = new Date();
\ No newline at end of file