Permalink
Browse files

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
  • Loading branch information...
1 parent 930b59e commit c9f2389c010ba9364a4454b45b3cedd4dd273c38 @dhh dhh committed Jun 26, 2005
@@ -93,6 +93,7 @@ Ajax.Autocompleter.prototype = (new Ajax.Base()).extend({
onComplete: function(request) {
if(!this.changed) {
this.update.innerHTML = request.responseText;
+ Element.cleanWhitespace(this.update.firstChild);
if(this.update.firstChild && this.update.firstChild.childNodes) {
this.entry_count =
@@ -131,10 +132,12 @@ Ajax.Autocompleter.prototype = (new Ajax.Base()).extend({
case Event.KEY_UP:
this.mark_previous();
this.render();
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
return;
case Event.KEY_DOWN:
this.mark_next();
this.render();
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
return;
}
else
@@ -554,4 +554,4 @@ Element.setContentZoom = function(element, percent) {
element.style.fontSize = sizeEm*(percent/100) + "em";
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
-}
+}
@@ -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) {

0 comments on commit c9f2389

Please sign in to comment.