AdfRichUIPeer.createPeerClass(AdfDhtmlTableBasePeer, "AdfDhtmlTablePeer", false);
AdfDhtmlTablePeer.InitSubclass = function() {
  AdfRichUIPeer.addComponentEventHandlers(this, AdfComponentTouchEvent.TOUCH_START_EVENT_TYPE);
  AdfRichUIPeer.addComponentEventHandlers(this, AdfUIInputEvent.MOUSE_IN_EVENT_TYPE, AdfUIInputEvent.MOUSE_OUT_EVENT_TYPE);
  this._COLUMN_DATA_CELL_CLASS = "af|column::data-cell";
  this._COLUMN_BANDED_DATA_CELL_CLASS = "af|column::banded-data-cell";
};
AdfDhtmlTablePeer.prototype.__getColumnResizeMargin = function() {
  return 3;
};
AdfDhtmlTablePeer.prototype.HandleComponentMouseOver = function(componentEvent) {
  if (this._resizedTH || this._reorderTH) {
    return;
  }
  var agent = AdfAgent.AGENT;
  var target = componentEvent.getNativeEventTarget();
  if (this._scrollbarBehavior == AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE && this._scrollbarHidden) {
    var vscroller;
    var hscroller;
    if (this._hasSingleScroller() && !this._isPaged) {
      vscroller = this.GetScroller();
      hscroller = this.GetScroller();
    } else {
      vscroller = this.GetScroller()[AdfDhtmlTableBasePeer._VSCROLLER];
      hscroller = this.GetScroller()[AdfDhtmlTableBasePeer._HSCROLLER];
    }
    if (hscroller != null && hscroller != null) {
      var scrollerBarWidth = vscroller.offsetWidth - vscroller.clientWidth;
      var scrollerBarHeight = hscroller.offsetHeight - hscroller.clientHeight;
      var container = this.getDomElement();
      var databodyWrapper = agent.getElementById(AdfRichUIPeer.CreateSubId(container.id, AdfDhtmlTableBasePeer._DATAWRAPPER));
      if (databodyWrapper) {
        var databodyWrapperStyle = databodyWrapper.style;
        databodyWrapperStyle.width = container.offsetWidth - scrollerBarWidth - this._cachedScrollerWidthAddl + "px";
        databodyWrapperStyle.height = container.offsetHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight - scrollerBarHeight - this._cachedScrollerHeightAddl + "px";
        var colFooter = this._getColumnFooter();
        if (colFooter) {
          colFooter.style.width = container.offsetWidth - scrollerBarWidth - this._cachedScrollerWidthAddl + "px";
        }
        var databody = this.GetDataBody();
        if (this._isBottomLoadMoreDisplayed) {
          var bottomLoadMore = this._getLoadMore(false);
          databody.style.top = parseInt(this._hShiftLoadMoreDataBody) + parseInt(this._hShiftDataBody) + "px";
          bottomLoadMore.style.top = parseInt(this._hShiftLoadMoreDataBody) + parseInt(this._hShiftDataBody) + "px";
          bottomLoadMore.style.width = this._loadMoreAdjWidth;
        } else {
          if (this._isTopLoadMoreDisplayed) {
            var topLoadMore = this._getLoadMore(true);
            topLoadMore.style.width = this._loadMoreAdjWidth;
          } else {
            databody.style.top = this._hShiftDataBody;
          }
        }
        vscroller.style.visibility = "";
        hscroller.style.visibility = "";
        this._scrollbarHidden = false;
      }
    }
  }
  if (target != null) {
    var tagName = target.tagName;
    if ((tagName == "TD" || tagName == "TH") && target.noWrap && !target.title) {
      this.ApplyTooltipTitle(target);
    }
    this.SetCursorToText(document, target, tagName);
    if (this._hoverHighlightRow) {
      var attrs = this.GetRowKeyAndRow(target, this.getDomElement());
      if (attrs != null) {
        var row = attrs[1];
        if (!AdfDomUtils.containsCSSClassName(row, AdfDhtmlTableBasePeer._SELECTED_CLASS)) {
          AdfDomUtils.addCSSClassName(row, AdfDhtmlTableBasePeer._HIGHLIGHTED_CLASS);
        }
        return;
      }
    }
  }
  if (this._headerless) {
    return;
  }
  var th = this._getParentTH(componentEvent.getNativeEvent());
  if (th && th.colSpan < 2) {
    var siId = AdfRichUIPeer.CreateSubId(th.id, AdfDhtmlTableBasePeer.__SORT_INDICATOR);
    var siElem = agent.getElementById(siId);
    if (siElem == null) {
      return;
    }
    var sortedType = siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE);
    var supportsHover = siElem.getAttribute(AdfDhtmlTableBasePeer._SUPPORTS_HOVER);
    if (sortedType == null && supportsHover) {
      siElem.style.visibility = "";
    }
  }
};
AdfDhtmlTablePeer.prototype.SetCursorToText = function(document, target, tagName) {
  var dragSource = this.getComponent().getDragSource();
  if ((tagName == "TD" || tagName == "SPAN" || tagName == "NOBR") && target.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) == null && dragSource != null) {
    var laf = AdfPage.PAGE.getLookAndFeel();
    onlyTextNode = this._getOnlyTextNode(target);
    if (onlyTextNode) {
      var currNode = onlyTextNode.parentNode;
      if (currNode && currNode.nodeName == "SPAN" && (currNode.parentNode && currNode.parentNode.nodeName != "A")) {
        AdfDhtmlTableBasePeer.SetCursor(currNode, "text");
        if (dragSource) {
          currNode.setAttribute(AdfDhtmlTableBasePeer._CELL_TEXT_KEY, "on");
        }
      } else {
        if (currNode && currNode.nodeName == "TD" && (AdfDomUtils.containsCSSClassName(currNode, laf.getStyleClass(AdfDhtmlTablePeer._COLUMN_DATA_CELL_CLASS)) || AdfDomUtils.containsCSSClassName(currNode, laf.getStyleClass(AdfDhtmlTablePeer._COLUMN_BANDED_DATA_CELL_CLASS))) || currNode.nodeName == "NOBR") {
          var newSpan = document.createElement("span");
          newSpan.appendChild(document.createTextNode(onlyTextNode.nodeValue));
          AdfDhtmlTableBasePeer.SetCursor(newSpan, "text");
          if (dragSource) {
            newSpan.setAttribute(AdfDhtmlTableBasePeer._CELL_TEXT_KEY, "on");
          }
          var oldTextNode = currNode.replaceChild(newSpan, onlyTextNode);
          if (oldTextNode == null) {
            AdfLogger.LOGGER.fine("unable to replace child textnode '", onlyTextNode.nodeValue, "' with a span element '", newSpan, "for the current node ", currNode);
          }
        } else {
        }
      }
    }
  }
};
AdfDhtmlTablePeer.prototype.HandleComponentMouseOut = function(componentEvent) {
  if (this._resizedTH || this._reorderTH) {
    return;
  }
  var agent = AdfAgent.AGENT;
  if (this._scrollbarBehavior == AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE) {
    var container = this.getDomElement();
    var databodyWrapper = agent.getElementById(AdfRichUIPeer.CreateSubId(container.id, AdfDhtmlTableBasePeer._DATAWRAPPER));
    if (databodyWrapper) {
      var childEvent = false;
      var clientX = componentEvent.getNativeEvent().clientX;
      var clientY = componentEvent.getNativeEvent().clientY;
      var vscroller;
      var hscroller;
      if (this._hasSingleScroller() && !this._isPaged) {
        vscroller = this.GetScroller();
        hscroller = this.GetScroller();
      } else {
        vscroller = this.GetScroller()[AdfDhtmlTableBasePeer._VSCROLLER];
        hscroller = this.GetScroller()[AdfDhtmlTableBasePeer._HSCROLLER];
      }
      if (hscroller != null && hscroller != null && !this._scrollbarHidden) {
        var scrollerBarWidth = vscroller.offsetWidth - vscroller.clientWidth;
        var scrollerBarHeight = hscroller.offsetHeight - hscroller.clientHeight;
        var boundingRect = databodyWrapper.getBoundingClientRect();
        if (clientX > boundingRect.left + 1 && clientX < boundingRect.right - scrollerBarWidth - 1 && clientY > boundingRect.top + 1 && clientY < boundingRect.bottom - scrollerBarHeight - 1) {
          childEvent = true;
        }
        if (!childEvent) {
          var databodyWrapperStyle = databodyWrapper.style;
          databodyWrapperStyle.width = container.offsetWidth + "px";
          databodyWrapperStyle.height = container.offsetHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight + "px";
          var colFooter = this._getColumnFooter();
          if (colFooter) {
            colFooter.style.width = container.offsetWidth + "px";
          }
          var databody = this.GetDataBody();
          if (this._isBottomLoadMoreDisplayed) {
            var bottomLoadMore = this._getLoadMore(false);
            databody.style.top = this._hShiftLoadMoreDataBody;
            bottomLoadMore.style.top = this._hShiftLoadMoreDataBody;
            bottomLoadMore.style.width = this._loadMoreFullWidth;
          } else {
            if (this._isTopLoadMoreDisplayed) {
              var topLoadMore = this._getLoadMore(true);
              topLoadMore.style.width = this._loadMoreFullWidth;
            } else {
              databody.style.top = "0px";
            }
          }
          vscroller.style.visibility = "hidden";
          hscroller.style.visibility = "hidden";
          this._scrollbarHidden = true;
        }
      }
    }
  }
  if (this._hoverHighlightRow) {
    var attrs = this.GetRowKeyAndRow(componentEvent.getNativeEventTarget(), this.getDomElement());
    if (attrs != null) {
      AdfDomUtils.removeCSSClassName(attrs[1], AdfDhtmlTableBasePeer._HIGHLIGHTED_CLASS);
      return;
    }
  }
  if (this._headerless) {
    return;
  }
  var th = this._getParentTH(componentEvent.getNativeEvent());
  if (th && th.colSpan < 2) {
    this._hideColumnSortableIndicator(agent, th);
  }
};
AdfDhtmlTablePeer.prototype.HandleComponentTouchStart = function(componentEvent) {
  if (componentEvent.getTouchCount() == 1) {
    if (this.__isOwnComponentEvent(componentEvent)) {
      var headerAction = this.__getColumnHeaderMouseAction(componentEvent.getNativeEvent());
      var actionType = headerAction ? headerAction.type : null;
      if ("resize" == actionType) {
        AdfDhtmlTablePeer.superclass.__handleColumnResizing.call(this, componentEvent);
      }
    }
    var target = componentEvent.getNativeEventTarget();
    this.ApplyTooltipTitle(target);
  }
};
