diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-26 17:23:38 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-26 17:23:38 +0000 |
commit | c9f2389c010ba9364a4454b45b3cedd4dd273c38 (patch) | |
tree | 1c3c83f051dbef3f3024e2e42dc31b22bd12f23a /actionpack/lib/action_view/helpers/javascripts/prototype.js | |
parent | 930b59eb39e2078ae83159d72dee9389ecc04897 (diff) | |
download | rails-c9f2389c010ba9364a4454b45b3cedd4dd273c38.tar.gz rails-c9f2389c010ba9364a4454b45b3cedd4dd273c38.tar.bz2 rails-c9f2389c010ba9364a4454b45b3cedd4dd273c38.zip |
Update script.aculo.us scripts to fix some bugs #1515
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1528 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/javascripts/prototype.js')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascripts/prototype.js | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js index 1ebb2a46b7..9b0e02cf80 100644 --- a/actionpack/lib/action_view/helpers/javascripts/prototype.js +++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js @@ -791,41 +791,49 @@ var Position = { return [valueL, valueT]; }, + cumulative_offset: function(element) { + var valueT = 0; var valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + } while(element); + return [valueL, valueT]; + }, + // caches x/y coordinate pair to use with overlap within: function(element, x, y) { if(this.include_scroll_offsets) - return within_including_scrolloffsets(element, x, y); + return this.within_including_scrolloffsets(element, x, y); this.xcomp = x; this.ycomp = y; - var offsettop = element.offsetTop; - var offsetleft = element.offsetLeft; - return (y>=offsettop && - y<offsettop+element.offsetHeight && - x>=offsetleft && - x<offsetleft+element.offsetWidth); + this.offset = this.cumulative_offset(element); + + return (y>=this.offset[1] && + y<this.offset[1]+element.offsetHeight && + x>=this.offset[0] && + x<this.offset[0]+element.offsetWidth); }, within_including_scrolloffsets: function(element, x, y) { var offsetcache = this.real_offset(element); - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.xcomp = x; - this.ycomp = y; - var offsettop = element.offsetTop; - var offsetleft = element.offsetLeft; - return (y>=offsettop && - y<offsettop+element.offsetHeight && - x>=offsetleft && - x<offsetleft+element.offsetWidth); + this.offset = this.cumulative_offset(element); + this.xcomp = x + offsetcache[0] - this.deltaX + this.offset[0]; + this.ycomp = y + offsetcache[1] - this.deltaY + this.offset[1]; + + return (this.ycomp>=this.offset[1] && + this.ycomp<this.offset[1]+element.offsetHeight && + this.xcomp>=this.offset[0] && + this.xcomp<this.offset[0]+element.offsetWidth); }, // within must be called directly before overlap: function(mode, element) { if(!mode) return 0; if(mode == 'vertical') - return ((element.offsetTop+element.offsetHeight)-this.ycomp) / element.offsetHeight; + return ((this.offset[1]+element.offsetHeight)-this.ycomp) / element.offsetHeight; if(mode == 'horizontal') - return ((element.offsetLeft+element.offsetWidth)-this.xcomp) / element.offsetWidth; + return ((this.offset[0]+element.offsetWidth)-this.xcomp) / element.offsetWidth; }, clone: function(source, target) { |