Changeset 1546 for trunk/Docs/Class/Class.Extras.md
- Timestamp:
- 05/05/08 10:36:32 (1 week ago)
- Files:
-
- 1 modified
-
trunk/Docs/Class/Class.Extras.md (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Docs/Class/Class.Extras.md
r1309 r1546 140 140 141 141 A 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.142 In [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'. 143 143 Events in a Class that implements [Events](#Events) must be either added as an option or with addEvent, not directly through .options.onEventName. 144 144 … … 156 156 157 157 - 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). 159 159 160 160 ### Example: … … 163 163 Implements: Events, 164 164 initialize: function(element){ 165 ...165 // ... 166 166 }, 167 167 complete: function(){ 168 this.fireEvent(' onComplete');168 this.fireEvent('complete'); 169 169 } 170 170 }); 171 171 172 172 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'). 174 178 175 179 … … 191 195 ### Arguments: 192 196 193 1. type - (*string*) The type of event (e.g. ' onComplete').197 1. type - (*string*) The type of event (e.g. 'complete'). 194 198 2. fn - (*function*) The function to execute. 195 199 3. internal - (*boolean*, optional) Sets the function property: internal to true. Internal property is used to prevent removal. … … 202 206 203 207 var myFx = new Fx.Tween('element', 'opacity'); 204 myFx.addEvent('onStart', myStartFunction); 205 208 myFx.addEvent('start', myStartFunction); 206 209 207 210 … … 217 220 ### Arguments: 218 221 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.222 1. 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. 220 223 221 224 ### Returns: … … 227 230 var myFx = new Fx.Tween('element', 'opacity'); 228 231 myFx.addEvents({ 229 ' onStart': myStartFunction,230 ' onComplete': function() {232 'start': myStartFunction, 233 'complete': function() { 231 234 alert('Done.'); 232 235 } … … 246 249 ### Arguments: 247 250 248 1. type - (*string*) The type of event (e.g. ' onComplete').251 1. type - (*string*) The type of event (e.g. 'complete'). 249 252 2. args - (*mixed*, optional) The argument(s) to pass to the function. To pass more than one argument, the arguments must be in an array. 250 253 3. delay - (*number*, optional) Delay in miliseconds to wait before executing the event (defaults to 0). … … 260 263 initialize: function(arg1, arg2){ 261 264 //... 262 this.fireEvent(" onInitialize", [arg1, arg2], 50);265 this.fireEvent("initialize", [arg1, arg2], 50); 263 266 } 264 267 }); … … 277 280 ### Arguments: 278 281 279 1. type - (*string*) The type of event (e.g. ' onComplete').282 1. type - (*string*) The type of event (e.g. 'complete'). 280 283 2. fn - (*function*) The function to remove. 281 284 … … 300 303 ### Arguments: 301 304 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.305 1. type - (*string*, optional) The type of event to remove (e.g. 'complete'). If no type is specified, removes all events of all types. 303 306 304 307 ### Returns: … … 309 312 310 313 var myFx = new Fx.Tween('myElement', 'opacity'); 311 myFx.removeEvents(' onComplete');314 myFx.removeEvents('complete'); 312 315 313 316 … … 323 326 A Utility Class. Its methods can be implemented with [Class:implement][] into any [Class][]. 324 327 Used 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' ).328 Will 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). 326 329 327 330 ### Syntax: