PageRenderTime 70ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Documentation/Help/scripts/SplitScreen.js

#
JavaScript | 35 lines | 18 code | 12 blank | 5 comment | 3 complexity | 92bc48ef6e57b68262f336747bf80134 MD5 | raw file
Possible License(s): MIT
  1. function SplitScreen (nonScrollingRegionId, scrollingRegionId) {
  2. // store references to the two regions
  3. this.nonScrollingRegion = document.getElementById(nonScrollingRegionId);
  4. this.scrollingRegion = document.getElementById(scrollingRegionId);
  5. // set the position model for each region
  6. this.nonScrollingRegion.style.position = "fixed";
  7. this.scrollingRegion.style.position = "absolute";
  8. // fix the size of the scrolling region
  9. this.resize(null);
  10. // add an event handler to resize the scrolling region when the window is resized
  11. registerEventHandler(window, 'resize', getInstanceDelegate(this, "resize"));
  12. }
  13. SplitScreen.prototype.resize = function(e) {
  14. if(navigator.userAgent.indexOf("Firefox")==-1)
  15. {
  16. var height = document.body.clientHeight - this.nonScrollingRegion.offsetHeight;
  17. if(height > 0) this.scrollingRegion.style.height = height + "px";
  18. else this.scrollingRegion.style.height = 0 + "px";
  19. this.scrollingRegion.style.width = document.body.clientWidth + "px";
  20. }
  21. // update the vertical offset of the scrolling region to account for the height of the non-scrolling region
  22. this.scrollingRegion.style.top = this.nonScrollingRegion.offsetHeight + "px";
  23. }