diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-02 06:20:05 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-02 06:20:05 +0000 |
commit | 2f61c431fa3beecb532c0c58c83e47f9759e64a5 (patch) | |
tree | 156e4c226aa529b0deff3564d2b28fa10223e3d9 | |
parent | 6d64bbcc56bb2c1862ef4e6ef63db70f87b7bbe6 (diff) | |
download | rails-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
4 files changed, 36 insertions, 15 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 02b5073744..59fdffbcfa 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -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] diff --git a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js index 78f82bcd23..20432a3c88 100644 --- a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js +++ b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js @@ -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(); diff --git a/actionpack/lib/action_view/helpers/javascripts/effects.js b/actionpack/lib/action_view/helpers/javascripts/effects.js index 756c95cfeb..73accbd139 100644 --- a/actionpack/lib/action_view/helpers/javascripts/effects.js +++ b/actionpack/lib/action_view/helpers/javascripts/effects.js @@ -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) { 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 && |