Changeset 4796
- Timestamp:
- 08/20/06 18:05:58 (2 years ago)
- Files:
-
- spinoffs/scriptaculous/CHANGELOG (modified) (1 diff)
- spinoffs/scriptaculous/src/effects.js (modified) (5 diffs)
- spinoffs/scriptaculous/src/unittest.js (modified) (1 diff)
- spinoffs/scriptaculous/test/unit/effects_test.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/scriptaculous/CHANGELOG
r4785 r4796 1 1 *SVN* 2 3 * Added a custom exception to all base effects when used on non-existing DOM elements, added a assertRaise method to unit tests 2 4 3 5 * Fix autoscrolling when dragging an element unto a scrollable container, fixes #5017 [thx tomg] spinoffs/scriptaculous/src/effects.js
r4711 r4796 105 105 106 106 var Effect = { 107 _elementDoesNotExistError: { 108 name: 'ElementDoesNotExistError', 109 message: 'The specified DOM element does not exist, but is required for this effect to operate' 110 }, 107 111 tagifyText: function(element) { 108 112 if(typeof Builder == 'undefined') … … 355 359 initialize: function(element) { 356 360 this.element = $(element); 361 if(!this.element) throw(Effect._elementDoesNotExistError); 357 362 // make this work on IE on elements without 'layout' 358 363 if(/MSIE/.test(navigator.userAgent) && (!this.element.currentStyle.hasLayout)) … … 373 378 initialize: function(element) { 374 379 this.element = $(element); 380 if(!this.element) throw(Effect._elementDoesNotExistError); 375 381 var options = Object.extend({ 376 382 x: 0, … … 411 417 Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { 412 418 initialize: function(element, percent) { 413 this.element = $(element) 419 this.element = $(element); 420 if(!this.element) throw(Effect._elementDoesNotExistError); 414 421 var options = Object.extend({ 415 422 scaleX: true, … … 486 493 initialize: function(element) { 487 494 this.element = $(element); 495 if(!this.element) throw(Effect._elementDoesNotExistError); 488 496 var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); 489 497 this.start(options); spinoffs/scriptaculous/src/unittest.js
r4621 r4796 333 333 catch(e) { this.error(e); } 334 334 }, 335 assertRaise: function(exceptionName, method) { 336 var message = arguments[2] || 'assertRaise'; 337 try { 338 method(); 339 this.fail(message + ": exception expected but none was raised"); } 340 catch(e) { 341 (e.name==exceptionName) ? this.pass() : this.error(e); 342 } 343 }, 335 344 _isVisible: function(element) { 336 345 element = $(element); spinoffs/scriptaculous/test/unit/effects_test.html
r4229 r4796 48 48 testBackwardsCompat: function() { with(this) { 49 49 assertInstanceOf(Effect.Opacity, new Effect2.Fade('sandbox')); 50 }}, 51 52 testExceptionOnNonExistingElement: function() { with(this) { 53 assertRaise('ElementDoesNotExistError', 54 function(){new Effect.Opacity('nothing-to-see-here')}); 55 assertRaise('ElementDoesNotExistError', 56 function(){new Effect.Move('nothing-to-see-here')}); 57 assertRaise('ElementDoesNotExistError', 58 function(){new Effect.Scale('nothing-to-see-here')}); 59 assertRaise('ElementDoesNotExistError', 60 function(){new Effect.Highlight('nothing-to-see-here')}); 50 61 }}, 51 62