diff options
Diffstat (limited to 'actionpack')
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 && |