in partnership with mediatemple

Changeset 1546

Show
Ignore:
Timestamp:
05/05/08 10:36:32 (6 days 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

Location:
trunk
Files:
32 modified

Legend:

Unmodified
Added
Removed
  • trunk/Compatibility/Request/Request.JSON.js

    r1540 r1546  
    1919         
    2020        failure: function(){ 
    21                 this.fireEvent('onFailure', this.xhr); 
     21                this.fireEvent('failure', this.xhr); 
    2222        } 
    2323 
  • trunk/Compatibility/Request/Request.js

    r1540 r1546  
    3030         
    3131        failure: function(){ 
    32                 this.fireEvent('onFailure', this.xhr); 
     32                this.fireEvent('failure', this.xhr); 
    3333        } 
    3434 
  • trunk/Demos/Fx.Slide/demo.js

    r1399 r1546  
    3737         
    3838        // When Vertical Slide ends its transition, we check for its status 
    39         // note that onComplete will not affect 'hide' and 'show' methods 
    40         myVerticalSlide.addEvent('onComplete', function() { 
     39        // note that complete will not affect 'hide' and 'show' methods 
     40        myVerticalSlide.addEvent('complete', function() { 
    4141                $('vertical_status').set('html', status[myVerticalSlide.open]); 
    4242        }); 
     
    7474         
    7575        // When Horizontal Slide ends its transition, we check for its status 
    76         // note that onComplete will not affect 'hide' and 'show' methods 
    77         myHorizontalSlide.addEvent('onComplete', function() { 
     76        // note that complete will not affect 'hide' and 'show' methods 
     77        myHorizontalSlide.addEvent('complete', function() { 
    7878                $('horizontal_status').set('html', status[myHorizontalSlide.open]); 
    7979        }); 
  • trunk/Demos/Sortables/index.html

    r1436 r1546  
    2525                The advanced example shows, that it is even possible to drag&drop list-elements 
    2626                into another list. 
    27         <p/> 
     27        </p> 
    2828        <div id="anotherSortablesDemo"> 
    2929         
  • 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: 
  • trunk/Docs/Fx/Fx.md

    r1443 r1546  
    4040### Events: 
    4141 
    42 * onStart               - (*function*) The function to execute when the effect begins. 
    43 * onCancel              - (*function*) The function to execute when you manually stop the effect. 
    44 * onComplete            - (*function*) The function to execute after the effect has processed. 
    45 * onChainComplete       - (*function*) The function to execute when using link 'chain' ([see options](#Fx:constructor)). It gets called after all effects in the chain have completed. 
     42* start                 - (*function*) The function to execute when the effect begins. 
     43* cancel                - (*function*) The function to execute when you manually stop the effect. 
     44* complete              - (*function*) The function to execute after the effect has processed. 
     45* chainComplete - (*function*) The function to execute when using link 'chain' ([see options](#Fx:constructor)). It gets called after all effects in the chain have completed. 
    4646 
    4747### Notes: 
     
    5959---------------------------- 
    6060 
    61 The start method is used to begin a transition.  Fires the onStart event. 
     61The start method is used to begin a transition.  Fires the 'start' event. 
    6262 
    6363### Syntax: 
     
    111111------------------------------ 
    112112 
    113 The cancel method is used to cancel a running transition.  Fires the onCancel event. 
     113The cancel method is used to cancel a running transition.  Fires the 'cancel' event. 
    114114 
    115115### Syntax: 
  • trunk/Docs/Plugins/Accordion.md

    r1516 r1546  
    4141## Events: 
    4242 
    43 ### onActive 
     43### active 
    4444 
    4545* (*function*) Function to execute when an element starts to show. 
     
    54542. element - (*element*) The Element being displayed. 
    5555 
    56 ### onBackground 
     56### background 
    5757 
    5858* (*function*) Function to execute when an element starts to hide. 
  • trunk/Docs/Plugins/Drag.Move.md

    r1538 r1546  
    3535### Events: 
    3636 
    37 * onDrop - Executed when the element drops. Passes as argument the element and the element dropped on. If dropped on nothing, the second argument is null. 
    38 * onLeave - Executed when the element leaves one of the droppables. 
    39 * onEnter - Executed when the element enters one of the droppables. 
     37* drop - Executed when the element drops. Passes as argument the element and the element dropped on. If dropped on nothing, the second argument is null. 
     38* leave - Executed when the element leaves one of the droppables. 
     39* enter - Executed when the element enters one of the droppables. 
    4040 
    4141### Example: 
  • trunk/Docs/Plugins/Drag.md

    r1505 r1546  
    3434### Events: 
    3535 
    36 * onBeforeStart - Executed before the Drag instance attaches the events. Receives the dragged element as an argument. 
    37 * onStart       - Executed when the user starts to drag (on mousedown). Receives the dragged element as an argument. 
    38 * onSnap        - Executed when the user has dragged past the snap option. Receives the dragged element as an argument. 
    39 * onDrag        - Executed on every step of the drag. Receives the dragged element as an argument. 
    40 * onComplete    - Executed when the user completes the drag. Receives the dragged element as an argument. 
     36* beforeStart - Executed before the Drag instance attaches the events. Receives the dragged element as an argument. 
     37* start       - Executed when the user starts to drag (on mousedown). Receives the dragged element as an argument. 
     38* snap        - Executed when the user has dragged past the snap option. Receives the dragged element as an argument. 
     39* drag        - Executed on every step of the drag. Receives the dragged element as an argument. 
     40* complete    - Executed when the user completes the drag. Receives the dragged element as an argument. 
    4141 
    4242### Examples: 
     
    126126------------------------------ 
    127127 
    128 Stops (removes) all attached events from the Drag instance and executes the onComplete Event. 
     128Stops (removes) all attached events from the Drag instance and executes the 'complete' Event. 
    129129 
    130130### Syntax: 
  • trunk/Docs/Plugins/Group.md

    r1464 r1546  
    2323 
    2424        var group = new Group(xhr1, xhr2, xhr3); 
    25         group.addEvent('onComplete', function(){ 
     25        group.addEvent('complete', function(){ 
    2626                alert('All Scripts loaded'); 
    2727        }); 
     
    4444###     Arguments: 
    4545 
    46 1. type - (*string*) The event name (e.g. 'onComplete') to add. 
     461. type - (*string*) The event name (e.g. 'complete') to add. 
    47472. fn   - (*function*) The callback function to execute when all instances fired this event. 
    4848 
  • trunk/Docs/Plugins/Scroller.md

    r1485 r1546  
    3030### Events: 
    3131 
    32 * onChange - (*function*) When the mouse reaches some boundaries, you can choose to alter some other values, instead of the scrolling offsets. 
     32* change - (*function*) When the mouse reaches some boundaries, you can choose to alter some other values, instead of the scrolling offsets. 
    3333 
    3434#### Signature: 
  • trunk/Docs/Plugins/Slider.md

    r1505 r1546  
    3333 
    3434 
    35 Slider Event: onChange {#Slider:onChange} 
     35Slider Event: change {#Slider:change} 
    3636----------------------------------------- 
    3737 
     
    4848 
    4949 
    50 Slider Event: onComplete {#Slider:onComplete} 
     50Slider Event: onComplete {#Slider:complete} 
    5151--------------------------------------------- 
    5252 
     
    6363 
    6464 
    65 Slider Event: onTick {#Slider:onTick} 
     65Slider Event: tick {#Slider:tick} 
    6666------------------------------------- 
    6767 
    68 * (*function*) Fires when the user drags the knob. This Event can be overriden to alter the onTick behavior. 
     68* (*function*) Fires when the user drags the knob. This Event can be overriden to alter the tick behavior. 
    6969 
    7070### Signature: 
     
    7878### Notes: 
    7979 
    80 - Slider originally uses the onTick event to set the style of the knob to a new position. 
     80- Slider originally uses the 'tick' event to set the style of the knob to a new position. 
    8181 
    8282### Returns: 
  • trunk/Docs/Plugins/Sortables.md

    r1544 r1546  
    2222### Events: 
    2323 
    24 * onStart    - function executed when the item starts dragging 
    25 * onSort     - function executed when the item is inserted into a new place in one of the lists 
    26 * onComplete - function executed when the item ends dragging 
     24* start    - function executed when the item starts dragging 
     25* sort     - function executed when the item is inserted into a new place in one of the lists 
     26* complete - function executed when the item ends dragging 
    2727 
    2828### Examples: 
  • trunk/Docs/Plugins/Tips.md

    r1485 r1546  
    2626### Options: 
    2727 
    28 * showDelay     - (*number*: defaults to 100) The delay the onShow method is called. 
    29 * hideDelay     - (*number*: defaults to 100) The delay the onHide method is called. 
     28* showDelay     - (*number*: defaults to 100) The delay the show event is fired. 
     29* hideDelay     - (*number*: defaults to 100) The delay the hide hide is fired. 
    3030* className     - (*string*: defaults to null) the className your tooltip container will get. Useful for extreme styling. 
    3131 * The tooltip element inside the tooltip container above will have 'tip' as classname. 
     
    3838### Events: 
    3939  
    40  * onHide: fires when the tip is shown 
    41  * onShow: fires when the tip is being hidden 
     40 * hide: fires when the tip is shown 
     41 * show: fires when the tip is being hidden 
    4242 
    4343### Example: 
     
    5252         
    5353 
    54 Tips Event: onShow {#Tips:onShow} 
     54Tips Event: show {#Tips:show} 
    5555--------------------------------- 
    5656 
     
    6767### Example: 
    6868 
    69         myTips.addEvent('onShow', function(tip){ 
     69        myTips.addEvent('show', function(tip){ 
    7070                tip.fade('in'); 
    7171        }); 
    7272 
    73 Tips Event: onHide {#Tips:onHide} 
     73Tips Event: hide {#Tips:hide} 
    7474--------------------------------- 
    7575 
     
    8686### Example: 
    8787 
    88         myTips.addEvent('onHide', function(tip){ 
     88        myTips.addEvent('hide', function(tip){ 
    8989                tip.fade('out'); 
    9090        }); 
  • trunk/Docs/Request/Request.HTML.md

    r1545 r1546  
    2626### Events: 
    2727 
    28 #### onComplete 
     28#### complete 
    2929 
    3030* (*function*) Function to execute when the HTML request completes. 
  • trunk/Docs/Request/Request.md

    r1504 r1546  
    3030---------------------------------------- 
    3131 
    32 ### onRequest 
     32### request 
    3333 
    3434(*function*) Function to execute when the Request is sent. 
     
    42421. instance - (Request) The transport instance. 
    4343 
    44 ### onSuccess 
     44### success 
    4545 
    4646(*function*) Function to execute when the Request completes. 
     
    55552. responseXML  - (*mixed*) The response XML from the request. 
    5656 
    57 ### onFailure 
     57### failure 
    5858 
    5959(*function*) Function to execute when the request fails (error status code). 
     
    6767instance - (Request) The transport instance. 
    6868 
    69 ### onException 
     69### exception 
    7070 
    7171(*function*) Function to execute when setting a request header fails. 
     
    80802. value      - (*string*) The value of the failing header. 
    8181 
    82 ###     onCancel 
     82###     cancel 
    8383 
    8484(*function*) Function to execute when a request has been cancelled. 
     
    9191 
    9292* running  - (*boolean*) True if the request is running. 
    93 * response - (*object*) Object with text and XML as keys. You can access this property in the onSuccess event. 
     93* response - (*object*) Object with text and XML as keys. You can access this property in the 'success' event. 
    9494 
    9595### Returns: 
  • trunk/Docs/Utilities/Swiff.md

    r1465 r1546  
    5151                }, 
    5252                events: { 
    53                         onLoad: myOnloadFunc 
     53                        load: myOnloadFunc 
    5454                } 
    5555        }); 
  • trunk/Source/Class/Class.Extras.js

    r1514 r1546  
    2828 
    2929        addEvent: function(type, fn, internal){ 
     30                type = Events.removeOn(type); 
    3031                if (fn != $empty){ 
    3132                        this.$events = this.$events || {}; 
     
    4344 
    4445        fireEvent: function(type, args, delay){ 
     46                type = Events.removeOn(type); 
    4547                if (!this.$events || !this.$events[type]) return this; 
    4648                this.$events[type].each(function(fn){ 
     
    5153 
    5254        removeEvent: function(type, fn){ 
     55                type = Events.removeOn(type); 
    5356                if (!this.$events || !this.$events[type]) return this; 
    5457                if (!fn.internal) this.$events[type].erase(fn); 
     
    6770}); 
    6871 
     72Events.removeOn = function(string){ 
     73        return string.replace(/^on([A-Z])/, function(full, first) { 
     74                return first.toLowerCase(); 
     75        }); 
     76}; 
     77 
    6978var Options = new Class({ 
    7079 
  • trunk/Source/Core/Core.js

    r1539 r1546  
    9494 
    9595(function(objects){ 
    96         for (var name in objects) Native.typize(objects[name], name.toLowerCase()); 
    97 })({'Boolean': Boolean, 'Native': Native, 'Object': Object}); 
     96        for (var name in objects) Native.typize(objects[name], name); 
     97})({'boolean': Boolean, 'native': Native, 'object': Object}); 
    9898 
    9999(function(objects){ 
     
    102102 
    103103(function(object, methods){ 
    104         for (var i = 0, l = methods.length; i < l; i++) Native.genericize(object, methods[i], true); 
     104        for (var i = methods.length; i--; i) Native.genericize(object, methods[i], true); 
    105105        return arguments.callee; 
    106106}) 
     
    142142 
    143143function $unlink(object){ 
    144         var unlinked = null; 
     144        var unlinked; 
    145145         
    146146        switch ($type(object)){ 
  • trunk/Source/Fx/Fx.js

    r1540 r1546  
    8383 
    8484        onStart: function(){ 
    85                 this.fireEvent('onStart', this.subject); 
     85                this.fireEvent('start', this.subject); 
    8686        }, 
    8787 
    8888        onComplete: function(){ 
    89                 this.fireEvent('onComplete', this.subject); 
    90                 if (!this.callChain()) this.fireEvent('onChainComplete', this.subject); 
     89                this.fireEvent('complete', this.subject); 
     90                if (!this.callChain()) this.fireEvent('chainComplete', this.subject); 
    9191        }, 
    9292 
    9393        onCancel: function(){ 
    94                 this.fireEvent('onCancel', this.subject).clearChain(); 
     94                this.fireEvent('cancel', this.subject).clearChain();