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 2009/06/04 18:18:52 UTC

svn commit: r781790 - /myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js

Author: weber
Date: Thu Jun  4 16:18:52 2009
New Revision: 781790

URL: http://svn.apache.org/viewvc?rev=781790&view=rev
Log:
(TOBAGO-761) Tabgroup should support ppr
<https://issues.apache.org/jira/browse/TOBAGO-761>

Modified:
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js?rev=781790&r1=781789&r2=781790&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js Thu Jun  4 16:18:52 2009
@@ -25,6 +25,7 @@
 
   Tobago.element(this.tabGroupId).jsObject = this;
   Tobago.addJsObject(this);
+  Tobago.addAjaxComponent(this.tabGroupId, this);
 
   //  var htmlId = this.tabGroupId;
   //
@@ -112,7 +113,7 @@
       //LOG.error(element.id);
       var idPrefix = element.id.substring(0, element.id.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length);
       //LOG.error(idPrefix);
-      for (i = (this.activeIndex * 1) + 1; i < this.size; i++) {
+      for (var i = (this.activeIndex * 1) + 1; i < this.size; i++) {
         var id = idPrefix + i;
         var span = Tobago.element(id);
         if (span && span.className.indexOf('tobago-tab-disabled') == -1) {
@@ -123,22 +124,8 @@
       //this.activeIndex =
       //LOG.error("Request tab with index " + this.activeIndex);
 
-      var hidden = Tobago.element(this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex");
-      if (hidden) {
-        hidden.value = this.activeIndex;
-      }
-      else {
-        LOG.warn("No hidden field for tabindex Id='" + this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex" + "'");
-        LOG.warn("aId = " + aId);
-      }
-      if (Tobago.Updater.hasTransport()) {
-        var id = idPrefix + this.activeIndex;
-        this.removeRelatedAcceleratorKeys(id.substring(0, id.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length));
-        var container = Tobago.element(this.tabGroupId);
-        Tobago.Updater.update2(event.srcElement, container, Tobago.page, this.tabGroupId, this.tabGroupId, this.options);
-      } else {
-        Tobago.submitAction2(event.srcElement, this.tabGroupId, null, null);
-      }
+      this.doReload(event.srcElement, this.tabGroupId, this.options, idPrefix);
+
     }
   } else {
     LOG.info("No reload Event");
@@ -158,7 +145,7 @@
       //LOG.error(element.id);
       var idPrefix = element.id.substring(0, element.id.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length);
       //LOG.error(idPrefix);
-      for (i = this.activeIndex - 1; i >= 0; i--) {
+      for (var i = this.activeIndex - 1; i >= 0; i--) {
         var id = idPrefix + i;
         var span = Tobago.element(id);
         if (span && span.className.indexOf('tobago-tab-disabled') == -1) {
@@ -169,22 +156,7 @@
       //this.activeIndex =
       //LOG.error("Request tab with index " + this.activeIndex);
 
-      var hidden = Tobago.element(this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex");
-      if (hidden) {
-        hidden.value = this.activeIndex;
-      }
-      else {
-        LOG.warn("No hidden field for tabindex Id='" + this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex" + "'");
-        LOG.warn("aId = " + aId);
-      }
-      if (Tobago.Updater.hasTransport()) {
-        var id = idPrefix + this.activeIndex;
-        this.removeRelatedAcceleratorKeys(id.substring(0, id.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length));
-        var container = Tobago.element(this.tabGroupId);
-        Tobago.Updater.update2(event.srcElement, container, Tobago.page, this.tabGroupId, this.tabGroupId, this.options);
-      } else {
-        Tobago.submitAction2(event.srcElement, this.tabGroupId, null, null);
-      }
+      this.doReload(event.srcElement, this.tabGroupId, this.options, idPrefix);
     }
   } else {
     LOG.info("No reload Event");
@@ -205,21 +177,8 @@
       this.activeIndex = aId.substring(aId.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length);
       LOG.debug("Request tab with index " + this.activeIndex);
 
-      var hidden = Tobago.element(this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex");
-      if (hidden) {
-        hidden.value = this.activeIndex;
-      }
-      else {
-        LOG.warn("No hidden field for tabindex Id='" + this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex" + "'");
-        LOG.warn("aId = " + aId);
-      }
-      if (Tobago.Updater.hasTransport()) {
-        this.removeRelatedAcceleratorKeys(aId.substring(0, aId.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length));
-        var container = Tobago.element(this.tabGroupId);
-        Tobago.Updater.update2(event.srcElement, container, Tobago.page, this.tabGroupId, this.tabGroupId, this.options);
-      } else {
-        Tobago.submitAction2(event.srcElement, this.tabGroupId, null, null);
-      }
+      var idPrefix = aId.substring(0, aId.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length);
+      this.doReload(event.srcElement, this.tabGroupId, this.options, idPrefix);
     }
   } else {
     LOG.info("No reload Event");
@@ -227,6 +186,44 @@
 
 };
 
+Tobago.TabGroup.prototype.reloadWithAction2 = function(source, actionId, options) {
+  if (options) {
+    var onComplete = options.onComplete;
+    Tobago.extend(options, this.options);
+    options.onComplete = function() {
+      onComplete();
+      options.onComplete();
+    };
+  } else {
+    options = {};
+    Tobago.extend(options, this.options);
+  }
+
+  var element = Tobago.element(this.tabGroupId).firstChild;
+  this.activeIndex = element.id.substring(element.id.lastIndexOf(Tobago.SUB_COMPONENT_SEP2) + Tobago.SUB_COMPONENT_SEP2.length);
+  var idPrefix = element.id + Tobago.SUB_COMPONENT_SEP2;
+
+  this.doReload(source, actionId, options, idPrefix);
+};
+
+Tobago.TabGroup.prototype.doReload = function(srcElement, actionId, options, idPrefix) {
+  var hidden = Tobago.element(this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex");
+  if (hidden) {
+    hidden.value = this.activeIndex;
+  }
+  else {
+    LOG.warn("No hidden field for tabindex Id='" + this.tabGroupId + Tobago.SUB_COMPONENT_SEP2 + "activeIndex" + "'");
+    LOG.warn("idPrefix = " + idPrefix);
+  }
+  if (Tobago.Updater.hasTransport()) {
+    this.removeRelatedAcceleratorKeys(idPrefix);
+    var container = Tobago.element(this.tabGroupId);
+    Tobago.Updater.update2(srcElement, container, Tobago.page, actionId, this.tabGroupId, options);
+  } else {
+    Tobago.submitAction2(srcElement, actionId, null, null);
+  }
+};
+
 Tobago.TabGroup.prototype.removeRelatedAcceleratorKeys = function(idPrefix) {
   var regex = new RegExp("Tobago.clickOnElement\\([\"']" + idPrefix);
   for (var name in Tobago.acceleratorKeys) {