705b565b96cf80c0eee453f937e89a2b5552298c.svn-base 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. if (!dojo._hasResource["dijit._base.scroll"]) { // _hasResource checks added by
  2. // build. Do not use
  3. // _hasResource directly in your
  4. // code.
  5. dojo._hasResource["dijit._base.scroll"] = true;
  6. dojo.provide("dijit._base.scroll");
  7. dijit.scrollIntoView = function(/* DomNode */node) {
  8. // summary
  9. // Scroll the passed node into view, if it is not.
  10. // don't rely on that node.scrollIntoView works just because the
  11. // function is there
  12. // it doesnt work in Konqueror or Opera even though the function is
  13. // there and probably
  14. // not safari either
  15. // dont like browser sniffs implementations but sometimes you have to
  16. // use it
  17. if (dojo.isIE) {
  18. // only call scrollIntoView if there is a scrollbar for this menu,
  19. // otherwise, scrollIntoView will scroll the window scrollbar
  20. if (dojo.marginBox(node.parentNode).h <= node.parentNode.scrollHeight) { // PORT
  21. // was
  22. // getBorderBox
  23. node.scrollIntoView(false);
  24. }
  25. } else if (dojo.isMozilla) {
  26. node.scrollIntoView(false);
  27. } else {
  28. var parent = node.parentNode;
  29. var parentBottom = parent.scrollTop + dojo.marginBox(parent).h; // PORT
  30. // was
  31. // getBorderBox
  32. var nodeBottom = node.offsetTop + dojo.marginBox(node).h;
  33. if (parentBottom < nodeBottom) {
  34. parent.scrollTop += (nodeBottom - parentBottom);
  35. } else if (parent.scrollTop > node.offsetTop) {
  36. parent.scrollTop -= (parent.scrollTop - node.offsetTop);
  37. }
  38. }
  39. };
  40. }