home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 February / Chip_2003-02_cd1.bin / firmy / acomw / js / dynlayer-common.js < prev    next >
Text File  |  2002-11-29  |  2KB  |  59 lines

  1. // Dynamic Layer Object Common Extensions
  2. // DynLayer write(), load(), setbg(), img() addon methods
  3. // 19990531
  4.  
  5. // Copyright (C) 1999 Dan Steinman
  6. // Distributed under the terms of the GNU Library General Public License
  7. // Available at http://www.dansteinman.com/dynapi/
  8.  
  9. // DynLayer Load Method
  10. // loads the contents of an external file into the layer
  11. function DynLayerLoad(url,fn) {
  12.     this.loadFinish = DynLayerLoadFinish
  13.     if (is.ns) this.css.load(url,this.w)
  14.     else if (is.ie) parent.bufferFrame.document.location = url
  15.     this.evalfn = fn
  16. }
  17. function DynLayerLoadFinish() {
  18.     if (is.ie) this.event.innerHTML = parent.bufferFrame.document.body.innerHTML
  19.     eval(this.evalfn)
  20. }
  21. DynLayer.prototype.load = DynLayerLoad
  22.  
  23. // DynLayer Set Background Method
  24. // changes the background (the layer must be clipped)
  25. function DynLayerSetbg(color) {
  26.     if (is.ns) this.doc.bgColor = color
  27.     else this.css.backgroundColor = color
  28. }
  29. DynLayer.prototype.setbg = DynLayerSetbg
  30.  
  31. // DynLayer ChangeImage Method
  32. // swaps an image in the layer
  33. function DynLayerImg(imgName,imgObj) {
  34.     this.doc.images[imgName].src = eval(imgObj+'.src')
  35. }
  36. DynLayer.prototype.img = DynLayerImg
  37.  
  38. // DynLayer GetRelative Methods
  39. // retrieves the real location of a relatively positioned layer
  40. function DynLayerGetRelativeX() {
  41.     return (is.ns)? this.css.pageX : this.elm.offsetLeft
  42. }
  43. function DynLayerGetRelativeY() {
  44.     return (is.ns)? this.css.pageY : this.elm.offsetTop
  45. }
  46. DynLayer.prototype.getRelativeX = DynLayerGetRelativeX
  47. DynLayer.prototype.getRelativeY = DynLayerGetRelativeY
  48.  
  49. // DynLayer GetContent Width/Height Methods
  50. // retrieves the total width/height of the contents of the layer when they are not known
  51. function DynLayerGetContentWidth() {
  52.     return (is.ns)? this.doc.width : this.elm.scrollWidth
  53. }
  54. function DynLayerGetContentHeight() {
  55.     return (is.ns)? this.doc.height : this.elm.scrollHeight
  56. }
  57. DynLayer.prototype.getContentWidth = DynLayerGetContentWidth
  58. DynLayer.prototype.getContentHeight = DynLayerGetContentHeight
  59.