Permalink
Browse files

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
  • Loading branch information...
1 parent 6d64bbc commit 2f61c431fa3beecb532c0c58c83e47f9759e64a5 @dhh dhh committed Jul 2, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Added evaluation of <SCRIPT> blocks in content returned to Ajax calls #1577 [Thomas Fuchs/court3nay]
+
* Directly generate paths with a leading slash instead of tacking it on later. #1543 [Nicholas Seckar]
* Fixed errant parameter modification in functional tests. #1542 [Nicholas Seckar]
@@ -111,7 +111,6 @@ Element.Class = {
var Droppables = {
drops: false,
- include_scroll_offsets: false,
add: function(element) {
var element = $(element);
@@ -180,7 +179,7 @@ var Droppables = {
if(!this.drops) return;
var pX = Event.pointerX(event);
var pY = Event.pointerY(event);
- if(this.include_scroll_offsets) Position.prepare();
+ Position.prepare();
var i = this.drops.length-1; do {
var drop = this.drops[i];
@@ -200,7 +199,7 @@ var Droppables = {
if(!this.drops) return;
var pX = Event.pointerX(event);
var pY = Event.pointerY(event);
- if(this.include_scroll_offsets) Position.prepare();
+ Position.prepare();
var i = this.drops.length-1; do {
var drop = this.drops[i];
@@ -251,6 +250,10 @@ Draggable.prototype = {
this.element.drag = this;
this.handle = options.handle ? $(options.handle) : this.element;
+ // fix IE
+ if(!this.element.style.position)
+ this.element.style.position = 'relative';
+
this.offsetX = 0;
this.offsetY = 0;
this.originalLeft = this.currentLeft();
@@ -124,6 +124,9 @@ Effect.Parallel = Class.create();
}
});
+// Internet Explorer caveat: works only on elements the have
+// a 'layout', meaning having a given width or height.
+// There is no way to safely set this automatically.
Effect.Opacity = Class.create();
Effect.Opacity.prototype = (new Effect.Base()).extend({
initialize: function(element) {
@@ -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 &&

0 comments on commit 2f61c43

Please sign in to comment.