Permalink
Browse files

Fixed Effect.Appear in effects.js to work with floats in Safari (closes

#3524, #3813, #3044) [Thomas Fuchs]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3757 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 964b67d commit e3bfd08cbcbffddf53de4f0f6030a794402cf532 @dhh dhh committed Mar 4, 2006
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed Effect.Appear in effects.js to work with floats in Safari #3524, #3813, #3044 [Thomas Fuchs]
+
* Fixed that default image extension was not appended when using a full URL with AssetTagHelper#image_tag #4032, #3728 [rubyonrails@beautifulpixel.com]
* Added that page caching will only happen if the response code is less than 400 #4033 [g.bucher@teti.ch]
View
@@ -115,11 +115,13 @@ end
# Publishing ------------------------------------------------------
task :update_scriptaculous do
- system("svn export --force http://dev.rubyonrails.org/svn/rails/spinoffs/scriptaculous/src/ #{File.dirname(__FILE__)}/lib/action_view/helpers/javascripts/")
+ for js in %w( controls dragdrop effects )
+ system("svn export --force http://dev.rubyonrails.org/svn/rails/spinoffs/scriptaculous/src/#{js} #{File.dirname(__FILE__)}/lib/action_view/helpers/javascripts/")
+ end
end
desc "Updates actionpack to the latest version of the javascript spinoffs"
-task :update_js => [:update_scriptaculous]
+task :update_js => [ :update_scriptaculous ]
# Publishing ------------------------------------------------------
@@ -85,6 +85,12 @@ Element.childrenWithClassName = function(element, className) {
function(c) { return Element.hasClassName(c, className) });
}
+Element.forceRerendering = function(element) {
+ var n = document.createTextNode(' ');
+ $(element).appendChild(n);
+ Element.remove(n);
+}
+
Array.prototype.call = function() {
var args = arguments;
this.each(function(f){ f.apply(this, args) });
@@ -545,6 +551,10 @@ Effect.Appear = function(element) {
var options = Object.extend({
from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
to: 1.0,
+ // force Safari to render floated elements properly
+ afterFinishInternal: function(effect) {
+ Element.forceRerendering(effect.element);
+ },
beforeSetup: function(effect) { with(Element) {
setOpacity(effect.element, effect.options.from);
show(effect.element); }}
View
@@ -75,7 +75,7 @@ end
desc "Updates railties to the latest version of the javascript spinoffs"
task :update_js do
- for js in %w( prototype controls dragdrop effects slider )
+ for js in %w( prototype controls dragdrop effects )
rm "html/javascripts/#{js}.js"
cp "./../actionpack/lib/action_view/helpers/javascripts/#{js}.js", "html/javascripts"
end
@@ -85,6 +85,12 @@ Element.childrenWithClassName = function(element, className) {
function(c) { return Element.hasClassName(c, className) });
}
+Element.forceRerendering = function(element) {
+ var n = document.createTextNode(' ');
+ $(element).appendChild(n);
+ Element.remove(n);
+}
+
Array.prototype.call = function() {
var args = arguments;
this.each(function(f){ f.apply(this, args) });
@@ -545,6 +551,10 @@ Effect.Appear = function(element) {
var options = Object.extend({
from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
to: 1.0,
+ // force Safari to render floated elements properly
+ afterFinishInternal: function(effect) {
+ Element.forceRerendering(effect.element);
+ },
beforeSetup: function(effect) { with(Element) {
setOpacity(effect.element, effect.options.from);
show(effect.element); }}
@@ -942,17 +942,17 @@ Object.extend(Element, {
setTimeout(function() {html.evalScripts()}, 10);
},
- replace: function(element, html) {
- element = $(element);
- if (element.outerHTML) {
- element.outerHTML = html.stripScripts();
- } else {
- var range = element.ownerDocument.createRange();
- range.selectNodeContents(element);
- element.parentNode.replaceChild(
- range.createContextualFragment(html.stripScripts()), element);
- }
- setTimeout(function() {html.evalScripts()}, 10);
+ replace: function(element, html) {
+ element = $(element);
+ if (element.outerHTML) {
+ element.outerHTML = html.stripScripts();
+ } else {
+ var range = element.ownerDocument.createRange();
+ range.selectNodeContents(element);
+ element.parentNode.replaceChild(
+ range.createContextualFragment(html.stripScripts()), element);
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
},
getHeight: function(element) {
@@ -1317,7 +1317,7 @@ var Field = {
$(arguments[i]).value = '';
},
- focus: function(element) {
+ focus: function(element) {
$(element).focus();
},
@@ -1551,15 +1551,16 @@ Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
Abstract.EventObserver = function() {}
Abstract.EventObserver.prototype = {
- initialize: function(element, callback) {
- this.element = $(element);
- this.callback = callback;
+ initialize: function() {
+ this.element = $(arguments[0]);
+ this.callback = arguments[1];
+ this.trigger = arguments[2];
this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
- this.registerCallback(this.element);
+ this.registerCallback(this.element, this.trigger);
},
onElementEvent: function() {
@@ -1573,11 +1574,13 @@ Abstract.EventObserver.prototype = {
registerFormCallbacks: function() {
var elements = Form.getElements(this.element);
for (var i = 0; i < elements.length; i++)
- this.registerCallback(elements[i]);
+ this.registerCallback(elements[i], this.trigger);
},
- registerCallback: function(element) {
- if (element.type) {
+ registerCallback: function(element, trigger) {
+ if (trigger && element.type) {
+ Event.observe(element, trigger, this.onElementEvent.bind(this));
+ } else if (element.type) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':

0 comments on commit e3bfd08

Please sign in to comment.