Permalink
Browse files

Update to Prototype 1.5.2_rc0 r7048. Fixes a rendering issue with opa…

…city-based effects and floating elements on Safari.

git-svn-id: http://svn.rubyonrails.org/rails/spinoffs/scriptaculous@7049 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 58c1873 commit 86d62cfbd90ca07c7469fdea1bbe68d0fc4b5907 @madrobby madrobby committed Jun 17, 2007
Showing with 51 additions and 13 deletions.
  1. +2 −0 CHANGELOG
  2. +39 −11 lib/prototype.js
  3. +10 −2 test/functional/effects_float_appear_test.html
View
@@ -1,5 +1,7 @@
*SVN*
+* Update to Prototype 1.5.2_rc0 r7048. Fixes a rendering issue with opacity-based effects and floating elements on Safari.
+
* Mild refactoring of sound.js to take advantage of new Prototype features.
* Add highlight element method as a shortcut to Effect.Highlight.
View
@@ -24,8 +24,8 @@ var Prototype = {
document.createElement('form').__proto__)
},
- ScriptFragment: '<script[^>]*>([\u0001-\uFFFF]*?)<\/script>',
- JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/,
+ ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
+ JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function() { },
K: function(x) { return x }
@@ -373,11 +373,15 @@ Object.extend(String.prototype, {
return this.sub(filter || Prototype.JSONFilter, '#{1}');
},
+ isJSON: function() {
+ var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
+ return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
+ },
+
evalJSON: function(sanitize) {
var json = this.unfilterJSON();
try {
- if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json)))
- return eval('(' + json + ')');
+ if (!sanitize || json.isJSON()) return eval('(' + json + ')');
} catch (e) { }
throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
},
@@ -872,6 +876,13 @@ Object.extend(Hash.prototype, {
return this.pluck('value');
},
+ index: function(value) {
+ var match = this.detect(function(pair) {
+ return pair.value === value;
+ });
+ return match && match.key;
+ },
+
merge: function(hash) {
return $H(hash).inject(this, function(mergedHash, pair) {
mergedHash[pair.key] = pair.value;
@@ -2080,6 +2091,23 @@ else if (Prototype.Browser.Gecko) {
}
else if (Prototype.Browser.WebKit) {
+ Element.Methods.setOpacity = function(element, value) {
+ element = $(element);
+ element.style.opacity = (value == 1 || value === '') ? '' :
+ (value < 0.00001) ? 0 : value;
+
+ if (value == 1)
+ if(element.tagName == 'IMG' && element.width) {
+ element.width++; element.width--;
+ } else try {
+ var n = document.createTextNode(' ');
+ element.appendChild(n);
+ element.removeChild(n);
+ } catch (e) {}
+
+ return element;
+ }
+
// Safari returns margins on body which is incorrect if the child is absolutely
// positioned. For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
@@ -2197,6 +2225,13 @@ Element.Methods.ByTag = {};
Object.extend(Element, Element.Methods);
+if (!Prototype.BrowserFeatures.ElementExtensions &&
+ document.createElement('div').__proto__) {
+ window.HTMLElement = {};
+ window.HTMLElement.prototype = document.createElement('div').__proto__;
+ Prototype.BrowserFeatures.ElementExtensions = true;
+}
+
Element.extend = (function() {
if (Prototype.BrowserFeatures.SpecificElementExtensions)
return Prototype.K;
@@ -2236,13 +2271,6 @@ Element.extend = (function() {
return extend;
})();
-if (!Prototype.BrowserFeatures.ElementExtensions &&
- document.createElement('div').__proto__) {
- window.HTMLElement = {};
- window.HTMLElement.prototype = document.createElement('div').__proto__;
- Prototype.BrowserFeatures.ElementExtensions = true;
-}
-
Element.hasAttribute = function(element, attribute) {
if (element.hasAttribute) return element.hasAttribute(attribute);
return Element.Methods.Simulated.hasAttribute(element, attribute);
@@ -15,7 +15,11 @@
</p>
<a href="#" onclick="Effect.Appear('float_div_left'); return false;">float:left</a> |
-<a href="#" onclick="Effect.Appear('float_div_right'); return false;">float:right</a>
+<a href="#" onclick="Effect.Appear('float_div_right'); return false;">float:right</a> |
+<a href="#" onclick="$('float_div_right').setOpacity(1)">float:right (setOpacity 1)</a> |
+<a href="#" onclick="Effect.Appear('icon'); return false;">image (non-floating)</a> |
+<a href="#" onclick="Effect.Appear('float_icon'); return false;">image (floating)</a> |
+<a href="#" onclick="$('float_icon').setOpacity(1);">image (setOpacity 1)</a>
<hr/>
@@ -26,13 +30,17 @@
ut labore et dolore magna aliqua.
</div>
-<div id="float_div_right" style="float:right;display:none">
+<div id="float_div_right" style="float:right;opacity:0.4">
Lorem ipsum dolor sit amet,<br/>
consectetur adipisicing elit,<br/>
sed do eiusmod tempor incididunt<br/>
ut labore et dolore magna aliqua.
</div>
+<img id="icon" src="icon.png" style="display:none" alt="" />
+
+<img id="float_icon" src="icon.png" style="float:left;opacity:0.4" alt="" />
+
</body>
</html>

0 comments on commit 86d62cf

Please sign in to comment.