Changeset 7209
- Timestamp:
- 07/22/07 20:01:24 (1 year ago)
- Files:
-
- spinoffs/scriptaculous/CHANGELOG (modified) (1 diff)
- spinoffs/scriptaculous/src/effects.js (modified) (3 diffs)
- spinoffs/scriptaculous/test/unit/effects_test.html (modified) (1 diff)
- spinoffs/scriptaculous/test/unit/element_test.html (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/scriptaculous/CHANGELOG
r7198 r7209 1 1 *SVN* 2 3 * Add support for full CSS inheritance in Effect.Morph. Closes #9054. [Tobie] 4 IMPORTANT: Note that this could potentially change the outcome of classname-based morphs, so be sure to check your morph effects if you use this feature. 5 For this feature, the new method Element#getStyles is introduced, which returns an objects which properties correspond to the CSS properties found in Element.CSS_PROPERTIES. Note that this method doesn't work seemlessly across browsers for certain non-measurable CSS properties, such as float. 2 6 3 7 * Add the externalControlOnly option to the in-place editors to allow for external controls to exclusively trigger the in-place editing. Closes #9024. [tdd] spinoffs/scriptaculous/src/effects.js
r6984 r7209 936 936 style: {} 937 937 }, arguments[1] || {}); 938 if (typeof options.style == 'string') { 939 if(options.style.indexOf(':') == -1) { 940 var cssText = '', selector = '.' + options.style; 941 $A(document.styleSheets).reverse().each(function(styleSheet) { 942 if (styleSheet.cssRules) cssRules = styleSheet.cssRules; 943 else if (styleSheet.rules) cssRules = styleSheet.rules; 944 $A(cssRules).reverse().each(function(rule) { 945 if (selector == rule.selectorText) { 946 cssText = rule.style.cssText; 947 throw $break; 948 } 949 }); 950 if (cssText) throw $break; 938 939 if (typeof options.style != 'string') this.style = $H(options.style); 940 else { 941 if (options.style.include(':')) 942 this.style = options.style.parseStyle(); 943 else { 944 this.element.addClassName(options.style); 945 this.style = $H(this.element.getStyles()); 946 this.element.removeClassName(options.style); 947 var css = this.element.getStyles(); 948 this.style = this.style.reject(function(style) { 949 return style.value == css[style.key]; 951 950 }); 952 this.style = cssText.parseStyle(); 953 options.afterFinishInternal = function(effect){ 951 options.afterFinishInternal = function(effect) { 954 952 effect.element.addClassName(effect.options.style); 955 953 effect.transforms.each(function(transform) { 956 if(transform.style != 'opacity') 957 effect.element.style[transform.style] = ''; 954 effect.element.style[transform.style] = ''; 958 955 }); 959 956 } 960 } else this.style = options.style.parseStyle();961 } else this.style = $H(options.style)957 } 958 } 962 959 this.start(options); 963 960 }, 961 964 962 setup: function(){ 965 963 function parseColor(color){ … … 1071 1069 }); 1072 1070 1073 if(Prototype.Browser.IE && this.in dexOf('opacity') > -1)1071 if(Prototype.Browser.IE && this.include('opacity')) 1074 1072 styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]; 1075 1073 1076 1074 return styleRules; 1077 1075 }; 1076 1077 if (document.defaultView && document.defaultView.getComputedStyle) { 1078 Element.getStyles = function(element) { 1079 var css = document.defaultView.getComputedStyle($(element), null); 1080 return Element.CSS_PROPERTIES.inject({}, function(styles, property) { 1081 styles[property] = css[property]; 1082 return styles; 1083 }); 1084 }; 1085 } else { 1086 Element.getStyles = function(element) { 1087 element = $(element); 1088 var css = element.currentStyle, styles; 1089 styles = Element.CSS_PROPERTIES.inject({}, function(hash, property) { 1090 hash[property] = css[property]; 1091 return hash; 1092 }); 1093 if (!styles.opacity) styles.opacity = element.getOpacity(); 1094 return styles; 1095 }; 1096 } 1078 1097 1079 1098 Effect.Methods = { … … 1107 1126 ); 1108 1127 1109 $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass ').each(1128 $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( 1110 1129 function(f) { Effect.Methods[f] = Element[f]; } 1111 1130 ); spinoffs/scriptaculous/test/unit/effects_test.html
r6981 r7209 22 22 color: #fff; 23 23 font-style: italic; 24 font-size: 20px;25 24 background: #000; 26 25 opacity: 0.5; 26 } 27 body div.final { 28 font-size: 20px; 27 29 } 28 30 </style> spinoffs/scriptaculous/test/unit/element_test.html
r6387 r7209 13 13 blah { color:rgb(0, 255, 0); } 14 14 #op2 { opacity:0.5;filter:alpha(opacity=50)progid:DXImageTransform.Microsoft.Blur(strength=10);} 15 #allStyles_1 {font-size: 12px;} 16 #allStyles_2 {opacity:0.5; filter:alpha(opacity=50);} 17 #allStyles_3 {opacity:0.5;} 15 18 </style> 16 19 </head> … … 59 62 60 63 <div id="perftest1"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div> 61 64 <div id="allStyles_1"></div> 65 <div id="allStyles_2"></div> 66 <div id="allStyles_3"></div> 62 67 <!-- Tests follow --> 63 68 <script type="text/javascript" language="javascript" charset="utf-8"> … … 96 101 "font:12px/15pt Verdana;opacity:0.4;border:4px dotted red".parseStyle(); 97 102 },100); 103 }}, 104 105 testGetStyles: function() { with(this) { 106 assertEqual('12px', $('allStyles_1').getStyles().fontSize); 107 assertEqual(1, parseFloat($('allStyles_1').getStyles().opacity)); 108 assertEqual(0.5, parseFloat($('allStyles_2').getStyles().opacity)); 109 assertEqual(0.5, parseFloat($('allStyles_3').getStyles().opacity)); 98 110 }} 99 111