Changeset 2764
- Timestamp:
- 10/27/05 14:14:36 (3 years ago)
- Files:
-
- spinoffs/scriptaculous/CHANGELOG (modified) (1 diff)
- spinoffs/scriptaculous/src/effects.js (modified) (6 diffs)
- spinoffs/scriptaculous/test/functional/effects4_test.html (modified) (1 diff)
- spinoffs/scriptaculous/test/unit/effects_test.html (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/scriptaculous/CHANGELOG
r2760 r2764 1 1 *SVN* 2 3 * Make Effect.Queue an Enumerable, fix a problem with Effect.Grow, more unit tests 2 4 3 5 * Added restricted option to prevent moved of handles prior/after adjacent handles on Sliders with multiple handles spinoffs/scriptaculous/src/effects.js
r2708 r2764 24 24 return(color.length==7 ? color : (arguments[0] || this)); 25 25 } 26 26 27 27 Element.collectTextNodesIgnoreClass = function(element, ignoreclass) { 28 28 var children = $(element).childNodes; … … 39 39 } 40 40 41 return text; 42 } 43 41 return text; 42 } 43 44 44 Element.setContentZoom = function(element, percent) { 45 45 element = $(element); 46 46 element.style.fontSize = (percent/100) + "em"; 47 47 if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); 48 } 49 48 } 49 50 50 Element.getOpacity = function(element){ 51 51 var opacity; … … 55 55 if(opacity[1]) return parseFloat(opacity[1]) / 100; 56 56 return 1.0; 57 } 58 57 } 58 59 59 Element.setOpacity = function(element, value){ 60 60 element= $(element); … … 257 257 Effect.Queue = { 258 258 effects: [], 259 _each: function(iterator) { 260 this.effects._each(iterator); 261 }, 259 262 interval: null, 260 263 add: function(effect) { … … 293 296 } 294 297 } 298 Object.extend(Effect.Queue, Enumerable); 295 299 296 300 Effect.Base = function() {}; … … 873 877 els.left = oldLeft; 874 878 els.height = oldHeight; 875 els.width = originalWidth ;879 els.width = originalWidth + 'px'; 876 880 Element.setInlineOpacity(el, oldOpacity); 877 881 } spinoffs/scriptaculous/test/functional/effects4_test.html
r1990 r2764 18 18 <h1>script.aculo.us Effects functional test file</h1> 19 19 20 <h2>Effect2.Highlight</h2> 20 <a href="#" onclick="new Effect.Highlight('d1',{duration:1.5}); return false;">Highlight</a> | 21 <a href="#" onclick="new Effect.BlindUp('d1',{duration:1.5}); return false;">BlindUp</a> | 22 <a href="#" onclick="new Effect.BlindDown('d1',{duration:1.5}); return false;">BlindDown</a> | 23 <a href="#" onclick="new Effect.SlideUp('d1',{duration:1.5}); return false;">SlideUp</a> | 24 <a href="#" onclick="new Effect.SlideDown('d1',{duration:1.5}); return false;">SlideDown</a> 21 25 22 <a href="#" onclick="new Effect.Highlight('d1',{duration:1.5}); return false;">Highlight</a> 23 24 <div id="d1"> 25 <p> 26 <div id="d1"><div style="overflow:hidden"> 26 27 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas enim. Nulla facilisi. Vestibulum accumsan augue vulputate justo. Fusce faucibus. Sed blandit, neque sed lacinia nonummy, diam quam imperdiet justo, at dictum augue nunc a neque. Sed urna lacus, tincidunt at, aliquam id, fringilla id, felis. Vivamus feugiat molestie quam. Sed id dolor. Sed ac purus id sapien sollicitudin ultricies. Aliquam hendrerit orci et odio. Suspendisse volutpat wisi at sem. Integer eget nulla. Duis eu diam a nunc condimentum tempus. Praesent gravida metus vitae massa. Aliquam neque magna, fringilla eu, porta id, interdum sit amet, dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin lorem est, ultrices sit amet, condimentum vitae, vehicula a, massa. 27 </p> 28 </div> 28 </div></div> 29 29 30 30 </body> spinoffs/scriptaculous/test/unit/effects_test.html
r2502 r2764 32 32 ['Fade','Appear','BlindUp','BlindDown','Puff','SwitchOff','DropOut','Shake', 33 33 'SlideUp','SlideDown','Pulsate','Squish','Fold','Grow','Shrink']; 34 35 var tmp, tmp2; 34 36 35 37 new Test.Unit.Runner({ … … 37 39 setup: function() { with (this) { 38 40 $('sandbox').innerHTML = ""; 41 }}, 42 43 teardown: function() { with(this) { 44 // remove all queued effects 45 Effect.Queue.each(function(e) { e.cancel() }); 46 }}, 47 48 testBackwardsCompat: function() { with(this) { 49 assertInstanceOf(Effect.Opacity, new Effect2.Fade('sandbox')); 50 }}, 51 52 testCallbacks: function() { with(this) { 53 tmp = tmp2 = 0; 54 var e1 = new Effect.Opacity('sandbox',{from:1.0,to:0.5,duration:0.5, 55 beforeStart: function() { tmp++ }, 56 beforeStartInternal: function() { tmp++ }, 57 beforeSetup: function() { tmp++ }, 58 beforeSetupInternal: function() { tmp++ }, 59 afterSetup: function() { tmp++ }, 60 afterSetupInternal: function() { tmp++ }, 61 beforeUpdate: function() { tmp2++ }, 62 beforeUpdateInternal: function() { tmp2++ }, 63 beforeFinish: function() { tmp++ }, 64 beforeFinishInternal: function() { tmp++ }, 65 afterFinish: function() { tmp++ }, 66 afterFinishInternal: function() { tmp++ } 67 }); 68 wait(1000, function() { 69 assertEqual(10, tmp); 70 assert(tmp2 > 0); 71 }); 72 }}, 73 74 testEffectsQueue: function() { with(this) { 75 var e1 = new Effect.Highlight('sandbox'); 76 var e2 = new Effect.Appear('sandbox'); 77 78 assertEqual(2, Effect.Queue.effects.length); 79 80 tmp = 0; 81 Effect.Queue.each(function(e) { tmp++ }); 82 assertEqual(2, tmp); 83 84 // the internal interval timer should be active 85 assertNotNull(Effect.Queue.interval); 86 e1.cancel(); 87 e2.cancel(); 88 assertEqual(0, Effect.Queue.effects.length); 89 90 // should be inactive after all effects are removed from queue 91 assertNull(Effect.Queue.interval); 92 93 // should be in e3,e1,e2 order 94 var e1 = new Effect.Highlight('sandbox'); 95 var e2 = new Effect.Appear('sandbox',{queue:'end'}); 96 var e3 = new Effect.Fade('sandbox',{queue:'front'}); 97 assert(e2.startOn > e1.startOn); 98 assert(e3.startOn < e1.startOn); 99 assert(e3.startOn < e2.startOn); 100 assertEqual(3, Effect.Queue.effects.length); 101 102 Effect.Queue.each(function(e) { e.cancel() }); 103 assertEqual(0, Effect.Queue.effects.length); 104 }}, 105 106 testEffectMultiple: function() { with(this) { 107 $('sandbox').appendChild(Builder.node('div',{id:'test_1'})); 108 $('sandbox').appendChild(Builder.node('div',{id:'test_2'},[Builder.node('div',{id:'test_2a'})])); 109 $('sandbox').appendChild(Builder.node('div',{id:'test_3'})); 110 111 // only direct child elements 112 Effect.multiple('sandbox',Effect.Fade); 113 assertEqual(3, Effect.Queue.effects.length); 114 115 Effect.Queue.each(function(e) { e.cancel() }); 116 assertEqual(0, Effect.Queue.effects.length); 117 118 // call with array 119 Effect.multiple(['test_1','test_3'],Effect.Puff); 120 assertEqual(2, Effect.Queue.effects.length); 121 }}, 122 123 testEffectTagifyText: function() { with(this) { 124 $('sandbox').innerHTML = "Blah<strong>bleb</strong> Blub"; 125 assertEqual(3, $('sandbox').childNodes.length); 126 Effect.tagifyText('sandbox'); 127 assertEqual(10, $('sandbox').childNodes.length); 128 129 Effect.multiple('sandbox', Effect.Fade); 130 assertEqual(10, Effect.Queue.effects.length); 39 131 }}, 40 132 … … 46 138 Builder.node('div',{id:'test_element'}, 47 139 [Builder.node('span','test')])); //some effects require a child element 48 var effect = new Effect[COMBINED_EFFECTS[j]]('test_element',{sync:true}); 140 141 // should work with new Effect.Blah syntax 142 var effect = new Effect[COMBINED_EFFECTS[j]]('test_element'); 143 assertEqual(0, effect.currentFrame); 144 145 // and without the 'new' 146 var effect = Effect[COMBINED_EFFECTS[j]]('test_element'); 49 147 assertEqual(0, effect.currentFrame); 50 148 } 149 }}, 150 151 testSynchronizedEffects: function() { with(this) { 152 var e1 = new Effect.Fade('sandbox',{sync:true}); 153 wait(250, function() { 154 // effect should still be at frame 0 155 assertEqual(0, e1.currentFrame); 156 assertEqual('idle', e1.state); 157 e1.render(0.01); 158 159 // no frame count for sync effects 160 assertEqual(0, e1.currentFrame); 161 assertEqual('running', e1.state); 162 }); 51 163 }}, 52 164 … … 57 169 }); 58 170 assertNull(testeffect.position); 171 assertEqual('idle', testeffect.state); 59 172 wait(1000, function() { 60 173 assertEqual('0.5', $('sandbox').innerHTML); 61 174 assertEqual(0.5, testeffect.position); 175 assertEqual('finished', testeffect.state); 62 176 }); 63 177 }}