in partnership with mediatemple

Changeset 1513

Show
Ignore:
Timestamp:
03/25/08 06:03:47 (2 months ago)
Author:
kamicane
Message:
  • enhanced aliases creation in Native. Now it accepts objects too, like Native:implement
  • added search and find aliases for Element, to alias getElements and getElement.
  • core: added hash as a type for $unlink.
  • Iframe: has no window property anymore, as it creates problems in some browsers.
  • memfree: added uid check before remove events, to remove some strict warnings.
  • docs: added documentation for Element:store and Element:retrieve
Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/Compatibility/Element/Element.js

    r1484 r1513  
    2121}); 
    2222 
    23 Element.alias('dispose', 'remove').alias('getLast', 'getLastChild'); 
     23Element.alias({'dispose': 'remove', 'getLast': 'getLastChild'}); 
    2424 
    2525Element.implement({ 
  • trunk/Compatibility/Native/Hash.js

    r1116 r1513  
    1 Hash.alias('getKeys', 'keys').alias('getValues', 'values').alias('has', 'hasKey'); 
     1Hash.alias({'getKeys': 'keys', 'getValues': 'values', 'has': 'hasKey'}); 
    22var Abstract = Hash; 
  • trunk/Source/Core/Core.js

    r1488 r1513  
    5252                return obj; 
    5353        }; 
    54  
     54         
    5555        object.implement = function(a1, a2, a3){ 
    5656                if (typeof a1 == 'string') return add(this, a1, a2, a3); 
     
    5858                return this; 
    5959        }; 
    60  
    61         object.alias = function(existing, property, force){ 
    62                 existing = this.prototype[existing]; 
    63                 if (existing) add(this, property, existing, force); 
     60         
     61        object.alias = function(a1, a2, a3){ 
     62                if (typeof a1 == 'string'){ 
     63                        a1 = this.prototype[a1]; 
     64                        if (a1) add(this, a2, a1, a3); 
     65                } else { 
     66                        for (var a in a1) this.alias(a, a1[a], a2); 
     67                } 
    6468                return this; 
    6569        }; 
     
    8387                return ($type(item) === family); 
    8488        }; 
     89}; 
     90 
     91Native.alias = function(objects, a1, a2, a3){ 
     92        for (var i = 0, j = objects.length; i < j; i++) objects[i].alias(a1, a2, a3); 
    8593}; 
    8694 
     
    140148                        unlinked = {}; 
    141149                        for (var p in object) unlinked[p] = $unlink(object[p]); 
     150                break; 
     151                case 'hash': 
     152                        unlinked = {}; 
     153                        object.each(function(p, v){ 
     154                                unlinked[p] = $unlink(v); 
     155                        }); 
    142156                break; 
    143157                case 'array': 
  • trunk/Source/Element/Element.js

    r1508 r1513  
    8484                        }); 
    8585                        if (host && host == window.location.host){ 
    86                                 iframe.window = iframe.contentWindow; 
    87                                 var win = new Window(iframe.window); 
    88                                 var doc = new Document(iframe.window.document); 
     86                                var win = new Window(iframe.contentWindow); 
     87                                var doc = new Document(iframe.contentWindow.document); 
    8988                                $extend(win.Element.prototype, Element.Prototype); 
    9089                        } 
     
    596595}); 
    597596 
     597Native.alias([Element, Document], {getElement: 'find', getElements: 'search'}); 
     598 
    598599Element.Attributes = new Hash({ 
    599600        Props: {'html': 'innerHTML', 'class': 'className', 'for': 'htmlFor', 'text': (Browser.Engine.trident) ? 'innerText' : 'textContent'}, 
     
    621622                Element.dispose(item); 
    622623        } 
    623         if (item.removeEvents) item.removeEvents(); 
     624        if (item.uid && item.removeEvents) item.removeEvents(); 
    624625}; 
    625626 
  • trunk/Source/Native/Hash.js

    r1483 r1513  
    133133}); 
    134134 
    135 Hash.alias('keyOf', 'indexOf').alias('hasValue', 'contains'); 
     135Hash.alias({keyOf: 'indexOf', hasValue: 'contains'});