aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/controls.js3
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/effects.js2
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js46
3 files changed, 31 insertions, 20 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/controls.js b/actionpack/lib/action_view/helpers/javascripts/controls.js
index 94d438a784..4da9b52bc7 100644
--- a/actionpack/lib/action_view/helpers/javascripts/controls.js
+++ b/actionpack/lib/action_view/helpers/javascripts/controls.js
@@ -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
diff --git a/actionpack/lib/action_view/helpers/javascripts/effects.js b/actionpack/lib/action_view/helpers/javascripts/effects.js
index 82f1fd53ed..794c4b81a8 100644
--- a/actionpack/lib/action_view/helpers/javascripts/effects.js
+++ b/actionpack/lib/action_view/helpers/javascripts/effects.js
@@ -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);
-} \ No newline at end of file
+}
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) {