in partnership with mediatemple

Show
Ignore:
Timestamp:
05/05/08 10:36:32 (1 week ago)
Author:
JanK
Message:
  • Class events should now be used without their on prefix, i.e. addEvent('onChainComplete', fn) becomes addEvent('chainComplete'). If you want to add events in the options you need to prefix them with 'on' now ('foo' -> 'onFoo').

Note: This is not a breaking change.

- other minor optimizations and doc fixes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Docs/Class/Class.Extras.md

    r1309 r1546  
    140140 
    141141A Utility Class. Its methods can be implemented with [Class:implement][] into any [Class][]. 
    142 In [Fx][], for example, this Class is used to allow any number of functions to be added to the Fx events, like onComplete, onStart, and onCancel. 
     142In [Fx][], for example, this Class is used to allow any number of functions to be added to the Fx events, like 'complete', 'start', and 'cancel'. 
    143143Events in a Class that implements [Events](#Events) must be either added as an option or with addEvent, not directly through .options.onEventName. 
    144144 
     
    156156 
    157157- This class can be implemented into other classes to add its functionality to them. 
    158 - Events has been designed to work well with the [Options](#Options) class when the option property begins with 'on' and is followed by a capital letter (e.g. 'onComplete'). 
     158- Events has been designed to work well with the [Options](#Options) class when the option property begins with 'on' and is followed by a capital letter it will be added as an event (e.g. 'onComplete' will add as 'complete' event). 
    159159 
    160160### Example: 
     
    163163                Implements: Events, 
    164164                initialize: function(element){ 
    165                         ... 
     165                        // ... 
    166166                }, 
    167167                complete: function(){ 
    168                         this.fireEvent('onComplete'); 
     168                        this.fireEvent('complete'); 
    169169                } 
    170170        }); 
    171171 
    172172        var myWidget = new Widget(); 
    173         myWidget.addEvent('onComplete', myFunction); 
     173        myWidget.addEvent('complete', myFunction); 
     174 
     175### Notes: 
     176 
     177- Events starting with 'on' are still supported in all methods and are converted to their representation without 'on' (e.g. 'onComplete' becomes 'complete'). 
    174178 
    175179 
     
    191195### Arguments: 
    192196 
    193 1. type     - (*string*) The type of event (e.g. 'onComplete'). 
     1971. type     - (*string*) The type of event (e.g. 'complete'). 
    1941982. fn       - (*function*) The function to execute. 
    1951993. internal - (*boolean*, optional) Sets the function property: internal to true. Internal property is used to prevent removal. 
     
    202206 
    203207        var myFx = new Fx.Tween('element', 'opacity'); 
    204         myFx.addEvent('onStart', myStartFunction); 
    205  
     208        myFx.addEvent('start', myStartFunction); 
    206209 
    207210 
     
    217220### Arguments: 
    218221 
    219 1. events - (*object*) An object with key/value representing: key the event name (e.g. 'onStart'), and value the function that is called when the Event occurs. 
     2221. events - (*object*) An object with key/value representing: key the event name (e.g. 'start'), and value the function that is called when the Event occurs. 
    220223 
    221224### Returns: 
     
    227230        var myFx = new Fx.Tween('element', 'opacity'); 
    228231        myFx.addEvents({ 
    229                 'onStart': myStartFunction, 
    230                 'onComplete': function() { 
     232                'start': myStartFunction, 
     233                'complete': function() { 
    231234                        alert('Done.'); 
    232235                } 
     
    246249### Arguments: 
    247250 
    248 1. type  - (*string*) The type of event (e.g. 'onComplete'). 
     2511. type  - (*string*) The type of event (e.g. 'complete'). 
    2492522. args  - (*mixed*, optional) The argument(s) to pass to the function. To pass more than one argument, the arguments must be in an array. 
    2502533. delay - (*number*, optional) Delay in miliseconds to wait before executing the event (defaults to 0). 
     
    260263                initialize: function(arg1, arg2){ 
    261264                        //... 
    262                         this.fireEvent("onInitialize", [arg1, arg2], 50); 
     265                        this.fireEvent("initialize", [arg1, arg2], 50); 
    263266                } 
    264267        }); 
     
    277280### Arguments: 
    278281 
    279 1. type - (*string*) The type of event (e.g. 'onComplete'). 
     2821. type - (*string*) The type of event (e.g. 'complete'). 
    2802832. fn   - (*function*) The function to remove. 
    281284 
     
    300303### Arguments: 
    301304 
    302 1. type - (*string*, optional) The type of event to remove (e.g. 'onComplete'). If no type is specified, removes all events of all types. 
     3051. type - (*string*, optional) The type of event to remove (e.g. 'complete'). If no type is specified, removes all events of all types. 
    303306 
    304307### Returns: 
     
    309312 
    310313        var myFx = new Fx.Tween('myElement', 'opacity'); 
    311         myFx.removeEvents('onComplete'); 
     314        myFx.removeEvents('complete'); 
    312315 
    313316 
     
    323326A Utility Class. Its methods can be implemented with [Class:implement][] into any [Class][]. 
    324327Used to automate the setting of a Class instance's options. 
    325 Will also add Class [Events](#Events) when the option property begins with 'on' and is followed by a capital letter (e.g. 'onComplete'). 
     328Will also add Class [Events](#Events) when the option property begins with 'on' and is followed by a capital letter (e.g. 'onComplete' adds a 'complete' event). 
    326329 
    327330### Syntax: