in partnership with mediatemple

Changeset 1540

Show
Ignore:
Timestamp:
04/21/08 09:53:03 (3 weeks ago)
Author:
kamicane
Message:
  • added code to fix the lack of function.caller in opera. Its not pretty, but its just for opera, and it only runs in opera. See the comments in the code.
  • removed additional usage of function.caller, as opera doesnt support it. No big deal, since it was used on internal methods for chaining. I'm now passing the function reference by hand in checks (its hideous, but its internal, so its all good).
  • added the parentOf method in class instances (aviable when you use Extends). To be used when you want to call another method's ancestor from a different method or closure.
Location:
trunk
Files:
10 modified

Legend:

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

    r1531 r1540  
    1414 
    1515        send: function(data){ 
    16                 if (!this.check(data)) return this; 
     16                if (!this.check(arguments.callee, data)) return this; 
    1717                return this.parent({url: this.url, data: {json: Json.encode(data)}}); 
    1818        }, 
  • trunk/Compatibility/Request/Request.js

    r1531 r1540  
    1919 
    2020        send: function(url, data){ 
    21                 if (!this.check(url, data)) return this; 
     21                if (!this.check(arguments.callee, url, data)) return this; 
    2222                return this.parent({url: url, data: data}); 
    2323        }, 
  • trunk/Source/Class/Class.js

    r1535 r1540  
    2222                                if (!this[mutator]) continue; 
    2323                                Class.Mutators[mutator](this, this[mutator]); 
     24                                delete this[mutator]; 
    2425                        } 
    2526 
     
    6364        var instance = new klass($empty); 
    6465         
     66        delete instance.parent; 
     67        delete instance.parentOf; 
     68         
    6569        for (var key in instance){ 
    6670 
     
    7781                 
    7882                switch (ctype){ 
    79                         case 'function': self[key]._parent_ = previous; break; 
     83                        case 'function':  
     84                         
     85                                // opera does not support function.caller, so we replace the function code with brute force. Not pretty, but its just for opera. 
     86                                // if future opera versions will support function.caller, this code wont be executed anymore. 
     87                                // this code will be only executed if the current browser does not support function.caller (only opera). 
     88                                 
     89                                if (!arguments.callee.caller) self[key] = eval('(' + current.toString().replace(/\bthis\.parent\((.*)\)/g, function(full, args){ 
     90                                        return 'arguments.callee._parent_.call(' + ((args) ? 'this, ' + args : 'this') + ')'; 
     91                                }) + ')'); 
     92                                 
     93                                //end "opera" code 
     94                         
     95                                self[key]._parent_ = previous; 
     96                        break; 
    8097                        case 'object': self[key] = $merge(previous, current); 
    8198                } 
     
    86103                return arguments.callee.caller._parent_.apply(this, arguments); 
    87104        }; 
     105         
     106        self.parentOf = function(descendant){ 
     107                return descendant._parent_.apply(this, Array.slice(arguments, 1)); 
     108        }; 
    88109 
    89110}; 
  • trunk/Source/Fx/Fx.Morph.js

    r1531 r1540  
    2929 
    3030        start: function(properties){ 
    31                 if (!this.check(properties)) return this; 
     31                if (!this.check(arguments.callee, properties)) return this; 
    3232                if (typeof properties == 'string') properties = this.search(properties); 
    3333                var from = {}, to = {}; 
  • trunk/Source/Fx/Fx.Tween.js

    r1531 r1540  
    2626 
    2727        start: function(property, from, to){ 
    28                 if (!this.check(property, from, to)) return this; 
     28                if (!this.check(arguments.callee, property, from, to)) return this; 
    2929                var args = Array.flatten(arguments); 
    3030                this.property = this.options.property || args.shift(); 
  • trunk/Source/Fx/Fx.js

    r1530 r1540  
    5353        }, 
    5454 
    55         check: function(){ 
     55        check: function(caller){ 
    5656                if (!this.timer) return true; 
    5757                switch (this.options.link){ 
    5858                        case 'cancel': this.cancel(); return true; 
    59                         case 'chain': this.chain(arguments.callee.caller.bind(this, arguments)); return false; 
     59                        case 'chain': this.chain(caller.bind(this, Array.slice(arguments, 1))); return false; 
    6060                } 
    6161                return false; 
     
    6363 
    6464        start: function(from, to){ 
    65                 if (!this.check(from, to)) return this; 
     65                if (!this.check(arguments.callee, from, to)) return this; 
    6666                this.from = from; 
    6767                this.to = to; 
  • trunk/Source/Plugins/Fx.Elements.js

    r1531 r1540  
    3434 
    3535        start: function(obj){ 
    36                 if (!this.check(obj)) return this; 
     36                if (!this.check(arguments.callee, obj)) return this; 
    3737                var from = {}, to = {}; 
    3838                for (var i in obj){ 
  • trunk/Source/Plugins/Fx.Scroll.js

    r1531 r1540  
    4949 
    5050        start: function(x, y){ 
    51                 if (!this.check(x, y)) return this; 
     51                if (!this.check(arguments.callee, x, y)) return this; 
    5252                var offsetSize = this.element.getSize(), scrollSize = this.element.getScrollSize(); 
    5353                var scroll = this.element.getScroll(), values = {x: x, y: y}; 
  • trunk/Source/Plugins/Fx.Slide.js

    r1531 r1540  
    5858 
    5959        start: function(how, mode){ 
    60                 if (!this.check(how, mode)) return this; 
     60                if (!this.check(arguments.callee, how, mode)) return this; 
    6161                this[mode || this.options.mode](); 
    6262                var margin = this.element.getStyle(this.margin).toInt(); 
  • trunk/Source/Request/Request.js

    r1530 r1540  
    9393        }, 
    9494 
    95         check: function(){ 
     95        check: function(caller){ 
    9696                if (!this.running) return true; 
    9797                switch (this.options.link){ 
    9898                        case 'cancel': this.cancel(); return true; 
    99                         case 'chain': this.chain(arguments.callee.caller.bind(this, arguments)); return false; 
     99                        case 'chain': this.chain(caller.bind(this, Array.slice(arguments, 1))); return false; 
    100100                } 
    101101                return false; 
     
    103103 
    104104        send: function(options){ 
    105                 if (!this.check(options)) return this; 
     105                if (!this.check(arguments.callee, options)) return this; 
    106106                this.running = true; 
    107107