aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/javascripts/prototype.js
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-02 06:20:05 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-02 06:20:05 +0000
commit2f61c431fa3beecb532c0c58c83e47f9759e64a5 (patch)
tree156e4c226aa529b0deff3564d2b28fa10223e3d9 /actionpack/lib/action_view/helpers/javascripts/prototype.js
parent6d64bbcc56bb2c1862ef4e6ef63db70f87b7bbe6 (diff)
downloadrails-2f61c431fa3beecb532c0c58c83e47f9759e64a5.tar.gz
rails-2f61c431fa3beecb532c0c58c83e47f9759e64a5.tar.bz2
rails-2f61c431fa3beecb532c0c58c83e47f9759e64a5.zip
Added evaluation of <SCRIPT> blocks in content returned to Ajax calls #1577 [Thomas Fuchs/court3nay]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1597 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.js37
1 files changed, 25 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index 9225f13125..4946ec0b70 100644
--- a/actionpack/lib/action_view/helpers/javascripts/prototype.js
+++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -225,9 +225,13 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
'X-Requested-With', 'XMLHttpRequest',
'X-Prototype-Version', Prototype.Version];
- if (this.options.method == 'post')
- requestHeaders.push(//'Connection', 'close',
+ if (this.options.method == 'post') {
+ requestHeaders.push(
'Content-type', 'application/x-www-form-urlencoded');
+ if(navigator.userAgent.indexOf('Gecko')>0)
+ requestHeaders.push(
+ 'Connection', 'close');
+ }
if (this.options.requestHeaders)
requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
@@ -255,13 +259,13 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
});
Ajax.Updater = Class.create();
-Ajax.Updater.ScriptFragmentMatch = /<script.*?>((?:\n|.)*?)<\/script>/im;
+Ajax.Updater.ScriptFragmentMatch = /<script.*?>((?:\n|.)*?)<\/script>/img;
Ajax.Updater.prototype = (new Ajax.Base()).extend({
initialize: function(container, url, options) {
this.containers = {
success: container.success ? $(container.success) : $(container),
- failure: container.failure ? $(container.failure) : null
+ failure: container.failure ? $(container.failure) : $(container)
}
this.setOptions(options);
@@ -296,14 +300,17 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
}
}
- if (this.request.transport.status == 200) {
+ if (this.request.transport.status == 200)
if (this.onComplete)
setTimeout((function() {this.onComplete(
this.request.transport)}).bind(this), 10);
-
- if (this.options.evalScripts && scripts)
- setTimeout((function() {eval(scripts[1])}).bind(this), 10);
- }
+
+ if (this.options.evalScripts && scripts)
+ setTimeout( (function() {
+ for(var i=0;i<scripts.length;i++)
+ eval(scripts[i].replace(/^<script.*?>/,'').replace(/<\/script>$/,''));
+ } ).bind(this), 10);
+
}
});
@@ -914,6 +921,12 @@ Object.extend(Event, {
});
var Position = {
+
+ // set to true if needed, warning: firefox performance problems
+ // NOT neeeded for page scrolling, only if draggable contained in
+ // scrollable elements
+ includeScrollOffsets: false,
+
// must be called before calling withinIncludingScrolloffset, every time the
// page is scrolled
prepare: function() {
@@ -925,7 +938,6 @@ var Position = {
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
- this.includeScrollOffsets = true;
},
realOffset: function(element) {
@@ -964,9 +976,10 @@ var Position = {
withinIncludingScrolloffsets: function(element, x, y) {
var offsetcache = this.realOffset(element);
+
+ this.xcomp = x + offsetcache[0] - this.deltaX;
+ this.ycomp = y + offsetcache[1] - this.deltaY;
this.offset = this.cumulativeOffset(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 &&