Changeset 1920


Ignore:
Timestamp:
2011-08-03 06:53:07 (10 months ago)
Author:
mpo
Message:

first stab at the refactoring suggested in #256

Location:
trunk
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/autocomplete/js/autocomplete.js

    r1771 r1920  
    1515 
    1616    function AutocompleteControl(id, form, conf) { 
    17         this['<super.init>'](id, form, conf); 
     17        kf.Control.init(this, id, form, conf); 
    1818    } 
    1919 
     
    2424             "<input type='text' kauri-role='input'/>" 
    2525    }); 
    26  
    27     AutocompleteControl.prototype.initType = function(conf) { 
    28         this["<super.call>"]("initType", [conf]); 
    29          
    30     } 
    3126 
    3227    AutocompleteControl.prototype.initElements = function(create) { 
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/color/js/color.js

    r1641 r1920  
    1919 
    2020    function ColorControl(id, form, conf) { 
    21         this['<super.init>'](id, form, conf); 
     21        kf.Control.init(this, id, form, conf); 
    2222    } 
    2323     
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/combobox/js/combobox.js

    r1680 r1920  
    2323   
    2424  function ComboboxControl(id, form, conf) { 
    25     this['<super.init>'](id, form, conf); 
     25    kf.Control.init(this, id, form, conf); 
    2626 
    2727    this.availableOptions = { 
     
    5555 
    5656  ComboboxControl.prototype.initType = function(conf) { 
    57       this["<super.call>"]("initType", [conf]); 
    58  
    5957      this.getType().multivalue = false; 
    6058  } 
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/dblselect/js/dblselect.js

    r1818 r1920  
    3434 
    3535    function DoubleSelectControl(id, form, conf) { 
    36         this['<super.init>'](id, form, conf); 
     36        kf.Control.init(this, id, form, conf); 
    3737 
    3838        this.availableOptions = { 
     
    7878 
    7979    DoubleSelectControl.prototype.initType = function(conf) { 
    80         this["<super.call>"]("initType", [conf]); 
    8180        // Force the field type to being multivalue 
    8281        this.getType().multivalue = true; 
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/radioselection/js/radioselection.js

    r1634 r1920  
    2020    function RadioSelectionControl( id, form, type) { 
    2121 
    22         this['<super.init>'](id, form, type); 
     22        kf.Control.init(this, id, form, type); 
    2323    } 
    2424 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/basic-controls.js

    r1918 r1920  
    2828    function InputControl( id, form, conf) { 
    2929 
    30         this['<super.init>'](id, form, conf); 
     30        kf.Control.init(this, id, form, conf); 
    3131    } 
    3232 
     
    104104    function OutputControl( id, form, conf) { 
    105105 
    106         this['<super.init>'](id, form, conf); 
     106        kf.Control.init(this, id, form, conf); 
    107107    } 
    108108 
     
    161161    function CheckBoxControl( id, form, type) { 
    162162 
    163         this['<super.init>'](id, form, type); 
     163        kf.Control.init(this, id, form, type); 
    164164    } 
    165165 
     
    239239    function SelectionControl( id, form, type) { 
    240240 
    241         this['<super.init>'](id, form, type); 
     241        kf.Control.init(this, id, form, type); 
    242242    } 
    243243 
     
    391391    function TextareaControl( id, form, type) { 
    392392 
    393         this['<super.init>'](id, form, type); 
     393        kf.Control.init(this, id, form, type); 
    394394    } 
    395395 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/basic-validators.js

    r1889 r1920  
    2626    // | scheme | :// | user:password @ | ip adrress | 3rd level domain 2nd level domain top level domain | :portnumber | path | 
    2727 
     28    kf.Validator.validateInt = function(me, value) { 
     29        if (value == undefined) 
     30            return me.notifySuccess(); 
     31 
     32        if (typeof value == 'number') 
     33            value = new Number(value); 
     34 
     35        if (value.constructor != Number || isNaN(value)) 
     36            return me.notifyFail("i18n:Not a number."); 
     37 
     38        var intValueStr = value.toFixed(0); 
     39        var valueStr = value.toString(); 
     40 
     41        if (intValueStr != valueStr) 
     42            return me.notifyFail("i18n:Not a valid integer!"); 
     43 
     44        return me.notifySuccess(); 
     45    } 
     46 
    2847    validators.putAll( { 
    2948 
    3049        "isInt" : { 
    3150            validate : function( value) { 
    32  
    33                 if (value == undefined) 
    34                     return this.notifySuccess(); 
    35  
    36                 if (typeof value == 'number') 
    37                     value = new Number(value); 
    38  
    39                 if (value.constructor != Number || isNaN(value)) 
    40                     return this.notifyFail("i18n:Not a number."); 
    41  
    42                 var intValueStr = value.toFixed(0); 
    43                 var valueStr = value.toString(); 
    44  
    45                 if (intValueStr != valueStr) 
    46                     return this.notifyFail("i18n:Not a valid integer!"); 
    47  
    48                 return this.notifySuccess(); 
     51                kf.Validator.validateInt(this, value); 
    4952            } 
    5053        }, 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/case.js

    r1879 r1920  
    2727    */ 
    2828    function CaseFieldType () { 
    29         this["<super.init>"](); 
     29        kf.FieldType.init(this); 
    3030    } 
    3131     
     
    127127    */ 
    128128    function CaseControl (id, form, conf) { 
    129         this["<super.init>"](id, form, conf); 
     129        kf.Control.init(this, id, form, conf); 
    130130    } 
    131131     
     
    207207        if (includeAll) 
    208208            return this._valueControls; 
    209         return this["<super.call>"]("getChildren"); 
     209        return kf.AbstractContainerControl.getChildren(this); 
    210210         
    211211    } 
     
    223223    CaseControl.prototype.getChild = function(id) { 
    224224        if (id == "case" || id == "value") { 
    225             return this["<super.call>"]("getChild", [id]); 
     225            return kf.AbstractContainerControl.getChild(this, id); 
    226226        } else if (id.substring(0,CASE_PFX.length)==CASE_PFX) { 
    227227            var caseName = id.substring(CASE_PFX.length, id.length); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/collection.js

    r1862 r1920  
    2424     * @constructor 
    2525     */ 
     26      
    2627    function CollectionFieldType() { 
    27         this['<super.init>'](); 
     28        kf.FieldType.init(this); 
    2829    } 
    2930 
     
    5758     */ 
    5859    function CollectionControl( id, form, conf) { 
    59         this['<super.init>'](id, form, conf); 
     60        kf.Control.init(this, id, form, conf); 
    6061    } 
    6162     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/composite.js

    r1597 r1920  
    2626    function CompositeFieldType() { 
    2727 
    28         this['<super.init>'](); 
     28        kf.FieldType.init(this); 
    2929    } 
    3030 
     
    7474    function CompositeControl( id, form, conf) { 
    7575 
    76         this['<super.init>'](id, form, conf); 
     76        kf.Control.init(this, id, form, conf); 
    7777    } 
    7878     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/control.js

    r1879 r1920  
    876876     */ 
    877877    function Control(id, form, conf){ 
    878         this._id = id; 
    879         this._form = form; 
     878        Control.init(this, id, form, conf);  
     879    } 
     880     
     881    Control.init = function(me, id, form, conf) { 
     882        me._id = id; 
     883        me._form = form; 
    880884         
    881885        if (conf != undefined) 
    882             this.initialize(conf); 
     886            me.initialize(conf); 
    883887    } 
    884888     
     
    895899    Control.prototype.initialize = function(conf){ 
    896900     
    897         this.initType(conf); 
     901        this._initType(conf); 
    898902         
    899903        this.initElementConfigs(); 
     
    908912    }; 
    909913     
     914 
     915     
    910916    /** 
    911917     * Initializes the 'type' from the configuration object passed in (if that didn't happen yet). 
     
    913919     * @final should not be overridden 
    914920     */ 
    915     Control.prototype.initType = function(conf){ 
     921    Control.prototype._initType = function(conf){ 
    916922     
    917923        var type; 
     
    923929        } 
    924930        this.setType(type); 
     931        this.initType(); 
     932    } 
     933     
     934    Control.prototype.initType = function(conf){ 
    925935    } 
    926936     
     
    19571967     */ 
    19581968    Control.prototype.hide = function(){ 
    1959         this.eachElement(function() { 
     1969        Control.hide(this); 
     1970    } 
     1971     
     1972    Control.hide = function(me) { 
     1973        me.eachElement(function() { 
    19601974            $(this).hide() 
    19611975        }); 
    1962         this.viewState = Control.STATE_HIDDEN; 
     1976        me.viewState = Control.STATE_HIDDEN; 
    19631977    } 
    19641978     
     
    19671981     */ 
    19681982    Control.prototype.show = function(){ 
    1969         this.eachElement(function() { 
     1983        Control.show(this); 
     1984    } 
     1985     
     1986    Control.show = function (me) { 
     1987        me.eachElement(function() { 
    19701988            $(this).show() 
    19711989        }); 
    1972         this.viewState = Control.STATE_VISIBLE; 
     1990        me.viewState = Control.STATE_VISIBLE; 
    19731991    } 
    19741992     
     
    19771995     */ 
    19781996    Control.prototype.enable = function(){ 
    1979         this.eachElement(function(){ 
     1997        Control.enable(this); 
     1998    } 
     1999    Control.enable = function(me) { 
     2000        me.eachElement(function(){ 
    19802001            var el = this; 
    19812002            if (el.is(":disabled")) { 
     
    19852006        });          
    19862007          
    1987         this.operationalState = Control.STATE_ENABLED; 
     2008        me.operationalState = Control.STATE_ENABLED; 
    19882009        // If the control isn't in STATE_INIT, we should re-validate to restore validation messages that may have been present when disable() was called 
    1989         if (this.valueState != Control.STATE_INIT) { 
    1990           this.newValidation(this.getValue(), this.getWireValue()); 
     2010        if (me.valueState != Control.STATE_INIT) { 
     2011          me.newValidation(me.getValue(), me.getWireValue()); 
    19912012        } 
    19922013    } 
     
    19962017     */ 
    19972018    Control.prototype.disable = function(){ 
    1998         this.eachElement(function(){ 
     2019        Control.disable(this); 
     2020    } 
     2021    Control.disable = function(me) { 
     2022        me.eachElement(function(){ 
    19992023            var el = this; 
    20002024            if (el.is(":enabled")) { 
     
    20042028        });          
    20052029         
    2006         this.clearMessage(); 
    2007         this.updateValidationClasses(); 
    2008         this.operationalState = Control.STATE_DISABLED; 
     2030        me.clearMessage(); 
     2031        me.updateValidationClasses(); 
     2032        me.operationalState = Control.STATE_DISABLED; 
    20092033    } 
    20102034     
     
    20852109    function AbstractContainerControl(id, form, conf){ 
    20862110     
    2087         this['<super.init>'](id, form, conf); 
     2111        Control.init(this, id, form, conf); 
    20882112    } 
    20892113 
     
    21452169    AbstractContainerControl.prototype.hide = function(){ 
    21462170        this.eachChild(function(i, child){ child.hide();}); 
    2147         this['<super.call>']('hide'); 
     2171        Control.hide(this); 
    21482172    } 
    21492173     
    21502174    AbstractContainerControl.prototype.show = function(){ 
    21512175        this.eachChild(function(i, child){ child.show();}); 
    2152         this['<super.call>']('show'); 
     2176        Control.show(this); 
    21532177    } 
    21542178 
    21552179    AbstractContainerControl.prototype.disable = function() { 
    21562180        this.eachChild(function(i, child){ child.disable();}); 
    2157         this['<super.call>']('disable'); 
     2181        Control.disable(this); 
    21582182    }; 
    21592183     
    21602184    AbstractContainerControl.prototype.enable = function() { 
    21612185        this.eachChild(function(i, child){ child.enable();}); 
    2162         this['<super.call>']('enable'); 
     2186        Control.enable(this); 
    21632187    }; 
    21642188     
     
    23982422     */ 
    23992423    AbstractContainerControl.prototype.getChildren = function(){ 
    2400      
    2401         return this._children; 
     2424        return AbstractContainerControl.getChildren(this); 
     2425    } 
     2426    AbstractContainerControl.getChildren = function(me) { 
     2427        return me._children; 
    24022428    } 
    24032429     
     
    24092435     */ 
    24102436    AbstractContainerControl.prototype.getChild = function(id){ 
    2411         return this._children[id]; 
     2437        return AbstractContainerControl.getChild(this, id); 
     2438    } 
     2439    AbstractContainerControl.getChild = function (me, id) { 
     2440        return me._children[id]; 
    24122441    } 
    24132442    AbstractContainerControl.prototype.getChildByPathSegment = function(pathSegment){ 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/date.js

    r1919 r1920  
    268268            minDate : undefined, // minimum date 
    269269            maxDate : undefined, // maximum date 
    270             step : 1, // we're using range as base we have to define steps 
    271             base : "range",  
    272270            validate : function (value) { 
    273271                if ($.isEmpty(value)) 
     
    277275                    return this.notifyFail(value + " is not a Date Object"); 
    278276                 
    279                 // set min & max using the amount of millis found in min/maxDate     
    280                 if (this.minDate != undefined && this.minDate.constructor == Date) this.min = this.minDate.getTime(); 
    281                 if (this.maxDate != undefined && this.maxDate.constructor == Date) this.max = this.maxDate.getTime(); 
    282                  
    283                 // use the validate function found in the range base validator to check if the amount of millis 
    284                 // in the date value is between the set min & max.     
    285                 this["<super.call>"]("validate", [value.getTime()]); 
     277                if (((this.minDate != undefined) && value < this.minDate) || ((this.maxDate != undefined) && value > this.maxDate) ) 
     278                    return this.notifyFail("i18n:Should be between {0} and {1}", [ this.minDate, this.maxDate ]); 
     279 
     280                return this.notifySuccess();                 
    286281            } 
    287282        }, 
     
    347342    $.inherit(DateControl, kf.Control); 
    348343    function DateControl( id, form, conf) { 
    349         this['<super.init>']( id, form, conf); 
     344        kf.Control.init(this, id, form, conf); 
    350345    } 
    351346     
     
    426421     
    427422    DateControl.prototype.enable = function(){ 
    428         this['<super.call>']('enable'); 
     423        kf.Control.enable(this); 
    429424        if(this.useDatePicker) { 
    430425            this.getElement().datepicker("enable"); 
     
    433428     
    434429    DateControl.prototype.disable = function(){ 
    435         this['<super.call>']('disable'); 
     430        kf.Control.disable(this); 
    436431        if(this.useDatePicker) { 
    437432            this.getElement().datepicker("disable"); 
     
    443438    $.inherit(DateRangeControl, kf.CompositeControl); 
    444439    function DateRangeControl( id, container, form, conf) { 
    445         this['<super.init>'](id, container, form, conf); 
     440        kf.Control.init(this, id, container, form, conf); 
    446441 
    447442        if (this.forceOrder == undefined) { 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/field.js

    r1916 r1920  
    343343     */ 
    344344    function FieldType() { 
    345  
     345        FieldType.init(this); 
     346    } 
     347    FieldType.init = function(me) { 
    346348    } 
    347349 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/form.js

    r1798 r1920  
    6363      }); // first trigger to execute. 
    6464 
    65       this['<super.init>'](id, form, conf); 
     65      kf.Control.init(this, id, form, conf); 
    6666 
    6767      this.initComplete( function() { 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/location.js

    r1577 r1920  
    3737    */ 
    3838    function GMapControl ( id, form, conf) { 
    39         this['<super.init>'](id, form, conf); 
     39        kf.Control.init(this, id, form, conf); 
    4040    } 
    4141     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/numeric-range.js

    r1518 r1920  
    6161     
    6262    kf.validators.put("isIntRange", { 
    63         base : "isInt", 
    6463        validate : function( value) { 
    6564     
     
    7069                 return this.notifyFail("Not a range."); 
    7170                  
    72             var response = this["<super.call>"]("validate", [value.start]); 
     71            var response = kf.Validator.validateInt(this, value.start); 
    7372            if(response == true) 
    74                 response = this["<super.call>"]("validate", [value.end]); 
     73                response = kf.Validator.validateInt(this, value.end); 
    7574                 
    7675            return response; 
     
    9190         
    9291    function SliderControl ( id, form, conf) { 
    93         this['<super.init>'](id, form, conf); 
     92        kf.Control.init(this, id, form, conf); 
    9493    } 
    9594    SliderControl.prototype.elements = {}; 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/registry.js

    r1856 r1920  
    307307 
    308308            var obj = this; 
    309             if ($.isFunction(customInit)) 
     309            if ($.isFunction(customInit)) { 
    310310                customInit.apply(obj, arguments); 
    311             else { 
    312                 var method = this['<super.init>']; 
    313                 method.apply(obj, arguments); 
     311            } else { 
     312                baseConstructor.apply(obj, arguments); 
    314313            } 
    315314        } 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/upload.js

    r1794 r1920  
    2929     */ 
    3030    function UploadControl(id, form, conf){ 
    31         this['<super.init>'](id, form, conf); 
     31        kf.Control.init(this, id, form, conf); 
    3232    } 
    3333     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/validator.js

    r1776 r1920  
    7272 
    7373    Validator.prototype.notify = function( result, msg) { 
     74        Validator.notify(this, result, msg); 
     75    } 
     76     
     77    Validator.notify = function(me, result, msg) { 
    7478 
    75         if (!this.listener || !this.seqId) 
     79        if (!me.listener || !me.seqId) 
    7680            return result; 
    7781 
    78         this.listener.report(this.seqId, result, msg); 
    79         this.clearSequence(); 
     82        me.listener.report(me.seqId, result, msg); 
     83        me.clearSequence(); 
    8084 
    8185        return result; 
     
    8387 
    8488    Validator.prototype.notifyFail = function( msg, args) { 
     89        Validator.notifyFail(this, msg, args); 
     90    } 
     91     
     92    Validator.notifyFail = function(me, msg, args) { 
    8593 
    86         msg = this.message || msg; 
     94        msg = me.message || msg; 
    8795        msg = kf.Message.build(msg, args, "Validator.notifyFail"); 
    88         return this.notify(false, msg); 
     96        return Validator.notify(me, false, msg); 
    8997    } 
    9098 
    9199    Validator.prototype.notifySuccess = function() { 
    92         return this.notify(true); 
     100        Validator.notifySuccess(this);  
     101    } 
     102    Validator.notifySuccess = function(me) { 
     103        return Validator.notify(me, true); 
    93104    } 
    94105     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/load/xdyna.js

    r447 r1920  
    99     
    1010    function XDyna(c) { 
    11         this.c = c; 
     11        XDyna.init(this,c); 
    1212    } 
    13          
     13 
     14    XDyna.init(me, c) { me.c = c ;} 
     15    $.XDyna = XDyna; 
     16             
    1417    XDyna.prototype.getC = function() {return this.c; };     
    1518    XDyna.prototype.check = "xdyna-loaded";     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-date.js

    r1919 r1920  
    190190        base : 'date-range' 
    191191    }; 
    192          
     192 
    193193    var form = new $.org.kauriproject.forms.Form($form, fconf); 
    194194 
     
    266266        base : fieldTypeName 
    267267    }; 
    268          
     268 
    269269    // create form 
    270270    var $form = $('<form />').appendTo($main); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-registry.js

    r802 r1920  
    66 
    77function XBase( x) { 
    8  
    9     this.x = x; 
    10 } 
     8    XBase.init(this, x); 
     9} 
     10 
     11XBase.init = function (me, x) { 
     12    me.x = x; 
     13} 
     14 
    1115XBase.prototype.getX = function() { 
    1216 
     
    7882        '<init>' : function( x, y) { 
    7983 
    80             this['<super.init>'](x); 
     84            XBase.init(this, x); 
    8185            this.y = y; 
    8286        }, 
     
    9599}); 
    96100 
    97  
     101function X2init(me) { 
     102    XBase.init(me, 0); 
     103} 
     104         
    98105test("testing a registered extension with constructor - normal instance", function() { 
    99106 
     
    101108    cr.put("x2", { 
    102109        base :"xbase", 
    103         '<init>' : function() { 
    104  
    105             this['<super.init>'](0); 
    106         }, 
     110        '<init>' : X2init, 
    107111        calc : function( b) { 
    108112 
     
    116120 
    117121 
     122function X3extra(me) { 
     123    return "ok"; 
     124} 
     125 
     126 
    118127test("testing a registered 2nd level extension with constructor - normal instance", function() { 
    119128 
     
    122131        base :"x2", 
    123132        '<init>' : function() { 
    124  
    125             this['<super.init>'](); 
    126         }, 
    127         extra : function() { 
    128  
    129             return "ok"; 
    130         } 
     133            X2init(); 
     134        }, 
     135        extra : X3extra 
    131136    }); 
    132137    var t = cr.getInstance("x3"); 
     
    149154        extra : function( b) { 
    150155 
    151             return "" + this['<super.call>']("extra") + this.calc(b); 
     156            return "" + X3extra(this) + this.calc(b); 
    152157        } 
    153158    }); 
     
    166171        '<init>' : function( y) { 
    167172 
    168             this['<super.init>'](); 
     173            X2init(); 
    169174            this.getY = function() { 
    170175 
     
    186191    function MyXBase( x, y) { 
    187192 
    188         this['<super.init>'](x); 
     193        XBase.init(this, x); 
    189194        this.y = y; 
    190195    } 
     
    229234                this.a = a; 
    230235                this.b = b; 
    231                 this['<super.init>'](c); 
     236                $.XDyna.init(this, c); 
    232237            }, 
    233238            calc : function( s) { 
     
    281286                    return this.data * y; 
    282287                } 
    283             }, 
    284  
     288            } 
     289            /* 
     290            , 
    285291            "myx" : { 
    286292                "<init>" : function() { 
     
    289295                } 
    290296            } 
     297            */ 
    291298        } 
    292299    }); 
  • trunk/modules/kauri-jquery/src/main/kauri/static-{build}.key/kauri.util/core.js

    r1602 r1920  
    201201    } 
    202202 
    203     var SUPER = "<super>"; 
    204     var SINIT = "<super.init>"; 
    205     var SCALL = "<super.call>"; 
    206     var STACK = "<super.call.stack>"; 
    207203    /** 
    208204     * Creates the necessary links between a sub-class deriving from a super-class 
     
    217213        if (!($.isFunction(subConstr) && $.isFunction(baseConstr))) 
    218214            return; 
    219  
    220         subConstr.prototype = new baseConstr(); 
    221         subConstr.prototype[SUPER] = baseConstr.prototype; 
     215             
     216        subConstr.prototype = new baseConstr();  
    222217        subConstr.prototype.constructor = subConstr; 
    223  
    224         subConstr.prototype[STACK] = []; 
    225         subConstr.prototype[SCALL] = SUPERCALL; 
    226         subConstr.prototype[SINIT] = SUPERINIT; 
    227     } 
    228  
    229     function SUPERINIT() { 
    230  
    231         this[SCALL]("constructor", arguments); 
    232     } 
    233  
    234     // TODO possibly add a check method $.isTypeOf(subInstance, baseConstrcutor) that allows checking if baseConstructor is 
    235     // somewhere in the '<super>' prototype chain 
    236  
    237     function SUPERCALL( methodName, argsArray) { 
    238  
    239         /* 
    240          * Note the hacking that is going on here. Since the called implementations can only refer to simply 'this' we manually 
    241          * addapt the actual current level of the parent-bubbling-up in a so called stack-variable on the object itself. Without 
    242          * this trick the calls to this['<super.init>'] would endlessly recurse to the initial constructor. 
    243          *  
    244          * Also note this implementation expects the execution to be absolutely single-threaded. Current implementation can fail 
    245          * in multithreaded environments. (Should be ok for javascript in browsers though) 
    246          */ 
    247  
    248         var me = this; 
    249         var stackPrototype = me[SUPER]; 
    250         if (methodName == undefined || stackPrototype == undefined) 
    251             return; 
    252  
    253  
    254         var restoreStack = me[STACK]; 
    255         if (restoreStack[0] == methodName) { 
    256             stackPrototype = restoreStack[1][SUPER]; 
    257         } 
    258  
    259  
    260         me[STACK] = [ methodName, stackPrototype ]; 
    261         var method = stackPrototype[methodName]; 
    262         // ie - jscript doesn't like it when the args passed are undefined 
    263         argsArray = argsArray || []; 
    264         var result = method.apply(me, argsArray); 
    265         me[STACK] = restoreStack; 
    266  
    267         return result; 
    268     } 
     218    } 
     219 
    269220 
    270221    /* ---------------------- debugging stuff ------------------------- */ 
  • trunk/modules/kauri-jquery/src/test/kauri.util/test-core.js

    r1915 r1920  
    5757 
    5858    function Base( x) { 
     59        Base.init(this,x); 
     60    } 
    5961 
    60         this.inits = {}; 
    61         this.x = x; 
    62         this.init(x); 
    63     } 
    64     Base.prototype.init = function( x) { 
    65  
    66         this.inits['x-deco'] = this.deco(x); 
     62    Base.init = function(me, x) { 
     63        me.x = x; 
     64        me.inits = {}; 
     65        me.inits['x-deco'] = me.deco(x); 
    6766    } 
    6867    Base.prototype.deco = function( x) { 
     
    7675    }; 
    7776    Base.prototype.fn = function(){ 
     77        return Base.fn(this); 
     78    } 
     79    Base.fn = function(me) { 
    7880        return "Base"; 
    7981    } 
     
    8183    $.inherit(Sub, Base); 
    8284    function Sub( x, y) { 
    83  
    84         this.y = y; 
    85         this['<super.init>'](x); 
     85        Sub.init(this, x, y); 
    8686    } 
     87     
     88    Sub.init = function(me, x, y) { 
     89        Base.init(me, x); 
     90        me.y = y; 
     91        me.inits['y-deco'] = me.deco(me.y); 
     92    } 
     93     
    8794    Sub.prototype.init = function( x) { 
    88  
    89         this['<super.call>']("init", [ x ]); 
    90         this.inits['y-deco'] = this.deco(this.y); 
     95        Sub.init(this,  x); 
    9196    } 
    9297    Sub.prototype.deco = function( x) { 
     
    100105    }; 
    101106    Sub.prototype.fn = function(){ 
    102         return this['<super.call>']("fn") + "Sub"; 
     107        return Base.fn(this) + "Sub"; 
    103108    } 
    104109 
     
    106111    function SubSub( x, y) { 
    107112 
    108         this['<super.init>'](x, y); 
     113        Sub.init(this, x, y); 
    109114    } 
    110115    SubSub.prototype.S = true; 
  • trunk/samples/kauri-tutorial-myblog/main-module/src/main/kauri/static/js/tagcontrol.js

    r1843 r1920  
    1515 
    1616    function TagControl(id, form, conf) { 
    17         this['<super.init>'](id, form, conf); 
     17        kf.Control.init(this, id, form, conf); 
    1818    } 
    1919 
     
    2424             "<input type='text' kauri-role='input'/>" 
    2525    }); 
    26  
    27     TagControl.prototype.initType = function(conf) { 
    28         this["<super.call>"]("initType", [conf]); 
    29          
    30     } 
    3126 
    3227    TagControl.prototype.getWireValue = function() { 
  • trunk/samples/kauri-tutorial-myblog/tinymce-module/src/main/kauri/static/forms/tinymce.js

    r1858 r1920  
    1515 
    1616    function TinyMCEControl(id, form, conf) { 
    17         this['<super.init>'](id, form, conf); 
     17        kf.Control.init(this, id, form, conf); 
    1818    } 
    1919 
     
    2424             "<textarea type='text' kauri-role='input'/>" 
    2525    }); 
    26  
    27     TinyMCEControl.prototype.initType = function(conf) { 
    28         this["<super.call>"]("initType", [conf]); 
    29          
    30     } 
    3126 
    3227    TinyMCEControl.prototype.initElements = function(create) { 
Note: See TracChangeset for help on using the changeset viewer.